Compare commits

..

744 Commits
0.9 ... 1.0.2

Author SHA1 Message Date
Romain Quetiez
18529b1330 Official release 1.0.2
SVN:1.0.2[1056]
2011-01-19 10:01:55 +00:00
Denis Flaven
cb0610bf0b Readme for iTop 1.0.2
SVN:trunk[1055]
2011-01-18 11:38:24 +00:00
Denis Flaven
20ea4644b4 Remove an ambiguous naming when performing a CSV import of DBServerInstance objects.
SVN:trunk[1054]
2011-01-18 11:37:21 +00:00
Denis Flaven
fde336d8dd Cosmetics: make the login & change password form look the same on all browsers.
SVN:trunk[1053]
2011-01-18 09:07:46 +00:00
Denis Flaven
bc78b19ba7 Fixed Trac #348: no validation needed when pressing "Restart".
SVN:trunk[1052]
2011-01-18 09:00:26 +00:00
Denis Flaven
a4883076f8 Fixed Trac #338: when updating a 'dependent' field, don't forget to cascade the refresh in case this field has its own dependent fields.
SVN:trunk[1051]
2011-01-17 17:11:03 +00:00
Denis Flaven
57a0e2d47e Fixed Trac #345: hidden or read-only parameters in a form were not taken into account for computing the allowed values.
SVN:trunk[1050]
2011-01-17 15:13:28 +00:00
Denis Flaven
5a41992739 Trying to make CKEditor work with the "ExtKey" widget. (Trac #343)
Seems to be functional but there is still an "uncaught exception" that pops up from nowhere when closing the dialog.

SVN:trunk[1049]
2011-01-10 18:15:15 +00:00
Denis Flaven
15e07b69d6 Fixed Trac #341: broken form when an external key is part of the attrbiutes of an n-n link !
SVN:trunk[1048]
2011-01-10 18:07:54 +00:00
Denis Flaven
f6bfcb8355 Preparing the readme for the 1.0.2 release
SVN:trunk[1047]
2011-01-04 09:44:47 +00:00
Denis Flaven
019959504f Added the ability to (easily) attach files to a user request from the "portal" page. (French translation)
SVN:trunk[1046]
2011-01-04 09:35:17 +00:00
Denis Flaven
331b7ec2f0 Added the ability to (easily) attach files to a user request from the "portal" page.
SVN:trunk[1045]
2011-01-03 16:39:16 +00:00
Romain Quetiez
56ddf960a5 Readme for 1.0.2 -draft
SVN:trunk[1044]
2011-01-03 16:05:09 +00:00
Denis Flaven
35429228a2 Fixed a typo in German translation (Trac #339), thanks to ulmerspatz and Jonathan Lucas
SVN:trunk[1043]
2011-01-03 15:02:05 +00:00
Denis Flaven
78256bae0b - Display PHP errors during setup instead of hiding them ! (Trac #321)
- Set a longer timeout during setup (Trac #314)

SVN:trunk[1042]
2011-01-03 14:56:28 +00:00
Denis Flaven
8145c23899 Avoid using 'gethostname()' which is not always available.
SVN:trunk[1041]
2011-01-03 14:38:58 +00:00
Denis Flaven
3b629ab83c SVN:trunk[1040] 2011-01-03 13:46:06 +00:00
Denis Flaven
abc2c7b5e1 Small fix: using an unassigned variable.
SVN:trunk[1039]
2011-01-03 13:02:17 +00:00
Denis Flaven
e1d7e17c5d Added support for hierarchical ZLists when checking the data model consistency
SVN:trunk[1038]
2011-01-03 12:58:21 +00:00
Denis Flaven
64f452caba FIxed the processing of hierarchical ZLists to keep the display order when plain fields and fieldsets are mixed at the same level.
SVN:trunk[1037]
2011-01-03 12:56:07 +00:00
Denis Flaven
a8a77fdebb Make sure that the "+" (Create) button is never displayed for an abstract class.
SVN:trunk[1036]
2011-01-03 12:54:05 +00:00
Romain Quetiez
83e7e9c44b Chinese: added to the readme.txt
SVN:trunk[1035]
2010-12-20 13:47:06 +00:00
Romain Quetiez
6c73b3ed2e Localized in chinese
SVN:trunk[1034]
2010-12-20 13:44:15 +00:00
Romain Quetiez
adfed90733 Localized in turkish
SVN:trunk[1033]
2010-12-20 11:48:34 +00:00
Denis Flaven
c6a6af0aa2 Including approot is not needed here !
SVN:trunk[1032]
2010-12-20 11:45:38 +00:00
Denis Flaven
19463b370c - Updates to the Spanish localization
SVN:trunk[1031]
2010-12-20 11:30:16 +00:00
Denis Flaven
6bc3a80c8c - Small updates to the German localization
SVN:trunk[1030]
2010-12-20 11:28:50 +00:00
Denis Flaven
de4945bca6 - Added the russian localization (thanks to Vladimir Shilov)
SVN:trunk[1029]
2010-12-20 11:17:05 +00:00
Denis Flaven
6dd3eb9970 - Added the russian localization (thanks to Vladimir Shilov)
SVN:trunk[1028]
2010-12-20 11:13:54 +00:00
Denis Flaven
511c703b61 Bug fix: history of encrypted fields was not recorded properly.
SVN:trunk[1027]
2010-12-15 16:33:08 +00:00
Romain Quetiez
21722b9e80 Internal: added an API for logging tools events
SVN:trunk[1026]
2010-12-10 15:19:18 +00:00
Denis Flaven
203887589f - Yet another IE fix...
SVN:trunk[1025]
2010-12-10 13:58:12 +00:00
Denis Flaven
028f23214d - Fixed the CSV "confirmation pie chart" to work under IE & enhanced the look of the chart by removing unused values.
SVN:trunk[1024]
2010-12-10 13:43:55 +00:00
Romain Quetiez
b89a4d32d1 Improved the detection of MySQL Slave status
SVN:trunk[1023]
2010-12-09 10:04:38 +00:00
Romain Quetiez
b6883ed3b4 Internal: added an helper to get the currently loaded config file
SVN:trunk[1022]
2010-12-08 15:29:30 +00:00
Denis Flaven
6338775506 Split the usage of the iTop logo: one logo to be displayed internally (once logged) one externally (login/logoff).
SVN:trunk[1021]
2010-12-08 09:43:56 +00:00
Denis Flaven
25ea409228 Build the menus BEFORE the actual display of the page content... since the content is the result of a menu !
SVN:trunk[1020]
2010-12-07 19:54:27 +00:00
Denis Flaven
6a72ceb685 Patch for supporting a data model without any Person.
SVN:trunk[1019]
2010-12-07 15:24:16 +00:00
Denis Flaven
235203b3a0 The hyperlink to the online-help file is now configurable
SVN:trunk[1018]
2010-12-07 15:15:43 +00:00
Denis Flaven
2b9beb971b For fine-grained user rights detection...
SVN:trunk[1017]
2010-12-07 15:13:41 +00:00
Denis Flaven
5ff5e3f1a7 Patch for supporting a data model without any Person.
SVN:trunk[1016]
2010-12-07 15:06:17 +00:00
Denis Flaven
e3caff6689 Patch for supporting a data model without any Organization.
SVN:trunk[1015]
2010-12-07 14:55:40 +00:00
Romain Quetiez
59970be867 Menus created via a handler, at runtime
SVN:trunk[1014]
2010-12-07 14:32:13 +00:00
Romain Quetiez
98cfcc9cb8 Fixed an issue in the display of CSV imports history
SVN:trunk[1013]
2010-12-07 13:46:22 +00:00
Romain Quetiez
e66f06cda2 Internal: improved the user management API ChangePassword()
SVN:trunk[1012]
2010-12-06 17:07:07 +00:00
Romain Quetiez
35fe0b9ef5 Fixed bug in CSV sync mode (class given by the scope)
SVN:trunk[1011]
2010-12-06 15:58:37 +00:00
Romain Quetiez
cde184e2a3 Allow a module to provide a handler to override application settings: OnMetaModelStarted()
SVN:trunk[1010]
2010-12-06 09:14:20 +00:00
Denis Flaven
df8f4449e8 Fix for Trac #337: email validation. Use a simpler regular expression that is much faster to execute.
SVN:trunk[1009]
2010-12-03 12:03:05 +00:00
Romain Quetiez
b225b621b7 Cosmetic issue with the banner when the application is fully accessible
SVN:trunk[1008]
2010-12-03 10:28:25 +00:00
Romain Quetiez
d85aba8ebc Improved change tracking: user login replaced by the full name if available
Added a tab into the CSV import: browse the CSV imports history
Finalized the read-only mode (distinguish between users and everybody, admin message displayed on top of the main screen)

SVN:trunk[1007]
2010-12-03 10:18:28 +00:00
Denis Flaven
53d5867b93 Patch to support a different data model where contacts are not part of an org
SVN:trunk[1006]
2010-12-03 09:10:15 +00:00
Romain Quetiez
d4eaf43257 Fixed cosmetic issues in the CSV import (related to the recent changes)
SVN:trunk[1005]
2010-12-01 16:27:11 +00:00
Denis Flaven
dc96cbc482 - Ask for confirmation when doing a CSV import/synchro that is considered as "risky" (based on thresholds from the config file)
- Added a "Restart" button to quickly start over a CSV import/synchro

SVN:trunk[1004]
2010-12-01 15:21:29 +00:00
Denis Flaven
73e9107ae2 - Added the new "synchro" mode to the CSV load page.
SVN:trunk[1003]
2010-12-01 10:27:10 +00:00
Denis Flaven
9d1df1b799 - Bug fix: when creating a new object the "Cancel" button must go somewhere !
SVN:trunk[1002]
2010-11-30 15:55:40 +00:00
Romain Quetiez
018344578e Internal: BulkChange improved with synchro mode
SVN:trunk[1001]
2010-11-30 15:32:30 +00:00
Denis Flaven
bb4c6aecfa Added the capability to enable/disable menus based on the rights to apply a given stimulus.
SVN:trunk[1000]
2010-11-30 15:16:17 +00:00
Denis Flaven
06bb4a4f03 - Bug fix: support resizable elements inside tabs.
SVN:trunk[999]
2010-11-30 14:54:03 +00:00
Denis Flaven
dfe3ced440 - Provide some feedback while loading the "creation" dialog in case of a "SELECT".
SVN:trunk[998]
2010-11-30 14:27:11 +00:00
Denis Flaven
922d1dc734 Added the capability to enable/disable menus based on the rights to apply a given stimulus.
SVN:trunk[997]
2010-11-30 14:26:17 +00:00
Denis Flaven
bf2654409b Debug of the ExtKeyWidget...
SVN:trunk[996]
2010-11-30 13:51:46 +00:00
Denis Flaven
b6a001fedc - Cosmetics: prevent the extkey widget to warp.
SVN:trunk[995]
2010-11-30 13:22:12 +00:00
Denis Flaven
d8f2979c5a - Fixed Trac #318 (and #335): added the check of the mandatory DOM extension.
SVN:trunk[994]
2010-11-29 18:27:44 +00:00
Denis Flaven
7f8f4f5aab Exclude the special "data loader" tool from the standard build
SVN:trunk[993]
2010-11-29 15:33:27 +00:00
Romain Quetiez
653229b1bd XML data loader: fixed issue with transations
SVN:trunk[992]
2010-11-29 14:42:42 +00:00
Romain Quetiez
2b69c5210f Fixed issues in the compatibility with config files generated with 1.0
SVN:trunk[991]
2010-11-29 13:26:18 +00:00
Denis Flaven
7531dd8b19 Align properly the 'validation_error' icon in forms.
SVN:trunk[990]
2010-11-29 13:04:50 +00:00
Denis Flaven
49e101403f Small fix of unassigned variable when editing ext keys.
SVN:trunk[989]
2010-11-29 12:28:47 +00:00
Denis Flaven
d10c3ace5d Renamed 'autocompleteWidget' to 'extkeyWidget' since it's not always an autocomplete...
SVN:trunk[988]
2010-11-29 10:43:06 +00:00
Denis Flaven
4a6bc8a896 - added the ability to create objects pointed by ExtKeys even when the edit mode is a drop-down list and not an autocomplete
- made this behavior configurable globally or per external key, using the config-flag/option: allow_target_creation.

SVN:trunk[987]
2010-11-29 10:35:18 +00:00
Romain Quetiez
c428e07c4b XML data loader to request for credentials
SVN:trunk[986]
2010-11-29 10:19:33 +00:00
Romain Quetiez
540eb5f272 Moved the standards menus into the "welcome" module
SVN:trunk[985]
2010-11-29 09:17:44 +00:00
Romain Quetiez
699679318a Welcome menu (forgot at previous commit)
SVN:trunk[984]
2010-11-26 16:39:41 +00:00
Denis Flaven
4bd217d178 Keep backward compatibility with *old* config files without the 'webservices' entry in the config-file.
SVN:trunk[983]
2010-11-26 16:22:20 +00:00
Romain Quetiez
e37f6a0954 Welcome page moved out the application, into a dedicated module: itop-welcome-itil
SVN:trunk[982]
2010-11-26 15:59:41 +00:00
Romain Quetiez
9f000c15ff Cosmetic on setup: perform post DB install in the same page as admin account creation, and hide ticket prerequisites module
SVN:trunk[981]
2010-11-26 15:57:11 +00:00
Romain Quetiez
7d13ec00e4 User profiles: created in dedicated module itop-profiles-itil
SVN:trunk[980]
2010-11-26 15:55:38 +00:00
Denis Flaven
c8384cc8a4 Handle filtering of non-existent attributes in hierarchical ZLists.
SVN:trunk[979]
2010-11-26 13:25:00 +00:00
Denis Flaven
9e70feb29d - Fixed bug #334: proper handling of the "remove objects" button (was working only for the first linkset in the object).
- Improved feedback while searching and reloading added objects.

SVN:trunk[978]
2010-11-26 13:19:13 +00:00
Denis Flaven
ced4bf4259 - Fixed Trac #333: organizations' drop-down list is truncated on IE when the name of an organization is too long.
SVN:trunk[977]
2010-11-26 11:16:55 +00:00
Denis Flaven
51fa310664 - Fixed Trac #332: improved usability of the CSV import wizard with IE8.
SVN:trunk[976]
2010-11-26 10:43:25 +00:00
Romain Quetiez
64044e47e1 Modularity: allow a module to execute some specific installation procedures (customize the config file, do something in the database)
SVN:trunk[975]
2010-11-25 17:15:12 +00:00
Romain Quetiez
ebf9910579 #331 Import.php could not be run in HTTP mode (when PHP running in CGI mode) - fix getting more bullet proof
SVN:trunk[974]
2010-11-25 09:52:22 +00:00
Romain Quetiez
a60709a354 #331 Import.php could not be run in HTTP mode (when PHP running in CGI mode)
SVN:trunk[973]
2010-11-25 09:44:42 +00:00
Romain Quetiez
c63d25e223 Read-only mode relying successively on a DB property, and an application setting
SVN:trunk[972]
2010-11-24 16:52:55 +00:00
Romain Quetiez
7fbcdc407e Added class DBProperty
SVN:trunk[971]
2010-11-24 16:28:13 +00:00
Romain Quetiez
35c50d6689 Ajax pages: exceptions are traced into error.log
SVN:trunk[970]
2010-11-24 14:00:24 +00:00
Romain Quetiez
ff112faf5a Removed PHP "warning"
SVN:trunk[969]
2010-11-24 09:05:35 +00:00
Romain Quetiez
5ecbc66d7e Fixed regressions in the user portal
SVN:trunk[968]
2010-11-24 09:03:20 +00:00
Romain Quetiez
dc3a99200f Added an helper function to report the current configuration
SVN:trunk[967]
2010-11-23 17:07:51 +00:00
Romain Quetiez
40a613b4db Cleanup: replaced remaining occurences of ISO-8859-1
SVN:trunk[966]
2010-11-23 16:18:48 +00:00
Romain Quetiez
fcbd9b8911 Improved Web services: opened to services coming from an optional module
SVN:trunk[965]
2010-11-23 16:16:01 +00:00
Denis Flaven
9dd2061f60 Do not assume that a User is linked to a Person !
SVN:trunk[964]
2010-11-23 13:36:53 +00:00
Denis Flaven
2c4bdf6398 - Fixed the detection of relative path in the config file to make it compatible with *nix
SVN:trunk[963]
2010-11-23 11:54:41 +00:00
Romain Quetiez
d8bb6a45b2 REVIEWED THE FILE INCLUSION POLICY
- includes are relative to the application root folder, aka APPROOT
- changed the config file, while preserving the compatibility with older installs

SVN:trunk[962]
2010-11-22 17:53:52 +00:00
Romain Quetiez
d0f168adbb Read-only mode - draft
SVN:trunk[961]
2010-11-22 14:13:49 +00:00
Denis Flaven
b30d6c4888 - Safer way to pass information through the WizardHelper JS object.
- Removed an unneeded size=100% that bothers IE.

SVN:trunk[960]
2010-11-22 13:27:41 +00:00
Denis Flaven
ed39fa2c96 Continuing the 'autocomplete' debug.
SVN:trunk[959]
2010-11-22 13:21:45 +00:00
Denis Flaven
92045ef15f Continuing the 'autocomplete' debug.
SVN:trunk[958]
2010-11-22 12:52:29 +00:00
Denis Flaven
956ebb1962 Force a dummy timezone to prevent a warning during the setup...
SVN:trunk[957]
2010-11-22 12:36:38 +00:00
Denis Flaven
a1cc8deb47 Debugging of the autocomplete on IE8.
SVN:trunk[956]
2010-11-22 12:35:46 +00:00
Denis Flaven
0306c6691a - Implementing the creation of objects on the fly when editing an extrernal key... still to be fully tested.
SVN:trunk[955]
2010-11-22 10:44:43 +00:00
Romain Quetiez
d098bae484 French is french, not english
SVN:trunk[954]
2010-11-22 10:23:38 +00:00
Romain Quetiez
a524100d99 Fixed typo in French dictionary
SVN:trunk[953]
2010-11-22 10:20:09 +00:00
Romain Quetiez
cf888ea165 Added attribute types into the dictionary
SVN:trunk[952]
2010-11-22 10:06:52 +00:00
Romain Quetiez
8f7be02bc2 Clarified the states / attributes flags for the user requests
SVN:trunk[951]
2010-11-22 10:02:04 +00:00
Romain Quetiez
8e125cb743 Fixed issue in the lifecycle generation tool (escape double quotes)
SVN:trunk[950]
2010-11-19 15:34:11 +00:00
Denis Flaven
a97e2825b1 Make sure that each input field gets its own unique ID.
SVN:trunk[949]
2010-11-18 17:37:30 +00:00
Romain Quetiez
738d90d592 Regression on N-N links creation - passing over to Denis
SVN:trunk[948]
2010-11-18 17:09:02 +00:00
Denis Flaven
dc9a52c9e0 Improved implementation of the 'autocomplete' input and fix of quite a few related issue with aysnchronous inputs. Autocompletes are now restricted to external keys only.
Some details:
- Autocomplete now matches on 'contains' instead of 'begins with'
- The minimum size of this match is configurable in the config file and per attribute ('min_autocomplete_chars').
- The maximum size that turns a drop-down list into an autocomplete is configurable in the config-file and per attribute ('max_combo_length').
- Better feedback when expanding/collapsing search results lists.
- 'Pointer' cursor on the link to Expand/Collapse results lists.
- The 'mandatory' state of an attribute is no longer lost when some part of a form is reloaded asynchronously

SVN:trunk[947]
2010-11-18 16:41:09 +00:00
Romain Quetiez
5ea71a3d51 #320 Integrated an HTML Editor -still, no attribute has been changed, because it would require a migration procedure... to be continued
SVN:trunk[946]
2010-11-16 16:16:47 +00:00
Denis Flaven
8d80d73f35 - Allow DBObjects to be deleted by the standard UI 'Delete', which may be useful in case a DBObject has to be deleted as a dependent object of a CMDBObject.
SVN:trunk[945]
2010-11-16 13:21:21 +00:00
Denis Flaven
99907a92ea Use XMLPage passthrough mode to speed up and consume less memory for big XML exports.
SVN:trunk[944]
2010-11-12 16:49:47 +00:00
Denis Flaven
259b266a19 - Keep track of the object at the source of any email notification for further correlation (either in the user's mailbox or for automatic processing of incoming emails)
SVN:trunk[943]
2010-11-12 16:34:50 +00:00
Denis Flaven
effa212261 - Added a 'pre' method for transparent support of the CLI (Command Line Interface) mode.
SVN:trunk[942]
2010-11-12 16:28:17 +00:00
Denis Flaven
1a92a7b4f3 Ready for 1.0.1 release
SVN:trunk[940]
2010-11-03 15:33:46 +00:00
Romain Quetiez
4338bce526 Readme draft for 1.0.1
SVN:trunk[939]
2010-11-03 13:06:52 +00:00
Denis Flaven
4572bdbb02 Nicer display of the CSV import results...
SVN:trunk[938]
2010-11-02 16:33:26 +00:00
Denis Flaven
fcd72fed82 Fix for Trac #315: default organization not handled properly when there is just one organization allowed for the user.
SVN:trunk[937]
2010-11-02 16:30:46 +00:00
Romain Quetiez
1800120762 #311 CSV import: Improved the reporting on external keys (and changed a little the behavior)
SVN:trunk[936]
2010-11-02 16:29:41 +00:00
Denis Flaven
e5f0460703 AutoComplete usage: code cleanup
SVN:trunk[935]
2010-11-02 10:16:24 +00:00
Denis Flaven
72dbb9cb8f Fixed Trac #312: initial form validation for the "apply stimulus/change state" wizard.
SVN:trunk[934]
2010-11-02 09:29:55 +00:00
Romain Quetiez
562cfde587 #308 Free IPs: do not show the subnet address (the first one)
SVN:trunk[933]
2010-11-01 08:37:21 +00:00
Denis Flaven
6fe25d8b57 Fixed Trac #309 : Missing php-ofc-library files
SVN:trunk[932]
2010-10-29 11:11:09 +00:00
Romain Quetiez
248cdcea8c #286 Issue with HTTPS - reviewed the fix implemented in [896]
SVN:trunk[931]
2010-10-28 12:55:51 +00:00
Denis Flaven
0b95b3799e Fixed Trac #307: prevent form submission when the value typed into an autocomplete field does not correspond to a valid value.
SVN:trunk[930]
2010-10-26 08:12:31 +00:00
Denis Flaven
05a2443afe The previous fix for Trac #276 broke the auto mapping of external keys... now fixed.
SVN:trunk[929]
2010-10-25 17:05:12 +00:00
Denis Flaven
1860521e74 Fixed Trac #306: corrupted password when user creation fails at first attempt.
SVN:trunk[928]
2010-10-25 15:49:20 +00:00
Denis Flaven
8d39ddded6 Do not create a "mailto" hyperlink for empty email addresses.
SVN:trunk[927]
2010-10-25 14:27:48 +00:00
Denis Flaven
fd3317e99e Fixed the "Relationships" Flash navigator so that it works also on Safari. (tested with Safari 5.0.2 on Windows)
SVN:trunk[926]
2010-10-25 14:14:29 +00:00
Denis Flaven
7651aaed81 - Fixed the search form, and also fixed the search/selection of objects to link (n:n links) that was broken on IE8.
SVN:trunk[925]
2010-10-25 14:12:26 +00:00
Romain Quetiez
a5d2d067ff #284 Do not forget to adjust both upload_max_filesize AND post_max_size
SVN:trunk[924]
2010-10-25 11:33:48 +00:00
Denis Flaven
b27fda4cf5 German localization update. Thanks to ITOMIG.
SVN:trunk[923]
2010-10-25 08:19:50 +00:00
Romain Quetiez
2834c073cd #304 Fixed OQL issue (regression when using time intervals)
SVN:trunk[922]
2010-10-25 08:12:17 +00:00
Denis Flaven
97f36bd7e8 Fix to prevent IE 8 from running in IE7 compatibility mode... to be tested...
SVN:trunk[921]
2010-10-25 08:04:46 +00:00
Romain Quetiez
3d299f015b #246 Implemented the CLI mode for import.php
SVN:trunk[920]
2010-10-22 22:22:13 +00:00
Denis Flaven
8a5ed95c80 - Integrating the Brazilian transalation from Marco Tulio...
SVN:trunk[919]
2010-10-22 16:55:41 +00:00
Denis Flaven
f4b29d152b Special passthrough mode for big XML pages output.
SVN:trunk[918]
2010-10-22 16:46:53 +00:00
Denis Flaven
463bc0873b Allow n:n links to link several times to the same remote object (if "duplicates)=> true in the linkedset definition)
SVN:trunk[917]
2010-10-22 10:45:12 +00:00
Denis Flaven
368ea1cfdb SVN:trunk[916] 2010-10-22 10:42:39 +00:00
Denis Flaven
1b618ff57c (Partial) fix for Trac #285: turn email fields into click-able mailto: hyperlinks.
SVN:trunk[915]
2010-10-22 10:33:53 +00:00
Romain Quetiez
70149af5d6 Fixed a bug in the XML encoding function
SVN:trunk[914]
2010-10-22 07:47:05 +00:00
Denis Flaven
006453678b Fixed Trac#300: each iTop instance now uses its own name for the cookie storing the session ID. Therefore several instances can coexist independently on the same server.
SVN:trunk[913]
2010-10-22 06:09:51 +00:00
Denis Flaven
135353aa76 Fixed Trac #258: cleaner handling of search forms...
SVN:trunk[912]
2010-10-21 15:39:30 +00:00
Romain Quetiez
ddd52554f1 Fixed issues with the search form and context and page args... not finished
SVN:trunk[911]
2010-10-21 14:28:40 +00:00
Denis Flaven
22cf8e4986 Fixed Trac #292: enums can now be null (if allowed) !
SVN:trunk[910]
2010-10-21 09:23:41 +00:00
Denis Flaven
931075687a Fix for Trac #289: setup now checks that the "setup" directory is writeable.
SVN:trunk[909]
2010-10-20 16:20:52 +00:00
Denis Flaven
adaf3a376c Fixed Trac #258: cleanup of application context parameters.
SVN:trunk[908]
2010-10-20 15:55:30 +00:00
Romain Quetiez
1808e5fe65 Fixed #302, Ticket icons were not always displayed (+ error message on some installations)
SVN:trunk[907]
2010-10-20 14:48:45 +00:00
Romain Quetiez
cab0eb7758 #297 Fixed SOAP unit tests and improved the reporting when a reconciliation on an external key has failed
SVN:trunk[906]
2010-10-20 13:11:50 +00:00
Romain Quetiez
7e06dd100a #293 Added IP address in the lists of interfaces
SVN:trunk[905]
2010-10-20 10:35:36 +00:00
Denis Flaven
f145b872de - Implemented some hints to help users find out what are the mandatory fields for a CSV import (Trac #276). Though not 100% bullet-proof.
- Continue to implement support of hierarchical ZLists in modification forms.

SVN:trunk[904]
2010-10-19 15:03:24 +00:00
Denis Flaven
b66e489ec8 - Fixed Trac #298: use the proper content-type for CSV files to prevent the let the browser pick the most appropriate application to open such files.
SVN:trunk[903]
2010-10-19 14:15:25 +00:00
Denis Flaven
63da528882 Fixed Trac #245: Search form now retains the base class that was used when displaying the form. After searching a Person it is possible to select "Contact" and perform another search on Contacts.
SVN:trunk[902]
2010-10-19 14:07:14 +00:00
Denis Flaven
ff80b06ea2 - Fixed Trac #284: do not "consume" a transaction until it really worked.
SVN:trunk[901]
2010-10-19 13:42:54 +00:00
Denis Flaven
e9304bbcfa - new implementation (database independent) of the transaction mechanism, that prevents a user from submitting the same form twice.
SVN:trunk[900]
2010-10-19 13:20:23 +00:00
Romain Quetiez
0c34b47aac Fixed regression on the previous fix (change in the prototype of MakeQuery): this was impacting update/delete on a single object => applied to all objects of the same root class!
SVN:trunk[899]
2010-10-19 13:14:19 +00:00
Denis Flaven
484d4d1679 Fix Trac #296: Incorrect display of Service/Subcategory localized characters in the portal.
SVN:trunk[898]
2010-10-19 12:54:13 +00:00
Denis Flaven
4b5a25ea59 Fixed Trac #278: better detection of all PHP mandatory modules.
SVN:trunk[897]
2010-10-19 12:45:48 +00:00
Denis Flaven
7153162696 Fixed Trac #286: incorrect detection of HTTPS on IIS/ISAPI. Thanks to cprobst for reporting it.
SVN:trunk[896]
2010-10-19 12:34:33 +00:00
Romain Quetiez
fb59939d57 #288 Fixed OQL issues, related to multi-columns usages
SVN:trunk[895]
2010-10-14 16:56:42 +00:00
Romain Quetiez
629a87c99b #282 Fixed bug in OQL interpretation (functions requiring class aliasing)
SVN:trunk[894]
2010-10-13 19:51:36 +00:00
Romain Quetiez
3d4e0da019 Typo in dictionary (contract: start datA)
SVN:trunk[893]
2010-10-13 16:54:08 +00:00
Romain Quetiez
1e1e10aa00 #111 Improved the data loader, and added a REST service to load data from a file
SVN:trunk[892]
2010-10-13 16:36:51 +00:00
Romain Quetiez
0fff433e90 #283 Fixed issue with the default value of Enum attributes
SVN:trunk[891]
2010-10-13 08:23:05 +00:00
Romain Quetiez
05dbcb0a8b Fixed limitation: tickets named automatically even if a name is specified (attribute : ref) ; this is stopper when importing tickets from an existing workflow tool
SVN:trunk[890]
2010-10-12 16:04:09 +00:00
Romain Quetiez
bc6a3ab485 Fixed issues in DB integrity check
SVN:trunk[889]
2010-10-06 15:59:33 +00:00
Denis Flaven
53855d2d20 - German translation for the KEDB menus
SVN:trunk[887]
2010-09-17 08:52:27 +00:00
Erwan Taloc
5c132776e1 Spanish translation for Problem Management
SVN:trunk[886]
2010-09-17 07:46:36 +00:00
Denis Flaven
5e1645e46f - Reviewed the release note for 1.0 !
SVN:trunk[885]
2010-09-16 17:00:22 +00:00
Romain Quetiez
5d32f7ccf9 Reviewed the readme
SVN:trunk[884]
2010-09-16 13:37:23 +00:00
Romain Quetiez
4690d4f901 #272 Could not delete a user account
SVN:trunk[883]
2010-09-16 13:25:09 +00:00
Erwan Taloc
bc2e414e9b Update itop documentation for the setup
SVN:trunk[882]
2010-09-16 09:37:35 +00:00
Denis Flaven
ea84314337 - New announcement message at the end of the setup wizard
- Bug fix: The link to Combodo opens in another frame if clicked during the setup, so that it does not stop/break the setup

SVN:trunk[881]
2010-09-16 09:27:56 +00:00
Denis Flaven
7494ed5ea0 Better handling of unexpected/invalid characters in an UTF-8 file.
SVN:trunk[880]
2010-09-16 09:21:20 +00:00
Romain Quetiez
6f223fbba2 Reviewed the readme
SVN:trunk[879]
2010-09-16 08:12:47 +00:00
Denis Flaven
e95ff8f220 - Setup online help. First draft.
SVN:trunk[878]
2010-09-16 07:26:45 +00:00
Denis Flaven
af190fe93c - German localization fine tuning.
SVN:trunk[877]
2010-09-16 07:25:52 +00:00
Erwan Taloc
9e9dc0d692 Fix dictionnary issue for french translation in Known error
SVN:trunk[876]
2010-09-15 17:42:21 +00:00
Erwan Taloc
03ea418083 update Known Errors menu (except German and Spanish)
SVN:trunk[875]
2010-09-15 17:37:09 +00:00
Romain Quetiez
13c03aaf69 Readme, second draft
SVN:trunk[874]
2010-09-15 16:28:19 +00:00
Romain Quetiez
d1bd87ebc2 Draft of the release note for 1.0
SVN:trunk[873]
2010-09-15 16:11:00 +00:00
Romain Quetiez
746d2a1597 #267 Fixed a regression due to the change [866]
SVN:trunk[872]
2010-09-14 21:06:43 +00:00
Romain Quetiez
f85d1edf06 Fixed issue in create from mail
SVN:trunk[871]
2010-09-14 16:03:07 +00:00
Denis Flaven
8c3344d9c2 Bug fix: create the admin accounts with its linked profile (admin) in one operations since profiles are now mandatory when creating/updating a user.
SVN:trunk[870]
2010-09-14 10:43:50 +00:00
Denis Flaven
f4c3f71959 Better handling of two cases:
- user not authorized to see a particular request (not hers/his)
- user not authorized to use a service

SVN:trunk[869]
2010-09-14 09:17:06 +00:00
Denis Flaven
fed7742b88 - Enforce users to be created with at least one profile
SVN:trunk[868]
2010-09-14 09:10:29 +00:00
Denis Flaven
b124e94551 - Enforce users to be created with at least one profile
SVN:trunk[867]
2010-09-14 09:09:36 +00:00
Romain Quetiez
faed087790 #267 Added version information into modules authent-ldap and authent-local
SVN:trunk[866]
2010-09-14 08:54:01 +00:00
Romain Quetiez
c550d56227 #266 Transformed audit OQL definitions into genuine OQL Attributes
SVN:trunk[865]
2010-09-14 08:51:28 +00:00
Romain Quetiez
eab30f77e4 #266 OQL attributes changed into TEXT
SVN:trunk[864]
2010-09-14 08:44:36 +00:00
Denis Flaven
312bd1fb26 For support purposes: added a page that simply calls phpinfo()
SVN:trunk[863]
2010-09-14 08:43:30 +00:00
Denis Flaven
b0c34c5498 Dictionnaries fix !
SVN:trunk[862]
2010-09-14 08:41:22 +00:00
Denis Flaven
d41e826297 Fixed portal hyperlink
SVN:trunk[861]
2010-09-14 08:35:11 +00:00
Denis Flaven
da726cbe7f Small bug fix: testing an index out of bounds
SVN:trunk[860]
2010-09-14 08:34:20 +00:00
Denis Flaven
da19da2fe1 - New icon for Group objects
SVN:trunk[859]
2010-09-13 21:53:58 +00:00
Denis Flaven
fcabde1cc5 - Integrating the German localization thanks to Jonathan Lucas from Itomig !
SVN:trunk[858]
2010-09-13 21:39:23 +00:00
Erwan Taloc
8d55ae2f6f add related change in Problem life cycle
SVN:trunk[857]
2010-09-13 20:10:34 +00:00
Denis Flaven
c2bff5bb85 Better handling (and styling) of the menu separator in the "Actions" menu.
SVN:trunk[856]
2010-09-13 19:45:18 +00:00
Denis Flaven
d504fa4e1c - Sort the class hierarchy for easier reference
SVN:trunk[855]
2010-09-13 19:14:49 +00:00
Denis Flaven
3a9097df66 - Localization: fixed a typo in the dictionnary: the translations of URP_UserOrg were incorrect.
SVN:trunk[854]
2010-09-13 19:05:11 +00:00
Denis Flaven
822c79ce5e - Fixed the URL to the portal hyperlink (hyperlink(portal)) in email notifications.
SVN:trunk[853]
2010-09-13 18:55:30 +00:00
Denis Flaven
2e06fae105 - Make the portal web page scrollable.
- Support a per-customer stylesheet for tailoring the look of the portal.

SVN:trunk[852]
2010-09-13 17:04:56 +00:00
Denis Flaven
fc2143c7b0 Spanish localization fine tuning...
SVN:trunk[851]
2010-09-13 13:52:08 +00:00
Romain Quetiez
7e5681067f Different notification scheme for user requests
SVN:trunk[850]
2010-09-13 13:46:54 +00:00
Denis Flaven
9be9a1ef17 - Menu and templates have been reviewed.
SVN:trunk[849]
2010-09-13 13:36:50 +00:00
Romain Quetiez
1199109e43 Fixed issue in test page
SVN:trunk[848]
2010-09-13 13:13:23 +00:00
Erwan Taloc
5218c00708 review data model
SVN:trunk[847]
2010-09-13 12:40:26 +00:00
Romain Quetiez
15293fd250 Redirect from /pages/index.php to /index.php (to prevent users from listing the directory)
SVN:trunk[846]
2010-09-13 12:36:58 +00:00
Denis Flaven
1d0675ec9e - Network Interfaces are back into the sample data... and they can be interconnected !
SVN:trunk[845]
2010-09-13 12:36:56 +00:00
Romain Quetiez
8ed58f19c3 Benchmark page moved into test tools
SVN:trunk[844]
2010-09-13 12:07:13 +00:00
Romain Quetiez
b4d9389b5e SVN:trunk[843] 2010-09-13 12:03:59 +00:00
Romain Quetiez
a3ed0441e9 .... continuing the cleanup in test module
SVN:trunk[842]
2010-09-13 12:02:07 +00:00
Denis Flaven
d422d9a8cb - Adjusted user statisfaction enums, ticket priority enums (1 => high !) and fixed display lists in Service Management.
SVN:trunk[841]
2010-09-13 12:00:50 +00:00
Romain Quetiez
0a5baa85f4 Test tools reintroduced as a separate folder, most of the files being excluded from the std build
SVN:trunk[840]
2010-09-13 11:58:09 +00:00
Romain Quetiez
555dd76ade Test tools - removed references
SVN:trunk[839]
2010-09-13 11:49:38 +00:00
Romain Quetiez
b537a3e810 Removed automatic test tools (separate module)
SVN:trunk[838]
2010-09-13 11:45:57 +00:00
Erwan Taloc
4f45baae9d add object group of CI
SVN:trunk[837]
2010-09-13 10:29:00 +00:00
Romain Quetiez
4997c2148b Dispatched sample data for notifications (user requests vs incident tickets)
SVN:trunk[836]
2010-09-13 10:16:09 +00:00
Denis Flaven
eb81fcf9c7 - Fixed Trac #254: external fields specified as reconciliation keys were not automatically checked in the interactive mapping process.
SVN:trunk[835]
2010-09-13 10:09:34 +00:00
Romain Quetiez
6d0bc6d2c7 Implemented security in import.php
SVN:trunk[834]
2010-09-13 09:30:56 +00:00
Denis Flaven
6b78832b00 - Reorganized "Actions" menu to make them more logical and added some separators between groups of actions.
SVN:trunk[833]
2010-09-13 09:16:18 +00:00
Denis Flaven
801146a3e7 Oops, spanish localization file overwrote the english dictionnary for request management...
SVN:trunk[832]
2010-09-13 09:11:56 +00:00
Denis Flaven
da3ca07081 Removed blank lines or CR at the beginning of the files...
SVN:trunk[831]
2010-09-13 08:40:36 +00:00
Denis Flaven
c404aa854e - Some progress in the spanish localization.
SVN:trunk[830]
2010-09-13 07:39:17 +00:00
Denis Flaven
d40ebd1051 Transparent background for the "switch" icon.
SVN:trunk[829]
2010-09-12 21:07:27 +00:00
Denis Flaven
5d97891616 -Fix for sorting the tables and taking into account the fact that the first column is not sort-able when it contains checkboxes.
-Also adds icons (up/down arrows to indicate the current sort order).
- Last but not least fixes a number of problems when adding/removing linked objects the lists were not sorting or hilighting properly.

SVN:trunk[828]
2010-09-12 21:06:09 +00:00
Romain Quetiez
e3edf855eb Automatic test to create 1000 PCs
SVN:trunk[827]
2010-09-12 14:02:17 +00:00
Romain Quetiez
54ebdf332d #109 and #114 Record modules installations in DB
SVN:trunk[826]
2010-09-12 13:28:20 +00:00
Denis Flaven
f77364d520 Flash navigator enhancements:
- The tooltip is always at 1:1 scale even if the whole graph is zoomed out.
- Provide some feedback when an error occurs while loading the data (instead of spinning forever)

SVN:trunk[825]
2010-09-12 10:08:28 +00:00
Romain Quetiez
384c8c8ba9 #152 Data model consistency check reporting issues
SVN:trunk[824]
2010-09-12 08:43:48 +00:00
Romain Quetiez
fe8ebc6c31 Added an automatic test: stressing import.php
SVN:trunk[823]
2010-09-12 08:42:49 +00:00
Denis Flaven
e43ba5f2db - Bug fix: use serialize instead of ToOQL to pass a search to the ajax page, since the OQL string does not contain the query parameters. This caused the chart to fail to load.
SVN:trunk[822]
2010-09-12 07:57:44 +00:00
Denis Flaven
85dfd8527d - Completely revamped welcome page and configuration management overview in order to streamline the configuration menu.
SVN:trunk[821]
2010-09-11 20:37:42 +00:00
Denis Flaven
cfa54ccb43 Enhancement: provide a "list" view of the "impacts" and "depends on" results on top of the graphical view.
SVN:trunk[820]
2010-09-11 20:31:31 +00:00
Denis Flaven
d65d4a42bb Enhancement: provide a "list" view of the "impacts" and "depends on" results on top of the graphical view.
SVN:trunk[819]
2010-09-11 20:30:18 +00:00
Romain Quetiez
2ad6c0594d #162 Implemented the non interactive bulk load (REST, CLI not implemented)
SVN:trunk[818]
2010-09-11 13:36:16 +00:00
Denis Flaven
500767c582 Final touch !
SVN:trunk[817]
2010-09-10 19:50:45 +00:00
Romain Quetiez
1a4c3c98f1 Connect interfaces to each other (1-1 link)
SVN:trunk[816]
2010-09-10 18:51:09 +00:00
Romain Quetiez
dfb1ae83c7 Fixed issue on deletion: was not recursive, leading to data integrity issues
SVN:trunk[815]
2010-09-10 18:49:48 +00:00
Denis Flaven
f120e21e00 Code cleanup: proper usage of the ReadParam function.
SVN:trunk[814]
2010-09-10 14:11:30 +00:00
Denis Flaven
3cc9d99aca - Fixed Trac #254: use external fields as reconciliation keys.
SVN:trunk[813]
2010-09-10 13:28:04 +00:00
Romain Quetiez
efc6246346 Removed unused code (clone - security breach)
SVN:trunk[812]
2010-09-10 13:05:43 +00:00
Romain Quetiez
2a4e649fd8 #90 Added a comment to differentiate changes made by the CSV import tool
SVN:trunk[811]
2010-09-10 13:02:43 +00:00
Denis Flaven
f4283f8ebb - New menu to edit the Audit Category and Rules
SVN:trunk[810]
2010-09-10 11:59:37 +00:00
Romain Quetiez
0c4a030e2a Improved security
SVN:trunk[809]
2010-09-10 11:59:04 +00:00
Denis Flaven
50b6cd0012 - Enhancement (Trac#189) first version of a (simple) End-Users portal.
- Fix for the appUserPreferences class

SVN:trunk[808]
2010-09-10 11:23:09 +00:00
Denis Flaven
815de3bc2a - Enhancement (Trac#189) first version of a (simple) End-Users portal.
- Fix for the appUserPreferences class

SVN:trunk[807]
2010-09-10 11:20:23 +00:00
Denis Flaven
463e7b5413 - Enhancement (Trac#189) first version of a (simple) End-Users portal.
- Fix for the appUserPreferences class

SVN:trunk[806]
2010-09-10 10:10:57 +00:00
Romain Quetiez
7312d977f3 Notifications template may specify this->hyperlink(portal) (and fixed issues in sample data)
SVN:trunk[805]
2010-09-09 15:26:07 +00:00
Romain Quetiez
e9a84e1e84 Fixed cosmetic issues (block_id) and made sure the warning would never appear again
SVN:trunk[804]
2010-09-09 15:14:05 +00:00
Romain Quetiez
ad6669135c Fixed cosmetic issues is data model walker utility
SVN:trunk[803]
2010-09-09 14:57:38 +00:00
Romain Quetiez
1d1c7b44c5 Fixed bug: losing links profiles/user when editing profiles
SVN:trunk[802]
2010-09-09 14:15:32 +00:00
Romain Quetiez
5f497a55de New profile: Portal User (and link from a ticket to the user portal)
SVN:trunk[801]
2010-09-09 13:47:22 +00:00
Romain Quetiez
5070dd2abe #260 Restrict some pages to administrators
SVN:trunk[800]
2010-09-09 05:44:18 +00:00
Romain Quetiez
a3f4dad24e Added memory peak to the internal profiling instrumentation
SVN:trunk[799]
2010-09-08 20:01:06 +00:00
Romain Quetiez
3f0b5ca63a #123 Switch back to the InnoDB engine, which shows better performances (moreover we did far more testing with this engine)
SVN:trunk[798]
2010-09-08 13:47:45 +00:00
Denis Flaven
c91b99c6a3 - New Welcome popup message, displayed once per session at maximum.
SVN:trunk[797]
2010-09-08 08:23:52 +00:00
Romain Quetiez
32b337b9a8 #140 Check that user logins are unique
SVN:trunk[796]
2010-09-08 08:11:46 +00:00
Denis Flaven
39e943c20a - Fixing Trac #173. The unused states are now excluded from the graph.
- The path to graphviz installation (dot executable) is now configurable via the 'graphviz_path' config variable (defaults to /usr/bin/dot).
- If graphviz is present, the graph is generated on the fly, and using the current user's localization/translation for the state & transition names.

SVN:trunk[795]
2010-09-07 20:04:21 +00:00
Denis Flaven
306168c761 - FIxed Trac#21: comsetic enhancement to the final step of the CSV import wizard.
SVN:trunk[794]
2010-09-07 19:22:33 +00:00
Denis Flaven
c39ec1eec4 - Properly deactivate the creation of 1:n links while creating an object, since it is not possible to create such links at this time.
SVN:trunk[793]
2010-09-07 19:02:59 +00:00
Denis Flaven
d0e07c634a - Fixed bug #226: Back button no longer uses the history "back" which is too unpredictable.
SVN:trunk[792]
2010-09-07 16:17:09 +00:00
Denis Flaven
142a64dfc9 - Fixed bug #250: sorting truncated tables.
- Tables can now be sorted on the first column too (object name).

SVN:trunk[791]
2010-09-07 15:43:26 +00:00
Erwan Taloc
88643dab96 add reconciliation key for NEtwork Interface
SVN:trunk[790]
2010-09-07 15:39:58 +00:00
Denis Flaven
f68a00c5f6 - Fixed Trac #249: loosing links when modifying a SLA !
SVN:trunk[789]
2010-09-07 10:33:33 +00:00
Romain Quetiez
2aed08ccd3 #255 Added the profile "Problem Manager"
SVN:trunk[788]
2010-09-07 10:14:35 +00:00
Denis Flaven
82bcf663c4 Fixed Trac #252: pb when doing a CSV load with no header line.
SVN:trunk[787]
2010-09-07 08:10:49 +00:00
Romain Quetiez
de5d345e4e Grant Summary on profiles was saying no for everything
SVN:trunk[786]
2010-09-06 20:01:58 +00:00
Romain Quetiez
5b728dc6b8 #251 Allow configuration managers to modify/delete Contacts
SVN:trunk[785]
2010-09-06 16:56:54 +00:00
Romain Quetiez
a9bfaee2ef Fixed typo causing a warning on some PHP compilations
SVN:trunk[784]
2010-09-06 16:47:14 +00:00
Romain Quetiez
49d96e503f #205 Missing object hyperlink when using trigger on object creation
SVN:trunk[783]
2010-09-06 16:40:16 +00:00
Erwan Taloc
666eb3245a SVN:trunk[782] 2010-09-06 14:57:54 +00:00
Erwan Taloc
066b738f6a update
SVN:trunk[781]
2010-09-06 14:55:35 +00:00
Erwan Taloc
89154d14dd update with good status
SVN:trunk[780]
2010-09-06 14:54:31 +00:00
Romain Quetiez
73975a9531 Simplified user management by profile (optimization for viewing a huge list of objects)
SVN:trunk[779]
2010-09-06 14:42:57 +00:00
Denis Flaven
4c789e8fbb - Fixed bug #102: regression introduced with the encoding of passwords: users were no longer able to change their own password...
SVN:trunk[778]
2010-09-06 11:36:11 +00:00
Romain Quetiez
6ab797b03a Removed related_change_id/related_problem_id from standard searches because it might slow down the load of search forms when many tickets are in the DB
SVN:trunk[777]
2010-09-06 09:21:57 +00:00
Romain Quetiez
5c4614a3af Dehardcoded against the DB engine (now defaults to myisam)
SVN:trunk[776]
2010-09-06 09:15:26 +00:00
Denis Flaven
e965ba71b9 - Fixed the display of "Notifications"
- Rolled back, not to display menus on linkedset when not in edition mode

SVN:trunk[775]
2010-09-06 09:09:31 +00:00
Denis Flaven
8f982bc5bd Bug fix: make sure that the log is properly filled when creating a notification.
SVN:trunk[774]
2010-09-06 09:06:57 +00:00
Denis Flaven
da42afed88 Bug fix: escape dialog's title since it may contain quotes (especially in localized versions).
SVN:trunk[773]
2010-09-06 08:45:21 +00:00
Romain Quetiez
40eb8367a4 #233 Speed up data load, found a bottleneck, but still some room for improvement, added internal settings to boost up huge load or workaround a bug in CheckToWrite (if any)
SVN:trunk[772]
2010-09-05 22:20:28 +00:00
Denis Flaven
47e18d9927 - Handle expansion/truncation of objects lists as part of the browser navigation history... implemented only for "simple lists" (Trac #73)
SVN:trunk[771]
2010-09-05 20:54:53 +00:00
Denis Flaven
7d327b1395 - Fixed Trac #158: removed (Debug) message about "applying a stimulus" to an object. The page just says "Object updated" as for any other kind of update.
SVN:trunk[770]
2010-09-05 16:23:44 +00:00
Denis Flaven
633497d7ff - Fixing more accurately #222 and #172
SVN:trunk[769]
2010-09-05 15:49:25 +00:00
Denis Flaven
d892005e7f - Fixed Trac #224: properly validate non-mandatory integer fields.
SVN:trunk[768]
2010-09-05 13:20:09 +00:00
Denis Flaven
798558f331 - Fixed Trac #177: Icons for everything ! For Incidents, User Requests and Changes the icon depends on the state of the object.
SVN:trunk[767]
2010-09-05 12:55:21 +00:00
Denis Flaven
f522e06bce Typo in the localization... fixed.
SVN:trunk[766]
2010-09-05 12:52:50 +00:00
Denis Flaven
4ed6b76188 - Simplified Notifications page (Trac #163)
SVN:trunk[765]
2010-09-05 12:51:58 +00:00
Denis Flaven
cb98432f6d - Fixed bug #243. OQLMenuNodes can now auto-refresh. I've enabled this by default for the "shortcuts" of Helpdesk, Incident Management and Change Management
SVN:trunk[764]
2010-09-05 12:46:47 +00:00
Denis Flaven
775524824e - Added a try/catch to nicely handle exceptions in these pages.
- Fixed Trac #240: Validation of the fields when pressing the "Back" button
- Fixed Trac #238: JS Error when pressin the "Next" button

SVN:trunk[763]
2010-09-05 09:43:26 +00:00
Denis Flaven
573e7f4e31 - Fixed Trac #177: Icons for everything ! For Incidents, User Requests and Changes the icon depends on the state of the object.
SVN:trunk[762]
2010-09-05 09:13:28 +00:00
Romain Quetiez
b49373b959 #153 SOAP Web service broken due to violated integrity rule
SVN:trunk[761]
2010-09-05 07:29:33 +00:00
Romain Quetiez
8926e64bc2 #223 Trim spaces on CSV import was not handling well the last line
SVN:trunk[760]
2010-09-05 07:02:13 +00:00
Romain Quetiez
81cd840604 #234 Removed the error_reporting directive and implemented a workaround to reduce the potential warnings issued by PHP
SVN:trunk[759]
2010-09-03 22:20:16 +00:00
Romain Quetiez
d1a84bfbc1 #247 Missing query argument (CSV export failing, or Emailed URL not working for lists)
SVN:trunk[758]
2010-09-03 21:42:37 +00:00
Romain Quetiez
1432f1ffe5 Updated the benchmark page to the last change in data model
SVN:trunk[757]
2010-09-03 21:29:27 +00:00
Romain Quetiez
a9c0ba63df Optimizations: DBObjectSet::Count does it without loading all the data + possibility to specify LIMIT + restored the query cache (was inoperant) + improved the debug reports + added two settings (query_cache_enabled and debug_queries)
SVN:trunk[756]
2010-09-03 21:23:37 +00:00
Denis Flaven
65b669f27f - Simplified Notifications page (Trac #163)
SVN:trunk[755]
2010-09-03 13:16:12 +00:00
Denis Flaven
66ea947bc3 - Prevent menu itemshyperlinks to get highlighted
SVN:trunk[754]
2010-09-03 11:49:48 +00:00
Denis Flaven
d4be10528b - Added an icon for Network Devices
- Added more reconciliation keys (ext key of ext key!)
- Added an "organization" field to the Documents objects

SVN:trunk[753]
2010-09-03 11:31:17 +00:00
Denis Flaven
22b096de28 - Fixed bug#236: current value is now properly displayed in autcomplete fields, and the validation works properly too.
SVN:trunk[752]
2010-09-03 10:36:57 +00:00
Denis Flaven
6b728bbb50 From field is now mandatory
SVN:trunk[751]
2010-09-03 09:57:26 +00:00
Romain Quetiez
8c82b098c0 - Fixed bug #232: changing password was not working without the Javascript debugger !!!
SVN:trunk[750]
2010-09-02 17:09:10 +00:00
Denis Flaven
368b863aa3 - When sending email the "From" field is mandatory otherwise the mails are not sent.
SVN:trunk[749]
2010-09-02 16:53:12 +00:00
Romain Quetiez
15b805fed6 #242 loosing linked objects when modifying name attribute
SVN:trunk[748]
2010-09-02 16:51:41 +00:00
Denis Flaven
b1f877f845 Fixed bug #231: distinguish between external key (id) and external key (name) for loading fields that are external keys pointing to externla keys! Example: Connected To->Device is to be mapped to the Connected Interface's device NAME whereas Connected To->Device->id is to be mapped to the connected interface's device id
SVN:trunk[747]
2010-09-02 15:57:08 +00:00
Romain Quetiez
66c7d99c46 #239 Issue with character set (impacting searches with accents)
SVN:trunk[746]
2010-09-02 15:25:57 +00:00
Denis Flaven
400e2916d0 - Fixed the (cosmetic) bug #237: hyperlinks color.
SVN:trunk[745]
2010-09-02 11:24:31 +00:00
Denis Flaven
16baa35ad4 - Fixed a regression introduced by revision [737]
SVN:trunk[744]
2010-09-02 11:21:38 +00:00
Romain Quetiez
d813a7b10d Usability: reviewed navigation into the data model
SVN:trunk[743]
2010-09-02 06:26:11 +00:00
Romain Quetiez
3695475e9f Fixed bug: CSV import (interactive or web service) reporting change "on behalf of"
SVN:trunk[742]
2010-09-02 05:56:14 +00:00
Romain Quetiez
a36f50d490 Cosmetic: changed the name of views (removed the underscore prefix)
SVN:trunk[741]
2010-09-02 05:54:38 +00:00
Romain Quetiez
2a3bddf454 Usability: trim spaces in search forms
SVN:trunk[740]
2010-09-02 05:52:14 +00:00
Romain Quetiez
e31e23df7a Could not search on Contacts while being allowed to search on persons/teams
SVN:trunk[739]
2010-09-02 05:50:40 +00:00
Denis Flaven
b0d89dece3 - Sepcial corner case when loading objects with external keys and these externla keys themsleves have reconciliation keys that are also externla keys.
Example: On a person the field location_id
Can be specified by Location->Name and Location->Owner Organization (The 2 reconciliation keys for the class Location). The latter is also an external key, and therefore only an Id can be supplied for this field. Note that Location->Owner Organization->Name is not yet supported.

SVN:trunk[738]
2010-09-01 17:27:18 +00:00
Denis Flaven
22aef82b83 - Display the full list of attributes (details ZList) when exporting objects in HTML format (useful for Excel Web Queries).
SVN:trunk[737]
2010-09-01 10:52:08 +00:00
Denis Flaven
79ab5d6b75 - Add the field 'to' to a list of EmailNotificationEvents.
SVN:trunk[736]
2010-09-01 10:48:38 +00:00
Romain Quetiez
4894dd2b4c New placeholders in templates: this->html(attcode) and this->label(attcode)
SVN:trunk[735]
2010-09-01 09:07:01 +00:00
Romain Quetiez
77159e8766 Notification were not working well with class hierarchy (not in Trac at that time)
SVN:trunk[734]
2010-08-31 21:11:11 +00:00
Denis Flaven
1f6473947c - Fix: the menu "Helpdesk / Requests assigned to me" no longer shows the resolved or closed requests assigned to me.
SVN:trunk[733]
2010-08-31 16:43:31 +00:00
Denis Flaven
b9d168bb04 - Display the actual code of each state next to its label. This is useful for writing OQL queries and also triggers.
SVN:trunk[732]
2010-08-31 16:42:22 +00:00
Denis Flaven
7b82f17eed - Cosmetics: aligned screen titles with the "Next" label mentioned in the previous screen.
- All hyperlinks (in the setup) now point to a new tab/window so that you can continue to run the setup in the original window after reading what was displayed.

SVN:trunk[731]
2010-08-31 16:39:40 +00:00
Denis Flaven
8cd804c2ec - Bug fix: the "global search" can be launched from any page...
SVN:trunk[730]
2010-08-31 16:05:00 +00:00
Romain Quetiez
8fe9d25341 Improved benchmark tools
SVN:trunk[729]
2010-08-31 13:35:16 +00:00
Denis Flaven
3c7af6d37f -Fixed menu loading order bug.
SVN:trunk[728]
2010-08-31 09:34:08 +00:00
Romain Quetiez
ac0b302e75 #213 Reset external keys upon object deletion
SVN:trunk[727]
2010-08-31 08:19:26 +00:00
Denis Flaven
ce02a39157 - Fixed Trac #215: support several characters encoding for the interactive CSV import.
SVN:trunk[726]
2010-08-31 08:15:35 +00:00
Erwan Taloc
a17c123f08 Update KEDB and Problem Mgmt Modules
Review other modules

SVN:trunk[725]
2010-08-31 07:51:26 +00:00
Romain Quetiez
e75b6f8dbb Added KPI for send mail
SVN:trunk[724]
2010-08-31 07:34:53 +00:00
Romain Quetiez
b726430ba1 Cosmetic on trigger action link (in lists)
SVN:trunk[723]
2010-08-31 07:25:43 +00:00
Romain Quetiez
b7131ba4db Improved the internal KPI reporting tools
SVN:trunk[722]
2010-08-30 22:14:04 +00:00
Romain Quetiez
8a788acb9a #139 Improved string size verification, the rule is guaranteed by the core
SVN:trunk[721]
2010-08-30 16:11:46 +00:00
Denis Flaven
0d499ef03a - Fixed issue #157: Data Admin menu allowed only to admins and configuration managers
SVN:trunk[720]
2010-08-30 15:27:29 +00:00
Romain Quetiez
ab808ebf93 #223 Trim spaces in CSV parsing
SVN:trunk[719]
2010-08-30 15:18:14 +00:00
Romain Quetiez
8fc34a9fd5 #229 History data was limited (administrators could not see any attribute!)
SVN:trunk[718]
2010-08-30 14:26:40 +00:00
Romain Quetiez
97f26c05e4 Fixed isssue with final class recall, discovered when reintroducing the field Ticket::related_change_id
SVN:trunk[717]
2010-08-30 14:04:16 +00:00
Romain Quetiez
ed1abec39d Reordered class declaration (not supported on some systems)
SVN:trunk[716]
2010-08-30 13:32:21 +00:00
Denis Flaven
1d0f0231a4 - Fixed bug #225: improve friendliness of auto-complete
SVN:trunk[715]
2010-08-30 12:02:36 +00:00
Denis Flaven
d2bad7d0fd - Fixed regression #230: Mandatory fields no longer shown as mandatory.
- Fixed bug #139: input of strings is now limited to 255 characters in the user interface

SVN:trunk[714]
2010-08-30 11:23:02 +00:00
Denis Flaven
89be9163e4 - Removed some debug output
SVN:trunk[713]
2010-08-30 11:03:15 +00:00
Denis Flaven
388951c951 - First spanish localization (Many thanks to Randall Badilla Castro from Costa Rica)
SVN:trunk[712]
2010-08-30 06:44:14 +00:00
Romain Quetiez
75bbad57fa Optimized roughly the load of user management data, and added a mean for quick profiling (to enable, add the setting log_duration)
SVN:trunk[711]
2010-08-29 19:49:17 +00:00
Denis Flaven
e6bdaf87e7 - Updated flash navigator: better objects placement, auto-zoom & pan at startup, improved tooltip with some details on each objects.
SVN:trunk[710]
2010-08-29 19:38:36 +00:00
Denis Flaven
bd001f8072 - Better management of (truncated) list of linked objects (Trac #219)
- New type of display block to display some "actions" (New/Search) for a given class of objects.

SVN:trunk[709]
2010-08-27 15:34:47 +00:00
Denis Flaven
88efd37525 SVN:trunk[708] 2010-08-27 14:18:58 +00:00
Erwan Taloc
af90749778 Update of itop-config-mgmt model
SVN:trunk[707]
2010-08-27 13:11:31 +00:00
Romain Quetiez
283cbeddc0 Fixed bug: grant matrix apparently not updated (but it was) when modifying/creating a user account
SVN:trunk[706]
2010-08-26 17:23:31 +00:00
Denis Flaven
8e018e4d54 - Added special thanks section
SVN:trunk[705]
2010-08-26 15:50:20 +00:00
Denis Flaven
38fec49fe5 - First spanish localization (Many thanks to Randall Badilla Castro from Costa Rica)
SVN:trunk[704]
2010-08-26 15:46:23 +00:00
Romain Quetiez
ea33128df8 #227 Could not search on Server/asset_ref
SVN:trunk[703]
2010-08-26 09:51:30 +00:00
Denis Flaven
11be873fe4 - Fixed bug #222: properly setup dependent fields in the form when creating a new object.
SVN:trunk[702]
2010-08-25 16:35:35 +00:00
Romain Quetiez
ecd017a030 #200 ToOQL() was not working anytime an argument was set onto the Filter object
SVN:trunk[701]
2010-08-25 16:21:06 +00:00
Denis Flaven
b6b8c432a3 - Check for some optional extensions (mcrypt, ldap,...) during the setup at tell the user what are the consequences.
SVN:trunk[700]
2010-08-25 15:53:59 +00:00
Romain Quetiez
34cd4a01da Allowed were missing on LDAP/External user logins
SVN:trunk[699]
2010-08-25 15:27:44 +00:00
Romain Quetiez
7c91d266ea Typo in dictionary
SVN:trunk[698]
2010-08-25 15:18:03 +00:00
Romain Quetiez
b28735213d #137 #203 #204 #119 - Finalized the new (simplified) module for user rights management ; needed to review deeply the data integrity management to have the setup working again!
SVN:trunk[697]
2010-08-25 14:51:36 +00:00
Denis Flaven
911de05616 - Fixed Trac #217: can not log-off at the first login after setup.
SVN:trunk[696]
2010-08-24 15:17:51 +00:00
Romain Quetiez
68b5fc78c9 Finished implementing the user rights by profile (simple)
SVN:trunk[695]
2010-08-24 13:25:46 +00:00
Denis Flaven
9748f8a6b3 Allow the ADministrator to load more objects via CSV load (Users, Audit rules)
SVN:trunk[694]
2010-08-24 09:40:42 +00:00
Denis Flaven
d0cfd699a4 Fixed for Trac #223: when checking the value of an attribute also use the pattern matching defined at the atribute level itself to ensure consistency.
SVN:trunk[693]
2010-08-23 17:01:40 +00:00
Romain Quetiez
b3777568e6 Draft of the addon for user management by profile (simplified)
SVN:trunk[692]
2010-08-23 16:24:20 +00:00
Denis Flaven
3c8f4cca20 Put back exception handler !
SVN:trunk[691]
2010-08-23 16:19:19 +00:00
Denis Flaven
fa72a6f672 Bug fix: n-n links with no attributes on the link were not managed properly.
SVN:trunk[690]
2010-08-23 16:18:36 +00:00
Denis Flaven
1b9174ef17 - Fixed Trac #218: direct URL to an object was too long. Now use the shorter version (?operation=details&class=xxx&id=yyy&menu=zzz)
SVN:trunk[689]
2010-08-23 13:22:43 +00:00
Romain Quetiez
b4b4d7980e SVN:trunk[688] 2010-08-23 13:21:33 +00:00
Romain Quetiez
646128e3dd Removed unused user management tools
SVN:trunk[687]
2010-08-23 13:17:42 +00:00
Romain Quetiez
95b27bfcf4 Reviewed benchmark tool (split creation of structure / CIs / Tickets)
SVN:trunk[686]
2010-08-23 13:03:18 +00:00
Romain Quetiez
80439759b7 Finalized module userrightsprofile
SVN:trunk[685]
2010-08-23 13:02:09 +00:00
Denis Flaven
a7799e524a - Objects filtering (read) is now performed by the core directly, no need to check further which objects in a set are read-able. Only those that can be read are returned.
SVN:trunk[684]
2010-08-23 12:54:27 +00:00
Denis Flaven
7aacef8d7d - Get rid of the class UserContext, since now everything is implemented directly in MetaModel
- Make the Accordion menu collapsible

SVN:trunk[683]
2010-08-23 12:27:21 +00:00
Romain Quetiez
a33dfa9f10 updated benchmark procedure
SVN:trunk[682]
2010-08-19 14:04:22 +00:00
Romain Quetiez
b555f104df Improved user rights management: SELECT filtered on objects authorized for the current user (not yet fully implemented)
SVN:trunk[681]
2010-08-19 13:08:42 +00:00
Romain Quetiez
2387176142 Improved the benchmarking utility
SVN:trunk[680]
2010-08-18 22:21:39 +00:00
Romain Quetiez
f59cdc523b #208 Missing email notification tabs for tickets - now automatically added for any class
SVN:trunk[679]
2010-08-18 14:09:39 +00:00
Romain Quetiez
fd8184ade7 #202 audit samples not working
SVN:trunk[678]
2010-08-18 10:36:16 +00:00
Romain Quetiez
b4807be4bf Updated benchmark tool and sample data with new data model names and attributes
SVN:trunk[677]
2010-08-16 14:51:55 +00:00
Romain Quetiez
02dd08587c #205 Notifications missing external fields (on object creation)
SVN:trunk[676]
2010-08-16 14:49:36 +00:00
Romain Quetiez
ad1cf8f658 Cosmetic: configuration module rendering booleans anytime
SVN:trunk[675]
2010-08-16 14:47:56 +00:00
Romain Quetiez
954b1a3779 Fixed issue with sample data for notifications: losing links when enabling an email notification
SVN:trunk[674]
2010-08-16 14:46:25 +00:00
Denis Flaven
28cfa56c95 - Fixed bug #197: incorrect validation of textarea fields
SVN:trunk[673]
2010-08-10 18:45:24 +00:00
Denis Flaven
c08c12bb72 - Fixed Trac #196: root menu nodes are no longer hyperlink, thus cannot be opened in a new window/tab.
SVN:trunk[672]
2010-08-10 18:38:01 +00:00
Denis Flaven
9eba34362c - Fixing Trac #188... new flag https_hyperlinks with a slightly different meaning: produce https hyperlinks even if the current page is NOT https.
SVN:trunk[671]
2010-08-10 17:10:39 +00:00
Denis Flaven
73458617bf - Integrated fix for patch #188 - ForceHttps = SecureConnectionRequired
SVN:trunk[670]
2010-08-10 16:53:28 +00:00
Denis Flaven
5b0c1e3003 - Integrated all the authentications methods and various logon methods...
SVN:trunk[669]
2010-08-10 16:38:55 +00:00
Denis Flaven
e3d0212802 - Integrated all the authentications methods and various logon methods...
SVN:trunk[668]
2010-08-09 11:48:07 +00:00
Denis Flaven
ed7fdf45e2 - New authentification module to support "external" authentication, i.e. when the authentication is done outside of iTop (for example by the web server itself using a .htaccess file)
SVN:trunk[667]
2010-08-09 11:47:31 +00:00
Denis Flaven
1c3e111c9d Fixed bug #159: pattern matching too strict for URL fields.
SVN:trunk[666]
2010-08-09 11:44:14 +00:00
Denis Flaven
272387d61e - Integrated all the authentications methods and various logon methods...
SVN:trunk[665]
2010-08-09 10:19:14 +00:00
Denis Flaven
cdf9812fbe Fix: actions were all recorded with 'user' on behalf of 'user' as if the user was impersonated...
SVN:trunk[664]
2010-08-06 07:50:11 +00:00
Denis Flaven
db8c287925 - Fixed the problem of initial (default) values (Trac #172) when creating an object by factorizing: creation / modification and cloning of objects !
SVN:trunk[663]
2010-08-05 17:10:35 +00:00
Denis Flaven
9a70c6f82d Sample for creating tickets by reading a incoming emails in a mailbox
SVN:trunk[662]
2010-08-05 12:33:34 +00:00
Denis Flaven
9e618d466a - Minor fixes...
SVN:trunk[661]
2010-08-05 12:31:07 +00:00
Denis Flaven
d6e1ccfee3 - Fixed bug Trac #210 (Incorrect error message in case of uploading a file too big)
SVN:trunk[660]
2010-08-05 12:21:50 +00:00
Denis Flaven
279e0238cb - New implementation of the n-n link edition widget... almost complete.
SVN:trunk[659]
2010-08-05 09:07:14 +00:00
Denis Flaven
422ac56260 - New implementation of the n-n link edition widget... in progress.
SVN:trunk[658]
2010-08-04 20:10:20 +00:00
Denis Flaven
fd9e971ecb - New implementation of the n-n link edition widget... in progress.
SVN:trunk[657]
2010-08-04 20:08:02 +00:00
Denis Flaven
37bc87e705 - New implementation of the n-n link edition widget... in progress.
SVN:trunk[656]
2010-08-04 20:07:07 +00:00
Denis Flaven
2df7884289 Fixing Trac #209 (default_language setting not used properly)
SVN:trunk[655]
2010-08-04 19:55:11 +00:00
Denis Flaven
b0b3330c13 - New implementation of the n-n link edition widget... in progress.
SVN:trunk[654]
2010-08-04 19:30:36 +00:00
Denis Flaven
835d54b22b Exclude createfrommail.php from the build, since it is more a sample than some production quality code.
SVN:trunk[653]
2010-08-04 19:27:23 +00:00
Denis Flaven
b9887bac8c - New implementation of the n-n link edition widget... in progress.
SVN:trunk[652]
2010-08-04 18:43:17 +00:00
Denis Flaven
f9a271b9d3 - Sample "web service" (REST) page to create a User Request ticket by reading new messages in a POP3 mailbox
SVN:trunk[651]
2010-08-03 13:54:39 +00:00
Romain Quetiez
b4bd496ca3 Added a comment...
SVN:trunk[650]
2010-07-30 14:43:52 +00:00
Romain Quetiez
a08ae40dc9 #150 Review TTO/TTR computation (generalized to ResponseTicket)
SVN:trunk[649]
2010-07-30 13:19:15 +00:00
Romain Quetiez
57ee10f8ac Finalized the move of private tools
SVN:trunk[648]
2010-07-30 11:46:15 +00:00
Romain Quetiez
c813ff1bf9 Restored sample data for audit an triggers/actions
SVN:trunk[647]
2010-07-30 08:55:29 +00:00
Denis Flaven
83e9fe1112 Adding installation instructions in SVN in order to streamline the build/packaging process.
SVN:trunk[646]
2010-07-30 07:58:39 +00:00
Romain Quetiez
0169f18de5 Old PHP syntax issuing a warning on some installations of PHP
SVN:trunk[645]
2010-07-30 07:51:35 +00:00
Romain Quetiez
e651a2d08c Cleanup: moved files from business directory into relevant modules
SVN:trunk[644]
2010-07-29 20:55:39 +00:00
Romain Quetiez
a76ce40036 Obsoleted the setup/data folder and moved the few sample data still used to the relevant modules (audit in config mgmt, and trigger/actions in ticketing)
SVN:trunk[643]
2010-07-29 15:25:55 +00:00
Denis Flaven
7f564b4697 - New "exclude.txt" files for the streamlined build process
SVN:trunk[642]
2010-07-29 11:47:30 +00:00
Denis Flaven
2ea00e00eb Adding the licence to SVN to streamline the build process
SVN:trunk[641]
2010-07-29 09:52:42 +00:00
Denis Flaven
33e6968e50 SVN:trunk[640] 2010-07-29 07:43:02 +00:00
Denis Flaven
5509dc41c8 Added a placeholder for the version number, to be filled by the build process.
SVN:trunk[639]
2010-07-28 20:30:19 +00:00
Denis Flaven
9974457971 Enhancing the search (Trac #147): now allows to pass some "magic patterns" when doing a standard search without any operator. Specially useful for searching on ranges of dates/datetimes
SVN:trunk[638]
2010-07-28 15:18:52 +00:00
Romain Quetiez
0938baefb6 Fixed a few typos in the french dictionary
SVN:trunk[637]
2010-07-28 14:42:19 +00:00
Romain Quetiez
d9c208236b #194 Fixed regression in DBObjectSet -due to the new feature "queries returning several objects"
SVN:trunk[636]
2010-07-28 14:38:41 +00:00
Romain Quetiez
1fb9af95b5 Ignore local files (SVN)
SVN:trunk[635]
2010-07-28 10:43:41 +00:00
Romain Quetiez
61a8b506f7 #193 Fixed regression due to the usage of gzcompress/gzuncompress
SVN:trunk[634]
2010-07-28 10:38:45 +00:00
Denis Flaven
86f953383e Beta version of the LDAP authentication module: added parameters %2$s (first name), %3$s (first name) and %4$s (email) as possible placeholders into the LDAP query.
SVN:trunk[633]
2010-07-27 16:39:38 +00:00
Romain Quetiez
1045d8891b Updated dictionaries (in particular for new authentication modules)
SVN:trunk[632]
2010-07-27 16:04:43 +00:00
Denis Flaven
4c4570d9d8 Make sure that the ajax pages declare properly their charset as UTF-8. (Trac #198)
SVN:trunk[631]
2010-07-27 15:58:25 +00:00
Denis Flaven
ef0ace1c22 Beta version of the LDAP authentication module.
SVN:trunk[630]
2010-07-27 11:49:23 +00:00
Romain Quetiez
05c9b10546 #166 Configuration by module (and module categories)
SVN:trunk[629]
2010-07-26 16:29:52 +00:00
Denis Flaven
c9a573e39f Replace Ajax "get" calls by "posts" since long URLs may be truncated... and sometimes URLs get longer than expected when some characters are urlencoded... (Trac #195)
SVN:trunk[628]
2010-07-26 15:28:19 +00:00
Romain Quetiez
b3594f5899 #166 Allow the definition of persistent classes having no table defined, and added a sample code for a null password authentication scheme
SVN:trunk[627]
2010-07-26 08:32:37 +00:00
Romain Quetiez
437066516d #192 Missing french translation for overviews (by ITIL module)
SVN:trunk[626]
2010-07-25 20:22:26 +00:00
Romain Quetiez
7f49aa6d6c #191 No profile could create links between ticket and ...
SVN:trunk[625]
2010-07-25 20:03:10 +00:00
Romain Quetiez
b10ade39b3 #190 No need to manage user rights for abstract classes
SVN:trunk[624]
2010-07-25 20:01:11 +00:00
Romain Quetiez
fed3751510 #190, removed abstract classes from Grant Matrix overview
SVN:trunk[623]
2010-07-25 08:51:28 +00:00
Romain Quetiez
1ce122cfcd Completed previous change with missing file: authent.local.inc.php
SVN:trunk[622]
2010-07-24 14:49:40 +00:00
Romain Quetiez
6e54a79940 #166 Split authentication and management of user rights
SVN:trunk[621]
2010-07-24 14:42:55 +00:00
Romain Quetiez
650e5002af #152 Suppress errors reported by the data model consistency check
SVN:trunk[620]
2010-07-21 15:16:34 +00:00
Romain Quetiez
6fc2b4127b #160 Views not created with the user defined prefix
SVN:trunk[619]
2010-07-21 13:18:59 +00:00
Romain Quetiez
ef91a2e0db Finalized web services (unit tests, sample client) and dehardcoded the GetVersion() verb
SVN:trunk[618]
2010-07-21 13:04:23 +00:00
Romain Quetiez
eb29f4084e #153 Finalized SOAP unit testing (local tests only)
SVN:trunk[617]
2010-07-21 09:31:08 +00:00
Romain Quetiez
c8fbd1df18 #187 Warning issued while computing the impact
SVN:trunk[616]
2010-07-21 09:10:42 +00:00
Denis Flaven
c667e65904 Re-added the "toggle" style for history blocks. The style by default remains the plain "table" (inside a dedicated tab).
SVN:trunk[615]
2010-07-20 11:32:05 +00:00
Romain Quetiez
74927428aa #153 Warning issued by the SOAP web services
SVN:trunk[614]
2010-07-19 11:20:50 +00:00
Romain Quetiez
bfc052805b #171 Could not use "show all" on a list of linked objects (e.g. Interfaces of a Server)
SVN:trunk[613]
2010-07-19 10:44:33 +00:00
Denis Flaven
3ddf8e8a3b Properly display linksets with undefined external keys
SVN:trunk[612]
2010-07-16 16:10:14 +00:00
Denis Flaven
8875fc3e11 Removed Debug trace !
SVN:trunk[611]
2010-07-16 12:08:21 +00:00
Denis Flaven
46a92aef55 Properly connect to the database BEFORE trying to create the admin account !
SVN:trunk[610]
2010-07-16 09:05:25 +00:00
Denis Flaven
628436be29 Fixed Trac #176: LinkSet attributes should never be proposed for CSV mapping
SVN:trunk[609]
2010-07-16 07:57:27 +00:00
Romain Quetiez
957fe96af5 Fixed typo in dictionary (CSV load - ObjectHadErrors)
SVN:trunk[608]
2010-07-15 11:42:41 +00:00
Denis Flaven
303b670c7c Added life-cycle images
SVN:trunk[607]
2010-07-15 09:09:23 +00:00
Romain Quetiez
7cbf978618 Typo on change state plannedandscheduleD
SVN:trunk[606]
2010-07-15 08:39:45 +00:00
Romain Quetiez
03237598a9 #165 Issue when installing without selecting any of the ticketing modules
SVN:trunk[605]
2010-07-15 07:58:58 +00:00
Romain Quetiez
57e1dd65c7 Simplified toolset
SVN:trunk[604]
2010-07-14 21:34:14 +00:00
Romain Quetiez
77dbb03647 Typo in dictionnary
SVN:trunk[603]
2010-07-14 21:14:33 +00:00
Romain Quetiez
2c8564aa1a Cleaned up the old data model directory (no reference to the default template)
SVN:trunk[602]
2010-07-14 21:13:38 +00:00
Denis Flaven
320166791e Faster navigator: less data output, and also more robust since so strange data appeared in the export of the linkset attributes, that broke the XML export...
SVN:trunk[601]
2010-07-13 15:45:14 +00:00
Denis Flaven
2efb732ba9 Data load adjustements for beta'
SVN:trunk[600]
2010-07-13 15:42:39 +00:00
Romain Quetiez
6df0ea704c Fixed issue with link set and enabled the dictionary for triggers/actions (english only)
SVN:trunk[599]
2010-07-12 15:51:57 +00:00
Romain Quetiez
86e34754cb Could not create a user
SVN:trunk[598]
2010-07-12 15:50:01 +00:00
Romain Quetiez
83ae3e473e Fixed typo in the SOAP client example
SVN:trunk[597]
2010-07-12 14:36:27 +00:00
Romain Quetiez
7256b08273 Translated Users/profiles classes in French
SVN:trunk[596]
2010-07-12 14:35:45 +00:00
Romain Quetiez
1afde06825 Could not easily attach a profile to a user (idem with notifications, etc.)
SVN:trunk[595]
2010-07-12 14:16:15 +00:00
Romain Quetiez
890565e278 #154 Application too slow - no need to check the DB format anytime!
SVN:trunk[594]
2010-07-12 12:55:32 +00:00
Romain Quetiez
38c82c120c Errors reporting was set to "debug" mode
SVN:trunk[593]
2010-07-12 12:13:10 +00:00
Romain Quetiez
7b0a9a0531 Moved the "customer" attribute to the top of tickets edition forms
SVN:trunk[592]
2010-07-12 11:38:29 +00:00
Denis Flaven
328edd115a Preparing for the 1.0 beta release... final adjustments
SVN:trunk[591]
2010-07-07 11:01:30 +00:00
Romain Quetiez
f399489175 Compute impacted CIs and Contacts and attach them to the ticket
SVN:trunk[590]
2010-07-07 10:10:37 +00:00
Denis Flaven
b7d6771ddb Disable the "Basic" data model, which is not ready for the beta
SVN:trunk[589]
2010-07-07 10:01:29 +00:00
Romain Quetiez
1e17f8c671 Finalized the ticket check page (still some work)
SVN:trunk[588]
2010-07-07 09:57:05 +00:00
Romain Quetiez
c86752c12e Updated data model and dictionary (FR)
SVN:trunk[587]
2010-07-07 09:41:29 +00:00
Romain Quetiez
3862a765be Updated the ticket creation web service (still known bugs)
SVN:trunk[586]
2010-07-07 09:38:55 +00:00
Romain Quetiez
e514184022 Adjusted french translation
SVN:trunk[585]
2010-07-07 05:56:23 +00:00
Romain Quetiez
492dc43fa2 New data model translated in french
SVN:trunk[584]
2010-07-06 22:35:09 +00:00
Denis Flaven
b35b25d56a New version (complety rewritten in AS3) of the flash navigator
SVN:trunk[583]
2010-07-06 17:53:26 +00:00
Romain Quetiez
a5157a34fe Removed unused lnkProviderToCustomer
SVN:trunk[582]
2010-07-06 16:30:14 +00:00
Romain Quetiez
f80f487f0c data model + dictionaries
SVN:trunk[581]
2010-07-06 16:25:41 +00:00
Denis Flaven
ffdf72ae4d Data model fine tuning
SVN:trunk[580]
2010-07-06 15:59:14 +00:00
Romain Quetiez
debbb94529 Reviewed profiles created at the setup (authorized stimuli)
SVN:trunk[579]
2010-07-06 15:53:23 +00:00
Romain Quetiez
bd33b42197 Cleaned 80% of errors found in the datamodel validity check
SVN:trunk[578]
2010-07-06 15:21:37 +00:00
Romain Quetiez
58a5ae3af0 Fixed issue in data model (could not view SW instances)
SVN:trunk[577]
2010-07-06 14:41:33 +00:00
Denis Flaven
2e5844858d Code cleanup
SVN:trunk[576]
2010-07-06 14:21:04 +00:00
Denis Flaven
34ec79c0f7 Updated menu entries and relations definitions
SVN:trunk[575]
2010-07-06 13:49:37 +00:00
Romain Quetiez
90aaaa7d22 Fixed sample queries
SVN:trunk[574]
2010-07-06 12:43:32 +00:00
Romain Quetiez
c9ec146dff Automaticaly insert the "final class" into lists where an external key is pointing to a class that has child classes
SVN:trunk[573]
2010-07-06 11:16:31 +00:00
Romain Quetiez
00b2dbe286 Page to check tickets states periodically
SVN:trunk[572]
2010-07-06 10:01:48 +00:00
Romain Quetiez
018167a5d3 Datamodel revised
SVN:trunk[571]
2010-07-06 09:46:28 +00:00
Romain Quetiez
de1deefa44 Datamodel: declared explicitely the linked sets
SVN:trunk[570]
2010-07-06 08:36:04 +00:00
Romain Quetiez
d1b7c880b1 Finalized the data model
SVN:trunk[569]
2010-07-06 00:08:03 +00:00
Denis Flaven
d668bdd6fe - Create the admin account with the default language selected during the setup
SVN:trunk[568]
2010-07-05 22:39:54 +00:00
Denis Flaven
dda0a8a04e - Create the admin account with the default language selected during the setup
SVN:trunk[567]
2010-07-05 22:38:22 +00:00
Denis Flaven
f80cbcb93b - Create the admin account with the default language selected during the setup
SVN:trunk[566]
2010-07-05 22:37:36 +00:00
Denis Flaven
5bf0fa7f2a - Display hilighted lists depending on each object's status
- Fixed the setup page to use UTF-8
- Create the admin account with the chosen default language

SVN:trunk[565]
2010-07-05 22:17:31 +00:00
Denis Flaven
fa7bfbdc5f - Enable the French dictionnary at setup
- Fixed a problem with QueryCache in MetaModel (two different queries were seen as the same!)
- Added description to tickets

SVN:trunk[564]
2010-07-05 20:39:43 +00:00
Denis Flaven
73de5e181d - New hyperlink in the top bar: Help !
SVN:trunk[563]
2010-07-05 16:46:00 +00:00
Denis Flaven
3f84297d82 - The Combodo logo is now clickable
SVN:trunk[562]
2010-07-05 16:26:17 +00:00
Romain Quetiez
899c532c6b Made some progress on config management
SVN:trunk[561]
2010-07-05 16:14:20 +00:00
Denis Flaven
d0ed8f624a - Display/Creation/Modification of the objects now strictly relies on the display ZList. (i.e any attribute not in the ZList is neither displayed nor edited)
SVN:trunk[560]
2010-07-05 16:10:50 +00:00
Denis Flaven
0335c82710 - Template menus with now template (!) act as simple separators in the menu... should use MenuGroup to be not top-level instead (??)
SVN:trunk[559]
2010-07-05 15:45:22 +00:00
Denis Flaven
23f6da40cf Now support the creation from abstract classes (will prompt for a derived class)
SVN:trunk[558]
2010-07-05 15:40:48 +00:00
Denis Flaven
3a26bd9f9a - Changed the navigator to "release mode" !
SVN:trunk[557]
2010-07-05 13:45:17 +00:00
Denis Flaven
d6a73a3bb7 - CSV import improvement: better guess of the possible reconciliation keys (esp. with ExternalKeys)
SVN:trunk[556]
2010-07-05 13:29:48 +00:00
Denis Flaven
de0d719942 - Align the display of "State" attributes with Enums
SVN:trunk[555]
2010-07-05 12:47:12 +00:00
Denis Flaven
2d454141e6 - Flash navigator is here !
SVN:trunk[554]
2010-07-05 11:58:14 +00:00
Denis Flaven
7053bd7926 - Fxied the display (after modification) of n-n LinkedSets
SVN:trunk[553]
2010-07-05 11:51:41 +00:00
Denis Flaven
1247fda416 Manage interdependencies between modules, in the setup
SVN:trunk[552]
2010-07-05 11:00:25 +00:00
Romain Quetiez
1f3554777d Fixed default value for date/datetime attributes
SVN:trunk[551]
2010-07-05 08:06:56 +00:00
Romain Quetiez
300fc8c187 Page to track sleeping tickets (requires testing)
SVN:trunk[550]
2010-07-05 06:20:50 +00:00
Romain Quetiez
218ed7036b Implemented the three types of changes and factorized their lifecycle
Created incident/request/change dictionnaries

SVN:trunk[549]
2010-07-04 16:58:00 +00:00
Romain Quetiez
a7bf711182 Added the error message when a menu could not be computed (error in template)
SVN:trunk[548]
2010-07-04 16:55:09 +00:00
Romain Quetiez
b368209631 Bug: could not use mysql reserved words for table names (e.g. 'Change')
SVN:trunk[547]
2010-07-04 16:37:17 +00:00
Romain Quetiez
db277c8539 Created request management module as a clone of incident management (class hierarchy) and fixed an issue revealed by the computed fields of a ticket
SVN:trunk[546]
2010-07-04 10:33:07 +00:00
Romain Quetiez
99ba209152 Ignore external keys and external fields when the target class is undefined
SVN:trunk[545]
2010-07-04 08:53:44 +00:00
Denis Flaven
56a084cb7b Continuing the integration of the new data model...
SVN:trunk[544]
2010-07-04 08:05:12 +00:00
Romain Quetiez
dbee38dfd1 ComputeValues optimized + fix in the algo computing the priority of an Incident
SVN:trunk[543]
2010-07-04 07:46:45 +00:00
Denis Flaven
91107715ac Cleanup
SVN:trunk[542]
2010-07-03 16:59:00 +00:00
Romain Quetiez
832f6f02ad Fixed issue with null value for an Enum that would be hidden in a given state, being handled as an empty string, which is not an allowed value.
SVN:trunk[541]
2010-07-03 15:19:20 +00:00
Denis Flaven
4a2f94e362 Continuing the integration of the new data model...
SVN:trunk[540]
2010-07-03 13:27:15 +00:00
Denis Flaven
223704ca4a Continuing the integration of the new data model...
SVN:trunk[539]
2010-07-03 12:56:50 +00:00
Denis Flaven
b57015d7ba New data model integration...
SVN:trunk[538]
2010-07-02 17:10:08 +00:00
Romain Quetiez
79f5151de4 Changed the priority (and its computation)
SVN:trunk[537]
2010-07-02 16:21:03 +00:00
Romain Quetiez
147d6ebe8e Started to create sample data (quick fix in the setup)
SVN:trunk[536]
2010-07-02 16:00:42 +00:00
Romain Quetiez
eff8b2818e fixed typo in itop-ticket module definition
SVN:trunk[535]
2010-07-02 13:45:30 +00:00
Romain Quetiez
bd2f35e286 Datamodel: draft for the tickets (integration of StimulusInternal)
SVN:trunk[534]
2010-07-02 13:37:20 +00:00
Denis Flaven
40913af0f6 - Check consistency of the retyped password when changing password
SVN:trunk[533]
2010-07-02 12:58:09 +00:00
Denis Flaven
aa3357fe78 Fixed bug #102: allow users to change their password.
SVN:trunk[532]
2010-07-02 11:23:59 +00:00
Denis Flaven
75c1287ad1 - New conditional block 'itopcheck' in the templates
SVN:trunk[531]
2010-07-02 08:28:03 +00:00
Denis Flaven
90b9709b78 Fixed some of the sample queries to adpat them to the new data model.Note however that since the new data model is modular, some query will not run if the administrator did not install all modules...
SVN:trunk[530]
2010-07-01 20:26:33 +00:00
Denis Flaven
db3f3ff1cd - The object creation page now offers tha choice to create an instance of the sub-classes
- Made some objects abstract in the std config-management model
- The creation button is now labelled "Create" instead of "Apply" !
- Better display of long messages (or errors) in SetuWebpage.

SVN:trunk[529]
2010-07-01 20:13:26 +00:00
Denis Flaven
d9725eec73 Don't use short tags (php opening tag) since they are not enabled by default on some configurations !
SVN:trunk[528]
2010-07-01 16:46:03 +00:00
Denis Flaven
1c7038345f - More standard display of LinkedSet and LinkedSet indirect: content can be modified only when modifying the container object
SVN:trunk[527]
2010-07-01 16:15:44 +00:00
Denis Flaven
60b3a67be8 - Added icons and dictionary entries for Service Management
SVN:trunk[526]
2010-07-01 16:08:11 +00:00
Denis Flaven
9e8b5d73c1 Nicer handling of indirect linksets
SVN:trunk[525]
2010-07-01 15:16:21 +00:00
Romain Quetiez
019b224db3 Updated models and menus (config and service management)
SVN:trunk[524]
2010-07-01 15:15:17 +00:00
Denis Flaven
49a526c41b Strange corner case, not sure if the fix is the good one, seems harmless for now...
SVN:trunk[523]
2010-07-01 14:50:17 +00:00
Denis Flaven
4531570070 - Default value for a drop-down list is not forced if the field is not mandatory
SVN:trunk[522]
2010-07-01 14:41:33 +00:00
Denis Flaven
9487a54bc1 Typo
SVN:trunk[521]
2010-07-01 14:36:13 +00:00
Denis Flaven
7b4778326d - Fixed the "Organizations" drop-down list.
SVN:trunk[520]
2010-07-01 14:32:38 +00:00
Denis Flaven
b298d3eb2e - Creation of n-n links with no attributes no longer prompts since it's not needed !
SVN:trunk[519]
2010-07-01 14:29:19 +00:00
Denis Flaven
702a2345f7 New data model integration: fully modular setup based on the "modules"
SVN:trunk[518]
2010-07-01 14:10:21 +00:00
Romain Quetiez
51c1e079dc Re-integrated computation of free IPs into the new data model
SVN:trunk[517]
2010-07-01 09:55:33 +00:00
Romain Quetiez
211e1e7070 Ignore LinkedSet attribute declaration when the corresponding class is missing
SVN:trunk[516]
2010-07-01 07:43:30 +00:00
Denis Flaven
7ff800fa81 - Properly handle the "Enter" key in the setup screens
- Hidden modules are now enabled by default
- Added the GPLv3 licence as html for display in the setup

SVN:trunk[515]
2010-06-30 17:26:12 +00:00
Denis Flaven
c93153f28c Don't display the admin menu for non-admin users
SVN:trunk[514]
2010-06-30 17:22:34 +00:00
Romain Quetiez
9a7159cc3d Fixed regression :profile grant matrix was not visible anymore
SVN:trunk[513]
2010-06-30 15:45:50 +00:00
Romain Quetiez
45c201c250 Finalized menus for Service management
SVN:trunk[512]
2010-06-30 15:40:47 +00:00
Denis Flaven
f5b40898a3 New data model integration: fully modular setup based on the "modules"
SVN:trunk[511]
2010-06-30 15:40:18 +00:00
Romain Quetiez
2938a8d41e Added ticket module (prerequiste to incident etc.) and change the declaration of a menu : made by an identifier
SVN:trunk[510]
2010-06-30 15:32:43 +00:00
Romain Quetiez
b5d0d78d5f Introduced the modules (model, dicionnary, menus, etc.)
SVN:trunk[509]
2010-06-30 13:11:08 +00:00
Denis Flaven
0db5fe786a New data model integration...
SVN:trunk[508]
2010-06-29 11:28:10 +00:00
Romain Quetiez
e9b5f21285 Datamodel adjustments
SVN:trunk[507]
2010-06-29 10:40:52 +00:00
Romain Quetiez
4b93cb2adb Added external fields to the link classes
SVN:trunk[506]
2010-06-29 10:22:55 +00:00
Denis Flaven
afba1f19a3 Fixed the inline display of HTML/XML documents
SVN:trunk[505]
2010-06-29 10:18:10 +00:00
Denis Flaven
c9d5c267ac New data model integration...
SVN:trunk[504]
2010-06-29 09:47:55 +00:00
Romain Quetiez
7d4199825f Added linked set to the data model
SVN:trunk[503]
2010-06-29 09:25:50 +00:00
Denis Flaven
90069f6826 New data model integration...
Enhanced the display of blob attributes

SVN:trunk[502]
2010-06-29 09:22:22 +00:00
Denis Flaven
464479a6b2 New data model integration...
SVN:trunk[501]
2010-06-29 09:06:11 +00:00
Denis Flaven
2feaac9454 New data model integration...
SVN:trunk[500]
2010-06-28 16:31:56 +00:00
Romain Quetiez
af0384d565 Adjustements in the datamodel and dictionary and the audit page
SVN:trunk[499]
2010-06-28 16:07:10 +00:00
Romain Quetiez
b178cc4620 Updated data model dictionary + a few adjustments in the data model + quick fix in the setup
SVN:trunk[498]
2010-06-28 15:22:51 +00:00
Denis Flaven
95dc9bfc1a New data model integration...
SVN:trunk[497]
2010-06-28 14:53:18 +00:00
Denis Flaven
bc4bfed9f8 - Bug fix: make GetMenuIndexByTitle work !
SVN:trunk[496]
2010-06-28 14:51:45 +00:00
Denis Flaven
a351bfd817 New data model integration...
SVN:trunk[495]
2010-06-28 14:51:21 +00:00
Denis Flaven
9bd8eeb0ca New data model integration...
SVN:trunk[494]
2010-06-28 14:49:27 +00:00
Romain Quetiez
3c21bd90e0 New menu for configuration management
SVN:trunk[493]
2010-06-28 13:29:57 +00:00
Denis Flaven
e1f55c9c57 - Bug fix: make GetMenuIndexByTitle work !
SVN:trunk[492]
2010-06-28 13:24:42 +00:00
Denis Flaven
2ac4d13517 - Bug fix: make GetMenuIndexByTitle work !
SVN:trunk[491]
2010-06-28 13:06:50 +00:00
Denis Flaven
06ead1f543 - In the "actions" menu, list only the relations that have a meaning for the selected class.
SVN:trunk[490]
2010-06-28 12:46:16 +00:00
Denis Flaven
13f85f00b6 - new implementation of the default DisplayDetails of an object: the tabs are now at the top and the ZList supports multiple columns and tabs for the attributes.
SVN:trunk[489]
2010-06-28 12:21:37 +00:00
Romain Quetiez
7cf47e553e Integrated user profiles with the new data model
SVN:trunk[488]
2010-06-28 09:50:39 +00:00
Denis Flaven
3392f30e6e - Cosmetics: aligning the style in the different pages, make the iTop logo clickable, etc...
- Handle persistent user preferences: for now only the menu status (open/closed) and its width. In the future the status of lists (open/closed, which columns to show...) can be considered as well.

SVN:trunk[487]
2010-06-25 16:27:44 +00:00
Romain Quetiez
3f60668d90 Data model reviewed (suppressed linkedsets from search/result ZLists)
SVN:trunk[486]
2010-06-25 15:37:57 +00:00
Romain Quetiez
7e9529cd00 Default value for Integer attributes is now casted to int
SVN:trunk[485]
2010-06-25 15:34:12 +00:00
Romain Quetiez
442161f7bd New data model: alpha version
SVN:trunk[484]
2010-06-25 14:44:27 +00:00
Denis Flaven
50ee5f8194 - global search enhancement: search for several words when the search search string contains spaces, unless it is surrounded by quotes.
SVN:trunk[483]
2010-06-24 16:52:18 +00:00
Denis Flaven
e9d28e65e4 - New implementation of the menus: menus are built on the fly and no longer stored in the database...
SVN:trunk[482]
2010-06-24 16:22:38 +00:00
Denis Flaven
59e4e03980 - New implementation of the menus: menu templates are now stored as plain files and no longer in the database...
SVN:trunk[481]
2010-06-24 15:47:49 +00:00
Denis Flaven
e77cfa4b94 Hardening of the setup script in case of error...
SVN:trunk[480]
2010-06-23 16:53:31 +00:00
Denis Flaven
4a456e61a8 Bug fix in the setup... strange it seems it was broken since the beginning, however it used to work fine...
SVN:trunk[479]
2010-06-23 16:46:42 +00:00
Denis Flaven
bfbaddc73d - Restyling and update of the UI
SVN:trunk[478]
2010-06-23 15:33:10 +00:00
Denis Flaven
62d8059d42 - Restyling and update of the UI
SVN:trunk[477]
2010-06-23 15:28:57 +00:00
Denis Flaven
3ff11cc813 - REstyling and update of the UI
SVN:trunk[476]
2010-06-23 15:27:15 +00:00
Denis Flaven
4494b3ea45 - New images for the UI re styling
SVN:trunk[475]
2010-06-23 15:24:33 +00:00
Romain Quetiez
d792d77d60 Core: new feature, enumerate relations starting from a given class
SVN:trunk[474]
2010-06-23 15:00:33 +00:00
Romain Quetiez
d58a82c6c2 Cleanup: obsolescence of "key_label" property on persistent classes
SVN:trunk[473]
2010-06-23 14:32:54 +00:00
Denis Flaven
4cb5651dca Fixed the handling of default values in the object creation form.
SVN:trunk[472]
2010-06-19 08:07:08 +00:00
Romain Quetiez
c481830858 #143 Bug when computing related objects (impact)
SVN:trunk[471]
2010-06-17 14:43:11 +00:00
Denis Flaven
46cd29e60a Adding the Flash navigator...
SVN:trunk[470]
2010-06-15 17:08:00 +00:00
Denis Flaven
5df44c2a22 Adding the Flash navigator...
SVN:trunk[469]
2010-06-15 17:05:34 +00:00
Denis Flaven
8035f20b1c Fix some bugs in the handling of creation/modification forms (Trac #131)
SVN:trunk[468]
2010-06-15 16:58:01 +00:00
Romain Quetiez
6013920a45 #124 Helpers for testing profile/dimension/projection
SVN:trunk[467]
2010-06-15 14:10:19 +00:00
Romain Quetiez
cb6605a22f Error management: truncate long messages (was generating a second error over an error report)
SVN:trunk[466]
2010-06-15 14:07:42 +00:00
Romain Quetiez
9b6590652c #142 User profiles without any positive permission
SVN:trunk[465]
2010-06-15 13:53:28 +00:00
Romain Quetiez
b973ff838e #141 a few transparent changes in the user management
SVN:trunk[464]
2010-06-15 13:32:47 +00:00
Denis Flaven
21bea2e7c3 - Enhanced the display and modification/creation of objects in order to be able to get rid of templates... (Trac#138)
SVN:trunk[463]
2010-06-14 15:49:35 +00:00
Romain Quetiez
c439ff2f46 Class icon defined in the data model, use either the static method GetClassIcon, or GetIcon (this one could be overloaded for an icon depending on the object state)
SVN:trunk[462]
2010-06-14 14:23:51 +00:00
Denis Flaven
c61e375483 Nicer display of the form's validation icon
SVN:trunk[461]
2010-06-14 09:33:50 +00:00
Denis Flaven
23c19c599e - Improved (more interactive) validation of the forms.
SVN:trunk[460]
2010-06-14 09:10:54 +00:00
Romain Quetiez
f29217379e #134 class lists not sorted (combos)
SVN:trunk[459]
2010-06-10 15:20:20 +00:00
Denis Flaven
e1d436fa33 - Make sure that the 'torn paper' style remains on the last line when sorting the table.
SVN:trunk[458]
2010-06-10 11:58:39 +00:00
Denis Flaven
c09048a103 Start date for the date input calendar is now 1900 instead of 2000.
SVN:trunk[457]
2010-06-10 10:41:10 +00:00
Denis Flaven
e9402467c2 Fixing Trac #91, finializing the subtle behavior of the "smart" mapping of fields in the CSV import.
SVN:trunk[456]
2010-06-10 09:25:30 +00:00
Romain Quetiez
c8ea97beae #129 Result list to show an hyperlink with the object name (replacing the "zoom" icon)
SVN:trunk[455]
2010-06-10 09:02:14 +00:00
Denis Flaven
a4e8c8d07d - Fixed behaviour of the popup menu (Trac #316): regression on popup menus inside content loaded via Ajax...
SVN:trunk[454]
2010-06-09 20:55:50 +00:00
Denis Flaven
b2e959bc1b - Fixed behaviour of the popup menu (Trac #316).
SVN:trunk[453]
2010-06-09 20:14:20 +00:00
Denis Flaven
3e2746e57a - Fixed the alignment of the text inside the popup menus (Trac #316).
SVN:trunk[452]
2010-06-09 17:19:56 +00:00
Denis Flaven
d4b07820be - Fixed the positioning of the iTop popup menus (Trac #316)
SVN:trunk[451]
2010-06-09 17:17:39 +00:00
Romain Quetiez
bdabd3f51a Bulk delete: fixed a regression due to transaction management + cosmetics
Error management: cope with context data that are not a string

SVN:trunk[450]
2010-06-09 15:57:28 +00:00
Denis Flaven
668fbcadc6 - Display the description on the field label when modifying/creating an object.
SVN:trunk[449]
2010-06-09 15:37:33 +00:00
Denis Flaven
e87c43c775 - Display some Help text as a tooltip on a field (in edition mode) to provide some hints about the format to be used... if such information is defined in the data model
SVN:trunk[448]
2010-06-09 15:31:36 +00:00
Romain Quetiez
8e2ca8c027 New verb to display information on edited fields and fixed a few typos in the dictionary
SVN:trunk[447]
2010-06-09 15:20:49 +00:00
Denis Flaven
0fea8f1ea0 - Fixed a typo
- New type of attributes that determines automatically the available languages (i.e. loaded dictionaries) for the application

SVN:trunk[446]
2010-06-09 08:30:24 +00:00
Denis Flaven
6dae6d378b The fix was already done by Romain in another file
SVN:trunk[445]
2010-06-09 08:28:37 +00:00
Romain Quetiez
d854c72243 #133 Issue on object creation with fields set to 'null'
SVN:trunk[444]
2010-06-09 08:26:30 +00:00
Denis Flaven
090e766f84 - Localization of the "Notifications" menu
SVN:trunk[443]
2010-06-08 15:42:58 +00:00
Denis Flaven
b827fbb295 Fixed the GetLanguages method to return what is documented
SVN:trunk[442]
2010-06-08 13:44:44 +00:00
Denis Flaven
fd8b3c835e - Upgraded to the latest version of Open Flash Charts (Version 2 Lug Wyrm Charmer)
- Localization of the menus 90% done.
- Removed the old types of Flash charts, (no longer used anyway, now we rely on open-flash-charts)

SVN:trunk[441]
2010-06-08 13:12:17 +00:00
Romain Quetiez
4d3fbf1f79 Do not allow the user to modify/delete objects designed for logging (change tracking, error log, information log, etc.)
SVN:trunk[440]
2010-06-08 09:33:14 +00:00
Romain Quetiez
a813a1e50a Fixed regression in the setup, due to the latest change (rearranged the includes)
SVN:trunk[439]
2010-06-08 09:19:44 +00:00
Romain Quetiez
3776e09cdb Localized strings for relations (e.g. "impacts")
SVN:trunk[438]
2010-06-07 16:16:07 +00:00
Romain Quetiez
d3ffa21943 Improved error handling and localization
SVN:trunk[437]
2010-06-07 14:28:42 +00:00
Denis Flaven
dc2430332a - Fix bug #116 (initial value of the linkset was lost)
SVN:trunk[436]
2010-06-07 12:19:18 +00:00
Romain Quetiez
0bb1be78a5 SVN:trunk[435] 2010-06-07 05:44:25 +00:00
Denis Flaven
9c43da711e - Non mandatory fields can be empty, even if a validation pattern was specified.
SVN:trunk[434]
2010-06-06 17:05:08 +00:00
Denis Flaven
ef38dac045 - New implementation preventing users to submit the same form twice.
- Better check whether or not an object was modified (rely on the core's IsModified function)

SVN:trunk[433]
2010-06-06 17:00:21 +00:00
Denis Flaven
fce9cbad1b - New implementation preventing users to submit the same form twice.
SVN:trunk[432]
2010-06-06 16:58:38 +00:00
Denis Flaven
dfb2303fc2 - New implementation preventing users to submit the same form twice.
SVN:trunk[431]
2010-06-06 16:57:48 +00:00
Romain Quetiez
65eb567f63 #132 Finalized: do check if an attribute is missing in a view
SVN:trunk[430]
2010-06-04 16:23:18 +00:00
Romain Quetiez
d115022132 #132 Views on data model classes
SVN:trunk[429]
2010-06-04 14:02:46 +00:00
Romain Quetiez
0a38eab341 #124 New page to create huge data sets and verify the scalability
SVN:trunk[428]
2010-05-31 15:27:40 +00:00
Romain Quetiez
024f67b1b8 #128 Allow a blob to be undefined (optional property)
SVN:trunk[427]
2010-05-31 14:51:37 +00:00
Denis Flaven
8c2d819920 - Moved the iTop version number to the Config class to be able to access it from the setup.
SVN:trunk[426]
2010-05-31 14:41:05 +00:00
Denis Flaven
d0c4546ec5 - Fized bug Trac#107: "select first line as header" is now checked when uploading data from a file.
SVN:trunk[425]
2010-05-27 15:56:53 +00:00
Denis Flaven
1a5604f184 Fixed Trac #126: misleading message during the setup when magic_quotes_gpc in On. Now we provide a more accurate message.
SVN:trunk[424]
2010-05-27 15:36:06 +00:00
Denis Flaven
1bc76fe5bd Fixed a typo in an error message (Tack #125).
SVN:trunk[423]
2010-05-27 15:08:50 +00:00
Romain Quetiez
a0e0371812 #19 - Reviewed the licensing information and started to align the comments in the code
SVN:trunk[422]
2010-05-24 09:24:35 +00:00
Romain Quetiez
2b365dca75 Deleted old files
SVN:trunk[421]
2010-05-24 09:19:42 +00:00
Romain Quetiez
08a8835fa5 Removed the indexes for the attributes of type Enum
SVN:trunk[420]
2010-05-21 07:43:51 +00:00
Romain Quetiez
80425789a7 #98 Fixed bug in the computation of free IP addresses for a given subnet
SVN:trunk[419]
2010-05-18 15:02:50 +00:00
Romain Quetiez
d65693598b New type of attribute: IP address
SVN:trunk[418]
2010-05-18 14:34:36 +00:00
Denis Flaven
280c8579be - Small bug fixes after a quick test by performing a clean installation on Windows/IE 8
SVN:trunk[417]
2010-05-16 18:46:19 +00:00
Denis Flaven
d95b941d5a - Partial localization... is this page used at all ?
SVN:trunk[416]
2010-05-16 16:55:22 +00:00
Denis Flaven
15352ad018 - Checking memory_limit during the setup
SVN:trunk[415]
2010-05-16 16:54:08 +00:00
Denis Flaven
e8d4cccf8f - French translation cleanup
SVN:trunk[414]
2010-05-16 16:52:13 +00:00
Denis Flaven
d42f2f18be Minor fix
SVN:trunk[413]
2010-05-16 16:51:03 +00:00
Denis Flaven
1de8ae4c33 - Added validation of the fields based on a regexp pattern
- Fields that depend on another field (in the same form) get refreshed when one of the fields they depend on is changed
- Updated the wizard to group all the mandatory fields on the first page, since having inter-dependent fields on one page is now supported

SVN:trunk[412]
2010-05-16 16:47:16 +00:00
Denis Flaven
76a8b5bbc3 - Added support for pattern-based field validation (anticipating HTML5 ?).
SVN:trunk[411]
2010-05-16 16:38:48 +00:00
Denis Flaven
d696e38902 Bug fix: (Consequence of the fix of Trac #112) Now all attributes are can be used for filtering, one cannot add them automatically to the filter... especially for history block where it makes absolutely no sense...
SVN:trunk[410]
2010-05-15 15:04:45 +00:00
Denis Flaven
fd7555e96b No longer needed, implementation replaced by jquery.popupmenu.js
SVN:trunk[409]
2010-05-15 14:52:52 +00:00
Denis Flaven
01539af632 New implementation of the "Actions" Javascript context menu. Simpler, easier to customize and more robust.
SVN:trunk[408]
2010-05-15 14:51:29 +00:00
Denis Flaven
e22393404f - Implementation of the localization... on going...
SVN:trunk[407]
2010-05-15 08:44:36 +00:00
Denis Flaven
124867f7fa - Implementation of the localization... on going...
SVN:trunk[406]
2010-05-15 07:54:59 +00:00
Romain Quetiez
cf042a795d #120 Added indexes on finalclass and enum columns
SVN:trunk[405]
2010-05-15 07:44:46 +00:00
Romain Quetiez
2e07f73122 #112 Implicit search filter declaration
SVN:trunk[404]
2010-05-14 10:06:07 +00:00
Romain Quetiez
d527b56340 #74 Added the configuration of logging (errors, web service usage, etc.), and improved a little the error logging (both in a file and into the database + new format for additional information such as the callstack)
SVN:trunk[403]
2010-05-13 20:40:52 +00:00
Denis Flaven
4e09d304f8 - Implementation of the localization... on going...
SVN:trunk[402]
2010-05-06 10:44:38 +00:00
Denis Flaven
aff20677fb - bug fix, found thanks to Eclipse syntax checking !
SVN:trunk[401]
2010-05-06 09:01:21 +00:00
Denis Flaven
a28823141d - Implementation of the localization... on going...
SVN:trunk[400]
2010-05-04 17:14:44 +00:00
Denis Flaven
cfc69316d1 - Implementation of the localization... on going...
SVN:trunk[399]
2010-05-04 15:14:22 +00:00
Denis Flaven
89dffd2845 - Implementation of the localization... on going...
SVN:trunk[398]
2010-05-04 14:42:36 +00:00
Denis Flaven
df98e25743 Preparing the integration of the Flash navigator
SVN:trunk[397]
2010-05-04 14:39:43 +00:00
Denis Flaven
bd3e09a9b8 Remove unused/obsolete pages
SVN:trunk[396]
2010-05-04 14:23:06 +00:00
Denis Flaven
ac1fa17727 - Typo
SVN:trunk[395]
2010-05-04 14:19:38 +00:00
Denis Flaven
65d6adde1c - Enhancement to UniversalSearch:
1) Localization
2) Fixed two medium issues, see Trac #35

SVN:trunk[394]
2010-05-04 13:57:14 +00:00
Denis Flaven
2aa049092f - Search forms now display the subclasses of the specified class...
SVN:trunk[393]
2010-05-04 12:21:39 +00:00
Denis Flaven
029857b5f2 - Verification of invalid external fields (i.e fields pointing to a non-existing field in the target class).
SVN:trunk[392]
2010-05-03 19:49:49 +00:00
Denis Flaven
cb9331c414 - Proper usage of htmlentities: specifiy the target character set !
SVN:trunk[391]
2010-05-02 18:52:46 +00:00
Denis Flaven
9ffb085658 - Creation and CSV import de-activated for abstract classes
SVN:trunk[390]
2010-05-02 18:42:49 +00:00
Denis Flaven
fe44e447ce - Search forms now display the subclasses of the specified class...
SVN:trunk[389]
2010-05-02 18:28:18 +00:00
Denis Flaven
c95df7a42c - Typo
SVN:trunk[388]
2010-05-02 18:26:18 +00:00
Denis Flaven
8e10c27adf - CSV import enhancements: automatic setting of search criterias and masking of the "id" columns expect in advanced mode. (Trac #21 and 106)
SVN:trunk[387]
2010-05-02 14:03:21 +00:00
Denis Flaven
3019e65193 - Building the French translation as we go...
SVN:trunk[386]
2010-05-02 14:02:52 +00:00
Denis Flaven
84d0533922 - Added the support of localization to the CSV import wizard
SVN:trunk[385]
2010-05-02 14:02:11 +00:00
Denis Flaven
12dab4a12a - CSV import enhancements: automatic setting of search criterias and masking of the "id" columns expect in advanced mode. (Trac #21 and 106)
- Added the support of localization to the CSV import wizard

SVN:trunk[384]
2010-05-02 13:59:38 +00:00
Denis Flaven
ffd22acff5 - Cleanup of 'finalclass'... (Trac #54)
SVN:trunk[383]
2010-05-02 13:56:28 +00:00
Romain Quetiez
c18f731660 Fixed regression due to the changes with 'finalclass', the value stored in the DB was the base class.
SVN:trunk[382]
2010-05-01 17:20:56 +00:00
Romain Quetiez
5ad54c02cb Cosmetics in the overviews (menu templates)
SVN:trunk[381]
2010-05-01 17:19:10 +00:00
Romain Quetiez
5a7e59e02f Clarified the meaning of the attribute 'finalclass'
SVN:trunk[380]
2010-05-01 16:16:43 +00:00
Romain Quetiez
776e6befe6 Improvement: allow to create intermediate classes having no table (just a different behavior)
SVN:trunk[379]
2010-05-01 11:26:48 +00:00
Romain Quetiez
e651c84331 Finalized the concept of abstract classes (#35) in the core. Still to be used within the UI.
SVN:trunk[378]
2010-04-30 16:42:08 +00:00
Romain Quetiez
a980d043c0 Added the readme file (last release = 0.9.1)
SVN:trunk[377]
2010-04-30 15:38:07 +00:00
Romain Quetiez
4a5b004c0f Cosmetics on the login page
SVN:trunk[376]
2010-04-30 08:31:08 +00:00
Romain Quetiez
6fcbd77b99 Change #113, by default, only the administrator is allowed to perform bulk deletions
SVN:trunk[375]
2010-04-30 08:21:33 +00:00
Denis Flaven
bc1292c54b - First implementation of the bulk delete
SVN:trunk[374]
2010-04-30 08:12:12 +00:00
Denis Flaven
1274150009 - Implementation of the localization... on going...
SVN:trunk[373]
2010-04-30 08:06:54 +00:00
Romain Quetiez
69a8d27b54 Obsoleted the SibusQL and the keyword pkey (still allowed as a placeholder in the templates)
SVN:trunk[372]
2010-04-29 16:51:56 +00:00
Denis Flaven
f2fd97a434 - Implementation of the localization... on going...
SVN:trunk[371]
2010-04-29 16:49:17 +00:00
Denis Flaven
37ab9d4512 - Implementation of the localization... on going...
SVN:trunk[370]
2010-04-29 16:39:53 +00:00
Denis Flaven
eed38bedbf - CSV import enhancements: support of non-ascii characters and "head line" set by default (Trac #107)
SVN:trunk[369]
2010-04-29 12:16:17 +00:00
Denis Flaven
6cae3c6742 - correct way to specify the include...
SVN:trunk[368]
2010-04-28 17:05:24 +00:00
Denis Flaven
14ba5de67f Bug fix Trac#106 (part 1): data from the last field of each row does not appear in the mapping/preview.
SVN:trunk[367]
2010-04-28 16:47:13 +00:00
Denis Flaven
74c322cd26 - Implementation of the localization... on going...
SVN:trunk[366]
2010-04-28 16:37:51 +00:00
Denis Flaven
372943720a - Implementation of the localization... on going...
SVN:trunk[365]
2010-04-28 13:14:04 +00:00
Romain Quetiez
2545872236 Updated config file for unit tests (the farmer data model)
SVN:trunk[364]
2010-04-28 07:17:58 +00:00
Denis Flaven
c6a57b5a2f - Implementation of the localization... on going...
SVN:trunk[363]
2010-04-27 13:11:04 +00:00
Denis Flaven
ef5877779d - Implementation of the localization... on going...
SVN:trunk[362]
2010-04-27 13:10:27 +00:00
Romain Quetiez
42ae42d5ee Fixed #97, could not delete an Organization
SVN:trunk[361]
2010-04-27 13:06:51 +00:00
Romain Quetiez
20020a0be8 Fixed regressions in CSV export (See #105)
SVN:trunk[360]
2010-04-27 12:44:09 +00:00
Romain Quetiez
7220052134 Enabled localized strings (not only enums, but other types... to be defined)
SVN:trunk[359]
2010-04-27 12:38:56 +00:00
Romain Quetiez
0c328d227d Fixed a typo in the datamodel
SVN:trunk[358]
2010-04-27 07:28:56 +00:00
Romain Quetiez
942d77a70f Aligned bulk load web services with recent changes (status reporting)
SVN:trunk[357]
2010-04-21 07:37:41 +00:00
Romain Quetiez
871e0ef101 Localization: user profile ++ language
SVN:trunk[356]
2010-04-21 07:35:19 +00:00
Romain Quetiez
018da0ddf4 Localization: cleanup in data model class declarations
SVN:trunk[355]
2010-04-20 15:54:13 +00:00
Denis Flaven
b0ff4a409a - Keep the values when coming back to the "options" step
SVN:trunk[354]
2010-04-20 15:51:29 +00:00
Romain Quetiez
419969c0dd Fixed bug on the last commit
SVN:trunk[353]
2010-04-20 15:33:08 +00:00
Romain Quetiez
cab47b5044 Localization: tools to report missing entries, and build the dictionary out of a data model made with the previous format
SVN:trunk[352]
2010-04-20 15:26:37 +00:00
Denis Flaven
1150df3e06 - bug fix: history log was not saved when doing a bulk import.
SVN:trunk[351]
2010-04-20 12:59:23 +00:00
Romain Quetiez
1844ee3663 Localization: Display of enums
SVN:trunk[350]
2010-04-20 12:45:21 +00:00
Romain Quetiez
a84aa1799d Fixed a bug related to the CSV templates
SVN:trunk[349]
2010-04-20 09:30:21 +00:00
Romain Quetiez
1bdfbbb284 Localization: cleanup in the DataModel + aligned some API (e.g. GetStateLabel)
SVN:trunk[348]
2010-04-20 09:21:46 +00:00
Denis Flaven
3f9a9424e9 - New version of the CSV import wizard. First implementation...
SVN:trunk[347]
2010-04-20 09:16:54 +00:00
Denis Flaven
23ee727fc5 - bug fix: external keys must be set - in case the object has to be created
SVN:trunk[346]
2010-04-20 08:46:03 +00:00
Denis Flaven
7b72cb8ee2 - bug fix...
SVN:trunk[345]
2010-04-20 08:44:55 +00:00
Denis Flaven
6ebe6da4eb - Static functions must be duplicated since they are not inherited...
SVN:trunk[344]
2010-04-20 08:43:24 +00:00
Denis Flaven
9854842436 - new styles for the CSV import
SVN:trunk[343]
2010-04-20 08:35:10 +00:00
Denis Flaven
a693d3f2ab - new icons for the CSV import
SVN:trunk[342]
2010-04-20 08:33:43 +00:00
Denis Flaven
a65a4f9c40 - Added jquery blockUI, useful when performing asynchronous (ajax) calls.
SVN:trunk[341]
2010-04-20 08:32:47 +00:00
Romain Quetiez
0714a08359 Localization... really finalized the metamodel (description on object states)
SVN:trunk[340]
2010-04-19 14:27:06 +00:00
Romain Quetiez
466f6b9c6d Localization: finalized the transfer of metamodel strings into the localizable files
SVN:trunk[339]
2010-04-19 14:21:34 +00:00
Romain Quetiez
dd02ce60b5 Localization: first step (class Dict and handling of Metamodel)
SVN:trunk[338]
2010-04-19 13:32:30 +00:00
Romain Quetiez
b825219948 CSV load quick fix for integration
SVN:trunk[337]
2010-04-15 15:54:26 +00:00
Denis Flaven
2c90ebcc13 - Integrating...
SVN:trunk[336]
2010-04-15 15:21:41 +00:00
Romain Quetiez
12b7fb7498 Bulkload reporting ready for integration with the new UI
SVN:trunk[335]
2010-04-15 15:12:47 +00:00
Romain Quetiez
0f8f966217 CSV import: improved handling of external keys
SVN:trunk[334]
2010-04-15 13:05:09 +00:00
Romain Quetiez
bf34791a80 CSV export: added external fields (all scalar fields are given)
SVN:trunk[333]
2010-04-15 12:09:08 +00:00
Denis Flaven
0a28faa9df - New implementation for the "join" display group, based on a complex OQL query and the display of several objects in the same row.
SVN:trunk[332]
2010-04-14 09:42:11 +00:00
Romain Quetiez
4e2edaabfa Added constructor for DBObjectSet: FromArrayAssoc
SVN:trunk[331]
2010-04-14 08:14:08 +00:00
Denis Flaven
3e2178db8f - Enhancement: support of ObjectSets with multiple objects per line.
SVN:trunk[330]
2010-04-13 12:58:03 +00:00
Romain Quetiez
b1754b1475 Finalized queries with multiple objects
SVN:trunk[329]
2010-04-13 12:46:07 +00:00
Denis Flaven
c81ac981c9 - Enhancement: support of ObjectSets with multiple objects per line.
SVN:trunk[328]
2010-04-13 10:35:43 +00:00
Romain Quetiez
5d46a94ddf Select multiple objects in OQL (beta, for integration within the UI)
SVN:trunk[327]
2010-04-13 09:42:22 +00:00
Denis Flaven
646ab068da - bug fix: it's now possible to have several search blocks (that can be toggled) in the same page.
- new type of display block "Join" for grouping objects based on the attribute of a joined query. Will be enhanced when the full OQL support of associative select is implemented.

SVN:trunk[326]
2010-04-12 12:29:48 +00:00
Denis Flaven
128f048800 Enhancement / bug fix: allow the overload of the GetName method for building the short name of an object. This is also used when the object appears in a drop-down list.
SVN:trunk[325]
2010-04-12 12:22:00 +00:00
Denis Flaven
37ccd94828 Enhancement : new configuration option (secure_conenction_required) to force the use of HTTPS to connect to iTop. The redirection http -> https is still buggy but the usage of https is enforced anyway.
SVN:trunk[324]
2010-04-12 12:19:12 +00:00
Denis Flaven
c4a51c31c9 Bug fix: the audit page was not working for object with no "org_id" filter criteria.
SVN:trunk[323]
2010-04-12 12:13:14 +00:00
Romain Quetiez
84c2599e6b Setup of user rights: an alternative to the ITIL model, just create two profiles (readers and writers)
SVN:trunk[322]
2010-04-09 11:41:57 +00:00
Denis Flaven
735cd28dfd Regression when fixing bug #89: the "state" attribute was editable. This is now fixed.
SVN:trunk[320]
2010-03-26 16:40:58 +00:00
Denis Flaven
12d0c865c2 - Fixed bug #85: MySQL password was displayed (along with the call stack) in case the connection to the database failed.
- Additional fix to #87: strings consisting only of digits (like 001231) were treated as numbers (i.e 1231)

SVN:trunk[319]
2010-03-23 08:17:50 +00:00
Denis Flaven
071f268a59 Bug fix: application crashes when a incorrect wizard config is detected
SVN:trunk[318]
2010-03-23 08:09:03 +00:00
Romain Quetiez
d8905c63b8 Fixed bug in DisplayBlock (group by - visible on the page "contacts overview")
SVN:trunk[317]
2010-03-12 16:58:50 +00:00
Romain Quetiez
f454ebf4b5 Fixed bugs on CSV import (was not working fine when exporting/importing incident tickets)
SVN:trunk[316]
2010-03-12 13:48:39 +00:00
Romain Quetiez
5b4057aebb Finalized the demo of impact computation (removed an ugly test message) and added few comments
SVN:trunk[315]
2010-03-11 08:15:19 +00:00
Romain Quetiez
e2524d28d7 Related objects:
- moved to OQL
- added capacity to set a default value based on the related objects (during the creation wizard)

SVN:trunk[314]
2010-03-09 14:09:51 +00:00
Romain Quetiez
5a09dc6e2b Trac #86 - CSV format aligned with standard specifications
Trac #93 - Fixed issue within the setup data load (related to memory_limit)
Fixed issues with the consultant toolkit: upgrade an existing DB (add new class/attribute)
Developed core services to allow for demonstrating impact computation capability
Deprecated option operation=direct on page UI.php

SVN:trunk[313]
2010-03-08 09:10:16 +00:00
Denis Flaven
10fa31807b - Fixed bug #87: Strings consisting only of digits are not managed as strings
SVN:trunk[312]
2010-02-26 15:29:30 +00:00
Denis Flaven
22a0030a62 whitepaces (tabs, etc...) cleanup
SVN:trunk[311]
2010-02-25 08:38:56 +00:00
Denis Flaven
5f91c8ccc0 Fixed bug #89: some hidden or read-only fields were displayed in the object creation wizard.
SVN:trunk[310]
2010-02-25 08:35:57 +00:00
760 changed files with 91508 additions and 36278 deletions

View File

@@ -1,49 +1,29 @@
<?php
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* UserRightsMatrix
* User management Module
* UserRightsMatrix (User management Module)
*
* @package iTopORM
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @author Denis Flaven <denisflave@free.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version 1.1.1.1 $
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
class UserRightsMatrixUsers extends DBObject
{
public static function Init()
{
$aParams = array
(
"category" => "addon/userrights",
"name" => "user",
"description" => "users and credentials",
"key_type" => "autoincrement",
"key_label" => "",
"name_attcode" => "login",
"state_attcode" => "",
"reconc_keys" => array(),
"db_table" => "priv_ur_matrixusers",
"db_key_field" => "id",
"db_finalclass_field" => "",
);
MetaModel::Init_Params($aParams);
//MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeInteger("userid", array("label"=>"User id", "description"=>"User identifier (depends on the business model)", "allowed_values"=>null, "sql"=>"userid", "default_value"=>0, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("login", array("label"=>"login", "description"=>"user identification string", "allowed_values"=>null, "sql"=>"login", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("password", array("label"=>"password", "description"=>"user authentication string", "allowed_values"=>null, "sql"=>"pwd", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
//MetaModel::Init_InheritFilters();
MetaModel::Init_AddFilterFromAttribute("userid");
MetaModel::Init_AddFilterFromAttribute("login");
}
}
class UserRightsMatrixClassGrant extends DBObject
{
public static function Init()
@@ -51,10 +31,7 @@ class UserRightsMatrixClassGrant extends DBObject
$aParams = array
(
"category" => "addon/userrights",
"name" => "class_permission",
"description" => "permissions on classes",
"key_type" => "autoincrement",
"key_label" => "",
"name_attcode" => "",
"state_attcode" => "",
"reconc_keys" => array(),
@@ -64,18 +41,12 @@ class UserRightsMatrixClassGrant extends DBObject
);
MetaModel::Init_Params($aParams);
//MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeExternalKey("userid", array("targetclass"=>"UserRightsMatrixUsers", "jointype"=> "", "label"=>"user", "description"=>"user account", "allowed_values"=>null, "sql"=>"userid", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("login", array("label"=>"Login", "description"=>"Login", "allowed_values"=>null, "extkey_attcode"=> 'userid', "target_attcode"=>"login")));
MetaModel::Init_AddAttribute(new AttributeString("class", array("label"=>"class", "description"=>"class name", "allowed_values"=>null, "sql"=>"class", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalKey("userid", array("targetclass"=>"User", "jointype"=> "", "allowed_values"=>null, "sql"=>"userid", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("login", array("allowed_values"=>null, "extkey_attcode"=> 'userid', "target_attcode"=>"login")));
MetaModel::Init_AddAttribute(new AttributeString("class", array("allowed_values"=>null, "sql"=>"class", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("action", array("label"=>"action", "description"=>"operations to perform on the given class", "allowed_values"=>null, "sql"=>"action", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeEnum("permission", array("label"=>"permission", "description"=>"allowed or not allowed?", "allowed_values"=>new ValueSetEnum('yes,no'), "sql"=>"permission", "default_value"=>"yes", "is_null_allowed"=>false, "depends_on"=>array())));
//MetaModel::Init_InheritFilters();
MetaModel::Init_AddFilterFromAttribute("userid");
MetaModel::Init_AddFilterFromAttribute("login");
MetaModel::Init_AddFilterFromAttribute("class");
MetaModel::Init_AddFilterFromAttribute("action");
MetaModel::Init_AddAttribute(new AttributeString("action", array("allowed_values"=>null, "sql"=>"action", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeEnum("permission", array("allowed_values"=>new ValueSetEnum('yes,no'), "sql"=>"permission", "default_value"=>"yes", "is_null_allowed"=>false, "depends_on"=>array())));
}
}
@@ -86,10 +57,7 @@ class UserRightsMatrixClassStimulusGrant extends DBObject
$aParams = array
(
"category" => "addon/userrights",
"name" => "stimulus_permission",
"description" => "permissions on stimilus in the life cycle of the object",
"key_type" => "autoincrement",
"key_label" => "",
"name_attcode" => "",
"state_attcode" => "",
"reconc_keys" => array(),
@@ -99,18 +67,12 @@ class UserRightsMatrixClassStimulusGrant extends DBObject
);
MetaModel::Init_Params($aParams);
//MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeExternalKey("userid", array("targetclass"=>"UserRightsMatrixUsers", "jointype"=> "", "label"=>"user", "description"=>"user account", "allowed_values"=>null, "sql"=>"userid", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("login", array("label"=>"Login", "description"=>"Login", "allowed_values"=>null, "extkey_attcode"=> 'userid', "target_attcode"=>"login")));
MetaModel::Init_AddAttribute(new AttributeString("class", array("label"=>"class", "description"=>"class name", "allowed_values"=>null, "sql"=>"class", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalKey("userid", array("targetclass"=>"User", "jointype"=> "", "allowed_values"=>null, "sql"=>"userid", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("login", array("allowed_values"=>null, "extkey_attcode"=> 'userid', "target_attcode"=>"login")));
MetaModel::Init_AddAttribute(new AttributeString("class", array("allowed_values"=>null, "sql"=>"class", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("stimulus", array("label"=>"action", "description"=>"operations to perform on the given class", "allowed_values"=>null, "sql"=>"action", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeEnum("permission", array("label"=>"permission", "description"=>"allowed or not allowed?", "allowed_values"=>new ValueSetEnum('yes,no'), "sql"=>"permission", "default_value"=>"yes", "is_null_allowed"=>false, "depends_on"=>array())));
//MetaModel::Init_InheritFilters();
MetaModel::Init_AddFilterFromAttribute("userid");
MetaModel::Init_AddFilterFromAttribute("login");
MetaModel::Init_AddFilterFromAttribute("class");
MetaModel::Init_AddFilterFromAttribute("stimulus");
MetaModel::Init_AddAttribute(new AttributeString("stimulus", array("allowed_values"=>null, "sql"=>"action", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeEnum("permission", array("allowed_values"=>new ValueSetEnum('yes,no'), "sql"=>"permission", "default_value"=>"yes", "is_null_allowed"=>false, "depends_on"=>array())));
}
}
@@ -121,10 +83,7 @@ class UserRightsMatrixAttributeGrant extends DBObject
$aParams = array
(
"category" => "addon/userrights",
"name" => "attribute_permission",
"description" => "permissions at the attributes level",
"key_type" => "autoincrement",
"key_label" => "",
"name_attcode" => "",
"state_attcode" => "",
"reconc_keys" => array(),
@@ -134,20 +93,13 @@ class UserRightsMatrixAttributeGrant extends DBObject
);
MetaModel::Init_Params($aParams);
//MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeExternalKey("userid", array("targetclass"=>"UserRightsMatrixUsers", "jointype"=> "", "label"=>"user", "description"=>"user account", "allowed_values"=>null, "sql"=>"userid", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("login", array("label"=>"Login", "description"=>"Login", "allowed_values"=>null, "extkey_attcode"=> 'userid', "target_attcode"=>"login")));
MetaModel::Init_AddAttribute(new AttributeString("class", array("label"=>"class", "description"=>"class name", "allowed_values"=>null, "sql"=>"class", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("attcode", array("label"=>"attribute", "description"=>"attribute code", "allowed_values"=>null, "sql"=>"attcode", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalKey("userid", array("targetclass"=>"User", "jointype"=> "", "allowed_values"=>null, "sql"=>"userid", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("login", array("allowed_values"=>null, "extkey_attcode"=> 'userid', "target_attcode"=>"login")));
MetaModel::Init_AddAttribute(new AttributeString("class", array("allowed_values"=>null, "sql"=>"class", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("attcode", array("allowed_values"=>null, "sql"=>"attcode", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("action", array("label"=>"action", "description"=>"operations to perform on the given class", "allowed_values"=>null, "sql"=>"action", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeEnum("permission", array("label"=>"permission", "description"=>"allowed or not allowed?", "allowed_values"=>new ValueSetEnum('yes,no'), "sql"=>"permission", "default_value"=>"yes", "is_null_allowed"=>false, "depends_on"=>array())));
//MetaModel::Init_InheritFilters();
MetaModel::Init_AddFilterFromAttribute("userid");
MetaModel::Init_AddFilterFromAttribute("login");
MetaModel::Init_AddFilterFromAttribute("class");
MetaModel::Init_AddFilterFromAttribute("attcode");
MetaModel::Init_AddFilterFromAttribute("action");
MetaModel::Init_AddAttribute(new AttributeString("action", array("allowed_values"=>null, "sql"=>"action", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeEnum("permission", array("allowed_values"=>new ValueSetEnum('yes,no'), "sql"=>"permission", "default_value"=>"yes", "is_null_allowed"=>false, "depends_on"=>array())));
}
}
@@ -166,13 +118,14 @@ class UserRightsMatrix extends UserRightsAddOnAPI
);
// Installation: create the very first user
public function CreateAdministrator($sAdminUser, $sAdminPwd)
public function CreateAdministrator($sAdminUser, $sAdminPwd, $sLanguage = 'EN US')
{
// Maybe we should check that no other user with userid == 0 exists
$oUser = new UserRightsMatrixUsers();
$oUser = new UserLocal();
$oUser->Set('login', $sAdminUser);
$oUser->Set('password', $sAdminPwd);
$oUser->Set('userid', 1); // one is for root !
$oUser->Set('contactid', 1); // one is for root !
$oUser->Set('language', $sLanguage); // Language was chosen during the installation
// Create a change to record the history of the User object
$oChange = MetaModel::NewObject("CMDBChange");
@@ -181,21 +134,27 @@ class UserRightsMatrix extends UserRightsAddOnAPI
$iChangeId = $oChange->DBInsert();
// Now record the admin user object
$iUserId = $oUser->DBInsertTrackedNoReload($oChange);
$iUserId = $oUser->DBInsertTrackedNoReload($oChange, true /* skip security */);
$this->SetupUser($iUserId, true);
return true;
}
public function IsAdministrator($iUserId)
public function IsAdministrator($oUser)
{
return ($iUserId == 1);
return ($oUser->GetKey() == 1);
}
public function IsPortalUser($oUser)
{
return ($oUser->GetKey() == 1);
}
// Deprecated - create a new module !
public function Setup()
{
// Users must be added manually
// This procedure will then update the matrix when a new user is found or a new class/attribute appears
$oUserSet = new DBObjectSet(DBObjectSearch::FromSibuSQL("UserRightsMatrixUsers"));
$oUserSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT User"));
while ($oUser = $oUserSet->Fetch())
{
$this->SetupUser($oUser->GetKey());
@@ -281,6 +240,7 @@ class UserRightsMatrix extends UserRightsAddOnAPI
}
}
}
/*
// Create the "My Bookmarks" menu item (parent_id = 0, rank = 6)
if ($bNewUser)
{
@@ -304,6 +264,7 @@ class UserRightsMatrix extends UserRightsAddOnAPI
$oMenu->Set('user_id', $iUserId);
$oMenu->DBInsert();
}
*/
}
@@ -313,50 +274,13 @@ class UserRightsMatrix extends UserRightsAddOnAPI
return true;
}
public function CheckCredentials($sUserName, $sPassword)
{
$oSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT UserRightsMatrixUsers WHERE login = '$sUserName'"));
if ($oSet->Count() < 1)
{
// todo: throw an exception?
return false;
}
$oLogin = $oSet->Fetch();
if ($oLogin->Get('password') == $sPassword)
{
return $oLogin->Get('userid');
}
// todo: throw an exception?
return false;
}
public function GetUserId($sUserName)
{
$oSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT UserRightsMatrixUsers WHERE login = '$sUserName'"));
if ($oSet->Count() < 1)
{
// todo: throw an exception?
return false;
}
$oLogin = $oSet->Fetch();
return $oLogin->Get('userid');
}
public function GetContactId($sUserName)
{
// this module has no link with the business data
return null;
}
public function GetFilter($sUserName, $sClass)
public function GetSelectFilter($oUser, $sClass)
{
$oNullFilter = new DBObjectSearch($sClass);
return $oNullFilter;
}
public function IsActionAllowed($iUserId, $sClass, $iActionCode, $oInstanceSet = null)
public function IsActionAllowed($oUser, $sClass, $iActionCode, $oInstanceSet = null)
{
if (!array_key_exists($iActionCode, self::$m_aActionCodes))
{
@@ -364,7 +288,7 @@ class UserRightsMatrix extends UserRightsAddOnAPI
}
$sAction = self::$m_aActionCodes[$iActionCode];
$oSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT UserRightsMatrixClassGrant WHERE class = '$sClass' AND action = '$sAction' AND userid = '$iUserId'"));
$oSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT UserRightsMatrixClassGrant WHERE class = '$sClass' AND action = '$sAction' AND userid = '{$oUser->GetKey()}'"));
if ($oSet->Count() < 1)
{
return UR_ALLOWED_NO;
@@ -384,7 +308,7 @@ class UserRightsMatrix extends UserRightsAddOnAPI
return $iRetCode;
}
public function IsActionAllowedOnAttribute($iUserId, $sClass, $sAttCode, $iActionCode, $oInstanceSet = null)
public function IsActionAllowedOnAttribute($oUser, $sClass, $sAttCode, $iActionCode, $oInstanceSet = null)
{
if (!array_key_exists($iActionCode, self::$m_aActionCodes))
{
@@ -392,7 +316,7 @@ class UserRightsMatrix extends UserRightsAddOnAPI
}
$sAction = self::$m_aActionCodes[$iActionCode];
$oSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT UserRightsMatrixAttributeGrant WHERE class = '$sClass' AND attcode = '$sAttCode' AND action = '$sAction' AND userid = '$iUserId'"));
$oSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT UserRightsMatrixAttributeGrant WHERE class = '$sClass' AND attcode = '$sAttCode' AND action = '$sAction' AND userid = '{$oUser->GetKey()}'"));
if ($oSet->Count() < 1)
{
return UR_ALLOWED_NO;
@@ -412,9 +336,9 @@ class UserRightsMatrix extends UserRightsAddOnAPI
return $iRetCode;
}
public function IsStimulusAllowed($iUserId, $sClass, $sStimulusCode, $oInstanceSet = null)
public function IsStimulusAllowed($oUser, $sClass, $sStimulusCode, $oInstanceSet = null)
{
$oSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT UserRightsMatrixClassStimulusGrant WHERE class = '$sClass' AND stimulus = '$sStimulusCode' AND userid = '$iUserId'"));
$oSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT UserRightsMatrixClassStimulusGrant WHERE class = '$sClass' AND stimulus = '$sStimulusCode' AND userid = '{$oUser->GetKey()}'"));
if ($oSet->Count() < 1)
{
return UR_ALLOWED_NO;

View File

@@ -1,33 +1,43 @@
<?php
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* UserRightsNull
* User management Module - say Yeah! to everything
*
* @package iTopORM
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @author Denis Flaven <denisflave@free.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version 1.1.1.1 $
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
class UserRightsNull extends UserRightsAddOnAPI
{
// Installation: create the very first user
public function CreateAdministrator($sAdminUser, $sAdminPwd)
public function CreateAdministrator($sAdminUser, $sAdminPwd, $sLanguage = 'EN US')
{
return true;
}
public function IsAdministrator($iUserId)
public function IsAdministrator($oUser)
{
return true;
}
public function Setup()
public function IsPortalUser($oUser)
{
return true;
}
@@ -37,39 +47,23 @@ class UserRightsNull extends UserRightsAddOnAPI
return true;
}
public function CheckCredentials($sUserName, $sPassword)
{
return 1;
}
public function GetUserId($sUserName)
{
return 1;
}
public function GetContactId($sUserName)
{
// this module has no link with the business data
return null;
}
public function GetFilter($sUserName, $sClass)
public function GetSelectFilter($oUser, $sClass)
{
$oNullFilter = new DBObjectSearch($sClass);
return $oNullFilter;
}
public function IsActionAllowed($iUserId, $sClass, $iActionCode, $oInstanceSet = null)
public function IsActionAllowed($oUser, $sClass, $iActionCode, $oInstanceSet = null)
{
return UR_ALLOWED_YES;
}
public function IsStimulusAllowed($iUserId, $sClass, $sStimulusCode, $oInstanceSet = null)
public function IsStimulusAllowed($oUser, $sClass, $sStimulusCode, $oInstanceSet = null)
{
return UR_ALLOWED_YES;
}
public function IsActionAllowedOnAttribute($iUserId, $sClass, $sAttCode, $iActionCode, $oInstanceSet = null)
public function IsActionAllowedOnAttribute($oUser, $sClass, $sAttCode, $iActionCode, $oInstanceSet = null)
{
return UR_ALLOWED_YES;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,15 +1,30 @@
<?php
require_once("../application/webpage.class.inc.php");
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* Simple web page with no includes, header or fancy formatting, useful to
* generate HTML fragments when called by an AJAX method
*
* @package iTopApplication
* @access public
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @author Denis Flaven <dflaven@free.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
require_once(APPROOT."/application/webpage.class.inc.php");
class ajax_page extends WebPage
{
@@ -18,6 +33,9 @@ class ajax_page extends WebPage
* @var Hash
*/
protected $m_sReadyScript;
protected $m_sCurrentTab;
protected $m_sCurrentTabContainer;
protected $m_aTabs;
/**
* constructor for the web page
@@ -27,8 +45,46 @@ class ajax_page extends WebPage
{
parent::__construct($s_title);
$this->m_sReadyScript = "";
$this->add_header("Content-type: text/html; charset=utf-8");
$this->add_header("Cache-control: no-cache");
$this->m_sCurrentTabContainer = '';
$this->m_sCurrentTab = '';
$this->m_aTabs = array();
}
public function AddTabContainer($sTabContainer, $sPrefix = '')
{
$this->m_aTabs[$sTabContainer] = array('content' =>'', 'prefix' => $sPrefix);
$this->add("\$Tabs:$sTabContainer\$");
}
public function AddToTab($sTabContainer, $sTabLabel, $sHtml)
{
if (!isset($this->m_aTabs[$sTabContainer]['content'][$sTabLabel]))
{
// Set the content of the tab
$this->m_aTabs[$sTabContainer]['content'][$sTabLabel] = $sHtml;
}
else
{
// Append to the content of the tab
$this->m_aTabs[$sTabContainer]['content'][$sTabLabel] .= $sHtml;
}
}
public function SetCurrentTabContainer($sTabContainer = '')
{
$sPreviousTabContainer = $this->m_sCurrentTabContainer;
$this->m_sCurrentTabContainer = $sTabContainer;
return $sPreviousTabContainer;
}
public function SetCurrentTab($sTabLabel = '')
{
$sPreviousTab = $this->m_sCurrentTab;
$this->m_sCurrentTab = $sTabLabel;
return $sPreviousTab;
}
/**
* Echoes the content of the whole page
@@ -40,14 +96,88 @@ class ajax_page extends WebPage
{
header($s_header);
}
if (count($this->m_aTabs) > 0)
{
$this->add_ready_script(
<<<EOF
// The "tab widgets" to handle.
var tabs = $('div[id^=tabbedContent]');
// This selector will be reused when selecting actual tab widget A elements.
var tab_a_selector = 'ul.ui-tabs-nav a';
// Enable tabs on all tab widgets. The `event` property must be overridden so
// that the tabs aren't changed on click, and any custom event name can be
// specified. Note that if you define a callback for the 'select' event, it
// will be executed for the selected tab whenever the hash changes.
tabs.tabs({ event: 'change' });
// Define our own click handler for the tabs, overriding the default.
tabs.find( tab_a_selector ).click(function()
{
var state = {};
// Get the id of this tab widget.
var id = $(this).closest( 'div[id^=tabbedContent]' ).attr( 'id' );
// Get the index of this tab.
var idx = $(this).parent().prevAll().length;
// Set the state!
state[ id ] = idx;
$.bbq.pushState( state );
});
EOF
);
}
// Render the tabs in the page (if any)
foreach($this->m_aTabs as $sTabContainerName => $aTabContainer)
{
$sTabs = '';
$m_aTabs = $aTabContainer['content'];
$sPrefix = $aTabContainer['prefix'];
$container_index = 0;
if (count($m_aTabs) > 0)
{
$sTabs = "<!-- tabs -->\n<div id=\"tabbedContent_{$sPrefix}{$container_index}\" class=\"light\">\n";
$sTabs .= "<ul>\n";
// Display the unordered list that will be rendered as the tabs
$i = 0;
foreach($m_aTabs as $sTabName => $sTabContent)
{
$sTabs .= "<li><a href=\"#tab_{$sPrefix}$i\" class=\"tab\"><span>".htmlentities($sTabName, ENT_QUOTES, 'UTF-8')."</span></a></li>\n";
$i++;
}
$sTabs .= "</ul>\n";
// Now add the content of the tabs themselves
$i = 0;
foreach($m_aTabs as $sTabName => $sTabContent)
{
$sTabs .= "<div id=\"tab_{$sPrefix}$i\">".$sTabContent."</div>\n";
$i++;
}
$sTabs .= "</div>\n<!-- end of tabs-->\n";
}
$this->s_content = str_replace("\$Tabs:$sTabContainerName\$", $sTabs, $this->s_content);
$container_index++;
}
$s_captured_output = ob_get_contents();
ob_end_clean();
echo $this->s_content;
echo $this->s_deferred_content;
if (count($this->a_scripts) > 0)
{
echo "<script type=\"text/javascript\">\n";
echo implode("\n", $this->a_scripts);
echo "\n</script>\n";
}
if (!empty($this->m_sReadyScript))
{
echo "<script>\n";
echo "<script type=\"text/javascript\">\n";
echo $this->m_sReadyScript; // Ready Scripts are output as simple scripts
echo "</script>\n";
echo "\n</script>\n";
}
if (trim($s_captured_output) != "")
{
@@ -64,70 +194,19 @@ class ajax_page extends WebPage
public function small_p($sText)
{
}
public function add($sHtml)
{
if (!empty($this->m_sCurrentTabContainer) && !empty($this->m_sCurrentTab))
{
$this->AddToTab($this->m_sCurrentTabContainer, $this->m_sCurrentTab, $sHtml);
}
else
{
parent::add($sHtml);
}
}
/**
* Adds a tabular content to the web page
* @param Hash $aConfig Configuration of the table: hash array of 'column_id' => 'Column Label'
* @param Hash $aData Hash array. Data to display in the table: each row is made of 'column_id' => Data. A column 'pkey' is expected for each row
* @param Hash $aParams Hash array. Extra parameters for the table. Entry 'class' holds the class of the objects listed in the table
* @return void
*/
public function table($aConfig, $aData, $aParams = array())
{
// WARNING WARNING WARNING
// This whole function is actually a copy paste from iTopWebPage::table
$oAppContext = new ApplicationContext();
static $iNbTables = 0;
$iNbTables++;
$sHtml = "";
$sHtml .= "<table class=\"listResults\">\n";
$sHtml .= "<thead>\n";
$sHtml .= "<tr>\n";
foreach($aConfig as $sName=>$aDef)
{
$sHtml .= "<th title=\"".$aDef['description']."\">".$aDef['label']."</th>\n";
}
$sHtml .= "</tr>\n";
$sHtml .= "</thead>\n";
$sHtml .= "<tbody>\n";
foreach($aData as $aRow)
{
if (false) //(isset($aParams['preview']) && $aParams['preview'])
{
$sHtml .= "<tr id=\"Row_".$iNbTables."_".$aRow['key']."\" onClick=\"DisplayPreview(".$iNbTables.",".$aRow['key'].",'".$aParams['class']."')\">\n";
}
else if (isset($aRow['key']))
{
$sHtml .= "<tr onDblClick=\"DisplayDetails(".$aRow['key'].",'".$aParams['class']."')\">\n";
}
else
{
$sHtml .= "<tr>\n";
}
foreach($aConfig as $sName=>$aVoid)
{
if ($sName != 'key')
{
$sValue = empty($aRow[$sName]) ? '&nbsp;' : $aRow[$sName];
$sHtml .= "<td>$sValue</td>\n";
}
else
{
$sUIPage = cmdbAbstractObject::ComputeUIPage($aParams['class']);
$sHtml .= "<td><a class=\"no-arrow\" href=\"$sUIPage?operation=details&id=".$aRow['key']."&class=".$aParams['class']."&".$oAppContext->GetForLink()."\"><img src=\"../images/zoom.gif\" title=\"Details\" border=\"0\"></a></td>\n";
}
}
$sHtml .= "</tr>\n";
}
$sHtml .= "</tbody>\n";
$sHtml .= "</table>\n";
if (isset($aParams['preview']) && $aParams['preview'])
{
$sHtml .= "<div class=\"PreviewPane\" id=\"PreviewPane_".$iNbTables."\" style=\"height:100px;border:1px solid black;margin-top:2px;padding:3px;text-align:left;display:none;\">Preview Pane</div>";
}
$this->add($sHtml);
}
/**
* Adds a script to be executed when the DOM is ready (typical JQuery use)
* NOT implemented in this version of the class.
@@ -140,6 +219,17 @@ class ajax_page extends WebPage
// considering that at this time everything in the page is "ready"...
$this->m_sReadyScript .= $sScript;
}
/**
* Cannot be called in this context, since Ajax pages do not share
* any context with the calling page !!
*/
public function GetUniqueId()
{
assert(false);
return 0;
}
}
?>

View File

@@ -1,13 +1,35 @@
<?php
// Includes all the classes to have the application up and running
require_once('../application/applicationcontext.class.inc.php');
require_once('../application/usercontext.class.inc.php');
require_once('../application/cmdbabstract.class.inc.php');
require_once('../application/displayblock.class.inc.php');
require_once('../application/audit.category.class.inc.php');
require_once('../application/audit.rule.class.inc.php');
//require_once('../application/menunode.class.inc.php');
require_once('../application/utils.inc.php');
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* Includes all the classes to have the application up and running
*
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
require_once(APPROOT.'/application/applicationcontext.class.inc.php');
require_once(APPROOT.'/application/cmdbabstract.class.inc.php');
require_once(APPROOT.'/application/displayblock.class.inc.php');
require_once(APPROOT.'/application/audit.category.class.inc.php');
require_once(APPROOT.'/application/audit.rule.class.inc.php');
//require_once(APPROOT.'/application/menunode.class.inc.php');
require_once(APPROOT.'/application/utils.inc.php');
class ApplicationException extends CoreException
{

View File

@@ -1,5 +1,29 @@
<?php
require_once("../application/utils.inc.php");
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* Class ApplicationContext
*
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
require_once(APPROOT."/application/utils.inc.php");
/**
* Helper class to store and manipulate the parameters that make the application's context
*
@@ -33,19 +57,52 @@ class ApplicationContext
if (empty(self::$aDefaultValues))
{
self::$aDefaultValues = array();
$aContext = utils::ReadParam('c', array());
foreach($this->aNames as $sName)
{
$sValue = utils::ReadParam($sName, '');
$sValue = isset($aContext[$sName]) ? $aContext[$sName] : '';
// TO DO: check if some of the context parameters are mandatory (or have default values)
if (!empty($sValue))
{
self::$aDefaultValues[$sName] = $sValue;
}
// Hmm, there must be a better (more generic) way to handle the case below:
// When there is only one possible (allowed) organization, the context must be
// fixed to this org
if ($sName == 'org_id')
{
if (MetaModel::IsValidClass('Organization'))
{
$oSearchFilter = new DBObjectSearch('Organization');
$oSet = new CMDBObjectSet($oSearchFilter);
$iCount = $oSet->Count();
if ($iCount == 1)
{
// Only one possible value for org_id, set it in the context
$oOrg = $oSet->Fetch();
self::$aDefaultValues[$sName] = $oOrg->GetKey();
}
}
}
}
}
$this->aValues = self::$aDefaultValues;
}
/**
* Returns the current value for the given parameter
* @param string $sParamName Name of the parameter to read
* @return mixed The value for this parameter
*/
public function GetCurrentValue($sParamName, $defaultValue = '')
{
if (isset($this->aValues[$sParamName]))
{
return $this->aValues[$sParamName];
}
return $defaultValue;
}
/**
* Returns the context as string with the format name1=value1&name2=value2....
* return string The context as a string to be appended to an href property
@@ -55,7 +112,7 @@ class ApplicationContext
$aParams = array();
foreach($this->aValues as $sName => $sValue)
{
$aParams[] = $sName.'='.urlencode($sValue);
$aParams[] = "c[$sName]".'='.urlencode($sValue);
}
return implode("&", $aParams);
}
@@ -69,7 +126,7 @@ class ApplicationContext
$sContext = "";
foreach($this->aValues as $sName => $sValue)
{
$sContext .= "<input type=\"hidden\" name=\"$sName\" value=\"$sValue\" />\n";
$sContext .= "<input type=\"hidden\" name=\"c[$sName]\" value=\"$sValue\" />\n";
}
return $sContext;
}
@@ -80,7 +137,21 @@ class ApplicationContext
*/
public function GetAsHash()
{
return $this->aValues;
$aReturn = array();
foreach($this->aValues as $sName => $sValue)
{
$aReturn["c[$sName]"] = $sValue;
}
return $aReturn;
}
/**
* Returns an array of the context parameters NAMEs
* @return array The list of context parameters
*/
public function GetNames()
{
return $this->aNames;
}
/**
* Removes the specified parameter from the context, for example when the same parameter

View File

@@ -1,11 +1,32 @@
<?php
require_once('../application/cmdbabstract.class.inc.php');
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* This class manages the audit "categories". Each category defines a set of objects
* to check and is linked to a set of rules that determine the valid or invalid objects
* inside the set
*
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
require_once(APPROOT.'/application/cmdbabstract.class.inc.php');
class AuditCategory extends cmdbAbstractObject
{
public static function Init()
@@ -13,30 +34,23 @@ class AuditCategory extends cmdbAbstractObject
$aParams = array
(
"category" => "application",
"name" => "AuditCategory",
"description" => "A section inside the overall audit",
"key_type" => "autoincrement",
"key_label" => "",
"name_attcode" => "name",
"state_attcode" => "",
"reconc_keys" => array('name'),
"db_table" => "priv_auditcategory",
"db_key_field" => "id",
"db_finalclass_field" => "",
"display_template" => "../application/templates/audit_category.html",
);
MetaModel::Init_Params($aParams);
MetaModel::Init_AddAttribute(new AttributeString("name", array("label"=>"Category Name", "description"=>"Short name for this category", "allowed_values"=>null, "sql"=>"name", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("description", array("label"=>"Audit Category Description", "description"=>"Long description for this audit category", "allowed_values"=>null, "sql"=>"description", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("definition_set", array("label"=>"Definition Set", "description"=>"SibusQL expression defining the set of objects to audit", "allowed_values"=>null, "sql"=>"definition_set", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddFilterFromAttribute("name");
MetaModel::Init_AddFilterFromAttribute("description");
MetaModel::Init_AddFilterFromAttribute("definition_set");
MetaModel::Init_AddAttribute(new AttributeString("name", array("description"=>"Short name for this category", "allowed_values"=>null, "sql"=>"name", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("description", array("allowed_values"=>null, "sql"=>"description", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeOQL("definition_set", array("allowed_values"=>null, "sql"=>"definition_set", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeLinkedSet("rules_list", array("linked_class"=>"AuditRule", "ext_key_to_me"=>"category_id", "allowed_values"=>null, "count_min"=>0, "count_max"=>0, "depends_on"=>array())));
// Display lists
MetaModel::Init_SetZListItems('details', array('name', 'description', 'definition_set')); // Attributes to be displayed for the complete details
MetaModel::Init_SetZListItems('list', array('name', 'description', )); // Attributes to be displayed for a list
MetaModel::Init_SetZListItems('details', array('name', 'description', 'definition_set', 'rules_list')); // Attributes to be displayed for the complete details
MetaModel::Init_SetZListItems('list', array('description', )); // Attributes to be displayed for a list
// Search criteria
MetaModel::Init_SetZListItems('standard_search', array('name', 'description')); // Criteria of the std search form
MetaModel::Init_SetZListItems('advanced_search', array('name', 'description', 'definition_set')); // Criteria of the advanced search form

View File

@@ -1,12 +1,33 @@
<?php
require_once('../application/audit.category.class.inc.php');
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* This class manages the audit "rule" linked to a given audit category.
* Each rule is based ona SibusQL expression that returns either the "good" objects
* Each rule is based on an OQL expression that returns either the "good" objects
* or the "bad" ones. The core audit engines computes the complement to the definition
* set when needed to obtain either the valid objects, or the ones with an error
*
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
require_once(APPROOT.'/application/audit.category.class.inc.php');
class AuditRule extends cmdbAbstractObject
{
public static function Init()
@@ -14,36 +35,26 @@ class AuditRule extends cmdbAbstractObject
$aParams = array
(
"category" => "application",
"name" => "AuditRule",
"description" => "A rule to check for a given Audit category",
"key_type" => "autoincrement",
"key_label" => "",
"name_attcode" => "name",
"state_attcode" => "",
"reconc_keys" => array('name'),
"db_table" => "priv_auditrule",
"db_key_field" => "id",
"db_finalclass_field" => "",
"display_template" => "../business/templates/default.html",
"display_template" => "",
);
MetaModel::Init_Params($aParams);
MetaModel::Init_AddAttribute(new AttributeString("name", array("label"=>"Rule Name", "description"=>"Short name for this rule", "allowed_values"=>null, "sql"=>"name", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("description", array("label"=>"Audit Rule Description", "description"=>"Long description for this audit rule", "allowed_values"=>null, "sql"=>"description", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("query", array("label"=>"Query to Run", "description"=>"The SibusQL expression to run", "allowed_values"=>null, "sql"=>"query", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeEnum("valid_flag", array("label"=>"Valid objects?", "description"=>"True if the rule returns the valid objects, false otherwise", "allowed_values"=>new ValueSetEnum('true,false'), "sql"=>"valid_flag", "default_value"=>"true", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalKey("category_id", array("label"=>"Category", "description"=>"The category for this rule", "allowed_values"=>null, "sql"=>"category_id", "targetclass"=>"AuditCategory", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("category_name", array("label"=>"Category", "description"=>"Name of the category for this rule", "allowed_values"=>null, "extkey_attcode"=> 'category_id', "target_attcode"=>"name")));
MetaModel::Init_AddFilterFromAttribute("name");
MetaModel::Init_AddFilterFromAttribute("description");
MetaModel::Init_AddFilterFromAttribute("query");
MetaModel::Init_AddFilterFromAttribute("valid_flag");
MetaModel::Init_AddFilterFromAttribute("category_id");
MetaModel::Init_AddFilterFromAttribute("category_name");
MetaModel::Init_AddAttribute(new AttributeString("name", array("allowed_values"=>null, "sql"=>"name", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("description", array("allowed_values"=>null, "sql"=>"description", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeOQL("query", array("allowed_values"=>null, "sql"=>"query", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeEnum("valid_flag", array("allowed_values"=>new ValueSetEnum('true,false'), "sql"=>"valid_flag", "default_value"=>"true", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalKey("category_id", array("allowed_values"=>null, "sql"=>"category_id", "targetclass"=>"AuditCategory", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("category_name", array("allowed_values"=>null, "extkey_attcode"=> 'category_id', "target_attcode"=>"name")));
// Display lists
MetaModel::Init_SetZListItems('details', array('category_id', 'name', 'description', 'query', 'valid_flag')); // Attributes to be displayed for the complete details
MetaModel::Init_SetZListItems('list', array('category_id', 'name', 'description', 'valid_flag')); // Attributes to be displayed for a list
MetaModel::Init_SetZListItems('list', array('category_id', 'description', 'valid_flag')); // Attributes to be displayed for a list
// Search criteria
MetaModel::Init_SetZListItems('standard_search', array('category_id', 'name', 'description', 'valid_flag')); // Criteria of the std search form
MetaModel::Init_SetZListItems('advanced_search', array('category_id', 'name', 'description', 'valid_flag', 'query')); // Criteria of the advanced search form

View File

@@ -0,0 +1,88 @@
<?php
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* CLI page
* The page adds the content-type text/XML and the encoding into the headers
*
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
require_once(APPROOT."/application/webpage.class.inc.php");
class CLIPage
{
function __construct($s_title)
{
}
public function output()
{
}
public function add($sText)
{
echo $sText;
}
public function p($sText)
{
echo $sText."\n";
}
public function pre($sText)
{
echo $sText."\n";
}
public function add_comment($sText)
{
echo "#".$sText."\n";
}
public function table($aConfig, $aData, $aParams = array())
{
$aCells = array();
foreach($aConfig as $sName=>$aDef)
{
if (strlen($aDef['description']) > 0)
{
$aCells[] = $aDef['label'].' ('.$aDef['description'].')';
}
else
{
$aCells[] = $aDef['label'];
}
}
echo implode(';', $aCells)."\n";
foreach($aData as $aRow)
{
$aCells = array();
foreach($aConfig as $sName=>$aAttribs)
{
$sValue = $aRow["$sName"];
$aCells[] = $sValue;
}
echo implode(';', $aCells)."\n";
}
}
}
?>

File diff suppressed because it is too large Load Diff

View File

@@ -1,15 +1,37 @@
<?php
require_once("../application/webpage.class.inc.php");
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* Simple web page with no includes or fancy formatting, useful to generateXML documents
* The page adds the content-type text/XML and the encoding into the headers
*
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
require_once(APPROOT."/application/webpage.class.inc.php");
class CSVPage extends WebPage
{
function __construct($s_title)
{
parent::__construct($s_title);
$this->add_header("Content-type: text/html; charset=iso-8859-1");
$this->add_header("Content-type: text/html; charset=utf-8");
$this->add_header("Cache-control: no-cache");
}
@@ -23,13 +45,52 @@ class CSVPage extends WebPage
echo trim($this->s_content);
}
public function small_p($sText)
{
public function small_p($sText)
{
}
public function add($sText)
{
$this->s_content .= $sText;
}
public function p($sText)
{
$this->s_content .= $sText."\n";
}
public function add_comment($sText)
{
$this->s_content .= "#".$sText."\n";
}
public function table($aConfig, $aData, $aParams = array())
{
$aCells = array();
foreach($aConfig as $sName=>$aDef)
{
if (strlen($aDef['description']) > 0)
{
$aCells[] = $aDef['label'].' ('.$aDef['description'].')';
}
else
{
$aCells[] = $aDef['label'];
}
}
$this->s_content .= implode(';', $aCells)."\n";
foreach($aData as $aRow)
{
$aCells = array();
foreach($aConfig as $sName=>$aAttribs)
{
$sValue = $aRow["$sName"];
$aCells[] = $sValue;
}
$this->s_content .= implode(';', $aCells)."\n";
}
}
}
?>
?>

View File

@@ -1,252 +0,0 @@
<?php
/**
* Helper class to allow modal-style dialog box in an html form
*
* Possible improvement: do not use _SESSION for the caller's data,
* instead set a member variable with caller information
* and take the opportunity of the first edit button to place the information
* into a hidden field
*
* Usage:
*/
define('DLGSTACK_OK', 1);
define('DLGSTACK_CANCEL', 2);
//session_name("dialogstack");
session_start();
class dialogstack
{
private static $m_bCurrPageDeclared = false;
/**
* Declare the current page as being a dialog issuer, potentially pop...
*/
static public function DeclareCaller($sTitle)
{
self::$m_bCurrPageDeclared = false;
$_SESSION['dialogstack_calleruri'] = $_SERVER["REQUEST_URI"];
$_SESSION['dialogstack_callertitle'] = $sTitle;
if (isset($_POST["dialogstackpop"]) && ($_POST["dialogstackpop"] == count($_SESSION['dialogstack_currdlg'])))
{
// Pop !
array_pop($_SESSION['dialogstack_currdlg']);
}
}
/**
* True if the current page has been loaded from an "dialog startup button"
*/
static private function GetRetArgName()
{
foreach($_REQUEST as $sArgName=>$sArgValue)
{
if (strstr($sArgName, "dlgstack_go,"))
{
$aTokens = explode(",", $sArgName);
return self::ArgNameDecode($aTokens[1]);
}
}
return "";
}
/**
* Protect against weird effects of PHP interpreting brackets...
*/
static private function ArgNameEncode($sArgName)
{
return str_replace(array('[', ']'), array('_bracket_open_', '_bracket_close_'), $sArgName);
}
static private function ArgNameDecode($sCodedArgName)
{
return str_replace(array('_bracket_open_', '_bracket_close_'), array('[', ']'), $sCodedArgName);
}
/**
* True if the current page has been loaded from an "dialog startup button"
*/
static public function IsDialogStartup()
{
return (strlen(self::GetRetArgName()) > 0);
}
/**
* Helper to
*/
static private function RemoveArg(&$aValues, $sKey, &$retval = null)
{
if (isset($aValues[$sKey]))
{
if (empty($retval))
{
$retval = $aValues[$sKey];
}
unset($aValues[$sKey]);
}
}
/**
* Record current page args, and returns the initial value for the dialog
*/
static public function StartDialog()
{
if (!isset($_SESSION['dialogstack_currdlg']))
{
// Init stack
$_SESSION['dialogstack_currdlg'] = array();
}
$sRetArgName = self::GetRetArgName();
$sCodedArgName = self::ArgNameEncode($sRetArgName);
$sArgForRetArgName = "dlgstack_init_".$sCodedArgName;
$sButtonName = "dlgstack_go,".$sCodedArgName;
// Do not record utility arguments, neither the current value (stored separately)
//
$initValue = null;
$aPost = $_POST;
self::RemoveArg($aPost, $sArgForRetArgName, $initValue);
self::RemoveArg($aPost, $sButtonName);
self::RemoveArg($aPost, 'dlgstack_onok_page', $sOnOKPage);
self::RemoveArg($aPost, 'dlgstack_onok_args', $aOnOKArgs);
$aGet = $_GET;
self::RemoveArg($aGet, $sArgForRetArgName, $initValue);
self::RemoveArg($aGet, $sButtonName);
self::RemoveArg($aGet, 'dlgstack_onok_page', $sOnOKPage);
self::RemoveArg($aGet, 'dlgstack_onok_args', $aOnOKArgs);
if (self::$m_bCurrPageDeclared)
{
throw new Exception("DeclareCaller() must not be called before StartDialog()");
}
$aCall = array(
"title"=>$_SESSION['dialogstack_callertitle'],
"uri"=>$_SESSION['dialogstack_calleruri'],
"post"=>$aPost,
"get"=>$aGet,
"retarg"=>$sRetArgName,
"initval"=>$initValue,
);
if (isset($sOnOKPage)) $aCall["onok_page"] = $sOnOKPage;
if (isset($aOnOKArgs)) $aCall["onok_args"] = $aOnOKArgs;
array_push($_SESSION['dialogstack_currdlg'], $aCall);
return $initValue;
}
/**
* Render a button to launch a new dialog
*/
static public function RenderEditableField($sTitle, $sArgName, $sCurrValue, $bAddFieldValue, $sOnOKPage = "", $aOnOKArgs = array())
{
$sRet = "";
$sCodedArgName = self::ArgNameEncode($sArgName);
if ($bAddFieldValue)
{
$sRet .= "<input type=\"hidden\" name=\"$sArgName\" value=\"$sCurrValue\">\n";
}
$sRet .= "<input type=\"hidden\" name=\"dlgstack_init_$sCodedArgName\" value=\"$sCurrValue\">\n";
$sRet .= "<input type=\"submit\" name=\"dlgstack_go,$sCodedArgName\" value=\"$sTitle\">\n";
if (!empty($sOnOKPage))
{
$sRet .= "<input type=\"hidden\" name=\"dlgstack_onok_page\" value=\"$sCurrValue\">\n";
}
foreach($aOnOKArgs as $sArgName=>$value)
{
$sRet .= "<input type=\"hidden\" name=\"dlgstack_onok_args[$sArgName]\" value=\"$value\">\n";
}
return $sRet;
}
/**
* Render a [set of] hidden field, from a value that may be an array
*/
static private function RenderHiddenField($sName, $value)
{
$sRet = "";
if (is_array($value))
{
foreach($value as $sKey=>$subvalue)
{
$sRet .= self::RenderHiddenField($sName.'['.$sKey.']', $subvalue);
}
}
else
{
$sRet .= "<input type=\"hidden\" name=\"$sName\" value=\"$value\">\n";
}
return $sRet;
}
/**
* Render a form to end the current dialog and return to the caller
*/
static public function RenderEndDialogForm($iButtonStyle, $sTitle, $sRetValue = null)
{
$aCall = end($_SESSION['dialogstack_currdlg']);
if (!$aCall) return;
return self::privRenderEndDialogForm($aCall, $iButtonStyle, $sTitle, $sRetValue);
}
/**
* Returns an array of buttons to get back to upper dialog levels
*/
static public function GetCurrentStack()
{
$aRet = array();
if (isset($_SESSION['dialogstack_currdlg']))
{
foreach ($_SESSION['dialogstack_currdlg'] as $aCall)
{
$aRet[] = self::privRenderEndDialogForm($aCall, DLGSTACK_CANCEL, $aCall["title"]);
}
}
return $aRet;
}
/**
* Render a form to end the current dialog and return to the caller
*/
static private function privRenderEndDialogForm($aCall, $iButtonStyle, $sTitle, $sRetValue = null)
{
if (($iButtonStyle == DLGSTACK_OK) && isset($aCall["onok_page"])) $sFormAction = $aCall["onok_page"];
else $sFormAction = $aCall["uri"];
$sRet = "<form method=\"post\" action=\"$sFormAction\">\n";
foreach ($aCall["post"] as $sName=>$value)
{
$sRet .= self::RenderHiddenField($sName, $value);
}
if ($iButtonStyle == DLGSTACK_OK)
{
if (isset($aCall["onok_args"]))
{
foreach($aCall["onok_args"] as $sArgName=>$value)
{
$sRet .= "<input type=\"hidden\" name=\"$sArgName\" value=\"$value\">\n";
}
}
$sRet .= "<input type=\"hidden\" name=\"".$aCall["retarg"]."\" value=\"$sRetValue\">\n";
$sRet .= "<input type=\"submit\" name=\"dlgstackOK\" value=\"$sTitle, (OK) Back to ".$aCall["title"]."\">\n";
}
elseif ($iButtonStyle == DLGSTACK_CANCEL)
{
if (!is_null($aCall["initval"]))
{
$sRet .= "<input type=\"hidden\" name=\"".$aCall["retarg"]."\" value=\"".$aCall["initval"]."\">\n";
}
$sRet .= "<input type=\"submit\" name=\"dlgstackCANCEL\" value=\"$sTitle\">\n";
}
else
{
throw new Exception("Wrong value for button style ($iButtonStyle)");
}
$sRet .= "<input type=\"hidden\" name=\"dialogstackpop\" value=\"".count($_SESSION['dialogstack_currdlg'])."\">\n";
$sRet .= "</form>\n";
return $sRet;
}
}
?>

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,29 @@
<?php
require_once('../application/cmdbabstract.class.inc.php');
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* Persistent class InputOutputTask
*
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
require_once(APPROOT.'/application/cmdbabstract.class.inc.php');
/**
* This class manages the input/output tasks
@@ -12,40 +36,30 @@ class InputOutputTask extends cmdbAbstractObject
$aParams = array
(
"category" => "application",
"name" => "IOTask",
"description" => "Input / Output Task for synchronizing information with external data sources",
"key_type" => "autoincrement",
"key_label" => "",
"name_attcode" => "name",
"state_attcode" => "",
"reconc_keys" => array(),
"db_table" => "priv_iotask",
"db_key_field" => "id",
"db_finalclass_field" => "",
"display_template" => "../business/templates/default.html",
"display_template" => "",
);
MetaModel::Init_Params($aParams);
MetaModel::Init_AddAttribute(new AttributeString("name", array("label"=>"Task Name", "description"=>"Short name for this task", "allowed_values"=>null, "sql"=>"name", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("description", array("label"=>"Task Description", "description"=>"Long description for this task", "allowed_values"=>null, "sql"=>"description", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeEnum("category", array("label"=>"Category", "description"=>"Type of task", "allowed_values"=>new ValueSetEnum('Input, Ouput'), "sql"=>"category", "default_value"=>"Input", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeEnum("source_type", array("label"=>"Source Type", "description"=>"Type of data source", "allowed_values"=>new ValueSetEnum('File, Database, Web Service'), "sql"=>"source_type", "default_value"=>"File", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeEnum("source_subtype", array("label"=>"Source Subtype", "description"=>"Subtype of Data Source", "allowed_values"=>new ValueSetEnum('Oracle, MySQL, Postgress, MSSQL, SOAP, HTTP-Get, HTTP-Post, XML/RPC, CSV, XML, Excel'), "sql"=>"source_subtype", "default_value"=>"CSV", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("source_path", array("label"=>"Source Path", "description"=>"Path to the icon o the menu", "allowed_values"=>null, "sql"=>"source_path", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeClass("objects_class", array("label"=>"Objects Class", "description"=>"Class of the objects processed by this task", "class_category"=>"", "more_values"=>"", "sql"=>"objects_class", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeEnum("test_mode", array("label"=>"Test Mode", "description"=>"If set to 'Yes' the modifications are not applied", "allowed_values"=>new ValueSetEnum('Yes,No'), "sql"=>"test_mode", "default_value"=>'No', "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeEnum("verbose_mode", array("label"=>"Verbose Mode", "description"=>"If set to 'Yes' extra debug information is added to the log", "allowed_values"=>new ValueSetEnum('Yes,No'), "sql"=>"verbose_mode", "default_value" => 'No', "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeEnum("options", array("label"=>"Options", "description"=>"Reconciliation options", "allowed_values"=>new ValueSetEnum('Full, Update Only, Creation Only'), "sql"=>"options", "default_value"=> 'Full', "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddFilterFromAttribute("name");
MetaModel::Init_AddFilterFromAttribute("description");
MetaModel::Init_AddFilterFromAttribute("category");
MetaModel::Init_AddFilterFromAttribute("source_type");
MetaModel::Init_AddFilterFromAttribute("source_subtype");
MetaModel::Init_AddFilterFromAttribute("objects_class");
MetaModel::Init_AddAttribute(new AttributeString("name", array("allowed_values"=>null, "sql"=>"name", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("description", array("allowed_values"=>null, "sql"=>"description", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeEnum("category", array("allowed_values"=>new ValueSetEnum('Input, Ouput'), "sql"=>"category", "default_value"=>"Input", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeEnum("source_type", array("allowed_values"=>new ValueSetEnum('File, Database, Web Service'), "sql"=>"source_type", "default_value"=>"File", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeEnum("source_subtype", array("allowed_values"=>new ValueSetEnum('Oracle, MySQL, Postgress, MSSQL, SOAP, HTTP-Get, HTTP-Post, XML/RPC, CSV, XML, Excel'), "sql"=>"source_subtype", "default_value"=>"CSV", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("source_path", array("allowed_values"=>null, "sql"=>"source_path", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeClass("objects_class", array("class_category"=>"", "more_values"=>"", "sql"=>"objects_class", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeEnum("test_mode", array("allowed_values"=>new ValueSetEnum('Yes,No'), "sql"=>"test_mode", "default_value"=>'No', "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeEnum("verbose_mode", array("allowed_values"=>new ValueSetEnum('Yes,No'), "sql"=>"verbose_mode", "default_value" => 'No', "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeEnum("options", array("allowed_values"=>new ValueSetEnum('Full, Update Only, Creation Only'), "sql"=>"options", "default_value"=> 'Full', "is_null_allowed"=>true, "depends_on"=>array())));
// Display lists
MetaModel::Init_SetZListItems('details', array('name', 'description', 'category', 'objects_class', 'source_type', 'source_subtype', 'source_path' , 'options', 'test_mode', 'verbose_mode')); // Attributes to be displayed for the complete details
MetaModel::Init_SetZListItems('list', array('name', 'description', 'category', 'objects_class', 'source_type', 'source_subtype', 'options')); // Attributes to be displayed for a list
MetaModel::Init_SetZListItems('list', array('description', 'category', 'objects_class', 'source_type', 'source_subtype', 'options')); // Attributes to be displayed for a list
// Search criteria
MetaModel::Init_SetZListItems('standard_search', array('name', 'category', 'objects_class', 'source_type', 'source_subtype')); // Criteria of the std search form
MetaModel::Init_SetZListItems('advanced_search', array('name', 'description', 'category', 'objects_class', 'source_type', 'source_subtype')); // Criteria of the advanced search form

View File

@@ -1,19 +1,43 @@
<?php
require_once("../application/nicewebpage.class.inc.php");
require_once("../application/usercontext.class.inc.php");
require_once("../application/applicationcontext.class.inc.php");
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* Class iTopWebPage
*
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
require_once(APPROOT."/application/nicewebpage.class.inc.php");
require_once(APPROOT."/application/applicationcontext.class.inc.php");
require_once(APPROOT."/application/user.preferences.class.inc.php");
/**
* Web page with some associated CSS and scripts (jquery) for a fancier display
*/
class iTopWebPage extends NiceWebPage
{
private $m_sMenu;
private $m_currentOrganization;
// private $m_currentOrganization;
private $m_aTabs;
private $m_sCurrentTabContainer;
private $m_sCurrentTab;
public function __construct($sTitle, $currentOrganization)
public function __construct($sTitle)
{
parent::__construct($sTitle);
$this->m_sCurrentTabContainer = '';
@@ -22,98 +46,322 @@ class iTopWebPage extends NiceWebPage
$this->m_sMenu = "";
$oAppContext = new ApplicationContext();
$sExtraParams = $oAppContext->GetForLink();
// $this->m_currentOrganization = $currentOrganization;
$this->add_header("Content-type: text/html; charset=utf-8");
$this->add_header("Cache-control: no-cache");
$this->m_currentOrganization = $currentOrganization;
$this->add_linked_script("../js/jquery.dimensions.js");
$this->add_linked_script("../js/splitter.js");
$this->add_linked_stylesheet("../css/jquery.treeview.css");
$this->add_linked_stylesheet("../css/jquery.autocomplete.css");
// $this->add_linked_stylesheet("../css/date.picker.css");
$this->add_linked_script('../js/jquery.layout.min.js');
$this->add_linked_script('../js/jquery.ba-bbq.min.js');
// $this->add_linked_script("../js/jquery.dimensions.js");
$this->add_linked_script("../js/jquery.tablehover.js");
$this->add_linked_script("../js/jquery.treeview.js");
$this->add_linked_script("../js/jquery.autocomplete.js");
$this->add_linked_script("../js/jquery.bgiframe.js");
$this->add_linked_script("../js/jquery.jdMenu.js");
$this->add_linked_script("../js/jquery.positionBy.js");
$this->add_linked_script("../js/jquery.popupmenu.js");
$this->add_linked_script("../js/date.js");
$this->add_linked_script("../js/jquery.date.picker.js");
// $this->add_linked_script("../js/jquery.date.picker.js");
$this->add_linked_script("../js/jquery.tablesorter.min.js");
$this->add_linked_script("../js/jquery.blockUI.js");
$this->add_linked_script("../js/utils.js");
//$this->add_linked_script("../js/jquery-ui-personalized-1.5.3.js");
$this->add_linked_script("../js/swfobject.js");
$this->add_linked_stylesheet("../css/jquery.treeview.css");
$this->add_linked_stylesheet("../css/jquery.autocomplete.css");
$this->add_linked_stylesheet("../css/date.picker.css");
$this->add_linked_script("../js/ckeditor/ckeditor.js");
$this->add_linked_script("../js/ckeditor/adapters/jquery.js");
$this->add_ready_script(
<<<EOF
// Vertical splitter. The min/max/starting sizes for the left (A) pane
// are set here. All values are in pixels.
$("#MySplitter").splitter({
type: "v",
minA: 100, initA: 250, maxA: 500,
accessKey: "|"
try
{
var myLayout; // a var is required because this page utilizes: myLayout.allowOverflow() method
$(document).ready(function () {
// Layout
paneSize = GetUserPreference('menu_size', 300)
myLayout = $('body').layout({
west : {
minSize: 200, size: paneSize, spacing_open: 16, spacing_close: 16, slideTrigger_open: "mouseover", hideTogglerOnSlide: true,
onclose_end: function(name, elt, state, options, layout)
{
if (state.isSliding == false)
{
SetUserPreference('menu_pane', 'closed', true);
}
},
onresize_end: function(name, elt, state, options, layout)
{
if (state.isSliding == false)
{
SetUserPreference('menu_size', state.size, true);
}
},
onopen_end: function(name, elt, state, options, layout)
{
if (state.isSliding == false)
{
SetUserPreference('menu_pane', 'open', true);
}
}
},
center: {
onresize_end: function(name, elt, state, options, layout)
{
$('.v-resizable').each( function() {
var fixedWidth = $(this).parent().innerWidth() - 6;
$(this).width(fixedWidth);
// Make sure it cannot be resized horizontally
$(this).resizable('options', { minWidth: fixedWidth, maxWidth: fixedWidth });
// Now adjust all the child 'items'
var innerWidth = $(this).innerWidth() - 10;
$(this).find('.item').width(innerWidth);
});
}
}
});
myLayout.addPinBtn( "#tPinMenu", "west" );
//myLayout.open( "west" );
$('.ui-layout-resizer-west').html('<img src="../images/splitter-top-corner.png"/>');
if (GetUserPreference('menu_pane', 'open') == 'closed')
{
myLayout.close('west');
}
// Accordion Menu
$("#accordion").accordion({ header: "h3", navigation: true, autoHeight: false, collapsible: false, icons: false }); // collapsible will be enabled once the item will be selected
});
//add new widget called TruncatedList to properly display truncated lists when they are sorted
$.tablesorter.addWidget({
// give the widget a id
id: "truncatedList",
// format is called when the on init and when a sorting has finished
format: function(table)
{
// Check if there is a "truncated" line
this.truncatedList = false;
if ($("tr td.truncated",table).length > 0)
{
this.truncatedList = true;
}
if (this.truncatedList)
{
$("tr td",table).removeClass('truncated');
$("tr:last td",table).addClass('truncated');
}
}
});
$.tablesorter.addWidget({
// give the widget a id
id: "myZebra",
// format is called when the on init and when a sorting has finished
format: function(table)
{
// Replace the 'red even' lines by 'red_even' since most browser do not support 2 classes selector in CSS, etc..
$("tbody tr:even",table).addClass('even');
$("tbody tr.red:even",table).removeClass('red').removeClass('even').addClass('red_even');
$("tbody tr.orange:even",table).removeClass('orange').removeClass('even').addClass('orange_even');
$("tbody tr.green:even",table).removeClass('green').removeClass('even').addClass('green_even');
// In case we sort again the table, we need to remove the added 'even' classes on odd rows
$("tbody tr:odd",table).removeClass('even');
$("tbody tr.red_even:odd",table).removeClass('even').removeClass('red_even').addClass('red');
$("tbody tr.orange_even:odd",table).removeClass('even').removeClass('orange_even').addClass('orange');
$("tbody tr.green_even:odd",table).removeClass('even').removeClass('green_even').addClass('green');
}
});
// Horizontal splitter, nested in the right pane of the vertical splitter.
if ( $("#TopPane").length > 0)
{
$("#RightPane").splitter({
type: "h" //,
//minA: 100, initA: 150, maxA: 500,
//accessKey: "_"
});
}
// Manually set the outer splitter's height to fill the browser window.
// This must be re-done any time the browser window is resized.
$(window).bind("resize", function(){
var ms = $("#MySplitter");
var top = ms.offset().top; // from dimensions.js
var wh = $(window).height();
// Account for margin or border on the splitter container
var mrg = parseInt(ms.css("marginBottom")) || 0;
var brd = parseInt(ms.css("borderBottomWidth")) || 0;
ms.css("height", (wh-top-mrg-brd)+"px");
// IE fires resize for splitter; others don't so do it here
if ( !jQuery.browser.msie )
ms.trigger("resize");
$('.resizable').resizable(); // Make resizable everything that claims to be resizable !
// Adjust initial size
$('.v-resizable').each( function()
{
var parent_id = $(this).parent().id;
// Restore the saved height
var iHeight = GetUserPreference(parent_id+'_'+this.id+'_height', undefined);
if (iHeight != undefined)
{
$(this).height(parseInt(iHeight, 10)); // Parse in base 10 !);
}
// Adjust the child 'item''s height and width to fit
var container = $(this);
var fixedWidth = container.parent().innerWidth() - 6;
// Set the width to fit the parent
$(this).width(fixedWidth);
var headerHeight = $(this).find('.drag_handle').height();
// Now adjust the width and height of the child 'item'
container.find('.item').height(container.innerHeight() - headerHeight - 12).width(fixedWidth - 10);
}
);
// Make resizable, vertically only everything that claims to be v-resizable !
$('.v-resizable').resizable( { handles: 's', minHeight: $(this).find('.drag_handle').height(), minWidth: $(this).parent().innerWidth() - 6, maxWidth: $(this).parent().innerWidth() - 6, stop: function()
{
// Adjust the content
var container = $(this);
var headerHeight = $(this).find('.drag_handle').height();
container.find('.item').height(container.innerHeight() - headerHeight - 12);//.width(container.innerWidth());
var parent_id = $(this).parent().id;
SetUserPreference(parent_id+'_'+this.id+'_height', $(this).height(), true); // true => persistent
}
} );
}).trigger("resize");
var ms = $("#MySplitter");
ms.trigger("resize");
if ( $("#TopPane").length > 0)
// Tabs, using JQuery BBQ to store the history
// The "tab widgets" to handle.
var tabs = $('div[id^=tabbedContent]');
// This selector will be reused when selecting actual tab widget A elements.
var tab_a_selector = 'ul.ui-tabs-nav a';
// Enable tabs on all tab widgets. The `event` property must be overridden so
// that the tabs aren't changed on click, and any custom event name can be
// specified. Note that if you define a callback for the 'select' event, it
// will be executed for the selected tab whenever the hash changes.
tabs.tabs({ event: 'change' });
// Define our own click handler for the tabs, overriding the default.
tabs.find( tab_a_selector ).click(function()
{
$("#RightPane").trigger("resize");
}
var state = {};
// Get the id of this tab widget.
var id = $(this).closest( 'div[id^=tabbedContent]' ).attr( 'id' );
// Get the index of this tab.
var idx = $(this).parent().prevAll().length;
// Set the state!
state[ id ] = idx;
$.bbq.pushState( state );
});
$("#tabbedContent > ul").tabs( 1, { fxFade: true, fxSpeed: 'fast' } ); // tabs
// Bind an event to window.onhashchange that, when the history state changes,
// iterates over all tab widgets, changing the current tab as necessary.
$(window).bind( 'hashchange', function(e)
{
// Iterate over all tab widgets.
tabs.each(function()
{
// Get the index for this tab widget from the hash, based on the
// appropriate id property. In jQuery 1.4, you should use e.getState()
// instead of $.bbq.getState(). The second, 'true' argument coerces the
// string value to a number.
var idx = $.bbq.getState( this.id, true ) || 0;
// Select the appropriate tab for this tab widget by triggering the custom
// event specified in the .tabs() init above (you could keep track of what
// tab each widget is on using .data, and only select a tab if it has
// changed).
$(this).find( tab_a_selector ).eq( idx ).triggerHandler( 'change' );
});
// Iterate over all truncated lists to find whether they are expanded or not
$('a.truncated').each(function()
{
var state = $.bbq.getState( this.id, true ) || 'close';
if (state == 'open')
{
$(this).trigger('open');
}
else
{
$(this).trigger('close');
}
});
});
// End of Tabs handling
$("table.listResults").tableHover(); // hover tables
$(".listResults").tablesorter( { headers: { 0:{sorter: false }}, widgets: ['zebra']} ); // sortable and zebra tables
$(".date-pick").datePicker( {clickInput: false, createButton: true, startDate: '2000-01-01'} ); // Date picker
$('#ModalDlg').jqm({ajax: '@href', trigger: 'a.jqmTrigger', overlay:70, modal:true, toTop:true}); // jqModal Window
// Check each 'listResults' table for a checkbox in the first column and make the first column sortable only if it does not contain a checkbox in the header
$(".listResults").each( function()
{
var table = $(this);
var id = $(this).parent();
var checkbox = (table.find('th:first :checkbox').length > 0);
if (checkbox)
{
// There is a checkbox in the first column, don't make it sortable
table.tablesorter( { headers: { 0: {sorter: false}}, widgets: ['myZebra', 'truncatedList']} ); // sortable and zebra tables
}
else
{
// There is NO checkbox in the first column, all columns are considered sortable
table.tablesorter( { widgets: ['myZebra', 'truncatedList']} ); // sortable and zebra tables
}
});
$(".date-pick").datepicker({
showOn: 'button',
buttonImage: '../images/calendar.png',
buttonImageOnly: true,
dateFormat: 'yy-mm-dd',
constrainInput: false,
changeMonth: true,
changeYear: true
});
// Restore the persisted sortable order, for all sortable lists... if any
$('.sortable').each(function()
{
var sTemp = GetUserPreference(this.id+'_order', undefined);
if (sTemp != undefined)
{
var aSerialized = sTemp.split(',');
var sortable = $(this);
$.each(aSerialized, function(i,v) {
var item = $('#menu_'+v);
if (item.length > 0) // Check that the menu exists
{
sortable.append(item);
}
});
}
});
// Make sortable, everything that claims to be sortable
$('.sortable').sortable( {axis: 'y', cursor: 'move', handle: '.drag_handle', stop: function()
{
if ($(this).hasClass('persistent'))
{
// remember the sort order for next time the page is loaded...
sSerialized = $(this).sortable('serialize', {key: 'menu'});
var sTemp = sSerialized.replace(/menu=/g, '');
SetUserPreference(this.id+'_order', sTemp.replace(/&/g, ','), true); // true => persistent !
}
}
});
docWidth = $(document).width();
$('#ModalDlg').dialog({ autoOpen: false, modal: true, width: 0.8*docWidth }); // JQuery UI dialogs
ShowDebug();
$('#logOffBtn>ul').popupmenu();
// $.history.init(history_callback);
// $("a[rel='history']").click(function()
// {
// $.history.load(this.href.replace(/^.*#/, ''));
// return false;
// });
}
catch(err)
{
// Do something with the error !
alert(err);
}
//$('.display_block').draggable(); // make the blocks draggable
EOF
);
$this->add_script("
// For automplete
function findValue(li) {
if( li == null ) return alert(\"No match!\");
// if coming from an AJAX call, let's use the CityId as the value
if( !!li.extra ) var sValue = li.extra[0];
// otherwise, let's just display the value in the text box
else var sValue = li.selectValue;
//alert(\"The value you selected was: \" + sValue);
}
function selectItem(li) {
findValue(li);
}
$sUserPrefs = appUserPreferences::GetAsJSON();
$this->add_script(
<<<EOF
// // for JQuery history
// function history_callback(hash)
// {
// // do stuff that loads page content based on hash variable
// var aMatches = /^tab_(.*)$/.exec(hash);
// if (aMatches != null)
// {
// var tab = $('#'+hash);
// tab.parents('div[id^=tabbedContent]:first').tabs('select', aMatches[1]);
// }
// }
function formatItem(row) {
return row[0];
}
@@ -122,8 +370,47 @@ EOF
{
window.history.back();
}
");
$this->DisplayMenu();
function BackToDetails(sClass, id, sDefaultUrl)
{
if (id > 0)
{
window.location.href = './UI.php?operation=details&class='+sClass+'&id='+id;
}
else
{
window.location.href = sDefaultUrl;
}
}
function BackToList(sClass)
{
window.location.href = './UI.php?operation=search_oql&oql_class='+sClass+'&oql_clause=WHERE id=0';
}
function ShowDebug()
{
if ($('#rawOutput > div').html() != '')
{
$('#rawOutput').dialog( {autoOpen: true, modal:false});
}
}
var oUserPreferences = $sUserPrefs;
EOF
);
// Build menus from module handlers
//
foreach(get_declared_classes() as $sPHPClass)
{
if (is_subclass_of($sPHPClass, 'ModuleHandlerAPI'))
{
$aCallSpec = array($sPHPClass, 'OnMenuCreation');
call_user_func($aCallSpec);
}
}
}
public function AddToMenu($sHtml)
@@ -131,78 +418,69 @@ EOF
$this->m_sMenu .= $sHtml;
}
public function GetSiloSelectionForm()
{
// List of visible Organizations
$iCount = 0;
if (MetaModel::IsValidClass('Organization'))
{
$oSearchFilter = new DBObjectSearch('Organization');
$oSet = new CMDBObjectSet($oSearchFilter);
$iCount = $oSet->Count();
}
switch($iCount)
{
case 0:
// No such dimension/silo => nothing to select
$sHtml = '<div id="SiloSelection"><!-- nothing to select --></div>';
break;
case 1:
// Only one possible choice... no selection, but display the value
$oOrg = $oSet->Fetch();
$sHtml = '<div id="SiloSelection">'.$oOrg->GetName().'</div>';
$sHtml .= '';
break;
default:
$oAppContext = new ApplicationContext();
$iCurrentOrganization = $oAppContext->GetCurrentValue('org_id');
$sHtml = '<div id="SiloSelection">';
$sHtml .= '<form style="display:inline" action="'.$_SERVER['PHP_SELF'].'"><select class="org_combo" name="c[org_id]" title="Pick an organization" onChange="this.form.submit();">';
$sSelected = ($iCurrentOrganization == '') ? ' selected' : '';
$sHtml .= '<option value=""'.$sSelected.'>'.Dict::S('UI:AllOrganizations').'</option>';
while($oOrg = $oSet->Fetch())
{
if ($iCurrentOrganization == $oOrg->GetKey())
{
// $oCurrentOrganization = $oOrg;
$sSelected = " selected";
}
else
{
$sSelected = "";
}
$sHtml .= '<option title="'.$oOrg->GetName().'" value="'.$oOrg->GetKey().'"'.$sSelected.'>'.$oOrg->GetName().'</option>';
}
$sHtml .= '</select>';
// Add other dimensions/context information to this form
// $oAppContext = new ApplicationContext();
$oAppContext->Reset('org_id'); // org_id is handled above and we want to be able to change it here !
$sHtml .= $oAppContext->GetForForm();
$sHtml .= '</form>';
$sHtml .= '</div>';
}
return $sHtml;
}
public function DisplayMenu()
{
// Combo box to select the organization
$this->AddToMenu("<div id=\"OrganizationSelection\">
<form style=\"display:inline\" action=\"{$_SERVER['PHP_SELF']}\"><select style=\"width:150px;font-size:x-small\" name=\"org_id\" title=\"Pick an organization\" onChange=\"this.form.submit();\">\n");
// List of visible Organizations
$oContext = new UserContext();
$oSearchFilter = $oContext->NewFilter("bizOrganization");
$oSet = new CMDBObjectSet($oSearchFilter);
$sSelected = ($this->m_currentOrganization == '') ? ' selected' : '';
$this->AddToMenu("<option value=\"\"$sSelected> All Organizations </option>");
if ($oSet->Count() > 0)
while($oOrg = $oSet->Fetch())
{
if ($this->m_currentOrganization == $oOrg->GetKey())
{
$oCurrentOrganization = $oOrg;
$sSelected = " selected";
}
else
{
$sSelected = "";
}
$this->AddToMenu("<option value=\"".$oOrg->GetKey()."\"$sSelected>".$oOrg->Get('name')."</option>\n");
}
$this->AddToMenu("</select>\n");
// Add other dimensions/context information to this form
$oAppContext = new ApplicationContext();
$oAppContext->Reset('org_id'); // Org id is handled above and we want to be able to change it here !
$this->AddToMenu($oAppContext->GetForForm());
$this->AddToMenu("</form>\n");
$this->AddToMenu("</div>\n");
$this->AddToMenu("<ul id=\"browser\" class=\"dir\">\n");
// Display the menu
$oAppContext = new ApplicationContext();
// 1) Application defined menus
$oSearchFilter = $oContext->NewFilter("menuNode");
$oSearchFilter->AddCondition('parent_id', 0, '=');
$oSearchFilter->AddCondition('type', 'application', '=');
// There may be more criteria added later to have a specific menu based on the user's profile
$oSet = new CMDBObjectSet($oSearchFilter, array('rank' => true));
while ($oRootMenuNode = $oSet->Fetch())
{
$oRootMenuNode->DisplayMenu($this, 'application', $oAppContext->GetAsHash());
}
// 2) User defined menus (Bookmarks)
$oSearchFilter = $oContext->NewFilter("menuNode");
$oSearchFilter->AddCondition('parent_id', 0, '=');
$oSearchFilter->AddCondition('type', 'user', '=');
$oSearchFilter->AddCondition('user_id', UserRights::GetUserId(), '=');
// There may be more criteria added later to have a specific menu based on the user's profile
$oSet = new CMDBObjectSet($oSearchFilter, array('rank' => true));
while ($oRootMenuNode = $oSet->Fetch())
{
$oRootMenuNode->DisplayMenu($this, 'user', $oAppContext->GetAsHash());
}
// 3) Administrator menu
if (userRights::IsAdministrator())
{
$oSearchFilter = $oContext->NewFilter("menuNode");
$oSearchFilter->AddCondition('parent_id', 0, '=');
$oSearchFilter->AddCondition('type', 'administrator', '=');
// There may be more criteria added later to have a specific menu based on the user's profile
$oSet = new CMDBObjectSet($oSearchFilter, array('rank' => true));
while ($oRootMenuNode = $oSet->Fetch())
{
$oRootMenuNode->DisplayMenu($this, 'administrator', $oAppContext->GetAsHash());
}
}
$iAccordionIndex = 0;
$this->AddToMenu("</ul>\n");
ApplicationMenu::DisplayMenu($this, $oAppContext->GetAsHash());
}
/**
@@ -210,6 +488,17 @@ EOF
*/
public function output()
{
$this->DisplayMenu(); // Compute the menu
// Put here the 'ready scripts' that must be executed after all others
$this->add_ready_script(
<<<EOF
// Since the event is only triggered when the hash changes, we need to trigger
// the event now, to handle the hash the page may have loaded with.
$(window).trigger( 'hashchange' );
EOF
);
foreach($this->a_headers as $s_header)
{
header($s_header);
@@ -219,8 +508,10 @@ EOF
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n";
echo "<html>\n";
echo "<head>\n";
echo "<title>{$this->s_title}</title>\n";
// Make sure that Internet Explorer renders the page using its latest/highest/greatest standards !
echo "<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\" />\n";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n";
echo "<title>{$this->s_title}</title>\n";
echo $this->get_base_tag();
// Stylesheets MUST be loaded before any scripts otherwise
// jQuery scripts may face some spurious problems (like failing on a 'reload')
@@ -267,18 +558,163 @@ EOF
echo "</head>\n";
echo "<body>\n";
// Display the header
// Render the revision number
if (ITOP_REVISION == '$WCREV$')
{
// This is NOT a version built using the buil system, just display the main version
$sVersionString = "iTop Version ".ITOP_VERSION;
$sVersionString = Dict::Format('UI:iTopVersion:Short', ITOP_VERSION);
}
else
{
// This is a build made from SVN, let display the full information
$sVersionString = "iTop Version ".ITOP_VERSION." revision ".ITOP_REVISION.", built on: ".ITOP_BUILD_DATE;
$sVersionString = Dict::Format('UI:iTopVersion:Long', ITOP_VERSION, ITOP_REVISION, ITOP_BUILD_DATE);
}
echo "<div id=\"Header\">\n";
// Render the text of the global search form
$sText = Utils::ReadParam('text', '');
$sOnClick = "";
if (empty($sText))
{
// if no search text is supplied then
// 1) the search text is filled with "your search"
// 2) clicking on it will erase it
$sText = Dict::S("UI:YourSearch");
$sOnClick = " onclick=\"this.value='';this.onclick=null;\"";
}
$sForm = $this->GetSiloSelectionForm();
// Render the tabs in the page (if any)
foreach($this->m_aTabs as $sTabContainerName => $m_aTabs)
{
$sTabs = '';
$container_index = 0;
if (count($m_aTabs) > 0)
{
$sTabs = "<!-- tabs -->\n<div id=\"tabbedContent_{$container_index}\" class=\"light\">\n";
$sTabs .= "<ul>\n";
// Display the unordered list that will be rendered as the tabs
$i = 0;
foreach($m_aTabs as $sTabName => $sTabContent)
{
$sTabs .= "<li><a href=\"#tab_$i\" class=\"tab\"><span>".htmlentities($sTabName, ENT_QUOTES, 'UTF-8')."</span></a></li>\n";
$i++;
}
$sTabs .= "</ul>\n";
// Now add the content of the tabs themselves
$i = 0;
foreach($m_aTabs as $sTabName => $sTabContent)
{
$sTabs .= "<div id=\"tab_$i\">".$sTabContent."</div>\n";
$i++;
}
$sTabs .= "</div>\n<!-- end of tabs-->\n";
}
$this->s_content = str_replace("\$Tabs:$sTabContainerName\$", $sTabs, $this->s_content);
$container_index++;
}
$sUserName = UserRights::GetUser();
$sIsAdmin = UserRights::IsAdministrator() ? '(Administrator)' : '';
if (UserRights::IsAdministrator())
{
$sLogonMessage = Dict::Format('UI:LoggedAsMessage+Admin', $sUserName);
}
else
{
$sLogonMessage = Dict::Format('UI:LoggedAsMessage', $sUserName);
}
$sLogOffMenu = "<span id=\"logOffBtn\"><ul><li><img src=\"../images/onOffBtn.png\"><ul>";
$sLogOffMenu .= "<li><span>$sLogonMessage</span></li>\n";
if (utils::CanLogOff() && UserRights::CanLogOff())
{
//$sLogOffMenu .= "<li><a href=\"../pages/UI.php?loginop=logoff\">".Dict::S('UI:LogOffMenu')."</a></li>\n";
$sLogOffMenu .= "<li><a href=\"../pages/logoff.php\">".Dict::S('UI:LogOffMenu')."</a></li>\n";
}
if (UserRights::CanChangePassword())
{
$sLogOffMenu .= "<li><a href=\"../pages/UI.php?loginop=change_pwd\">".Dict::S('UI:ChangePwdMenu')."</a></li>\n";
}
$sLogOffMenu .= "</ul>\n</li>\n</ul></span>\n";
$sRestrictions = '';
if (!MetaModel::DBHasAccess(ACCESS_ADMIN_WRITE))
{
if (!MetaModel::DBHasAccess(ACCESS_ADMIN_WRITE))
{
$sRestrictions = Dict::S('UI:AccessRO-All');
}
}
elseif (!MetaModel::DBHasAccess(ACCESS_USER_WRITE))
{
$sRestrictions = Dict::S('UI:AccessRO-Users');
}
if (strlen($sRestrictions) > 0)
{
$sAdminMessage = trim(MetaModel::GetConfig()->Get('access_message'));
$sApplicationBanner = '<div id="admin-banner">';
$sApplicationBanner .= '<img src="../images/locked.png" style="vertical-align:middle;">';
$sApplicationBanner .= '&nbsp;<b>'.$sRestrictions.'</b>';
if (strlen($sAdminMessage) > 0)
{
$sApplicationBanner .= '&nbsp;<b>'.$sAdminMessage.'</b>';
}
$sApplicationBanner .= '</div>';
}
else
{
$sApplicationBanner = '';
}
$sOnlineHelpUrl = MetaModel::GetConfig()->Get('online_help');
//$sLogOffMenu = "<span id=\"logOffBtn\" style=\"height:55px;padding:0;margin:0;\"><img src=\"../images/onOffBtn.png\"></span>";
echo '<div id="left-pane" class="ui-layout-west">';
echo '<!-- Beginning of the left pane -->';
echo ' <div id="header-logo">';
echo ' <div id="top-left"></div><div id="logo"><a href="http://www.combodo.com/itop"><img src="../images/itop-logo.png" title="'.$sVersionString.'" style="border:0; margin-top:16px; margin-right:40px;"/></a></div>';
echo ' </div>';
echo ' <div class="header-menu">';
echo ' <div class="icon ui-state-default ui-corner-all"><span id="tPinMenu" class="ui-icon ui-icon-pin-w">pin</span></div>';
echo ' <div style="text-align:center;">'.$sForm.'</div>';
echo ' </div>';
echo ' <div id="menu" class="ui-layout-content">';
echo ' <div id="inner_menu">';
echo ' <div id="accordion">';
echo $this->m_sMenu;
echo ' <!-- Beginning of the accordion menu -->';
echo ' <!-- End of the accordion menu-->';
echo ' </div>';
echo ' </div> <!-- /inner menu -->';
echo ' </div> <!-- /menu -->';
echo ' <div class="footer"><a href="http://www.combodo.com" title="www.combodo.com" target="_blank"><img src="../images/logo-combodo.png"/></a></div>';
echo '<!-- End of the left pane -->';
echo '</div>';
echo '<div class="ui-layout-center">';
echo ' <div id="top-bar" style="width:100%">';
echo $sApplicationBanner;
echo ' <div id="global-search"><form action="../pages/UI.php"><table><tr><td></td><td id="g-search-input"><input type="text" name="text" value="'.$sText.'"'.$sOnClick.'/></td>';
echo '<td><input type="image" src="../images/searchBtn.png"/></a></td>';
echo '<td><a style="background:transparent;" href="'.$sOnlineHelpUrl.'" target="_blank"><img style="border:0;padding-left:20px;padding-right:10px;" title="'.Dict::S('UI:Help').'" src="../images/help.png"/></td>';
echo '<td style="padding-right:20px;padding-left:10px;">'.$sLogOffMenu.'</td><td><input type="hidden" name="operation" value="full_text"/></td></tr></table></form></div>';
//echo '<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="hidden" name="operation" value="full_text"/></td></tr></table></form></div>';
echo ' </div>';
echo ' <div class="ui-layout-content">';
echo ' <!-- Beginning of page content -->';
echo $this->s_content;
echo ' <!-- End of page content -->';
echo ' </div>';
echo '</div>';
/*
echo "<div class=\"iTopLogo\" title=\"$sVersionString\"><span>iTop</span></div>\n";
//echo "<div id=\"GlobalSearch\"><div style=\"border: 1px solid #999; padding:1px; background-color:#fff;\"><img src=\"../images/magnifier.gif\"/><input style=\"border:0\" type=\"text\" size=\"15\" title=\"Global Search\"></input></div></div>\n";
$sText = Utils::ReadParam('text', '');
@@ -288,17 +724,27 @@ EOF
// if no search text is supplied then
// 1) the search text is filled with "your search"
// 2) clicking on it will erase it
$sText = "Your search";
$sText = Dict::S("UI:YourSearch");
$sOnClick = " onclick=\"this.value='';this.onclick=null;\"";
}
$sUserName = UserRights::GetUser();
$sIsAdmin = UserRights::IsAdministrator() ? '(Administrator)' : '';
echo "<div id=\"Login\" style=\"position:absolute; top:18px; right:16px; width:500px;\">Logged in as '$sUserName'&nbsp;$sIsAdmin&nbsp;&nbsp;";
if (UserRights::IsAdministrator())
{
$sLogonMessage = Dict::Format('UI:LoggedAsMessage+Admin', $sUserName);
}
else
{
$sLogonMessage = Dict::Format('UI:LoggedAsMessage', $sUserName);
}
$sLogOffBtn = Dict::S('UI:Button:Logoff');
$sSearchBtn = Dict::S('UI:Button:GlobalSearch');
echo "<div id=\"Login\" style=\"position:absolute; top:18px; right:16px; width:600px;\">{$sLogonMessage}&nbsp;&nbsp;";
echo "<form action=\"../pages/UI.php\" method=\"post\" style=\"display:inline\">\n";
echo "<input type=\"submit\" value=\"Log off\" />\n";
echo "<input type=\"submit\" value=\"$sLogOffBtn\" />\n";
echo "<input type=\"hidden\" name=\"loginop\" value=\"logoff\" />\n";
echo "</form>\n";
echo "<form action=\"../pages/UI.php\" style=\"display:inline\"><div style=\"padding:1px; background-color:#fff;display:inline;\"><img src=\"../images/magnifier.gif\"/><input style=\"border:0\" type=\"text\" size=\"15\" title=\"Global Search\" name=\"text\" value=\"$sText\"$sOnClick></input></div><input type=\"submit\" value=\"Search\" />
echo "<form action=\"../pages/UI.php\" style=\"display:inline\"><div style=\"padding:1px; background-color:#fff;display:inline;\"><img src=\"../images/magnifier.gif\"/><input style=\"border:0\" type=\"text\" size=\"15\" title=\"Global Search\" name=\"text\" value=\"$sText\"$sOnClick></input></div><input type=\"submit\" value=\"$sSearchBtn\" />
<input type=\"hidden\" name=\"operation\" value=\"full_text\" /></form>\n";
echo "</div>\n";
@@ -311,48 +757,22 @@ EOF
echo " </div> <!-- LeftPane -->\n";
echo "<div id=\"RightPane\">\n";
// Render the tabs in the page (if any)
foreach($this->m_aTabs as $sTabContainerName => $m_aTabs)
{
$sTabs = '';
if (count($m_aTabs) > 0)
{
$sTabs = "<!-- tabs -->\n<div id=\"tabbedContent\" class=\"light\">\n";
$sTabs .= "<ul>\n";
// Display the unordered list that will be rendered as the tabs
$i = 0;
foreach($m_aTabs as $sTabName => $sTabContent)
{
$sTabs .= "<li><a href=\"#fragment_$i\" class=\"tab\"><span>".htmlentities($sTabName)."</span></a></li>\n";
$i++;
}
$sTabs .= "</ul>\n";
// Now add the content of the tabs themselves
$i = 0;
foreach($m_aTabs as $sTabName => $sTabContent)
{
$sTabs .= "<div id=\"fragment_$i\">".$sTabContent."</div>\n";
$i++;
}
$sTabs .= "</div>\n<!-- end of tabs-->\n";
}
$this->s_content = str_replace("\$Tabs:$sTabContainerName\$", $sTabs, $this->s_content);
}
// Display the page's content
echo $this->s_content;
*/
// Add the captured output
if (trim($s_captured_output) != "")
{
echo "<div class=\"raw_output\">$s_captured_output</div>\n";
echo "<div id=\"rawOutput\" title=\"Debug Output\"><div style=\"height:500px; overflow-y:auto;\">$s_captured_output</div></div>\n";
}
echo $this->s_deferred_content;
echo "<div class=\"jqmWindow\" id=\"ex2\">Please wait...</div>\n"; // jqModal Window
echo "</div> <!-- RightPane -->\n";
echo "</div> <!-- Splitter -->\n";
echo "<div class=\"jqmWindow\" id=\"ModalDlg\"></div>";
echo "<div style=\"display:none\" title=\"ex2\" id=\"ex2\">Please wait...</div>\n"; // jqModal Window
echo "<div style=\"display:none\" title=\"dialog\" id=\"ModalDlg\"></div>";
echo "<div style=\"display:none\" id=\"ajax_content\"></div>";
echo "</body>\n";
echo "</html>\n";
}
@@ -391,6 +811,36 @@ EOF
return $sPreviousTab;
}
/**
* Make the given tab the active one, as if it were clicked
* DOES NOT WORK: apparently in the *old* version of jquery
* that we are using this is not supported... TO DO upgrade
* the whole jquery bundle...
*/
public function SelectTab($sTabContainer, $sTabLabel)
{
$container_index = 0;
$tab_index = 0;
foreach($this->m_aTabs as $sCurrentTabContainerName => $aTabs)
{
if ($sTabContainer == $sCurrentTabContainerName)
{
foreach($aTabs as $sCurrentTabLabel => $void)
{
if ($sCurrentTabLabel == $sTabLabel)
{
break;
}
$tab_index++;
}
break;
}
$container_index++;
}
$sSelector = '#tabbedContent_'.$container_index.' > ul';
$this->add_ready_script("$('$sSelector').tabs('select', $tab_index);");
}
public function StartCollapsibleSection($sSectionLabel, $bOpen = false)
{
$this->add($this->GetStartCollapsibleSection($sSectionLabel, $bOpen));

View File

@@ -1,4 +1,28 @@
<?php
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* Class iTopWizardWebPage
*
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
require_once('itopwebpage.class.inc.php');
/**
* Web page to display a wizard in the iTop framework

View File

@@ -1,5 +1,29 @@
<?php
require_once("../application/nicewebpage.class.inc.php");
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* Class LoginWebPage
*
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
require_once(APPROOT."/application/nicewebpage.class.inc.php");
/**
* Web page used for displaying the login form
*/
@@ -8,63 +32,158 @@ class LoginWebPage extends NiceWebPage
public function __construct()
{
parent::__construct("iTop Login");
$this->add_style("
$this->add_style(<<<EOF
body {
background-color: #eee;
background: #eee;
margin: 0;
padding: 0;
}
#login {
width: 230px;
#login-logo {
margin-top: 150px;
width: 300px;
padding-left: 20px;
padding-right: 20px;
padding-top: 10px;
padding-bottom: 10px;
margin-left: auto;
margin-right: auto;
background: #f6f6f1;
height: 54px;
border-top: 1px solid #000;
border-left: 1px solid #000;
border-right: 1px solid #000;
border-bottom: 0;
text-align: center;
}
#login-logo img {
border: 0;
}
#login {
width: 300px;
margin-left: auto;
margin-right: auto;
margin-top: 150px;
padding: 20px;
background-color: #fff;
border: 1px solid #000;
border-bottom: 1px solid #000;
border-left: 1px solid #000;
border-right: 1px solid #000;
border-top: 0;
text-align: center;
}
#pwd, #user,#old_pwd, #new_pwd, #retype_new_pwd {
width: 10em;
}
.center {
text-align: center;
}
h1 {
color: #83b217;
color: #1C94C4;
font-size: 16pt;
}
.v-spacer {
padding-top: 1em;
}
");
EOF
);
}
public function DisplayLoginForm($bFailedLogin = false)
public function DisplayLoginForm($sLoginType, $bFailedLogin = false)
{
switch($sLoginType)
{
case 'basic':
case 'url':
$this->add_header('WWW-Authenticate: Basic realm="'.Dict::Format('UI:iTopVersion:Short', ITOP_VERSION));
$this->add_header('HTTP/1.0 401 Unauthorized');
// Note: displayed when the user will click on Cancel
$this->add('<p><strong>'.Dict::S('UI:Login:Error:AccessRestricted').'</strong></p>');
break;
case 'external':
case 'form':
default: // In case the settings get messed up...
$sAuthUser = utils::ReadParam('auth_user', '');
$sAuthPwd = utils::ReadParam('suggest_pwd', '');
$sVersionShort = Dict::Format('UI:iTopVersion:Short', ITOP_VERSION);
$this->add("<div id=\"login-logo\"><a href=\"http://www.combodo.com/itop\"><img title=\"$sVersionShort\" src=\"../images/itop-logo-external.png\"></a></div>\n");
$this->add("<div id=\"login\">\n");
$this->add("<h1>".Dict::S('UI:Login:Welcome')."</h1>\n");
if ($bFailedLogin)
{
$this->add("<p class=\"hilite\">".Dict::S('UI:Login:IncorrectLoginPassword')."</p>\n");
}
else
{
$this->add("<p>".Dict::S('UI:Login:IdentifyYourself')."</p>\n");
}
$this->add("<form method=\"post\">\n");
$this->add("<table width=\"100%\">\n");
$this->add("<tr><td style=\"text-align:right\"><label for=\"user\">".Dict::S('UI:Login:UserNamePrompt').":</label></td><td style=\"text-align:left\"><input id=\"user\" type=\"text\" name=\"auth_user\" value=\"$sAuthUser\" /></td></tr>\n");
$this->add("<tr><td style=\"text-align:right\"><label for=\"pwd\">".Dict::S('UI:Login:PasswordPrompt').":</label></td><td style=\"text-align:left\"><input id=\"pwd\" type=\"password\" name=\"auth_pwd\" value=\"$sAuthPwd\" /></td></tr>\n");
$this->add("<tr><td colspan=\"2\" class=\"center v-spacer\"> <input type=\"submit\" value=\"".Dict::S('UI:Button:Login')."\" /></td></tr>\n");
$this->add("</table>\n");
$this->add("<input type=\"hidden\" name=\"loginop\" value=\"login\" />\n");
$this->add("</form>\n");
$this->add("</div>\n");
break;
}
}
public function DisplayChangePwdForm($bFailedLogin = false)
{
$sAuthUser = utils::ReadParam('auth_user', '');
$sAuthPwd = utils::ReadParam('suggest_pwd', '');
$sVersionShort = Dict::Format('UI:iTopVersion:Short', ITOP_VERSION);
$sInconsistenPwdMsg = Dict::S('UI:Login:RetypePwdDoesNotMatch');
$this->add_script(<<<EOF
function GoBack()
{
window.history.back();
}
function DoCheckPwd()
{
if ($('#new_pwd').val() != $('#retype_new_pwd').val())
{
alert('$sInconsistenPwdMsg');
return false;
}
return true;
}
EOF
);
$this->add("<div id=\"login-logo\"><a href=\"http://www.combodo.com/itop\"><img title=\"$sVersionShort\" src=\"../images/itop-logo.png\"></a></div>\n");
$this->add("<div id=\"login\">\n");
$this->add("<h1>Welcome to iTop!</h1>\n");
$this->add("<h1>".Dict::S('UI:Login:ChangeYourPassword')."</h1>\n");
if ($bFailedLogin)
{
$this->add("<p class=\"hilite\">Incorrect login/password, please try again.</p>\n");
}
else
{
$this->add("<p>Please identify yourself before continuing.</p>\n");
$this->add("<p class=\"hilite\">".Dict::S('UI:Login:IncorrectOldPassword')."</p>\n");
}
$this->add("<form method=\"post\">\n");
$this->add("<table>\n");
$this->add("<tr><td><label for=\"user\">User Name:</label></td><td><input id=\"user\" type=\"text\" name=\"auth_user\" value=\"$sAuthUser\" /></td></tr>\n");
$this->add("<tr><td><label for=\"pwd\">Password:</label></td><td><input id=\"pwd\" type=\"password\" name=\"auth_pwd\" value=\"$sAuthPwd\" /></td></tr>\n");
$this->add("<tr><td colspan=\"2\" class=\"center v-spacer\"> <input type=\"submit\" value=\"Enter iTop\" /></td></tr>\n");
$this->add("<table width=\"100%\">\n");
$this->add("<tr><td style=\"text-align:right\"><label for=\"old_pwd\">".Dict::S('UI:Login:OldPasswordPrompt').":</label></td><td style=\"text-align:left\"><input type=\"password\" id=\"old_pwd\" name=\"old_pwd\" value=\"\" /></td></tr>\n");
$this->add("<tr><td style=\"text-align:right\"><label for=\"new_pwd\">".Dict::S('UI:Login:NewPasswordPrompt').":</label></td><td style=\"text-align:left\"><input type=\"password\" id=\"new_pwd\" name=\"new_pwd\" value=\"\" /></td></tr>\n");
$this->add("<tr><td style=\"text-align:right\"><label for=\"retype_new_pwd\">".Dict::S('UI:Login:RetypeNewPasswordPrompt').":</label></td><td style=\"text-align:left\"><input type=\"password\" id=\"retype_new_pwd\" name=\"retype_new_pwd\" value=\"\" /></td></tr>\n");
$this->add("<tr><td colspan=\"2\" class=\"center v-spacer\"> <input type=\"button\" onClick=\"GoBack();\" value=\"".Dict::S('UI:Button:Cancel')."\" />&nbsp;&nbsp;<input type=\"submit\" onClick=\"return DoCheckPwd();\" value=\"".Dict::S('UI:Button:ChangePassword')."\" /></td></tr>\n");
$this->add("</table>\n");
$this->add("<input type=\"hidden\" name=\"loginop\" value=\"login\" />\n");
$this->add("<input type=\"hidden\" name=\"loginop\" value=\"do_change_pwd\" />\n");
$this->add("</form>\n");
$this->add("</div>\n");
}
static protected function ResetSession()
static function ResetSession()
{
if (isset($_SESSION['login_mode']))
{
$sPreviousLoginMode = $_SESSION['login_mode'];
}
else
{
$sPreviousLoginMode = '';
}
// Unset all of the session variables.
$_SESSION = array();
// If it's desired to kill the session, also delete the session cookie.
@@ -76,51 +195,221 @@ h1 {
// Finally, destroy the session.
session_destroy();
}
static function SecureConnectionRequired()
{
return MetaModel::GetConfig()->GetSecureConnectionRequired();
}
static function IsConnectionSecure()
{
$bSecured = false;
if (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS']!='off'))
{
$bSecured = true;
}
return $bSecured;
}
static function DoLogin()
protected static function Login()
{
if (self::SecureConnectionRequired() && !self::IsConnectionSecure())
{
// Non secured URL... redirect to a secured one
$sUrl = Utils::GetAbsoluteUrl(true /* query string */, true /* force HTTPS */);
header("Location: $sUrl");
exit;
}
$aAllowedLoginTypes = MetaModel::GetConfig()->GetAllowedLoginTypes();
if (isset($_SESSION['auth_user']))
{
//echo "User: ".$_SESSION['auth_user']."\n";
// Already authentified
UserRights::Login($_SESSION['auth_user']); // Login & set the user's language
return true;
}
else
{
$index = 0;
$sLoginMode = '';
$sAuthentication = 'internal';
while(($sLoginMode == '') && ($index < count($aAllowedLoginTypes)))
{
$sLoginType = $aAllowedLoginTypes[$index];
switch($sLoginType)
{
case 'form':
// iTop standard mode: form based authentication
$sAuthUser = utils::ReadPostedParam('auth_user', '');
$sAuthPwd = utils::ReadPostedParam('auth_pwd', '');
if ($sAuthUser != '')
{
$sLoginMode = 'form';
}
break;
case 'basic':
// Standard PHP authentication method, works with Apache...
// Case 1) Apache running in CGI mode + rewrite rules in .htaccess
if (isset($_SERVER['HTTP_AUTHORIZATION']) && !empty($_SERVER['HTTP_AUTHORIZATION']))
{
list($sAuthUser, $sAuthPwd) = explode(':' , base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'], 6)));
$sLoginMode = 'basic';
}
else if (isset($_SERVER['PHP_AUTH_USER']))
{
$sAuthUser = $_SERVER['PHP_AUTH_USER'];
$sAuthPwd = $_SERVER['PHP_AUTH_PW'];
$sLoginMode = 'basic';
}
break;
case 'external':
// Web server supplied authentication
$bExternalAuth = false;
$sExtAuthVar = MetaModel::GetConfig()->GetExternalAuthenticationVariable(); // In which variable is the info passed ?
$sEval = '$bExternalAuth = isset('.$sExtAuthVar.');';
eval($sEval);
if ($bExternalAuth)
{
eval('$sAuthUser = '.$sExtAuthVar.';'); // Retrieve the value
$sAuthPwd = ''; // No password in this case the web server already authentified the user...
$sLoginMode = 'external';
$sAuthentication = 'external';
}
break;
case 'url':
// Credentials passed directly in the url
$sAuthUser = utils::ReadParam('auth_user', '');
if ($sAuthUser != '')
{
$sAuthPwd = utils::ReadParam('auth_pwd', '');
$sLoginMode = 'url';
}
break;
}
$index++;
}
//echo "\nsLoginMode: $sLoginMode (user: $sAuthUser / pwd: $sAuthPwd\n)";
if ($sLoginMode == '')
{
// First connection
$sDesiredLoginMode = utils::ReadParam('login_mode');
if (in_array($sDesiredLoginMode, $aAllowedLoginTypes))
{
$sLoginMode = $sDesiredLoginMode;
}
else
{
$sLoginMode = $aAllowedLoginTypes[0]; // First in the list...
}
$oPage = new LoginWebPage();
$oPage->DisplayLoginForm( $sLoginMode, false /* no previous failed attempt */);
$oPage->output();
exit;
}
else
{
if (!UserRights::CheckCredentials($sAuthUser, $sAuthPwd, $sAuthentication))
{
self::ResetSession();
$oPage = new LoginWebPage();
$oPage->DisplayLoginForm( $sLoginMode, true /* failed attempt */);
$oPage->output();
exit;
}
else
{
// User is Ok, let's save it in the session and proceed with normal login
UserRights::Login($sAuthUser, $sAuthentication); // Login & set the user's language
$_SESSION['auth_user'] = $sAuthUser;
$_SESSION['login_mode'] = $sLoginMode;
}
}
}
}
/**
* Check if the user is already authentified, if yes, then performs some additional validations:
* - if $bMustBeAdmin is true, then the user must be an administrator, otherwise an error is displayed
* - if $bIsAllowedToPortalUsers is false and the user has only access to the portal, then the user is redirected to the portal
* @param bool $bMustBeAdmin Whether or not the user must be an admin to access the current page
* @param bool $bIsAllowedToPortalUsers Whether or not the current page is considered as part of the portal
*/
static function DoLogin($bMustBeAdmin = false, $bIsAllowedToPortalUsers = false)
{
$operation = utils::ReadParam('loginop', '');
session_name(MetaModel::GetConfig()->Get('session_name'));
session_start();
if ($operation == 'logoff')
{
self::ResetSession();
}
if (!isset($_SESSION['auth_user']) || !isset($_SESSION['auth_pwd']))
{
if ($operation == 'login')
if (isset($_SESSION['login_mode']))
{
$sAuthUser = utils::ReadParam('auth_user', '', 'post');
$sAuthPwd = utils::ReadParam('auth_pwd', '', 'post');
$sLoginMode = $_SESSION['login_mode'];
}
else
{
$oPage = new LoginWebPage();
$oPage->DisplayLoginForm();
$oPage->output();
exit;
$aAllowedLoginTypes = MetaModel::GetConfig()->GetAllowedLoginTypes();
if (count($aAllowedLoginTypes) > 0)
{
$sLoginMode = $aAllowedLoginTypes[0];
}
else
{
$sLoginMode = 'form';
}
}
}
else
{
$sAuthUser = $_SESSION['auth_user'];
$sAuthPwd = $_SESSION['auth_pwd'];
}
if (!UserRights::Login($sAuthUser, $sAuthPwd))
{
self::ResetSession();
$oPage = new LoginWebPage();
$oPage->DisplayLoginForm( true /* failed attempt */);
$oPage->DisplayLoginForm( $sLoginMode, false /* not a failed attempt */);
$oPage->output();
exit;
}
else if ($operation == 'change_pwd')
{
$sAuthUser = $_SESSION['auth_user'];
UserRights::Login($sAuthUser); // Set the user's language
$oPage = new LoginWebPage();
$oPage->DisplayChangePwdForm();
$oPage->output();
exit;
}
else
if ($operation == 'do_change_pwd')
{
$_SESSION['auth_user'] = $sAuthUser ;
$_SESSION['auth_pwd'] = $sAuthPwd;
$sAuthUser = $_SESSION['auth_user'];
UserRights::Login($sAuthUser); // Set the user's language
$sOldPwd = utils::ReadPostedParam('old_pwd');
$sNewPwd = utils::ReadPostedParam('new_pwd');
if (UserRights::CanChangePassword() && ((!UserRights::CheckCredentials($sAuthUser, $sOldPwd)) || (!UserRights::ChangePassword($sOldPwd, $sNewPwd))))
{
$oPage = new LoginWebPage();
$oPage->DisplayChangePwdForm(true); // old pwd was wrong
$oPage->output();
}
}
self::Login();
if ($bMustBeAdmin && !UserRights::IsAdministrator())
{
require_once(APPROOT.'/setup/setuppage.class.inc.php');
$oP = new SetupWebPage(Dict::S('UI:PageTitle:FatalError'));
$oP->add("<h1>".Dict::S('UI:Login:Error:AccessAdmin')."</h1>\n");
$oP->p("<a href=\"../pages/logoff.php\">".Dict::S('UI:LogOffMenu')."</a>");
$oP->output();
exit;
}
elseif ( (!$bIsAllowedToPortalUsers) && (UserRights::IsPortalUser()))
{
// No rights to be here, redirect to the portal
header('Location: ../portal/index.php');
}
}
} // End of class
?>

View File

@@ -1,215 +1,687 @@
<?php
require_once('../core/attributedef.class.inc.php');
require_once('../core/filterdef.class.inc.php');
require_once('../core/stimulus.class.inc.php');
require_once('../core/MyHelpers.class.inc.php');
require_once('../core/cmdbsource.class.inc.php');
require_once('../core/sqlquery.class.inc.php');
require_once('../core/dbobject.class.php');
require_once('../core/dbobjectsearch.class.php');
require_once('../core/dbobjectset.class.php');
require_once('../application/displayblock.class.inc.php');
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* This class manages en entries in the menu tree on the left of the iTop pages
* Construction and display of the application's main menu
*
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
class menuNode extends DBObject
{
public static function Init()
{
$aParams = array
(
"category" => "gui",
"name" => "menuNode",
"description" => "Main menu configuration elements",
"key_type" => "autoincrement",
"key_label" => "",
"name_attcode" => "name",
"state_attcode" => "",
"reconc_keys" => array(),
"db_table" => "priv_menunode",
"db_key_field" => "id",
"db_finalclass_field" => "",
);
MetaModel::Init_Params($aParams);
// MetaModel::Init_AddAttribute(new AttributeExternalKey("change", array("label"=>"change", "description"=>"change", "allowed_values"=>null, "sql"=>"changeid", "targetclass"=>"CMDBChange", "jointype"=>"closed")));
// MetaModel::Init_AddAttribute(new AttributeExternalField("date", array("label"=>"date", "description"=>"date and time of the change", "allowed_values"=>null, "extkey_attcode"=>"change", "target_attcode"=>"date")));
MetaModel::Init_AddAttribute(new AttributeString("name", array("label"=>"Menu Name", "description"=>"Short name for this menu", "allowed_values"=>null, "sql"=>"name", "default_value"=>"", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("label", array("label"=>"Menu Description", "description"=>"Long description for this menu", "allowed_values"=>null, "sql"=>"label", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("hyperlink", array("label"=>"Hyperlink", "description"=>"Hyperlink to the page", "allowed_values"=>null, "sql"=>"hyperlink", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("icon_path", array("label"=>"Menu Icon", "description"=>"Path to the icon o the menu", "allowed_values"=>null, "sql"=>"icon_path", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("template", array("label"=>"Template", "description"=>"HTML template for the view", "allowed_values"=>null, "sql"=>"template", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeEnum("type", array("label"=>"Type", "description"=>"Type of menu", "allowed_values"=>new ValueSetEnum('application,user,administrator'), "sql"=>"type", "default_value"=>"application", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeInteger("rank", array("label"=>"Display rank", "description"=>"Sort order for displaying the menu", "allowed_values"=>null, "sql"=>"rank", "default_value" => 999, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalKey("parent_id", array("label"=>"Parent Menu Item", "description"=>"Parent Menu Item", "allowed_values"=>null, "sql"=>"parent_id", "targetclass"=>"menuNode", "is_null_allowed"=>true, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("parent_name", array("label"=>"Parent Menu Item", "description"=>"Parent Menu Item", "allowed_values"=>null, "extkey_attcode"=>"parent_id", "target_attcode"=>"name")));
MetaModel::Init_AddAttribute(new AttributeInteger("user_id", array("label"=>"Owner of the menu", "description"=>"User who owns this menu (for user defined menus)", "allowed_values"=>null, "sql"=>"user_id", "default_value" => 0, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddFilterFromAttribute("label");
MetaModel::Init_AddFilterFromAttribute("parent_id");
MetaModel::Init_AddFilterFromAttribute("rank");
MetaModel::Init_AddFilterFromAttribute("type");
MetaModel::Init_AddFilterFromAttribute("user_id");
MetaModel::Init_SetZListItems('details', array('parent_id', 'name', 'label', 'hyperlink', 'template', 'rank', 'type')); // Attributes to be displayed for the complete details
MetaModel::Init_SetZListItems('list', array('parent_id', 'name', 'label', 'rank', 'type')); // Attributes to be displayed for a list
require_once(APPROOT.'/application/utils.inc.php');
require_once(APPROOT.'/application/template.class.inc.php');
/**
* This class manipulates, stores and displays the navigation menu used in the application
* In order to improve the modularity of the data model and to ease the update/migration
* between evolving data models, the menus are no longer stored in the database, but are instead
* built on the fly each time a page is loaded.
* The application's menu is organized into top-level groups with, inside each group, a tree of menu items.
* Top level groups do not display any content, they just expand/collapse.
* Sub-items drive the actual content of the page, they are based either on templates, OQL queries or full (external?) web pages.
*
* Example:
* Here is how to insert the following items in the application's menu:
* +----------------------------------------+
* | Configuration Management Group | >> Top level group
* +----------------------------------------+
* + Configuration Management Overview >> Template based menu item
* + Contacts >> Template based menu item
* + Persons >> Plain list (OQL based)
* + Teams >> Plain list (OQL based)
*
* // Create the top-level group. fRank = 1, means it will be inserted after the group '0', which is usually 'Welcome'
* $oConfigMgmtMenu = new MenuGroup('ConfigurationManagementMenu', 1);
* // Create an entry, based on a custom template, for the Configuration management overview, under the top-level group
* new TemplateMenuNode('ConfigurationManagementMenu', '../somedirectory/configuration_management_menu.html', $oConfigMgmtMenu->GetIndex(), 0);
* // Create an entry (template based) for the overview of contacts
* $oContactsMenu = new TemplateMenuNode('ContactsMenu', '../somedirectory/configuration_management_menu.html',$oConfigMgmtMenu->GetIndex(), 1);
* // Plain list of persons
* new OQLMenuNode('PersonsMenu', 'SELECT bizPerson', $oContactsMenu->GetIndex(), 0);
*
*/
class ApplicationMenu
{
static $aRootMenus = array();
static $aMenusIndex = array();
/**
* Main function to add a menu entry into the application, can be called during the definition
* of the data model objects
*/
static public function InsertMenu(MenuNode $oMenuNode, $iParentIndex = -1, $fRank)
{
$index = self::GetMenuIndexById($oMenuNode->GetMenuId());
if ($index == -1)
{
// The menu does not already exist, insert it
$index = count(self::$aMenusIndex);
self::$aMenusIndex[$index] = array( 'node' => $oMenuNode, 'children' => array());
if ($iParentIndex == -1)
{
self::$aRootMenus[] = array ('rank' => $fRank, 'index' => $index);
}
else
{
self::$aMenusIndex[$iParentIndex]['children'][] = array ('rank' => $fRank, 'index' => $index);
}
}
return $index;
}
public function IsVisible()
/**
* Entry point to display the whole menu into the web page, used by iTopWebPage
*/
static public function DisplayMenu(iTopWebPage $oPage, $aExtraParams)
{
// Sort the root menu based on the rank
usort(self::$aRootMenus, array('ApplicationMenu', 'CompareOnRank'));
$iAccordion = 0;
$iActiveMenu = ApplicationMenu::GetActiveNodeId();
foreach(self::$aRootMenus as $aMenu)
{
$oMenuNode = self::GetMenuNode($aMenu['index']);
if (!$oMenuNode->IsEnabled()) continue; // Don't display a non-enabled menu
$oPage->AddToMenu('<h3>'.$oMenuNode->GetTitle().'</h3>');
$oPage->AddToMenu('<div>');
$aChildren = self::GetChildren($aMenu['index']);
if (count($aChildren) > 0)
{
$oPage->AddToMenu('<ul>');
$bActive = self::DisplaySubMenu($oPage, $aChildren, $aExtraParams, $iActiveMenu);
$oPage->AddToMenu('</ul>');
if ($bActive)
{
$oPage->add_ready_script("$('#accordion').accordion('activate', $iAccordion);");
$oPage->add_ready_script("$('#accordion').accordion('option', {collapsible: true});"); // Make it auto-collapsible once it has been opened properly
}
}
$oPage->AddToMenu('</div>');
$iAccordion++;
}
}
/**
* Handles the display of the sub-menus (called recursively if necessary)
* @return true if the currently selected menu is one of the submenus
*/
static protected function DisplaySubMenu($oPage, $aMenus, $aExtraParams, $iActiveMenu = -1)
{
// Sort the menu based on the rank
$bActive = false;
usort($aMenus, array('ApplicationMenu', 'CompareOnRank'));
foreach($aMenus as $aMenu)
{
$index = $aMenu['index'];
$oMenu = self::GetMenuNode($index);
if ($oMenu->IsEnabled())
{
$aChildren = self::GetChildren($index);
$sCSSClass = (count($aChildren) > 0) ? ' class="submenu"' : '';
$sHyperlink = $oMenu->GetHyperlink($aExtraParams);
if ($sHyperlink != '')
{
$oPage->AddToMenu('<li'.$sCSSClass.'><a href="'.$oMenu->GetHyperlink($aExtraParams).'">'.$oMenu->GetTitle().'</a></li>');
}
else
{
$oPage->AddToMenu('<li'.$sCSSClass.'>'.$oMenu->GetTitle().'</li>');
}
$aCurrentMenu = self::$aMenusIndex[$index];
if ($iActiveMenu == $index)
{
$bActive = true;
}
if (count($aChildren) > 0)
{
$oPage->AddToMenu('<ul>');
$bActive |= self::DisplaySubMenu($oPage, $aChildren, $aExtraParams, $iActiveMenu);
$oPage->AddToMenu('</ul>');
}
}
}
return $bActive;
}
/**
* Helper function to sort the menus based on their rank
*/
static public function CompareOnRank($a, $b)
{
$result = 1;
if ($a['rank'] == $b['rank'])
{
$result = 0;
}
if ($a['rank'] < $b['rank'])
{
$result = -1;
}
return $result;
}
/**
* Helper function to retrieve the MenuNodeObject based on its ID
*/
static public function GetMenuNode($index)
{
return isset(self::$aMenusIndex[$index]) ? self::$aMenusIndex[$index]['node'] : null;
}
/**
* Helper function to get the list of child(ren) of a menu
*/
static protected function GetChildren($index)
{
return self::$aMenusIndex[$index]['children'];
}
/**
* Helper function to get the ID of a menu based on its name
* @param string $sTitle Title of the menu (as passed when creating the menu)
* @return integer ID of the menu, or -1 if not found
*/
static public function GetMenuIndexById($sTitle)
{
$index = -1;
foreach(self::$aMenusIndex as $aMenu)
{
if ($aMenu['node']->GetMenuId() == $sTitle)
{
$index = $aMenu['node']->GetIndex();
break;
}
}
return $index;
}
/**
* Retrieves the currently active menu (if any, otherwise the first menu is the default)
* @return MenuNode or null if there is no menu at all !
*/
static public function GetActiveNodeId()
{
$oAppContext = new ApplicationContext();
$iMenuIndex = $oAppContext->GetCurrentValue('menu', -1);
if ($iMenuIndex == -1)
{
// Make sure the root menu is sorted on 'rank'
usort(self::$aRootMenus, array('ApplicationMenu', 'CompareOnRank'));
$oFirstGroup = self::GetMenuNode(self::$aRootMenus[0]['index']);
$oMenuNode = self::GetMenuNode(self::$aMenusIndex[$oFirstGroup->GetIndex()]['children'][0]['index']);
$iMenuIndex = $oMenuNode->GetIndex();
}
return $iMenuIndex;
}
}
/**
* Root class for all the kind of node in the menu tree, data model providers are responsible for instantiating
* MenuNodes (i.e instances from derived classes) in order to populate the application's menu. Creating an objet
* derived from MenuNode is enough to have it inserted in the application's main menu.
* The class iTopWebPage, takes care of 3 items:
* +--------------------+
* | Welcome |
* +--------------------+
* Welcome To iTop
* +--------------------+
* | Tools |
* +--------------------+
* CSV Import
* +--------------------+
* | Admin Tools |
* +--------------------+
* User Accounts
* Profiles
* Notifications
* Run Queries
* Export
* Data Model
* Universal Search
*
* All the other menu items must constructed along with the various data model modules
*/
abstract class MenuNode
{
protected $sMenuId;
protected $index;
/**
* Class of objects to check if the menu is enabled, null if none
*/
protected $m_sEnableClass;
/**
* User Rights Action code to check if the menu is enabled, null if none
*/
protected $m_iEnableAction;
/**
* User Rights allowed results (actually a bitmask) to check if the menu is enabled, null if none
*/
protected $m_iEnableActionResults;
/**
* Stimulus to check: if the user can 'apply' this stimulus, then she/he can see this menu
*/
protected $m_sEnableStimulus;
/**
* Create a menu item, sets the condition to have it displayed and inserts it into the application's main menu
* @param string $sMenuId Unique identifier of the menu (used to identify the menu for bookmarking, and for getting the labels from the dictionary)
* @param integer $iParentIndex ID of the parent menu, pass -1 for top level (group) items
* @param float $fRank Number used to order the list, any number will do, but for a given level (i.e same parent) all menus are sorted based on this value
* @param string $sEnableClass Name of class of object
* @param mixed $iActionCode UR_ACTION_READ, UR_ACTION_MODIFY, UR_ACTION_DELETE, UR_ACTION_BULKREAD, UR_ACTION_BULKMODIFY or UR_ACTION_BULKDELETE
* @param integer $iAllowedResults Expected "rights" for the action: either UR_ALLOWED_YES, UR_ALLOWED_NO, UR_ALLOWED_DEPENDS or a mix of them...
* @param string $sEnableStimulus The user can see this menu if she/he has enough rights to apply this stimulus
* @return MenuNode
*/
public function __construct($sMenuId, $iParentIndex = -1, $fRank = 0, $sEnableClass = null, $iActionCode = null, $iAllowedResults = UR_ALLOWED_YES, $sEnableStimulus = null)
{
$this->sMenuId = $sMenuId;
$this->m_sEnableClass = $sEnableClass;
$this->m_iEnableAction = $iActionCode;
$this->m_iEnableActionResults = $iAllowedResults;
$this->m_sEnableStimulus = $sEnableStimulus;
$this->index = ApplicationMenu::InsertMenu($this, $iParentIndex, $fRank);
}
public function GetMenuId()
{
return $this->sMenuId;
}
public function GetTitle()
{
return Dict::S("Menu:$this->sMenuId");
}
public function GetLabel()
{
return Dict::S("Menu:$this->sMenuId+");
}
public function GetIndex()
{
return $this->index;
}
public function GetHyperlink($aExtraParams)
{
$aExtraParams['c[menu]'] = $this->GetIndex();
return $this->AddParams('../pages/UI.php', $aExtraParams);
}
/**
* Tells whether the menu is enabled (i.e. displayed) for the current user
* @return bool True if enabled, false otherwise
*/
public function IsEnabled()
{
if ($this->m_sEnableClass != null)
{
if (MetaModel::IsValidClass($this->m_sEnableClass))
{
if ($this->m_sEnableStimulus != null)
{
if (!UserRights::IsStimulusAllowed($this->m_sEnableClass, $this->m_sEnableStimulus))
{
return false;
}
}
if ($this->m_iEnableAction != null)
{
$iResult = UserRights::IsActionAllowed($this->m_sEnableClass, $this->m_iEnableAction);
if (($iResult & $this->m_iEnableActionResults))
{
return true;
}
else
{
return false;
}
}
return true;
}
return false;
}
return true;
}
public function GetMenuName()
public abstract function RenderContent(WebPage $oPage, $aExtraParams = array());
protected function AddParams($sHyperlink, $aExtraParams)
{
return $this->Get('name');
if (count($aExtraParams) > 0)
{
$aQuery = array();
$sSeparator = '?';
if (strpos($sHyperlink, '?') !== false)
{
$sSeparator = '&';
}
foreach($aExtraParams as $sName => $sValue)
{
$aQuery[] = urlencode($sName).'='.urlencode($sValue);
}
$sHyperlink .= $sSeparator.implode('&', $aQuery);
}
return $sHyperlink;
}
}
public function GetMenuIcon()
/**
* This class implements a top-level menu group. A group is just a container for sub-items
* it does not display a page by itself
*/
class MenuGroup extends MenuNode
{
/**
* Create a top-level menu group and inserts it into the application's main menu
* @param string $sMenuId Unique identifier of the menu (used to identify the menu for bookmarking, and for getting the labels from the dictionary)
* @param float $fRank Number used to order the list, the groups are sorted based on this value
* @param string $sEnableClass Name of class of object
* @param integer $iActionCode Either UR_ACTION_READ, UR_ACTION_MODIFY, UR_ACTION_DELETE, UR_ACTION_BULKREAD, UR_ACTION_BULKMODIFY or UR_ACTION_BULKDELETE
* @param integer $iAllowedResults Expected "rights" for the action: either UR_ALLOWED_YES, UR_ALLOWED_NO, UR_ALLOWED_DEPENDS or a mix of them...
* @return MenuGroup
*/
public function __construct($sMenuId, $fRank, $sEnableClass = null, $iActionCode = null, $iAllowedResults = UR_ALLOWED_YES, $sEnableStimulus = null)
{
return $this->Get('icon_path');
}
public function GetMenuLabel()
{
return $this->Get('label');
parent::__construct($sMenuId, -1 /* no parent, groups are at root level */, $fRank, $sEnableClass, $iActionCode, $iAllowedResults, $sEnableStimulus);
}
public function GetMenuLink($aExtraParams)
{
$aExtraParams['menu'] = $this->GetKey(); // Make sure we overwrite the current menu id (if any)
$aParams = array();
foreach($aExtraParams as $sName => $sValue)
{
$aParams[] = urlencode($sName)."=".urlencode($sValue);
}
return $this->Get('hyperlink')."?".implode("&", $aParams);
}
public function GetChildNodesSet($sType = null)
{
$aParams = array();
if ($sType == 'user')
{
$sSelectChilds = 'SELECT menuNode AS m WHERE m.parent_id = :parent AND type = :type AND m.user_id = :user';
$aParams = array('parent' => $this->GetKey(), 'type' => $sType, 'user' => UserRights::GetUserId());
}
elseif ($sType != null)
{
$sSelectChilds = 'SELECT menuNode AS m WHERE m.parent_id = :parent AND type = :type';
$aParams = array('parent' => $this->GetKey(), 'type' => $sType);
}
else
{
$sSelectChilds = 'SELECT menuNode AS m WHERE m.parent_id = :parent';
$aParams = array('parent' => $this->GetKey());
}
$oSearchFilter = DBObjectSearch::FromOQL($sSelectChilds);
$oSet = new CMDBObjectSet($oSearchFilter, array('rank' => true), $aParams);
return $oSet;
}
public function RenderContent(WebPage $oPage, $aExtraParams = array())
{
$sTemplate = $this->Get('template');
$oTemplate = new DisplayTemplate($sTemplate);
$oTemplate->Render($oPage, $aExtraParams);
//$this->ProcessTemplate($sTemplate, $oPage, $aExtraParams);
assert(false); // Shall never be called, groups do not display any content
}
}
/**
* This class defines a menu item which content is based on a custom template.
* Note the template can be either a local file or an URL !
*/
class TemplateMenuNode extends MenuNode
{
protected $sTemplateFile;
/**
* Create a menu item based on a custom template and inserts it into the application's main menu
* @param string $sMenuId Unique identifier of the menu (used to identify the menu for bookmarking, and for getting the labels from the dictionary)
* @param string $sTemplateFile Path (or URL) to the file that will be used as a template for displaying the page's content
* @param integer $iParentIndex ID of the parent menu
* @param float $fRank Number used to order the list, any number will do, but for a given level (i.e same parent) all menus are sorted based on this value
* @param string $sEnableClass Name of class of object
* @param integer $iActionCode Either UR_ACTION_READ, UR_ACTION_MODIFY, UR_ACTION_DELETE, UR_ACTION_BULKREAD, UR_ACTION_BULKMODIFY or UR_ACTION_BULKDELETE
* @param integer $iAllowedResults Expected "rights" for the action: either UR_ALLOWED_YES, UR_ALLOWED_NO, UR_ALLOWED_DEPENDS or a mix of them...
* @return MenuNode
*/
public function __construct($sMenuId, $sTemplateFile, $iParentIndex, $fRank = 0, $sEnableClass = null, $iActionCode = null, $iAllowedResults = UR_ALLOWED_YES, $sEnableStimulus = null)
{
parent::__construct($sMenuId, $iParentIndex, $fRank, $sEnableClass, $iActionCode, $iAllowedResults, $sEnableStimulus);
$this->sTemplateFile = $sTemplateFile;
}
public function DisplayMenu(iTopWebPage $oP, $sType, $aExtraParams)
public function GetHyperlink($aExtraParams)
{
$oP->AddToMenu("<li><a href=\"".$this->GetMenuLink($aExtraParams)."\" title=\"".$this->GetMenuLabel()."\">".$this->GetMenuName()."</a>");
$oSet = $this->GetChildNodesSet($sType);
if ($oSet->Count() > 0)
{
$oP->AddToMenu("\n<ul>\n");
while($oChildNode = $oSet->Fetch())
{
$oChildNode->DisplayMenu($oP, $sType, $aExtraParams);
}
$oP->AddToMenu("</ul>\n");
}
$oP->AddToMenu("</li>\n");
}
static public function DisplayCreationForm(WebPage $oP, $sClass, $sFilter, $aExtraParams = array())
{
$oFilter = DBObjectSearch::unserialize($sFilter);
$oP->p('Create a new menu item for: '.$oFilter->__DescribeHTML());
$oP->add('<form action="UniversalSearch.php" method="post">');
$oP->add('<input type="hidden" name="operation" value="add_menu">');
$oP->add('<input type="hidden" name="filter" value="'.$sFilter.'">');
$oP->add('<input type="hidden" name="class" value="'.$sClass.'">');
$oP->p('Menu Label: <input type="text" name="label" size="30">');
$oP->p('Description: <input type="text" name="description" size="30">');
$oP->add('<p>Insert after: <select name="previous_node_id">');
$aNodes = self::GetMenuAsArray(null, 'user');
foreach($aNodes as $aNodeDesc)
{
$oP->add('<option value="'.$aNodeDesc['id'].'">'.str_repeat('&nbsp;&nbsp;&nbsp;', $aNodeDesc['depth']).$aNodeDesc['label'].'</option>');
}
$oP->add('</select></p>');
$oP->p('<input type="checkbox" name="child_item" value="1"> Create as a child menu item');
$oP->p('<input type="submit" value=" Ok "> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" class="jqmClose" value="Cancel">');
$oP->add('</form>');
if ($this->sTemplateFile == '') return '';
return parent::GetHyperlink($aExtraParams);
}
static public function GetMenuAsArray($oRootNode = null, $sType = 'application', $iDepth = 0)
public function RenderContent(WebPage $oPage, $aExtraParams = array())
{
$aNodes = array();
if (is_object($oRootNode))
$sTemplate = @file_get_contents($this->sTemplateFile);
if ($sTemplate !== false)
{
$oChildSet = $oRootNode->GetChildNodesSet($sType);
while($oNode = $oChildSet->Fetch())
{
$aNodes[] = array('depth' => $iDepth, 'id' => $oNode->GetKey(), 'label' => $oNode->GetName());
$aNodes = array_merge($aNodes, self::GetMenuAsArray($oNode, $sType, $iDepth+1));
}
$oTemplate = new DisplayTemplate($sTemplate);
$oTemplate->Render($oPage, $aExtraParams);
}
else
{
$oSearchFilter = new DbObjectSearch("menuNode");
$oSearchFilter->AddCondition('parent_id', 0, '=');
if ($sType != null)
{
$oSearchFilter->AddCondition('type', $sType, '=');
if ($sType == 'user')
{
$oSearchFilter->AddCondition('user_id', UserRights::GetUserId(), '=');
}
}
$oRootSet = new CMDBObjectSet($oSearchFilter, array('rank' => true));
while($oNode = $oRootSet->Fetch())
{
$aNodes[] = array('depth' => $iDepth, 'id' => $oNode->GetKey(), 'label' => $oNode->GetName());
$aNodes = array_merge($aNodes, self::GetMenuAsArray($oNode, $sType, $iDepth+1));
}
$oPage->p("Error: failed to load template file: '{$this->sTemplateFile}'"); // No need to translate ?
}
return $aNodes;
}
}
/**
* This class defines a menu item that uses a standard template to display a list of items therefore it allows
* only two parameters: the page's title and the OQL expression defining the list of items to be displayed
*/
class OQLMenuNode extends MenuNode
{
protected $sPageTitle;
protected $sOQL;
protected $bSearch;
/**
* Returns a set of all the nodes following the current node in the tree
* (i.e. nodes with the same parent but with a greater rank)
* Extra parameters to be passed to the display block to fine tune its appearence
*/
public function GetNextNodesSet($sType = 'application')
protected $m_aParams;
/**
* Create a menu item based on an OQL query and inserts it into the application's main menu
* @param string $sMenuId Unique identifier of the menu (used to identify the menu for bookmarking, and for getting the labels from the dictionary)
* @param string $sOQL OQL query defining the set of objects to be displayed
* @param integer $iParentIndex ID of the parent menu
* @param float $fRank Number used to order the list, any number will do, but for a given level (i.e same parent) all menus are sorted based on this value
* @param bool $bSearch Whether or not to display a (collapsed) search frame at the top of the page
* @param string $sEnableClass Name of class of object
* @param integer $iActionCode Either UR_ACTION_READ, UR_ACTION_MODIFY, UR_ACTION_DELETE, UR_ACTION_BULKREAD, UR_ACTION_BULKMODIFY or UR_ACTION_BULKDELETE
* @param integer $iAllowedResults Expected "rights" for the action: either UR_ALLOWED_YES, UR_ALLOWED_NO, UR_ALLOWED_DEPENDS or a mix of them...
* @return MenuNode
*/
public function __construct($sMenuId, $sOQL, $iParentIndex, $fRank = 0, $bSearch = false, $sEnableClass = null, $iActionCode = null, $iAllowedResults = UR_ALLOWED_YES, $sEnableStimulus = null)
{
$oSearchFilter = new DBObjectSearch("menuNode");
$oSearchFilter->AddCondition('parent_id', $this->Get('parent_id'));
$oSearchFilter->AddCondition('rank', $this->Get('rank'), '>');
if ($sType != null)
parent::__construct($sMenuId, $iParentIndex, $fRank, $sEnableClass, $iActionCode, $iAllowedResults, $sEnableStimulus);
$this->sPageTitle = "Menu:$sMenuId+";
$this->sOQL = $sOQL;
$this->bSearch = $bSearch;
$this->m_aParams = array();
// Enhancement: we could set as the "enable" condition that the user has enough rights to "read" the objects
// of the class specified by the OQL...
}
/**
* Set some extra parameters to be passed to the display block to fine tune its appearence
* @param Hash $aParams paramCode => value. See DisplayBlock::GetDisplay for the meaning of the parameters
*/
public function SetParameters($aParams)
{
$this->m_aParams = $aParams;
}
public function RenderContent(WebPage $oPage, $aExtraParams = array())
{
$aExtraParams = array_merge($aExtraParams, $this->m_aParams);
try
{
$oSearchFilter->AddCondition('type', $sType, '=');
if ($sType == 'user')
$oSearch = DBObjectSearch::FromOQL($this->sOQL);
$sIcon = MetaModel::GetClassIcon($oSearch->GetClass());
}
catch(Exception $e)
{
$sIcon = '';
}
// The standard template used for all such pages: a (closed) search form at the top and a list of results at the bottom
$sTemplate = '';
if ($this->bSearch)
{
$sTemplate .= <<<EOF
<itopblock BlockClass="DisplayBlock" type="search" asynchronous="false" encoding="text/oql">$this->sOQL</itopblock>
EOF;
}
$sParams = '';
if (!empty($this->m_aParams))
{
$sParams = 'parameters="';
foreach($this->m_aParams as $sName => $sValue)
{
$oSearchFilter->AddCondition('user_id', UserRights::GetUserId(), '=');
$sParams .= $sName.':'.$sValue.';';
}
$sParams .= '"';
}
$sTemplate .= <<<EOF
<p class="page-header">$sIcon<itopstring>$this->sPageTitle</itopstring></p>
<itopblock BlockClass="DisplayBlock" type="list" asynchronous="false" encoding="text/oql" $sParams>$this->sOQL</itopblock>
EOF;
$oTemplate = new DisplayTemplate($sTemplate);
$oTemplate->Render($oPage, $aExtraParams);
}
}
/**
* This class defines a menu item that displays a search form for the given class of objects
*/
class SearchMenuNode extends MenuNode
{
protected $sPageTitle;
protected $sClass;
/**
* Create a menu item based on an OQL query and inserts it into the application's main menu
* @param string $sMenuId Unique identifier of the menu (used to identify the menu for bookmarking, and for getting the labels from the dictionary)
* @param string $sClass The class of objects to search for
* @param string $sPageTitle Title displayed into the page's content (will be looked-up in the dictionnary for translation)
* @param integer $iParentIndex ID of the parent menu
* @param float $fRank Number used to order the list, any number will do, but for a given level (i.e same parent) all menus are sorted based on this value
* @param string $sEnableClass Name of class of object
* @param integer $iActionCode Either UR_ACTION_READ, UR_ACTION_MODIFY, UR_ACTION_DELETE, UR_ACTION_BULKREAD, UR_ACTION_BULKMODIFY or UR_ACTION_BULKDELETE
* @param integer $iAllowedResults Expected "rights" for the action: either UR_ALLOWED_YES, UR_ALLOWED_NO, UR_ALLOWED_DEPENDS or a mix of them...
* @return MenuNode
*/
public function __construct($sMenuId, $sClass, $iParentIndex, $fRank = 0, $bSearch = false, $sEnableClass = null, $iActionCode = null, $iAllowedResults = UR_ALLOWED_YES, $sEnableStimulus = null)
{
parent::__construct($sMenuId, $iParentIndex, $fRank, $sEnableClass, $iActionCode, $iAllowedResults, $sEnableStimulus);
$this->sPageTitle = "Menu:$sMenuId+";
$this->sClass = $sClass;
}
public function RenderContent(WebPage $oPage, $aExtraParams = array())
{
// The standard template used for all such pages: an open search form at the top
$sTemplate = <<<EOF
<itopblock BlockClass="DisplayBlock" type="search" asynchronous="false" encoding="text/oql" parameters="open:true">SELECT $this->sClass</itopblock>
EOF;
$oTemplate = new DisplayTemplate($sTemplate);
$oTemplate->Render($oPage, $aExtraParams);
}
}
/**
* This class defines a menu that points to any web page. It takes only two parameters:
* - The hyperlink to point to
* - The name of the menu
* Note: the parameter menu=xxx (where xxx is the id of the menu itself) will be added to the hyperlink
* in order to make it the active one, if the target page is based on iTopWebPage and therefore displays the menu
*/
class WebPageMenuNode extends MenuNode
{
protected $sHyperlink;
/**
* Create a menu item that points to any web page (not only UI.php)
* @param string $sMenuId Unique identifier of the menu (used to identify the menu for bookmarking, and for getting the labels from the dictionary)
* @param string $sHyperlink URL to the page to load. Use relative URL if you want to keep the application portable !
* @param integer $iParentIndex ID of the parent menu
* @param float $fRank Number used to order the list, any number will do, but for a given level (i.e same parent) all menus are sorted based on this value
* @param string $sEnableClass Name of class of object
* @param integer $iActionCode Either UR_ACTION_READ, UR_ACTION_MODIFY, UR_ACTION_DELETE, UR_ACTION_BULKREAD, UR_ACTION_BULKMODIFY or UR_ACTION_BULKDELETE
* @param integer $iAllowedResults Expected "rights" for the action: either UR_ALLOWED_YES, UR_ALLOWED_NO, UR_ALLOWED_DEPENDS or a mix of them...
* @return MenuNode
*/
public function __construct($sMenuId, $sHyperlink, $iParentIndex, $fRank = 0, $sEnableClass = null, $iActionCode = null, $iAllowedResults = UR_ALLOWED_YES, $sEnableStimulus = null)
{
parent::__construct($sMenuId, $iParentIndex, $fRank, $sEnableClass, $iActionCode, $iAllowedResults, $sEnableStimulus);
$this->sHyperlink = $sHyperlink;
}
public function GetHyperlink($aExtraParams)
{
$aExtraParams['c[menu]'] = $this->GetIndex();
return $this->AddParams( $this->sHyperlink, $aExtraParams);
}
public function RenderContent(WebPage $oPage, $aExtraParams = array())
{
assert(false); // Shall never be called, the external web page will handle the display by itself
}
}
/**
* This class defines a menu that points to the page for creating a new object of the specified class.
* It take only one parameter: the name of the class
* Note: the parameter menu=xxx (where xxx is the id of the menu itself) will be added to the hyperlink
* in order to make it the active one
*/
class NewObjectMenuNode extends MenuNode
{
protected $sClass;
/**
* Create a menu item that points to the URL for creating a new object, the menu will be added only if the current user has enough
* rights to create such an object (or an object of a child class)
* @param string $sMenuId Unique identifier of the menu (used to identify the menu for bookmarking, and for getting the labels from the dictionary)
* @param string $sClass URL to the page to load. Use relative URL if you want to keep the application portable !
* @param integer $iParentIndex ID of the parent menu
* @param float $fRank Number used to order the list, any number will do, but for a given level (i.e same parent) all menus are sorted based on this value
* @return MenuNode
*/
public function __construct($sMenuId, $sClass, $iParentIndex, $fRank = 0)
{
parent::__construct($sMenuId, $iParentIndex, $fRank);
$this->sClass = $sClass;
}
public function GetHyperlink($aExtraParams)
{
$sHyperlink = '../pages/UI.php?operation=new&class='.$this->sClass;
$aExtraParams['c[menu]'] = $this->GetIndex();
return $this->AddParams($sHyperlink, $aExtraParams);
}
/**
* Overload the check of the "enable" state of this menu to take into account
* derived classes of objects
*/
public function IsEnabled()
{
// Enable this menu, only if the current user has enough rights to create such an object, or an object of
// any child class
$aSubClasses = MetaModel::EnumChildClasses($this->sClass, ENUM_CHILD_CLASSES_ALL); // Including the specified class itself
$bActionIsAllowed = false;
foreach($aSubClasses as $sCandidateClass)
{
if (!MetaModel::IsAbstract($sCandidateClass) && (UserRights::IsActionAllowed($sCandidateClass, UR_ACTION_MODIFY) == UR_ALLOWED_YES))
{
$bActionIsAllowed = true;
break; // Enough for now
}
}
$oSet = new DBObjectSet($oSearchFilter, array('rank'=> true)); // Order by rank (true means ascending)
return $oSet;
return $bActionIsAllowed;
}
public function RenderContent(WebPage $oPage, $aExtraParams = array())
{
assert(false); // Shall never be called, the external web page will handle the display by itself
}
}
?>

View File

@@ -1,5 +1,29 @@
<?php
require_once("../application/webpage.class.inc.php");
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* Class NiceWebPage
*
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
require_once(APPROOT."/application/webpage.class.inc.php");
/**
* Web page with some associated CSS and scripts (jquery) for a fancier display
*/
@@ -11,16 +35,18 @@ class NiceWebPage extends WebPage
{
parent::__construct($s_title);
$this->m_aReadyScripts = array();
$this->add_linked_script("../js/jquery.latest.js");
$this->add_linked_script("../js/jquery.history_remote.pack.js");
$this->add_linked_script("../js/jquery-1.4.2.min.js");
//$this->add_linked_script("../js/jquery.history_remote.pack.js");
$this->add_linked_stylesheet('../css/ui-lightness/jquery-ui-1.8.2.custom.css');
$this->add_linked_script('../js/jquery-ui-1.8.2.custom.min.js');
//$this->add_linked_script("../js/ui.resizable.js");
$this->add_linked_script("../js/ui.tabs.js");
// $this->add_linked_script("../js/ui.tabs.js");
$this->add_linked_script("../js/hovertip.js");
$this->add_linked_script("../js/jqModal.js");
// $this->add_linked_script("../js/jqModal.js");
$this->add_linked_stylesheet("../css/light-grey.css");
$this->add_linked_stylesheet("../js/themes/light/light.tabs.css");
// $this->add_linked_stylesheet("../js/themes/light/light.tabs.css");
//$this->add_linked_stylesheet("../css/jquery.tabs-ie.css", "lte IE 7");
$this->add_linked_stylesheet("../css/jqModal.css");
// $this->add_linked_stylesheet("../css/jqModal.css");
$this->add_ready_script(' window.setTimeout(hovertipInit, 1);');
}
@@ -35,14 +61,20 @@ class NiceWebPage extends WebPage
// $aTopLevelClasses = array('bizService', 'bizContact', 'logInfra', 'bizDocument');
// These are classes wich root class is cmdbAbstractObject !
$this->add("<select id=\"select_$sName\" name=\"$sName\">");
$aValidClasses = array();
foreach(MetaModel::GetClasses('bizmodel') as $sClassName)
{
if (is_null($iActionCode) || UserRights::IsActionAllowed($sClassName, $iActionCode))
{
$sSelected = ($sClassName == $sDefaultValue) ? " SELECTED" : "";
$this->add("<option style=\"width: ".$iWidthPx." px;\" value=\"$sClassName\"$sSelected>$sClassName - ".MetaModel::GetClassDescription($sClassName)."</option>");
$sDescription = MetaModel::GetClassDescription($sClassName);
$sDisplayName = MetaModel::GetName($sClassName);
$aValidClasses[$sDisplayName] = "<option style=\"width: ".$iWidthPx." px;\" title=\"$sDescription\" value=\"$sClassName\"$sSelected>$sDisplayName</option>";
}
}
ksort($aValidClasses);
$this->add(implode("\n", $aValidClasses));
$this->add("</select>");
}
@@ -53,7 +85,7 @@ class NiceWebPage extends WebPage
foreach($aChoices as $sKey => $sValue)
{
$sSelected = ($sKey == $sDefaultValue) ? " SELECTED" : "";
$this->add("<option style=\"width: ".$iWidthPx." px;\" value=\"$sKey\"$sSelected>$sValue</option>");
$this->add("<option style=\"width: ".$iWidthPx." px;\" value=\"".htmlspecialchars($sKey)."\"$sSelected>".htmlentities($sValue, ENT_QUOTES, 'UTF-8')."</option>");
}
$this->add("</select>");
}

View File

@@ -0,0 +1,177 @@
<?php
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* Class PortalWebPage
*
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
require_once(APPROOT."/application/nicewebpage.class.inc.php");
require_once(APPROOT."/application/applicationcontext.class.inc.php");
require_once(APPROOT."/application/user.preferences.class.inc.php");
/**
* Web page with some associated CSS and scripts (jquery) for a fancier display
* of the Portal web page
*/
class PortalWebPage extends NiceWebPage
{
/**
* Portal menu
*/
protected $m_aMenuButtons;
public function __construct($sTitle, $sAlternateStyleSheet = '')
{
$this->m_aMenuButtons = array();
parent::__construct($sTitle);
$this->add_header("Content-type: text/html; charset=utf-8");
$this->add_header("Cache-control: no-cache");
$this->add_linked_stylesheet("../css/jquery.treeview.css");
$this->add_linked_stylesheet("../css/jquery.autocomplete.css");
if ($sAlternateStyleSheet != '')
{
$this->add_linked_stylesheet("../portal/$sAlternateStyleSheet/portal.css");
}
else
{
$this->add_linked_stylesheet("../portal/portal.css");
}
$this->add_linked_script('../js/jquery.layout.min.js');
$this->add_linked_script('../js/jquery.ba-bbq.min.js');
$this->add_linked_script("../js/jquery.tablehover.js");
$this->add_linked_script("../js/jquery.treeview.js");
$this->add_linked_script("../js/jquery.autocomplete.js");
$this->add_linked_script("../js/jquery.bgiframe.js");
$this->add_linked_script("../js/jquery.positionBy.js");
$this->add_linked_script("../js/jquery.popupmenu.js");
$this->add_linked_script("../js/date.js");
$this->add_linked_script("../js/jquery.tablesorter.min.js");
$this->add_linked_script("../js/jquery.blockUI.js");
$this->add_linked_script("../js/utils.js");
$this->add_linked_script("../js/forms-json-utils.js");
$this->add_linked_script("../js/swfobject.js");
$this->add_ready_script(
<<<EOF
try
{
//add new widget called TruncatedList to properly display truncated lists when they are sorted
$.tablesorter.addWidget({
// give the widget a id
id: "truncatedList",
// format is called when the on init and when a sorting has finished
format: function(table)
{
// Check if there is a "truncated" line
this.truncatedList = false;
if ($("tr td.truncated",table).length > 0)
{
this.truncatedList = true;
}
if (this.truncatedList)
{
$("tr td",table).removeClass('truncated');
$("tr:last td",table).addClass('truncated');
}
}
});
$.tablesorter.addWidget({
// give the widget a id
id: "myZebra",
// format is called when the on init and when a sorting has finished
format: function(table)
{
// Replace the 'red even' lines by 'red_even' since most browser do not support 2 classes selector in CSS, etc..
$("tbody tr:even",table).addClass('even');
$("tbody tr.red:even",table).removeClass('red').removeClass('even').addClass('red_even');
$("tbody tr.orange:even",table).removeClass('orange').removeClass('even').addClass('orange_even');
$("tbody tr.green:even",table).removeClass('green').removeClass('even').addClass('green_even');
}
});
$("table.listResults").tableHover(); // hover tables
$(".listResults").tablesorter( { widgets: ['myZebra', 'truncatedList']} ); // sortable and zebra tables
$(".date-pick").datepicker({
showOn: 'button',
buttonImage: '../images/calendar.png',
buttonImageOnly: true,
dateFormat: 'yy-mm-dd',
constrainInput: false,
changeMonth: true,
changeYear: true
});
$('.resizable').resizable(); // Make resizable everything that claims to be resizable !
}
catch(err)
{
// Do something with the error !
alert(err);
}
EOF
);
$this->add_script(
<<<EOF
function CheckSelection(sMessage)
{
var bResult = ($('input:checked').length > 0);
if (!bResult)
{
alert(sMessage);
}
return bResult;
}
function GoBack()
{
var form = $('#request_form');
var step = $('input[name=step]');
form.unbind('submit'); // De-activate validation
step.val(step.val() -2); // To go Back one step: next step is x, current step is x-1, previous step is x-2
form.submit(); // Go
}
EOF
);
}
/**
* Add a button to the portal's main menu
*/
public function AddMenuButton($sId, $sLabel, $sHyperlink)
{
$this->m_aMenuButtons[] = array('id' => $sId, 'label' => $sLabel, 'hyperlink' => $sHyperlink);
}
public function output()
{
$sMenu = '';
$this->AddMenuButton('logoff', 'Portal:Disconnect', '../pages/logoff.php?portal=1'); // This menu is always present and is the last one
foreach($this->m_aMenuButtons as $aMenuItem)
{
$sMenu .= "<a class=\"button\" id=\"{$aMenuItem['id']}\" href=\"{$aMenuItem['hyperlink']}\"><span>".Dict::S($aMenuItem['label'])."</span></a>";
}
$this->s_content = '<div id="portal"><div id="banner"><div id="logo"></div>'.$sMenu.'</div><div id="content">'.$this->s_content.'</div></div>';
parent::output();
}
}
?>

View File

@@ -1,9 +1,30 @@
<?php
define('ITOP_VERSION', '0.9');
define('ITOP_REVISION', '$WCREV$');
define('ITOP_BUILD_DATE', '$WCNOW$');
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
require_once('../application/utils.inc.php');
/**
* File to include to initialize the datamodel in memory
*
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
require_once(APPROOT.'/core/cmdbobject.class.inc.php');
require_once(APPROOT.'/application/utils.inc.php');
MetaModel::Startup(ITOP_CONFIG_FILE);

View File

@@ -1,5 +1,29 @@
<?php
require_once('../application/displayblock.class.inc.php');
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* Class DisplayTemplate
*
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
require_once(APPROOT.'/application/displayblock.class.inc.php');
/**
* This class manages the special template format used internally to build the iTop web pages
*/
@@ -11,7 +35,7 @@ class DisplayTemplate
public function __construct($sTemplate)
{
$this->m_aTags = array('itopblock', 'itoptabs', 'itoptab', 'itoptoggle');
$this->m_aTags = array('itopblock', 'itopcheck', 'itoptabs', 'itoptab', 'itoptoggle', 'itopstring');
$this->m_sTemplate = $sTemplate;
}
@@ -31,11 +55,23 @@ class DisplayTemplate
$oPage->add(substr($this->m_sTemplate, $iBeforeTagPos, $iStart - $iBeforeTagPos));
if ($sTag == DisplayBlock::TAG_BLOCK)
{
$oBlock = DisplayBlock::FromTemplate($sOuterTag);
if (is_object($oBlock))
try
{
$oBlock->Display($oPage, 'block_'.self::$iBlockCount, $aParams);
$oBlock = DisplayBlock::FromTemplate($sOuterTag);
if (is_object($oBlock))
{
$oBlock->Display($oPage, 'block_'.self::$iBlockCount, $aParams);
}
}
catch(OQLException $e)
{
$oPage->p('Error in template (please contact your administrator) - Invalid query<!--'.$sOuterTag.'-->');
}
catch(Exception $e)
{
$oPage->p('Error in template (please contact your administrator)<!--'.$e->getMessage().'--><!--'.$sOuterTag.'-->');
}
self::$iBlockCount++;
}
else
@@ -50,7 +86,6 @@ class DisplayTemplate
$iStart = $iEnd;
$iEnd = strlen($this->m_sTemplate);
$iCount++;
if ($iCount > 10) break; //@@@ Why ?? Debug ??
}
$oPage->add(substr($this->m_sTemplate, $iAfterTagPos));
}
@@ -132,8 +167,22 @@ class DisplayTemplate
$oPage->SetCurrentTabContainer('');
break;
case 'itopcheck':
$sClassName = $aAttributes['class'];
if (MetaModel::IsValidClass($sClassName) && UserRights::IsActionAllowed($sClassName, UR_ACTION_READ))
{
$oTemplate = new DisplayTemplate($sContent);
$oTemplate->Render($oPage, array()); // no params to apply, they have already been applied
}
else
{
// Leave a trace for those who'd like to understand why nothing is displayed
$oPage->add("<!-- class $sClassName does not exist, skipping some part of the template -->\n");
}
break;
case 'itoptab':
$oPage->SetCurrentTab(str_replace('_', ' ', $aAttributes['name']));
$oPage->SetCurrentTab(Dict::S(str_replace('_', ' ', $aAttributes['name'])));
$oTemplate = new DisplayTemplate($sContent);
$oTemplate->Render($oPage, array()); // no params to apply, they have already been applied
//$oPage->p('iTop Tab Content:<pre>'.htmlentities($sContent).'</pre>');
@@ -143,13 +192,17 @@ class DisplayTemplate
case 'itoptoggle':
$sName = isset($aAttributes['name']) ? $aAttributes['name'] : 'Tagada';
$bOpen = isset($aAttributes['open']) ? $aAttributes['open'] : true;
$oPage->StartCollapsibleSection($sName, $bOpen);
$oPage->StartCollapsibleSection(Dict::S($sName), $bOpen);
$oTemplate = new DisplayTemplate($sContent);
$oTemplate->Render($oPage, array()); // no params to apply, they have already been applied
//$oPage->p('iTop Tab Content:<pre>'.htmlentities($sContent).'</pre>');
$oPage->EndCollapsibleSection();
break;
case 'itopstring':
$oPage->add(Dict::S($sContent));
break;
case 'itopblock': // No longer used, handled by DisplayBlock::FromTemplate see above
$oPage->add("<!-- Application Error: should be handled by DisplayBlock::FromTemplate -->");
break;
@@ -165,29 +218,29 @@ class DisplayTemplate
*/
static public function UnitTest()
{
require_once('../application/startup.inc.php');
require_once("../application/itopwebpage.class.inc.php");
require_once(APPROOT.'/application/startup.inc.php');
require_once(APPROOT."/application/itopwebpage.class.inc.php");
$sTemplate = '<div class="page_header">
<div class="actions_details"><a href="#"><span>Actions</span></a></div>
<h1>$class$: <span class="hilite">$name$</span></h1>
<itopblock blockclass="HistoryBlock" type="toggle" encoding="text/oql">SELECT CMDBChangeOp WHERE objkey = $pkey$ AND objclass = \'$class$\'</itopblock>
<itopblock blockclass="HistoryBlock" type="toggle" encoding="text/oql">SELECT CMDBChangeOp WHERE objkey = $id$ AND objclass = \'$class$\'</itopblock>
</div>
<img src="../../images/connect_to_network.png" style="margin-top:-10px; margin-right:10px; float:right">
<itopblock blockclass="DisplayBlock" asynchronous="false" type="bare_details" encoding="text/sibusql">bizNetworkDevice: pkey = $pkey$</itopblock>
<itopblock blockclass="DisplayBlock" asynchronous="false" type="bare_details" encoding="text/oql">SELECT NetworkDevice AS d WHERE d.id = $id$</itopblock>
<itoptabs>
<itoptab name="Interfaces">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/sibusql">bizInterface: device_id = $pkey$</itopblock>
<itopblock blockclass="DisplayBlock" type="list" encoding="text/oql">SELECT Interface AS i WHERE i.device_id = $id$</itopblock>
</itoptab>
<itoptab name="Contacts">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/sibusql">bizContact: PKEY IS contact_id IN (ContactsLinks: object_id = $pkey$)</itopblock>
<itopblock blockclass="DisplayBlock" type="list" encoding="text/oql">SELECT Contact AS c JOIN lnkContactToCI AS l ON l.contact_id = c.id WHERE l.ci_id = $id$</itopblock>
</itoptab>
<itoptab name="Documents">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/sibusql">bizDocument: PKEY IS doc_id IN (lnkDocumentRealObject: object_id = $pkey$)</itopblock>
<itopblock blockclass="DisplayBlock" type="list" encoding="text/oql">SELECT Document AS d JOIN lnkDocumentToCI as l ON l.document_id = d.id WHERE l.ci_id = $id$)</itopblock>
</itoptab>
</itoptabs>';
$oPage = new iTopWebPage('Unit Test', 3);
$oPage = new iTopWebPage('Unit Test');
//$oPage->add("Template content: <pre>".htmlentities($sTemplate)."</pre>\n");
$oTemplate = new DisplayTemplate($sTemplate);
$oTemplate->Render($oPage, array('class'=>'Network device','pkey'=> 271, 'name' => 'deliversw01.mecanorama.fr', 'org_id' => 3));

View File

@@ -1,12 +1,12 @@
<div class="page_header">
<itopblock blockclass="MenuBlock" type="popup" encoding="text/sibusql" label="Actions">$class$: pkey = $pkey$</itopblock>
<itopblock blockclass="MenuBlock" type="popup" encoding="text/oql" label="Actions">SELECT $class$ WHERE id = $id$</itopblock>
<h1>$class$: <span class="hilite">$name$</span></h1>
<itopblock blockclass="HistoryBlock" type="toggle" encoding="text/oql">SELECT CMDBChangeOp WHERE objkey = $pkey$ AND objclass = '$class$'</itopblock>
<itopblock blockclass="HistoryBlock" type="toggle" encoding="text/oql">SELECT CMDBChangeOp WHERE objkey = $id$ AND objclass = '$class$'</itopblock>
</div>
<img src="../../images/clean.png" style="margin-top:-20px; margin-right:10px; float:right">
<itopblock blockclass="DisplayBlock" asynchronous="false" type="bare_details" encoding="text/sibusql">$class$: pkey = $pkey$</itopblock>
<itopblock blockclass="DisplayBlock" asynchronous="false" type="bare_details" encoding="text/oql">SELECT $class$ WHERE id = $id$</itopblock>
<itoptabs>
<itoptab name="Rules">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/sibusql">AuditRule: category_id = $pkey$</itopblock>
<itopblock blockclass="DisplayBlock" type="list" encoding="text/oql">SELECT AuditRule WHERE category_id = $id$</itopblock>
</itoptab>
</itoptabs>

View File

@@ -0,0 +1,20 @@
<div class="page_header" style="padding:0.5em;">
<h1><itopstring>UI:NotificationsMenu:Title</itopstring></h1>
</div>
<itoptoggle name="UI:NotificationsMenu:Help" open="true">
<div style="padding: 1em; font-size:10pt;background:#E8F3CF;margin-top: 0.25em;">
<img src="../images/bell.png" style="margin-top: -60px; margin-right: 10px; float: right;">
<itopstring>UI:NotificationsMenu:HelpContent</itopstring>
</div>
</itoptoggle>
<p>&nbsp;</p>
<itoptabs>
<itoptab name="UI:NotificationsMenu:Triggers">
<h2><itopstring>UI:NotificationsMenu:AvailableTriggers</itopstring></h2>
<itopblock BlockClass="DisplayBlock" type="list" asynchronous="false" encoding="text/oql">SELECT Trigger</itopblock>
</itoptab>
<itoptab name="UI:NotificationsMenu:Actions">
<h2><itopstring>UI:NotificationsMenu:AvailableActions</itopstring></h2>
<itopblock BlockClass="DisplayBlock" type="list" asynchronous="false" encoding="text/oql">SELECT ActionEmail</itopblock>
</itoptab>
</itoptabs>

View File

@@ -0,0 +1,46 @@
<div style="width:100%;background: url(../images/welcome.jpg) top left no-repeat;">
<style>
.dashboard {
vertical-align:top;
width:50%;
border:0px solid #000;
background-color:#F9F9F1;
padding:10px;
text-align:left;
font-size:10pt;
}
.dashboard2 {
vertical-align:top;
width:50%;
border:0px solid #000;
-moz-border-radius:10px;
padding:5px;
text-align:left;
}
td.dashboard li {
margin-top: 5px;
display: list-item;
}
td div.display_block {
padding:0;
}
tr td.dashboard2, tr td.dashboard2 ul {
font-size:10pt;
}
</style>
<p></p>
<p></p>
<p style="text-align:left; font-size:32px;padding-left:400px;padding-top:40px;margin-bottom:30px;margin-top:0;color:#FFFFFF;"><itopstring>UI:WelcomeMenu:Title</itopstring></p>
<p></p>
<table border="0" style="padding:10px;border-spacing: 10px;width:100%">
<tr>
<td class="dashboard2">
<itopstring>UI:WelcomeMenu:LeftBlock</itopstring>
</td>
<td class="dashboard2">
<itopstring>UI:WelcomeMenu:RightBlock</itopstring>
</td>
</tr>
</table>
</div>

View File

@@ -0,0 +1,97 @@
<?php
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* This class records the pending "transactions" corresponding to forms that have not been
* submitted yet, in order to prevent double submissions. When created a transaction remains valid
* until the user's session expires
* @package iTop
*/
class privUITransaction
{
/**
* Create a new transaction id, store it in the session and return its id
* @param void
* @return int The identifier of the new transaction
*/
public static function GetNewTransactionId()
{
if (!isset($_SESSION['transactions']))
{
$_SESSION['transactions'] = array();
}
// Strictly speaking, the two lines below should be grouped together
// by a critical section
// sem_acquire($rSemIdentified);
$id = 1 + count($_SESSION['transactions']);
$_SESSION['transactions'][$id] = true;
// sem_release($rSemIdentified);
return sprintf("%d", $id);
}
/**
* Check whether a transaction is valid or not and (optionally) remove the valid transaction from
* the session so that another call to IsTransactionValid for the same transaction id
* will return false
* @param int $id Identifier of the transaction, as returned by GetNewTransactionId
* @param bool $bRemoveTransaction True if the transaction must be removed
* @return bool True if the transaction is valid, false otherwise
*/
public static function IsTransactionValid($id, $bRemoveTransaction = true)
{
$bResult = false;
if (isset($_SESSION['transactions']))
{
// Strictly speaking, the eight lines below should be grouped together
// inside the same critical section as above
// sem_acquire($rSemIdentified);
if (isset($_SESSION['transactions'][$id]))
{
$bResult = true;
if ($bRemoveTransaction)
{
unset($_SESSION['transactions'][$id]);
}
}
// sem_release($rSemIdentified);
}
return $bResult;
}
/**
* Removes the transaction specified by its id
* @param int $id The Identifier (as returned by GetNewTranscationId) of the transaction to be removed.
* @return void
*/
public static function RemoveTransaction($id)
{
if (isset($_SESSION['transactions']))
{
// Strictly speaking, the three lines below should be grouped together
// inside the same critical section as above
// sem_acquire($rSemIdentified);
if (isset($_SESSION['transactions'][$id]))
{
unset($_SESSION['transactions'][$id]);
}
// sem_release($rSemIdentified);
}
}
}
?>

View File

@@ -0,0 +1,271 @@
<?php
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* Class UIExtKeyWidget
* UI wdiget for displaying and editing external keys when
* A simple drop-down list is not enough...
*
* The layout is the following
*
* +-- #label_<id> (input)-------+ +-----------+
* | | | Browse... |
* +-----------------------------+ +-----------+
*
* And the popup dialog has the following layout:
*
* +------------------- ac_dlg_<id> (div)-----------+
* + +--- ds_<id> (div)---------------------------+ |
* | | +------------- fs_<id> (form)------------+ | |
* | | | +--------+---+ | | |
* | | | | Class | V | | | |
* | | | +--------+---+ | | |
* | | | | | |
* | | | S e a r c h F o r m | | |
* | | | +--------+ | | |
* | | | | Search | | | |
* | | | +--------+ | | |
* | | +----------------------------------------+ | |
* | +--------------+-dh_<id>-+--------------------+ |
* | \ Search / |
* | +------+ |
* | +--- fr_<id> (form)--------------------------+ |
* | | +------------ dr_<id> (div)--------------+ | |
* | | | | | |
* | | | S e a r c h R e s u l t s | | |
* | | | | | |
* | | +----------------------------------------+ | |
* | | +--------+ +-----+ | |
* | | | Cancel | | Add | | |
* | | +--------+ +-----+ | |
* | +--------------------------------------------+ |
* +------------------------------------------------+
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
require_once(APPROOT.'/application/webpage.class.inc.php');
require_once(APPROOT.'/application/displayblock.class.inc.php');
class UIExtKeyWidget
{
protected static $iWidgetIndex = 0;
protected $sAttCode;
protected $sNameSuffix;
protected $iId;
protected $sTitle;
public function __construct($sAttCode, $sClass, $sTitle, $aAllowedValues, $value, $iInputId, $bMandatory, $sNameSuffix = '', $sFieldPrefix = '', $sFormPrefix = '')
{
self::$iWidgetIndex++;
$this->sAttCode = $sAttCode;
$this->sClass = $sClass;
$this->oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
$this->sNameSuffix = $sNameSuffix;
$this->iId = $iInputId;
$this->aAllowedValues = $aAllowedValues;
$this->value = $value;
$this->sFieldPrefix = $sFieldPrefix;
$this->sTargetClass = $this->oAttDef->GetTargetClass();
$this->sTitle = $sTitle;
$this->sFormPrefix = $sFormPrefix;
$this->bMandatory = $bMandatory;
}
/**
* Get the HTML fragment corresponding to the linkset editing widget
* @param WebPage $oP The web page used for all the output
* @param Hash $aArgs Extra context arguments
* @return string The HTML fragment to be inserted into the page
*/
public function Display(WebPage $oPage, $aArgs = array())
{
$bCreate = (!MetaModel::IsAbstract($this->sTargetClass)) && (UserRights::IsActionAllowed($this->sTargetClass, UR_ACTION_BULK_MODIFY) && $this->oAttDef->AllowTargetCreation());
$sMessage = Dict::S('UI:Message:EmptyList:UseSearchForm');
$sHTMLValue = "<span style=\"white-space:nowrap\">"; // no wrap
if (count($this->aAllowedValues) < $this->oAttDef->GetMaximumComboLength())
{
// Few choices, use a normal 'select'
$sSelectMode = 'true';
$sHelpText = $this->oAttDef->GetHelpOnEdition();
// In case there are no valid values, the select will be empty, thus blocking the user from validating the form
$sHTMLValue = "<select title=\"$sHelpText\" name=\"attr_{$this->sFieldPrefix}{$this->sAttCode}{$this->sNameSuffix}\" id=\"$this->iId\">\n";
$sHTMLValue .= "<option value=\"\">".Dict::S('UI:SelectOne')."</option>\n";
foreach($this->aAllowedValues as $key => $display_value)
{
if ((count($this->aAllowedValues) == 1) && ($this->bMandatory == 'true') )
{
// When there is only once choice, select it by default
$sSelected = ' selected';
}
else
{
$sSelected = ($this->value == $key) ? ' selected' : '';
}
$sHTMLValue .= "<option value=\"$key\"$sSelected>$display_value</option>\n";
}
$sHTMLValue .= "</select>\n";
$oPage->add_ready_script(
<<<EOF
oACWidget_{$this->iId} = new ExtKeyWidget('{$this->iId}', '{$this->sClass}', '{$this->sAttCode}', '{$this->sNameSuffix}', $sSelectMode, oWizardHelper{$this->sFormPrefix});
oACWidget_{$this->iId}.emptyHtml = "<div style=\"background: #fff; border:0; text-align:center; vertical-align:middle;\"><p>$sMessage</p></div>";
EOF
);
}
else
{
// Too many choices, use an autocomplete
$sSelectMode = 'false';
if ($this->oAttDef->IsNull($this->value)) // Null values are displayed as ''
{
$sDisplayValue = '';
}
else
{
$sDisplayValue = $this->GetObjectName($this->value);
}
$sFormPrefix = $this->sFormPrefix;
$iMinChars = $this->oAttDef->GetMinAutoCompleteChars();
$iFieldSize = $this->oAttDef->GetMaxSize();
// the input for the auto-complete
$sHTMLValue = "<input count=\"".count($this->aAllowedValues)."\" type=\"text\" id=\"label_$this->iId\" size=\"30\" maxlength=\"$iFieldSize\" value=\"$sDisplayValue\"/>&nbsp;";
$sHTMLValue .= "<a class=\"no-arrow\" href=\"javascript:oACWidget_{$this->iId}.Search();\"><img style=\"border:0;vertical-align:middle;\" src=\"../images/mini_search.gif\" /></a>&nbsp;";
// another hidden input to store & pass the object's Id
$sHTMLValue .= "<input type=\"hidden\" id=\"$this->iId\" name=\"attr_{$this->sFieldPrefix}{$this->sAttCode}{$this->sNameSuffix}\" value=\"$this->value\" />\n";
// Scripts to start the autocomplete and bind some events to it
$oPage->add_ready_script(
<<<EOF
oACWidget_{$this->iId} = new ExtKeyWidget('{$this->iId}', '{$this->sClass}', '{$this->sAttCode}', '{$this->sNameSuffix}', $sSelectMode, oWizardHelper{$this->sFormPrefix});
oACWidget_{$this->iId}.emptyHtml = "<div style=\"background: #fff; border:0; text-align:center; vertical-align:middle;\"><p>$sMessage</p></div>";
$('#label_$this->iId').autocomplete('./ajax.render.php', { scroll:true, minChars:{$iMinChars}, formatItem:formatItem, autoFill:false, matchContains:true, keyHolder:'#{$this->iId}', extraParams:{operation:'autocomplete', sclass:'{$this->sClass}',attCode:'{$this->sAttCode}'}});
$('#label_$this->iId').blur(function() { $(this).search(); } );
$('#label_$this->iId').result( function(event, data, formatted) { OnAutoComplete('{$this->iId}', event, data, formatted); } );
$('#ac_dlg_$this->iId').dialog({ width: $(window).width()*0.8, height: $(window).height()*0.8, autoOpen: false, modal: true, title: '{$this->sTitle}', resizeStop: oACWidget_{$this->iId}.UpdateSizes, close: oACWidget_{$this->iId}.OnClose });
EOF
);
$oPage->add_at_the_end($this->GetSearchDialog($oPage)); // To prevent adding forms inside the main form
}
if ($bCreate)
{
$sHTMLValue .= "<a class=\"no-arrow\" href=\"javascript:oACWidget_{$this->iId}.CreateObject();\"><img style=\"border:0;vertical-align:middle;\" src=\"../images/mini_add.gif\" /></a>&nbsp;";
$oPage->add_at_the_end('<div id="ajax_'.$this->iId.'"></div>');
}
$sHTMLValue .= "<span id=\"v_{$this->iId}\"></span>";
$sHTMLValue .= "</span>"; // end of no wrap
return $sHTMLValue;
}
protected function GetSearchDialog(WebPage $oPage)
{
$sHTML = '<div id="ac_dlg_'.$this->iId.'"><div class="wizContainer" style="vertical-align:top;"><div id="dc_'.$this->iId.'">';
$oFilter = new DBObjectSearch($this->sTargetClass);
$oSet = new CMDBObjectSet($oFilter);
$oBlock = new DisplayBlock($oFilter, 'search', false);
$sHTML .= $oBlock->GetDisplay($oPage, $this->iId, array('open' => true, 'currentId' => $this->iId));
$sHTML .= "<form id=\"fr_{$this->iId}\" OnSubmit=\"return oACWidget_{$this->iId}.DoOk();\">\n";
$sHTML .= "<div id=\"dr_{$this->iId}\" style=\"vertical-align:top;background: #fff;height:100%;overflow:auto;padding:0;border:0;\">\n";
$sHTML .= "<div style=\"background: #fff; border:0; text-align:center; vertical-align:middle;\"><p>".Dict::S('UI:Message:EmptyList:UseSearchForm')."</p></div>\n";
$sHTML .= "</div>\n";
$sHTML .= "<input type=\"button\" id=\"btn_cancel_{$this->iId}\" value=\"".Dict::S('UI:Button:Cancel')."\" onClick=\"$('#ac_dlg_{$this->iId}').dialog('close');\">&nbsp;&nbsp;";
$sHTML .= "<input type=\"button\" id=\"btn_ok_{$this->iId}\" value=\"".Dict::S('UI:Button:Ok')."\" onClick=\"oACWidget_{$this->iId}.DoOk();\">";
$sHTML .= "</form>\n";
$sHTML .= '</div></div></div>';
$oPage->add_ready_script("$('#fs_{$this->iId}').bind('submit.uiAutocomplete', oACWidget_{$this->iId}.DoSearchObjects);");
$oPage->add_ready_script("$('#dc_{$this->iId}').resize(oACWidget_{$this->iId}.UpdateSizes);");
return $sHTML;
}
/**
* Search for objects to be selected
* @param WebPage $oP The page used for the output (usually an AjaxWebPage)
* @param string $sRemoteClass Name of the "remote" class to perform the search on, must be a derived class of m_sRemoteClass
* @param Array $aAlreadyLinkedIds List of IDs of objects of "remote" class already linked, to be filtered out of the search
*/
public function SearchObjectsToSelect(WebPage $oP, $sTargetClass = '')
{
if ($sTargetClass != '')
{
// assert(MetaModel::IsParentClass($this->m_sRemoteClass, $sRemoteClass));
$oFilter = new DBObjectSearch($sTargetClass);
}
else
{
// No remote class specified use the one defined in the linkedset
$oFilter = new DBObjectSearch($this->sTargetClass);
}
$oFilter->AddCondition('id', array_keys($this->aAllowedValues), 'IN');
$oSet = new CMDBObjectSet($oFilter);
$oBlock = new DisplayBlock($oFilter, 'list', false);
$oBlock->Display($oP, $this->iId, array('menu' => false, 'selection_mode' => true, 'selection_type' => 'single', 'display_limit' => false)); // Don't display the 'Actions' menu on the results
}
/**
* Get the display name of the selected object, to fill back the autocomplete
*/
public function GetObjectName($iObjId)
{
$oObj = MetaModel::GetObject($this->sTargetClass, $iObjId);
return $oObj->GetName();
}
/**
* Get the form to create a new object of the 'target' class
*/
public function GetObjectCreationForm(WebPage $oPage)
{
$oPage->add('<div id="ac_create_'.$this->iId.'"><div class="wizContainer" style="vertical-align:top;"><div id="dcr_'.$this->iId.'">');
$oPage->add("<h1>".MetaModel::GetClassIcon($this->sTargetClass)."&nbsp;".Dict::Format('UI:CreationTitle_Class', MetaModel::GetName($this->sTargetClass))."</h1>\n");
cmdbAbstractObject::DisplayCreationForm($oPage, $this->sTargetClass, null, array(), array('formPrefix' => $this->iId, 'noRelations' => true));
$oPage->add('</div></div></div>');
$oPage->add_ready_script("\$('#ac_create_$this->iId').dialog({ width: $(window).width()*0.8, height: 'auto', autoOpen: false, modal: true, title: '$this->sTitle'});\n");
$oPage->add_ready_script("$('#dcr_{$this->iId} form').removeAttr('onsubmit');");
$oPage->add_ready_script("$('#dcr_{$this->iId} form').bind('submit.uilinksWizard', oACWidget_{$this->iId}.DoCreateObject);");
}
/**
* Get the form to create a new object of the 'target' class
*/
public function DoCreateObject($oPage)
{
$oObj = MetaModel::NewObject($this->sTargetClass);
$oObj->UpdateObject($this->sFormPrefix.$this->iId);
$oMyChange = MetaModel::NewObject("CMDBChange");
$oMyChange->Set("date", time());
$sUserString = CMDBChange::GetCurrentUserName();
$oMyChange->Set("userinfo", $sUserString);
$iChangeId = $oMyChange->DBInsert();
$oObj->DBInsertTracked($oMyChange);
return array('name' => $oObj->GetName(), 'id' => $oObj->GetKey());
//return array('name' => 'test', 'id' => '42');
}
}
?>

View File

@@ -0,0 +1,86 @@
<?php
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* Class UIHTMLEditorWidget
* UI wdiget for displaying and editing one-way encrypted passwords
*
* @author Phil Eddies
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
class UIHTMLEditorWidget
{
protected $m_iId;
protected $m_sAttCode;
protected $m_sNameSuffix;
protected $m_sFieldPrefix;
protected $m_sHelpText;
protected $m_sValidationField;
protected $m_sValue;
protected $m_sMandatory;
public function __construct($iInputId, $sAttCode, $sNameSuffix, $sFieldPrefix, $sHelpText, $sValidationField, $sValue, $sMandatory)
{
$this->m_iId = $iInputId;
$this->m_sAttCode = $sAttCode;
$this->m_sNameSuffix = $sNameSuffix;
$this->m_sHelpText = $sHelpText;
$this->m_sValidationField = $sValidationField;
$this->m_sValue = $sValue;
$this->m_sMandatory = $sMandatory;
$this->m_sFieldPrefix = $sFieldPrefix;
}
/**
* Get the HTML fragment corresponding to the HTML editor widget
* @param WebPage $oP The web page used for all the output
* @param Hash $aArgs Extra context arguments
* @return string The HTML fragment to be inserted into the page
*/
public function Display(WebPage $oPage, $aArgs = array())
{
$iId = $this->m_iId;
$sCode = $this->m_sAttCode.$this->m_sNameSuffix;
$sValue = $this->m_sValue;
$sHelpText = $this->m_sHelpText;
$sValidationField = $this->m_sValidationField;
$sHtmlValue = "<table><tr><td><textarea class=\"htmlEditor\" title=\"$sHelpText\" name=\"attr_{$this->m_sFieldPrefix}{$sCode}\" rows=\"14\" cols=\"110\" id=\"$iId\">$sValue</textarea></td><td>$sValidationField</td></tr></table>";
// Replace the text area with CKEditor
// To change the default settings of the editor,
// a) edit the file /js/ckeditor/config.js
// b) or override some of the configuration settings, using the second parameter of ckeditor()
$sLanguage = strtolower(trim(UserRights::GetUserLanguage()));
$oPage->add_ready_script("$('#$iId').ckeditor(function() { /* callback code */ }, { language : '$sLanguage' , contentsLanguage : '$sLanguage' });"); // Transform $iId into a CKEdit
// Please read...
// ValidateCKEditField triggers a timer... calling itself indefinitely
// This design was the quickest way to achieve the field validation (only checking if the field is blank)
// because the ckeditor does not fire events like "change" or "keyup", etc.
// See http://dev.ckeditor.com/ticket/900 => won't fix
// The most relevant solution would be to implement a plugin to CKEdit, and handle the internal events like: setData, insertHtml, insertElement, loadSnapshot, key, afterUndo, afterRedo
// Could also be bound to 'instanceReady.ckeditor'
$oPage->add_ready_script("$('#$iId').bind('validate', function(evt, sFormId) { return ValidateCKEditField('$iId', '', {$this->m_sMandatory}, sFormId, '') } );");
return $sHtmlValue;
}
}
?>

View File

@@ -1,6 +1,30 @@
<?php
require_once('../application/webpage.class.inc.php');
require_once('../application/displayblock.class.inc.php');
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* Class UILinksWidget
*
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
require_once(APPROOT.'/application/webpage.class.inc.php');
require_once(APPROOT.'/application/displayblock.class.inc.php');
class UILinksWidget
{
@@ -8,129 +32,223 @@ class UILinksWidget
protected $m_sAttCode;
protected $m_sNameSuffix;
protected $m_iInputId;
protected $m_aAttributes;
protected $m_sExtKeyToRemote;
protected $m_sLinkedClass;
protected $m_sRemoteClass;
protected $m_bDuplicatesAllowed;
public function __construct($sClass, $sAttCode, $iInputId, $sNameSuffix = '')
public function __construct($sClass, $sAttCode, $iInputId, $sNameSuffix = '', $bDuplicatesAllowed = false)
{
$this->m_sClass = $sClass;
$this->m_sAttCode = $sAttCode;
$this->m_sNameSuffix = $sNameSuffix;
$this->m_iInputId = $iInputId;
}
public function Display(WebPage $oPage, $oCurrentValuesSet = null)
{
$sHTMLValue = '';
$sTargetClass = self::GetTargetClass($this->m_sClass, $this->m_sAttCode);
// #@# todo - add context information, otherwise any value will be authorized for external keys
$aAllowedValues = MetaModel::GetAllowedValues_att($this->m_sClass, $this->m_sAttCode, array(), '');
$this->m_bDuplicatesAllowed = $bDuplicatesAllowed;
$this->m_aEditableFields = array();
$oAttDef = MetaModel::GetAttributeDef($this->m_sClass, $this->m_sAttCode);
$sExtKeyToRemote = $oAttDef->GetExtKeyToRemote();
$this->m_sLinkedClass = $oAttDef->GetLinkedClass();
$this->m_sExtKeyToRemote = $oAttDef->GetExtKeyToRemote();
$oLinkingAttDef = MetaModel::GetAttributeDef($this->m_sLinkedClass, $this->m_sExtKeyToRemote);
$this->m_sRemoteClass = $oLinkingAttDef->GetTargetClass();
$sExtKeyToMe = $oAttDef->GetExtKeyToMe();
$sStateAttCode = MetaModel::GetStateAttributeCode($this->m_sClass);
$sDefaultState = MetaModel::GetDefaultState($this->m_sClass);
$sDefaultState = MetaModel::GetDefaultState($this->m_sClass);
$aAttributes = array();
$sLinkedClass = $oAttDef->GetLinkedClass();
foreach(MetaModel::ListAttributeDefs($sLinkedClass) as $sAttCode=>$oAttDef)
$this->m_aEditableFields = array();
$this->m_aTableConfig = array();
$this->m_aTableConfig['form::checkbox'] = array( 'label' => "<input class=\"select_all\" type=\"checkbox\" value=\"1\" onClick=\"CheckAll('#linkedset_{$this->m_sAttCode}{$this->m_sNameSuffix} .selection', this.checked); oWidget".$this->m_iInputId.".OnSelectChange();\">", 'description' => Dict::S('UI:SelectAllToggle+'));
foreach(MetaModel::ListAttributeDefs($this->m_sLinkedClass) as $sAttCode=>$oAttDef)
{
if ($sStateAttCode == $sAttCode)
{
// State attribute is always hidden from the UI
}
else if (!$oAttDef->IsExternalField() && ($sAttCode != $sExtKeyToMe) && ($sAttCode != $sExtKeyToRemote))
else if (!$oAttDef->IsExternalField() && ($sAttCode != $sExtKeyToMe) && ($sAttCode != $this->m_sExtKeyToRemote) && ($sAttCode != 'finalclass'))
{
$iFlags = MetaModel::GetAttributeFlags($this->m_sClass, $sDefaultState, $sAttCode);
$iFlags = MetaModel::GetAttributeFlags($this->m_sLinkedClass, $sDefaultState, $sAttCode);
if ( !($iFlags & OPT_ATT_HIDDEN) && !($iFlags & OPT_ATT_READONLY) )
{
$aAttributes[] = $sAttCode;
$this->m_aEditableFields[] = $sAttCode;
$this->m_aTableConfig[$sAttCode] = array( 'label' => $oAttDef->GetLabel(), 'description' => $oAttDef->GetDescription());
}
}
}
$sAttributes = "['".implode("','", $aAttributes)."']";
if ($oCurrentValuesSet != null)
$this->m_aTableConfig['static::key'] = array( 'label' => MetaModel::GetName($this->m_sRemoteClass), 'description' => MetaModel::GetClassDescription($this->m_sRemoteClass));
foreach(MetaModel::GetZListItems($this->m_sRemoteClass, 'list') as $sFieldCode)
{
// Serialize the link set into a JSon object
$aCurrentValues = array();
while($oLinkObj = $oCurrentValuesSet->Fetch())
// TO DO: check the state of the attribute: hidden or visible ?
if ($sFieldCode != 'finalclass')
{
$sRow = '{';
foreach($aAttributes as $sLinkAttCode)
{
$sRow.= "\"$sLinkAttCode\": \"".addslashes($oLinkObj->Get($sLinkAttCode))."\", ";
}
$sRow .= "\"$sExtKeyToRemote\": ".$oLinkObj->Get($sExtKeyToRemote).'}';
$aCurrentValues[] = $sRow;
$oAttDef = MetaModel::GetAttributeDef($this->m_sRemoteClass, $sFieldCode);
$this->m_aTableConfig['static::'.$sFieldCode] = array( 'label' => $oAttDef->GetLabel(), 'description' => $oAttDef->GetDescription());
}
$sJSON = '['.implode(',', $aCurrentValues).']';
}
else
{
//echo "JSON VA IECH<br/>\n";
}
//echo "JASON: $sJSON<br/>\n";;
// Many values (or even a unknown list) display an autocomplete
if ( (count($aAllowedValues) == 0) || (count($aAllowedValues) > 50) )
{
// too many choices, use an autocomplete
// The input for the auto complete
$sTitle = $oAttDef->GetDescription();
$sHTMLValue .= "<script type=\"text/javascript\">\n";
$sHTMLValue .= "oLinkWidget{$this->m_iInputId} = new LinksWidget('{$this->m_iInputId}', '$sLinkedClass', '$sExtKeyToMe', '$sExtKeyToRemote', $sAttributes);\n";
$sHTMLValue .= "</script>\n";
$oPage->add_at_the_end($this->GetObjectPickerDialog($oPage, $sTargetClass, 'oLinkWidget'.$this->m_iInputId.'.OnOk')); // Forms should not be inside forms
$oPage->add_at_the_end($this->GetLinkObjectDialog($oPage, $this->m_iInputId)); // Forms should not be inside forms
$sHTMLValue .= "<input type=\"text\" id=\"ac_{$this->m_iInputId}\" size=\"35\" value=\"\" title=\"Type the first 3 characters\"/>";
$sHTMLValue .= "<input type=\"button\" id=\"ac_add_{$this->m_iInputId}\" value=\" Add... \" class=\"action\" onClick=\"oLinkWidget{$this->m_iInputId}.AddObject();\"/>";
$sHTMLValue .= "&nbsp;<input type=\"button\" value=\"Browse...\" class=\"action\" onClick=\"return ManageObjects('$sTitle', '$sTargetClass', '$this->m_iInputId', '$sExtKeyToRemote');\"/>";
// another hidden input to store & pass the object's Id
$sHTMLValue .= "<input type=\"hidden\" id=\"id_ac_{$this->m_iInputId}\" onChange=\"EnableAddButton('{$this->m_iInputId}');\"/>\n";
$sHTMLValue .= "<input type=\"hidden\" id=\"{$this->m_iInputId}\" name=\"attr_{$this->m_sAttCode}{$this->m_sNameSuffix}\" value=\"\"/>\n";
$oPage->add_ready_script("\$('#{$this->m_iInputId}').val('$sJSON');\noLinkWidget{$this->m_iInputId}.Init();\n\$('#ac_{$this->m_iInputId}').autocomplete('./ajax.render.php', { scroll:true, minChars:3, onItemSelect:selectItem, onFindValue:findValue, formatItem:formatItem, autoFill:true, keyHolder:'#id_ac_{$this->m_iInputId}', extraParams:{operation:'ui.linkswidget', sclass:'{$this->m_sClass}', attCode:'{$this->m_sAttCode}', max:30}});");
$oPage->add_ready_script("\$('#ac_add_{$this->m_iInputId}').attr('disabled', 'disabled');");
$oPage->add_ready_script("\$('#ac_{$this->m_iInputId}').result( function(event, data, formatted) { if (data) { $('#id_ac_{$this->m_iInputId}').val(data[1]); $('#ac_add_{$this->m_iInputId}').attr('disabled', ''); } else { $('#ac_add_{$this->m_iInputId}').attr('disabled', 'disabled'); } } );");
}
else
{
// Few choices, use a normal 'select'
$sHTMLValue = "<select name=\"attr_{$this->m_sAttCode}\" id=\"{$this->m_iInputId}\">\n";
$sHTMLValue .= "<option value=\"0\">--- select a value ---</option>\n";
if (count($aAllowedValues) > 0)
{
foreach($aAllowedValues as $key => $value)
{
$sHTMLValue .= "<option value=\"$key\"$sSelected>$value</option>\n";
}
}
$sHTMLValue .= "</select>\n";
}
$sHTMLValue .= "<div id=\"{$this->m_iInputId}_values\">\n";
if ($oCurrentValuesSet != null)
{
// transform the DBObjectSet into a CMDBObjectSet !!!
$aLinkedObjects = $oCurrentValuesSet->ToArray(false);
// Actual values will be displayed asynchronously, no need to display them here
//if (count($aLinkedObjects) > 0)
//{
// $oSet = CMDBObjectSet::FromArray($sLinkedClass, $aLinkedObjects);
// $oDisplayBlock = DisplayBlock::FromObjectSet($oSet, 'list');
// $sHTMLValue .= $oDisplayBlock->GetDisplay($oPage, $this->m_iInputId.'_current', array('linkage' => $sExtKeyToMe, 'menu' => false));
//}
}
$sHTMLValue .= "</div>\n";
return $sHTMLValue;
}
/**
* A one-row form for editing a link record
* @param WebPage $oP Web page used for the ouput
* @param DBObject $oLinkedObj The object to which all the elements of the linked set refer to
* @param mixed $linkObjOrId Either the object linked or a unique number for new link records to add
* @param Hash $aArgs Extra context arguments
* @return string The HTML fragment of the one-row form
*/
protected function GetFormRow(WebPage $oP, DBObject $oLinkedObj, $linkObjOrId = null, $aArgs = array() )
{
$sPrefix = "$this->m_sAttCode{$this->m_sNameSuffix}";
$aRow = array();
if(is_object($linkObjOrId))
{
$key = $linkObjOrId->GetKey();
$sPrefix .= "[$key][";
$sNameSuffix = "]"; // To make a tabular form
$aArgs['prefix'] = $sPrefix;
$aRow['form::checkbox'] = "<input class=\"selection\" type=\"checkbox\" onClick=\"oWidget".$this->m_iInputId.".OnSelectChange();\" value=\"$key\">";
$aRow['form::checkbox'] .= "<input type=\"hidden\" name=\"attr_{$sPrefix}id{$sNameSuffix}\" value=\"$key\">";
foreach($this->m_aEditableFields as $sFieldCode)
{
$sFieldId = $this->m_iInputId.'_'.$sFieldCode.'['.$linkObjOrId->GetKey().']';
$sSafeId = str_replace(array('[',']','-'), '_', $sFieldId);
$oAttDef = MetaModel::GetAttributeDef($this->m_sLinkedClass, $sFieldCode);
$aRow[$sFieldCode] = cmdbAbstractObject::GetFormElementForField($oP, $this->m_sLinkedClass, $sFieldCode, $oAttDef, $linkObjOrId->Get($sFieldCode), '' /* DisplayValue */, $sSafeId, $sNameSuffix, 0, $aArgs);
}
}
else
{
// form for creating a new record
$sPrefix .= "[$linkObjOrId][";
$sNameSuffix = "]"; // To make a tabular form
$aArgs['prefix'] = $sPrefix;
$aRow['form::checkbox'] = "<input class=\"selection\" type=\"checkbox\" onClick=\"oWidget".$this->m_iInputId.".OnSelectChange();\" value=\"$linkObjOrId\">";
$aRow['form::checkbox'] .= "<input type=\"hidden\" name=\"attr_{$sPrefix}id{$sNameSuffix}\" value=\"\">";
foreach($this->m_aEditableFields as $sFieldCode)
{
$sFieldId = $this->m_iInputId.'_'.$sFieldCode.'['.$linkObjOrId.']';
$sSafeId = str_replace(array('[',']','-'), '_', $sFieldId);
$oAttDef = MetaModel::GetAttributeDef($this->m_sLinkedClass, $sFieldCode);
$aRow[$sFieldCode] = cmdbAbstractObject::GetFormElementForField($oP, $this->m_sLinkedClass, $sFieldCode, $oAttDef, '' /* TO DO/ call GetDefaultValue($oObject->ToArgs()) */, '' /* DisplayValue */, $sSafeId /* id */, $sNameSuffix, 0, $aArgs);
}
}
$aRow['static::key'] = $oLinkedObj->GetHyperLink();
foreach(MetaModel::GetZListItems($this->m_sRemoteClass, 'list') as $sFieldCode)
{
$aRow['static::'.$sFieldCode] = $oLinkedObj->GetAsHTML($sFieldCode);
}
return $aRow;
}
/**
* Display one row of the whole form
* @return none
*/
protected function DisplayFormRow(WebPage $oP, $aConfig, $aRow, $iRowId)
{
$sHtml = '';
$sHtml .= "<tr id=\"{$this->m_sAttCode}{$this->m_sNameSuffix}_row_$iRowId\">\n";
foreach($aConfig as $sName=>$void)
{
$sHtml .= "<td>".$aRow[$sName]."</td>\n";
}
$sHtml .= "</tr>\n";
return $sHtml;
}
/**
* Display the table with the form for editing all the links at once
* @param WebPage $oP The web page used for the output
* @param Hash $aConfig The table's header configuration
* @param Hash $aData The tabular data to be displayed
* @return string Html fragment representing the form table
*/
protected function DisplayFormTable(WebPage $oP, $aConfig, $aData)
{
$sHtml = '';
$sHtml .= "<table class=\"listResults\">\n";
// Header
$sHtml .= "<thead>\n";
$sHtml .= "<tr>\n";
foreach($aConfig as $sName=>$aDef)
{
$sHtml .= "<th title=\"".$aDef['description']."\">".$aDef['label']."</th>\n";
}
$sHtml .= "</tr>\n";
$sHtml .= "</thead>\n";
// Content
$sHtml .= "</tbody>\n";
if (count($aData) == 0)
{
$sHtml .= "<tr id=\"{$this->m_sAttCode}{$this->m_sNameSuffix}_empty_row\"><td colspan=\"".count($aConfig)."\" style=\"text-align:center;\">".Dict::S('UI:Message:EmptyList:UseAdd')."<input type=\"hidden\" name=\"attr_{$this->m_sAttCode}{$this->m_sNameSuffix}\" value=\"\"></td></td>";
}
else
{
foreach($aData as $iRowId => $aRow)
{
$sHtml .= $this->DisplayFormRow($oP, $aConfig, $aRow, $iRowId);
}
}
$sHtml .= "</tbody>\n";
// Footer
$sHtml .= "</table>\n";
return $sHtml;
}
/**
* Get the HTML fragment corresponding to the linkset editing widget
* @param WebPage $oP The web page used for all the output
* @param DBObjectSet The initial value of the linked set
* @param Hash $aArgs Extra context arguments
* @return string The HTML fragment to be inserted into the page
*/
public function Display(WebPage $oPage, DBObjectSet $oValue, $aArgs = array())
{
$sHtmlValue = '';
$sTargetClass = self::GetTargetClass($this->m_sClass, $this->m_sAttCode);
$sHtmlValue .= "<div id=\"linkedset_{$this->m_sAttCode}{$this->m_sNameSuffix}\">\n";
$oValue->Rewind();
$aForm = array();
while($oCurrentLink = $oValue->Fetch())
{
$aRow = array();
$key = $oCurrentLink->GetKey();
$oLinkedObj = MetaModel::GetObject($this->m_sRemoteClass, $oCurrentLink->Get($this->m_sExtKeyToRemote));
$aForm[$key] = $this->GetFormRow($oPage, $oLinkedObj, $oCurrentLink, $aArgs);
}
$sHtmlValue .= $this->DisplayFormTable($oPage, $this->m_aTableConfig, $aForm);
$sDuplicates = ($this->m_bDuplicatesAllowed) ? 'true' : 'false';
$oPage->add_ready_script(<<<EOF
oWidget{$this->m_iInputId} = new LinksWidget('{$this->m_sAttCode}{$this->m_sNameSuffix}', '{$this->m_sClass}', '{$this->m_sAttCode}', '{$this->m_iInputId}', '{$this->m_sNameSuffix}', $sDuplicates);
oWidget{$this->m_iInputId}.Init();
EOF
);
$sHtmlValue .= "<span style=\"float:left;\">&nbsp;&nbsp;&nbsp;<img src=\"../images/tv-item-last.gif\">&nbsp;&nbsp;<input id=\"{$this->m_sAttCode}{$this->m_sNameSuffix}_btnRemove\" type=\"button\" value=\"".Dict::S('UI:RemoveLinkedObjectsOf_Class')."\" onClick=\"oWidget{$this->m_iInputId}.RemoveSelected();\" >";
$sHtmlValue .= "&nbsp;&nbsp;&nbsp;<input id=\"{$this->m_sAttCode}{$this->m_sNameSuffix}_btnAdd\" type=\"button\" value=\"".Dict::Format('UI:AddLinkedObjectsOf_Class', MetaModel::GetName($this->m_sRemoteClass))."\" onClick=\"oWidget{$this->m_iInputId}.AddObjects();\"></span>\n";
$sHtmlValue .= "<span style=\"clear:both;\"><p>&nbsp;</p></span>\n";
$sHtmlValue .= "</div>\n";
$oPage->add_at_the_end($this->GetObjectPickerDialog($oPage)); // To prevent adding forms inside the main form
return $sHtmlValue;
}
/**
* This static function is called by the Ajax Page when there is a need to fill an autocomplete combo
* @param $oPage WebPage The ajax page used for the put^put (sent back to the browser
* @param $oContext UserContext The context of the user (for limiting the search)
* @param $oPage WebPage The ajax page used for the output (sent back to the browser)
* @param $sClass string The name of the class of the current object being edited
* @param $sAttCode string The name of the attribute being edited
* @param $sName string The partial name that was typed by the user
* @param $iMaxCount integer The maximum number of items to return
* @return void
*/
static public function Autocomplete(WebPage $oPage, UserContext $oContext, $sClass, $sAttCode, $sName, $iMaxCount)
static public function Autocomplete(WebPage $oPage, $sClass, $sAttCode, $sName, $iMaxCount)
{
// #@# todo - add context information, otherwise any value will be authorized for external keys
$aAllowedValues = MetaModel::GetAllowedValues_att($sClass, $sAttCode, array() /* $aArgs */, $sName);
@@ -150,7 +268,7 @@ class UILinksWidget
$oAttDef = $oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
$sLinkedClass = $oAttDef->GetLinkedClass();
$sSearchClass = self::GetTargetClass($sClass, $sAttCode);
$oFilter = $oContext->NewFilter($sSearchClass);
$oFilter = new DBObjectSearch($sSearchClass);
$sSearchAttCode = MetaModel::GetNameAttributeCode($sSearchClass);
$oFilter->AddCondition($sSearchAttCode, $sName, 'Begins with');
$oSet = new CMDBObjectSet($oFilter, array($sSearchAttCode => true));
@@ -183,7 +301,7 @@ class UILinksWidget
foreach($aObject as $sAttCode => $value)
{
$oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
if ($oAttDef->IsExternalKey())
if ($oAttDef->IsExternalKey() && ($value != 0))
{
$oTargetObj = MetaModel::GetObject($oAttDef->GetTargetClass(), $value); // @@ optimization, don't do & query per object in the set !
$oObj->Set($sAttCode, $oTargetObj);
@@ -202,6 +320,7 @@ class UILinksWidget
$aExtraParams['target_attr'] = $sExtKeyToRemote;
$aExtraParams['menu'] = false;
$aExtraParams['select'] = false;
$aExtraParams['view_link'] = false;
cmdbAbstractObject::DisplaySet($oPage, $oSet, $aExtraParams);
}
@@ -226,105 +345,99 @@ class UILinksWidget
return $sTargetClass;
}
protected function GetObjectPickerDialog($oPage, $sTargetClass, $sOkFunction)
protected function GetObjectPickerDialog($oPage)
{
$sHTML = <<< EOF
<div class="jqmWindow" id="ManageObjectsDlg_{$this->m_iInputId}">
<div class="wizContainer">
<div class="page_header"><h1 id="Manage_DlgTitle_{$this->m_iInputId}">Selected Objects</h1></div>
<table width="100%">
<tr>
<td>
<p>Selected objects:</p>
<button type="button" class="action" onClick="FilterLeft('$sTargetClass');"><span> Filter... </span></button>
<p><select id="selected_objects_{$this->m_iInputId}" size="10" multiple onChange="Manage_UpdateButtons('$this->m_iInputId')" style="width:300px;">
</select></p>
</td>
<td style="text-align:center; valign:middle;">
<p><button type="button" id="btn_add_objects_{$this->m_iInputId}" onClick="Manage_AddObjects('$this->m_iInputId');"> &lt;&lt; Add </button></p>
<p><button type="button" id="btn_remove_objects_{$this->m_iInputId}" onClick="Manage_RemoveObjects('$this->m_iInputId');"> Remove &gt;&gt; </button></p>
</td>
<td>
<p>Available objects:</p>
<button type="button" class="action" onClick="FilterRight('$sTargetClass');"><span> Filter... </span></button>
<p><select id="available_objects_{$this->m_iInputId}" size="10" multiple onChange="Manage_UpdateButtons('$this->m_iInputId')" style="width:300px;">
</select></p>
</td>
</tr>
<tr>
<td colspan="3">
<input type="submit" class="jqmClose" onClick="$('#ManageObjectsDlg_{$this->m_iInputId}').jqmHide(); $sOkFunction('$sTargetClass', 'selected_objects')" value=" Ok " />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<button type="button" class="jqmClose"> Cancel</button>
</td>
</tr>
</table>
</div>
</div>
EOF;
$oPage->add_ready_script("$('#ManageObjectsDlg_$this->m_iInputId').jqm({overlay:70, modal:true, toTop:true});"); // jqModal Window
//$oPage->add_ready_script("UpdateObjectList('$sClass');");
return $sHTML;
$sHtml = "<div id=\"dlg_{$this->m_sAttCode}{$this->m_sNameSuffix}\">";
$sHtml .= "<div class=\"wizContainer\" style=\"vertical-align:top;\">\n";
$oFilter = new DBObjectSearch($this->m_sRemoteClass);
$oSet = new CMDBObjectSet($oFilter);
$oBlock = new DisplayBlock($oFilter, 'search', false);
$sHtml .= $oBlock->GetDisplay($oPage, "SearchFormToAdd_{$this->m_sAttCode}{$this->m_sNameSuffix}", array('open' => true));
$sHtml .= "<form id=\"ObjectsAddForm_{$this->m_sAttCode}{$this->m_sNameSuffix}\" OnSubmit=\"return oWidget{$this->m_iInputId}.DoAddObjects(this.id);\">\n";
$sHtml .= "<div id=\"SearchResultsToAdd_{$this->m_sAttCode}{$this->m_sNameSuffix}\" style=\"vertical-align:top;background: #fff;height:100%;overflow:auto;padding:0;border:0;\">\n";
$sHtml .= "<div style=\"background: #fff; border:0; text-align:center; vertical-align:middle;\"><p>".Dict::S('UI:Message:EmptyList:UseSearchForm')."</p></div>\n";
$sHtml .= "</div>\n";
$sHtml .= "<input type=\"button\" value=\"".Dict::S('UI:Button:Cancel')."\" onClick=\"$('#dlg_{$this->m_sAttCode}{$this->m_sNameSuffix}').dialog('close');\">&nbsp;&nbsp;<input type=\"submit\" value=\"".Dict::S('UI:Button:Add')."\">";
$sHtml .= "</div>\n";
$sHtml .= "</form>\n";
$sHtml .= "</div>\n";
$oPage->add_ready_script("$('#dlg_{$this->m_sAttCode}{$this->m_sNameSuffix}').dialog({ width: $(window).width()*0.8, height: $(window).height()*0.8, autoOpen: false, modal: true, resizeStop: oWidget{$this->m_iInputId}.UpdateSizes });");
$oPage->add_ready_script("$('#dlg_{$this->m_sAttCode}{$this->m_sNameSuffix}').dialog('option', {title:'".addslashes(Dict::Format('UI:AddObjectsOf_Class_LinkedWith_Class', MetaModel::GetName($this->m_sLinkedClass), MetaModel::GetName($this->m_sClass)))."'});");
$oPage->add_ready_script("$('#SearchFormToAdd_{$this->m_sAttCode}{$this->m_sNameSuffix} form').bind('submit.uilinksWizard', oWidget{$this->m_iInputId}.SearchObjectsToAdd);");
$oPage->add_ready_script("$('#SearchFormToAdd_{$this->m_sAttCode}{$this->m_sNameSuffix}').resize(oWidget{$this->m_iInputId}.UpdateSizes);");
return $sHtml;
}
protected function GetLinkObjectDialog($oPage, $sId)
/**
* Search for objects to be linked to the current object (i.e "remote" objects)
* @param WebPage $oP The page used for the output (usually an AjaxWebPage)
* @param string $sRemoteClass Name of the "remote" class to perform the search on, must be a derived class of m_sRemoteClass
* @param Array $aAlreadyLinkedIds List of IDs of objects of "remote" class already linked, to be filtered out of the search
*/
public function SearchObjectsToAdd(WebPage $oP, $sRemoteClass = '', $aAlreadyLinkedIds = array())
{
$oAttDef = MetaModel::GetAttributeDef($this->m_sClass, $this->m_sAttCode);
$sLinkedClass = $oAttDef->GetLinkedClass();
$sStateAttCode = MetaModel::GetStateAttributeCode($sLinkedClass);
$sDefaultState = MetaModel::GetDefaultState($sLinkedClass);
$oAttDef = MetaModel::GetAttributeDef($this->m_sClass, $this->m_sAttCode);
$sExtKeyToMe = $oAttDef->GetExtKeyToMe();
$sExtKeyToRemote = $oAttDef->GetExtKeyToRemote();
$sHTML = "<div class=\"jqmWindow\" id=\"LinkDlg_$sId\">\n";
$sHTML .= "<div class=\"wizContainer\">\n";
$sHTML .= "<div class=\"page_header\"><h1>".MetaModel::GetName($sLinkedClass)." attributes</h1></div>\n";
$sHTML .= "<form action=\"./UI.php\" onSubmit=\"return oLinkWidget$sId.OnLinkOk();\">\n";
$index = 0;
$aAttrsMap = array();
$aDetails = array();
foreach(MetaModel::ListAttributeDefs($sLinkedClass) as $sAttCode=>$oAttDef)
if ($sRemoteClass != '')
{
if ($sStateAttCode == $sAttCode)
// assert(MetaModel::IsParentClass($this->m_sRemoteClass, $sRemoteClass));
$oFilter = new DBObjectSearch($sRemoteClass);
}
else
{
// No remote class specified use the one defined in the linkedset
$oFilter = new DBObjectSearch($this->m_sRemoteClass);
}
if (!$this->m_bDuplicatesAllowed && count($aAlreadyLinkedIds) > 0)
{
// Positive IDs correspond to existing link records
// negative IDs correspond to "remote" objects to be linked
$aLinkIds = array();
$aRemoteObjIds = array();
foreach($aAlreadyLinkedIds as $iId)
{
// State attribute is always hidden from the UI
//$sHTMLValue = $this->GetState();
//$aDetails[] = array('label' => $oAttDef->GetLabel(), 'value' => $sHTMLValue);
}
else if (!$oAttDef->IsExternalField() && ($sAttCode != $sExtKeyToMe) && ($sAttCode != $sExtKeyToRemote))
{
$iFlags = MetaModel::GetAttributeFlags($sLinkedClass, $sDefaultState, $sAttCode);
if ($iFlags & OPT_ATT_HIDDEN)
if ($iId > 0)
{
// Attribute is hidden, do nothing
$aLinkIds[] = $iId;
}
else
{
if ($iFlags & OPT_ATT_READONLY)
{
// Attribute is read-only
$sHTMLValue = $this->GetAsHTML($sAttCode);
}
else
{
$sValue = ""; //$this->Get($sAttCode);
$sDisplayValue = ""; //$this->GetDisplayValue($sAttCode);
$sSubId = $sId.'_'.$index;
$aAttrsMap[$sAttCode] = $sSubId;
$index++;
$sHTMLValue = cmdbAbstractObject::GetFormElementForField($oPage, $sLinkedClass, $sAttCode, $oAttDef, $sValue, $sDisplayValue, $sSubId, $this->m_sAttCode);
}
$aDetails[] = array('label' => $oAttDef->GetLabel(), 'value' => $sHTMLValue);
$aRemoteObjIds[] = -$iId;
}
}
if (count($aLinkIds) >0)
{
// Search for the links to find to which "remote" object they are linked
$oLinkFilter = new DBObjectSearch($this->m_sLinkedClass);
$oLinkFilter->AddCondition('id', $aLinkIds, 'IN');
$oLinkSet = new CMDBObjectSet($oLinkFilter);
while($oLink = $oLinkSet->Fetch())
{
$aRemoteObjIds[] = $oLink->Get($this->m_sExtKeyToRemote);
}
}
$oFilter->AddCondition('id', $aRemoteObjIds, 'NOTIN');
}
$oSet = new CMDBObjectSet($oFilter);
$oBlock = new DisplayBlock($oFilter, 'list', false);
$oBlock->Display($oP, 'ResultsToAdd', array('menu' => false, 'selection_mode' => true, 'display_limit' => false)); // Don't display the 'Actions' menu on the results
}
public function DoAddObjects(WebPage $oP, $aLinkedObjectIds = array())
{
$aTable = array();
foreach($aLinkedObjectIds as $iObjectId)
{
$oLinkedObj = MetaModel::GetObject($this->m_sRemoteClass, $iObjectId);
if (is_object($oLinkedObj))
{
$aRow = $this->GetFormRow($oP, $oLinkedObj, -$iObjectId ); // Not yet created link get negative Ids
$oP->add($this->DisplayFormRow($oP, $this->m_aTableConfig, $aRow, -$iObjectId));
}
else
{
$oP->p(Dict::Format('UI:Error:Object_Class_Id_NotFound', $this->m_sLinkedClass, $iObjectId));
}
}
$sHTML .= $oPage->GetDetails($aDetails);
$sHTML .= "<input type=\"submit\" class=\"jqmClose\" onClick=\"oLinkWidget$sId.OnLinkOk()\" value=\" Ok \" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<button type=\"button\" class=\"jqmClose\" onClick=\"oLinkWidget$sId.OnLinkCancel()\"> Cancel</button>\n";
$sHTML .= "</form>\n";
$sHTML .= "</div>\n";
$sHTML .= "</div>\n";
$oPage->add_ready_script("$('#LinkDlg_$sId').jqm({overlay:70, modal:true, toTop:true});"); // jqModal Window
//$oPage->add_ready_script("UpdateObjectList('$sClass');");
return $sHTML;
}
}
?>

View File

@@ -0,0 +1,70 @@
<?php
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* Class UIPasswordWidget
* UI wdiget for displaying and editing one-way encrypted passwords
*
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
require_once(APPROOT.'/application/webpage.class.inc.php');
require_once(APPROOT.'/application/displayblock.class.inc.php');
class UIPasswordWidget
{
protected static $iWidgetIndex = 0;
protected $sAttCode;
protected $sNameSuffix;
protected $iId;
public function __construct($sAttCode, $iInputId, $sNameSuffix = '')
{
self::$iWidgetIndex++;
$this->sAttCode = $sAttCode;
$this->sNameSuffix = $sNameSuffix;
$this->iId = $iInputId;
}
/**
* Get the HTML fragment corresponding to the linkset editing widget
* @param WebPage $oP The web page used for all the output
* @param Hash $aArgs Extra context arguments
* @return string The HTML fragment to be inserted into the page
*/
public function Display(WebPage $oPage, $aArgs = array())
{
$sCode = $this->sAttCode.$this->sNameSuffix;
$iWidgetIndex = self::$iWidgetIndex;
$sPasswordValue = utils::ReadPostedParam("attr_$sCode", '*****');
$sConfirmPasswordValue = utils::ReadPostedParam("attr_{$sCode}_confirmed", '*****');
$sChangedValue = (($sPasswordValue != '*****') || ($sConfirmPasswordValue != '*****')) ? 1 : 0;
$sHtmlValue = '';
$sHtmlValue = '<input type="password" maxlength="255" name="attr_'.$sCode.'" id="'.$this->iId.'" value="'.htmlentities($sPasswordValue, ENT_QUOTES, 'UTF-8').'"/>&nbsp;<span class="form_validation" id="v_'.$this->iId.'"></span><br/>';
$sHtmlValue .= '<input type="password" maxlength="255" id="'.$this->iId.'_confirm" value="'.htmlentities($sConfirmPasswordValue, ENT_QUOTES, 'UTF-8').'" name="attr_'.$sCode.'_confirmed"/> '.Dict::S('UI:PasswordConfirm').' <input type="button" value="'.Dict::S('UI:Button:ResetPassword').'" onClick="ResetPwd(\''.$this->iId.'\');">';
$sHtmlValue .= '<input type="hidden" id="'.$this->iId.'_changed" name="attr_'.$sCode.'_changed" value="'.$sChangedValue.'"/>';
$oPage->add_ready_script("$('#$this->iId').bind('keyup change', function(evt) { return PasswordFieldChanged('$this->iId') } );"); // Bind to a custom event: validate
$oPage->add_ready_script("$('#$this->iId').bind('keyup change validate', function(evt, sFormId) { return ValidatePasswordField('$this->iId', sFormId) } );"); // Bind to a custom event: validate
$oPage->add_ready_script("$('#{$this->iId}_confirm').bind('keyup change', function(evt, sFormId) { return ValidatePasswordField('$this->iId', sFormId) } );"); // Bind to a custom event: validate
return $sHtmlValue;
}
}
?>

View File

@@ -1,4 +1,28 @@
<?php
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* Class UILinksWizard
*
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
class UILinksWizard
{
protected $m_sClass;
@@ -19,7 +43,7 @@ class UILinksWizard
$this->m_aEditableFields = array();
$this->m_aTableConfig = array();
$this->m_aTableConfig['form::checkbox'] = array( 'label' => "<input class=\"select_all\" type=\"checkbox\" value=\"1\" onChange=\"var value = this.checked; $('.selection').each( function() { this.checked = value; } );OnSelectChange();\">", 'description' => "Select / Deselect All");
$this->m_aTableConfig['form::checkbox'] = array( 'label' => "<input class=\"select_all\" type=\"checkbox\" value=\"1\" onChange=\"var value = this.checked; $('.selection').each( function() { this.checked = value; } );OnSelectChange();\">", 'description' => Dict::S('UI:SelectAllToggle+'));
foreach(MetaModel::GetAttributesList($this->m_sClass) as $sAttCode)
{
$oAttDef = MetaModel::GetAttributeDef($this->m_sClass, $sAttCode);
@@ -46,7 +70,7 @@ class UILinksWizard
}
if (empty($this->m_sLinkedClass))
{
throw( new Exception("Incorrect link definition: the class of objects to manage: '$sLinkedClass' was not found as an external key in the class '$sClass'"));
throw( new Exception(Dict::Format('UI:Error:IncorrectLinkDefinition_LinkedClass_Class', $sLinkedClass, $sClass)));
}
foreach(MetaModel::GetZListItems($this->m_sLinkedClass, 'list') as $sFieldCode)
{
@@ -55,11 +79,11 @@ class UILinksWizard
}
}
public function Display(WebPage $oP, UserContext $oContext, $aExtraParams = array())
public function Display(WebPage $oP, $aExtraParams = array())
{
$oAttDef = MetaModel::GetAttributeDef($this->m_sClass, $this->m_sLinkageAttr);
$sTargetClass = $oAttDef->GetTargetClass();
$oTargetObj = $oContext->GetObject($sTargetClass, $this->m_iObjectId);
$oTargetObj = MetaModel::GetObject($sTargetClass, $this->m_iObjectId);
$oP->set_title("iTop - ".MetaModel::GetName($this->m_sLinkedClass)." objects linked with ".MetaModel::GetName(get_class($oTargetObj)).": ".$oTargetObj->GetName());
$oP->add("<div class=\"wizContainer\">\n");
@@ -71,10 +95,12 @@ class UILinksWizard
$oP->add("<input type=\"hidden\" name=\"linkage\" value=\"{$this->m_sLinkageAttr}\">\n");
$oP->add("<input type=\"hidden\" name=\"object_id\" value=\"{$this->m_iObjectId}\">\n");
$oP->add("<input type=\"hidden\" name=\"linking_attcode\" value=\"{$this->m_sLinkingAttCode}\">\n");
$oP->add("<h1>Manage ".MetaModel::GetName($this->m_sLinkedClass)."s linked with ".MetaModel::GetName(get_class($oTargetObj)).": <span class=\"hilite\">".$oTargetObj->GetHyperlink()."</span></h1>\n");
$oP->add("<h1>".Dict::Format('UI:ManageObjectsOf_Class_LinkedWith_Class_Instance', MetaModel::GetName($this->m_sLinkedClass), MetaModel::GetName(get_class($oTargetObj)), "<span class=\"hilite\">".$oTargetObj->GetHyperlink()."</span>")."</h1>\n");
$oP->add("</div>\n");
$oP->add("<script type=\"text/javascript\">\n");
$oP->add("function OnSelectChange()
$oP->add(
<<<EOF
function OnSelectChange()
{
var nbChecked = $('.selection:checked').length;
if (nbChecked > 0)
@@ -106,7 +132,7 @@ class UILinksWizard
function AddObjects()
{
// TO DO: compute the list of objects already linked with the current Object
$.get( 'ajax.render.php', { 'operation': 'addObjects',
$.post( 'ajax.render.php', { 'operation': 'addObjects',
'class': '{$this->m_sClass}',
'linkageAttr': '{$this->m_sLinkageAttr}',
'linkedClass': '{$this->m_sLinkedClass}',
@@ -119,7 +145,7 @@ class UILinksWizard
$('#ModalDlg').css('width', dlgWidth);
$('#ModalDlg').css('left', 50);
$('#ModalDlg').css('top', 50);
$('#ModalDlg').jqmShow();
$('#ModalDlg').dialog( 'open' );
},
'html'
);
@@ -132,7 +158,10 @@ class UILinksWizard
'linkedClass': '{$this->m_sLinkedClass}',
'objectId': '{$this->m_iObjectId}'
}
if ($('#'+currentFormId+' :input[name=class]').val() != undefined)
{
theMap.linkedClass = $('#'+currentFormId+' :input[name=class]').val();
}
// Gather the parameters from the search form
$('#'+currentFormId+' :input').each(
function(i)
@@ -146,22 +175,11 @@ class UILinksWizard
theMap['operation'] = 'searchObjectsToAdd';
// Run the query and display the results
$.get( 'ajax.render.php', theMap,
$.post( 'ajax.render.php', theMap,
function(data)
{
$('#SearchResultsToAdd').html(data);
nb_rows = $('#SearchResultsToAdd table.listResults tr').length;
if(nb_rows > 10)
{
yOffset = $('#ModalDlg').height() - $('#SearchResultsToAdd table.listResults tbody').height();
tbodyHeight = $(document).height() - 100 - yOffset;
if ($('#ModalDlg').height() > ($(document).height() - 100))
{
$('#SearchResultsToAdd table.listResults tbody').attr('height', tbodyHeight);
$('#SearchResultsToAdd .listResults tbody').css('overflow', 'auto');
$('#SearchResultsToAdd .listResults').tablesorter( { headers: { 0:{sorter: false }}, widgets: ['zebra']} ); // sortable and zebra tables
}
}
$('#SearchResultsToAdd .listResults').tablesorter( { headers: {0: false}}, widgets: ['myZebra', 'truncatedList']} ); // sortable and zebra tables
},
'html'
@@ -205,7 +223,7 @@ class UILinksWizard
theMap['operation'] = 'doAddObjects';
// Run the query and display the results
$.get( 'ajax.render.php', theMap,
$.post( 'ajax.render.php', theMap,
function(data)
{
//console.log('Data: ' + data);
@@ -215,11 +233,11 @@ class UILinksWizard
}
$('.listResults tbody').append(data);
$('.listResults').trigger('update');
$('.listResults').tablesorter( { headers: { 0:{sorter: false }}, widgets: ['zebra']} ); // sortable and zebra tables
$('.listResults').tablesorter( { headers: {0: false}}, widgets: ['myZebra', 'truncatedList']} ); // sortable and zebra tables
},
'html'
);
$('#ModalDlg').jqmHide();
$('#ModalDlg').dialog('close');
return false;
}
@@ -230,10 +248,18 @@ class UILinksWizard
$('#btnRemove').attr('disabled','disabled');
$('#linksToRemove').val('');
}
");
function SubmitHook()
{
var the_form = this;
SearchObjectsToAdd(the_form.id);
return false;
}
EOF
);
$oP->Add("</script>\n");
$oP->add_ready_script("InitForm();");
$oFilter = $oContext->NewFilter($this->m_sClass);
$oFilter = new DBObjectSearch($this->m_sClass);
$oFilter->AddCondition($this->m_sLinkageAttr, $this->m_iObjectId, '=');
$oSet = new DBObjectSet($oFilter);
$aForm = array();
@@ -241,17 +267,17 @@ class UILinksWizard
{
$aRow = array();
$key = $oCurrentLink->GetKey();
$oLinkedObj = $oContext->GetObject($this->m_sLinkedClass, $oCurrentLink->Get($this->m_sLinkingAttCode));
$oLinkedObj = MetaModel::GetObject($this->m_sLinkedClass, $oCurrentLink->Get($this->m_sLinkingAttCode));
$aForm[$key] = $this->GetFormRow($oP, $oLinkedObj, $oCurrentLink);
}
//var_dump($aTableLabels);
//var_dump($aForm);
$this->DisplayFormTable($oP, $this->m_aTableConfig, $aForm);
$oP->add("<span style=\"float:left;\">&nbsp;&nbsp;&nbsp;<img src=\"../images/tv-item-last.gif\">&nbsp;&nbsp;<input id=\"btnRemove\" type=\"button\" value=\" Remove ".MetaModel::GetName($this->m_sLinkedClass)."s \" onClick=\"RemoveSelected();\" >");
$oP->add("&nbsp;&nbsp;&nbsp;<input id=\"btnAdd\" type=\"button\" value=\" Add ".MetaModel::GetName($this->m_sLinkedClass)."s... \" onClick=\"AddObjects();\"></span>\n");
$oP->add("<span style=\"float:right;\"><input id=\"btnCancel\" type=\"button\" value=\" Cancel \" onClick=\"goBack();\">");
$oP->add("&nbsp;&nbsp;&nbsp;<input id=\"btnOk\" type=\"submit\" value=\" Ok \"></span>\n");
$oP->add("<span style=\"float:left;\">&nbsp;&nbsp;&nbsp;<img src=\"../images/tv-item-last.gif\">&nbsp;&nbsp;<input id=\"btnRemove\" type=\"button\" value=\"".Dict::S('UI:RemoveLinkedObjectsOf_Class')."\" onClick=\"RemoveSelected();\" >");
$oP->add("&nbsp;&nbsp;&nbsp;<input id=\"btnAdd\" type=\"button\" value=\"".Dict::Format('UI:AddLinkedObjectsOf_Class', MetaModel::GetName($this->m_sLinkedClass))."\" onClick=\"AddObjects();\"></span>\n");
$oP->add("<span style=\"float:right;\"><input id=\"btnCancel\" type=\"button\" value=\"".Dict::S('UI:Button:Cancel')."\" onClick=\"BackToDetails('".$sTargetClass."', ".$this->m_iObjectId.");\">");
$oP->add("&nbsp;&nbsp;&nbsp;<input id=\"btnOk\" type=\"submit\" value=\"".Dict::S('UI:Button:Ok')."\"></span>\n");
$oP->add("<span style=\"clear:both;\"><p>&nbsp;</p></span>\n");
$oP->add("</div>\n");
$oP->add("</form>\n");
@@ -285,7 +311,7 @@ class UILinksWizard
foreach($this->m_aEditableFields as $sFieldCode)
{
$oAttDef = MetaModel::GetAttributeDef($this->m_sClass, $sFieldCode);
$aRow[$sFieldCode] = cmdbAbstractObject::GetFormElementForField($oP, $this->m_sClass, $sFieldCode, $oAttDef, '' /* TO DO/ call GetDefaultValue */, '' /* DisplayValue */, '' /* id */, $sNameSuffix);
$aRow[$sFieldCode] = cmdbAbstractObject::GetFormElementForField($oP, $this->m_sClass, $sFieldCode, $oAttDef, '' /* TO DO/ call GetDefaultValue($oObject->ToArgs()) */, '' /* DisplayValue */, '' /* id */, $sNameSuffix);
}
}
foreach(MetaModel::GetZListItems($this->m_sLinkedClass, 'list') as $sFieldCode)
@@ -312,7 +338,7 @@ class UILinksWizard
$oP->add("</tbody>\n");
if (count($aData) == 0)
{
$oP->add("<tr id=\"empty_row\"><td colspan=\"".count($aConfig)."\" style=\"text-align:center;\">The list is empty, use 'Add...' to add elements.</td></td>");
$oP->add("<tr id=\"empty_row\"><td colspan=\"".count($aConfig)."\" style=\"text-align:center;\">".Dict::S('UI:Message:EmptyList:UseAdd')."</td></td>");
}
else
{
@@ -337,41 +363,42 @@ class UILinksWizard
$oP->add("</tr>\n");
}
public function DisplayAddForm(WebPage $oP, UserContext $oContext)
public function DisplayAddForm(WebPage $oP)
{
$oAttDef = MetaModel::GetAttributeDef($this->m_sClass, $this->m_sLinkageAttr);
$sTargetClass = $oAttDef->GetTargetClass();
$oTargetObj = $oContext->GetObject($sTargetClass, $this->m_iObjectId);
$oTargetObj = MetaModel::GetObject($sTargetClass, $this->m_iObjectId);
$oP->add("<div class=\"wizContainer\">\n");
$oP->add("<div class=\"page_header\">\n");
$oP->add("<h1>Add ".MetaModel::GetName($this->m_sLinkedClass)."s to ".MetaModel::GetName(get_class($oTargetObj)).": <span class=\"hilite\">".$oTargetObj->GetHyperlink()."</span></h1>\n");
$oP->add("</div>\n");
//$oP->add("<div class=\"page_header\">\n");
//$oP->add("<h1>".Dict::Format('UI:AddObjectsOf_Class_LinkedWith_Class_Instance', MetaModel::GetName($this->m_sLinkedClass), MetaModel::GetName(get_class($oTargetObj)), "<span class=\"hilite\">".$oTargetObj->GetHyperlink()."</span>")."</h1>\n");
//$oP->add("</div>\n");
$oFilter = $oContext->NewFilter($this->m_sLinkedClass);
$oFilter = new DBObjectSearch($this->m_sLinkedClass);
$oSet = new CMDBObjectSet($oFilter);
$oBlock = new DisplayBlock($oFilter, 'search', false);
$oBlock->Display($oP, 'SearchFormToAdd', array('open' => true));
$oP->Add("<form id=\"ObjectsAddForm\" OnSubmit=\"return DoAddObjects(this.id);\">\n");
$oP->Add("<div id=\"SearchResultsToAdd\">\n");
$oP->Add("<div style=\"height: 100px; background: #fff;border-color:#F6F6F1 #E6E6E1 #E6E6E1 #F6F6F1; border-style:solid; border-width:3px; text-align: center; vertical-align: center;\"><p>Use the search form above to search for objects to be added.</p></div>\n");
$oP->Add("<div style=\"height: 100px; background: #fff;border-color:#F6F6F1 #E6E6E1 #E6E6E1 #F6F6F1; border-style:solid; border-width:3px; text-align: center; vertical-align: center;\"><p>".Dict::S('UI:Message:EmptyList:UseSearchForm')."</p></div>\n");
$oP->Add("</div>\n");
$oP->add("<input type=\"button\" value=\"Cancel\" onClick=\"$('#ModalDlg').jqmHide();\">&nbsp;&nbsp;<input type=\"submit\" value=\" Add \">");
$oP->add("<input type=\"button\" value=\"".Dict::S('UI:Button:Cancel')."\" onClick=\"$('#ModalDlg').dialog('close');\">&nbsp;&nbsp;<input type=\"submit\" value=\"".Dict::S('UI:Button:Add')."\">");
$oP->Add("</div>\n");
$oP->Add("</form>\n");
$oP->add_ready_script("$('div#SearchFormToAdd form').bind('submit', function() {var the_form = this; SearchObjectsToAdd(the_form.id); return false;});");
$oP->add_ready_script("$('#ModalDlg').dialog('option', {title:'".Dict::Format('UI:AddObjectsOf_Class_LinkedWith_Class_Instance', MetaModel::GetName($this->m_sLinkedClass), MetaModel::GetName(get_class($oTargetObj)), "<span class=\"hilite\">".$oTargetObj->GetHyperlink()."</span>")."'});");
$oP->add_ready_script("$('div#SearchFormToAdd form').bind('submit.uilinksWizard', SubmitHook);");
}
public function SearchObjectsToAdd(WebPage $oP, UserContext $oContext)
public function SearchObjectsToAdd(WebPage $oP)
{
//$oAttDef = MetaModel::GetAttributeDef($this->m_sClass, $this->m_sLinkageAttr);
$oFilter = $oContext->NewFilter($this->m_sLinkedClass);
$oFilter = new DBObjectSearch($this->m_sLinkedClass);
$oSet = new CMDBObjectSet($oFilter);
$oBlock = new DisplayBlock($oFilter, 'list', false);
$oBlock->Display($oP, 'ResultsToAdd', array('menu' => false, 'selection_mode' => true, 'display_limit' => false)); // Don't display the 'Actions' menu on the results
}
public function DoAddObjects(WebPage $oP, UserContext $oContext, $aLinkedObjectIds = array())
public function DoAddObjects(WebPage $oP, $aLinkedObjectIds = array())
{
//$oAttDef = MetaModel::GetAttributeDef($this->m_sClass, $this->m_sLinkageAttr);
//$sTargetClass = $oAttDef->GetTargetClass();
@@ -379,7 +406,7 @@ class UILinksWizard
$aTable = array();
foreach($aLinkedObjectIds as $iObjectId)
{
$oLinkedObj = $oContext->GetObject($this->m_sLinkedClass, $iObjectId);
$oLinkedObj = MetaModel::GetObject($this->m_sLinkedClass, $iObjectId);
if (is_object($oLinkedObj))
{
$aRow = $this->GetFormRow($oP, $oLinkedObj, -$iObjectId ); // Not yet created link get negative Ids
@@ -387,7 +414,7 @@ class UILinksWizard
}
else
{
echo "Object: $sTargetClass - Id: $iObjectId not found <br/>\n";
echo Dict::Format('UI:Error:Object_Class_Id_NotFound', $this->m_sLinkedClass, $iObjectId);
}
}
//var_dump($aTable);

View File

@@ -1,4 +1,28 @@
<?php
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* Class UIWizard
*
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
class UIWizard
{
protected $m_oPage;
@@ -38,9 +62,9 @@ class UIWizard
$sJSHandlerCode = ''; // Javascript code to be executed each time this step of the wizard is entered
foreach($aStep as $sAttCode)
{
if ($sAttCode != 'finalclass') // Do not display the attribute that stores the actual class name
$oAttDef = MetaModel::GetAttributeDef($this->m_sClass, $sAttCode);
if ($oAttDef->IsWritable())
{
$oAttDef = MetaModel::GetAttributeDef($this->m_sClass, $sAttCode);
$sAttLabel = $oAttDef->GetLabel();
$iOptions = isset($aStates[$this->m_sTargetState]['attribute_list'][$sAttCode]) ? $aStates[$this->m_sTargetState]['attribute_list'][$sAttCode] : 0;
@@ -58,11 +82,11 @@ class UIWizard
$aOptions[] = 'Prerequisites: '.implode(', ', $aPrerequisites);
}
$sFieldFlag = ($iOptions & (OPT_ATT_MANDATORY | OPT_ATT_MUSTCHANGE)) ? ' <span class="hilite">*</span>' : '';
$oDefaultValuesSet = $oAttDef->GetDefaultValue(); // @@@ TO DO: get the object's current value if the object exists
$sFieldFlag = (($iOptions & (OPT_ATT_MANDATORY | OPT_ATT_MUSTCHANGE)) || (!$oAttDef->IsNullAllowed()) )? ' <span class="hilite">*</span>' : '';
$oDefaultValuesSet = $oAttDef->GetDefaultValue(/* $oObject->ToArgs() */); // @@@ TO DO: get the object's current value if the object exists
$sHTMLValue = cmdbAbstractObject::GetFormElementForField($this->m_oPage, $this->m_sClass, $sAttCode, $oAttDef, $oDefaultValuesSet, '', "att_$iMaxInputId", '', $iOptions, $aArgs);
$aFieldsMap[$iMaxInputId] = $sAttCode;
$aDetails[] = array('label' => $oAttDef->GetLabel().$sFieldFlag, 'value' => "<div id=\"field_$iMaxInputId\">$sHTMLValue</div>");
$aFieldsMap["att_$iMaxInputId"] = $sAttCode;
$aDetails[] = array('label' => '<span title="'.$oAttDef->GetDescription().'">'.$oAttDef->GetLabel().$sFieldFlag.'</span>', 'value' => "<span id=\"field_att_$iMaxInputId\">$sHTMLValue</span>");
if ($oAttDef->GetValuesDef() != null)
{
$sJSHandlerCode .= "\toWizardHelper.RequestAllowedValues('$sAttCode');\n";
@@ -84,9 +108,9 @@ class UIWizard
$sDisabled = $bFinishEnabled ? '' : 'disabled';
$nbSteps = count($this->m_aWizardSteps['mandatory']) + count($this->m_aWizardSteps['optional']);
$this->m_oPage->add("<div style=\"text-align:center\">
<input type=\"button\" value=\"&lt;&lt; Back \" $sBackButtonDisabled onClick=\"GoToStep($iStepIndex, $iStepIndex - 1)\" />
<input type=\"button\" value=\" Next &gt;&gt;\" onClick=\"GoToStep($iStepIndex, 1+$iStepIndex)\" />
<input type=\"button\" value=\" Finish \" $sDisabled onClick=\"GoToStep($iStepIndex, 1+$nbSteps)\" />
<input type=\"button\" value=\"".Dict::S('UI:Button:Back')."\" $sBackButtonDisabled onClick=\"GoToStep($iStepIndex, $iStepIndex - 1)\" />
<input type=\"button\" value=\"".Dict::S('UI:Button:Next')."\" onClick=\"GoToStep($iStepIndex, 1+$iStepIndex)\" />
<input type=\"button\" value=\"".Dict::S('UI:Button:Finish')."\" $sDisabled onClick=\"GoToStep($iStepIndex, 1+$nbSteps)\" />
</div>\n");
$this->m_oPage->add("
<script type=\"text/javascript\">
@@ -111,7 +135,7 @@ $sJSHandlerCode
$oAppContext = new ApplicationContext();
$this->m_oPage->add("<div class=\"wizContainer\" id=\"wizStep$iStepIndex\" style=\"display:none;\">\n");
$this->m_oPage->add("<a name=\"step$iStepIndex\" />\n");
$this->m_oPage->P("Final step: confirmation");
$this->m_oPage->P(Dict::S('UI:Wizard:FinalStepTitle'));
$this->m_oPage->add("<input type=\"hidden\" name=\"operation\" value=\"wizard_apply_new\" />\n");
$this->m_oPage->add("<input type=\"hidden\" name=\"transaction_id\" value=\"".utils::GetNewTransactionId()."\" />\n");
$this->m_oPage->add("<input type=\"hidden\" id=\"wizard_json_obj\" name=\"json_obj\" value=\"\" />\n");
@@ -128,6 +152,7 @@ $sJSHandlerCode
$this->m_oPage->add("<div id=\"object_preview\">\n");
$this->m_oPage->add("</div>\n");
$this->m_oPage->add($oAppContext->GetForForm());
$this->m_oPage->add("<input type=\"button\" value=\"".Dict::S('UI:Button:Back')."\" onClick=\"GoToStep($iStepIndex, $iStepIndex - 1)\" />");
$this->m_oPage->add("<input type=\"submit\" value=\"Create ".MetaModel::GetName($this->m_sClass)."\" />\n");
$this->m_oPage->add("</div>\n");
$this->m_oPage->add("</form>\n");
@@ -145,46 +170,52 @@ $sJSHandlerCode
$aFieldsDone = array(); // Store all the fields that are already covered by a previous step of the wizard
$aStates = MetaModel::EnumStates($this->m_sClass);
$sStateAttCode = MetaModel::GetStateAttributeCode($this->m_sClass);
$aMandatoryAttributes = array();
// Some attributes are always mandatory independently of the state machine (if any)
foreach(MetaModel::GetAttributesList($this->m_sClass) as $sAttCode)
{
$oAttDef = MetaModel::GetAttributeDef($this->m_sClass, $sAttCode);
if (!$oAttDef->IsExternalField() && !$oAttDef->IsNullAllowed())
if (!$oAttDef->IsExternalField() && !$oAttDef->IsNullAllowed() &&
$oAttDef->IsWritable() && ($sAttCode != $sStateAttCode) )
{
$aMandatoryAttributes[$sAttCode] = OPT_ATT_MANDATORY;
}
}
// Now check the attributes that are mandatory in the specified state
if ( (!empty($this->m_sTargetState)) && (count($aStates[$this->m_sTargetState]['attribute_list']) > 0) )
if ( (!empty($this->m_sTargetState)) && (count($aStates[$this->m_sTargetState]['attribute_list']) > 0) )
{
// Check all the fields that *must* be included in the wizard for this
// particular target state
$aFields = array();
foreach($aStates[$this->m_sTargetState]['attribute_list'] as $sAttCode => $iOptions)
{
if (isset($aMandatoryAttributes[$sAttCode]))
{
$aMandatoryAttributes[$sAttCode] |= $iOptions;
}
else
{
$aMandatoryAttributes[$sAttCode] = $iOptions;
}
}
}
// Check all the fields that *must* be included in the wizard
if ( (isset($aMandatoryAttributes[$sAttCode])) &&
($aMandatoryAttributes[$sAttCode] & (OPT_ATT_MANDATORY | OPT_ATT_MUSTCHANGE | OPT_ATT_MUSTPROMPT)) )
{
$aMandatoryAttributes[$sAttCode] |= $iOptions;
}
else
{
$aMandatoryAttributes[$sAttCode] = $iOptions;
}
}
}
// Check all the fields that *must* be included in the wizard
// i.e. all mandatory, must-change or must-prompt fields that are
// not also read-only or hidden.
// Some fields may be required (null not allowed) from the database
// perspective, but hidden or read-only from the user interface perspective
$aFields = array();
foreach($aMandatoryAttributes as $sAttCode => $iOptions)
{
$oAttDef = MetaModel::GetAttributeDef($this->m_sClass, $sAttCode);
$sAttLabel = $oAttDef->GetLabel();
if ( ($iOptions & (OPT_ATT_MANDATORY | OPT_ATT_MUSTCHANGE | OPT_ATT_MUSTPROMPT)) )
if ( ($iOptions & (OPT_ATT_MANDATORY | OPT_ATT_MUSTCHANGE | OPT_ATT_MUSTPROMPT)) &&
!($iOptions & (OPT_ATT_READONLY | OPT_ATT_HIDDEN)) )
{
$oAttDef = MetaModel::GetAttributeDef($this->m_sClass, $sAttCode);
$aPrerequisites = $oAttDef->GetPrerequisiteAttributes();
$aFields[$sAttCode] = array();
foreach($aPrerequisites as $sCode)
@@ -195,39 +226,48 @@ $sJSHandlerCode
}
// Now use the dependencies between the fields to order them
while(count($aFields) > 0)
// Start from the order of the 'details'
$aList = MetaModel::GetZListItems($this->m_sClass, 'details');
$index = 0;
$aOrder = array();
foreach($aFields as $sAttCode => $void)
{
$aCurrentStep = array();
foreach($aFields as $sAttCode => $aDependencies)
$aOrder[$sAttCode] = 999; // At the end of the list...
}
foreach($aList as $sAttCode)
{
if (array_key_exists($sAttCode, $aFields))
{
// All fields with no remaining dependencies can be entered at this
// step of the wizard
if (count($aDependencies) == 0)
$aOrder[$sAttCode] = $index;
}
$index++;
}
foreach($aFields as $sAttCode => $aDependencies)
{
// All fields with no remaining dependencies can be entered at this
// step of the wizard
if (count($aDependencies) > 0)
{
$iMaxPos = 0;
// Remove this field from the dependencies of the other fields
foreach($aDependencies as $sDependentAttCode => $void)
{
$aCurrentStep[] = $sAttCode;
$aFieldsDone[$sAttCode] = '';
unset($aFields[$sAttCode]);
// Remove this field from the dependencies of the other fields
foreach($aFields as $sUpdatedCode => $aDummy)
{
// remove the dependency
unset($aFields[$sUpdatedCode][$sAttCode]);
}
// position the current field after the ones it depends on
$iMaxPos = max($iMaxPos, 1+$aOrder[$sDependentAttCode]);
}
}
if (count($aCurrentStep) == 0)
{
// This step of the wizard would contain NO field !
echo "<strong>Error:</strong> Circular reference in the dependencies between the fields.";
print_r($aFields);
break;
}
$aWizardSteps['mandatory'][] = $aCurrentStep;
}
asort($aOrder);
$aCurrentStep = array();
foreach($aOrder as $sAttCode => $rank)
{
$aCurrentStep[] = $sAttCode;
$aFieldsDone[$sAttCode] = '';
}
$aWizardSteps['mandatory'][] = $aCurrentStep;
// Now computes the steps to fill the optional fields
$sStateAttCode = MetaModel::GetStateAttributeCode($this->m_sClass);
$aFields = array(); // reset
foreach(MetaModel::ListAttributeDefs($this->m_sClass) as $sAttCode=>$oAttDef)
{
@@ -279,7 +319,7 @@ $sJSHandlerCode
if (count($aCurrentStep) == 0)
{
// This step of the wizard would contain NO field !
$oPage->add("<strong>Error:</strong> Circular reference in the dependencies between the fields.");
$this->m_oPage->add(Dict::S('UI:Error:WizardCircularReferenceInDependencies'));
print_r($aFields);
break;
}

View File

@@ -0,0 +1,177 @@
<?php
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* Store and retrieve user's preferences (i.e persistent per user settings)
*
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
require_once(APPROOT.'/core/dbobject.class.php');
require_once(APPROOT.'/core/userrights.class.inc.php');
/**
* This class is used to store, in a persistent manner, user related settings (preferences)
* For each user, one record in the database will be created, making their preferences permanent and storing a list
* of properties (pairs of name/value strings)
* This overcomes some limitations of cookies: limited number of cookies, maximum size, depends on the browser, etc..
* This class is used in conjunction with the GetUserPreferences/SetUserPreferences javascript functions (utils.js)
*/
class appUserPreferences extends DBObject
{
static $oUserPrefs = null; // Local cache
/**
* Get the value of the given property/preference
* If not set, the default value will be returned
* @param string $sCode Code/Name of the property to set
* @param string $sDefaultValue The default value
* @return string The value of the property for the current user
*/
static function GetPref($sCode, $sDefaultValue)
{
if (self::$oUserPrefs == null)
{
self::Load();
}
$aPrefs = self::$oUserPrefs->Get('preferences');
if (isset($aPrefs[$sCode]))
{
return $aPrefs[$sCode];
}
else
{
return $sDefaultValue;
}
}
/**
* Set the value for a given preference, and stores it into the database
* @param string $sCode Code/Name of the property/preference to set
* @param string $sValue Value to set
*/
static function SetPref($sCode, $sValue)
{
if (self::$oUserPrefs == null)
{
self::Load();
}
$aPrefs = self::$oUserPrefs->Get('preferences');
$aPrefs[$sCode] = $sValue;
self::$oUserPrefs->Set('preferences', $aPrefs);
self::Save();
}
/**
* Call this function to get all the preferences for the user, packed as a JSON object
* @return string JSON representation of the preferences
*/
static function GetAsJSON()
{
if (self::$oUserPrefs == null)
{
self::Load();
}
$aPrefs = self::$oUserPrefs->Get('preferences');
return json_encode($aPrefs);
}
/**
* Call this function if the user has changed (like when doing a logoff...)
*/
static public function Reset()
{
self::$oUserPrefs = null;
}
/**
* Call this function to ERASE all the preferences from the current user
*/
static public function ClearPreferences()
{
self::$oUserPrefs = null;
}
static protected function Save()
{
if (self::$oUserPrefs != null)
{
if (self::$oUserPrefs->IsModified())
{
self::$oUserPrefs->DBUpdate();
}
}
}
/**
* Loads the preferences for the current user, creating the record in the database
* if needed
*/
static protected function Load()
{
if (self::$oUserPrefs != null) return;
$oSearch = new DBObjectSearch('appUserPreferences');
$oSearch->AddCondition('userid', UserRights::GetUserId(), '=');
$oSet = new DBObjectSet($oSearch);
$oObj = $oSet->Fetch();
if ($oObj == null)
{
// No prefs (yet) for this user, create the object
$oObj = new appUserPreferences();
$oObj->Set('userid', UserRights::GetUserId());
$oObj->Set('preferences', array()); // Default preferences: an empty array
try
{
$oObj->DBInsert();
}
catch(Exception $e)
{
// Ignore errors
}
}
self::$oUserPrefs = $oObj;
}
public static function Init()
{
$aParams = array
(
"category" => "gui",
"key_type" => "autoincrement",
"name_attcode" => "userid",
"state_attcode" => "",
"reconc_keys" => array(),
"db_table" => "priv_app_preferences",
"db_key_field" => "id",
"db_finalclass_field" => "",
);
MetaModel::Init_Params($aParams);
MetaModel::Init_AddAttribute(new AttributeExternalKey("userid", array("targetclass"=>"User", "allowed_values"=>null, "sql"=>"userid", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributePropertySet("preferences", array("allowed_values"=>null, "sql"=>"preferences", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
}
/**
* Overloading this function here to secure a fix done right before the release
* The real fix should be to implement this verb in DBObject
*/
public function DBDeleteTracked(CMDBChange $oChange, $bSkipStrongSecurity = null)
{
$this->DBDelete();
}
}
?>

View File

@@ -1,106 +0,0 @@
<?php
require_once('../core/cmdbobject.class.inc.php');
require_once('../core/userrights.class.inc.php');
/**
* Helper class to capture a user's restrictions (access rights, profiles...) as a set of limiting conditions
*
* **** NOW OBSOLETE *** SHOULD BE REPLACED EVERYWHERE BY UserRights *****
*
*
*
*
* Usage:
* 1) Build the user's context (from her rights, a lookup in the database, a cookie, whatever)
* $oContext = new UserContext();
* $oContext->AddCondition('SomeClass', 'someFilter', 'SomeValue', '=');
* ...
*
* 2) Use the restrictions contained in the context when retrieving objects either when:
* getting directly an instance of an object
* $oObj = $oContext->GetObject('myClass', 'someKey'); // Instead of $oObj = MetaModel::GetObject('Klass', 'someKey');
* or when building a new search filter
* $oFilter = $oContext->NewFilter('myClass'); // Instead of $oFilter = new CMDBSearchFilter('Klass');
*/
class UserContext
{
/**
* Hash array to store the restricting conditions by myClass
*/
protected $m_aConditions;
/**
* Constructor
*/
public function __construct()
{
$this->m_aConditions = array();
}
/**
* Create a new search filter for the given class of objects that already contains the context's restrictions
*/
public function NewFilter($sClass)
{
return UserRights::GetFilter($sClass);
/*
$oFilter = new CMDBSearchFilter($sClass);
foreach($this->m_aConditions as $sConditionClass => $aConditionList)
{
// Add to the filter all the conditions of the parent classes of this class
if ($this->IsSubclass($sConditionClass,$sClass))
{
foreach($aConditionList as $sFilterCode => $aCondition)
{
$oFilter->AddCondition($sFilterCode, $aCondition['value'], $aCondition['operator']);
}
}
}
return $oFilter;
*/
}
/**
* Retrieve an instance of an object (if allowed by the context)
*/
public function GetObject($sClass, $sKey)
{
$oObject = null;
$oFilter = $this->NewFilter($sClass);
$oFilter->AddCondition('pkey', $sKey, '=');
$oSet = new CMDBObjectSet($oFilter);
if ($oSet->Count() > 0)
{
$oObject = $oSet->Fetch();
}
return $oObject;
}
/**
* Add a restriction to the context for a given class of objects (and all its persistent subclasses)
*/
public function AddCondition($sClass, $sFilterCode, $value, $sOperator)
{
if(!isset($this->m_aConditions[$sClass]))
{
$this->m_aConditions[$sClass] = array();
}
$this->m_aConditions[$sClass][$sFilterCode] = array('value'=>$value, 'operator'=>$sOperator);
}
/**
* Check if a given class is a subclass of (or same as) another one
*/
protected function IsSubclass($sParentClass, $sSubclass)
{
$bResult = false;
if ($sParentClass == $sSubclass)
{
$bResult = true;
}
else
{
$aParentList = MetaModel::EnumParentClasses($sSubclass);
$bResult = in_array($sParentClass, $aParentList);
}
return $bResult;
}
}
?>

View File

@@ -1,19 +1,82 @@
<?php
require_once('../core/config.class.inc.php');
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
define('ITOP_CONFIG_FILE', '../config-itop.php');
/**
* Static class utils
*
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
require_once(APPROOT.'/core/config.class.inc.php');
require_once(APPROOT.'/application/transaction.class.inc.php');
define('ITOP_CONFIG_FILE', APPROOT.'/config-itop.php');
class FileUploadException extends Exception
{
}
/**
* Helper functions to interact with forms: read parameters, upload files...
* @package iTop
*/
class utils
{
private static $m_sConfigFile = ITOP_CONFIG_FILE;
private static $m_oConfig = null;
public static function ReadParam($sName, $defaultValue = "")
public static function IsModeCLI()
{
return isset($_REQUEST[$sName]) ? $_REQUEST[$sName] : $defaultValue;
$sSAPIName = php_sapi_name();
$sCleanName = strtolower(trim($sSAPIName));
if ($sCleanName == 'cli')
{
return true;
}
else
{
return false;
}
}
public static function ReadParam($sName, $defaultValue = "", $bAllowCLI = false)
{
global $argv;
$retValue = $defaultValue;
if (isset($_REQUEST[$sName]))
{
$retValue = $_REQUEST[$sName];
}
elseif ($bAllowCLI && isset($argv))
{
foreach($argv as $iArg => $sArg)
{
if (preg_match('/^--'.$sName.'=(.*)$/', $sArg, $aMatches))
{
$retValue = $aMatches[1];
}
}
}
return $retValue;
}
public static function ReadPostedParam($sName, $defaultValue = "")
@@ -51,7 +114,7 @@ class utils
$sMimeType = $sType;
}
}
@finfo_close($finfo);
@finfo_close($rInfo);
}
$oDocument = new ormDocument($doc_content, $sMimeType, $_FILES[$sName]['name']);
break;
@@ -62,27 +125,27 @@ class utils
case UPLOAD_ERR_FORM_SIZE:
case UPLOAD_ERR_INI_SIZE:
throw new FileUploadException("Uploaded file is too big. (Max allowed size is ".ini_get('upload_max_filesize').". Check you PHP configuration for upload_max_filesize.");
throw new FileUploadException(Dict::Format('UI:Error:UploadedFileTooBig', ini_get('upload_max_filesize')));
break;
case UPLOAD_ERR_PARTIAL:
throw new FileUploadException("File upload failed, file has been truncated.");
throw new FileUploadException(Dict::S('UI:Error:UploadedFileTruncated.'));
break;
case UPLOAD_ERR_NO_TMP_DIR:
throw new FileUploadException("Missing a temporary folder.");
throw new FileUploadException(Dict::S('UI:Error:NoTmpDir'));
break;
case UPLOAD_ERR_CANT_WRITE:
throw new FileUploadException("Unable to write the temporary file to the disk (upload_tmp_dir = ".ini_get('upload_tmp_dir').")");
throw new FileUploadException(Dict::Format('UI:Error:CannotWriteToTmp_Dir', ini_get('upload_tmp_dir')));
break;
case UPLOAD_ERR_EXTENSION:
throw new FileUploadException("File upload stopped by extension. (Original file name: ".$_FILES[$sName]['name'].")");
throw new FileUploadException(Dict::Format('UI:Error:UploadStoppedByExtension_FileName', $_FILES[$sName]['name']));
break;
default:
throw new FileUploadException("File upload failed, unknown cause (Error code = ".$_FILES[$sName]['error'].")");
throw new FileUploadException(Dict::Format('UI:Error:UploadFailedUnknownCause_Code', $_FILES[$sName]['error']));
break;
}
@@ -92,14 +155,17 @@ class utils
public static function GetNewTransactionId()
{
// TO DO implement the real mechanism here
return sprintf("%08x", rand(0,2000000000));
return privUITransaction::GetNewTransactionId();
}
public static function IsTransactionValid($sId)
public static function IsTransactionValid($sId, $bRemoveTransaction = true)
{
// TO DO implement the real mechanism here
return true;
return privUITransaction::IsTransactionValid($sId, $bRemoveTransaction);
}
public static function RemoveTransaction($sId)
{
return privUITransaction::RemoveTransaction($sId);
}
public static function ReadFromFile($sFileName)
@@ -108,19 +174,6 @@ class utils
return file_get_contents($sFileName);
}
/**
* Get access to the application config file
* @param none
* @return Config The Config object initialized from the application config file
*/
public static function GetConfig()
{
if (self::$m_oConfig == null)
{
self::$m_oConfig = new Config(ITOP_CONFIG_FILE);
}
return self::$m_oConfig;
}
/**
* Helper function to convert a value expressed in a 'user friendly format'
* as in php.ini, e.g. 256k, 2M, 1G etc. Into a number of bytes
@@ -151,20 +204,36 @@ class utils
/**
* Returns an absolute URL to the current page
* @param $bQueryString bool True to also get the query string, false otherwise
* @param $bForceHTTPS bool True to force HTTPS, false otherwise
* @return string The absolute URL to the current page
*/
static public function GetAbsoluteUrl($bQueryString = true)
static public function GetAbsoluteUrl($bQueryString = true, $bForceHTTPS = false)
{
// Build an absolute URL to this page on this server/port
$sServerName = $_SERVER['SERVER_NAME'];
$sProtocol = isset($_SERVER['HTTPS']) ? 'https' : 'http';
if ($sProtocol == 'http')
$sServerName = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : '';
if (MetaModel::GetConfig()->GetSecureConnectionRequired() || MetaModel::GetConfig()->GetHttpsHyperlinks())
{
$sPort = ($_SERVER['SERVER_PORT'] == 80) ? '' : ':'.$_SERVER['SERVER_PORT'];
// If a secure connection is required, or if the URL is requested to start with HTTPS
// then any URL must start with https !
$bForceHTTPS = true;
}
if ($bForceHTTPS)
{
$sProtocol = 'https';
$sPort = '';
}
else
{
$sPort = ($_SERVER['SERVER_PORT'] == 443) ? '' : ':'.$_SERVER['SERVER_PORT'];
$sProtocol = (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS']!="off")) ? 'https' : 'http';
$iPort = isset($_SERVER['SERVER_PORT']) ? $_SERVER['SERVER_PORT'] : 80;
if ($sProtocol == 'http')
{
$sPort = ($iPort == 80) ? '' : ':'.$iPort;
}
else
{
$sPort = ($iPort == 443) ? '' : ':'.$iPort;
}
}
// $_SERVER['REQUEST_URI'] is empty when running on IIS
// Let's use Ivan Tcholakov's fix (found on www.dokeos.com)
@@ -195,5 +264,46 @@ class utils
return $sUrl;
}
/**
* Returns the absolute URL PATH of the current page
* @param $bForceHTTPS bool True to force HTTPS, false otherwise
* @return string The absolute URL to the current page
*/
static public function GetAbsoluteUrlPath($bForceHTTPS = false)
{
$sAbsoluteUrl = self::GetAbsoluteUrl(false, $bForceHTTPS); // False => Don't get the query string
$sAbsoluteUrl = substr($sAbsoluteUrl, 0, 1+strrpos($sAbsoluteUrl, '/')); // remove the current page, keep just the path, up to the last /
return $sAbsoluteUrl;
}
/**
* Returns the absolute URL to the server's root path
* @param $bForceHTTPS bool True to force HTTPS, false otherwise
* @return string The absolute URL to the server's root, without the first slash
*/
static public function GetAbsoluteUrlRoot($bForceHTTPS = false)
{
$sAbsoluteUrl = self::GetAbsoluteUrl(false, $bForceHTTPS); // False => Don't get the query string
$sServerPos = 3 + strpos($sAbsoluteUrl, '://');
$iFirstSlashPos = strpos($sAbsoluteUrl, '/', $sServerPos);
if ($iFirstSlashPos !== false)
{
$sAbsoluteUrl = substr($sAbsoluteUrl, 0, $iFirstSlashPos); // remove the current page, keep just the path, without the first /
}
return $sAbsoluteUrl;
}
/**
* Tells whether or not log off operation is supported.
* Actually in only one case:
* 1) iTop is using an internal authentication
* 2) the user did not log-in using the "basic" mode (i.e basic authentication) or by passing credentials in the URL
* @return boolean True if logoff is supported, false otherwise
*/
static function CanLogOff()
{
return (isset($_SESSION['login_mode']) && $_SESSION['login_mode'] == 'form');
}
}
?>

View File

@@ -1,4 +1,28 @@
<?php
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* Class WebPage
*
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
/**
* Simple helper class to ease the production of HTML pages
*
@@ -21,6 +45,7 @@ class WebPage
protected $a_include_stylesheets;
protected $a_headers;
protected $a_base;
protected $iNextId;
public function __construct($s_title)
{
@@ -33,6 +58,7 @@ class WebPage
$this->a_linked_stylesheets = array();
$this->a_headers = array();
$this->a_base = array( 'href' => '', 'target' => '');
$this->iNextId = 0;
ob_start(); // Start capturing the output
}
@@ -79,6 +105,14 @@ class WebPage
$this->add($this->GetP($s_html));
}
/**
* Add a pre-formatted text to the body of the page
*/
public function pre($s_html)
{
$this->add('<pre>'.$s_html.'</pre>');
}
/**
* Add a paragraph to the body of the page
*/
@@ -87,6 +121,13 @@ class WebPage
return "<p>$s_html</p>\n";
}
/**
* Adds a tabular content to the web page
* @param Hash $aConfig Configuration of the table: hash array of 'column_id' => 'Column Label'
* @param Hash $aData Hash array. Data to display in the table: each row is made of 'column_id' => Data. A column 'pkey' is expected for each row
* @param Hash $aParams Hash array. Extra parameters for the table.
* @return void
*/
public function table($aConfig, $aData, $aParams = array())
{
$this->add($this->GetTable($aConfig, $aData, $aParams));
@@ -111,13 +152,9 @@ class WebPage
$sHtml .= "<tbody>\n";
foreach($aData as $aRow)
{
if (false) //(isset($aParams['preview']) && $aParams['preview'])
if (isset($aRow['@class'])) // Row specific class, for hilighting certain rows
{
$sHtml .= "<tr id=\"Row_".$iNbTables."_".$aRow['key']."\" onClick=\"DisplayPreview(".$iNbTables.",".$aRow['key'].",'".$aParams['class']."')\">\n";
}
else if (isset($aRow['key']))
{
$sHtml .= "<tr onDblClick=\"DisplayDetails(".$aRow['key'].",'".$aParams['class']."')\">\n";
$sHtml .= "<tr class=\"{$aRow['@class']}\">\n";
}
else
{
@@ -125,17 +162,10 @@ class WebPage
}
foreach($aConfig as $sName=>$aAttribs)
{
$aMatches = array();
$sClass = isset($aAttribs['class']) ? 'class="'.$aAttribs['class'].'"' : '';
if ($sName != 'key')
{
$sValue = ($aRow[$sName] === '') ? '&nbsp;' : $aRow[$sName];
$sHtml .= "<td $sClass>$sValue</td>\n";
}
else
{
$sUIPage = cmdbAbstractObject::ComputeUIPage($aParams['class']);
$sHtml .= "<td><a class=\"no-arrow\" href=\"$sUIPage?operation=details&id=".$aRow['key']."&class=".$aParams['class']."&".$oAppContext->GetForLink()."\"><img src=\"../images/zoom.gif\" title=\"Details\" border=\"0\"></a></td>\n";
}
$sValue = ($aRow[$sName] === '') ? '&nbsp;' : $aRow[$sName];
$sHtml .= "<td $sClass>$sValue</td>\n";
}
$sHtml .= "</tr>\n";
}
@@ -249,6 +279,7 @@ class WebPage
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n";
echo "<html>\n";
echo "<head>\n";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n";
echo "<title>{$this->s_title}</title>\n";
echo $this->get_base_tag();
foreach($this->a_linked_scripts as $s_script)
@@ -329,5 +360,14 @@ class WebPage
}
return $sTag;
}
/**
* Get an ID (for any kind of HTML tag) that is guaranteed unique in this page
* @return int The unique ID (in this page)
*/
public function GetUniqueId()
{
return $this->iNextId++;
}
}
?>
?>

View File

@@ -1,5 +1,29 @@
<?php
require_once('../application/uiwizard.class.inc.php');
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* Class WizardHelper
*
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
require_once(APPROOT.'/application/uiwizard.class.inc.php');
class WizardHelper
{
@@ -15,13 +39,19 @@ class WizardHelper
*/
public function GetTargetObject($bReadUploadedFiles = false)
{
$oObj = MetaModel::NewObject($this->m_aData['m_sClass']);
foreach($this->m_aData['m_aCurrentValues'] as $iIndex => $value)
if (isset($this->m_aData['m_oCurrentValues']['id']))
{
$oObj = MetaModel::GetObject($this->m_aData['m_sClass'], $this->m_aData['m_oCurrentValues']['id']);
}
else
{
$oObj = MetaModel::NewObject($this->m_aData['m_sClass']);
}
foreach($this->m_aData['m_oCurrentValues'] as $sAttCode => $value)
{
$sAttCode = array_search($iIndex, $this->m_aData['m_oFieldsMap']);
// Because this is stored in a Javascript array, unused indexes
// are filled with null values
if ( ($sAttCode !== false) && ($value !== null))
// are filled with null values and unused keys (stored as strings) contain $$NULL$$
if ( ($sAttCode !='id') && ($sAttCode !== false) && ($value !== null) && ($value !== '$$NULL$$'))
{
$oAttDef = MetaModel::GetAttributeDef($this->m_aData['m_sClass'], $sAttCode);
if (($oAttDef->IsLinkSet()) && ($value != '') )
@@ -46,7 +76,7 @@ class WizardHelper
if ( isset($aLinkedObject[$sLinkedAttCode]) && ($aLinkedObject[$sLinkedAttCode] !== null) )
{
$sLinkedAttDef = MetaModel::GetAttributeDef($sLinkedClass, $sLinkedAttCode);
if (($sLinkedAttDef->IsExternalKey()) && ($aLinkedObject[$sLinkedAttCode] != '') )
if (($sLinkedAttDef->IsExternalKey()) && ($aLinkedObject[$sLinkedAttCode] != '') && ($aLinkedObject[$sLinkedAttCode] != 0) )
{
// For external keys: load the target object so that external fields
// get filled too
@@ -104,7 +134,6 @@ class WizardHelper
// Protect against a request for a non existing field
if (isset($this->m_aData['m_oFieldsMap'][$sAttCode]))
{
$iIndex = $this->m_aData['m_oFieldsMap'][$sAttCode];
$oAttDef = MetaModel::GetAttributeDef($this->m_aData['m_sClass'], $sAttCode);
if ($oAttDef->GetEditClass() == 'List')
{
@@ -124,13 +153,13 @@ class WizardHelper
}
$aData[] = $aRow;
}
$this->m_aData['m_aDefaultValue'][$iIndex] = json_encode($aData);
$this->m_aData['m_oDefaultValue'][$sAttCode] = json_encode($aData);
}
else
{
// Normal handling for all other scalar attributes
$this->m_aData['m_aDefaultValue'][$iIndex] = $value;
$this->m_aData['m_oDefaultValue'][$sAttCode] = $value;
}
}
}
@@ -145,8 +174,7 @@ class WizardHelper
// Protect against a request for a non existing field
if (isset($this->m_aData['m_oFieldsMap'][$sAttCode]))
{
$iIndex = $this->m_aData['m_oFieldsMap'][$sAttCode];
$this->m_aData['m_aAllowedValues'][$iIndex] = $sHtml;
$this->m_aData['m_oAllowedValues'][$sAttCode] = $sHtml;
}
}
@@ -199,9 +227,22 @@ class WizardHelper
return $this->m_aData['m_sClass'];
}
public function GetFormPrefix()
{
return $this->m_aData['m_sFormPrefix'];
}
public function GetIdForField($sFieldName)
{
return $this->m_aData['m_oFieldsMap'][$sFieldName];
$sResult = '';
// It may happen that the field we'd like to update does not
// exist in the form. For example, if the field should be hidden/read-only
// in the current state of the object
if (isset($this->m_aData['m_oFieldsMap'][$sFieldName]))
{
$sResult = $this->m_aData['m_oFieldsMap'][$sFieldName];
}
return $sResult;
}
static function ParseJsonSet($oMe, $sLinkClass, $sExtKeyToMe, $sJsonSet)

View File

@@ -1,28 +1,92 @@
<?php
require_once("../application/webpage.class.inc.php");
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* Class XMLPage
*
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
require_once(APPROOT."/application/webpage.class.inc.php");
/**
* Simple web page with no includes or fancy formatting, useful to generateXML documents
* The page adds the content-type text/XML and the encoding into the headers
*/
class XMLPage extends WebPage
{
function __construct($s_title)
/**
* For big XML files, it's better NOT to store everything in memory and output the XML piece by piece
*/
var $m_bPassThrough;
var $m_bHeaderSent;
function __construct($s_title, $bPassThrough = false)
{
parent::__construct($s_title);
$this->add_header("Content-type: text/xml; charset=utf-8");
$this->m_bPassThrough = $bPassThrough;
$this->m_bHeaderSent = false;
$this->add_header("Content-type: text/xml; charset=utf-8");
$this->add_header("Cache-control: no-cache");
$this->add_header("Content-location: export.xml");
$this->add("<?xml version=\"1.0\" encoding=\"UTF-8\"?".">\n");
}
public function output()
{
$this->add_header("Content-Length: ".strlen(trim($this->s_content)));
foreach($this->a_headers as $s_header)
{
header($s_header);
}
echo trim($this->s_content);
if (!$this->m_bPassThrough)
{
$this->add("<?xml version=\"1.0\" encoding=\"UTF-8\"?".">\n");
$this->add_header("Content-Length: ".strlen(trim($this->s_content)));
foreach($this->a_headers as $s_header)
{
header($s_header);
}
echo trim($this->s_content);
}
}
public function add($sText)
{
if (!$this->m_bPassThrough)
{
parent::add($sText);
}
else
{
if ($this->m_bHeaderSent)
{
echo $sText;
}
else
{
$s_captured_output = ob_get_contents();
ob_end_clean();
foreach($this->a_headers as $s_header)
{
header($s_header);
}
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?".">\n";
echo trim($s_captured_output);
echo trim($this->s_content);
echo $sText;
$this->m_bHeaderSent = true;
}
}
}
public function small_p($sText)

3
approot.inc.php Normal file
View File

@@ -0,0 +1,3 @@
<?php
define('APPROOT', dirname(__FILE__).'/');
?>

View File

@@ -1,305 +0,0 @@
<?php
////////////////////////////////////////////////////////////////////////////////////
/**
* A Change Ticket
*/
////////////////////////////////////////////////////////////////////////////////////
class bizChangeTicket extends cmdbAbstractObject
{
public static function Init()
{
$aParams = array
(
"category" => "bizmodel,searchable",
"name" => "Change",
"description" => "Change ticket",
"key_type" => "autoincrement",
"key_label" => "id",
"name_attcode" => "name",
"state_attcode" => "ticket_status",
"reconc_keys" => array("title"),
"db_table" => "change_ticket",
"db_key_field" => "id",
"db_finalclass_field" => "",
"display_template" => "../business/templates/change.html",
);
MetaModel::Init_Params($aParams);
//MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeString("name", array("label"=>"Ticket Ref", "description"=>"Refence number ofr this change", "allowed_values"=>null, "sql"=>"name", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("title", array("label"=>"Title", "description"=>"Overview of the Change", "allowed_values"=>null, "sql"=>"title", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("type", array("label"=>"Change Type", "description"=>"Type of the Change", "allowed_values"=>new ValueSetEnum("Routine, Normal, Emergency"), "sql"=>"type", "default_value"=>"Routine", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("domain", array("label"=>"Domain", "description"=>"Domain for the Change", "allowed_values"=>new ValueSetEnum("Network,Server,Desktop,Application"), "sql"=>"domain", "default_value"=>"Desktop", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("reason", array("label"=>"Reason For Change", "description"=>"Reason for the Change", "allowed_values"=>null, "sql"=>"reason", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalKey("requestor_id", array("targetclass"=>"bizPerson", "jointype"=> "", "label"=>"Requestor", "description"=>"who is requesting this change", "allowed_values"=>new ValueSetObjects('SELECT bizPerson AS p WHERE p.org_id = :this->org_id'), "sql"=>"requestor_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array("org_id"))));
MetaModel::Init_AddAttribute(new AttributeExternalField("requestor_mail", array("label"=>"Requestor", "description"=>"mail of user requesting this change", "allowed_values"=>null, "extkey_attcode"=> 'requestor_id', "target_attcode"=>"email")));
MetaModel::Init_AddAttribute(new AttributeExternalKey("org_id", array("targetclass"=>"bizOrganization", "label"=>"Customer", "description"=>"who is impacted by the ticket", "allowed_values"=>null, "sql"=>"customer", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("customer_name", array("label"=>"Customer", "description"=>"Name of the customer impacted by this ticket", "allowed_values"=>null, "extkey_attcode"=> 'org_id', "target_attcode"=>"name")));
MetaModel::Init_AddAttribute(new AttributeEnum("ticket_status", array("label"=>"Status", "description"=>"Status of the ticket", "allowed_values"=>new ValueSetEnum("New, Validated,Rejected,Assigned,PlannedScheduled,Approved,NotApproved,Implemented,Monitored, Closed"), "sql"=>"change_status", "default_value"=>"New", "is_null_allowed"=>false, "depends_on"=>array())));
// SetPossibleValues("status",array("Open","Monitored","Closed"));
MetaModel::Init_AddAttribute(new AttributeDate("creation_date", array("label"=>"Creation Date", "description"=>"Change creation date", "allowed_values"=>null, "sql"=>"creation_date", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
// définir une date de défaut à maintenant, alias creation ou modification du ticket
MetaModel::Init_AddAttribute(new AttributeDate("last_update", array("label"=>"Last Update", "description"=>"last time the Ticket was modified", "allowed_values"=>null, "sql"=>"last_update", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeDate("start_date", array("label"=>"Start Date", "description"=>"Time the change is expected to start", "allowed_values"=>null, "sql"=>"start_date", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeDate("end_date", array("label"=>"End Date", "description"=>"Date when the change is supposed to end", "allowed_values"=>null, "sql"=>"end_date", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeDate("close_date", array("label"=>"Closure Date", "description"=>"Date when the Ticket was closed", "allowed_values"=>null, "sql"=>"closed_date", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("impact", array("label"=>"Risk Assessment", "description"=>"Impact of the change", "allowed_values"=>null, "sql"=>"impact", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalKey("workgroup_id", array("targetclass"=>"bizWorkgroup", "jointype"=> "", "label"=>"Workgroup", "description"=>"which workgroup is owning ticket", "allowed_values"=>null, "sql"=>"workgroup_id", "is_null_allowed"=>true, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("workgroup_name", array("label"=>"Workgroup", "description"=>"name of workgroup managing the Ticket", "allowed_values"=>null, "extkey_attcode"=> 'workgroup_id', "target_attcode"=>"name")));
MetaModel::Init_AddAttribute(new AttributeExternalKey("agent_id", array("targetclass"=>"bizPerson", "jointype"=> "", "label"=>"Agent", "description"=>"who is managing the ticket", "allowed_values"=>new ValueSetObjects('SELECT bizPerson AS p JOIN lnkContactTeam AS l ON l.contact_id=p.id JOIN bizTeam AS t ON l.team_id=t.id JOIN bizWorkgroup AS w ON w.team_id=t.id WHERE w.id = :this->workgroup_id'), "sql"=>"agent_id", "is_null_allowed"=>true, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array('workgroup_id'))));
MetaModel::Init_AddAttribute(new AttributeExternalField("agent_mail", array("label"=>"Agent", "description"=>"name of agent managing the Ticket", "allowed_values"=>null, "extkey_attcode"=> 'agent_id', "target_attcode"=>"email")));
MetaModel::Init_AddAttribute(new AttributeExternalKey("supervisorgroup_id", array("targetclass"=>"bizWorkgroup", "jointype"=> "", "label"=>"Supervisor Group", "description"=>"which workgroup is supervising ticket", "allowed_values"=>null, "sql"=>"supervisorgroup_id", "is_null_allowed"=>true, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("supervisorgroup_name", array("label"=>"Supervisor Group", "description"=>"name of the group supervising the Ticket", "allowed_values"=>null, "extkey_attcode"=> 'supervisorgroup_id', "target_attcode"=>"name")));
MetaModel::Init_AddAttribute(new AttributeExternalKey("supervisor_id", array("targetclass"=>"bizPerson", "jointype"=> "", "label"=>"Supervisor", "description"=>"who is managing the ticket", "allowed_values"=>new ValueSetObjects('SELECT bizPerson AS p JOIN lnkContactTeam AS l ON l.contact_id=p.id JOIN bizTeam AS t ON l.team_id=t.id JOIN bizWorkgroup AS w ON w.team_id=t.id WHERE w.id = :this->supervisorgroup_id'), "sql"=>"supervisor_id", "is_null_allowed"=>true, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array('supervisorgroup_id'))));
MetaModel::Init_AddAttribute(new AttributeExternalField("supervisor_mail", array("label"=>"Supervisor", "description"=>"name of agent supervising the Ticket", "allowed_values"=>null, "extkey_attcode"=> 'supervisor_id', "target_attcode"=>"email")));
MetaModel::Init_AddAttribute(new AttributeExternalKey("managergroup_id", array("targetclass"=>"bizWorkgroup", "jointype"=> "", "label"=>"Manager Group", "description"=>"which workgroup is approving ticket", "allowed_values"=>null, "sql"=>"managergroup_id", "is_null_allowed"=>true, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("managergroup_name", array("label"=>"Manager Group", "description"=>"name of workgroup approving the Ticket", "allowed_values"=>null, "extkey_attcode"=> 'managergroup_id', "target_attcode"=>"name")));
MetaModel::Init_AddAttribute(new AttributeExternalKey("manager_id", array("targetclass"=>"bizPerson", "jointype"=> "", "label"=>"Manager", "description"=>"who is approving the ticket", "allowed_values"=>new ValueSetObjects('SELECT bizPerson AS p JOIN lnkContactTeam AS l ON l.contact_id=p.id JOIN bizTeam AS t ON l.team_id=t.id JOIN bizWorkgroup AS w ON w.team_id=t.id WHERE w.id = :this->managergroup_id'), "sql"=>"manager_id", "is_null_allowed"=>true, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array('managergroup_id'))));
MetaModel::Init_AddAttribute(new AttributeExternalField("manager_mail", array("label"=>"Manager", "description"=>"name of agent approving the Ticket", "allowed_values"=>null, "extkey_attcode"=> 'manager_id', "target_attcode"=>"email")));
MetaModel::Init_AddAttribute(new AttributeEnum("outage", array("label"=>"Planned Outage", "description"=>"Flag to define if there is a planned outage", "allowed_values"=>new ValueSetEnum("Yes,No"), "sql"=>"outage", "default_value"=>"No", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("change_request", array("label"=>"Change Request", "description"=>"Description of Change required", "allowed_values"=>null, "sql"=>"change_req", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("change_log", array("label"=>"Implementation Log", "description"=>"List all action performed during the change", "allowed_values"=>null, "sql"=>"change_log", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("fallback", array("label"=>"Fallback Plan", "description"=>"Instruction to come back to former situation", "allowed_values"=>null, "sql"=>"fallback", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeInteger("assignment_count", array("label"=>"Assignment Count", "description"=>"Number of times this ticket was assigned or reassigned", "allowed_values"=>null, "sql"=>"assignment_count", "default_value"=>0, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeLinkedSetIndirect("impacted_infra_manual", array("label"=>"Impacted Infrastructure", "description"=>"CIs that are impacted by this change", "linked_class"=>"lnkInfraChangeTicket", "ext_key_to_me"=>"ticket_id", "ext_key_to_remote"=>"infra_id", "allowed_values"=>null, "count_min"=>1, "count_max"=>0, "depends_on"=>array())));
//MetaModel::Init_InheritFilters();
MetaModel::Init_AddFilterFromAttribute("name");
MetaModel::Init_AddFilterFromAttribute("title");
MetaModel::Init_AddFilterFromAttribute("type");
MetaModel::Init_AddFilterFromAttribute("domain");
MetaModel::Init_AddFilterFromAttribute("org_id");
MetaModel::Init_AddFilterFromAttribute("requestor_id");
MetaModel::Init_AddFilterFromAttribute("ticket_status");
MetaModel::Init_AddFilterFromAttribute("creation_date");
MetaModel::Init_AddFilterFromAttribute("start_date");
MetaModel::Init_AddFilterFromAttribute("last_update");
MetaModel::Init_AddFilterFromAttribute("end_date");
MetaModel::Init_AddFilterFromAttribute("close_date");
MetaModel::Init_AddFilterFromAttribute("workgroup_id");
MetaModel::Init_AddFilterFromAttribute("workgroup_name");
MetaModel::Init_AddFilterFromAttribute("supervisorgroup_id");
MetaModel::Init_AddFilterFromAttribute("managergroup_id");
MetaModel::Init_AddFilterFromAttribute("supervisor_id");
MetaModel::Init_AddFilterFromAttribute("manager_id");
MetaModel::Init_AddFilterFromAttribute("agent_id");
MetaModel::Init_AddFilterFromAttribute("impact");
MetaModel::Init_AddFilterFromAttribute("assignment_count");
MetaModel::Init_AddFilterFromAttribute("outage");
// doit-on aussi ajouter un filtre sur les extfields lié à une extkey ? ici le name de l'agent?
// Display lists
MetaModel::Init_SetZListItems('details', array('name','title', 'org_id','type','domain','requestor_id','change_request','ticket_status', 'outage','impact', 'last_update', 'start_date','end_date', 'assignment_count', 'workgroup_id','agent_id','supervisorgroup_id','supervisor_id','managergroup_id','manager_id','change_log','fallback')); // Attributes to be displayed for a list
MetaModel::Init_SetZListItems('list', array('name', 'title', 'org_id', 'ticket_status','outage','start_date','type')); // Attributes to be displayed for a list
// Search criteria
MetaModel::Init_SetZListItems('standard_search', array('name', 'title', 'org_id', 'ticket_status','type', 'outage','requestor_id','workgroup_id','agent_id')); // Criteria of the std search form
MetaModel::Init_SetZListItems('advanced_search', array('name', 'title', 'org_id', 'ticket_status','type', 'outage','workgroup_id','agent_id')); // Criteria of the advanced search form
// State machine
MetaModel::Init_DefineState("New", array("label"=>"New (Unassigned)", "description"=>"Newly created ticket", "attribute_inherit"=>null,
"attribute_list"=>array('name' => OPT_ATT_READONLY,'org_id' => OPT_ATT_MANDATORY, 'title' => OPT_ATT_MANDATORY, 'reason' => OPT_ATT_MANDATORY, 'impacted_infra_manual' => OPT_ATT_MANDATORY,
'assignment_count' => OPT_ATT_HIDDEN, 'end_date' => OPT_ATT_HIDDEN, 'workgroup_id' => OPT_ATT_HIDDEN, 'supervisorgroup_id' => OPT_ATT_HIDDEN, 'managergroup_id' => OPT_ATT_HIDDEN, 'supervisor_id' => OPT_ATT_HIDDEN, 'manager_id' => OPT_ATT_HIDDEN, 'agent_id' => OPT_ATT_HIDDEN )));
MetaModel::Init_DefineState("Validated", array("label"=>"Validated", "description"=>"Ticket is validated", "attribute_inherit"=>null,
"attribute_list"=>array('name' => OPT_ATT_READONLY,'org_id' => OPT_ATT_READONLY,'change_request' => OPT_ATT_READONLY,'creation_date' => OPT_ATT_READONLY, 'title' => OPT_ATT_READONLY, 'reason' => OPT_ATT_READONLY, 'impacted_infra_manual' => OPT_ATT_MANDATORY,
'assignment_count' => OPT_ATT_HIDDEN, 'end_date' => OPT_ATT_HIDDEN, 'workgroup_id' => OPT_ATT_MUSTCHANGE, 'supervisorgroup_id' => OPT_ATT_MUSTCHANGE, 'managergroup_id' => OPT_ATT_MUSTCHANGE, 'supervisor_id' => OPT_ATT_HIDDEN, 'manager_id' => OPT_ATT_HIDDEN, 'agent_id' => OPT_ATT_HIDDEN)));
MetaModel::Init_DefineState("Rejected", array("label"=>"Rejected", "description"=>"This ticket is not approved", "attribute_inherit"=>null,
"attribute_list"=>array('name' => OPT_ATT_READONLY, 'org_id' => OPT_ATT_READONLY,'creation_date' => OPT_ATT_READONLY,'assignment_count' => OPT_ATT_HIDDEN, 'end_date' => OPT_ATT_HIDDEN)));
MetaModel::Init_DefineState("Assigned", array("label"=>"Assigned", "description"=>"Ticket is assigned", "attribute_inherit"=>null,
"attribute_list"=>array('name' => OPT_ATT_READONLY,'org_id' => OPT_ATT_READONLY,'change_request' => OPT_ATT_READONLY,'creation_date' => OPT_ATT_READONLY, 'title' => OPT_ATT_READONLY, 'reason' => OPT_ATT_READONLY, 'impacted_infra_manual' => OPT_ATT_MANDATORY,
'assignment_count' => OPT_ATT_HIDDEN, 'end_date' => OPT_ATT_HIDDEN, 'workgroup_id' => OPT_ATT_MANDATORY, 'supervisorgroup_id' => OPT_ATT_MANDATORY, 'managergroup_id' => OPT_ATT_MANDATORY, 'supervisor_id' => OPT_ATT_MUSTCHANGE, 'manager_id' => OPT_ATT_MUSTCHANGE, 'agent_id' => OPT_ATT_MUSTCHANGE)));
MetaModel::Init_DefineState("PlannedScheduled", array("label"=>"Planned&Scheduled", "description"=>"Evaluation is done for this change", "attribute_inherit"=>null,
"attribute_list"=>array('name' => OPT_ATT_READONLY, 'org_id' => OPT_ATT_READONLY,'assignment_count' => OPT_ATT_HIDDEN,'start_date' => OPT_ATT_MANDATORY, 'end_date' => OPT_ATT_MANDATORY, 'impact' => OPT_ATT_MANDATORY, 'workgroup_id' => OPT_ATT_READONLY,'supervisorgroup_id' => OPT_ATT_READONLY, 'managergroup_id' => OPT_ATT_READONLY, 'supervisor_id' => OPT_ATT_MANDATORY, 'manager_id' => OPT_ATT_MANDATORY, 'agent_id' => OPT_ATT_MANDATORY, 'change_log' => OPT_ATT_MANDATORY,'fallback' => OPT_ATT_MANDATORY,'title' => OPT_ATT_READONLY, 'reason' => OPT_ATT_READONLY,'type' => OPT_ATT_READONLY,'requestor_id' => OPT_ATT_READONLY,'domain' => OPT_ATT_READONLY,'change_request' => OPT_ATT_READONLY,'creation_date' => OPT_ATT_READONLY)));
MetaModel::Init_DefineState("Approved", array("label"=>"Approved", "description"=>"Ticket is approved by CAB", "attribute_inherit"=>null,
"attribute_list"=>array('name' => OPT_ATT_READONLY, 'org_id' => OPT_ATT_READONLY,'outage' => OPT_ATT_READONLY,'assignment_count' => OPT_ATT_HIDDEN,'start_date' => OPT_ATT_READONLY, 'end_date' => OPT_ATT_MANDATORY, 'impact' => OPT_ATT_READONLY, 'workgroup_id' => OPT_ATT_READONLY,'supervisorgroup_id' => OPT_ATT_READONLY, 'managergroup_id' => OPT_ATT_READONLY, 'supervisor_id' => OPT_ATT_READONLY, 'manager_id' => OPT_ATT_READONLY, 'agent_id' => OPT_ATT_MANDATORY, 'change_log' => OPT_ATT_MANDATORY,'fallback' => OPT_ATT_MANDATORY,'title' => OPT_ATT_READONLY, 'reason' => OPT_ATT_READONLY,'type' => OPT_ATT_READONLY,'requestor_id' => OPT_ATT_READONLY,'domain' => OPT_ATT_READONLY,'change_request' => OPT_ATT_READONLY,'creation_date' => OPT_ATT_READONLY)));
MetaModel::Init_DefineState("NotApproved", array("label"=>"Not Approved", "description"=>"Ticket has not been approved by CAB", "attribute_inherit"=>null,
"attribute_list"=>array('name' => OPT_ATT_READONLY, 'org_id' => OPT_ATT_READONLY,'outage' => OPT_ATT_READONLY,'assignment_count' => OPT_ATT_HIDDEN,'start_date' => OPT_ATT_READONLY, 'end_date' => OPT_ATT_MANDATORY, 'impact' => OPT_ATT_READONLY, 'workgroup_id' => OPT_ATT_READONLY,'supervisorgroup_id' => OPT_ATT_READONLY, 'managergroup_id' => OPT_ATT_READONLY, 'supervisor_id' => OPT_ATT_READONLY, 'manager_id' => OPT_ATT_READONLY, 'agent_id' => OPT_ATT_MANDATORY, 'change_log' => OPT_ATT_MANDATORY,'fallback' => OPT_ATT_MANDATORY,'title' => OPT_ATT_READONLY, 'reason' => OPT_ATT_READONLY,'type' => OPT_ATT_READONLY,'requestor_id' => OPT_ATT_READONLY,'domain' => OPT_ATT_READONLY,'change_request' => OPT_ATT_READONLY,'creation_date' => OPT_ATT_READONLY)));
MetaModel::Init_DefineState("Implemented", array("label"=>"Implementation", "description"=>"Work is in progress for this ticket", "attribute_inherit"=>null,
"attribute_list"=>array('name' => OPT_ATT_READONLY, 'org_id' => OPT_ATT_READONLY,'assignment_count' => OPT_ATT_HIDDEN,'start_date' => OPT_ATT_READONLY,'outage' => OPT_ATT_READONLY, 'end_date' => OPT_ATT_MANDATORY, 'impact' => OPT_ATT_READONLY, 'workgroup_id' => OPT_ATT_READONLY,'supervisorgroup_id' => OPT_ATT_READONLY, 'managergroup_id' => OPT_ATT_READONLY, 'supervisor_id' => OPT_ATT_READONLY, 'manager_id' => OPT_ATT_READONLY, 'agent_id' => OPT_ATT_MANDATORY, 'change_log' => OPT_ATT_MANDATORY,'fallback' => OPT_ATT_MANDATORY,'title' => OPT_ATT_READONLY, 'reason' => OPT_ATT_READONLY,'type' => OPT_ATT_READONLY,'requestor_id' => OPT_ATT_READONLY,'domain' => OPT_ATT_READONLY,'change_request' => OPT_ATT_READONLY,'creation_date' => OPT_ATT_READONLY)));
MetaModel::Init_DefineState("Monitored", array("label"=>"Monitored", "description"=>"Change performed is now monitored", "attribute_inherit"=>null,
"attribute_list"=>array('name' => OPT_ATT_READONLY, 'org_id' => OPT_ATT_READONLY,'assignment_count' => OPT_ATT_HIDDEN,'start_date' => OPT_ATT_READONLY, 'end_date' => OPT_ATT_READONLY, 'impact' => OPT_ATT_READONLY, 'workgroup_id' => OPT_ATT_READONLY,'supervisorgroup_id' => OPT_ATT_READONLY, 'managergroup_id' => OPT_ATT_READONLY, 'supervisor_id' => OPT_ATT_READONLY, 'manager_id' => OPT_ATT_READONLY, 'agent_id' => OPT_ATT_READONLY, 'change_log' => OPT_ATT_READONLY,'fallback' => OPT_ATT_READONLY,'title' => OPT_ATT_READONLY, 'reason' => OPT_ATT_READONLY,'type' => OPT_ATT_READONLY,'requestor_id' => OPT_ATT_READONLY,'domain' => OPT_ATT_READONLY,'change_request' => OPT_ATT_READONLY,'creation_date' => OPT_ATT_READONLY)));
MetaModel::Init_DefineState("Closed", array("label"=>"Closed", "description"=>"Ticket is closed", "attribute_inherit"=>null, "attribute_list"=>array('name' => OPT_ATT_READONLY,'outage' => OPT_ATT_READONLY,'org_id' => OPT_ATT_READONLY,'assignment_count' => OPT_ATT_HIDDEN,'start_date' => OPT_ATT_READONLY,'end_date' => OPT_ATT_READONLY,'last_update' => OPT_ATT_READONLY,'close_date' => OPT_ATT_READONLY, 'impact' => OPT_ATT_READONLY, 'workgroup_id' => OPT_ATT_READONLY,'supervisorgroup_id' => OPT_ATT_READONLY, 'managergroup_id' => OPT_ATT_READONLY, 'supervisor_id' => OPT_ATT_READONLY, 'manager_id' => OPT_ATT_READONLY, 'agent_id' => OPT_ATT_READONLY, 'change_log' => OPT_ATT_READONLY,'fallback' => OPT_ATT_READONLY,'title' => OPT_ATT_READONLY, 'reason' => OPT_ATT_READONLY,'type' => OPT_ATT_READONLY,'requestor_id' => OPT_ATT_READONLY,'domain' => OPT_ATT_READONLY,'change_request' => OPT_ATT_READONLY,'creation_date' => OPT_ATT_READONLY)));
MetaModel::Init_DefineStimulus("ev_validate", new StimulusUserAction(array("label"=>"Validate this change", "description"=>"Make sure it is a valid change request")));
MetaModel::Init_DefineStimulus("ev_reject", new StimulusUserAction(array("label"=>"Reject this change", "description"=>"This change request is rejected because it is a non valid one")));
MetaModel::Init_DefineStimulus("ev_assign", new StimulusUserAction(array("label"=>"Assign this change", "description"=>"This change request is assigned")));
MetaModel::Init_DefineStimulus("ev_reopen", new StimulusUserAction(array("label"=>"Modify this change", "description"=>"Update change request to make it valid")));
MetaModel::Init_DefineStimulus("ev_plan", new StimulusUserAction(array("label"=>"Plan this change", "description"=>"Plan and Schedule this change for validation")));
MetaModel::Init_DefineStimulus("ev_approve", new StimulusUserAction(array("label"=>"Approve this change", "description"=>"This change is approved by CAB")));
MetaModel::Init_DefineStimulus("ev_replan", new StimulusUserAction(array("label"=>"Update planning and schedule", "description"=>"Modify Plan and Schedule in order to have this change re-validated")));
MetaModel::Init_DefineStimulus("ev_notapprove", new StimulusUserAction(array("label"=>"Not approve this change", "description"=>"This change is not approved by CAB")));
MetaModel::Init_DefineStimulus("ev_implement", new StimulusUserAction(array("label"=>"Implement this change", "description"=>"Implementation pahse for current change")));
MetaModel::Init_DefineStimulus("ev_monitor", new StimulusUserAction(array("label"=>"Monitor this change", "description"=>"Starting monitoring period for this change")));
MetaModel::Init_DefineStimulus("ev_finish", new StimulusUserAction(array("label"=>"Close change", "description"=>"Change is done, and can be closed")));
MetaModel::Init_DefineTransition("New", "ev_validate", array("target_state"=>"Validated", "actions"=>array('SetLastUpDate'), "user_restriction"=>null));
MetaModel::Init_DefineTransition("New", "ev_reject", array("target_state"=>"Rejected", "actions"=>array('SetLastUpDate'), "user_restriction"=>null));
MetaModel::Init_DefineTransition("Rejected", "ev_reopen", array("target_state"=>"New", "actions"=>array('SetLastUpDate'), "user_restriction"=>null));
MetaModel::Init_DefineTransition("Validated", "ev_assign", array("target_state"=>"Assigned", "actions"=>array('SetLastUpDate'), "user_restriction"=>null));
MetaModel::Init_DefineTransition("Assigned", "ev_plan", array("target_state"=>"PlannedScheduled", "actions"=>array('SetLastUpDate'), "user_restriction"=>null));
MetaModel::Init_DefineTransition("PlannedScheduled", "ev_approve", array("target_state"=>"Approved", "actions"=>array('SetLastUpDate'), "user_restriction"=>null));
MetaModel::Init_DefineTransition("PlannedScheduled", "ev_notapprove", array("target_state"=>"NotApproved", "actions"=>array('SetLastUpDate'), "user_restriction"=>null));
MetaModel::Init_DefineTransition("NotApproved", "ev_replan", array("target_state"=>"PlannedScheduled", "actions"=>array('SetLastUpDate'), "user_restriction"=>null));
MetaModel::Init_DefineTransition("Approved", "ev_implement", array("target_state"=>"Implemented", "actions"=>array('SetLastUpDate'), "user_restriction"=>null));
MetaModel::Init_DefineTransition("Implemented", "ev_monitor", array("target_state"=>"Monitored", "actions"=>array('SetLastUpDate'), "user_restriction"=>null));
MetaModel::Init_DefineTransition("Implemented", "ev_finish", array("target_state"=>"Closed", "actions"=>array('SetClosureDate','SetLastUpDate'), "user_restriction"=>null));
MetaModel::Init_DefineTransition("Monitored", "ev_finish", array("target_state"=>"Closed", "actions"=>array('SetClosureDate','SetLastUpDate'), "user_restriction"=>null));
}
public function Generate(cmdbDataGenerator $oGenerator)
{
$this->Set('org_id', $oGenerator->GetOrganizationId());
$this->Set('title', $oGenerator->GenerateString("enum(Site,Server,Line)| |enum(is down,is flip-flopping,is not responding)"));
$this->Set('agent_id', $oGenerator->GenerateKey("bizPerson", array('org_id' =>$oGenerator->GetOrganizationId() )));
$this->Set('ticket_status', $oGenerator->GenerateString("enum(Open,Closed,Closed,Monitored)"));
$this->Set('start_date', $oGenerator->GenerateString("2007-|number(07-12)|-|number(01-30)| |number(07-12)|:|number(00-59)|:|number(00-59)"));
$this->Set('last_update', $oGenerator->GenerateString("2007-|number(07-12)|-|number(01-30)| |number(07-12)|:|number(00-59)|:|number(00-59)"));
$this->Set('end_date', $oGenerator->GenerateString("2007-|number(07-12)|-|number(01-30)| |number(07-12)|:|number(00-59)|:|number(00-59)"));
}
// State machine actions
public function IncrementAssignmentCount($sStimulusCode)
{
$this->Set('assignment_count', $this->Get('assignment_count') + 1);
return true;
}
public function SetClosureDate($sStimulusCode)
{
$this->Set('end_date', time());
return true;
}
public function SetLastUpDate($sStimulusCode)
{
$this->Set('last_update', time());
return true;
}
public function ComputeValues()
{
$iKey = $this->GetKey();
if ($iKey < 0)
{
// Object not yet in the Database
$iKey = MetaModel::GetNextKey(get_class($this));
}
$sName = sprintf('C-%06d', $iKey);
$this->Set('name', $sName);
}
}
////////////////////////////////////////////////////////////////////////////////////
/**
* n-n link between any Infra and a Change Ticket
*/
////////////////////////////////////////////////////////////////////////////////////
class lnkInfraChangeTicket extends cmdbAbstractObject
{
public static function Init()
{
$aParams = array
(
"category" => "bizmodel,searchable",
"name" => "Infra Change Ticket",
"description" => "Infra impacted by a Change ticket",
"key_type" => "autoincrement",
"key_label" => "link_id",
"name_attcode" => "impact", // ????
"state_attcode" => "",
"reconc_keys" => array("impact"), // ????
"db_table" => "infra_changeticket",
"db_key_field" => "link_id",
"db_finalclass_field" => "",
"display_template" => "../business/templates/default.html",
);
MetaModel::Init_Params($aParams);
MetaModel::Init_AddAttribute(new AttributeExternalKey("infra_id", array("targetclass"=>"logInfra", "jointype"=> '', "label"=>"Infrastructure", "description"=>"The infrastructure impacted", "allowed_values"=>null, "sql"=>"infra_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("infra_name", array("label"=>"Infrastructure Name", "description"=>"Name of the impacted infrastructure", "allowed_values"=>null, "extkey_attcode"=> 'infra_id', "target_attcode"=>"name")));
MetaModel::Init_AddAttribute(new AttributeExternalKey("ticket_id", array("targetclass"=>"bizChangeTicket", "jointype"=> '', "label"=>"Ticket", "description"=>"Ticket number", "allowed_values"=>null, "sql"=>"ticket_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("ticket_name", array("label"=>"Ticket Name", "description"=>"Name of the ticket", "allowed_values"=>null, "extkey_attcode"=> 'ticket_id', "target_attcode"=>"title")));
MetaModel::Init_AddAttribute(new AttributeString("impact", array("label"=>"Impact", "description"=>"Level of impact of the infra by the related ticket", "allowed_values"=>null, "sql"=>"impact", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddFilterFromAttribute("infra_id");
MetaModel::Init_AddFilterFromAttribute("ticket_id");
// Display lists
MetaModel::Init_SetZListItems('details', array('infra_id', 'ticket_id', 'impact')); // Attributes to be displayed for a list
MetaModel::Init_SetZListItems('list', array('infra_id', 'ticket_id', 'impact')); // Attributes to be displayed for a list
// Search criteria
MetaModel::Init_SetZListItems('standard_search', array('infra_id', 'ticket_id')); // Criteria of the std search form
MetaModel::Init_SetZListItems('advanced_search', array('infra_id', 'ticket_id')); // Criteria of the advanced search form
}
public function Generate(cmdbDataGenerator $oGenerator)
{
$this->Set('infra_id', $oGenerator->GenerateKey("logInfra", array('org_id' =>$oGenerator->GetOrganizationId() )));
$this->Set('ticket_id', $oGenerator->GenerateKey("bizIncidentTicket", array('org_id' =>$oGenerator->GetOrganizationId() )));
$this->Set('impact', $oGenerator->GenerateString("enum(none,mandatory,partial)"));
}
}
////////////////////////////////////////////////////////////////////////////////////
/**
* n-n link between any contact and a Contract
*/
////////////////////////////////////////////////////////////////////////////////////
class lnkContactChange extends cmdbAbstractObject
{
public static function Init()
{
$aParams = array
(
"category" => "bizmodel,searchable",
"name" => "ContactChangeLink",
"description" => "Contact associated to a change",
"key_type" => "autoincrement",
"key_label" => "link_id",
"name_attcode" => "role", // ????
"state_attcode" => "",
"reconc_keys" => array("role"), // ????
"db_table" => "contact_change",
"db_key_field" => "link_id",
"db_finalclass_field" => "",
"display_template" => "../business/templates/default.html",
);
MetaModel::Init_Params($aParams);
MetaModel::Init_AddAttribute(new AttributeExternalKey("contact_id", array("targetclass"=>"bizContact", "jointype"=> '', "label"=>"Contact", "description"=>"The contact linked to contract", "allowed_values"=>null, "sql"=>"contact_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("contact_mail", array("label"=>"Contact E-mail", "description"=>"Mail for the contact", "allowed_values"=>null, "extkey_attcode"=> 'contact_id', "target_attcode"=>"email")));
MetaModel::Init_AddAttribute(new AttributeExternalKey("change_id", array("targetclass"=>"bizChangeTicket", "jointype"=> '', "label"=>"Change Ticket", "description"=>"Change ticket ID", "allowed_values"=>null, "sql"=>"change_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("change_number", array("label"=>"Change Ticket", "description"=>"Ticket number for this change", "allowed_values"=>null, "extkey_attcode"=> 'change_id', "target_attcode"=>"name")));
MetaModel::Init_AddAttribute(new AttributeString("role", array("label"=>"Role", "description"=>"Role of this contact for this change", "allowed_values"=>null, "sql"=>"role", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddFilterFromAttribute("change_id");
MetaModel::Init_AddFilterFromAttribute("contact_id");
// Display lists
MetaModel::Init_SetZListItems('details', array('change_id', 'contact_id', 'role')); // Attributes to be displayed for a list
MetaModel::Init_SetZListItems('list', array('change_id', 'contact_id', 'role')); // Attributes to be displayed for a list
// Search criteria
MetaModel::Init_SetZListItems('standard_search', array('change_id', 'contact_id')); // Criteria of the std search form
MetaModel::Init_SetZListItems('advanced_search', array('change_id', 'contact_id')); // Criteria of the advanced search form
}
public function Generate(cmdbDataGenerator $oGenerator)
{
$this->Set('contract_id', $oGenerator->GenerateKey("logInfra", array('org_id' =>$oGenerator->GetOrganizationId() )));
$this->Set('contact_id', $oGenerator->GenerateKey("bizIncidentTicket", array('org_id' =>$oGenerator->GetOrganizationId() )));
$this->Set('role', $oGenerator->GenerateString("enum(none,mandatory,partial)"));
}
}
?>

View File

@@ -1,32 +0,0 @@
Changements principaux:
- la classe AbstractObject est sortie du biz model
- join_type remplacé par is_null_allowed (placé à la fin pour être + facile à retrouver)
- j'ai enlevé toute la classe logLocatedObject qui était en commentaire
- Enlevé 'address' de l'advanced search sur une location car ce n'est plus un critère de recherche possible (remplacé par country)
- Ajouté des critères de recherche sur bizCircuit
- Ajouté les ZList sur bizCircuit
- Ajouté les Zlist pour bizInterface
- Ajouté les Zlist pour lnkInfraInfra
- Ajouté les Zlist pour lnkInfraTicket
Dans AbstractObject: désactivé l'affichage des contacts liés qui ne marche pas pour les tickets.
Bug fix ?
- J'ai rajouté un blindage if (is_object($proposedValue) &&... dans AttributeDate::MakeRealValue mais je ne comprends pas d' sort la classe DateTime... et pourtant il y en a...
Améliorations:
- Ajouter une vérification des ZList (les attributs/critèresde recherche déclarés dans la liste existent-ils pour cet objet)
Ne marche pas:
- Objets avec des clefs externes vides
- Enums !!!!
Data Generator:
Organization '1' updated.
5 Location objects created.
19 PC objects created.
19 Network Device objects created.
42 Person objects created.
6 Incident objects created.
17 Infra Group objects created.
34 Infra Infra objects created.

View File

@@ -1,163 +0,0 @@
<?php
////////////////////////////////////////////////////////////////////////////////////
/**
* Description of known error
*/
////////////////////////////////////////////////////////////////////////////////////
class bizKnownError extends cmdbAbstractObject
{
public static function Init()
{
$aParams = array
(
"category" => "bizmodel,searchable",
"name" => "Known Error",
"description" => "Error documented for a known issue",
"key_type" => "autoincrement",
"key_label" => "id",
"name_attcode" => "name",
"state_attcode" => "",
"reconc_keys" => array("org_id", "name"), // inherited attributes
"db_table" => "known_error",
"db_key_field" => "id",
"db_finalclass_field" => "",
"display_template" => "../business/templates/knownError.html",
);
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeString("name", array("label"=>"Name", "description"=>"Name to identify this error", "allowed_values"=>null, "sql"=>"name", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalKey("org_id", array("targetclass"=>"bizOrganization", "label"=>"Organization", "description"=>"Organization for this known error", "allowed_values"=>null, "sql"=>"cust_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("cust_name", array("label"=>"Organization", "description"=>"Company / Department owning this object", "allowed_values"=>null, "extkey_attcode"=> 'org_id', "target_attcode"=>"name")));
MetaModel::Init_AddAttribute(new AttributeText("symptom", array("label"=>"Symptom", "description"=>"Description of this error", "allowed_values"=>null, "sql"=>"symptom", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("root_cause", array("label"=>"Root cause", "description"=>"Original cause for this known error", "allowed_values"=>null, "sql"=>"rootcause", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("workaround", array("label"=>"Workaround", "description"=>"Work around to fix this error", "allowed_values"=>null, "sql"=>"workaround", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("solution", array("label"=>"Solution", "description"=>"Description of this contract", "allowed_values"=>null, "sql"=>"solution", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("error_code", array("label"=>"Error Code", "description"=>"Key word to identify error", "allowed_values"=>null, "sql"=>"error_code", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeEnum("domain", array("label"=>"Domain", "description"=>"Domain for this known error, network, desktop, ...", "allowed_values"=>new ValueSetEnum("Network, Server, Application, Desktop"), "sql"=>"domain", "default_value"=>"Application", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("vendor", array("label"=>"Vendor", "description"=>"Vendor concerned by this known error", "allowed_values"=>null, "sql"=>"vendor", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("model", array("label"=>"Model", "description"=>"Model concerned by this known error, it may be an application, a device ...", "allowed_values"=>null, "sql"=>"model", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("version", array("label"=>"Version", "description"=>"Version related to model impacted by known error", "allowed_values"=>null, "sql"=>"version", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_InheritFilters();
MetaModel::Init_AddFilterFromAttribute("name");
MetaModel::Init_AddFilterFromAttribute("org_id");
MetaModel::Init_AddFilterFromAttribute("cust_name");
MetaModel::Init_AddFilterFromAttribute("error_code");
MetaModel::Init_AddFilterFromAttribute("domain");
MetaModel::Init_SetZListItems('details', array('name', 'org_id','error_code','domain','vendor','model','version', 'symptom','root_cause','workaround','solution')); // Attributes to be displayed for the complete details
MetaModel::Init_SetZListItems('list', array('name', 'org_id','error_code', 'symptom')); // Attributes to be displayed for a list
// Search criteria
MetaModel::Init_SetZListItems('standard_search', array('name', 'error_code','domain')); // Criteria of the std search form
MetaModel::Init_SetZListItems('advanced_search', array('name', 'org_id','error_code', 'error_code','symptom')); // Criteria of the advanced search form
}
// State machine actions
public function IncrementVersion($sStimulusCode)
{
$this->Set('version_number', $this->Get('version_number') + 1);
return true;
}
}
////////////////////////////////////////////////////////////////////////////////////
/**
* n-n link between any Infra and a Known Error
*/
////////////////////////////////////////////////////////////////////////////////////
class lnkInfraError extends cmdbAbstractObject
{
public static function Init()
{
$aParams = array
(
"category" => "bizmodel,searchable",
"name" => "InfraErrorLinks",
"description" => "Infra related to a known error",
"key_type" => "autoincrement",
"key_label" => "link_id",
"name_attcode" => "", // ????
"state_attcode" => "",
"reconc_keys" => array("infra_id","error_id"), // ????
"db_table" => "infra_error_links",
"db_key_field" => "link_id",
"db_finalclass_field" => "",
"display_template" => "../business/templates/default.html",
);
MetaModel::Init_Params($aParams);
MetaModel::Init_AddAttribute(new AttributeExternalKey("infra_id", array("targetclass"=>"logInfra", "jointype"=> '', "label"=>"Infrastructure", "description"=>"The infrastructure impacted", "allowed_values"=>null, "sql"=>"infra_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("infra_name", array("label"=>"Infrastructure Name", "description"=>"Name of the impacted infrastructure", "allowed_values"=>null, "extkey_attcode"=> 'infra_id', "target_attcode"=>"name")));
MetaModel::Init_AddAttribute(new AttributeExternalField("infra_status", array("label"=>"Status", "description"=>"Status of the impacted infrastructure", "allowed_values"=>null, "extkey_attcode"=> 'infra_id', "target_attcode"=>"status")));
MetaModel::Init_AddAttribute(new AttributeExternalKey("error_id", array("targetclass"=>"bizKnownError", "jointype"=> '', "label"=>"Error", "description"=>"Error id", "allowed_values"=>null, "sql"=>"error_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("error_name", array("label"=>"Error Name", "description"=>"Name of the error", "allowed_values"=>null, "extkey_attcode"=> 'error_id', "target_attcode"=>"name")));
MetaModel::Init_AddFilterFromAttribute("infra_id");
MetaModel::Init_AddFilterFromAttribute("error_id");
// Display lists
MetaModel::Init_SetZListItems('details', array('infra_id', 'error_id')); // Attributes to be displayed for a list
MetaModel::Init_SetZListItems('list', array('infra_id', 'infra_status','error_id')); // Attributes to be displayed for a list
// Search criteria
MetaModel::Init_SetZListItems('standard_search', array('infra_id', 'error_id')); // Criteria of the std search form
MetaModel::Init_SetZListItems('advanced_search', array('infra_id', 'error_id')); // Criteria of the advanced search form
}
}
////////////////////////////////////////////////////////////////////////////////////
/**
* n-n link between any Contract and a Document
*/
////////////////////////////////////////////////////////////////////////////////////
class lnkDocumentError extends cmdbAbstractObject
{
public static function Init()
{
$aParams = array
(
"category" => "bizmodel,searchable",
"name" => "DocumentsErrorLinks",
"description" => "A link between a document and a known error",
"key_type" => "autoincrement",
"key_label" => "link_id",
"name_attcode" => "link_type",
"state_attcode" => "",
"reconc_keys" => array("doc_name", "error_name"),
"db_table" => "documents_error_link",
"db_key_field" => "link_id",
"db_finalclass_field" => "",
"display_template" => "../business/templates/default.html",
);
MetaModel::Init_Params($aParams);
MetaModel::Init_AddAttribute(new AttributeExternalKey("doc_id", array("targetclass"=>"bizDocument", "label"=>"Document", "description"=>"id of the Document", "allowed_values"=>null, "sql"=>"doc_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("doc_name", array("label"=>"Document Name", "description"=>"name of the document", "allowed_values"=>null, "extkey_attcode"=> 'doc_id', "target_attcode"=>"name")));
MetaModel::Init_AddAttribute(new AttributeExternalKey("error_id", array("targetclass"=>"bizKnownError", "label"=>"Error", "description"=>"Error linked to this document", "allowed_values"=>null, "sql"=>"error_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("error_name", array("label"=>"Error Name", "description"=>"name of the linked error", "allowed_values"=>null, "extkey_attcode"=> 'error_id', "target_attcode"=>"name")));
MetaModel::Init_AddAttribute(new AttributeString("link_type", array("label"=>"Link Type", "description"=>"More information", "allowed_values"=>null, "sql"=>"link_type", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddFilterFromAttribute("doc_id");
MetaModel::Init_AddFilterFromAttribute("doc_name");
MetaModel::Init_AddFilterFromAttribute("error_id");
MetaModel::Init_AddFilterFromAttribute("error_name");
MetaModel::Init_AddFilterFromAttribute("link_type");
// Display lists
MetaModel::Init_SetZListItems('details', array('doc_id', 'error_name', 'link_type')); // Attributes to be displayed for the complete details
MetaModel::Init_SetZListItems('list', array('doc_id', 'error_name', 'link_type')); // Attributes to be displayed for a list
}
}
?>

View File

@@ -1,276 +0,0 @@
<?php
/**
* ServiceDesk.businnes.php
* Define business model for Service Desk module
*
* @package iTopBizModelSamples
* @author Erwan Taloc <erwan.taloc@gmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version 1.1.1.1 $
*/
////////////////////////////////////////////////////////////////////////////////////
/**
* An Incident Ticket
*/
////////////////////////////////////////////////////////////////////////////////////
class bizServiceCall extends cmdbAbstractObject
{
public static function Init()
{
$aParams = array
(
"category" => "bizmodel,searchable",
"name" => "ServiceCall",
"description" => "Service Call from customer",
"key_type" => "autoincrement",
"key_label" => "id",
"name_attcode" => "name",
"state_attcode" => "call_status",
"reconc_keys" => array("title"),
"db_table" => "servicecall",
"db_key_field" => "id",
"db_finalclass_field" => "",
"display_template" => "../business/templates/serviceCall.html",
);
MetaModel::Init_Params($aParams);
//MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeString("name", array("label"=>"Service Call Ref", "description"=>"Refence identifier for this service call", "allowed_values"=>null, "sql"=>"name", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("title", array("label"=>"Title", "description"=>"Overview of the service call", "allowed_values"=>null, "sql"=>"title", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeEnum("type", array("label"=>"Type", "description"=>"Type of the Incident", "allowed_values"=>new ValueSetEnum("Network,Server,Desktop,Application"), "sql"=>"type", "default_value"=>"Server", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalKey("org_id", array("targetclass"=>"bizOrganization", "label"=>"Customer", "description"=>"Customer concerned by this service call", "allowed_values"=>null, "sql"=>"customer", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("customer_name", array("label"=>"Customer", "description"=>"Name of the customer raising this service call", "allowed_values"=>null, "extkey_attcode"=> 'org_id', "target_attcode"=>"name")));
MetaModel::Init_AddAttribute(new AttributeEnum("call_status", array("label"=>"Status", "description"=>"Status of the ticket", "allowed_values"=>new ValueSetEnum("New, Assigned, WorkInProgress,Resolved,Closed"), "sql"=>"call_status", "default_value"=>"New", "is_null_allowed"=>false, "depends_on"=>array())));
// SetPossibleValues("status",array("Open","Monitored","Closed"));
MetaModel::Init_AddAttribute(new AttributeText("call_description", array("label"=>"Description", "description"=>"Description of the call as describe by caller", "allowed_values"=>null, "sql"=>"call_description", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeDate("creation_date", array("label"=>"Creation date", "description"=>"Call creation date", "allowed_values"=>null, "sql"=>"creation_date", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
// définir une date de défaut à maintenant, alias creation ou modification du ticket
MetaModel::Init_AddAttribute(new AttributeDate("last_update", array("label"=>"Last update", "description"=>"last time the call was modified", "allowed_values"=>null, "sql"=>"last_update", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeDate("next_update", array("label"=>"Next update", "description"=>"next time the Ticket is expected to be modified", "allowed_values"=>null, "sql"=>"next_update", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeDate("end_date", array("label"=>"Closure Date", "description"=>"Date when the call was closed", "allowed_values"=>null, "sql"=>"closed_date", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalKey("caller_id", array("targetclass"=>"bizPerson", "jointype"=> "", "label"=>"Caller", "description"=>"person that trigger this call", "allowed_values"=>new ValueSetObjects('SELECT bizPerson AS p WHERE p.org_id = :this->org_id'), "sql"=>"caller_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array('org_id'))));
MetaModel::Init_AddAttribute(new AttributeExternalField("caller_mail", array("label"=>"Caller", "description"=>"Person that trigger this call", "allowed_values"=>null, "extkey_attcode"=> 'caller_id', "target_attcode"=>"email")));
MetaModel::Init_AddAttribute(new AttributeString("impact", array("label"=>"Impact", "description"=>"Impact for this call", "allowed_values"=>null, "sql"=>"impact", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalKey("workgroup_id", array("targetclass"=>"bizWorkgroup", "jointype"=> "", "label"=>"Workgroup", "description"=>"which workgroup is owning call", "allowed_values"=>null, "sql"=>"workgroup_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("workgroup_name", array("label"=>"Workgroup", "description"=>"name of workgroup managing the call", "allowed_values"=>null, "extkey_attcode"=> 'workgroup_id', "target_attcode"=>"name")));
MetaModel::Init_AddAttribute(new AttributeExternalKey("agent_id", array("targetclass"=>"bizPerson", "jointype"=> "", "label"=>"Agent", "description"=>"who is managing the call", "allowed_values"=>new ValueSetObjects('SELECT bizPerson AS p JOIN lnkContactTeam AS l ON l.contact_id=p.id JOIN bizTeam AS t ON l.team_id=t.id JOIN bizWorkgroup AS w ON w.team_id=t.id WHERE w.id = :this->workgroup_id'), "sql"=>"agent_id", "is_null_allowed"=>true, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array("workgroup_id"))));
MetaModel::Init_AddAttribute(new AttributeExternalField("agent_mail", array("label"=>"Agent", "description"=>"mail of agent managing the call", "allowed_values"=>null, "extkey_attcode"=> 'agent_id', "target_attcode"=>"email")));
// Comment afficher le first + last name de l'agent ? Est-ce utile d'ajouter ce champ?
MetaModel::Init_AddAttribute(new AttributeText("action_log", array("label"=>"Action Logs", "description"=>"List all action performed during the call", "allowed_values"=>null, "sql"=>"action_log", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeEnum("severity", array("label"=>"Severity", "description"=>"Field defining the criticity for the call", "allowed_values"=>new ValueSetEnum("critical,medium,low"), "sql"=>"criticity", "default_value"=>"low", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("resolution", array("label"=>"Resolution", "description"=>"Description of the resolution", "allowed_values"=>null, "sql"=>"resolution", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeEnum("source", array("label"=>"Source", "description"=>"source type for this call", "allowed_values"=>new ValueSetEnum("phone,E-mail,Fax"), "sql"=>"source", "default_value"=>"phone", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeLinkedSetIndirect("impacted_infra_manual", array("label"=>"Impacted Infrastructure", "description"=>"CIs that are not meeting the SLA", "linked_class"=>"lnkInfraCall", "ext_key_to_me"=>"call_id", "ext_key_to_remote"=>"infra_id", "allowed_values"=>null, "count_min"=>1, "count_max"=>0, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeLinkedSetIndirect("related_tickets", array("label"=>"Related Incident", "description"=>"Other incident tickets related to this call", "linked_class"=>"lnkCallTicket", "ext_key_to_me"=>"call_id", "ext_key_to_remote"=>"ticket_id", "allowed_values"=>null, "count_min"=>0, "count_max"=>0, "depends_on"=>array(/*'impacted_infra_computed',*/ 'impacted_infra_manual'))));
//MetaModel::Init_InheritFilters();
MetaModel::Init_AddFilterFromAttribute("name");
MetaModel::Init_AddFilterFromAttribute("title");
MetaModel::Init_AddFilterFromAttribute("type");
MetaModel::Init_AddFilterFromAttribute("org_id");
MetaModel::Init_AddFilterFromAttribute("caller_id");
MetaModel::Init_AddFilterFromAttribute("call_status");
MetaModel::Init_AddFilterFromAttribute("creation_date");
MetaModel::Init_AddFilterFromAttribute("last_update");
MetaModel::Init_AddFilterFromAttribute("end_date");
MetaModel::Init_AddFilterFromAttribute("workgroup_id");
MetaModel::Init_AddFilterFromAttribute("agent_id");
MetaModel::Init_AddFilterFromAttribute("severity");
MetaModel::Init_AddFilterFromAttribute("source");
// doit-on aussi ajouter un filtre sur les extfields lié à une extkey ? ici le name de l'agent?
// Display lists
MetaModel::Init_SetZListItems('details', array('name','title', 'org_id', 'type','call_status','source', 'severity','creation_date', 'call_description', 'caller_id', 'impact', 'last_update', 'end_date', 'workgroup_id','agent_id','action_log','resolution')); // Attributes to be displayed for a list
MetaModel::Init_SetZListItems('list', array('name', 'title', 'org_id', 'type','call_status','severity','creation_date')); // Attributes to be displayed for a list
// Search criteria
MetaModel::Init_SetZListItems('standard_search', array('name', 'title', 'org_id','source', 'caller_id','type', 'call_status', 'severity','creation_date', 'last_update','end_date','agent_id')); // Criteria of the std search form
MetaModel::Init_SetZListItems('advanced_search', array('name', 'title', 'org_id', 'caller_id','type', 'call_status', 'severity','creation_date', 'last_update','end_date','agent_id')); // Criteria of the advanced search form
// State machine
MetaModel::Init_DefineState("New", array("label"=>"New (Unassigned)", "description"=>"Newly created call", "attribute_inherit"=>null,
"attribute_list"=>array('name' => OPT_ATT_READONLY, 'end_date' => OPT_ATT_HIDDEN, 'last_update' => OPT_ATT_READONLY,
"title"=>OPT_ATT_MANDATORY, "org_id"=>OPT_ATT_MANDATORY, "caller_id"=>OPT_ATT_MANDATORY, "call_description"=>OPT_ATT_MANDATORY, "creation_date"=>OPT_ATT_MANDATORY, "workgroup_id"=>OPT_ATT_MANDATORY,
"severity"=>OPT_ATT_MANDATORY, "agent_id"=>OPT_ATT_HIDDEN,"impacted_infra_manual"=>OPT_ATT_MANDATORY, "related_tickets"=>OPT_ATT_MUSTPROMPT)));
MetaModel::Init_DefineState("Assigned", array("label"=>"Assigned", "description"=>"Call is assigned to somebody", "attribute_inherit"=>null,
"attribute_list"=>array('name' => OPT_ATT_READONLY, "title"=>OPT_ATT_READONLY, "org_id"=>OPT_ATT_READONLY,"source"=>OPT_ATT_READONLY, "caller_id"=>OPT_ATT_READONLY, "call_description"=>OPT_ATT_READONLY, "creation_date"=>OPT_ATT_READONLY,'end_date' => OPT_ATT_HIDDEN, "workgroup_id"=>OPT_ATT_READONLY, "agent_id"=>OPT_ATT_MUSTCHANGE)));
MetaModel::Init_DefineState("WorkInProgress", array("label"=>"Work In Progress", "description"=>"Work is in progress", "attribute_inherit"=>null, "attribute_list"=>array('name' => OPT_ATT_READONLY, 'end_date' => OPT_ATT_HIDDEN, 'last_update' => OPT_ATT_READONLY,
"title"=>OPT_ATT_READONLY, "org_id"=>OPT_ATT_READONLY,"source"=>OPT_ATT_READONLY, "caller_id"=>OPT_ATT_READONLY, "call_description"=>OPT_ATT_READONLY, "creation_date"=>OPT_ATT_READONLY, "workgroup_id"=>OPT_ATT_READONLY,
"severity"=>OPT_ATT_MANDATORY, "agent_id"=>OPT_ATT_MANDATORY,"action_log"=>OPT_ATT_MUSTPROMPT,"impacted_infra_manual"=>OPT_ATT_MANDATORY, "related_tickets"=>OPT_ATT_MUSTPROMPT)));
MetaModel::Init_DefineState("Resolved", array("label"=>"Resolved", "description"=>"Call is resolved", "attribute_inherit"=>null, "attribute_list"=>array('name' => OPT_ATT_READONLY, 'end_date' => OPT_ATT_HIDDEN, 'last_update' => OPT_ATT_READONLY,
"title"=>OPT_ATT_READONLY, "org_id"=>OPT_ATT_READONLY, "source"=>OPT_ATT_READONLY,"caller_id"=>OPT_ATT_READONLY, "call_description"=>OPT_ATT_READONLY, "creation_date"=>OPT_ATT_READONLY, "workgroup_id"=>OPT_ATT_READONLY,
"severity"=>OPT_ATT_READONLY, "agent_id"=>OPT_ATT_READONLY,"action_log"=>OPT_ATT_READONLY,"impacted_infra_manual"=>OPT_ATT_MANDATORY, "related_tickets"=>OPT_ATT_MUSTPROMPT, "resolution"=>OPT_ATT_MUSTCHANGE)));
MetaModel::Init_DefineState("Closed", array("label"=>"Closed", "description"=>"Call is closed", "attribute_inherit"=>null, "attribute_list"=>array('name' => OPT_ATT_READONLY, 'end_date' => OPT_ATT_READONLY, 'last_update' => OPT_ATT_READONLY,"next_update"=>OPT_ATT_READONLY,
"title"=>OPT_ATT_READONLY, "org_id"=>OPT_ATT_READONLY,"source"=>OPT_ATT_READONLY, "caller_id"=>OPT_ATT_READONLY, "call_description"=>OPT_ATT_READONLY, "creation_date"=>OPT_ATT_READONLY,"impact"=>OPT_ATT_READONLY,"type"=>OPT_ATT_READONLY, "workgroup_id"=>OPT_ATT_READONLY,
"severity"=>OPT_ATT_READONLY, "agent_id"=>OPT_ATT_READONLY,"action_log"=>OPT_ATT_READONLY,"impacted_infra_manual"=>OPT_ATT_READONLY, "related_tickets"=>OPT_ATT_READONLY, "resolution"=>OPT_ATT_READONLY)));
MetaModel::Init_DefineStimulus("ev_assign", new StimulusUserAction(array("label"=>"Assign this call", "description"=>"Assign this call to a group and an agent")));
MetaModel::Init_DefineStimulus("ev_reassign", new StimulusUserAction(array("label"=>"Reassign this call", "description"=>"Reassign this call to a different group and agent")));
MetaModel::Init_DefineStimulus("ev_start_working", new StimulusUserAction(array("label"=>"Work on this call", "description"=>"Start working on this call")));
MetaModel::Init_DefineStimulus("ev_resolve", new StimulusUserAction(array("label"=>"Resolve this call", "description"=>"Resolve this call")));
MetaModel::Init_DefineStimulus("ev_close", new StimulusUserAction(array("label"=>"Close this call", "description"=>"Close this call")));
MetaModel::Init_DefineTransition("New", "ev_assign", array("target_state"=>"Assigned", "actions"=>array('SetLastUpdate'), "user_restriction"=>null));
MetaModel::Init_DefineTransition("Assigned", "ev_reassign", array("target_state"=>"Assigned", "actions"=>array('SetLastUpdate'), "user_restriction"=>null));
MetaModel::Init_DefineTransition("Assigned", "ev_start_working", array("target_state"=>"WorkInProgress", "actions"=>array('SetLastUpdate'), "user_restriction"=>null));
MetaModel::Init_DefineTransition("WorkInProgress", "ev_reassign", array("target_state"=>"Assigned", "actions"=>array('SetLastUpdate'), "user_restriction"=>null));
MetaModel::Init_DefineTransition("WorkInProgress", "ev_resolve", array("target_state"=>"Resolved", "actions"=>array('SetLastUpdate'), "user_restriction"=>null));
MetaModel::Init_DefineTransition("Resolved", "ev_close", array("target_state"=>"Closed", "actions"=>array('SetLastUpdate','SetClosureDate'), "user_restriction"=>null));
}
public function Generate(cmdbDataGenerator $oGenerator)
{
$this->Set('org_id', $oGenerator->GetOrganizationId());
$this->Set('title', $oGenerator->GenerateString("enum(Site,Server,Line)| |enum(is down,is flip-flopping,is not responding)"));
$this->Set('agent_id', $oGenerator->GenerateKey("bizPerson", array('org_id' =>$oGenerator->GetOrganizationId() )));
$this->Set('call_status', $oGenerator->GenerateString("enum(Open,Closed,Closed,Monitored)"));
$this->Set('creation_date', $oGenerator->GenerateString("2007-|number(07-12)|-|number(01-30)| |number(07-12)|:|number(00-59)|:|number(00-59)"));
$this->Set('last_update', $oGenerator->GenerateString("2007-|number(07-12)|-|number(01-30)| |number(07-12)|:|number(00-59)|:|number(00-59)"));
$this->Set('end_date', $oGenerator->GenerateString("2007-|number(07-12)|-|number(01-30)| |number(07-12)|:|number(00-59)|:|number(00-59)"));
}
// State machine actions
public function SetClosureDate($sStimulusCode)
{
$this->Set('end_date', time());
return true;
}
public function SetLastUpdate($sStimulusCode)
{
$this->Set('last_update', time());
return true;
}
public function ComputeValues()
{
$iKey = $this->GetKey();
if ($iKey < 0)
{
// Object not yet in the Database
$iKey = MetaModel::GetNextKey(get_class($this));
}
$sName = sprintf('S-%06d', $iKey);
$this->Set('name', $sName);
}
}
////////////////////////////////////////////////////////////////////////////////////
/**
* n-n link between any ticket and a Call
*/
////////////////////////////////////////////////////////////////////////////////////
class lnkCallTicket extends cmdbAbstractObject
{
public static function Init()
{
$aParams = array
(
"category" => "bizmodel,searchable",
"name" => "Call Ticket",
"description" => "Ticket related to a call",
"key_type" => "autoincrement",
"key_label" => "link_id",
"name_attcode" => "impact", // ????
"state_attcode" => "",
"reconc_keys" => array("impact"), // ????
"db_table" => "call_ticket",
"db_key_field" => "link_id",
"db_finalclass_field" => "",
"display_template" => "../business/templates/default.html",
);
MetaModel::Init_Params($aParams);
MetaModel::Init_AddAttribute(new AttributeExternalKey("ticket_id", array("targetclass"=>"bizIncidentTicket", "jointype"=> '', "label"=>"Related Ticket", "description"=>"The related ticket", "allowed_values"=>null, "sql"=>"ticket_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("ticket_name", array("label"=>"Related ticket", "description"=>"Name of the related ticket", "allowed_values"=>null, "extkey_attcode"=> 'ticket_id', "target_attcode"=>"title")));
MetaModel::Init_AddAttribute(new AttributeExternalKey("call_id", array("targetclass"=>"bizServiceCall", "jointype"=> '', "label"=>"Call", "description"=>"Ticket number", "allowed_values"=>null, "sql"=>"call_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("call_name", array("label"=>"Call name", "description"=>"Name of the call", "allowed_values"=>null, "extkey_attcode"=> 'call_id', "target_attcode"=>"title")));
MetaModel::Init_AddAttribute(new AttributeString("impact", array("label"=>"Impact", "description"=>"Impact on the call", "allowed_values"=>null, "sql"=>"impact", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddFilterFromAttribute("ticket_id");
MetaModel::Init_AddFilterFromAttribute("call_id");
// Display lists
MetaModel::Init_SetZListItems('details', array('ticket_id', 'call_id', 'impact')); // Attributes to be displayed for a list
MetaModel::Init_SetZListItems('list', array('ticket_id', 'call_id', 'impact')); // Attributes to be displayed for a list
// Search criteria
MetaModel::Init_SetZListItems('standard_search', array('ticket_id', 'call_id')); // Criteria of the std search form
MetaModel::Init_SetZListItems('advanced_search', array('ticket_id', 'call_id')); // Criteria of the advanced search form
}
public function Generate(cmdbDataGenerator $oGenerator)
{
$this->Set('call_id', $oGenerator->GenerateKey("bizServiceCall", array('org_id' =>$oGenerator->GetOrganizationId() )));
$this->Set('ticket_id', $oGenerator->GenerateKey("bizIncidentTicket", array('org_id' =>$oGenerator->GetOrganizationId() )));
$this->Set('impact', $oGenerator->GenerateString("enum(none,mandatory,partial)"));
}
}
////////////////////////////////////////////////////////////////////////////////////
/**
* n-n link between any Infra and a Call
*/
////////////////////////////////////////////////////////////////////////////////////
class lnkInfraCall extends cmdbAbstractObject
{
public static function Init()
{
$aParams = array
(
"category" => "bizmodel,searchable",
"name" => "Infra Call",
"description" => "Infra concerned by a call",
"key_type" => "autoincrement",
"key_label" => "link_id",
"name_attcode" => "impact", // ????
"state_attcode" => "",
"reconc_keys" => array("impact"), // ????
"db_table" => "infra_call",
"db_key_field" => "link_id",
"db_finalclass_field" => "",
"display_template" => "../business/templates/default.html",
);
MetaModel::Init_Params($aParams);
MetaModel::Init_AddAttribute(new AttributeExternalKey("infra_id", array("targetclass"=>"logInfra", "jointype"=> '', "label"=>"Infrastructure", "description"=>"The infrastructure impacted", "allowed_values"=>null, "sql"=>"infra_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("infra_name", array("label"=>"Infrastructure Name", "description"=>"Name of the impacted infrastructure", "allowed_values"=>null, "extkey_attcode"=> 'infra_id', "target_attcode"=>"name")));
MetaModel::Init_AddAttribute(new AttributeExternalKey("call_id", array("targetclass"=>"bizServiceCall", "jointype"=> '', "label"=>"Call", "description"=>"Call number", "allowed_values"=>null, "sql"=>"call_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("call_name", array("label"=>"Call name", "description"=>"Name of the call", "allowed_values"=>null, "extkey_attcode"=> 'call_id', "target_attcode"=>"title")));
MetaModel::Init_AddAttribute(new AttributeString("impact", array("label"=>"Impact", "description"=>"Level of impact of the infra by the related ticket", "allowed_values"=>null, "sql"=>"impact", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddFilterFromAttribute("infra_id");
MetaModel::Init_AddFilterFromAttribute("call_id");
// Display lists
MetaModel::Init_SetZListItems('details', array('infra_id', 'call_id', 'impact')); // Attributes to be displayed for a list
MetaModel::Init_SetZListItems('list', array('infra_id', 'call_id', 'impact')); // Attributes to be displayed for a list
// Search criteria
MetaModel::Init_SetZListItems('standard_search', array('infra_id', 'call_id')); // Criteria of the std search form
MetaModel::Init_SetZListItems('advanced_search', array('infra_id', 'call_id')); // Criteria of the advanced search form
}
public function Generate(cmdbDataGenerator $oGenerator)
{
$this->Set('infra_id', $oGenerator->GenerateKey("logInfra", array('org_id' =>$oGenerator->GetOrganizationId() )));
$this->Set('call_id', $oGenerator->GenerateKey("bizServiceCall", array('org_id' =>$oGenerator->GetOrganizationId() )));
$this->Set('impact', $oGenerator->GenerateString("enum(none,mandatory,partial)"));
}
}
?>

View File

@@ -1,338 +0,0 @@
<?php
////////////////////////////////////////////////////////////////////////////////////
/**
* Description of a service provided by an organization
*/
////////////////////////////////////////////////////////////////////////////////////
class bizService extends cmdbAbstractObject
{
public static function Init()
{
$aParams = array
(
"category" => "bizmodel,searchable",
"name" => "Service",
"description" => "Service provided by an organization",
"key_type" => "autoincrement",
"key_label" => "id",
"name_attcode" => "name",
//"state_attcode" => "status",
"state_attcode" => "",
"reconc_keys" => array("org_id", "name"), // inherited attributes
"db_table" => "services",
"db_key_field" => "id",
"db_finalclass_field" => "",
"display_template" => "../business/templates/service.html",
);
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeString("name", array("label"=>"Name", "description"=>"Name of the service", "allowed_values"=>null, "sql"=>"name", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalKey("org_id", array("targetclass"=>"bizOrganization", "label"=>"Provider", "description"=>"Provider for this service", "allowed_values"=>null, "sql"=>"customer_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("provider_name", array("label"=>"Provider", "description"=>"name of the Provider", "allowed_values"=>null, "extkey_attcode"=> 'org_id', "target_attcode"=>"name")));
MetaModel::Init_AddAttribute(new AttributeEnum("service_category", array("label"=>"Service Category", "description"=>"Category for this contract", "allowed_values"=>new ValueSetEnum("Server,Network,End-User,Desktop,Application"), "sql"=>"service_category", "default_value"=>"End-User", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("description", array("label"=>"Description", "description"=>"Description of this service", "allowed_values"=>null, "sql"=>"description", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeEnum("status", array("label"=>"Status", "description"=>"Status of the service", "allowed_values"=>new ValueSetEnum("New, Implementation,Production,Obsolete"), "sql"=>"status", "default_value"=>"New", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeEnum("type", array("label"=>"Type", "description"=>"Type of the service", "allowed_values"=>new ValueSetEnum("Hardware,Software,Support"), "sql"=>"type", "default_value"=>"Support", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_InheritFilters();
MetaModel::Init_AddFilterFromAttribute("name");
MetaModel::Init_AddFilterFromAttribute("org_id");
MetaModel::Init_AddFilterFromAttribute("service_category");
MetaModel::Init_AddFilterFromAttribute("type");
MetaModel::Init_AddFilterFromAttribute("status");
/*
// Life cycle
MetaModel::Init_DefineState("New", array("label"=>"New", "description"=>"Newly created service", "attribute_inherit"=>null,
"attribute_list"=>array()));
MetaModel::Init_DefineState("Implementation", array("label"=>"Implementing", "description"=>"The service is being worked on", "attribute_inherit"=>null,
"attribute_list"=>array()));
MetaModel::Init_DefineState("Production", array("label"=>"Production", "description"=>"The service is effective in production", "attribute_inherit"=>null,
"attribute_list"=>array()));
MetaModel::Init_DefineState("Obsolete", array("label"=>"Obsolete", "description"=>"The service is no more deleivered", "attribute_inherit"=>null,
"attribute_list"=>array()));
MetaModel::Init_DefineStimulus("ev_implement", new StimulusUserAction(array("label"=>"Implement this service", "description"=>"This service is under construction")));
MetaModel::Init_DefineStimulus("ev_move2prod", new StimulusUserAction(array("label"=>"Move to production", "description"=>"This service is now on production")));
MetaModel::Init_DefineStimulus("ev_obsolete", new StimulusUserAction(array("label"=>"Obsolete", "description"=>"Thi service is no more delivered")));
MetaModel::Init_DefineTransition("New", "ev_implement", array("target_state"=>"Implementation", "actions"=>array(), "user_restriction"=>null));
MetaModel::Init_DefineTransition("Implementation", "ev_move2prod", array("target_state"=>"Production", "actions"=>array(), "user_restriction"=>null));
MetaModel::Init_DefineTransition("Production", "ev_obsolete", array("target_state"=>"Obsolete", "actions"=>array('IncrementVersion'), "user_restriction"=>null));
*/
MetaModel::Init_SetZListItems('details', array('name', 'status', 'org_id','service_category','type','status','description')); // Attributes to be displayed for the complete details
MetaModel::Init_SetZListItems('list', array('name', 'status', 'org_id','service_category','type')); // Attributes to be displayed for a list
// Search criteria
MetaModel::Init_SetZListItems('standard_search', array('name', 'status','org_id','service_category','type')); // Criteria of the std search form
MetaModel::Init_SetZListItems('advanced_search', array('name', 'status','org_id','service_category','type')); // Criteria of the advanced search form
}
// State machine actions
public function IncrementVersion($sStimulusCode)
{
$this->Set('version_number', $this->Get('version_number') + 1);
return true;
}
}
////////////////////////////////////////////////////////////////////////////////////
/**
* Description of a contract signed with a customer
*/
////////////////////////////////////////////////////////////////////////////////////
class bizContract extends cmdbAbstractObject
{
public static function Init()
{
$aParams = array
(
"category" => "bizmodel,searchable",
"name" => "Contract",
"description" => "Contract signed by an organization",
"key_type" => "autoincrement",
"key_label" => "id",
"name_attcode" => "name",
//"state_attcode" => "status",
"state_attcode" => "",
"reconc_keys" => array("org_id", "name"), // inherited attributes
"db_table" => "contracts",
"db_key_field" => "id",
"db_finalclass_field" => "",
"display_template" => "../business/templates/contract.html",
);
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeString("name", array("label"=>"Name", "description"=>"Name of the contract", "allowed_values"=>null, "sql"=>"name", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalKey("org_id", array("targetclass"=>"bizOrganization", "label"=>"Customer", "description"=>"Customer for this contract", "allowed_values"=>null, "sql"=>"customer_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("customer_name", array("label"=>"Customer", "description"=>"name of the Customer", "allowed_values"=>null, "extkey_attcode"=> 'org_id', "target_attcode"=>"name")));
MetaModel::Init_AddAttribute(new AttributeExternalKey("service_id", array("targetclass"=>"bizService", "label"=>"Service", "description"=>"Provider for this contract", "allowed_values"=>null, "sql"=>"service_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("provider_name", array("label"=>"Provider", "description"=>"name of the service provider", "allowed_values"=>null, "extkey_attcode"=> 'service_id', "target_attcode"=>"provider_name")));
MetaModel::Init_AddAttribute(new AttributeExternalField("service_name", array("label"=>"Service", "description"=>"name of the service", "allowed_values"=>null, "extkey_attcode"=> 'service_id', "target_attcode"=>"name")));
MetaModel::Init_AddAttribute(new AttributeExternalKey("team_id", array("targetclass"=>"bizTeam", "label"=>"Team", "description"=>"Team managing this contract", "allowed_values"=>null, "sql"=>"team_id", "is_null_allowed"=>true, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("team_name", array("label"=>"Team", "description"=>"name of the team managing this contract", "allowed_values"=>null, "extkey_attcode"=> 'team_id', "target_attcode"=>"name")));
MetaModel::Init_AddAttribute(new AttributeEnum("service_level", array("label"=>"Service Level", "description"=>"Level of service for this contract", "allowed_values"=>new ValueSetEnum("Gold,Silver,Bronze"), "sql"=>"service_level", "default_value"=>"Bronze", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeEnum("cost_unit", array("label"=>"Cost Unit", "description"=>"Cost unit to compute global cost for this contract", "allowed_values"=>new ValueSetEnum("Devices,Persons,Applications,Global"), "sql"=>"cost_unit", "default_value"=>"Global", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeEnum("cost_freq", array("label"=>"Billing frequency", "description"=>"Frequency of cost for this contract", "allowed_values"=>new ValueSetEnum("Monthly,Yearly,Once"), "sql"=>"cost_freq", "default_value"=>"Once", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("cost", array("label"=>"Cost", "description"=>"Cost of this contract", "allowed_values"=>null, "sql"=>"cost", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeEnum("currency", array("label"=>"Currency", "description"=>"Currency of cost for this contract", "allowed_values"=>new ValueSetEnum("Euros,Dollars"), "sql"=>"currency", "default_value"=>"Euros", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("description", array("label"=>"Description", "description"=>"Description of this contract", "allowed_values"=>null, "sql"=>"description", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeDate("move2prod_date", array("label"=>"Date of Move To Production", "description"=>"Date when the contract is on production", "allowed_values"=>null, "sql"=>"move2prod_date", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeDate("end_prod", array("label"=>"Date of End Of Production", "description"=>"Date when the contract is stopped", "allowed_values"=>null, "sql"=>"end_date", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeEnum("status", array("label"=>"Status", "description"=>"Status of the contract", "allowed_values"=>new ValueSetEnum("New, Negotiating, Signed, Production,Finished"), "sql"=>"status", "default_value"=>"New", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeEnum("type", array("label"=>"Type", "description"=>"Type of the contract", "allowed_values"=>new ValueSetEnum("Hardware,Software,Support,Licence"), "sql"=>"type", "default_value"=>"Support", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeInteger("version_number", array("label"=>"Version", "description"=>"Revision number for this contract", "allowed_values"=>null, "sql"=>"version_number", "default_value"=>1, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_InheritFilters();
MetaModel::Init_AddFilterFromAttribute("service_name");
MetaModel::Init_AddFilterFromAttribute("provider_name");
MetaModel::Init_AddFilterFromAttribute("service_id");
MetaModel::Init_AddFilterFromAttribute("org_id");
MetaModel::Init_AddFilterFromAttribute("team_id");
MetaModel::Init_AddFilterFromAttribute("team_name");
MetaModel::Init_AddFilterFromAttribute("service_level");
MetaModel::Init_AddFilterFromAttribute("end_prod");
MetaModel::Init_AddFilterFromAttribute("status");
MetaModel::Init_AddFilterFromAttribute("version_number");
MetaModel::Init_AddFilterFromAttribute("name");
MetaModel::Init_AddFilterFromAttribute("type");
/*
// Life cycle
MetaModel::Init_DefineState("New", array("label"=>"New", "description"=>"Newly created contract", "attribute_inherit"=>null,
"attribute_list"=>array('name' => OPT_ATT_MANDATORY,'org_id' => OPT_ATT_MANDATORY, 'service_id' => OPT_ATT_MANDATORY,'type' => OPT_ATT_MANDATORY, 'description' => OPT_ATT_MANDATORY)));
MetaModel::Init_DefineState("Negotiating", array("label"=>"Negotiating", "description"=>"The contract is being worked on", "attribute_inherit"=>null,
"attribute_list"=>array('name' => OPT_ATT_READONLY,'org_id' => OPT_ATT_READONLY)));
MetaModel::Init_DefineState("Signed", array("label"=>"Signed", "description"=>"The contract has been signed", "attribute_inherit"=>null,
"attribute_list"=>array( 'name' => OPT_ATT_READONLY,'org_id' => OPT_ATT_READONLY, 'service_id' => OPT_ATT_READONLY,'type' => OPT_ATT_READONLY, 'service_level' => OPT_ATT_MANDATORY , 'cost_unit' => OPT_ATT_MANDATORY , 'cost_freq' => OPT_ATT_MANDATORY , 'cost' => OPT_ATT_MANDATORY, 'currency' => OPT_ATT_MANDATORY)));
MetaModel::Init_DefineState("Production", array("label"=>"Production", "description"=>"The contract is effective in production", "attribute_inherit"=>null,
"attribute_list"=>array('name' => OPT_ATT_READONLY,'org_id' => OPT_ATT_READONLY, 'service_id' => OPT_ATT_READONLY,'type' => OPT_ATT_READONLY, 'service_level' => OPT_ATT_READONLY , 'cost_unit' => OPT_ATT_READONLY , 'cost_freq' => OPT_ATT_READONLY , 'cost' => OPT_ATT_READONLY, 'currency' => OPT_ATT_READONLY,'move2prod_date' => OPT_ATT_MUSTPROMPT,'end_prod' => OPT_ATT_MANDATORY)));
MetaModel::Init_DefineState("Finished", array("label"=>"Finished", "description"=>"The contract is terminated", "attribute_inherit"=>null,
"attribute_list"=>array('name' => OPT_ATT_READONLY,'org_id' => OPT_ATT_READONLY, 'service_id' => OPT_ATT_READONLY,'type' => OPT_ATT_READONLY, 'service_level' => OPT_ATT_READONLY , 'cost_unit' => OPT_ATT_READONLY , 'cost_freq' => OPT_ATT_READONLY , 'cost' => OPT_ATT_READONLY, 'currency' => OPT_ATT_READONLY,'move2prod_date' => OPT_ATT_READONLY,'end_prod' => OPT_ATT_READONLY,'team_id' => OPT_ATT_READONLY,'description' => OPT_ATT_READONLY)));
MetaModel::Init_DefineStimulus("ev_negociate", new StimulusUserAction(array("label"=>"Negotiate this contract", "description"=>"This version of the contract is published")));
MetaModel::Init_DefineStimulus("ev_sign", new StimulusUserAction(array("label"=>"Sign this contract", "description"=>"This contract is being signed")));
MetaModel::Init_DefineStimulus("ev_begin", new StimulusUserAction(array("label"=>"Move to production", "description"=>"The contract becomes applicable in production")));
MetaModel::Init_DefineStimulus("ev_terminate", new StimulusUserAction(array("label"=>"Ends this contract", "description"=>"The contract is ending")));
MetaModel::Init_DefineTransition("New", "ev_negociate", array("target_state"=>"Negotiating", "actions"=>array('IncrementVersion'), "user_restriction"=>null));
MetaModel::Init_DefineTransition("Negotiating", "ev_sign", array("target_state"=>"Signed", "actions"=>array(), "user_restriction"=>null));
MetaModel::Init_DefineTransition("Negotiating", "ev_terminate", array("target_state"=>"Finished", "actions"=>array(), "user_restriction"=>null));
MetaModel::Init_DefineTransition("Signed", "ev_begin", array("target_state"=>"Production", "actions"=>array('SetProdDate'), "user_restriction"=>null));
MetaModel::Init_DefineTransition("Signed", "ev_terminate", array("target_state"=>"Finished", "actions"=>array(), "user_restriction"=>null));
MetaModel::Init_DefineTransition("Production", "ev_terminate", array("target_state"=>"Finished", "actions"=>array(), "user_restriction"=>null));
*/
MetaModel::Init_SetZListItems('details', array('name', 'status', 'org_id', 'service_id','provider_name','type','description','team_id','service_level','cost','currency','cost_unit','cost_freq','move2prod_date','end_prod', 'version_number')); // Attributes to be displayed for the complete details
MetaModel::Init_SetZListItems('list', array('name', 'status', 'org_id', 'service_id','provider_name','service_name','service_level','type')); // Attributes to be displayed for a list
// Search criteria
MetaModel::Init_SetZListItems('standard_search', array('name', 'status','service_id','provider_name','team_name','service_level','type')); // Criteria of the std search form
MetaModel::Init_SetZListItems('advanced_search', array('name', 'status','service_id','team_name', 'service_level', 'org_id')); // Criteria of the advanced search form
}
// State machine actions
public function IncrementVersion($sStimulusCode)
{
$this->Set('version_number', $this->Get('version_number') + 1);
return true;
}
public function SetProdDate($sStimulusCode)
{
$this->Set('move2prod_date', time());
return true;
}
}
////////////////////////////////////////////////////////////////////////////////////
/**
* n-n link between any Infra and a Contract
*/
////////////////////////////////////////////////////////////////////////////////////
class lnkInfraContract extends cmdbAbstractObject
{
public static function Init()
{
$aParams = array
(
"category" => "bizmodel,searchable",
"name" => "InfraContractLinks",
"description" => "Infra covered by a contract",
"key_type" => "autoincrement",
"key_label" => "link_id",
"name_attcode" => "coverage", // ????
"state_attcode" => "",
"reconc_keys" => array("infra_id","contract_id"), // ????
"db_table" => "infra_contract_links",
"db_key_field" => "link_id",
"db_finalclass_field" => "",
"display_template" => "../business/templates/default.html",
);
MetaModel::Init_Params($aParams);
MetaModel::Init_AddAttribute(new AttributeExternalKey("infra_id", array("targetclass"=>"logInfra", "jointype"=> '', "label"=>"Infrastructure", "description"=>"The infrastructure impacted", "allowed_values"=>null, "sql"=>"infra_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("infra_name", array("label"=>"Infrastructure Name", "description"=>"Name of the impacted infrastructure", "allowed_values"=>null, "extkey_attcode"=> 'infra_id', "target_attcode"=>"name")));
MetaModel::Init_AddAttribute(new AttributeExternalField("infra_status", array("label"=>"Status", "description"=>"Status of the impacted infrastructure", "allowed_values"=>null, "extkey_attcode"=> 'infra_id', "target_attcode"=>"status")));
MetaModel::Init_AddAttribute(new AttributeExternalKey("contract_id", array("targetclass"=>"bizContract", "jointype"=> '', "label"=>"Contract", "description"=>"Contract id", "allowed_values"=>null, "sql"=>"contract_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("contract_name", array("label"=>"Contract Name", "description"=>"Name of the contract", "allowed_values"=>null, "extkey_attcode"=> 'contract_id', "target_attcode"=>"name")));
MetaModel::Init_AddAttribute(new AttributeString("coverage", array("label"=>"Coverage", "description"=>"coverage for the given infra", "allowed_values"=>null, "sql"=>"coverage", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("service_level", array("label"=>"Service Level", "description"=>"service level for the given infra", "allowed_values"=>null, "sql"=>"sla", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddFilterFromAttribute("infra_id");
MetaModel::Init_AddFilterFromAttribute("contract_id");
// Display lists
MetaModel::Init_SetZListItems('details', array('infra_id', 'contract_id', 'coverage','service_level')); // Attributes to be displayed for a list
MetaModel::Init_SetZListItems('list', array('infra_id', 'infra_status','contract_id' , 'coverage','service_level')); // Attributes to be displayed for a list
// Search criteria
MetaModel::Init_SetZListItems('standard_search', array('infra_id', 'contract_id')); // Criteria of the std search form
MetaModel::Init_SetZListItems('advanced_search', array('infra_id', 'contract_id')); // Criteria of the advanced search form
}
}
////////////////////////////////////////////////////////////////////////////////////
/**
* n-n link between any contact and a Contract
*/
////////////////////////////////////////////////////////////////////////////////////
class lnkContactContract extends cmdbAbstractObject
{
public static function Init()
{
$aParams = array
(
"category" => "bizmodel,searchable",
"name" => "ContactContractLink",
"description" => "Contact associated to a contract",
"key_type" => "autoincrement",
"key_label" => "link_id",
"name_attcode" => "role", // ????
"state_attcode" => "",
"reconc_keys" => array("role"), // ????
"db_table" => "contact_Contract",
"db_key_field" => "link_id",
"db_finalclass_field" => "",
"display_template" => "../business/templates/default.html",
);
MetaModel::Init_Params($aParams);
MetaModel::Init_AddAttribute(new AttributeExternalKey("contact_id", array("targetclass"=>"bizContact", "jointype"=> '', "label"=>"Contact", "description"=>"The contact linked to contract", "allowed_values"=>null, "sql"=>"contact_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("contact_mail", array("label"=>"Contact E-mail", "description"=>"Mail for the contact", "allowed_values"=>null, "extkey_attcode"=> 'contact_id', "target_attcode"=>"email")));
MetaModel::Init_AddAttribute(new AttributeExternalKey("contract_id", array("targetclass"=>"bizContract", "jointype"=> '', "label"=>"Contract", "description"=>"Contract ID", "allowed_values"=>null, "sql"=>"contract_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("contract_name", array("label"=>"Contract Name", "description"=>"Name of the contract", "allowed_values"=>null, "extkey_attcode"=> 'contract_id', "target_attcode"=>"name")));
MetaModel::Init_AddAttribute(new AttributeString("role", array("label"=>"Role", "description"=>"Role of this contact for this contract", "allowed_values"=>null, "sql"=>"role", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddFilterFromAttribute("contract_id");
MetaModel::Init_AddFilterFromAttribute("contact_id");
// Display lists
MetaModel::Init_SetZListItems('details', array('contract_id', 'contact_id', 'role')); // Attributes to be displayed for a list
MetaModel::Init_SetZListItems('list', array('contract_id', 'contact_id', 'role')); // Attributes to be displayed for a list
// Search criteria
MetaModel::Init_SetZListItems('standard_search', array('contract_id', 'contact_id')); // Criteria of the std search form
MetaModel::Init_SetZListItems('advanced_search', array('contract_id', 'contact_id')); // Criteria of the advanced search form
}
public function Generate(cmdbDataGenerator $oGenerator)
{
$this->Set('contract_id', $oGenerator->GenerateKey("logInfra", array('org_id' =>$oGenerator->GetOrganizationId() )));
$this->Set('contact_id', $oGenerator->GenerateKey("bizIncidentTicket", array('org_id' =>$oGenerator->GetOrganizationId() )));
$this->Set('role', $oGenerator->GenerateString("enum(none,mandatory,partial)"));
}
}
////////////////////////////////////////////////////////////////////////////////////
/**
* n-n link between any Contract and a Document
*/
////////////////////////////////////////////////////////////////////////////////////
class lnkDocumentContract extends cmdbAbstractObject
{
public static function Init()
{
$aParams = array
(
"category" => "bizmodel,searchable",
"name" => "DocumentsContractLinks",
"description" => "A link between a document and another contract",
"key_type" => "autoincrement",
"key_label" => "link_id",
"name_attcode" => "link_type",
"state_attcode" => "",
"reconc_keys" => array("doc_name", "contract_name"),
"db_table" => "documents_contracts",
"db_key_field" => "link_id",
"db_finalclass_field" => "",
"display_template" => "../business/templates/default.html",
);
MetaModel::Init_Params($aParams);
MetaModel::Init_AddAttribute(new AttributeExternalKey("doc_id", array("targetclass"=>"bizDocument", "label"=>"Document", "description"=>"id of the Document", "allowed_values"=>null, "sql"=>"doc_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("doc_name", array("label"=>"Document Name", "description"=>"name of the document", "allowed_values"=>null, "extkey_attcode"=> 'doc_id', "target_attcode"=>"name")));
MetaModel::Init_AddAttribute(new AttributeExternalKey("contract_id", array("targetclass"=>"bizContract", "label"=>"Contract", "description"=>"Contract linked to this document", "allowed_values"=>null, "sql"=>"contract_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("contract_name", array("label"=>"Contract Name", "description"=>"name of the linked contract", "allowed_values"=>null, "extkey_attcode"=> 'contract_id', "target_attcode"=>"name")));
MetaModel::Init_AddAttribute(new AttributeString("link_type", array("label"=>"Link Type", "description"=>"More information", "allowed_values"=>null, "sql"=>"link_type", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddFilterFromAttribute("doc_id");
MetaModel::Init_AddFilterFromAttribute("doc_name");
MetaModel::Init_AddFilterFromAttribute("contract_id");
MetaModel::Init_AddFilterFromAttribute("contract_name");
MetaModel::Init_AddFilterFromAttribute("link_type");
// Display lists
MetaModel::Init_SetZListItems('details', array('doc_id', 'contract_name', 'link_type')); // Attributes to be displayed for the complete details
MetaModel::Init_SetZListItems('list', array('doc_id', 'contract_name', 'link_type')); // Attributes to be displayed for a list
}
}
// require_once('ServiceRequest.business.php');
?>

View File

@@ -1,184 +0,0 @@
<?php
////////////////////////////////////////////////////////////////////////////////////
/**
* Description of a service request
*
*/
////////////////////////////////////////////////////////////////////////////////////
class bizServiceRequest extends cmdbAbstractObject
{
public static function Init()
{
$aParams = array
(
"category" => "bizmodel,searchable",
"name" => "ServiceRequest",
"description" => "Service request",
"key_type" => "autoincrement",
"key_label" => "id",
"name_attcode" => "name",
"state_attcode" => "",
"reconc_keys" => array("org_id", "name"), // inherited attributes
"db_table" => "serviceRequests",
"db_key_field" => "id",
"db_finalclass_field" => "",
"display_template" => "../business/templates/serviceRequest.html",
);
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeString("name", array("label"=>"Request Ref", "description"=>"Refence number ofr this service request", "allowed_values"=>null, "sql"=>"name", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("title", array("label"=>"Title", "description"=>"Overview of the Service Request", "allowed_values"=>null, "sql"=>"title", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalKey("org_id", array("targetclass"=>"bizOrganization", "label"=>"Customer", "description"=>"Customer for this service request", "allowed_values"=>null, "sql"=>"customer_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("customer_name", array("label"=>"Customer", "description"=>"name of the Customer", "allowed_values"=>null, "extkey_attcode"=> 'org_id', "target_attcode"=>"name")));
MetaModel::Init_AddAttribute(new AttributeText("description", array("label"=>"Description", "description"=>"Description of this service request", "allowed_values"=>null, "sql"=>"description", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeEnum("status", array("label"=>"Status", "description"=>"Status of the service request", "allowed_values"=>new ValueSetEnum("Open,approved,rejected,assigned,pending,closed"), "sql"=>"status", "default_value"=>"Open", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalKey("requester_id", array("targetclass"=>"bizPerson", "jointype"=> "", "label"=>"Requester", "description"=>"person that trigger service request", "allowed_values"=>null, "sql"=>"requester_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("requester_mail", array("label"=>"Requester", "description"=>"Person that trigger this service request", "allowed_values"=>null, "extkey_attcode"=> 'requester_id', "target_attcode"=>"email")));
MetaModel::Init_AddAttribute(new AttributeEnum("priority", array("label"=>"Priority", "description"=>"Field defining the priority for this service request", "allowed_values"=>new ValueSetEnum("critical,medium,low"), "sql"=>"priority", "default_value"=>"low", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeEnum("source", array("label"=>"Source", "description"=>"source type for this call", "allowed_values"=>new ValueSetEnum("phone,E-mail,Fax"), "sql"=>"source", "default_value"=>"phone", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalKey("coordinator_id", array("targetclass"=>"bizWorkgroup", "jointype"=> "", "label"=>"Coordinator", "description"=>"which workgroup is controlling this request", "allowed_values"=>null, "sql"=>"coordinator_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("coordinator_name", array("label"=>"Coordinator", "description"=>"name of workgroup coordinating this service request", "allowed_values"=>null, "extkey_attcode"=> 'coordinator_id', "target_attcode"=>"name")));
MetaModel::Init_AddAttribute(new AttributeExternalKey("agent_id", array("targetclass"=>"bizPerson", "jointype"=> "", "label"=>"Coordinator Agent", "description"=>"who is managing the ticket", "allowed_values"=>null, "sql"=>"agent_id", "is_null_allowed"=>true, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array("coordinator_id"))));
MetaModel::Init_AddAttribute(new AttributeExternalField("agent_mail", array("label"=>"Coordinator Agent", "description"=>"mail of agent coordinating this service request", "allowed_values"=>null, "extkey_attcode"=> 'agent_id', "target_attcode"=>"email")));
MetaModel::Init_InheritFilters();
MetaModel::Init_AddFilterFromAttribute("name");
MetaModel::Init_AddFilterFromAttribute("org_id");
MetaModel::Init_AddFilterFromAttribute("requester_id");
MetaModel::Init_AddFilterFromAttribute("priority");
MetaModel::Init_AddFilterFromAttribute("coordinator_id");
MetaModel::Init_AddFilterFromAttribute("agent_id");
MetaModel::Init_AddFilterFromAttribute("status");
MetaModel::Init_AddFilterFromAttribute("source");
/*
// Life cycle
MetaModel::Init_DefineState("New", array("label"=>"New", "description"=>"Newly created service", "attribute_inherit"=>null,
"attribute_list"=>array()));
MetaModel::Init_DefineState("Implementation", array("label"=>"Implementing", "description"=>"The service is being worked on", "attribute_inherit"=>null,
"attribute_list"=>array()));
MetaModel::Init_DefineState("Production", array("label"=>"Production", "description"=>"The service is effective in production", "attribute_inherit"=>null,
"attribute_list"=>array()));
MetaModel::Init_DefineState("Obsolete", array("label"=>"Obsolete", "description"=>"The service is no more deleivered", "attribute_inherit"=>null,
"attribute_list"=>array()));
MetaModel::Init_DefineStimulus("ev_implement", new StimulusUserAction(array("label"=>"Implement this service", "description"=>"This service is under construction")));
MetaModel::Init_DefineStimulus("ev_move2prod", new StimulusUserAction(array("label"=>"Move to production", "description"=>"This service is now on production")));
MetaModel::Init_DefineStimulus("ev_obsololete", new StimulusUserAction(array("label"=>"Obsolete", "description"=>"Thi service is no more delivered")));
MetaModel::Init_DefineTransition("New", "ev_implement", array("target_state"=>"Implementation", "actions"=>array(), "user_restriction"=>null));
MetaModel::Init_DefineTransition("Implementation", "ev_move2prod", array("target_state"=>"Production", "actions"=>array(), "user_restriction"=>null));
MetaModel::Init_DefineTransition("Production", "ev_obsolete", array("target_state"=>"Obsolete", "actions"=>array('IncrementVersion'), "user_restriction"=>null));
*/
MetaModel::Init_SetZListItems('details', array('name', 'title','status', 'org_id','priority','requester_id','description','source','coordinator_id','agent_id')); // Attributes to be displayed for the complete details
MetaModel::Init_SetZListItems('list', array('name', 'title','status', 'org_id','priority')); // Attributes to be displayed for a list
// Search criteria
MetaModel::Init_SetZListItems('standard_search', array('name', 'status','org_id','priority','requester_id','source','coordinator_id','agent_id')); // Criteria of the std search form
MetaModel::Init_SetZListItems('advanced_search', array('name', 'status','org_id','priority','requester_id','source','coordinator_id','agent_id')); // Criteria of the advanced search form
}
// State machine actions
public function IncrementVersion($sStimulusCode)
{
$this->Set('version_number', $this->Get('version_number') + 1);
return true;
}
}
////////////////////////////////////////////////////////////////////////////////////
/**
* Description of a service item
*
*/
////////////////////////////////////////////////////////////////////////////////////
class bizServiceItem extends cmdbAbstractObject
{
public static function Init()
{
$aParams = array
(
"category" => "bizmodel,searchable",
"name" => "ServiceItem",
"description" => "Service Item",
"key_type" => "autoincrement",
"key_label" => "id",
"name_attcode" => "name",
"state_attcode" => "",
"reconc_keys" => array("request_id", "name"), // inherited attributes
"db_table" => "serviceItems",
"db_key_field" => "id",
"db_finalclass_field" => "",
"display_template" => "../business/templates/default.html",
);
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeString("name", array("label"=>"Request Ref", "description"=>"Refence number for this service item", "allowed_values"=>null, "sql"=>"name", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("title", array("label"=>"Title", "description"=>"Overview of the Service item", "allowed_values"=>null, "sql"=>"title", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalKey("request_id", array("targetclass"=>"bizServiceRequest", "label"=>"Service Request", "description"=>"Corresponding service request", "allowed_values"=>null, "sql"=>"request_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("request_name", array("label"=>"Service Request", "description"=>"name of the request", "allowed_values"=>null, "extkey_attcode"=> 'request_id', "target_attcode"=>"name")));
MetaModel::Init_AddAttribute(new AttributeExternalKey("contract_id", array("targetclass"=>"bizContract", "label"=>"Service", "description"=>"Corresponding service", "allowed_values"=>null, "sql"=>"contract_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("contract_name", array("label"=>"Service Name", "description"=>"name of the service", "allowed_values"=>null, "extkey_attcode"=> 'contract_id', "target_attcode"=>"name")));
MetaModel::Init_AddAttribute(new AttributeText("description", array("label"=>"Description", "description"=>"Description of this service request", "allowed_values"=>null, "sql"=>"description", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeEnum("status", array("label"=>"Status", "description"=>"Status of the service request", "allowed_values"=>new ValueSetEnum("Open,approved,rejected,assigned,pending,closed"), "sql"=>"status", "default_value"=>"Open", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("priority", array("label"=>"Priority", "description"=>"priority corresponding to service request", "allowed_values"=>null, "extkey_attcode"=> 'request_id', "target_attcode"=>"priority")));
MetaModel::Init_AddAttribute(new AttributeText("comment", array("label"=>"Comment", "description"=>"Comment of this service item", "allowed_values"=>null, "sql"=>"comment", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalKey("workgroup_id", array("targetclass"=>"bizWorkgroup", "jointype"=> "", "label"=>"Workgroup", "description"=>"which workgroup working on this service item", "allowed_values"=>null, "sql"=>"workgroup_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("workgroup_name", array("label"=>"Workgroup", "description"=>"name of workgroup working on this service item", "allowed_values"=>null, "extkey_attcode"=> 'workgroup_id', "target_attcode"=>"name")));
MetaModel::Init_AddAttribute(new AttributeExternalKey("agent_id", array("targetclass"=>"bizPerson", "jointype"=> "", "label"=>"Coordinator Agent", "description"=>"who is managing the service item", "allowed_values"=>null, "sql"=>"agent_id", "is_null_allowed"=>true, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array("workgroup_id"))));
MetaModel::Init_AddAttribute(new AttributeExternalField("agent_mail", array("label"=>"Agent", "description"=>"mail of agent coordinating this service item", "allowed_values"=>null, "extkey_attcode"=> 'agent_id', "target_attcode"=>"email")));
MetaModel::Init_InheritFilters();
MetaModel::Init_AddFilterFromAttribute("name");
MetaModel::Init_AddFilterFromAttribute("request_id");
MetaModel::Init_AddFilterFromAttribute("contract_id");
MetaModel::Init_AddFilterFromAttribute("priority");
MetaModel::Init_AddFilterFromAttribute("workgroup_id");
MetaModel::Init_AddFilterFromAttribute("agent_id");
MetaModel::Init_AddFilterFromAttribute("status");
MetaModel::Init_AddFilterFromAttribute("priority");
/*
// Life cycle
MetaModel::Init_DefineState("New", array("label"=>"New", "description"=>"Newly created service", "attribute_inherit"=>null,
"attribute_list"=>array()));
MetaModel::Init_DefineState("Implementation", array("label"=>"Implementing", "description"=>"The service is being worked on", "attribute_inherit"=>null,
"attribute_list"=>array()));
MetaModel::Init_DefineState("Production", array("label"=>"Production", "description"=>"The service is effective in production", "attribute_inherit"=>null,
"attribute_list"=>array()));
MetaModel::Init_DefineState("Obsolete", array("label"=>"Obsolete", "description"=>"The service is no more deleivered", "attribute_inherit"=>null,
"attribute_list"=>array()));
MetaModel::Init_DefineStimulus("ev_implement", new StimulusUserAction(array("label"=>"Implement this service", "description"=>"This service is under construction")));
MetaModel::Init_DefineStimulus("ev_move2prod", new StimulusUserAction(array("label"=>"Move to production", "description"=>"This service is now on production")));
MetaModel::Init_DefineStimulus("ev_obsololete", new StimulusUserAction(array("label"=>"Obsolete", "description"=>"Thi service is no more delivered")));
MetaModel::Init_DefineTransition("New", "ev_implement", array("target_state"=>"Implementation", "actions"=>array(), "user_restriction"=>null));
MetaModel::Init_DefineTransition("Implementation", "ev_move2prod", array("target_state"=>"Production", "actions"=>array(), "user_restriction"=>null));
MetaModel::Init_DefineTransition("Production", "ev_obsolete", array("target_state"=>"Obsolete", "actions"=>array('IncrementVersion'), "user_restriction"=>null));
*/
MetaModel::Init_SetZListItems('details', array('name', 'title','request_id','contract_id','status','priority','description','comment','workgroup_id','agent_id')); // Attributes to be displayed for the complete details
MetaModel::Init_SetZListItems('list', array('name', 'title','status', 'contract_id','priority')); // Attributes to be displayed for a list
// Search criteria
MetaModel::Init_SetZListItems('standard_search', array('name','request_id','contract_id','status','priority','workgroup_id','agent_id')); // Criteria of the std search form
MetaModel::Init_SetZListItems('advanced_search', array('name','request_id','contract_id','status','priority','workgroup_id','agent_id')); // Criteria of the advanced search form
}
}
?>

View File

@@ -1,261 +0,0 @@
<?php
require_once('../core/MyHelpers.class.inc.php');
require_once('../core/cmdbobject.class.inc.php');
/**
* business_itopbegins.class.inc.php
* User defined objects, for unit testing
*
* @package iTopUnitTests
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @author Denis Flaven <denisflave@free.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version 1.1.1.1 $
*/
///////////////////////////////////////////////////////////////////////////////
// Business implementation demo
///////////////////////////////////////////////////////////////////////////////
/**
* blah blah
*
* @package iTopUnitTests
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version 1.1.1.1 $
*/
class cmdbContact extends CMDBObject
{
public static function Init()
{
$aParams = array
(
"category" => "blah",
"name" => "klassContact",
"description" => "klass contact description",
"key_type" => "autoincrement",
"key_label" => "",
"name_attcode" => "att_contact_name",
"state_attcode" => "",
"reconc_keys" => array("att_contact_name"),
"db_table" => "contact",
"db_key_field" => "contactid",
"db_finalclass_field" => "actualclass",
);
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeString("att_contact_name", array("label"=>"name of the contact", "description"=>"blah", "allowed_values"=>null, "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array(), "sql"=>"name")));
MetaModel::Init_AddAttribute(new AttributeInteger("att_contact_availability", array("label"=>"degree of availability in percent", "description"=>"blah", "allowed_values"=>null, "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array(), "sql"=>"availability")));
MetaModel::Init_AddAttribute(new AttributeDate("start_date", array("label"=>"Starting date", "description"=>"Incident starting date", "allowed_values"=>null, "sql"=>"start_date", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_InheritFilters();
MetaModel::Init_AddFilterFromAttribute("att_contact_name");
MetaModel::Init_AddFilterFromAttribute("att_contact_availability");
}
}
/**
* blah blah
*
* @package iTopUnitTests
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version 1.1.1.1 $
*/
class cmdbPerson extends cmdbContact
{
public static function Init()
{
$oValsDunsNumber = new ValueSetObjects("cmdbCompany: att_company_dunsnumber Begins with '$[duns_prm::]'", "att_company_dunsnumber", array("att_company_dunsnumber"=>true));
$aParams = array
(
"category" => "blah",
"name" => "klassPerson",
"description" => "klass person description",
"key_type" => "autoincrement",
"key_label" => "",
"name_attcode" => "att_contact_name",
"state_attcode" => "",
"reconc_keys" => array("att_contact_name"),
"db_table" => "person",
"db_key_field" => "personid",
"db_finalclass_field" => "",
);
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeString("att_person_email", array("label"=>"iMaile", "description"=>"imelle", "allowed_values"=>$oValsDunsNumber, "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array(), "sql"=>"email")));
MetaModel::Init_AddAttribute(new AttributeString("att_person_name", array("label"=>"secName", "description"=>"secondary name", "allowed_values"=>new ValueSetEnum(array("nom1", "nom2", "nom10", "no", "noms", "")), "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array(), "sql"=>"name")));
MetaModel::Init_InheritFilters();
MetaModel::Init_AddFilterFromAttribute("att_person_email");
}
}
/**
* blah blah
*
* @package iTopUnitTests
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version 1.1.1.1 $
*/
class cmdbSubcontractor extends cmdbPerson
{
public static function Init()
{
$aParams = array
(
"category" => "blah",
"name" => "klassSubcontractor",
"description" => "klass subcontractor description",
"key_type" => "autoincrement",
"key_label" => "",
"name_attcode" => "att_contact_name",
"state_attcode" => "",
"reconc_keys" => array("att_contact_name"),
"db_table" => "subcontractor",
"db_key_field" => "subcontractorid",
"db_finalclass_field" => "",
);
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeString("att_contractinfo", array("label"=>"contract info", "description"=>"blah", "allowed_values"=>null, "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array(), "sql"=>"contractinfo")));
MetaModel::Init_AddAttribute(new AttributeExternalKey("ext_subcontractor_provider", array("label"=>"ssii", "description"=>"blah", "allowed_values"=>null, "sql"=>"provider", "targetclass"=>"cmdbProvider", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("extatt_subcontractor_provider_ref", array("label"=>"ref", "description"=>"blah", "allowed_values"=>null, "extkey_attcode"=>"ext_subcontractor_provider", "target_attcode"=>"att_provider_ref")));
MetaModel::Init_AddAttribute(new AttributeExternalKey("ext_subcontractor_tutor", array("label"=>"tutor", "description"=>"blah", "allowed_values"=>null, "sql"=>"tutor", "targetclass"=>"cmdbPerson", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("extatt_subcontractor_tutor_email", array("label"=>"tutor email", "description"=>"blah", "allowed_values"=>null, "extkey_attcode"=>"ext_subcontractor_tutor", "target_attcode"=>"att_person_email")));
MetaModel::Init_AddAttribute(new AttributeExternalField("extatt_subcontractor_tutor_secondname", array("label"=>"2ndname (ext field)", "description"=>"blah", "allowed_values"=>null, "extkey_attcode"=>"ext_subcontractor_tutor", "target_attcode"=>"att_person_name")));
MetaModel::Init_InheritFilters();
MetaModel::Init_AddFilterFromAttribute("extatt_subcontractor_tutor_secondname");
}
}
/**
* blah blah
*
* @package iTopUnitTests
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version 1.1.1.1 $
*/
class cmdbCrowd extends cmdbObject
{
public static function Init()
{
$aParams = array
(
"category" => "blah",
"name" => "klassCrowd",
"description" => "klass crowd description",
"key_type" => "autoincrement",
"key_label" => "",
"name_attcode" => "att_crowd_peoplecount",
"state_attcode" => "",
"reconc_keys" => array("att_crowd_peoplecount"),
"db_table" => "crowd",
"db_key_field" => "crowdid",
"db_finalclass_field" => "crowdclass",
);
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeInteger("att_crowd_peoplecount", array("label"=>"people count", "description"=>"blah", "allowed_values"=>null, "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array(), "sql"=>"peoplecount")));
MetaModel::Init_InheritFilters();
MetaModel::Init_AddFilterFromAttribute("att_crowd_peoplecount");
}
}
/**
* blah blah
*
* @package iTopUnitTests
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version 1.1.1.1 $
*/
class cmdbCompany extends cmdbCrowd
{
public static function Init()
{
$aParams = array
(
"category" => "blah",
"name" => "klassCompany",
"description" => "klass company description",
"key_type" => "autoincrement",
"key_label" => "",
"name_attcode" => "att_company_dunsnumber",
"state_attcode" => "",
"reconc_keys" => array("att_company_dunsnumber"),
"db_table" => "company",
"db_key_field" => "companyid",
"db_finalclass_field" => "",
);
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeString("att_company_dunsnumber", array("label"=>"duns number", "description"=>"blah", "allowed_values"=>null, "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array(), "sql"=>"dunsnumber")));
MetaModel::Init_InheritFilters();
MetaModel::Init_AddFilterFromAttribute("att_company_dunsnumber");
}
}
/**
* blah blah
*
* @package iTopUnitTests
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version 1.1.1.1 $
*/
class cmdbProvider extends cmdbCompany
{
public static function Init()
{
$aParams = array
(
"category" => "blah",
"name" => "klassProvider",
"description" => "klass provider description",
"key_type" => "autoincrement",
"key_label" => "",
"name_attcode" => "att_provider_ref",
"state_attcode" => "",
"reconc_keys" => array("att_provider_ref"),
"db_table" => "provider",
"db_key_field" => "providerid",
"db_finalclass_field" => "",
);
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeInteger("att_provider_ref", array("label"=>"provider ref", "description"=>"blah", "allowed_values"=>null, "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array(), "sql"=>"providerref")));
MetaModel::Init_InheritFilters();
MetaModel::Init_AddFilterFromAttribute("att_provider_ref");
}
}
?>

View File

@@ -1,366 +0,0 @@
<?php
require_once('../core/MyHelpers.class.inc.php');
require_once('../core/cmdbobject.class.inc.php');
/**
* business_test.class.inc.php
* User defined objects, for unit testing
*
* @package iTopUnitTests
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @author Denis Flaven <denisflave@free.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version 1.1.1.1 $
*/
///////////////////////////////////////////////////////////////////////////////
// Business implementation demo
///////////////////////////////////////////////////////////////////////////////
MetaModel::RegisterRelation("Potes", array("description"=>"ceux dont l'email ressemble au mien", "verb_down"=>"est pote de", "verb_up"=>"est pote de"));
MetaModel::RegisterZList("list1", array("description"=>"une premiere list, just for fun", "type"=>"attributes"));
MetaModel::RegisterZList("list2", array("description"=>"la secunda e meliora", "type"=>"attributes"));
MetaModel::RegisterZList("list3", array("description"=>"la variante qui tue", "type"=>"filters"));
/**
* blah blah
*
* @package iTopUnitTests
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version 1.1.1.1 $
*/
class cmdbObjectHomeMade extends cmdbObject
{
public static function Init()
{
$aParams = array
(
"category" => "blah",
"name" => "anyObject",
"description" => "std object",
"key_type" => "autoincrement",
"key_label" => "",
"name_attcode" => "",
"state_attcode" => "",
"reconc_keys" => array(""),
"db_table" => "",
"db_key_field" => "",
"db_finalclass_field" => "",
);
MetaModel::Init_Params($aParams);
}
public static function GetRelationQueries($sRelCode)
{
//trigger_error("GetRelationQueries: cmdbObjectHomeMade");
switch ($sRelCode)
{
case "Potes":
$aRels = array("xxxx" => array("sQuery"=>"cmdbContact: pkey = 40", "bPropagate"=>true, "iDistance"=>3));
return $aRels;
}
}
}
/**
* blah blah
*
* @package iTopUnitTests
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version 1.1.1.1 $
*/
class cmdbContact extends cmdbObjectHomeMade
{
public static function Init()
{
$aParams = array
(
"category" => "blah",
"name" => "Contact",
"description" => "Un object que l'on peut communiquer avec",
"key_type" => "autoincrement",
"key_label" => "",
"name_attcode" => "name",
"state_attcode" => "etat",
"reconc_keys" => array("name"),
"db_table" => "contact",
"db_key_field" => "contactid",
"db_finalclass_field" => "actualclass",
);
MetaModel::Init_Params($aParams);
//MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeString("etat", array("label"=>"l'etat", "description"=>"les etats d'ame d'eric", "allowed_values"=>new ValueSetEnum('justborn, 15, 21'), "sql"=>"etat", "default_value"=>"justborn", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("name", array("label"=>"nom", "description"=>"ze equipe", "allowed_values"=>null, "sql"=>"name", "default_value"=>"XXXX", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("email", array("label"=>"iMaile", "description"=>"imelle", "allowed_values"=>null, "sql"=>"email", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalKey("owner", array("label"=>"owned by", "description"=>"organization owning the team", "allowed_values"=>null, "sql"=>"ownerorg", "targetclass"=>"cmdbOrga", "is_null_allowed"=>true, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("ownername", array("label"=>"owned by", "description"=>"name of organization owning the team", "allowed_values"=>null, "extkey_attcode"=>"owner", "target_attcode"=>"_name_")));
MetaModel::Init_AddAttribute(new AttributeExternalField("ownertnut", array("label"=>"owntnut", "description"=>"blah tnut blah", "allowed_values"=>null, "extkey_attcode"=>"owner", "target_attcode"=>"_dunsnumber_")));
MetaModel::Init_AddAttribute(new AttributeLinkedSet("myworkshops", array("label"=>"held workshops", "description"=>"blah tnut blah", "depends_on"=>array(), "linked_class"=>"cmdbLiens", "ext_key_to_me"=>"tocontact", "count_min"=>1, "count_max"=>10, "allowed_values"=>null)));
MetaModel::Init_InheritFilters();
MetaModel::Init_AddFilterFromAttribute("owner");
MetaModel::Init_AddFilterFromAttribute("name");
MetaModel::Init_AddFilterFromAttribute("ownername");
MetaModel::Init_SetZListItems("list1", array("name", "email"));
MetaModel::Init_SetZListItems("list2", array());
MetaModel::Init_SetZListItems("list3", array("ownername"));
MetaModel::Init_DefineState("justborn", array("label"=>"just born", "description"=>"too young to die", "attribute_inherit"=>null, "attribute_list"=>array("owner"=>OPT_ATT_MANDATORY)));
MetaModel::Init_DefineState("15", array("label"=>"student", "description"=>"stupid age", "attribute_inherit"=>"justborn", "attribute_list"=>array("owner"=>OPT_ATT_MUSTPROMPT, "email"=>OPT_ATT_MUSTPROMPT)));
MetaModel::Init_DefineState("21", array("label"=>"old", "description"=>"one foot in the grave", "attribute_inherit"=>"15", "attribute_list"=>array("email"=>OPT_ATT_READONLY|OPT_ATT_MUSTCHANGE)));
MetaModel::Init_DefineStimulus("toschool", new StimulusUserAction(array("label"=>"go to school", "description"=>"start learning stupid things")));
MetaModel::Init_DefineStimulus("raise", new StimulusUserAction(array("label"=>"grow!", "description"=>"eat tons of BigMACs")));
MetaModel::Init_DefineTransition("justborn", "toschool", array("target_state"=>"15", "actions"=>array('MyLifecycleHandler', 'MyLifecycleHandler2'), "user_restriction"=>null));
MetaModel::Init_DefineTransition("15", "raise", array("target_state"=>"21", "actions"=>null, "user_restriction"=>null));
}
public static function GetRelationQueries($sRelCode)
{
//trigger_error("GetRelationQueries: cmdbContact");
switch ($sRelCode)
{
case "Potes":
$aRels = array(
"zz1" => array("sQuery"=>"cmdbContact: name Begins with '\$[this.name::]' AND pkey != \$[this.pkey::]", "bPropagate"=>false, "iDistance"=>3),
"zz2" => array("sQuery"=>"cmdbContact: owner = \$[this.owner::] AND owner != 2", "bPropagate"=>false, "iDistance"=>3),
);
return array_merge($aRels, parent::GetRelationQueries($sRelCode));
}
}
public function MyLifecycleHandler($sStimulusCode)
{
echo "<p>youhou!</p>";
return true;
}
public function MyLifecycleHandler2($sStimulusCode)
{
echo "<p>... les papous...</p>";
return true;
}
}
/**
* blah blah
*
* @package iTopUnitTests
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version 1.1.1.1 $
*/
class cmdbTeam extends cmdbContact
{
public static function Init()
{
$aParams = array
(
"category" => "blah",
"name" => "Equipado",
"description" => "Un regroupement de gens",
"key_type" => "autoincrement",
"key_label" => "",
"name_attcode" => "email",
"state_attcode" => "",
"reconc_keys" => array("email"),
"db_table" => "team",
"db_key_field" => "teamid",
"db_finalclass_field" => "",
);
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();
MetaModel::Init_OverloadAttributeParams("email", array("label"=>"email2", "description"=>"emailleu22"));
MetaModel::Init_AddAttribute(new AttributeInteger("headcount", array("label"=>"nombre", "description"=>"combien ils sont", "allowed_values"=>null, "sql"=>"headcount", "default_value"=>654321, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_InheritFilters();
MetaModel::Init_AddFilterFromAttribute("headcount");
MetaModel::Init_SetZListItems("noneditable", array("name"));
}
public function ComputeValues()
{
//echo "Set(), function ComputeValues has been found for ".get_class($this)."<br/>\n";
$this->Set("name", $this->Get("email")." and ".$this->Get("headcount"));
}
public static function GetRelationQueries($sRelCode)
{
//trigger_error("GetRelationQueries: cmdbTeam");
switch ($sRelCode)
{
case "Potes":
//$aRels = array("Relies on" => array("sQuery"=>"cmdbContact: name Begins with 'Louis'", "bPropagate"=>false, "iDistance"=>3));
return array_merge(array(), parent::GetRelationQueries($sRelCode));
}
}
}
/**
* blah blah
*
* @package iTopUnitTests
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version 1.1.1.1 $
*/
class cmdbOrga extends cmdbObjectHomeMade
{
public static function Init()
{
$aParams = array
(
"category" => "blah",
"name" => "Organization",
"description" => "Une entite qui possede des choses",
"key_type" => "",
"key_label" => "",
"name_attcode" => "_name_",
"state_attcode" => "",
"reconc_keys" => array("_name_"),
"db_table" => "organization",
"db_key_field" => "orgid",
"db_finalclass_field" => "",
);
MetaModel::Init_Params($aParams);
//MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeString("_name_", array("label"=>"namo", "description"=>"official company name", "allowed_values"=>null, "sql"=>"name", "default_value"=>"XXXX", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeEnum("_status_", array("label"=>"step", "description"=>"step or status, etc.", "allowed_values"=>null, "sql"=>"status", "default_value"=>"XXXX", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeInteger("_dunsnumber_", array("label"=>"duns debile number", "description"=>"une bonne idee a OVSD", "allowed_values"=>null, "sql"=>"dunsnumber", "default_value"=>99007, "is_null_allowed"=>false, "depends_on"=>array())));
// not yet allowed MetaModel::Init_AddAttribute(new AttributeInteger("_dunsnumberBY2_", array("label"=>"dummy duns", "description"=>"deux fois plus debile", "allowed_values"=>null, "sql"=>"dunsnumber * 3.141592654")));
MetaModel::Init_InheritFilters();
MetaModel::Init_AddFilterFromAttribute("_name_");
MetaModel::Init_SetZListItems("list1", array("_status_"));
MetaModel::Init_SetZListItems("list2", array());
MetaModel::Init_SetZListItems("list3", array("_name_"));
}
}
/**
* blah blah
*
* @package iTopUnitTests
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version 1.1.1.1 $
*/
class cmdbLiens extends cmdbObjectHomeMade
{
public static function Init()
{
$aParams = array
(
"category" => "blah",
"name" => "Liens_entre_contacts_et_workshop",
"description" => "Une entite qui lie des contacts et workshops",
"key_type" => "autoincrement",
"key_label" => "",
"name_attcode" => "function",
"state_attcode" => "",
"reconc_keys" => array("function"),
"db_table" => "role_ws",
"db_key_field" => "linkid",
"db_finalclass_field" => "",
);
MetaModel::Init_Params($aParams);
//MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeString("function", array("label"=>"fonction", "description"=>"la fonction...", "allowed_values"=>null, "sql"=>"function", "default_value"=>"XXXX", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("a1", array("label"=>"a1", "description"=>"a1", "allowed_values"=>null, "sql"=>"a1", "default_value"=>"XXXX", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("a2", array("label"=>"a1", "description"=>"a2", "allowed_values"=>null, "sql"=>"a2", "default_value"=>"XXXX", "is_null_allowed"=>true, "depends_on"=>array())));
// What makes it being a link...
MetaModel::Init_AddAttribute(new AttributeExternalKey("toworkshop", array("label"=>"participates in", "description"=>"workshop in wich the person is participating", "allowed_values"=>null, "sql"=>"ws_id", "targetclass"=>"cmdbWorkshop", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("ws_info", array("label"=>"name", "description"=>"namedescription", "allowed_values"=>null, "extkey_attcode"=>"toworkshop", "target_attcode"=>"namitus")));
MetaModel::Init_AddAttribute(new AttributeExternalKey("tocontact", array("label"=>"is held by", "description"=>"people involved in that mess", "allowed_values"=>null, "sql"=>"contactid", "targetclass"=>"cmdbContact", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("contact_info", array("label"=>"name", "description"=>"namedescription", "allowed_values"=>null, "extkey_attcode"=>"tocontact", "target_attcode"=>"name")));
MetaModel::Init_InheritFilters();
MetaModel::Init_AddFilterFromAttribute("function");
MetaModel::Init_SetZListItems("list1", array("toworkshop", "contact_info"));
MetaModel::Init_SetZListItems("list2", array("function"));
MetaModel::Init_SetZListItems("list3", array("function"));
}
public static function GetRelationQueries($sRelCode)
{
throw new CoreException("GetRelationQueries: cmdbLiens");
return array("Relies on" => array("sQuery"=>"", "bPropagate"=>true, "iDistance"=>3));
}
}
/**
* blah blah
*
* @package iTopUnitTests
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version 1.1.1.1 $
*/
class cmdbWorkshop extends cmdbObjectHomeMade
{
public static function Init()
{
$aParams = array
(
"category" => "blah",
"name" => "Workshop",
"description" => "Une entite qui pond des theories insensees",
"key_type" => "autoincrement",
"key_label" => "",
"name_attcode" => "namitus",
"state_attcode" => "",
"reconc_keys" => array("namitus"),
"db_table" => "workshop",
"db_key_field" => "ws_id",
"db_finalclass_field" => "",
);
MetaModel::Init_Params($aParams);
//MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeString("namitus", array("label"=>"namo", "description"=>"nom imbitique pour pondeurs de debilites", "allowed_values"=>null, "sql"=>"name", "default_value"=>"XXXX", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_InheritFilters();
MetaModel::Init_AddFilterFromAttribute("namitus");
MetaModel::Init_SetZListItems("list1", array("namitus"));
MetaModel::Init_SetZListItems("list2", array());
MetaModel::Init_SetZListItems("list3", array("namitus"));
}
public static function GetRelationQueries($sRelCode)
{
throw new CoreException("GetRelationQueries: cmdbWorkshop");
return array("Relies on" => array("sQuery"=>"", "bPropagate"=>true, "iDistance"=>3));
}
}
?>

File diff suppressed because it is too large Load Diff

View File

@@ -1,372 +0,0 @@
<?php
/**
* incident<business<php
* Define business model for incident mgmt module
*
* @package iTopBizModelSamples
* @author Erwan Taloc <erwan.taloc@gmail.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version 1.1.1.1 $
*/
////////////////////////////////////////////////////////////////////////////////////
/**
* An Incident Ticket
*/
////////////////////////////////////////////////////////////////////////////////////
class bizIncidentTicket extends cmdbAbstractObject
{
public static function Init()
{
$aParams = array
(
"category" => "bizmodel,searchable",
"name" => "Incident",
"description" => "Incident ticket",
"key_type" => "autoincrement",
"key_label" => "id",
"name_attcode" => "name",
"state_attcode" => "ticket_status",
"reconc_keys" => array("title"),
"db_table" => "incident",
"db_key_field" => "id",
"db_finalclass_field" => "",
"display_template" => "../business/templates/ticket.html",
);
MetaModel::Init_Params($aParams);
//MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeString("name", array("label"=>"Ticket Ref", "description"=>"Refence number ofr this incident", "allowed_values"=>null, "sql"=>"name", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("title", array("label"=>"Title", "description"=>"Overview of the Incident", "allowed_values"=>null, "sql"=>"title", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeEnum("type", array("label"=>"Type", "description"=>"Type of the Incident", "allowed_values"=>new ValueSetEnum("Network,Server,Desktop,Application"), "sql"=>"type", "default_value"=>"Server", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalKey("org_id", array("targetclass"=>"bizOrganization", "label"=>"Customer", "description"=>"who is impacted by the ticket", "allowed_values"=>null, "sql"=>"customer", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("customer_name", array("label"=>"Customer", "description"=>"Name of the customer impacted by this ticket", "allowed_values"=>null, "extkey_attcode"=> 'org_id', "target_attcode"=>"name")));
MetaModel::Init_AddAttribute(new AttributeEnum("ticket_status", array("label"=>"Status", "description"=>"Status of the ticket", "allowed_values"=>new ValueSetEnum("New, Assigned, WorkInProgress, Resolved, Closed"), "sql"=>"ticket_status", "default_value"=>"New", "is_null_allowed"=>false, "depends_on"=>array())));
// SetPossibleValues("status",array("Open","Monitored","Closed"));
MetaModel::Init_AddAttribute(new AttributeText("initial_situation", array("label"=>"Initial Situation", "description"=>"Initial situation of the Incident", "allowed_values"=>null, "sql"=>"initial_situation", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("current_situation", array("label"=>"Current Situation", "description"=>"Current situation of the Incident", "allowed_values"=>null, "sql"=>"current_situation", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeDate("start_date", array("label"=>"Starting date", "description"=>"Incident starting date", "allowed_values"=>null, "sql"=>"start_date", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
// définir une date de défaut à maintenant, alias creation ou modification du ticket
MetaModel::Init_AddAttribute(new AttributeDate("last_update", array("label"=>"Last update", "description"=>"last time the Ticket was modified", "allowed_values"=>null, "sql"=>"last_update", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeDate("next_update", array("label"=>"Next update", "description"=>"next time the Ticket is expected to be modified", "allowed_values"=>null, "sql"=>"next_update", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeDate("end_date", array("label"=>"Closure Date", "description"=>"Date when the Ticket was closed", "allowed_values"=>null, "sql"=>"closed_date", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalKey("caller_id", array("targetclass"=>"bizPerson", "jointype"=> "", "label"=>"Caller", "description"=>"person that trigger incident", "allowed_values"=>new ValueSetObjects('SELECT bizPerson AS p WHERE p.org_id = :this->org_id'), "sql"=>"caller_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array("org_id"))));
MetaModel::Init_AddAttribute(new AttributeExternalField("caller_mail", array("label"=>"Caller", "description"=>"Person that trigger this incident", "allowed_values"=>null, "extkey_attcode"=> 'caller_id', "target_attcode"=>"email")));
MetaModel::Init_AddAttribute(new AttributeString("impact", array("label"=>"Impact", "description"=>"Impact of the Incident", "allowed_values"=>null, "sql"=>"impact", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalKey("workgroup_id", array("targetclass"=>"bizWorkgroup", "jointype"=> "", "label"=>"Workgroup", "description"=>"which workgroup is owning ticket", "allowed_values"=>null, "sql"=>"workgroup_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("workgroup_name", array("label"=>"Workgroup", "description"=>"name of workgroup managing the Ticket", "allowed_values"=>null, "extkey_attcode"=> 'workgroup_id', "target_attcode"=>"name")));
MetaModel::Init_AddAttribute(new AttributeExternalKey("agent_id", array("targetclass"=>"bizPerson", "jointype"=> "", "label"=>"Agent", "description"=>"who is managing the ticket", "allowed_values"=>new ValueSetObjects('SELECT bizPerson AS p JOIN lnkContactTeam AS l ON l.contact_id=p.id JOIN bizTeam AS t ON l.team_id=t.id JOIN bizWorkgroup AS w ON w.team_id=t.id WHERE w.id = :this->workgroup_id'), "sql"=>"agent_id", "is_null_allowed"=>true, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array('workgroup_id'))));
MetaModel::Init_AddAttribute(new AttributeExternalField("agent_mail", array("label"=>"Agent", "description"=>"mail of agent managing the Ticket", "allowed_values"=>null, "extkey_attcode"=> 'agent_id', "target_attcode"=>"email")));
// Comment afficher le first + last name de l'agent ? Est-ce utile d'ajouter ce champ?
MetaModel::Init_AddAttribute(new AttributeText("action_log", array("label"=>"Action Logs", "description"=>"List all action performed during the incident", "allowed_values"=>null, "sql"=>"action_log", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeEnum("severity", array("label"=>"Severity", "description"=>"Field defining the criticity if the incident", "allowed_values"=>new ValueSetEnum("critical,medium,low"), "sql"=>"criticity", "default_value"=>"low", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeInteger("assignment_count", array("label"=>"Assignment Count", "description"=>"Number of times this ticket was assigned or reassigned", "allowed_values"=>null, "sql"=>"assignment_count", "default_value"=>0, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("resolution", array("label"=>"Resolution", "description"=>"Description of the resolution", "allowed_values"=>null, "sql"=>"resolution", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeLinkedSetIndirect("impacted_infra_manual", array("label"=>"Impacted Infrastructure", "description"=>"CIs that are not meeting the SLA", "linked_class"=>"lnkInfraTicket", "ext_key_to_me"=>"ticket_id", "ext_key_to_remote"=>"infra_id", "allowed_values"=>null, "count_min"=>1, "count_max"=>0, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeLinkedSetIndirect("related_tickets", array("label"=>"Related Tickets", "description"=>"Other incident tickets related to this one", "linked_class"=>"lnkRelatedTicket", "ext_key_to_me"=>"ticket_id", "ext_key_to_remote"=>"rel_ticket_id", "allowed_values"=>null, "count_min"=>0, "count_max"=>0, "depends_on"=>array(/*'impacted_infra_computed',*/ 'impacted_infra_manual'))));
//MetaModel::Init_InheritFilters();
MetaModel::Init_AddFilterFromAttribute("name");
MetaModel::Init_AddFilterFromAttribute("title");
MetaModel::Init_AddFilterFromAttribute("type");
MetaModel::Init_AddFilterFromAttribute("org_id");
MetaModel::Init_AddFilterFromAttribute("caller_id");
MetaModel::Init_AddFilterFromAttribute("ticket_status");
MetaModel::Init_AddFilterFromAttribute("start_date");
MetaModel::Init_AddFilterFromAttribute("last_update");
MetaModel::Init_AddFilterFromAttribute("end_date");
MetaModel::Init_AddFilterFromAttribute("workgroup_id");
MetaModel::Init_AddFilterFromAttribute("agent_id");
MetaModel::Init_AddFilterFromAttribute("severity");
MetaModel::Init_AddFilterFromAttribute("assignment_count");
// doit-on aussi ajouter un filtre sur les extfields lié à une extkey ? ici le name de l'agent?
// Display lists
MetaModel::Init_SetZListItems('details', array('name','title', 'org_id', 'type','ticket_status', 'severity','start_date', 'initial_situation', 'current_situation','caller_id', 'impact', 'last_update', 'next_update','end_date', 'assignment_count', 'workgroup_id','agent_id','action_log','resolution')); // Attributes to be displayed for a list
MetaModel::Init_SetZListItems('list', array('name', 'title', 'org_id', 'type','ticket_status','severity','start_date', 'initial_situation')); // Attributes to be displayed for a list
// Search criteria
MetaModel::Init_SetZListItems('standard_search', array('name', 'title', 'org_id', 'caller_id','type', 'ticket_status', 'severity','start_date', 'last_update','end_date','agent_id')); // Criteria of the std search form
MetaModel::Init_SetZListItems('advanced_search', array('name', 'title', 'org_id','caller_id','type','ticket_status', 'severity','start_date', 'last_update', 'end_date','agent_id')); // Criteria of the advanced search form
// State machine
MetaModel::Init_DefineState("New", array("label"=>"New (Unassigned)", "description"=>"Newly created ticket", "attribute_inherit"=>null,
"attribute_list"=>array('name' => OPT_ATT_READONLY, 'assignment_count' => OPT_ATT_HIDDEN, 'end_date' => OPT_ATT_HIDDEN, 'next_update' => OPT_ATT_HIDDEN, 'last_update' => OPT_ATT_HIDDEN,
"title"=>OPT_ATT_MANDATORY, "org_id"=>OPT_ATT_MANDATORY, "caller_id"=>OPT_ATT_MANDATORY, "initial_situation"=>OPT_ATT_MANDATORY, "start_date"=>OPT_ATT_MANDATORY, "workgroup_id"=>OPT_ATT_MANDATORY,
"severity"=>OPT_ATT_MANDATORY, "agent_id"=>OPT_ATT_HIDDEN,"impacted_infra_manual"=>OPT_ATT_MANDATORY, "related_tickets"=>OPT_ATT_MUSTPROMPT,"resolution"=>OPT_ATT_HIDDEN)));
MetaModel::Init_DefineState("Assigned", array("label"=>"Assigned", "description"=>"Ticket is assigned to somebody", "attribute_inherit"=>null,
"attribute_list"=>array('name' => OPT_ATT_READONLY, "title"=>OPT_ATT_READONLY, "org_id"=>OPT_ATT_READONLY, "caller_id"=>OPT_ATT_READONLY, "initial_situation"=>OPT_ATT_READONLY, "start_date"=>OPT_ATT_READONLY,'assignment_count' => OPT_ATT_READONLY,'end_date' => OPT_ATT_HIDDEN, "workgroup_id"=>OPT_ATT_READONLY, "agent_id"=>OPT_ATT_MUSTCHANGE,"resolution"=>OPT_ATT_HIDDEN)));
MetaModel::Init_DefineState("WorkInProgress", array("label"=>"Work In Progress", "description"=>"Work is in progress", "attribute_inherit"=>null, "attribute_list"=>array("title"=>OPT_ATT_READONLY, "org_id"=>OPT_ATT_READONLY, "caller_id"=>OPT_ATT_READONLY, "initial_situation"=>OPT_ATT_READONLY,'end_date' => OPT_ATT_HIDDEN, "start_date"=>OPT_ATT_READONLY,"workgroup_id"=>OPT_ATT_MANDATORY, "agent_id"=>OPT_ATT_MANDATORY,"action_log"=>OPT_ATT_MANDATORY,"impact"=>OPT_ATT_READONLY,"severity"=>OPT_ATT_READONLY)));
MetaModel::Init_DefineState("Resolved", array("label"=>"Resolved", "description"=>"Ticket is resolved", "attribute_inherit"=>null, "attribute_list"=>array('name' => OPT_ATT_READONLY,'type' => OPT_ATT_READONLY, "title"=>OPT_ATT_READONLY, "org_id"=>OPT_ATT_READONLY, "caller_id"=>OPT_ATT_READONLY, "initial_situation"=>OPT_ATT_READONLY,"current_situation"=>OPT_ATT_READONLY,'end_date' => OPT_ATT_READONLY,'last_update' => OPT_ATT_READONLY,'next_update' => OPT_ATT_READONLY, "start_date"=>OPT_ATT_READONLY,"workgroup_id"=>OPT_ATT_READONLY, "agent_id"=>OPT_ATT_READONLY,"action_log"=>OPT_ATT_READONLY,"impact"=>OPT_ATT_READONLY,"severity"=>OPT_ATT_READONLY,"resolution"=>OPT_ATT_MUSTCHANGE)));
MetaModel::Init_DefineState("Closed", array("label"=>"Closed", "description"=>"Ticket is closed", "attribute_inherit"=>null, "attribute_list"=>array('name' => OPT_ATT_READONLY,'type' => OPT_ATT_READONLY, "title"=>OPT_ATT_READONLY, "org_id"=>OPT_ATT_READONLY, "caller_id"=>OPT_ATT_READONLY, "initial_situation"=>OPT_ATT_READONLY,"current_situation"=>OPT_ATT_READONLY,'end_date' => OPT_ATT_READONLY,'last_update' => OPT_ATT_READONLY,'next_update' => OPT_ATT_READONLY, "start_date"=>OPT_ATT_READONLY,"workgroup_id"=>OPT_ATT_READONLY, "agent_id"=>OPT_ATT_READONLY,"action_log"=>OPT_ATT_READONLY,"impact"=>OPT_ATT_READONLY,"severity"=>OPT_ATT_READONLY,"resolution"=>OPT_ATT_READONLY)));
MetaModel::Init_DefineStimulus("ev_assign", new StimulusUserAction(array("label"=>"Assign this ticket", "description"=>"Assign this ticket to a group and an agent")));
MetaModel::Init_DefineStimulus("ev_reassign", new StimulusUserAction(array("label"=>"Reassign this ticket", "description"=>"Reassign this ticket to a different group and agent")));
MetaModel::Init_DefineStimulus("ev_start_working", new StimulusUserAction(array("label"=>"Work on this ticket", "description"=>"Start working on this ticket")));
MetaModel::Init_DefineStimulus("ev_resolve", new StimulusUserAction(array("label"=>"Resolve this ticket", "description"=>"Resolve this ticket")));
MetaModel::Init_DefineStimulus("ev_close", new StimulusUserAction(array("label"=>"Close this ticket", "description"=>"Close this ticket")));
MetaModel::Init_DefineTransition("New", "ev_assign", array("target_state"=>"Assigned", "actions"=>array('IncrementAssignmentCount'), "user_restriction"=>null));
MetaModel::Init_DefineTransition("Assigned", "ev_reassign", array("target_state"=>"Assigned", "actions"=>array('IncrementAssignmentCount','SetLastUpdate'), "user_restriction"=>null));
MetaModel::Init_DefineTransition("Assigned", "ev_start_working", array("target_state"=>"WorkInProgress", "actions"=>array('SetLastUpdate'), "user_restriction"=>null));
MetaModel::Init_DefineTransition("WorkInProgress", "ev_reassign", array("target_state"=>"Assigned", "actions"=>array('IncrementAssignmentCount','SetLastUpdate'), "user_restriction"=>null));
MetaModel::Init_DefineTransition("WorkInProgress", "ev_resolve", array("target_state"=>"Resolved", "actions"=>array('SetLastUpdate'), "user_restriction"=>null));
MetaModel::Init_DefineTransition("Resolved", "ev_close", array("target_state"=>"Closed", "actions"=>array('SetClosureDate','SetLastUpdate'), "user_restriction"=>null));
}
public function Generate(cmdbDataGenerator $oGenerator)
{
$this->Set('org_id', $oGenerator->GetOrganizationId());
$this->Set('title', $oGenerator->GenerateString("enum(Site,Server,Line)| |enum(is down,is flip-flopping,is not responding)"));
$this->Set('agent_id', $oGenerator->GenerateKey("bizPerson", array('org_id' =>$oGenerator->GetOrganizationId() )));
$this->Set('ticket_status', $oGenerator->GenerateString("enum(Open,Closed,Closed,Monitored)"));
$this->Set('start_date', $oGenerator->GenerateString("2007-|number(07-12)|-|number(01-30)| |number(07-12)|:|number(00-59)|:|number(00-59)"));
$this->Set('last_update', $oGenerator->GenerateString("2007-|number(07-12)|-|number(01-30)| |number(07-12)|:|number(00-59)|:|number(00-59)"));
$this->Set('end_date', $oGenerator->GenerateString("2007-|number(07-12)|-|number(01-30)| |number(07-12)|:|number(00-59)|:|number(00-59)"));
}
// State machine actions
public function IncrementAssignmentCount($sStimulusCode)
{
$this->Set('assignment_count', $this->Get('assignment_count') + 1);
return true;
}
public function SetClosureDate($sStimulusCode)
{
$this->Set('end_date', time());
return true;
}
public function SetLastUpdate($sStimulusCode)
{
$this->Set('last_update', time());
return true;
}
public function ComputeValues()
{
$iKey = $this->GetKey();
if ($iKey < 0)
{
// Object not yet in the Database
$iKey = MetaModel::GetNextKey(get_class($this));
}
$sName = sprintf('I-%06d', $iKey);
$this->Set('name', $sName);
}
}
////////////////////////////////////////////////////////////////////////////////////
/**
* n-n link between any Infra and a Incident
*/
////////////////////////////////////////////////////////////////////////////////////
class lnkRelatedTicket extends cmdbAbstractObject
{
public static function Init()
{
$aParams = array
(
"category" => "bizmodel,searchable",
"name" => "Related Ticket",
"description" => "Ticket related to a ticket",
"key_type" => "autoincrement",
"key_label" => "link_id",
"name_attcode" => "impact", // ????
"state_attcode" => "",
"reconc_keys" => array("impact"), // ????
"db_table" => "related_ticket",
"db_key_field" => "link_id",
"db_finalclass_field" => "",
"display_template" => "../business/templates/default.html",
);
MetaModel::Init_Params($aParams);
MetaModel::Init_AddAttribute(new AttributeExternalKey("rel_ticket_id", array("targetclass"=>"bizIncidentTicket", "jointype"=> '', "label"=>"Related Ticket", "description"=>"The related ticket", "allowed_values"=>null, "sql"=>"rel_ticket_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("rel_ticket_name", array("label"=>"Related ticket", "description"=>"Name of the related ticket", "allowed_values"=>null, "extkey_attcode"=> 'rel_ticket_id', "target_attcode"=>"title")));
MetaModel::Init_AddAttribute(new AttributeExternalKey("ticket_id", array("targetclass"=>"bizIncidentTicket", "jointype"=> '', "label"=>"Ticket", "description"=>"Ticket number", "allowed_values"=>null, "sql"=>"ticket_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("ticket_name", array("label"=>"Ticket Name", "description"=>"Name of the ticket", "allowed_values"=>null, "extkey_attcode"=> 'ticket_id', "target_attcode"=>"title")));
MetaModel::Init_AddAttribute(new AttributeString("impact", array("label"=>"Impact", "description"=>"Impact on the related ticket", "allowed_values"=>null, "sql"=>"impact", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddFilterFromAttribute("rel_ticket_id");
MetaModel::Init_AddFilterFromAttribute("ticket_id");
// Display lists
MetaModel::Init_SetZListItems('details', array('rel_ticket_id', 'ticket_id', 'impact')); // Attributes to be displayed for a list
MetaModel::Init_SetZListItems('list', array('rel_ticket_id', 'ticket_id', 'impact')); // Attributes to be displayed for a list
// Search criteria
MetaModel::Init_SetZListItems('standard_search', array('rel_ticket_id', 'ticket_id')); // Criteria of the std search form
MetaModel::Init_SetZListItems('advanced_search', array('rel_ticket_id', 'ticket_id')); // Criteria of the advanced search form
}
public function Generate(cmdbDataGenerator $oGenerator)
{
$this->Set('infra_id', $oGenerator->GenerateKey("logInfra", array('org_id' =>$oGenerator->GetOrganizationId() )));
$this->Set('ticket_id', $oGenerator->GenerateKey("bizIncidentTicket", array('org_id' =>$oGenerator->GetOrganizationId() )));
$this->Set('impact', $oGenerator->GenerateString("enum(none,mandatory,partial)"));
}
}
////////////////////////////////////////////////////////////////////////////////////
/**
* n-n link between any Infra and a Incident
*/
////////////////////////////////////////////////////////////////////////////////////
class lnkInfraTicket extends cmdbAbstractObject
{
public static function Init()
{
$aParams = array
(
"category" => "bizmodel,searchable",
"name" => "Infra Ticket",
"description" => "Infra impacted by a ticket",
"key_type" => "autoincrement",
"key_label" => "link_id",
"name_attcode" => "impact", // ????
"state_attcode" => "",
"reconc_keys" => array("impact"), // ????
"db_table" => "infra_ticket",
"db_key_field" => "link_id",
"db_finalclass_field" => "",
"display_template" => "../business/templates/default.html",
);
MetaModel::Init_Params($aParams);
MetaModel::Init_AddAttribute(new AttributeExternalKey("infra_id", array("targetclass"=>"logInfra", "jointype"=> '', "label"=>"Infrastructure", "description"=>"The infrastructure impacted", "allowed_values"=>null, "sql"=>"infra_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("infra_name", array("label"=>"Infrastructure Name", "description"=>"Name of the impacted infrastructure", "allowed_values"=>null, "extkey_attcode"=> 'infra_id', "target_attcode"=>"name")));
MetaModel::Init_AddAttribute(new AttributeExternalKey("ticket_id", array("targetclass"=>"bizIncidentTicket", "jointype"=> '', "label"=>"Ticket #", "description"=>"Ticket number", "allowed_values"=>null, "sql"=>"ticket_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("ticket_name", array("label"=>"Ticket Name", "description"=>"Name of the ticket", "allowed_values"=>null, "extkey_attcode"=> 'ticket_id', "target_attcode"=>"title")));
MetaModel::Init_AddAttribute(new AttributeString("impact", array("label"=>"Impact", "description"=>"Level of impact of the infra by the related ticket", "allowed_values"=>null, "sql"=>"impact", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddFilterFromAttribute("infra_id");
MetaModel::Init_AddFilterFromAttribute("ticket_id");
// Display lists
MetaModel::Init_SetZListItems('details', array('infra_id', 'ticket_id', 'impact')); // Attributes to be displayed for a list
MetaModel::Init_SetZListItems('list', array('infra_id', 'ticket_id', 'impact')); // Attributes to be displayed for a list
// Search criteria
MetaModel::Init_SetZListItems('standard_search', array('infra_id', 'ticket_id')); // Criteria of the std search form
MetaModel::Init_SetZListItems('advanced_search', array('infra_id', 'ticket_id')); // Criteria of the advanced search form
}
public function Generate(cmdbDataGenerator $oGenerator)
{
$this->Set('infra_id', $oGenerator->GenerateKey("logInfra", array('org_id' =>$oGenerator->GetOrganizationId() )));
$this->Set('ticket_id', $oGenerator->GenerateKey("bizIncidentTicket", array('org_id' =>$oGenerator->GetOrganizationId() )));
$this->Set('impact', $oGenerator->GenerateString("enum(none,mandatory,partial)"));
}
}
////////////////////////////////////////////////////////////////////////////////////
/**
* n-n link between any Contqct and a Incident
*/
////////////////////////////////////////////////////////////////////////////////////
class lnkContactTicket extends cmdbAbstractObject
{
public static function Init()
{
$aParams = array
(
"category" => "bizmodel,searchable",
"name" => "Contact Ticket",
"description" => "Contacts to be notify for a ticket",
"key_type" => "autoincrement",
"key_label" => "link_id",
"name_attcode" => "role", // ????
"state_attcode" => "",
"reconc_keys" => array("role"), // ????
"db_table" => "contact_ticket",
"db_key_field" => "link_id",
"db_finalclass_field" => "",
"display_template" => "../business/templates/default.html",
);
MetaModel::Init_Params($aParams);
MetaModel::Init_AddAttribute(new AttributeExternalKey("contact_id", array("targetclass"=>"bizContact", "jointype"=> '', "label"=>"Contact", "description"=>"Contact to Notify", "allowed_values"=>null, "sql"=>"contact_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("contact_email", array("label"=>"Contact email", "description"=>"Mail for the contact", "allowed_values"=>null, "extkey_attcode"=> 'contact_id', "target_attcode"=>"email")));
MetaModel::Init_AddAttribute(new AttributeExternalKey("ticket_id", array("targetclass"=>"bizIncidentTicket", "jointype"=> '', "label"=>"Ticket #", "description"=>"Ticket number", "allowed_values"=>null, "sql"=>"ticket_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("ticket_name", array("label"=>"Ticket Name", "description"=>"Name of the ticket", "allowed_values"=>null, "extkey_attcode"=> 'ticket_id', "target_attcode"=>"title")));
MetaModel::Init_AddAttribute(new AttributeString("role", array("label"=>"Role", "description"=>"Role of the contact", "allowed_values"=>null, "sql"=>"role", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddFilterFromAttribute("contact_id");
MetaModel::Init_AddFilterFromAttribute("ticket_id");
// Display lists
MetaModel::Init_SetZListItems('details', array('contact_id', 'ticket_id', 'role')); // Attributes to be displayed for a list
MetaModel::Init_SetZListItems('list', array('contact_id', 'ticket_id', 'role')); // Attributes to be displayed for a list
// Search criteria
MetaModel::Init_SetZListItems('standard_search', array('contact_id', 'ticket_id')); // Criteria of the std search form
MetaModel::Init_SetZListItems('advanced_search', array('contact_id', 'ticket_id')); // Criteria of the advanced search form
}
public function Generate(cmdbDataGenerator $oGenerator)
{
$this->Set('infra_id', $oGenerator->GenerateKey("logInfra", array('org_id' =>$oGenerator->GetOrganizationId() )));
$this->Set('ticket_id', $oGenerator->GenerateKey("bizIncidentTicket", array('org_id' =>$oGenerator->GetOrganizationId() )));
$this->Set('impact', $oGenerator->GenerateString("enum(none,mandatory,partial)"));
}
}
////////////////////////////////////////////////////////////////////////////////////
//**
//* A workgroup is a queue in a given call tracking system
//* It belongs to a team and a given organization
////////////////////////////////////////////////////////////////////////////////////
class bizWorkgroup extends logRealObject
{
public static function Init()
{
$aParams = array
(
"category" => "bizmodel,searchable",
"name" => "Workgroup",
"description" => "Call tracking workgroup",
"key_type" => "",
"key_label" => "id",
"name_attcode" => "name",
"state_attcode" => "",
"reconc_keys" => array("org_name", "name"), // inherited attributes
"db_table" => "workgroups",
"db_key_field" => "id",
"db_finalclass_field" => "",
"display_template" => "../business/templates/default.html",
);
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeEnum("status", array("label"=>"Status", "description"=>"Lifecycle status", "allowed_values"=>new ValueSetEnum('production,implementation,obsolete'), "sql"=>"status", "default_value"=>"implementation", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("org_name", array("label"=>"Organization", "description"=>"Company / Department owning this object", "allowed_values"=>null, "extkey_attcode"=> 'org_id', "target_attcode"=>"name")));
MetaModel::Init_AddAttribute(new AttributeExternalKey("team_id", array("targetclass"=>"bizTeam", "label"=>"Team", "description"=>"Team owning the workgroup", "allowed_values"=>null, "sql"=>"team_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("team_name", array("label"=>"Team Name", "description"=>"name of the team", "allowed_values"=>null, "extkey_attcode"=> 'team_id', "target_attcode"=>"name")));
MetaModel::Init_AddAttribute(new AttributeString("role", array("label"=>"Role", "description"=>"Role of this work group", "allowed_values"=>new ValueSetEnum("1st level support,2nd level support,3rd level support"), "sql"=>"role", "default_value"=>"1st level support", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_InheritFilters();
MetaModel::Init_AddFilterFromAttribute("org_name");
MetaModel::Init_AddFilterFromAttribute("team_id");
MetaModel::Init_AddFilterFromAttribute("role");
// Display lists
MetaModel::Init_SetZListItems('details', array('name', 'status', 'org_id', 'team_id', 'role')); // Attributes to be displayed for the complete details
MetaModel::Init_SetZListItems('list', array('name', 'team_id','role')); // Attributes to be displayed for a list
// Search criteria
MetaModel::Init_SetZListItems('standard_search', array('name', 'status', 'team_id')); // Criteria of the std search form
MetaModel::Init_SetZListItems('advanced_search', array('name', 'status', 'team_id','role')); // Criteria of the advanced search form
}
}
?>

File diff suppressed because it is too large Load Diff

View File

@@ -1,30 +0,0 @@
<div class="page_header">
<itopblock blockclass="MenuBlock" type="popup" encoding="text/oql" label="Actions">SELECT $class$ WHERE id = $pkey$</itopblock>
<h1>$class_name$: <span class="hilite">$name$</span></h1>
<itopblock blockclass="HistoryBlock" type="toggle" encoding="text/oql">SELECT CMDBChangeOp WHERE objkey = $pkey$ AND objclass = '$class$'</itopblock>
</div>
<img src="../images/software.jpg" style="margin-top:-10px; margin-right:10px; float:right">
<itopblock blockclass="DisplayBlock" asynchronous="false" type="bare_details" encoding="text/oql">SELECT bizApplication WHERE id = $pkey$</itopblock>
<itoptabs>
<itoptab name="Impacted_Client_Applications">
<itopblock blockclass="DisplayBlock" type="links" link_attr="server_id" object_id="$pkey$" target_attr="client_id" encoding="text/oql">SELECT lnkClientServer WHERE server_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Application_Server">
<itopblock blockclass="DisplayBlock" type="links" link_attr="client_id" object_id="$pkey$" target_attr="server_id" encoding="text/oql">SELECT lnkClientServer WHERE client_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Incidents">
<itopblock blockclass="DisplayBlock" type="links" link_attr="infra_id" object_id="$pkey$" target_attr="ticket_id" encoding="text/sibusql">lnkInfraTicket: infra_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Changes">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/sibusql">bizChangeTicket: PKEY IS ticket_id IN (lnkInfraChangeTicket: infra_id = $pkey$)</itopblock>
</itoptab>
<itoptab name="Contracts">
<itopblock blockclass="DisplayBlock" type="links" link_attr="infra_id" object_id="$pkey$" target_attr="contract_id" encoding="text/oql">SELECT lnkInfraContract WHERE infra_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Groups">
<itopblock blockclass="DisplayBlock" type="links" link_attr="infra_id" object_id="$pkey$" target_attr="infra_group_id" encoding="text/oql">SELECT lnkInfraGrouping WHERE infra_id = $pkey$</itopblock>
</itoptab>
</itoptabs>

View File

@@ -1,17 +0,0 @@
<div class="page_header">
<itopblock blockclass="MenuBlock" type="popup" encoding="text/oql" label="Actions">SELECT $class$ WHERE id = $pkey$</itopblock>
<h1>$class_name$: <span class="hilite">$name$</span></h1>
<itopblock blockclass="HistoryBlock" type="toggle" encoding="text/oql">SELECT CMDBChangeOp WHERE objkey = $pkey$ AND objclass = '$class$'</itopblock>
</div>
<img src="../images/imageChange.gif" style="margin-top:-10px; margin-right:10px; float:right">
<itopblock blockclass="DisplayBlock" asynchronous="false" type="bare_details" encoding="text/oql">SELECT $class$ WHERE id = $pkey$</itopblock>
<itoptabs>
<itoptab name="Impacted_Infrastructures">
<itopblock blockclass="DisplayBlock" type="links" link_attr="ticket_id" object_id="$pkey$" target_attr="infra_id" encoding="text/oql">SELECT lnkInfraChangeTicket WHERE ticket_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Contacts_to_Notify">
<itopblock blockclass="DisplayBlock" type="links" link_attr="change_id" object_id="$pkey$" target_attr="contact_id" encoding="text/oql">SELECT lnkContactChange WHERE change_id = $pkey$</itopblock>
</itoptab>
</itoptabs>
<br style="clear:both"/>

View File

@@ -1,21 +0,0 @@
<div class="page_header">
<itopblock blockclass="MenuBlock" type="popup" encoding="text/sibusql" label="Actions">$class$: pkey = $pkey$</itopblock>
<h1>$class_name$: <span class="hilite">$name$</span></h1>
<itopblock blockclass="HistoryBlock" type="toggle" encoding="text/oql">SELECT CMDBChangeOp WHERE objkey = $pkey$ AND objclass = '$class$'</itopblock>
</div>
<img src="../images/WanLinks.jpg" style="margin-top:-10px; margin-right:10px; float:right">
<itopblock blockclass="DisplayBlock" asynchronous="false" type="bare_details" encoding="text/sibusql">$class$: pkey = $pkey$</itopblock>
<itoptabs>
<itoptab name="Contacts">
<itopblock blockclass="DisplayBlock" type="links" link_attr="object_id" object_id="$pkey$" target_attr="contact_id" encoding="text/oql">SELECT lnkContactRealObject WHERE object_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Incidents">
<itopblock blockclass="DisplayBlock" type="links" link_attr="infra_id" object_id="$pkey$" target_attr="ticket_id" encoding="text/oql">SELECT lnkInfraTicket WHERE infra_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Changes">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/oql">SELECT bizChangeTicket AS Change JOIN lnkInfraChangeTicket AS Link ON Link.ticket_id = Change.id WHERE Link.infra_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Documents">
<itopblock blockclass="DisplayBlock" type="links" link_attr="object_id" object_id="$pkey$" target_attr="doc_id" encoding="text/oql">SELECT lnkDocumentRealObject WHERE object_id = $pkey$</itopblock>
</itoptab>
</itoptabs>

View File

@@ -1,18 +0,0 @@
<div class="page_header">
<itopblock blockclass="MenuBlock" type="popup" encoding="text/oql" label="Actions">SELECT $class$ WHERE id = $pkey$</itopblock>
<h1>$class_name$: <span class="hilite">$name$</span></h1>
<itopblock blockclass="HistoryBlock" type="toggle" encoding="text/oql">SELECT CMDBChangeOp WHERE objkey = $pkey$ AND objclass = '$class$'</itopblock>
</div>
<img src="../images/erwanContracts.jpg" style="margin-top:-10px; margin-right:10px; float:right">
<itopblock blockclass="DisplayBlock" asynchronous="false" type="bare_details" encoding="text/oql">SELECT bizContract WHERE id = $pkey$</itopblock>
<itoptabs>
<itoptab name="Covered_Infrastructures">
<itopblock blockclass="DisplayBlock" type="links" link_attr="contract_id" object_id="$pkey$" target_attr="infra_id" encoding="text/oql">SELECT lnkInfraContract WHERE contract_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Contacts">
<itopblock blockclass="DisplayBlock" type="links" link_attr="contract_id" object_id="$pkey$" target_attr="contact_id" encoding="text/oql">SELECT lnkContactContract WHERE contract_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Documents">
<itopblock blockclass="DisplayBlock" type="links" link_attr="contract_id" object_id="$pkey$" target_attr="doc_id" encoding="text/oql">SELECT lnkDocumentContract WHERE contract_id = $pkey$</itopblock>
</itoptab>
</itoptabs>

View File

@@ -1,8 +0,0 @@
<div class="page_header">
<itopblock blockclass="MenuBlock" type="popup" encoding="text/sibusql" label="Actions">$class$: pkey = $pkey$</itopblock>
<h1>$class_name$: <span class="hilite">$name$</span></h1>
<itopblock blockclass="HistoryBlock" type="toggle" encoding="text/oql">SELECT CMDBChangeOp WHERE objkey = $pkey$ AND objclass = '$class$'</itopblock>
</div>
<img src="../images/tar.png" style="margin-top:-10px; margin-right:10px; float:right">
<itopblock blockclass="DisplayBlock" asynchronous="false" type="bare_details" encoding="text/sibusql">$class$: pkey = $pkey$</itopblock>

View File

@@ -1,7 +0,0 @@
<div class="page_header">
<itopblock blockclass="MenuBlock" type="popup" encoding="text/sibusql" label="Actions">$class$: pkey = $pkey$</itopblock>
<h1>$class_name$: <span class="hilite">$name$</span></h1>
<itopblock blockclass="HistoryBlock" type="toggle" encoding="text/oql">SELECT CMDBChangeOp WHERE objkey = $pkey$ AND objclass = '$class$'</itopblock>
</div>
<img src="../images/folder_documents.png" style="margin-top:-10px; margin-right:10px; float:right">
<itopblock blockclass="DisplayBlock" asynchronous="false" type="bare_details" encoding="text/oql">SELECT $class$ WHERE id = $pkey$</itopblock>

View File

@@ -1,16 +0,0 @@
<div class="page_header">
<itopblock blockclass="MenuBlock" type="popup" encoding="text/oql" label="Actions">SELECT $class$ WHERE id = $pkey$</itopblock>
<h1>$class_name$: <span class="hilite">$name$</span></h1>
<itopblock blockclass="HistoryBlock" type="toggle" encoding="text/oql">SELECT CMDBChangeOp WHERE objkey = $pkey$ AND objclass = '$class$'</itopblock>
</div>
<img src="../images/tar.png" style="margin-top:-10px; margin-right:10px; float:right">
<itopblock blockclass="DisplayBlock" asynchronous="false" type="bare_details" encoding="text/oql">SELECT bizInfraGroup WHERE id = $pkey$</itopblock>
<itoptabs>
<itoptab name="Infrastructures">
<itopblock blockclass="DisplayBlock" type="links" link_attr="infra_group_id" object_id="$pkey$" target_attr="infra_id" encoding="text/oql">SELECT lnkInfraGrouping WHERE infra_group_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Contacts">
<itopblock blockclass="DisplayBlock" type="links" link_attr="object_id" object_id="$pkey$" target_attr="contact_id" encoding="text/oql">SELECT lnkContactRealObject WHERE object_id = $pkey$</itopblock>
</itoptab>
</itoptabs>

View File

@@ -1,14 +0,0 @@
<div class="page_header">
<itopblock blockclass="MenuBlock" type="popup" encoding="text/oql" label="Actions">SELECT $class$ WHERE id = $pkey$</itopblock>
<h1>$class_name$: <span class="hilite">$name$</span></h1>
<itopblock blockclass="HistoryBlock" type="toggle" encoding="text/oql">SELECT CMDBChangeOp WHERE objkey = $pkey$ AND objclass = '$class$'</itopblock>
</div>
<img src="../images/tar.png" style="margin-top:-10px; margin-right:10px; float:right">
<itopblock blockclass="DisplayBlock" asynchronous="false" type="bare_details" encoding="text/oql">SELECT bizInterface WHERE id = $pkey$</itopblock>
<itoptabs>
<itoptab name="Groups">
<itopblock blockclass="DisplayBlock" type="links" link_attr="infra_id" object_id="$pkey$" target_attr="infra_group_id" encoding="text/oql">SELECT lnkInfraGrouping WHERE infra_id = $pkey$</itopblock>
</itoptab>
</itoptabs>

View File

@@ -1,11 +0,0 @@
<div class="page_header">
<itopblock blockclass="MenuBlock" type="popup" encoding="text/oql" label="Actions">SELECT $class$ WHERE id = $pkey$</itopblock>
<h1>$class_name$: <span class="hilite">$name$</span></h1>
<itopblock blockclass="HistoryBlock" type="toggle" encoding="text/oql">SELECT CMDBChangeOp WHERE objkey = $pkey$ AND objclass = '$class$'</itopblock>
</div>
<itopblock blockclass="DisplayBlock" asynchronous="false" type="bare_details" encoding="text/oql">SELECT bizKnownError WHERE id = $pkey$</itopblock>
<itoptabs>
<itoptab name="Related_Intrastructures">
<itopblock blockclass="DisplayBlock" type="links" link_attr="error_id" object_id="$pkey$" target_attr="infra_id" encoding="text/oql">SELECT lnkInfraError WHERE error_id = $pkey$</itopblock>
</itoptab>
</itoptabs>

View File

@@ -1,25 +0,0 @@
<div class="page_header">
<itopblock blockclass="MenuBlock" type="popup" encoding="text/oql" label="Actions">SELECT $class$ WHERE id = $pkey$</itopblock>
<h1>$class_name$: <span class="hilite">$name$</span></h1>
<itopblock blockclass="HistoryBlock" type="toggle" encoding="text/oql">SELECT CMDBChangeOp WHERE objkey = $pkey$ AND objclass = '$class$'</itopblock>
</div>
<img src="../images/starthere.png" style="margin-top:-20px; margin-right:10px; float:right">
<itopblock blockclass="DisplayBlock" asynchronous="false" type="bare_details" encoding="text/oql">SELECT bizLocation WHERE id = $pkey$</itopblock>
<itoptabs>
<itoptab name="Contacts">
<itopblock blockclass="DisplayBlock" type="list" object_id="$pkey$" target_attr="location_id" encoding="text/oql">SELECT bizContact WHERE location_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Servers">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/oql" object_id="$pkey$" target_attr="location_id">SELECT bizServer WHERE location_id = $pkey$</itopblock>
</itoptab>
<itoptab name="PCs">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/oql" object_id="$pkey$" target_attr="location_id">SELECT bizPC WHERE location_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Network_Devices">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/oql" object_id="$pkey$" target_attr="location_id">SELECT bizNetworkDevice WHERE location_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Documents">
<itopblock blockclass="DisplayBlock" type="links" link_attr="object_id" object_id="$pkey$" target_attr="doc_id" encoding="text/oql">SELECT lnkDocumentRealObject WHERE object_id = $pkey$</itopblock>
</itoptab>
</itoptabs>

View File

@@ -1,28 +0,0 @@
<div class="page_header">
<itopblock blockclass="MenuBlock" type="popup" encoding="text/oql" label="Actions">SELECT $class$ WHERE id = $pkey$</itopblock>
<h1>$class_name$: <span class="hilite">$name$</span></h1>
<itopblock blockclass="HistoryBlock" type="toggle" encoding="text/oql">SELECT CMDBChangeOp WHERE objkey = $pkey$ AND objclass = '$class$'</itopblock>
</div>
<img src="../images/connect_to_network.png" style="margin-top:-10px; margin-right:10px; float:right">
<itopblock blockclass="DisplayBlock" asynchronous="false" type="bare_details" encoding="text/oql">SELECT bizNetworkDevice WHERE id = $pkey$</itopblock>
<itoptabs>
<itoptab name="Interfaces">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/oql" object_id="$pkey$" target_attr="device_id">SELECT bizInterface WHERE device_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Contacts">
<itopblock blockclass="DisplayBlock" type="links" link_attr="infra_id" object_id="$pkey$" target_attr="contact_id" encoding="text/oql">SELECT lnkContactInfra WHERE infra_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Incidents">
<itopblock blockclass="DisplayBlock" type="links" link_attr="infra_id" object_id="$pkey$" target_attr="ticket_id" encoding="text/oql">SELECT lnkInfraTicket WHERE infra_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Changes">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/sibusql">bizChangeTicket: PKEY IS ticket_id IN (lnkInfraChangeTicket: infra_id = $pkey$)</itopblock>
</itoptab>
<itoptab name="Groups">
<itopblock blockclass="DisplayBlock" type="links" link_attr="infra_id" object_id="$pkey$" target_attr="infra_group_id" encoding="text/oql">SELECT lnkInfraGrouping WHERE infra_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Documents">
<itopblock blockclass="DisplayBlock" type="links" link_attr="object_id" object_id="$pkey$" target_attr="doc_id" encoding="text/oql">SELECT lnkDocumentRealObject WHERE object_id = $pkey$</itopblock>
</itoptab>
</itoptabs>

View File

@@ -1,30 +0,0 @@
<div class="page_header">
<itopblock blockclass="MenuBlock" type="popup" encoding="text/oql" label="Actions">SELECT $class$ WHERE id = $pkey$</itopblock>
<h1>$class_name$: <span class="hilite">$name$</span></h1>
<itopblock blockclass="HistoryBlock" type="toggle" encoding="text/oql">SELECT CMDBChangeOp WHERE objkey = $pkey$ AND objclass = '$class$'</itopblock>
</div>
<img src="../images/laptop_pcmcia.png" style="margin-top:-20px; margin-right:10px; float:right">
<itopblock blockclass="DisplayBlock" asynchronous="false" type="bare_details" encoding="text/oql">SELECT bizPC WHERE id = $pkey$</itopblock>
<itoptabs>
<itoptab name="Applications">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/oql" object_id="$pkey$" target_attr="device_id">SELECT bizApplication WHERE device_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Patches">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/oql" object_id="$pkey$" target_attr="device_id">SELECT bizPatch WHERE device_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Interfaces">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/oql" object_id="$pkey$" target_attr="device_id">SELECT bizInterface WHERE device_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Contacts">
<itopblock blockclass="DisplayBlock" type="links" link_attr="object_id" object_id="$pkey$" target_attr="contact_id" encoding="text/oql">SELECT lnkContactRealObject WHERE object_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Incidents">
<itopblock blockclass="DisplayBlock" type="links" link_attr="infra_id" object_id="$pkey$" target_attr="ticket_id" encoding="text/oql">SELECT lnkInfraTicket WHERE infra_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Groups">
<itopblock blockclass="DisplayBlock" type="links" link_attr="infra_id" object_id="$pkey$" target_attr="infra_group_id" encoding="text/oql">SELECT lnkInfraGrouping WHERE infra_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Documents">
<itopblock blockclass="DisplayBlock" type="links" link_attr="object_id" object_id="$pkey$" target_attr="doc_id" encoding="text/oql">SELECT lnkDocumentRealObject WHERE object_id = $pkey$</itopblock>
</itoptab>
</itoptabs>

View File

@@ -1,22 +0,0 @@
<div class="page_header">
<itopblock blockclass="MenuBlock" type="popup" encoding="text/oql" label="Actions">SELECT $class$ WHERE id = $pkey$</itopblock>
<h1>$class_name$: <span class="hilite">$name$</span></h1>
<itopblock blockclass="HistoryBlock" type="toggle" encoding="text/oql">SELECT CMDBChangeOp WHERE objkey = $pkey$ AND objclass = '$class$'</itopblock>
</div>
<img src="../images/users2-big.png" style="margin-top:-10px; margin-right:10px; float:right">
<itopblock blockclass="DisplayBlock" asynchronous="false" type="bare_details" encoding="text/oql">SELECT bizPerson WHERE id = $pkey$</itopblock>
<itoptabs>
<itoptab name="Teams">
<itopblock blockclass="DisplayBlock" type="links" link_attr="contact_id" object_id="$pkey$" target_attr="team_id" encoding="text/oql">SELECT lnkContactTeam WHERE contact_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Infrastructure">
<itopblock blockclass="DisplayBlock" type="links" link_attr="contact_id" object_id="$pkey$" target_attr="object_id" encoding="text/oql">SELECT lnkContactRealObject WHERE contact_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Service_Calls">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/oql">SELECT bizServiceCall WHERE caller_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Documents">
<itopblock blockclass="DisplayBlock" type="links" link_attr="object_id" object_id="$pkey$" target_attr="doc_id" encoding="text/oql">SELECT lnkDocumentRealObject WHERE object_id = $pkey$</itopblock>
</itoptab>
</itoptabs>

View File

@@ -1,34 +0,0 @@
<div class="page_header">
<itopblock blockclass="MenuBlock" type="popup" encoding="text/oql" label="Actions">SELECT $class$ WHERE id = $pkey$</itopblock>
<h1>$class_name$: <span class="hilite">$name$</span></h1>
<itopblock blockclass="HistoryBlock" type="toggle" encoding="text/oql">SELECT CMDBChangeOp WHERE objkey = $pkey$ AND objclass = '$class$'</itopblock>
</div>
<img src="../images/network-server.png" style="margin-top:-10px; margin-right:10px; float:right">
<itopblock blockclass="DisplayBlock" asynchronous="false" type="bare_details" encoding="text/oql">SELECT bizServer WHERE id = $pkey$</itopblock>
<itoptabs>
<itoptab name="Applications">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/oql" object_id="$pkey$" target_attr="device_id">SELECT bizApplication WHERE device_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Patches">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/oql" object_id="$pkey$" target_attr="device_id">SELECT bizPatch WHERE device_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Interfaces">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/oql" object_id="$pkey$" target_attr="device_id">SELECT bizInterface WHERE device_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Contacts">
<itopblock blockclass="DisplayBlock" type="links" link_attr="object_id" object_id="$pkey$" target_attr="contact_id" encoding="text/oql">SELECT lnkContactRealObject WHERE object_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Incidents">
<itopblock blockclass="DisplayBlock" type="links" link_attr="infra_id" object_id="$pkey$" target_attr="ticket_id" encoding="text/oql">SELECT lnkInfraTicket WHERE infra_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Changes">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/oql">SELECT bizChangeTicket AS Change JOIN lnkInfraChangeTicket AS Link ON Link.ticket_id = Change.id WHERE Link.infra_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Groups">
<itopblock blockclass="DisplayBlock" type="links" link_attr="infra_id" object_id="$pkey$" target_attr="infra_group_id" encoding="text/oql">SELECT lnkInfraGrouping WHERE infra_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Documents">
<itopblock blockclass="DisplayBlock" type="links" link_attr="object_id" object_id="$pkey$" target_attr="doc_id" encoding="text/oql">SELECT lnkDocumentRealObject WHERE object_id = $pkey$</itopblock>
</itoptab>
</itoptabs>

View File

@@ -1,13 +0,0 @@
<div class="page_header">
<itopblock blockclass="MenuBlock" type="popup" encoding="text/sibusql" label="Actions">$class$: pkey = $pkey$</itopblock>
<h1>$class_name$: <span class="hilite">$name$</span></h1>
<itopblock blockclass="HistoryBlock" type="toggle" encoding="text/oql">SELECT CMDBChangeOp WHERE objkey = $pkey$ AND objclass = '$class$'</itopblock>
</div>
<img src="../images/kservices-big.png" style="margin-top:-10px; margin-right:10px; float:right">
<itopblock blockclass="DisplayBlock" asynchronous="false" type="bare_details" encoding="text/oql">SELECT bizService WHERE id=$pkey$</itopblock>
<itoptabs>
<itoptab name="Contracts">
<itopblock blockclass="DisplayBlock" asynchronous="false" type="list" encoding="text/oql" object_id="$pkey$" target_attr="service_id">SELECT bizContract WHERE service_id = $pkey$</itopblock>
</itoptab>
</itoptabs>

View File

@@ -1,18 +0,0 @@
<div class="page_header">
<itopblock blockclass="MenuBlock" type="popup" encoding="text/oql" label="Actions">SELECT $class$ WHERE id = $pkey$</itopblock>
<h1>$class_name$: <span class="hilite">$name$</span></h1>
<itopblock blockclass="HistoryBlock" type="toggle" encoding="text/oql">SELECT CMDBChangeOp WHERE objkey = $pkey$ AND objclass = '$class$'</itopblock>
</div>
<img src="../images/messagebox_warning.png" style="margin-top:-10px; margin-right:10px; float:right">
<itopblock blockclass="DisplayBlock" asynchronous="false" type="bare_details" encoding="text/oql">SELECT $class$ WHERE id = $pkey$</itopblock>
<itoptabs>
<itoptab name="Impacted_Infrastructures">
<itopblock blockclass="DisplayBlock" type="links" link_attr="call_id" object_id="$pkey$" target_attr="infra_id" encoding="text/oql">SELECT lnkInfraCall WHERE call_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Related_Incidents">
<itopblock blockclass="DisplayBlock" type="links" link_attr="call_id" object_id="$pkey$" target_attr="ticket_id" encoding="text/oql">SELECT lnkCallTicket WHERE call_id = $pkey$</itopblock>
</itoptab>
</itoptabs>
<br style="clear:both"/>

View File

@@ -1,12 +0,0 @@
<div class="page_header">
<itopblock blockclass="MenuBlock" type="popup" encoding="text/oql" label="Actions">SELECT $class$ WHERE id = $pkey$</itopblock>
<h1>$class_name$: <span class="hilite">$name$</span></h1>
<itopblock blockclass="HistoryBlock" type="toggle" encoding="text/oql">SELECT CMDBChangeOp WHERE objkey = $pkey$ AND objclass = '$class$'</itopblock>
</div>
<img src="../images/erwanContracts.jpg" style="margin-top:-10px; margin-right:10px; float:right">
<itopblock blockclass="DisplayBlock" asynchronous="false" type="bare_details" encoding="text/oql">SELECT $class$ WHERE id = $pkey$</itopblock>
<itoptabs>
<itoptab name="Service_Items">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/oql">SELECT bizServiceItem WHERE request_id = $pkey$</itopblock>
</itoptab>
</itoptabs>

View File

@@ -1,13 +0,0 @@
<div class="page_header">
<itopblock blockclass="MenuBlock" type="popup" encoding="text/sibusql" label="Actions">$class$: pkey = $pkey$</itopblock>
<h1>$class_name$: <span class="hilite">$name$</span></h1>
<itopblock blockclass="HistoryBlock" type="toggle" encoding="text/oql">SELECT CMDBChangeOp WHERE objkey = $pkey$ AND objclass = '$class$'</itopblock>
</div>
<img src="../images/software.jpg" style="margin-top:-10px; margin-right:10px; float:right">
<itopblock blockclass="DisplayBlock" asynchronous="false" type="bare_details" encoding="text/sibusql">bizSoftware: pkey = $pkey$</itopblock>
<itoptabs>
<itoptab name="Installed_Instances">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/sibusql">bizApplication: soft_id = $pkey$</itopblock>
</itoptab>
</itoptabs>

View File

@@ -1,22 +0,0 @@
<div class="page_header">
<itopblock blockclass="MenuBlock" type="popup" encoding="text/oql" label="Actions">SELECT $class$ WHERE id = $pkey$</itopblock>
<h1>$class_name$: <span class="hilite">$name$</span></h1>
<itopblock blockclass="HistoryBlock" type="toggle" encoding="text/oql">SELECT CMDBChangeOp WHERE objkey = $pkey$ AND objclass = '$class$'</itopblock>
</div>
<img src="../images/users2-big.png" style="margin-top:-10px; margin-right:10px; float:right">
<itopblock blockclass="DisplayBlock" asynchronous="false" type="bare_details" encoding="text/oql">SELECT $class$ WHERE id = $pkey$</itopblock>
<itoptabs>
<itoptab name="Members">
<itopblock blockclass="DisplayBlock" type="links" link_attr="team_id" object_id="$pkey$" target_attr="contact_id" encoding="text/oql">SELECT lnkContactTeam WHERE team_id=$pkey$</itopblock>
</itoptab>
<itoptab name="Infrastructures">
<itopblock blockclass="DisplayBlock" type="links" link_attr="contact_id" object_id="$pkey$" target_attr="infra_id" encoding="text/oql">SELECT lnkContactInfra WHERE contact_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Workgroups">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/oql">SELECT bizWorkgroup WHERE team_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Documents">
<itopblock blockclass="DisplayBlock" type="links" link_attr="object_id" object_id="$pkey$" target_attr="doc_id" encoding="text/oql">SELECT lnkDocumentRealObject WHERE object_id = $pkey$</itopblock>
</itoptab>
</itoptabs>

View File

@@ -1,24 +0,0 @@
<div class="page_header">
<itopblock blockclass="MenuBlock" type="popup" encoding="text/sibusql" label="Actions">$class$: pkey = $pkey$</itopblock>
<h1>$class_name$: <span class="hilite">$name$</span></h1>
<itopblock blockclass="HistoryBlock" type="toggle" encoding="text/oql">SELECT CMDBChangeOp WHERE objkey = $pkey$ AND objclass = '$class$'</itopblock>
</div>
<img src="../images/messagebox_warning.png" style="margin-top:-10px; margin-right:10px; float:right">
<itopblock blockclass="DisplayBlock" asynchronous="false" type="bare_details" encoding="text/sibusql">$class$: pkey = $pkey$</itopblock>
<itoptabs>
<itoptab name="Impacted_Infrastructures">
<itopblock blockclass="DisplayBlock" type="list" link_attr="ticket_id" object_id="$pkey$" target_attr="infra_id" encoding="text/oql">SELECT lnkInfraTicket WHERE ticket_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Related_Incidents">
<itopblock blockclass="DisplayBlock" type="links" link_attr="ticket_id" object_id="$pkey$" target_attr="rel_ticket_id" encoding="text/oql">SELECT lnkRelatedTicket WHERE ticket_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Contacts_to_Notify">
<itopblock blockclass="DisplayBlock" type="list" link_attr="ticket_id" object_id="$pkey$" target_attr="contact_id" encoding="text/oql">SELECT lnkContactTicket WHERE ticket_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Email_Notifications">
<itopblock blockclass="DisplayBlock" type="list" parameters="menu:0;" encoding="text/oql">SELECT EventNotificationEmail AS Ev JOIN TriggerOnObject AS T ON Ev.trigger_id = T.id WHERE T.target_class = 'bizIncidentTicket' AND Ev.object_id = $pkey$</itopblock>
</itoptab>
</itoptabs>
<br style="clear:both"/>

View File

@@ -1,272 +0,0 @@
<?php
/**
* test_farm.class.inc.php
* User defined objects, for unit testing - SQL generation oriented (complex links)
*
* @package iTopUnitTests
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @author Denis Flaven <denisflave@free.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version 1.1.1.1 $
*/
///////////////////////////////////////////////////////////////////////////////
// Business implementation demo
///////////////////////////////////////////////////////////////////////////////
//todo MetaModel::RegisterRelation("Potes", array("description"=>"ceux dont l'email ressemble au mien", "verb_down"=>"est pote de", "verb_up"=>"est pote de"));
//todo MetaModel::RegisterZList("list1", array("description"=>"une premiere list, just for fun", "type"=>"attributes"));
//todo MetaModel::RegisterZList("list2", array("description"=>"la secunda e meliora", "type"=>"attributes"));
//todo MetaModel::RegisterZList("list3", array("description"=>"la variante qui tue", "type"=>"filters"));
class Animal extends cmdbObject
{
public static function Init()
{
$aParams = array
(
"category" => "blah",
"name" => "Animal",
"description" => "An animal",
"key_type" => "autoincrement",
"key_label" => "",
"name_attcode" => "",
"state_attcode" => "",
"reconc_keys" => array(""),
"db_table" => "animals",
"db_key_field" => "animalid",
"db_finalclass_field" => "actualclass",
);
MetaModel::Init_Params($aParams);
MetaModel::Init_AddAttribute(new AttributeEnum("sex", array("label"=>"sex", "description"=>"sex", "allowed_values"=>new ValueSetEnum('male, female'), "sql"=>"sex", "default_value"=>"male", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("species", array("label"=>"species", "description"=>"species", "allowed_values"=>null, "sql"=>"species", "default_value"=>"xxx", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeInteger("speed", array("label"=>"walk speed", "description"=>"maximum possible speed m.s-1", "allowed_values"=>null, "sql"=>"speed", "default_value"=>4, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalKey("mother", array("label"=>"mother", "description"=>"mother", "allowed_values"=>null, "sql"=>"mother", "targetclass"=>"Animal", "is_null_allowed"=>true, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalKey("father", array("label"=>"father", "description"=>"father", "allowed_values"=>null, "sql"=>"father", "targetclass"=>"Animal", "is_null_allowed"=>true, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
//MetaModel::Init_InheritFilters();
MetaModel::Init_AddFilterFromAttribute("sex");
MetaModel::Init_AddFilterFromAttribute("species");
MetaModel::Init_AddFilterFromAttribute("speed");
MetaModel::Init_AddFilterFromAttribute("mother");
MetaModel::Init_AddFilterFromAttribute("father");
}
}
class Mammal extends Animal
{
public static function Init()
{
$aParams = array
(
"category" => "blah",
"name" => "Mammal",
"description" => "An animal with some characteristics",
"key_type" => "autoincrement",
"key_label" => "",
"name_attcode" => "name",
"state_attcode" => "",
"reconc_keys" => array(),
"db_table" => "mammals",
"db_key_field" => "mammalid",
"db_finalclass_field" => "",
);
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeString("name", array("label"=>"name", "description"=>"name", "allowed_values"=>null, "sql"=>"name", "default_value"=>"xxx", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeInteger("height", array("label"=>"height", "description"=>"size in centimeters", "allowed_values"=>null, "sql"=>"height", "default_value"=>1, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeDate("birth", array("label"=>"birth date", "description"=>"birth date", "allowed_values"=>null, "sql"=>"birth", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalKey("member", array("label"=>"member", "description"=>"leader", "allowed_values"=>null, "sql"=>"member", "targetclass"=>"Group", "is_null_allowed"=>true, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
// ? MetaModel::Init_AddAttribute(new AttributeLinkedSet("a2a", array("label"=>"animal to animal", "description"=>"interanimal relations", "depends_on"=>array(), "linked_class"=>"Animal2animal", "ext_key_to_me"=>"animal1", "count_min"=>0, "count_max"=>10, "allowed_values"=>null)));
MetaModel::Init_InheritFilters();
MetaModel::Init_AddFilterFromAttribute("name");
MetaModel::Init_AddFilterFromAttribute("height");
MetaModel::Init_AddFilterFromAttribute("birth");
MetaModel::Init_AddFilterFromAttribute("member");
}
}
class Bird extends Animal
{
public static function Init()
{
$aParams = array
(
"category" => "blah",
"name" => "Bird",
"description" => "Un regroupement de gens",
"key_type" => "autoincrement",
"key_label" => "",
"name_attcode" => "",
"state_attcode" => "",
"reconc_keys" => array(),
"db_table" => "birds",
"db_key_field" => "birdid",
"db_finalclass_field" => "",
);
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();
MetaModel::Init_OverloadAttributeParams("species", array("allowed_values"=>array('geese', 'rooster', 'chicken', 'turckey', 'pie', 'corbeau')));
MetaModel::Init_InheritFilters();
}
}
class WalkingBird extends Bird
{
public static function Init()
{
$aParams = array
(
"category" => "blah",
"name" => "WalkingBird",
"description" => "A bird which nevers flies",
"key_type" => "",
"key_label" => "",
"name_attcode" => "",
"state_attcode" => "",
"reconc_keys" => array(),
"db_table" => "walkingbirds",
"db_key_field" => "walkingbirdid",
"db_finalclass_field" => "",
);
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();
MetaModel::Init_OverloadAttributeParams("species", array("allowed_values"=>array('geese', 'rooster', 'chicken', 'turckey')));
MetaModel::Init_InheritFilters();
}
}
class FlyingBird extends Bird
{
public static function Init()
{
$aParams = array
(
"category" => "blah",
"name" => "FlyingBird",
"description" => "A bird which nevers flies",
"key_type" => "",
"key_label" => "",
"name_attcode" => "",
"state_attcode" => "",
"reconc_keys" => array(),
"db_table" => "flyingbirds",
"db_key_field" => "flyingbirdid",
"db_finalclass_field" => "",
);
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();
MetaModel::Init_OverloadAttributeParams("species", array("allowed_values"=>array('pie', 'corbeau')));
MetaModel::Init_AddAttribute(new AttributeInteger("flyingspeed", array("label"=>"flying speed", "description"=>"flying at ms.s-1", "allowed_values"=>null, "sql"=>"headcount", "default_value"=>10, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_InheritFilters();
MetaModel::Init_AddFilterFromAttribute("flyingspeed");
}
}
class AnimalRelation extends cmdbObject
{
public static function Init()
{
$aParams = array
(
"category" => "blah",
"name" => "AnimalRelation",
"description" => "Link between two animals",
"key_type" => "autoincrement",
"key_label" => "",
"name_attcode" => "",
"state_attcode" => "",
"reconc_keys" => array(),
"db_table" => "a2a",
"db_key_field" => "linkid",
"db_finalclass_field" => "",
);
MetaModel::Init_Params($aParams);
//MetaModel::Init_InheritAttributes();
// What makes it being a link...
MetaModel::Init_AddAttribute(new AttributeExternalKey("animal1", array("label"=>"source", "description"=>"the animal which does ...", "allowed_values"=>null, "sql"=>"a1", "targetclass"=>"Animal", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalKey("animal2", array("label"=>"target", "description"=>"the animal to which something is done...", "allowed_values"=>null, "sql"=>"a2", "targetclass"=>"Animal", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
//MetaModel::Init_InheritFilters();
MetaModel::Init_AddFilterFromAttribute("animal1");
MetaModel::Init_AddFilterFromAttribute("animal2");
}
}
class EaterToEaten extends AnimalRelation
{
public static function Init()
{
$aParams = array
(
"category" => "blah",
"name" => "EaterToEaten",
"description" => "Animal 1 eats animal 2",
"key_type" => "autoincrement",
"key_label" => "",
"name_attcode" => "",
"state_attcode" => "",
"reconc_keys" => array(),
"db_table" => "eatertoeaten",
"db_key_field" => "eatertoeatonid",
"db_finalclass_field" => "",
);
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeEnum("DeadOrAlive", array("label"=>"DeadOrAlive", "description"=>"State in which it is ok for the eater to proceed", "allowed_values"=>new ValueSetEnum('dead, fresh, cooked'), "sql"=>"deadoralive", "default_value"=>"fresh", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_InheritFilters();
MetaModel::Init_AddFilterFromAttribute("DeadOrAlive");
}
}
class Group extends cmdbObject
{
public static function Init()
{
$aParams = array
(
"category" => "blah",
"name" => "Group",
"description" => "Group of animals",
"key_type" => "autoincrement",
"key_label" => "",
"name_attcode" => "name",
"state_attcode" => "",
"reconc_keys" => array(),
"db_table" => "groups",
"db_key_field" => "groupid",
"db_finalclass_field" => "",
);
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeString("name", array("label"=>"name", "description"=>"name", "allowed_values"=>null, "sql"=>"name", "default_value"=>"xxx", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalKey("leader", array("label"=>"leader", "description"=>"leader", "allowed_values"=>null, "sql"=>"leader", "targetclass"=>"Mammal", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("leader_name", array("label"=>"Leader Name", "description"=>"Name of the leader (defined on Mammal)", "allowed_values"=>null, "extkey_attcode"=> 'leader', "target_attcode"=>"name")));
MetaModel::Init_AddAttribute(new AttributeExternalField("leader_speed", array("label"=>"Leader Name", "description"=>"Speed of the leader (defined on Animal)", "allowed_values"=>null, "extkey_attcode"=> 'leader', "target_attcode"=>"speed")));
MetaModel::Init_InheritFilters();
MetaModel::Init_AddFilterFromAttribute("name");
MetaModel::Init_AddFilterFromAttribute("leader");
MetaModel::Init_AddFilterFromAttribute("leader_name");
MetaModel::Init_AddFilterFromAttribute("leader_speed");
}
}
?>

View File

@@ -1,38 +0,0 @@
<?php
//
// phpMyORM configuration file
//
// To be manually edited (or generated by the configuration wizard)
//
// The file is used in MetaModel::LoadConfig() which does all the necessary initialization job
//
$MySettings = array(
'db_host' => 'localhost',
'db_user' => 'itop',
'db_pwd' => '1T0p',
'db_name' => 'itopv06',
'db_subname' => '', // use it to differentiate two applications instances running on the same DB
);
// Modules: file names should be specified as a absolute paths
$MyModules = array(
'application' => array (
'../application/menunode.class.inc.php',
'../application/audit.rule.class.inc.php',
// to be continued...
),
'business' => array (
'../business/itop.business.class.inc.php'
// to be continued...
),
'addons' => array (
'user rights' => '../addons/userrights/userrightsprofile.class.inc.php',
// other modules to come later
)
);
?>

View File

@@ -1,36 +0,0 @@
<?php
//
// phpMyORM configuration file
//
// To be manually edited (or generated by the configuration wizard)
//
// The file is used in MetaModel::LoadConfig() which does all the necessary initialization job
//
$MySettings = array(
'db_host' => 'localhost',
'db_user' => 'itop',
'db_pwd' => '1T0p',
'db_name' => 'TestBizModelGenericItop',
'db_subname' => 'tribute2itop', // use it to differentiate two applications instances running on the same DB
);
// Modules: file names should be specified as a absolute paths
$MyModules = array(
'application' => array (
// to be continued...
),
'business' => array (
'../business/business_test.class.inc.php'
// to be continued...
),
'addons' => array (
// other modules to come later
)
);
?>

View File

@@ -1,18 +1,35 @@
<?php
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* Various dev/debug helpers
* TODO: cleanup or at least re-organize
*
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
/**
* MyHelpers
* various dev/debug helpers, to cleanup or at least re-organize
*
* @package iTopORM
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @author Denis Flaven <denisflave@free.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version 1.1.1.1 $
*/
class MyHelpers
{
public static function CheckValueInArray($sDescription, $value, $aData)
@@ -471,7 +488,7 @@ class Str
*/
protected static function xmlencode($string)
{
return self::xmlentities(iconv("ISO-8859-1", "UTF-8//IGNORE",$string));
return self::xmlentities(iconv("UTF-8", "UTF-8//IGNORE",$string));
}
public static function islowcase($sString)

View File

@@ -1,17 +1,35 @@
<?php
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
require_once('../core/email.class.inc.php');
/**
* Persistent classes (internal): user defined actions
*
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
require_once(APPROOT.'/core/email.class.inc.php');
/**
* A user defined action, to customize the application
*
* @package iTopORM
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @author Denis Flaven <denisflave@free.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version 1.1.1.1 $
*/
abstract class Action extends cmdbAbstractObject
{
@@ -20,10 +38,7 @@ abstract class Action extends cmdbAbstractObject
$aParams = array
(
"category" => "core/cmdb",
"name" => "action",
"description" => "Custom action",
"key_type" => "autoincrement",
"key_label" => "",
"name_attcode" => "name",
"state_attcode" => "",
"reconc_keys" => array(),
@@ -34,17 +49,13 @@ abstract class Action extends cmdbAbstractObject
);
MetaModel::Init_Params($aParams);
//MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeString("name", array("label"=>"Name", "description"=>"label", "allowed_values"=>null, "sql"=>"name", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("description", array("label"=>"Description", "description"=>"one line description", "allowed_values"=>null, "sql"=>"description", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeEnum("status", array("label"=>"Status", "description"=>"In production or ?", "allowed_values"=>new ValueSetEnum(array('test'=>'Being tested' ,'enabled'=>'In production', 'disabled'=>'Inactive')), "sql"=>"status", "default_value"=>"test", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeLinkedSetIndirect("related_triggers", array("label"=>"Related Triggers", "description"=>"Triggers linked to this action", "linked_class"=>"lnkTriggerAction", "ext_key_to_me"=>"action_id", "ext_key_to_remote"=>"trigger_id", "allowed_values"=>null, "count_min"=>0, "count_max"=>0, "depends_on"=>array())));
//MetaModel::Init_InheritFilters();
MetaModel::Init_AddFilterFromAttribute("name");
MetaModel::Init_AddFilterFromAttribute("description");
MetaModel::Init_AddAttribute(new AttributeString("name", array("allowed_values"=>null, "sql"=>"name", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("description", array("allowed_values"=>null, "sql"=>"description", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeEnum("status", array("allowed_values"=>new ValueSetEnum(array('test'=>'Being tested' ,'enabled'=>'In production', 'disabled'=>'Inactive')), "sql"=>"status", "default_value"=>"test", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeLinkedSetIndirect("trigger_list", array("linked_class"=>"lnkTriggerAction", "ext_key_to_me"=>"action_id", "ext_key_to_remote"=>"trigger_id", "allowed_values"=>null, "count_min"=>0, "count_max"=>0, "depends_on"=>array())));
// Display lists
MetaModel::Init_SetZListItems('details', array('name', 'description', 'status')); // Attributes to be displayed for the complete details
MetaModel::Init_SetZListItems('details', array('name', 'description', 'status', 'trigger_list')); // Attributes to be displayed for the complete details
MetaModel::Init_SetZListItems('list', array('finalclass', 'name', 'description', 'status')); // Attributes to be displayed for a list
// Search criteria
// MetaModel::Init_SetZListItems('standard_search', array('name')); // Criteria of the std search form
@@ -83,12 +94,6 @@ abstract class Action extends cmdbAbstractObject
* A notification
*
* @package iTopORM
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @author Denis Flaven <denisflave@free.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version 1.1.1.1 $
*/
abstract class ActionNotification extends Action
{
@@ -97,10 +102,7 @@ abstract class ActionNotification extends Action
$aParams = array
(
"category" => "core/cmdb",
"name" => "notification",
"description" => "Notification (abstract)",
"key_type" => "autoincrement",
"key_label" => "",
"name_attcode" => "name",
"state_attcode" => "",
"reconc_keys" => array(),
@@ -112,10 +114,8 @@ abstract class ActionNotification extends Action
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();
MetaModel::Init_InheritFilters();
// Display lists
MetaModel::Init_SetZListItems('details', array('name', 'description', 'status')); // Attributes to be displayed for the complete details
MetaModel::Init_SetZListItems('details', array('name', 'description', 'status', 'trigger_list')); // Attributes to be displayed for the complete details
MetaModel::Init_SetZListItems('list', array('finalclass', 'name', 'description', 'status')); // Attributes to be displayed for a list
// Search criteria
// MetaModel::Init_SetZListItems('standard_search', array('name')); // Criteria of the std search form
@@ -127,12 +127,6 @@ abstract class ActionNotification extends Action
* An email notification
*
* @package iTopORM
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @author Denis Flaven <denisflave@free.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version 1.1.1.1 $
*/
class ActionEmail extends ActionNotification
{
@@ -141,10 +135,7 @@ class ActionEmail extends ActionNotification
$aParams = array
(
"category" => "core/cmdb",
"name" => "email notification",
"description" => "Action: Email notification",
"key_type" => "autoincrement",
"key_label" => "",
"name_attcode" => "name",
"state_attcode" => "",
"reconc_keys" => array(),
@@ -156,21 +147,19 @@ class ActionEmail extends ActionNotification
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeEmailAddress("test_recipient", array("label"=>"Test recipient", "description"=>"Detination in case status is set to \"Test\"", "allowed_values"=>null, "sql"=>"test_recipient", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeEmailAddress("test_recipient", array("allowed_values"=>null, "sql"=>"test_recipient", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("from", array("label"=>"From", "description"=>"Will be sent into the email header", "allowed_values"=>null, "sql"=>"from", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("reply_to", array("label"=>"Reply to", "description"=>"Will be sent into the email header", "allowed_values"=>null, "sql"=>"reply_to", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeOQL("to", array("label"=>"To", "description"=>"Destination of the email", "allowed_values"=>null, "sql"=>"to", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeOQL("cc", array("label"=>"Cc", "description"=>"Carbon Copy", "allowed_values"=>null, "sql"=>"cc", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeOQL("bcc", array("label"=>"bcc", "description"=>"Blind Carbon Copy", "allowed_values"=>null, "sql"=>"bcc", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeTemplateString("subject", array("label"=>"subject", "description"=>"Title of the email", "allowed_values"=>null, "sql"=>"subject", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeTemplateText("body", array("label"=>"body", "description"=>"Contents of the email", "allowed_values"=>null, "sql"=>"body", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeEnum("importance", array("label"=>"importance", "description"=>"Importance flag", "allowed_values"=>new ValueSetEnum('low,normal,high'), "sql"=>"importance", "default_value"=>'normal', "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_InheritFilters();
MetaModel::Init_AddAttribute(new AttributeString("from", array("allowed_values"=>null, "sql"=>"from", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("reply_to", array("allowed_values"=>null, "sql"=>"reply_to", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeOQL("to", array("allowed_values"=>null, "sql"=>"to", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeOQL("cc", array("allowed_values"=>null, "sql"=>"cc", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeOQL("bcc", array("allowed_values"=>null, "sql"=>"bcc", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeTemplateString("subject", array("allowed_values"=>null, "sql"=>"subject", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeTemplateText("body", array("allowed_values"=>null, "sql"=>"body", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeEnum("importance", array("allowed_values"=>new ValueSetEnum('low,normal,high'), "sql"=>"importance", "default_value"=>'normal', "is_null_allowed"=>false, "depends_on"=>array())));
// Display lists
MetaModel::Init_SetZListItems('details', array('name', 'description', 'status', 'test_recipient', 'from', 'reply_to', 'to', 'cc', 'bcc', 'subject', 'body', 'importance')); // Attributes to be displayed for the complete details
MetaModel::Init_SetZListItems('details', array('name', 'description', 'status', 'test_recipient', 'from', 'reply_to', 'to', 'cc', 'bcc', 'subject', 'body', 'importance', 'trigger_list')); // Attributes to be displayed for the complete details
MetaModel::Init_SetZListItems('list', array('name', 'status', 'to', 'subject')); // Attributes to be displayed for a list
// Search criteria
// MetaModel::Init_SetZListItems('standard_search', array('name')); // Criteria of the std search form
@@ -194,7 +183,7 @@ class ActionEmail extends ActionNotification
{
$oSearch = DBObjectSearch::FromOQL($sOQL);
}
catch (OqlException $e)
catch (OQLException $e)
{
$this->m_aMailErrors[] = "query syntax error for recipient '$sRecipAttCode'";
return $e->getMessage();
@@ -246,8 +235,12 @@ class ActionEmail extends ActionNotification
$sSubject = MetaModel::ApplyParams($this->Get('subject'), $aContextArgs);
$sBody = MetaModel::ApplyParams($this->Get('body'), $aContextArgs);
$oObj = $aContextArgs['this->object()'];
$sServerIP = $_SERVER['SERVER_ADDR']; //gethostbyname(gethostname());
$sReference = '<iTop/'.get_class($oObj).'/'.$oObj->GetKey().'@'.$sServerIP.'>';
$oEmail = new Email();
$oEmail = new EMail();
if ($this->IsBeingTested())
{
@@ -262,12 +255,14 @@ class ActionEmail extends ActionNotification
$sTestBody .= "<li>BCC: $sBCC</li>\n";
$sTestBody .= "<li>From: $sFrom</li>\n";
$sTestBody .= "<li>Reply-To: $sReplyTo</li>\n";
$sTestBody .= "<li>References: $sReference</li>\n";
$sTestBody .= "</ul>\n";
$sTestBody .= "</p>\n";
$sTestBody .= "</div>\n";
$oEmail->SetBody($sTestBody);
$oEmail->SetRecipientTO($this->Get('test_recipient'));
$oEmail->SetRecipientFrom($this->Get('test_recipient'));
$oEmail->SetReferences($sReference);
}
else
{
@@ -278,6 +273,7 @@ class ActionEmail extends ActionNotification
$oEmail->SetRecipientBCC($sBCC);
$oEmail->SetRecipientFrom($sFrom);
$oEmail->SetRecipientReplyTo($sReplyTo);
$oEmail->SetReferences($sReference);
}
if (empty($this->m_aMailErrors))
@@ -288,7 +284,9 @@ class ActionEmail extends ActionNotification
}
else
{
$oKPI = new ExecutionKPI();
$this->m_aMailErrors = array_merge($this->m_aMailErrors, $oEmail->Send());
$oKPI->ComputeStats('Send mail', $sTo);
}
}
}
@@ -297,53 +295,55 @@ class ActionEmail extends ActionNotification
$this->m_aMailErrors[] = $e->getMessage();
}
$oLog = new EventNotificationEmail();
if (empty($this->m_aMailErrors))
if (MetaModel::IsLogEnabledNotification())
{
if ($this->IsBeingTested())
$oLog = new EventNotificationEmail();
if (empty($this->m_aMailErrors))
{
$oLog->Set('message', 'TEST - Notification sent ('.$this->Get('test_recipient').')');
if ($this->IsBeingTested())
{
$oLog->Set('message', 'TEST - Notification sent ('.$this->Get('test_recipient').')');
}
else
{
$oLog->Set('message', 'Notification sent');
}
}
else
{
$oLog->Set('message', 'Notification sent');
if (is_array($this->m_aMailErrors) && count($this->m_aMailErrors) > 0)
{
$sError = implode(', ', $this->m_aMailErrors);
}
else
{
$sError = 'Unknown reason';
}
if ($this->IsBeingTested())
{
$oLog->Set('message', 'TEST - Notification was not sent: '.$sError);
}
else
{
$oLog->Set('message', 'Notification was not sent: '.$sError);
}
}
}
else
{
if (is_array($this->m_aMailErrors) && count($this->m_aMailErrors) > 0)
{
$sError = implode(', ', $this->m_aMailErrors);
}
else
{
$sError = 'Unknown reason';
}
if ($this->IsBeingTested())
{
$oLog->Set('message', 'TEST - Notification was not sent: '.$sError);
}
else
{
$oLog->Set('message', 'Notification was not sent: '.$sError);
}
}
$oLog->Set('userinfo', UserRights::GetUser());
$oLog->Set('trigger_id', $oTrigger->GetKey());
$oLog->Set('action_id', $this->GetKey());
$oLog->Set('object_id', $aContextArgs['this->object()']->GetKey());
$oLog->Set('userinfo', UserRights::GetUser());
$oLog->Set('trigger_id', $oTrigger->GetKey());
$oLog->Set('action_id', $this->GetKey());
$oLog->Set('object_id', $aContextArgs['this->id']);
// Note: we have to secure this because those values are calculated
// inside the try statement, and we would like to keep track of as
// many data as we could while some variables may still be undefined
if (isset($sTo)) $oLog->Set('to', $sTo);
if (isset($sCC)) $oLog->Set('cc', $sCC);
if (isset($sBCC)) $oLog->Set('bcc', $sBCC);
if (isset($sFrom)) $oLog->Set('from', $sFrom);
if (isset($sSubject)) $oLog->Set('subject', $sSubject);
if (isset($sBody)) $oLog->Set('body', $sBody);
$oLog->DBInsertNoReload();
// Note: we have to secure this because those values are calculated
// inside the try statement, and we would like to keep track of as
// many data as we could while some variables may still be undefined
if (isset($sTo)) $oLog->Set('to', $sTo);
if (isset($sCC)) $oLog->Set('cc', $sCC);
if (isset($sBCC)) $oLog->Set('bcc', $sBCC);
if (isset($sFrom)) $oLog->Set('from', $sFrom);
if (isset($sSubject)) $oLog->Set('subject', $sSubject);
if (isset($sBody)) $oLog->Set('body', $sBody);
$oLog->DBInsertNoReload();
}
}
}
?>
?>

View File

@@ -1,18 +1,29 @@
<?php
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* archive.class.inc.php
* Utility to import/export the DB from/to a ZIP file
* Utility to import/export the DB from/to a ZIP file
*
* @package iTopORM
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @author Denis Flaven <denisflave@free.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version 1.1.1.1 $
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
/**
* iTopArchive a class to manipulate (read/write) iTop archives with their catalog
* Each iTop archive is a zip file that contains (at the root of the archive)
@@ -131,7 +142,7 @@ class iTopArchive
public function WriteCatalog()
{
$sXml = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?".">\n"; // split the XML closing tag that disturbs PSPad's syntax coloring
$sXml = "<?xml version=\"1.0\" encoding=\"utf-8\"?".">\n"; // split the XML closing tag that disturbs PSPad's syntax coloring
$sXml .= "<archive version=\"1.0\">\n";
$sXml .= "<title>{$this->m_sTitle}</title>\n";
$sXml .= "<description>{$this->m_sDescription}</description>\n";

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,15 +1,33 @@
<?php
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* Persistent class (internal) cmdbChange
*
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
/**
* A change as requested/validated at once by user, may groups many atomic changes
*
* @package iTopORM
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @author Denis Flaven <denisflave@free.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version 1.1.1.1 $
*/
class CMDBChange extends DBObject
{
@@ -18,10 +36,7 @@ class CMDBChange extends DBObject
$aParams = array
(
"category" => "core/cmdb",
"name" => "change",
"description" => "Changes tracking",
"key_type" => "autoincrement",
"key_label" => "",
"name_attcode" => "date",
"state_attcode" => "",
"reconc_keys" => array(),
@@ -31,14 +46,37 @@ class CMDBChange extends DBObject
);
MetaModel::Init_Params($aParams);
//MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeDate("date", array("label"=>"date", "description"=>"date and time at which the changes have been recorded", "allowed_values"=>null, "sql"=>"date", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("userinfo", array("label"=>"misc. info", "description"=>"caller's defined information", "allowed_values"=>null, "sql"=>"userinfo", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
//MetaModel::Init_InheritFilters();
MetaModel::Init_AddFilterFromAttribute("date");
MetaModel::Init_AddFilterFromAttribute("userinfo");
MetaModel::Init_AddAttribute(new AttributeDateTime("date", array("allowed_values"=>null, "sql"=>"date", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("userinfo", array("allowed_values"=>null, "sql"=>"userinfo", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
}
// Helper to keep track of the author of a given change,
// taking into account a variety of cases (contact attached or not, impersonation)
static public function GetCurrentUserName()
{
if (UserRights::IsImpersonated())
{
$sUserString = Dict::Format('UI:Archive_User_OnBehalfOf_User', UserRights::GetRealUserFriendlyName(), UserRights::GetUserFriendlyName());
}
else
{
$sUserString = UserRights::GetUserFriendlyName();
}
return $sUserString;
}
public function GetUserName()
{
if (preg_match('/^(.*)\\(CSV\\)$/i', $this->Get('userinfo'), $aMatches))
{
$sUser = $aMatches[1];
}
else
{
$sUser = $this->Get('userinfo');
}
return $sUser;
}
}
?>

View File

@@ -1,15 +1,33 @@
<?php
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* Persistent classes (internal) : cmdbChangeOp and derived
*
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
/**
* Various atomic change operations, to be tracked
*
* @package iTopORM
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @author Denis Flaven <denisflave@free.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version 1.1.1.1 $
*/
class CMDBChangeOp extends DBObject
@@ -19,10 +37,7 @@ class CMDBChangeOp extends DBObject
$aParams = array
(
"category" => "core/cmdb",
"name" => "change operation",
"description" => "Change operations tracking",
"key_type" => "autoincrement",
"key_label" => "",
"name_attcode" => "change",
"state_attcode" => "",
"reconc_keys" => array(),
@@ -32,20 +47,16 @@ class CMDBChangeOp extends DBObject
);
MetaModel::Init_Params($aParams);
//MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeExternalKey("change", array("label"=>"change", "description"=>"change", "allowed_values"=>null, "sql"=>"changeid", "targetclass"=>"CMDBChange", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("date", array("label"=>"date", "description"=>"date and time of the change", "allowed_values"=>null, "extkey_attcode"=>"change", "target_attcode"=>"date")));
MetaModel::Init_AddAttribute(new AttributeExternalField("userinfo", array("label"=>"user", "description"=>"who made this change", "allowed_values"=>null, "extkey_attcode"=>"change", "target_attcode"=>"userinfo")));
MetaModel::Init_AddAttribute(new AttributeString("objclass", array("label"=>"object class", "description"=>"object class", "allowed_values"=>null, "sql"=>"objclass", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("objkey", array("label"=>"object id", "description"=>"object id", "allowed_values"=>null, "sql"=>"objkey", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddFilterFromAttribute("objclass");
MetaModel::Init_AddFilterFromAttribute("objkey");
MetaModel::Init_AddFilterFromAttribute("date");
MetaModel::Init_AddFilterFromAttribute("userinfo");
MetaModel::Init_AddAttribute(new AttributeExternalKey("change", array("allowed_values"=>null, "sql"=>"changeid", "targetclass"=>"CMDBChange", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("date", array("allowed_values"=>null, "extkey_attcode"=>"change", "target_attcode"=>"date")));
MetaModel::Init_AddAttribute(new AttributeExternalField("userinfo", array("allowed_values"=>null, "extkey_attcode"=>"change", "target_attcode"=>"userinfo")));
MetaModel::Init_AddAttribute(new AttributeString("objclass", array("allowed_values"=>null, "sql"=>"objclass", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("objkey", array("allowed_values"=>null, "sql"=>"objkey", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_SetZListItems('details', array('change', 'date', 'userinfo')); // Attributes to be displayed for the complete details
MetaModel::Init_SetZListItems('list', array('change', 'date', 'userinfo')); // Attributes to be displayed for the complete details
}
/**
* Describe (as a text string) the modifications corresponding to this change
*/
@@ -61,11 +72,6 @@ class CMDBChangeOp extends DBObject
* Record the creation of an object
*
* @package iTopORM
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version $itopversion$
*/
class CMDBChangeOpCreate extends CMDBChangeOp
{
@@ -74,10 +80,7 @@ class CMDBChangeOpCreate extends CMDBChangeOp
$aParams = array
(
"category" => "core/cmdb",
"name" => "object creation",
"description" => "Object creation tracking",
"key_type" => "",
"key_label" => "",
"name_attcode" => "change",
"state_attcode" => "",
"reconc_keys" => array(),
@@ -87,8 +90,6 @@ class CMDBChangeOpCreate extends CMDBChangeOp
);
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();
MetaModel::Init_InheritFilters();
}
/**
@@ -96,7 +97,7 @@ class CMDBChangeOpCreate extends CMDBChangeOp
*/
public function GetDescription()
{
return 'Object created';
return Dict::S('Change:ObjectCreated');
}
}
@@ -105,11 +106,6 @@ class CMDBChangeOpCreate extends CMDBChangeOp
* Record the deletion of an object
*
* @package iTopORM
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version $itopversion$
*/
class CMDBChangeOpDelete extends CMDBChangeOp
{
@@ -118,10 +114,7 @@ class CMDBChangeOpDelete extends CMDBChangeOp
$aParams = array
(
"category" => "core/cmdb",
"name" => "object deletion",
"description" => "Object deletion tracking",
"key_type" => "",
"key_label" => "",
"name_attcode" => "change",
"state_attcode" => "",
"reconc_keys" => array(),
@@ -131,15 +124,13 @@ class CMDBChangeOpDelete extends CMDBChangeOp
);
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();
MetaModel::Init_InheritFilters();
}
/**
* Describe (as a text string) the modifications corresponding to this change
*/
public function GetDescription()
{
return 'Object deleted';
return Dict::S('Change:ObjectDeleted');
}
}
@@ -148,11 +139,6 @@ class CMDBChangeOpDelete extends CMDBChangeOp
* Record the modification of an attribute (abstract)
*
* @package iTopORM
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version $itopversion$
*/
class CMDBChangeOpSetAttribute extends CMDBChangeOp
{
@@ -161,10 +147,7 @@ class CMDBChangeOpSetAttribute extends CMDBChangeOp
$aParams = array
(
"category" => "core/cmdb",
"name" => "object change",
"description" => "Object properties change tracking",
"key_type" => "",
"key_label" => "",
"name_attcode" => "change",
"state_attcode" => "",
"reconc_keys" => array(),
@@ -174,10 +157,7 @@ class CMDBChangeOpSetAttribute extends CMDBChangeOp
);
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeString("attcode", array("label"=>"Attribute", "description"=>"code of the modified property", "allowed_values"=>null, "sql"=>"attcode", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_InheritFilters();
MetaModel::Init_AddFilterFromAttribute("attcode");
MetaModel::Init_AddAttribute(new AttributeString("attcode", array("allowed_values"=>null, "sql"=>"attcode", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
// Display lists
MetaModel::Init_SetZListItems('details', array('date', 'userinfo', 'attcode')); // Attributes to be displayed for the complete details
@@ -189,11 +169,6 @@ class CMDBChangeOpSetAttribute extends CMDBChangeOp
* Record the modification of a scalar attribute
*
* @package iTopORM
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version $itopversion$
*/
class CMDBChangeOpSetAttributeScalar extends CMDBChangeOpSetAttribute
{
@@ -202,10 +177,7 @@ class CMDBChangeOpSetAttributeScalar extends CMDBChangeOpSetAttribute
$aParams = array
(
"category" => "core/cmdb",
"name" => "property change",
"description" => "Object scalar properties change tracking",
"key_type" => "",
"key_label" => "",
"name_attcode" => "change",
"state_attcode" => "",
"reconc_keys" => array(),
@@ -215,12 +187,8 @@ class CMDBChangeOpSetAttributeScalar extends CMDBChangeOpSetAttribute
);
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeString("oldvalue", array("label"=>"Previous value", "description"=>"previous value of the attribute", "allowed_values"=>null, "sql"=>"oldvalue", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("newvalue", array("label"=>"New value", "description"=>"new value of the attribute", "allowed_values"=>null, "sql"=>"newvalue", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_InheritFilters();
MetaModel::Init_AddFilterFromAttribute("oldvalue");
MetaModel::Init_AddFilterFromAttribute("newvalue");
MetaModel::Init_AddAttribute(new AttributeString("oldvalue", array("allowed_values"=>null, "sql"=>"oldvalue", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("newvalue", array("allowed_values"=>null, "sql"=>"newvalue", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
// Display lists
MetaModel::Init_SetZListItems('details', array('date', 'userinfo', 'attcode', 'oldvalue', 'newvalue')); // Attributes to be displayed for the complete details
@@ -239,7 +207,7 @@ class CMDBChangeOpSetAttributeScalar extends CMDBChangeOpSetAttribute
$oTargetObjectClass = $this->Get('objclass');
$oTargetObjectKey = $this->Get('objkey');
$oTargetSearch = new DBObjectSearch($oTargetObjectClass);
$oTargetSearch->AddCondition('id', $oTargetObjectKey);
$oTargetSearch->AddCondition('id', $oTargetObjectKey, '=');
$oMonoObjectSet = new DBObjectSet($oTargetSearch);
if (UserRights::IsActionAllowedOnAttribute($this->Get('objclass'), $this->Get('attcode'), UR_ACTION_READ, $oMonoObjectSet) == UR_ALLOWED_YES)
@@ -255,16 +223,16 @@ class CMDBChangeOpSetAttributeScalar extends CMDBChangeOpSetAttribute
if (substr($sNewValue,0, strlen($sOldValue)) == $sOldValue) // Text added at the end
{
$sDelta = substr($sNewValue, strlen($sOldValue));
$sResult = "$sDelta appended to $sAttName";
$sResult = Dict::Format('Change:Text_AppendedTo_AttName', $sDelta, $sAttName);
}
else if (substr($sNewValue, -strlen($sOldValue)) == $sOldValue) // Text added at the beginning
{
$sDelta = substr($sNewValue, 0, strlen($sNewValue) - strlen($sOldValue));
$sResult = "$sDelta appended to $sAttName";
$sResult = Dict::Format('Change:Text_AppendedTo_AttName', $sDelta, $sAttName);
}
else
{
$sResult = "$sAttName set to $sNewValue (previous value: $sOldValue)";
$sResult = Dict::Format('Change:AttName_SetTo_NewValue_PreviousValue_OldValue', $sAttName, $sNewValue, $sOldValue);
}
}
elseif($bIsHtml && $oAttDef->IsExternalKey())
@@ -280,7 +248,7 @@ class CMDBChangeOpSetAttributeScalar extends CMDBChangeOpSetAttribute
}
else
{
$sResult = "$sAttName set to $sNewValue (previous value: $sOldValue)";
$sResult = Dict::Format('Change:AttName_SetTo_NewValue_PreviousValue_OldValue', $sAttName, $sNewValue, $sOldValue);
}
}
return $sResult;
@@ -291,11 +259,6 @@ class CMDBChangeOpSetAttributeScalar extends CMDBChangeOpSetAttribute
* Record the modification of a blob
*
* @package iTopORM
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version $itopversion$
*/
class CMDBChangeOpSetAttributeBlob extends CMDBChangeOpSetAttribute
{
@@ -304,10 +267,7 @@ class CMDBChangeOpSetAttributeBlob extends CMDBChangeOpSetAttribute
$aParams = array
(
"category" => "core/cmdb",
"name" => "data change",
"description" => "data change tracking",
"key_type" => "",
"key_label" => "",
"name_attcode" => "change",
"state_attcode" => "",
"reconc_keys" => array(),
@@ -317,10 +277,8 @@ class CMDBChangeOpSetAttributeBlob extends CMDBChangeOpSetAttribute
);
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeBlob("prevdata", array("label"=>"Previous data", "description"=>"previous contents of the attribute", "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeBlob("prevdata", array("depends_on"=>array())));
MetaModel::Init_InheritFilters();
// Display lists
MetaModel::Init_SetZListItems('details', array('date', 'userinfo', 'attcode')); // Attributes to be displayed for the complete details
MetaModel::Init_SetZListItems('list', array('date', 'userinfo', 'attcode')); // Attributes to be displayed for a list
@@ -338,7 +296,7 @@ class CMDBChangeOpSetAttributeBlob extends CMDBChangeOpSetAttribute
$oTargetObjectClass = $this->Get('objclass');
$oTargetObjectKey = $this->Get('objkey');
$oTargetSearch = new DBObjectSearch($oTargetObjectClass);
$oTargetSearch->AddCondition('id', $oTargetObjectKey);
$oTargetSearch->AddCondition('id', $oTargetObjectKey, '=');
$oMonoObjectSet = new DBObjectSet($oTargetSearch);
if (UserRights::IsActionAllowedOnAttribute($this->Get('objclass'), $this->Get('attcode'), UR_ACTION_READ, $oMonoObjectSet) == UR_ALLOWED_YES)
@@ -347,11 +305,114 @@ class CMDBChangeOpSetAttributeBlob extends CMDBChangeOpSetAttribute
$sAttName = $oAttDef->GetLabel();
$oPrevDoc = $this->Get('prevdata');
$sDocView = $oPrevDoc->GetAsHtml();
$sDocView .= "<br/>Open in New Window: ".$oPrevDoc->GetDisplayLink(get_class($this), $this->GetKey(), 'prevdata').", \n";
$sDocView .= "Download: ".$oPrevDoc->GetDownloadLink(get_class($this), $this->GetKey(), 'prevdata')."\n";
$sDocView .= "<br/>".Dict::Format('UI:OpenDocumentInNewWindow_',$oPrevDoc->GetDisplayLink(get_class($this), $this->GetKey(), 'prevdata')).", \n";
$sDocView .= Dict::Format('UI:DownloadDocument_', $oPrevDoc->GetDownloadLink(get_class($this), $this->GetKey(), 'prevdata'))."\n";
//$sDocView = $oPrevDoc->GetDisplayInline(get_class($this), $this->GetKey(), 'prevdata');
$sResult = "$sAttName changed, previous value: $sDocView";
$sResult = Dict::Format('Change:AttName_Changed_PreviousValue_OldValue', $sAttName, $sDocView);
}
return $sResult;
}
}
/**
* Safely record the modification of one way encrypted password
*/
class CMDBChangeOpSetAttributeOneWayPassword extends CMDBChangeOpSetAttribute
{
public static function Init()
{
$aParams = array
(
"category" => "core/cmdb",
"key_type" => "",
"name_attcode" => "change",
"state_attcode" => "",
"reconc_keys" => array(),
"db_table" => "priv_changeop_setatt_pwd",
"db_key_field" => "id",
"db_finalclass_field" => "",
);
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeOneWayPassword("prev_pwd", array("sql" => 'data', "default_value" => '', "is_null_allowed"=> true, "allowed_values" => null, "depends_on"=>array())));
// Display lists
MetaModel::Init_SetZListItems('details', array('date', 'userinfo', 'attcode')); // Attributes to be displayed for the complete details
MetaModel::Init_SetZListItems('list', array('date', 'userinfo', 'attcode')); // Attributes to be displayed for a list
}
/**
* Describe (as a text string) the modifications corresponding to this change
*/
public function GetDescription()
{
// Temporary, until we change the options of GetDescription() -needs a more global revision
$bIsHtml = true;
$sResult = '';
$oTargetObjectClass = $this->Get('objclass');
$oTargetObjectKey = $this->Get('objkey');
$oTargetSearch = new DBObjectSearch($oTargetObjectClass);
$oTargetSearch->AddCondition('id', $oTargetObjectKey, '=');
$oMonoObjectSet = new DBObjectSet($oTargetSearch);
if (UserRights::IsActionAllowedOnAttribute($this->Get('objclass'), $this->Get('attcode'), UR_ACTION_READ, $oMonoObjectSet) == UR_ALLOWED_YES)
{
$oAttDef = MetaModel::GetAttributeDef($this->Get('objclass'), $this->Get('attcode'));
$sAttName = $oAttDef->GetLabel();
$sResult = Dict::Format('Change:AttName_Changed', $sAttName);
}
return $sResult;
}
}
/**
* Safely record the modification of an encrypted field
*/
class CMDBChangeOpSetAttributeEncrypted extends CMDBChangeOpSetAttribute
{
public static function Init()
{
$aParams = array
(
"category" => "core/cmdb",
"key_type" => "",
"name_attcode" => "change",
"state_attcode" => "",
"reconc_keys" => array(),
"db_table" => "priv_changeop_setatt_encrypted",
"db_key_field" => "id",
"db_finalclass_field" => "",
);
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeEncryptedString("prevstring", array("sql" => 'data', "default_value" => '', "is_null_allowed"=> true, "allowed_values" => null, "depends_on"=>array())));
// Display lists
MetaModel::Init_SetZListItems('details', array('date', 'userinfo', 'attcode')); // Attributes to be displayed for the complete details
MetaModel::Init_SetZListItems('list', array('date', 'userinfo', 'attcode')); // Attributes to be displayed for a list
}
/**
* Describe (as a text string) the modifications corresponding to this change
*/
public function GetDescription()
{
// Temporary, until we change the options of GetDescription() -needs a more global revision
$bIsHtml = true;
$sResult = '';
$oTargetObjectClass = $this->Get('objclass');
$oTargetObjectKey = $this->Get('objkey');
$oTargetSearch = new DBObjectSearch($oTargetObjectClass);
$oTargetSearch->AddCondition('id', $oTargetObjectKey, '=');
$oMonoObjectSet = new DBObjectSet($oTargetSearch);
if (UserRights::IsActionAllowedOnAttribute($this->Get('objclass'), $this->Get('attcode'), UR_ACTION_READ, $oMonoObjectSet) == UR_ALLOWED_YES)
{
$oAttDef = MetaModel::GetAttributeDef($this->Get('objclass'), $this->Get('attcode'));
$sAttName = $oAttDef->GetLabel();
$sPrevString = $this->Get('prevstring');
$sResult = Dict::Format('Change:AttName_Changed_PreviousValue_OldValue', $sAttName, $sPrevString);
}
return $sResult;
}
@@ -361,11 +422,6 @@ class CMDBChangeOpSetAttributeBlob extends CMDBChangeOpSetAttribute
* Record the modification of a multiline string (text)
*
* @package iTopORM
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version $itopversion$
*/
class CMDBChangeOpSetAttributeText extends CMDBChangeOpSetAttribute
{
@@ -374,10 +430,7 @@ class CMDBChangeOpSetAttributeText extends CMDBChangeOpSetAttribute
$aParams = array
(
"category" => "core/cmdb",
"name" => "text change",
"description" => "text change tracking",
"key_type" => "",
"key_label" => "",
"name_attcode" => "change",
"state_attcode" => "",
"reconc_keys" => array(),
@@ -387,10 +440,8 @@ class CMDBChangeOpSetAttributeText extends CMDBChangeOpSetAttribute
);
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeText("prevdata", array("label"=>"Previous data", "description"=>"previous contents of the attribute", "allowed_values"=>null, "sql"=>"prevdata", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("prevdata", array("allowed_values"=>null, "sql"=>"prevdata", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_InheritFilters();
// Display lists
MetaModel::Init_SetZListItems('details', array('date', 'userinfo', 'attcode')); // Attributes to be displayed for the complete details
MetaModel::Init_SetZListItems('list', array('date', 'userinfo', 'attcode')); // Attributes to be displayed for a list
@@ -408,7 +459,7 @@ class CMDBChangeOpSetAttributeText extends CMDBChangeOpSetAttribute
$oTargetObjectClass = $this->Get('objclass');
$oTargetObjectKey = $this->Get('objkey');
$oTargetSearch = new DBObjectSearch($oTargetObjectClass);
$oTargetSearch->AddCondition('id', $oTargetObjectKey);
$oTargetSearch->AddCondition('id', $oTargetObjectKey, '=');
$oMonoObjectSet = new DBObjectSet($oTargetSearch);
if (UserRights::IsActionAllowedOnAttribute($this->Get('objclass'), $this->Get('attcode'), UR_ACTION_READ, $oMonoObjectSet) == UR_ALLOWED_YES)
@@ -418,7 +469,7 @@ class CMDBChangeOpSetAttributeText extends CMDBChangeOpSetAttribute
$sTextView = '<div>'.$this->GetAsHtml('prevdata').'</div>';
//$sDocView = $oPrevDoc->GetDisplayInline(get_class($this), $this->GetKey(), 'prevdata');
$sResult = "$sAttName changed, previous value: $sTextView";
$sResult = Dict::Format('Change:AttName_Changed_PreviousValue_OldValue', $sAttName, $sTextView);
}
return $sResult;
}

View File

@@ -1,21 +1,43 @@
<?php
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* Class cmdbObject
*
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
/**
* cmdbObjectClass
* the file to include, then the core is yours
*
* @package iTopORM
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @author Denis Flaven <denisflave@free.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version 1.1.1.1 $
*/
require_once('coreexception.class.inc.php');
require_once('config.class.inc.php');
require_once('log.class.inc.php');
require_once('kpi.class.inc.php');
require_once('dict.class.inc.php');
require_once('attributedef.class.inc.php');
require_once('filterdef.class.inc.php');
@@ -37,6 +59,8 @@ require_once('dbobject.class.php');
require_once('dbobjectsearch.class.php');
require_once('dbobjectset.class.php');
require_once('dbproperty.class.inc.php');
// db change tracking data model
require_once('cmdbchange.class.inc.php');
require_once('cmdbchangeop.class.inc.php');
@@ -53,98 +77,16 @@ require_once('cmdbchangeop.class.inc.php');
require_once('csvparser.class.inc.php');
require_once('bulkchange.class.inc.php');
require_once('userrights.class.inc.php');
//
// Error handling
// To be finalized... or removed ?
//
function cmdbErrorHandler($errno, $errstr, $errfile, $errline)
{
// font-family: Courier-New, Courier, Arial, Helevtica;
$sErrorStyle = "
background-color: #ffaaaa;
color: #000000;
border: 1px dashed #000000;
padding: 0.25em;
margin-top: 1em;
";
$sCallStackStyle = "
font-size: smaller;
background-color: #ffcccc;
color: #000000;
border: 1px dashed #000000;
padding: 0.25em;
margin-top: 1em;
";
switch ($errno)
{
case E_USER_ERROR:
case E_ERROR:
echo "<div style=\"$sErrorStyle\">\n";
echo "<b>Error</b> [$errno] $errstr<br />\n";
echo "<div style=\"$sCallStackStyle\">\n";
MyHelpers::dump_callstack(1);
echo "</div>\n";
echo "Hereafter the biz model internals:<br />\n";
echo "<pre>\n";
MetaModel::static_var_dump();
echo "</pre>\n";
echo "Aborting...<br />\n";
echo "</div>\n";
exit(1);
break;
case E_USER_WARNING:
case E_WARNING:
echo "<div style=\"background-color:#FAA;\">\n";
echo "<b>Warning</b> [$errno] $errstr<br />\n";
echo "<div style=\"background-color:#FCC;\">\n";
MyHelpers::dump_callstack(1);
echo "</div>\n";
echo "</div>\n";
break;
case E_USER_NOTICE:
case E_NOTICE:
echo "<div style=\"background-color:#FAA;\">\n";
echo "<b>Notice</b> [$errno] $errstr<br />\n";
echo "<div style=\"background-color:#FCC;\">\n";
MyHelpers::dump_callstack(1);
echo "</div>\n";
echo "</div>\n";
break;
default:
echo "Unknown error type: [$errno] $errstr<br />\n";
MyHelpers::dump_callstack(1);
break;
}
}
error_reporting(E_ALL | E_STRICT);
//set_error_handler("cmdbErrorHandler");
//
//
//
/**
* A persistent object, which changes are accurately recorded
*
* @package iTopORM
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @author Denis Flaven <denisflave@free.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version 1.1.1.1 $
*/
abstract class CMDBObject extends DBObject
{
protected $m_datCreated;
protected $m_datUpdated;
// Note: this value is static, but that could be changed because it is sometimes a real issue (see update of interfaces / connected_to
protected static $m_oCurrChange = null;
@@ -173,7 +115,47 @@ abstract class CMDBObject extends DBObject
$oAttDef = MetaModel::GetAttributeDef(get_class($this), $sAttCode);
if ($oAttDef->IsLinkSet()) continue; // #@# temporary
if ($oAttDef instanceOf AttributeBlob)
if ($oAttDef instanceOf AttributeOneWayPassword)
{
// One Way encrypted passwords' history is stored -one way- encrypted
$oMyChangeOp = MetaModel::NewObject("CMDBChangeOpSetAttributeOneWayPassword");
$oMyChangeOp->Set("change", $oChange->GetKey());
$oMyChangeOp->Set("objclass", get_class($this));
$oMyChangeOp->Set("objkey", $this->GetKey());
$oMyChangeOp->Set("attcode", $sAttCode);
if (array_key_exists($sAttCode, $aOrigValues))
{
$original = $aOrigValues[$sAttCode];
}
else
{
$original = '';
}
$oMyChangeOp->Set("prev_pwd", $original);
$iId = $oMyChangeOp->DBInsertNoReload();
}
elseif ($oAttDef instanceOf AttributeEncryptedString)
{
// Encrypted string history is stored encrypted
$oMyChangeOp = MetaModel::NewObject("CMDBChangeOpSetAttributeEncrypted");
$oMyChangeOp->Set("change", $oChange->GetKey());
$oMyChangeOp->Set("objclass", get_class($this));
$oMyChangeOp->Set("objkey", $this->GetKey());
$oMyChangeOp->Set("attcode", $sAttCode);
if (array_key_exists($sAttCode, $aOrigValues))
{
$original = $aOrigValues[$sAttCode];
}
else
{
$original = '';
}
$oMyChangeOp->Set("prevstring", $original);
$iId = $oMyChangeOp->DBInsertNoReload();
}
elseif ($oAttDef instanceOf AttributeBlob)
{
// Data blobs
$oMyChangeOp = MetaModel::NewObject("CMDBChangeOpSetAttributeBlob");
@@ -238,6 +220,35 @@ abstract class CMDBObject extends DBObject
}
}
/**
* Helper to ultimately check user rights before writing (Insert, Update or Delete)
* The check should never fail, because the UI should prevent from such a usage
* Anyhow, if the user has found a workaround... the security gets enforced here
*/
protected function CheckUserRights($bSkipStrongSecurity, $iActionCode)
{
if (is_null($bSkipStrongSecurity))
{
// This is temporary
// We have implemented this safety net right before releasing iTop 1.0
// and we decided that it was too risky to activate it
// Anyhow, users willing to have a very strong security could set
// skip_strong_security = 0, in the config file
$bSkipStrongSecurity = MetaModel::GetConfig()->Get('skip_strong_security');
}
if (!$bSkipStrongSecurity)
{
$sClass = get_class($this);
$oSet = DBObjectSet::FromObject($this);
if (!UserRights::IsActionAllowed($sClass, $iActionCode, $oSet))
{
// Intrusion detected
throw new SecurityException('You are not allowed to modify objects of class: '.$sClass);
}
}
}
public function DBInsert()
{
if(!is_object(self::$m_oCurrChange))
@@ -247,16 +258,20 @@ abstract class CMDBObject extends DBObject
return $this->DBInsertTracked_Internal();
}
public function DBInsertTracked(CMDBChange $oChange)
public function DBInsertTracked(CMDBChange $oChange, $bSkipStrongSecurity = null)
{
$this->CheckUserRights($bSkipStrongSecurity, UR_ACTION_MODIFY);
self::$m_oCurrChange = $oChange;
$ret = $this->DBInsertTracked_Internal();
self::$m_oCurrChange = null;
return $ret;
}
public function DBInsertTrackedNoReload(CMDBChange $oChange)
public function DBInsertTrackedNoReload(CMDBChange $oChange, $bSkipStrongSecurity = null)
{
$this->CheckUserRights($bSkipStrongSecurity, UR_ACTION_MODIFY);
self::$m_oCurrChange = $oChange;
$ret = $this->DBInsertTracked_Internal(true);
self::$m_oCurrChange = null;
@@ -311,8 +326,10 @@ abstract class CMDBObject extends DBObject
return $this->DBUpdateTracked_internal();
}
public function DBUpdateTracked(CMDBChange $oChange)
public function DBUpdateTracked(CMDBChange $oChange, $bSkipStrongSecurity = null)
{
$this->CheckUserRights($bSkipStrongSecurity, UR_ACTION_MODIFY);
self::$m_oCurrChange = $oChange;
$this->DBUpdateTracked_Internal();
self::$m_oCurrChange = null;
@@ -324,7 +341,7 @@ abstract class CMDBObject extends DBObject
$aChanges = $this->ListChanges();
if (count($aChanges) == 0)
{
throw new CoreWarning("Attempting to update an unchanged object");
//throw new CoreWarning("Attempting to update an unchanged object");
return;
}
@@ -344,8 +361,10 @@ abstract class CMDBObject extends DBObject
return $this->DBDeleteTracked_Internal();
}
public function DBDeleteTracked(CMDBChange $oChange)
public function DBDeleteTracked(CMDBChange $oChange, $bSkipStrongSecurity = null)
{
$this->CheckUserRights($bSkipStrongSecurity, UR_ACTION_DELETE);
self::$m_oCurrChange = $oChange;
$this->DBDeleteTracked_Internal();
self::$m_oCurrChange = null;
@@ -381,7 +400,7 @@ abstract class CMDBObject extends DBObject
// Get the list of objects to delete (and record data before deleting the DB records)
$oObjSet = new CMDBObjectSet($oFilter);
$aObjAndKeys = array(); // array of pkey=>object
$aObjAndKeys = array(); // array of id=>object
while ($oItem = $oObjSet->Fetch())
{
$aObjAndKeys[$oItem->GetKey()] = $oItem;
@@ -450,12 +469,6 @@ abstract class CMDBObject extends DBObject
* TODO: investigate how to get rid of this class that was made to workaround some language limitation... or a poor design!
*
* @package iTopORM
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @author Denis Flaven <denisflave@free.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version 1.1.1.1 $
*/
class CMDBObjectSet extends DBObjectSet
{
@@ -486,18 +499,30 @@ class CMDBObjectSet extends DBObjectSet
return $oRetSet;
}
static public function FromArrayAssoc($aClasses, $aObjects)
{
// In a perfect world, we should create a complete tree of DBObjectSearch,
// but as we lack most of the information related to the objects,
// let's create one search definition
$sClass = reset($aClasses);
$sAlias = key($aClasses);
$oFilter = new CMDBSearchFilter($sClass, $sAlias);
$oRetSet = new CMDBObjectSet($oFilter);
$oRetSet->m_bLoaded = true; // no DB load
foreach($aObjects as $rowIndex => $aObjectsByClassAlias)
{
$oRetSet->AddObjectExtended($aObjectsByClassAlias);
}
return $oRetSet;
}
}
/**
* TODO: investigate how to get rid of this class that was made to workaround some language limitation... or a poor design!
*
* @package iTopORM
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @author Denis Flaven <denisflave@free.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version 1.1.1.1 $
*/
class CMDBSearchFilter extends DBObjectSearch
{

View File

@@ -1,16 +1,26 @@
<?php
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* CMDBSource
* database access wrapper
* DB Server abstraction
*
* @package iTopORM
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @author Denis Flaven <denisflave@free.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version 1.1.1.1 $
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
require_once('MyHelpers.class.inc.php');
@@ -26,6 +36,12 @@ class MySQLException extends CoreException
}
/**
* CMDBSource
* database access wrapper
*
* @package iTopORM
*/
class CMDBSource
{
protected static $m_sDBHost;
@@ -53,6 +69,21 @@ class CMDBSource
}
}
public static function SetCharacterSet($sCharset = 'utf8', $sCollation = 'utf8_general_ci')
{
if (strlen($sCharset) > 0)
{
if (strlen($sCollation) > 0)
{
self::Query("SET NAMES '$sCharset' COLLATE '$sCollation'");
}
else
{
self::Query("SET NAMES '$sCharset'");
}
}
}
public static function ListDB()
{
$aDBs = self::QueryToCol('SHOW DATABASES', 'Database');
@@ -143,6 +174,11 @@ class CMDBSource
// otherwise and if there is a mix of strings and numbers, the clause
// would always be false
if (is_null($value))
{
return 'NULL';
}
if (is_array($value))
{
$aRes = array();
@@ -159,7 +195,7 @@ class CMDBSource
$value = stripslashes($value);
}
// Quote if not a number or a numeric string
if ($bAlways || !is_numeric($value))
if ($bAlways || is_string($value))
{
$value = $cQuoteStyle . mysql_real_escape_string($value, self::$m_resDBLink) . $cQuoteStyle;
}
@@ -174,14 +210,13 @@ class CMDBSource
//$aTraceInf['file'] = __FILE__;
// $sSQLQuery .= MyHelpers::MakeSQLComment($aTraceInf);
$mu_t1 = MyHelpers::getmicrotime();
$oKPI = new ExecutionKPI();
$result = mysql_query($sSQLQuery, self::$m_resDBLink);
if (!$result)
{
throw new MySQLException('Failed to issue SQL query', array('query' => $sSQLQuery));
}
$mu_t2 = MyHelpers::getmicrotime();
// #@# todo - query_trace($sSQLQuery, $mu_t2 - $mu_t1);
$oKPI->ComputeStats('Query exec (mySQL)', $sSQLQuery);
return $result;
}
@@ -244,19 +279,7 @@ class CMDBSource
throw new MySQLException('Failed to issue SQL query', array('query' => $sSql));
}
$aNames = array();
for ($i = 0; $i < mysql_num_fields($result) ; $i++)
{
$meta = mysql_fetch_field($result, $i);
if (!$meta)
{
throw new MySQLException('mysql_fetch_field: No information available', array('query'=>$sSql, 'i'=>$i));
}
else
{
$aNames[] = $meta->name;
}
}
$aNames = self::GetColumns($result);
$aData[] = $aNames;
while ($aRow = mysql_fetch_array($result, MYSQL_ASSOC))
@@ -289,6 +312,24 @@ class CMDBSource
return mysql_fetch_array($result, MYSQL_ASSOC);
}
public static function GetColumns($result)
{
$aNames = array();
for ($i = 0; $i < mysql_num_fields($result) ; $i++)
{
$meta = mysql_fetch_field($result, $i);
if (!$meta)
{
throw new MySQLException('mysql_fetch_field: No information available', array('query'=>$sSql, 'i'=>$i));
}
else
{
$aNames[] = $meta->name;
}
}
return $aNames;
}
public static function Seek($result, $iRow)
{
return mysql_data_seek($result, $iRow);
@@ -492,6 +533,51 @@ class CMDBSource
// so far, only one line...
return implode(', ', $aRes);
}
/**
* Determine the slave status of the server
* @return bool true if the server is slave
*/
public static function IsSlaveServer()
{
try
{
$result = self::Query('SHOW SLAVE STATUS');
}
catch(MySQLException $e)
{
throw new CoreException("Current user not allowed to check the status", array('mysql_error' => $e->getMessage()));
}
if (mysql_num_rows($result) == 0)
{
return false;
}
// Returns one single row anytime
$aRow = mysql_fetch_array($result, MYSQL_ASSOC);
mysql_free_result($result);
if (!isset($aRow['Slave_IO_Running']))
{
return false;
}
if (!isset($aRow['Slave_SQL_Running']))
{
return false;
}
// If at least one slave thread is running, then we consider that the slave is enabled
if ($aRow['Slave_IO_Running'] == 'Yes')
{
return true;
}
if ($aRow['Slave_SQL_Running'] == 'Yes')
{
return true;
}
return false;
}
}

View File

@@ -1,26 +1,73 @@
<?php
require_once('coreexception.class.inc.php');
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
define('ITOP_VERSION', '$ITOP_VERSION$');
define('ITOP_REVISION', '$WCREV$');
define('ITOP_BUILD_DATE', '$WCNOW$');
define('ACCESS_USER_WRITE', 1);
define('ACCESS_ADMIN_WRITE', 2);
define('ACCESS_FULL', ACCESS_USER_WRITE | ACCESS_ADMIN_WRITE);
define('ACCESS_READONLY', 0);
/**
* Config
* configuration data
* Configuration read/write
*
* @package iTopORM
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @author Denis Flaven <denisflave@free.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version 1.1.1.1 $
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
require_once('coreexception.class.inc.php');
class ConfigException extends CoreException
{
}
define ('DEFAULT_CHARACTER_SET', 'utf8');
define ('DEFAULT_COLLATION', 'utf8_general_ci');
define ('DEFAULT_LOG_GLOBAL', true);
define ('DEFAULT_LOG_NOTIFICATION', true);
define ('DEFAULT_LOG_ISSUE', true);
define ('DEFAULT_LOG_WEB_SERVICE', true);
define ('DEFAULT_LOG_KPI_DURATION', false);
define ('DEFAULT_LOG_KPI_MEMORY', false);
define ('DEFAULT_DEBUG_QUERIES', false);
define ('DEFAULT_QUERY_CACHE_ENABLED', true);
define ('DEFAULT_MIN_DISPLAY_LIMIT', 10);
define ('DEFAULT_MAX_DISPLAY_LIMIT', 15);
define ('DEFAULT_STANDARD_RELOAD_INTERVAL', 5*60);
define ('DEFAULT_FAST_RELOAD_INTERVAL', 1*60);
define ('DEFAULT_SECURE_CONNECTION_REQUIRED', false);
define ('DEFAULT_HTTPS_HYPERLINKS', false);
define ('DEFAULT_ALLOWED_LOGIN_TYPES', 'form|basic|external');
define ('DEFAULT_EXT_AUTH_VARIABLE', '$_SERVER[\'REMOTE_USER\']');
define ('DEFAULT_ENCRYPTION_KEY', '@iT0pEncr1pti0n!'); // We'll use a random value, later...
/**
* Config
* configuration data (this class cannot not be localized, because it is responsible for loading the dictionaries)
*
* @package iTopORM
*/
class Config
{
//protected $m_bIsLoaded = false;
@@ -28,13 +75,194 @@ class Config
protected $m_aAppModules;
protected $m_aDataModels;
protected $m_aWebServiceCategories;
protected $m_aAddons;
protected $m_aDictionaries;
protected $m_aModuleSettings;
// New way to store the settings !
//
protected $m_aSettings = array(
'skip_check_to_write' => array(
'type' => 'bool',
'description' => 'Disable data format and integrity checks to boost up data load (insert or update)',
'default' => false,
'value' => false,
'source_of_value' => '',
'show_in_conf_sample' => false,
),
'skip_check_ext_keys' => array(
'type' => 'bool',
'description' => 'Disable external key check when checking the value of attribtutes',
'default' => false,
'value' => false,
'source_of_value' => '',
'show_in_conf_sample' => false,
),
'skip_strong_security' => array(
'type' => 'bool',
'description' => 'Disable strong security - TEMPORY: this flag should be removed when we are more confident in the recent change in security',
'default' => true,
'value' => true,
'source_of_value' => '',
'show_in_conf_sample' => false,
),
'graphviz_path' => array(
'type' => 'string',
'description' => 'Path to the Graphviz "dot" executable for graphing objects lifecycle',
'default' => '/usr/bin/dot',
'value' => '',
'source_of_value' => '',
'show_in_conf_sample' => false,
),
'session_name' => array(
'type' => 'string',
'description' => 'The name of the cookie used to store the PHP session id',
'default' => 'iTop',
'value' => '',
'source_of_value' => '',
'show_in_conf_sample' => true,
),
'max_combo_length' => array(
'type' => 'int',
'description' => 'The maximum number of elements in a drop-down list. If more then an autocomplete will be used',
'default' => 50,
'value' => 50,
'source_of_value' => '',
'show_in_conf_sample' => false,
),
'min_autocomplete_chars' => array(
'type' => 'int',
'description' => 'The minimum number of characters to type in order to trigger the "autocomplete" behavior',
'default' => 3,
'value' => 3,
'source_of_value' => '',
'show_in_conf_sample' => false,
),
'allow_target_creation' => array(
'type' => 'bool',
'description' => 'Displays the + button on external keys to create target objects',
'default' => true,
'value' => true,
'source_of_value' => '',
'show_in_conf_sample' => false,
),
// Levels that trigger a confirmation in the CSV import/synchro wizard
'csv_import_min_object_confirmation' => array(
'type' => 'integer',
'description' => 'Minimum number of objects to check for the confirmation percentages',
'default' => 3,
'value' => 3,
'source_of_value' => '',
'show_in_conf_sample' => false,
),
'csv_import_errors_percentage' => array(
'type' => 'integer',
'description' => 'Percentage of errors that trigger a confirmation in the CSV import',
'default' => 50,
'value' => 50,
'source_of_value' => '',
'show_in_conf_sample' => false,
),
'csv_import_modifications_percentage' => array(
'type' => 'integer',
'description' => 'Percentage of modifications that trigger a confirmation in the CSV import',
'default' => 50,
'value' => 50,
'source_of_value' => '',
'show_in_conf_sample' => false,
),
'csv_import_creations_percentage' => array(
'type' => 'integer',
'description' => 'Percentage of creations that trigger a confirmation in the CSV import',
'default' => 50,
'value' => 50,
'source_of_value' => '',
'show_in_conf_sample' => false,
),
'access_mode' => array(
'type' => 'integer',
'description' => 'Combination of flags (ACCESS_USER_WRITE | ACCESS_ADMIN_WRITE, or ACCESS_FULL)',
'default' => ACCESS_FULL,
'value' => ACCESS_FULL,
'source_of_value' => '',
'show_in_conf_sample' => true,
),
'access_message' => array(
'type' => 'string',
'description' => 'Message displayed to the users when there is any access restriction',
'default' => 'iTop is temporarily frozen, please wait... (the admin team)',
'value' => '',
'source_of_value' => '',
'show_in_conf_sample' => true,
),
'online_help' => array(
'type' => 'string',
'description' => 'Hyperlink to the online-help web page',
'default' => 'http://www.combodo.com/itop-help',
'value' => '',
'source_of_value' => '',
'show_in_conf_sample' => true,
),
);
public function IsProperty($sPropCode)
{
return (array_key_exists($sPropCode, $this->m_aSettings));
}
public function Set($sPropCode, $value, $sSourceDesc = 'unknown')
{
$sType = $this->m_aSettings[$sPropCode]['type'];
switch($sType)
{
case 'bool':
$value = (bool) $value;
break;
case 'string':
$value = (string) $value;
break;
case 'integer':
$value = (integer) $value;
break;
case 'float':
$value = (float) $value;
break;
default:
throw new CoreException('Unknown type for setting', array('property' => $sPropCode, 'type' => $sType));
}
$this->m_aSettings[$sPropCode]['value'] = $value;
$this->m_aSettings[$sPropCode]['source_of_value'] = $sSourceDesc;
}
public function Get($sPropCode)
{
return $this->m_aSettings[$sPropCode]['value'];
}
// Those variables will be deprecated later, when the transition to ...Get('my_setting') will be done
protected $m_sDBHost;
protected $m_sDBUser;
protected $m_sDBPwd;
protected $m_sDBName;
protected $m_sDBSubname;
protected $m_sDBCharacterSet;
protected $m_sDBCollation;
/**
* Event log options (see LOG_... definition)
*/
// Those variables will be deprecated later, when the transition to ...Get('my_setting') will be done
protected $m_bLogGlobal;
protected $m_bLogNotification;
protected $m_bLogIssue;
protected $m_bLogWebService;
protected $m_bLogKpiDuration; // private setting
protected $m_bLogKpiMemory; // private setting
protected $m_bDebugQueries; // private setting
protected $m_bQueryCacheEnabled; // private setting
/**
* @var integer Number of elements to be displayed when there are more than m_iMaxDisplayLimit elements
@@ -54,22 +282,125 @@ class Config
*/
protected $m_iFastReloadInterval;
/**
* @var boolean Whether or not a secure connection is required for using the application.
* If set, any attempt to connect to an iTop page with http:// will be redirected
* to https://
*/
protected $m_bSecureConnectionRequired;
/**
* @var boolean Forces iTop to output hyperlinks starting with https:// even
* if the current page is not using https. This can be useful when
* the application runs behind a SSL gateway
*/
protected $m_bHttpsHyperlinks;
/**
* @var string Langage code, default if the user language is undefined
*/
protected $m_sDefaultLanguage;
/**
* @var string Type of login process allowed: form|basic|url|external
*/
protected $m_sAllowedLoginTypes;
/**
* @var string Name of the PHP variable in which external authentication information is passed by the web server
*/
protected $m_sExtAuthVariable;
/**
* @var string Encryption key used for all attributes of type "encrypted string". Can be set to a random value
* unless you want to import a database from another iTop instance, in which case you must use
* the same encryption key in order to properly decode the encrypted fields
*/
protected $m_sEncryptionKey;
/**
* @var array Additional character sets to be supported by the interactive CSV import
* 'iconv_code' => 'display name'
*/
protected $m_aCharsets;
public function __construct($sConfigFile, $bLoadConfig = true)
{
$this->m_sFile = $sConfigFile;
$this->m_aAppModules = array();
$this->m_aAppModules = array(
// Some default modules, always present can be move to an official iTop Module later if needed
'application/transaction.class.inc.php',
'application/menunode.class.inc.php',
'application/user.preferences.class.inc.php',
'application/audit.rule.class.inc.php',
// Romain - That's dirty, because those 3 classes are in fact part of the core
// but I needed those classes to be derived from cmdbAbstractObject
// (to be managed via the GUI) and this class in not really known from
// the core, PLUS I needed the includes to be there also for the setup
// to create the tables.
'core/event.class.inc.php',
'core/action.class.inc.php',
'core/trigger.class.inc.php',
);
$this->m_aDataModels = array();
$this->m_aAddons = array();
$this->m_aWebServiceCategories = array(
'webservices/webservices.basic.php',
);
$this->m_aAddons = array(
// Default AddOn, always present can be moved to an official iTop Module later if needed
'user rights' => 'addons/userrights/userrightsprofile.class.inc.php',
);
$this->m_aDictionaries = array(
// Default dictionaries, always present can be moved to an official iTop Module later if needed
'dictionaries/dictionary.itop.core.php',
'dictionaries/dictionary.itop.ui.php', // Support for English
'dictionaries/fr.dictionary.itop.ui.php', // Support for French
'dictionaries/fr.dictionary.itop.core.php', // Support for French
'dictionaries/es_cr.dictionary.itop.ui.php', // Support for Spanish (from Costa Rica)
'dictionaries/es_cr.dictionary.itop.core.php', // Support for Spanish (from Costa Rica)
'dictionaries/de.dictionary.itop.ui.php', // Support for German
'dictionaries/de.dictionary.itop.core.php', // Support for German
'dictionaries/pt_br.dictionary.itop.ui.php', // Support for Brazilian Portuguese
'dictionaries/pt_br.dictionary.itop.core.php', // Support for Brazilian Portuguese
'dictionaries/ru.dictionary.itop.ui.php', // Support for Russian
'dictionaries/ru.dictionary.itop.core.php', // Support for Russian
'dictionaries/tr.dictionary.itop.ui.php', // Support for Turkish
'dictionaries/tr.dictionary.itop.core.php', // Support for Turkish
'dictionaries/zh.dictionary.itop.ui.php', // Support for Chinese
'dictionaries/zh.dictionary.itop.core.php', // Support for Chinese
);
foreach($this->m_aSettings as $sPropCode => $aSettingInfo)
{
$this->m_aSettings[$sPropCode]['value'] = $aSettingInfo['default'];
}
$this->m_sDBHost = '';
$this->m_sDBUser = '';
$this->m_sDBPwd = '';
$this->m_sDBName = '';
$this->m_sDBSubname = '';
$this->m_sDBCharacterSet = DEFAULT_CHARACTER_SET;
$this->m_sDBCollation = DEFAULT_COLLATION;
$this->m_bLogGlobal = DEFAULT_LOG_GLOBAL;
$this->m_bLogNotification = DEFAULT_LOG_NOTIFICATION;
$this->m_bLogIssue = DEFAULT_LOG_ISSUE;
$this->m_bLogWebService = DEFAULT_LOG_WEB_SERVICE;
$this->m_bLogKPIDuration = DEFAULT_LOG_KPI_DURATION;
$this->m_bLogKPIDuration = DEFAULT_LOG_KPI_DURATION;
$this->m_iMinDisplayLimit = DEFAULT_MIN_DISPLAY_LIMIT;
$this->m_iMaxDisplayLimit = DEFAULT_MAX_DISPLAY_LIMIT;
$this->m_iStandardReloadInterval = DEFAULT_STANDARD_RELOAD_INTERVAL;
$this->m_iFastReloadInterval = DEFAULT_FAST_RELOAD_INTERVAL;
$this->m_bSecureConnectionRequired = DEFAULT_SECURE_CONNECTION_REQUIRED;
$this->m_bHttpsHyperlinks = DEFAULT_HTTPS_HYPERLINKS;
$this->m_sDefaultLanguage = 'EN US';
$this->m_sAllowedLoginTypes = DEFAULT_ALLOWED_LOGIN_TYPES;
$this->m_sExtAuthVariable = DEFAULT_EXT_AUTH_VARIABLE;
$this->m_sEncryptionKey = DEFAULT_ENCRYPTION_KEY;
$this->m_aCharsets = array();
$this->m_aModuleSettings = array();
if ($bLoadConfig)
{
$this->Load($sConfigFile);
@@ -135,11 +466,30 @@ class Config
}
if (!array_key_exists('user rights', $MyModules['addons']))
{
$MyModules['addons']['user rights'] = '../addons/userrights/userrightsnull.class.inc.php';
// Add one, by default
$MyModules['addons']['user rights'] = '/addons/userrights/userrightsnull.class.inc.php';
}
if (!array_key_exists('dictionaries', $MyModules))
{
throw new ConfigException('Missing item in configuration file', array('file' => $sConfigFile, 'expected' => '$MyModules[\'dictionaries\']'));
}
$this->m_aAppModules = $MyModules['application'];
$this->m_aDataModels = $MyModules['business'];
if (isset($MyModules['webservices']))
{
$this->m_aWebServiceCategories = $MyModules['webservices'];
}
$this->m_aAddons = $MyModules['addons'];
$this->m_aDictionaries = $MyModules['dictionaries'];
foreach($MySettings as $sPropCode => $rawvalue)
{
if ($this->IsProperty($sPropCode))
{
$value = trim($rawvalue);
$this->Set($sPropCode, $value, $sConfigFile);
}
}
$this->m_sDBHost = trim($MySettings['db_host']);
$this->m_sDBUser = trim($MySettings['db_user']);
@@ -147,42 +497,98 @@ class Config
$this->m_sDBName = trim($MySettings['db_name']);
$this->m_sDBSubname = trim($MySettings['db_subname']);
$this->m_sDBCharacterSet = isset($MySettings['db_character_set']) ? trim($MySettings['db_character_set']) : DEFAULT_CHARACTER_SET;
$this->m_sDBCollation = isset($MySettings['db_collation']) ? trim($MySettings['db_collation']) : DEFAULT_COLLATION;
$this->m_bLogGlobal = isset($MySettings['log_global']) ? (bool) trim($MySettings['log_global']) : DEFAULT_LOG_GLOBAL;
$this->m_bLogNotification = isset($MySettings['log_notification']) ? (bool) trim($MySettings['log_notification']) : DEFAULT_LOG_NOTIFICATION;
$this->m_bLogIssue = isset($MySettings['log_issue']) ? (bool) trim($MySettings['log_issue']) : DEFAULT_LOG_ISSUE;
$this->m_bLogWebService = isset($MySettings['log_web_service']) ? (bool) trim($MySettings['log_web_service']) : DEFAULT_LOG_WEB_SERVICE;
$this->m_bLogKPIDuration = isset($MySettings['log_kpi_duration']) ? (bool) trim($MySettings['log_kpi_duration']) : DEFAULT_LOG_KPI_DURATION;
$this->m_bLogKPIMemory = isset($MySettings['log_kpi_memory']) ? (bool) trim($MySettings['log_kpi_memory']) : DEFAULT_LOG_KPI_MEMORY;
$this->m_bDebugQueries = isset($MySettings['debug_queries']) ? (bool) trim($MySettings['debug_queries']) : DEFAULT_DEBUG_QUERIES;
$this->m_bQueryCacheEnabled = isset($MySettings['query_cache_enabled']) ? (bool) trim($MySettings['query_cache_enabled']) : DEFAULT_QUERY_CACHE_ENABLED;
$this->m_iMinDisplayLimit = isset($MySettings['min_display_limit']) ? trim($MySettings['min_display_limit']) : DEFAULT_MIN_DISPLAY_LIMIT;
$this->m_iMaxDisplayLimit = isset($MySettings['max_display_limit']) ? trim($MySettings['max_display_limit']) : DEFAULT_MAX_DISPLAY_LIMIT;
$this->m_iStandardReloadInterval = isset($MySettings['standard_reload_interval']) ? trim($MySettings['standard_reload_interval']) : DEFAULT_STANDARD_RELOAD_INTERVAL;
$this->m_iFastReloadInterval = isset($MySettings['fast_reload_interval']) ? trim($MySettings['fast_reload_interval']) : DEFAULT_FAST_RELOAD_INTERVAL;
$this->m_bSecureConnectionRequired = isset($MySettings['secure_connection_required']) ? (bool) trim($MySettings['secure_connection_required']) : DEFAULT_SECURE_CONNECTION_REQUIRED;
$this->m_bHttpsHyperlinks = isset($MySettings['https_hyperlinks']) ? (bool) trim($MySettings['https_hyperlinks']) : DEFAULT_HTTPS_HYPERLINKS;
$this->m_aModuleSettings = isset($MyModuleSettings) ? $MyModuleSettings : array();
$this->m_sDefaultLanguage = isset($MySettings['default_language']) ? trim($MySettings['default_language']) : 'EN US';
$this->m_sAllowedLoginTypes = isset($MySettings['allowed_login_types']) ? trim($MySettings['allowed_login_types']) : DEFAULT_ALLOWED_LOGIN_TYPES;
$this->m_sExtAuthVariable = isset($MySettings['ext_auth_variable']) ? trim($MySettings['ext_auth_variable']) : DEFAULT_EXT_AUTH_VARIABLE;
$this->m_sEncryptionKey = isset($MySettings['encryption_key']) ? trim($MySettings['encryption_key']) : DEFAULT_ENCRYPTION_KEY;
$this->m_aCharsets = isset($MySettings['csv_import_charsets']) ? $MySettings['csv_import_charsets'] : array();
}
protected function Verify()
{
foreach ($this->m_aAppModules as $sModule => $sToInclude)
// Files are verified later on, just before using them -see MetaModel::Plugin()
// (we have their final path at that point)
}
public function GetModuleSetting($sModule, $sProperty, $defaultvalue = null)
{
if (isset($this->m_aModuleSettings[$sModule][$sProperty]))
{
$this->CheckFile('application module', $sToInclude);
}
foreach ($this->m_aDataModels as $sModule => $sToInclude)
{
$this->CheckFile('business model', $sToInclude);
}
foreach ($this->m_aAddons as $sModule => $sToInclude)
{
$this->CheckFile('addon module', $sToInclude);
return $this->m_aModuleSettings[$sModule][$sProperty];
}
return $defaultvalue;
}
public function SetModuleSetting($sModule, $sProperty, $value)
{
$this->m_aModuleSettings[$sModule][$sProperty] = $value;
}
public function GetAppModules()
{
return $this->m_aAppModules;
}
public function SetAppModules($aAppModules)
{
$this->m_aAppModules = $aAppModules;
}
public function GetDataModels()
{
return $this->m_aDataModels;
}
public function SetDataModels($aDataModels)
{
$this->m_aDataModels = $aDataModels;
}
public function GetWebServiceCategories()
{
return $this->m_aWebServiceCategories;
}
public function SetWebServiceCategories($aWebServiceCategories)
{
$this->m_aWebServiceCategories = $aWebServiceCategories;
}
public function GetAddons()
{
return $this->m_aAddons;
}
public function SetAddons($aAddons)
{
$this->m_aAddons = $aAddons;
}
public function GetDictionaries()
{
return $this->m_aDictionaries;
}
public function SetDictionaries($aDictionaries)
{
$this->m_aDictionaries = $aDictionaries;
}
public function GetDBHost()
{
@@ -199,6 +605,16 @@ class Config
return $this->m_sDBSubname;
}
public function GetDBCharacterSet()
{
return $this->m_sDBCharacterSet;
}
public function GetDBCollation()
{
return $this->m_sDBCollation;
}
public function GetDBUser()
{
return $this->m_sDBUser;
@@ -209,6 +625,46 @@ class Config
return $this->m_sDBPwd;
}
public function GetLogGlobal()
{
return $this->m_bLogGlobal;
}
public function GetLogNotification()
{
return $this->m_bLogNotification;
}
public function GetLogIssue()
{
return $this->m_bLogIssue;
}
public function GetLogWebService()
{
return $this->m_bLogWebService;
}
public function GetLogKPIDuration()
{
return $this->m_bLogKPIDuration;
}
public function GetLogKPIMemory()
{
return $this->m_bLogKPIMemory;
}
public function GetDebugQueries()
{
return $this->m_bDebugQueries;
}
public function GetQueryCacheEnabled()
{
return $this->m_bQueryCacheEnabled;
}
public function GetMinDisplayLimit()
{
return $this->m_iMinDisplayLimit;
@@ -229,6 +685,41 @@ class Config
return $this->m_iFastReloadInterval;
}
public function GetSecureConnectionRequired()
{
return $this->m_bSecureConnectionRequired;
}
public function GetHttpsHyperlinks()
{
return $this->m_bHttpsHyperlinks;
}
public function GetDefaultLanguage()
{
return $this->m_sDefaultLanguage;
}
public function GetEncryptionKey()
{
return $this->m_sEncryptionKey;
}
public function GetAllowedLoginTypes()
{
return explode('|', $this->m_sAllowedLoginTypes);
}
public function GetExternalAuthenticationVariable()
{
return $this->m_sExtAuthVariable;
}
public function GetCSVImportCharsets()
{
return $this->m_aCharsets;
}
public function SetDBHost($sDBHost)
{
$this->m_sDBHost = $sDBHost;
@@ -244,6 +735,16 @@ class Config
$this->m_sDBSubname = $sDBSubName;
}
public function SetDBCharacterSet($sDBCharacterSet)
{
$this->m_sDBCharacterSet = $sDBCharacterSet;
}
public function SetDBCollation($sDBCollation)
{
$this->m_sDBCollation = $sDBCollation;
}
public function SetDBUser($sUser)
{
$this->m_sDBUser = $sUser;
@@ -254,6 +755,26 @@ class Config
$this->m_sDBPwd = $sPwd;
}
public function SetLogGlobal($iLogGlobal)
{
$this->m_iLogGlobal = $iLogGlobal;
}
public function SetLogNotification($iLogNotification)
{
$this->m_iLogNotification = $iLogNotification;
}
public function SetLogIssue($iLogIssue)
{
$this->m_iLogIssue = $iLogIssue;
}
public function SetLogWebService($iLogWebService)
{
$this->m_iLogWebService = $iLogWebService;
}
public function SetMinDisplayLimit($iMinDisplayLimit)
{
$this->m_iMinDisplayLimit = $iMinDisplayLimit;
@@ -274,11 +795,117 @@ class Config
$this->m_iFastReloadInterval = $iFastReloadInterval;
}
public function SetSecureConnectionRequired($bSecureConnectionRequired)
{
$this->m_bSecureConnectionRequired = $bSecureConnectionRequired;
}
public function SetHttpsHyperlinks($bHttpsHyperlinks)
{
$this->m_bHttpsHyperlinks = $bHttpsHyperlinks;
}
public function SetDefaultLanguage($sLanguageCode)
{
$this->m_sDefaultLanguage = $sLanguageCode;
}
public function SetAllowedLoginTypes($aAllowedLoginTypes)
{
$this->m_sAllowedLoginTypes = implode('|', $aAllowedLoginTypes);
}
public function SetExternalAuthenticationVariable($sExtAuthVariable)
{
$this->m_sExtAuthVariable = $sExtAuthVariable;
}
public function SetEncryptionKey($sKey)
{
$this->m_sEncryptionKey = $sKey;
}
public function SetCSVImportCharsets($aCharsets)
{
$this->m_aCharsets = $aCharsets;
}
public function AddCSVImportCharset($sIconvCode, $sDisplayName)
{
$this->m_aCharsets[$sIconvCode] = $sDisplayName;
}
public function FileIsWritable()
{
return is_writable($this->m_sFile);
}
public function GetLoadedFile()
{
return $this->m_sFile;
}
/**
* Render the configuration as an associative array
* @return boolean True otherwise throws an Exception
*/
public function ToArray()
{
$aSettings = array();
foreach($this->m_aSettings as $sPropCode => $aSettingInfo)
{
$aSettings[$sPropCode] = $aSettingInfo['value'];
}
$aSettings['db_host'] = $this->m_sDBHost;
$aSettings['db_user'] = $this->m_sDBUser;
$aSettings['db_pwd'] = $this->m_sDBPwd;
$aSettings['db_name'] = $this->m_sDBName;
$aSettings['db_subname'] = $this->m_sDBSubname;
$aSettings['db_character_set'] = $this->m_sDBCharacterSet;
$aSettings['db_collation'] = $this->m_sDBCollation;
$aSettings['log_global'] = $this->m_bLogGlobal;
$aSettings['log_notification'] = $this->m_bLogNotification;
$aSettings['log_issue'] = $this->m_bLogIssue;
$aSettings['log_web_service'] = $this->m_bLogWebService;
$aSettings['min_display_limit'] = $this->m_iMinDisplayLimit;
$aSettings['max_display_limit'] = $this->m_iMaxDisplayLimit;
$aSettings['standard_reload_interval'] = $this->m_iStandardReloadInterval;
$aSettings['fast_reload_interval'] = $this->m_iFastReloadInterval;
$aSettings['secure_connection_required'] = $this->m_bSecureConnectionRequired;
$aSettings['https_hyperlinks'] = $this->m_bHttpsHyperlinks;
$aSettings['default_language'] = $this->m_sDefaultLanguage;
$aSettings['allowed_login_types'] = $this->m_sAllowedLoginTypes;
$aSettings['encryption_key'] = $this->m_sEncryptionKey;
$aSettings['csv_import_charsets'] = $this->m_aCharsets;
foreach ($this->m_aModuleSettings as $sModule => $aProperties)
{
foreach ($aProperties as $sProperty => $value)
{
$aSettings['module_settings'][$sModule][$sProperty] = $value;
}
}
foreach($this->m_aAppModules as $sFile)
{
$aSettings['application_list'][] = $sFile;
}
foreach($this->m_aDataModels as $sFile)
{
$aSettings['datamodel_list'][] = $sFile;
}
foreach($this->m_aWebServiceCategories as $sFile)
{
$aSettings['webservice_list'][] = $sFile;
}
foreach($this->m_aAddons as $sKey => $sFile)
{
$aSettings['addon_list'][] = $sFile;
}
foreach($this->m_aDictionaries as $sFile)
{
$aSettings['dictionary_list'][] = $sFile;
}
return $aSettings;
}
/**
* Write the configuration to a file (php format) that can be reloaded later
* By default write to the same file that was specified when constructing the object
@@ -305,16 +932,60 @@ class Config
fwrite($hFile, "\n");
fwrite($hFile, "\$MySettings = array(\n");
foreach($this->m_aSettings as $sPropCode => $aSettingInfo)
{
if ($aSettingInfo['show_in_conf_sample'])
{
$sType = $this->m_aSettings[$sPropCode]['type'];
switch($sType)
{
case 'bool':
$sSeenAs = $aSettingInfo['value'] ? '1' : '0';
break;
default:
$sSeenAs = "'".$aSettingInfo['value']."'";
}
fwrite($hFile, "\t'$sPropCode' => $sSeenAs,\n");
}
}
fwrite($hFile, "\t'db_host' => '{$this->m_sDBHost}',\n");
fwrite($hFile, "\t'db_user' => '{$this->m_sDBUser}',\n");
fwrite($hFile, "\t'db_pwd' => '".addslashes($this->m_sDBPwd)."',\n");
fwrite($hFile, "\t'db_name' => '{$this->m_sDBName}',\n");
fwrite($hFile, "\t'db_subname' => '{$this->m_sDBSubname}',\n");
fwrite($hFile, "\t'db_character_set' => '{$this->m_sDBCharacterSet}',\n");
fwrite($hFile, "\t'db_collation' => '{$this->m_sDBCollation}',\n");
fwrite($hFile, "\n");
fwrite($hFile, "\t'log_global' => {$this->m_bLogGlobal},\n");
fwrite($hFile, "\t'log_notification' => {$this->m_bLogNotification},\n");
fwrite($hFile, "\t'log_issue' => {$this->m_bLogIssue},\n");
fwrite($hFile, "\t'log_web_service' => {$this->m_bLogWebService},\n");
fwrite($hFile, "\t'min_display_limit' => {$this->m_iMinDisplayLimit},\n");
fwrite($hFile, "\t'max_display_limit' => {$this->m_iMaxDisplayLimit},\n");
fwrite($hFile, "\t'standard_reload_interval' => {$this->m_iStandardReloadInterval},\n");
fwrite($hFile, "\t'fast_reload_interval' => {$this->m_iFastReloadInterval},\n");
fwrite($hFile, "\t'secure_connection_required' => ".($this->m_bSecureConnectionRequired ? 'true' : 'false').",\n");
fwrite($hFile, "\t'https_hyperlinks' => ".($this->m_bHttpsHyperlinks ? 'true' : 'false').",\n");
fwrite($hFile, "\t'default_language' => '{$this->m_sDefaultLanguage}',\n");
fwrite($hFile, "\t'allowed_login_types' => '{$this->m_sAllowedLoginTypes}',\n");
fwrite($hFile, "\t'encryption_key' => '{$this->m_sEncryptionKey}',\n");
$sExport = var_export($this->m_aCharsets, true);
fwrite($hFile, "\t'csv_import_charsets' => $sExport,\n");
fwrite($hFile, ");\n");
fwrite($hFile, "\n");
fwrite($hFile, "\$MyModuleSettings = array(\n");
foreach ($this->m_aModuleSettings as $sModule => $aProperties)
{
fwrite($hFile, "\t'$sModule' => array (\n");
foreach ($aProperties as $sProperty => $value)
{
$sExport = var_export($value, true);
fwrite($hFile, "\t\t'$sProperty' => $sExport,\n");
}
fwrite($hFile, "\t),\n");
}
fwrite($hFile, ");\n");
fwrite($hFile, "\n/**\n");
@@ -324,26 +995,35 @@ class Config
fwrite($hFile, " */\n");
fwrite($hFile, "\$MyModules = array(\n");
fwrite($hFile, "\t'application' => array (\n");
fwrite($hFile, "\t\t'../application/menunode.class.inc.php',\n");
fwrite($hFile, "\t\t'../application/audit.rule.class.inc.php',\n");
// Romain - That's dirty, because those 3 classes are in fact part of the core
// but I needed those classes to be derived from cmdbAbstractObject
// (to be managed via the GUI) and this class in not really known from
// the core, PLUS I needed the includes to be there also for the setup
// to create the tables.
fwrite($hFile, "\t\t'../core/event.class.inc.php',\n");
fwrite($hFile, "\t\t'../core/action.class.inc.php',\n");
fwrite($hFile, "\t\t'../core/trigger.class.inc.php',\n");
fwrite($hFile, "\t\t// to be continued...\n");
foreach($this->m_aAppModules as $sFile)
{
fwrite($hFile, "\t\t'$sFile',\n");
}
fwrite($hFile, "\t),\n");
fwrite($hFile, "\t'business' => array (\n");
fwrite($hFile, "\t\t'../business/itop.business.class.inc.php'\n");
fwrite($hFile, "\t\t// to be continued...\n");
foreach($this->m_aDataModels as $sFile)
{
fwrite($hFile, "\t\t'$sFile',\n");
}
fwrite($hFile, "\t),\n");
fwrite($hFile, "\t'webservices' => array (\n");
foreach($this->m_aWebServiceCategories as $sFile)
{
fwrite($hFile, "\t\t'$sFile',\n");
}
fwrite($hFile, "\t),\n");
fwrite($hFile, "\t'addons' => array (\n");
fwrite($hFile, "\t\t'user rights' => '../addons/userrights/userrightsprofile.class.inc.php',\n");
fwrite($hFile, "\t\t// other modules to come later\n");
fwrite($hFile, "\t)\n");
foreach($this->m_aAddons as $sKey => $sFile)
{
fwrite($hFile, "\t\t'$sKey' => '$sFile',\n");
}
fwrite($hFile, "\t),\n");
fwrite($hFile, "\t'dictionaries' => array (\n");
foreach($this->m_aDictionaries as $sFile)
{
fwrite($hFile, "\t\t'$sFile',\n");
}
fwrite($hFile, "\t),\n");
fwrite($hFile, ");\n");
fwrite($hFile, '?'.'>'); // Avoid perturbing the syntax highlighting !
return fclose($hFile);

View File

@@ -1,9 +1,29 @@
<?php
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* Exception management
*
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
class SecurityException extends CoreException
{
}
class CoreException extends Exception
{
@@ -64,10 +84,31 @@ class CoreException extends Exception
{
$this->m_aContextData[$sKey] = $value;
}
public function getIssue()
{
return $this->m_sIssue;
}
public function getImpact()
{
return $this->m_sImpact;
}
public function getContextData()
{
return $this->m_aContextData;
}
}
class CoreWarning extends CoreException
{
}
class CoreUnexpectedValue extends CoreException
{
}
class SecurityException extends CoreException
{
}
?>

View File

@@ -1,190 +1,241 @@
<?php
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* CSVParser
* CSV interpreter helper, optionaly tries to guess column mapping and the separator, check the consistency
* CSV parser
*
* @package iTopORM
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @author Denis Flaven <denisflave@free.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version 1.1.1.1 $
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
class CSVParserException extends CoreException
{
}
define('stSTARTING', 1); //grey zone: the type is undetermined
define('stRAW', 2); //building a non-qualified string
define('stQUALIFIED', 3); //building qualified string
define('stESCAPED', 4); //just encountered an escape char
define('evBLANK', 0);
define('evSEPARATOR', 1);
define('evNEWLINE', 2);
define('evTEXTQUAL', 3); // used for escaping as well
define('evOTHERCHAR', 4);
define('evEND', 5);
/**
* CSVParser
*
* @package iTopORM
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version $itopversion$
*/
class CSVParser
{
private $m_sCSVData;
private $m_sSep;
private $m_iSkip;
private $m_sTextQualifier;
public function __construct($sTxt)
{
$this->m_sCSVData = $sTxt;
}
public function SetSeparator($sSep)
public function __construct($sTxt, $sSep = ',', $sTextQualifier = '"')
{
$this->m_sCSVData = str_replace("\r\n", "\n", $sTxt);
$this->m_sSep = $sSep;
}
public function GetSeparator()
{
return $this->m_sSep;
$this->m_sTextQualifier = $sTextQualifier;
}
public function SetSkipLines($iSkip)
{
$this->m_iSkip = $iSkip;
}
public function GetSkipLines()
{
return $this->m_iSkip;
}
protected $m_sCurrCell = '';
protected $m_aCurrRow = array();
protected $m_iToSkip = 0;
protected $m_aDataSet = array();
public function GuessSeparator()
protected function __AddChar($c)
{
// Note: skip the first line anyway
$aKnownSeps = array(';', ',', "\t"); // Use double quote for special chars!!!
$aStatsBySeparator = array();
foreach ($aKnownSeps as $sSep)
$this->m_sCurrCell .= $c;
}
protected function __ClearCell()
{
$this->m_sCurrCell = '';
}
protected function __AddCell($c = null, $aFieldMap = null, $bTrimSpaces = false)
{
if ($bTrimSpaces)
{
$aStatsBySeparator[$sSep] = array();
$sCell = trim($this->m_sCurrCell);
}
foreach(explode("\n", $this->m_sCSVData) as $sLine)
else
{
$sLine = trim($sLine);
if (substr($sLine, 0, 1) == '#') continue;
if (empty($sLine)) continue;
$aLineCharsCount = count_chars($sLine, 0);
foreach ($aKnownSeps as $sSep)
$sCell = $this->m_sCurrCell;
}
if (!is_null($aFieldMap))
{
$iNextCol = count($this->m_aCurrRow);
$iNextName = $aFieldMap[$iNextCol];
$this->m_aCurrRow[$iNextName] = $sCell;
}
else
{
$this->m_aCurrRow[] = $sCell;
}
$this->m_sCurrCell = '';
}
protected function __AddRow($c = null, $aFieldMap = null, $bTrimSpaces = false)
{
$this->__AddCell($c, $aFieldMap, $bTrimSpaces);
if ($this->m_iToSkip > 0)
{
$this->m_iToSkip--;
}
elseif (count($this->m_aCurrRow) > 1)
{
$this->m_aDataSet[] = $this->m_aCurrRow;
}
elseif (count($this->m_aCurrRow) == 1)
{
// Get the unique value
$aValues = array_values($this->m_aCurrRow);
$sValue = $aValues[0];
if (strlen($sValue) > 0)
{
$aStatsBySeparator[$sSep][] = $aLineCharsCount[ord($sSep)];
$this->m_aDataSet[] = $this->m_aCurrRow;
}
}
// Default to ','
$this->SetSeparator(",");
foreach ($aKnownSeps as $sSep)
else
{
// Note: this function is NOT available :-(
// stats_variance($aStatsBySeparator[$sSep]);
$iMin = min($aStatsBySeparator[$sSep]);
$iMax = max($aStatsBySeparator[$sSep]);
if (($iMin == $iMax) && ($iMax > 0))
{
$this->SetSeparator($sSep);
break;
}
// blank line, skip silently
}
return $this->GetSeparator();
$this->m_aCurrRow = array();
}
protected function __AddCellTrimmed($c = null, $aFieldMap = null)
{
$this->__AddCell($c, $aFieldMap, true);
}
public function GuessSkipLines()
protected function __AddRowTrimmed($c = null, $aFieldMap = null)
{
// Take the FIRST -valuable- LINE ONLY
// If there is a number, then for sure this is not a header line
// Otherwise, we may consider that there is one line to skip
foreach(explode("\n", $this->m_sCSVData) as $sLine)
$this->__AddRow($c, $aFieldMap, true);
}
function ToArray($iToSkip = 1, $aFieldMap = null, $iMax = 0)
{
$aTransitions = array();
$aTransitions[stSTARTING][evBLANK] = array('', stSTARTING);
$aTransitions[stSTARTING][evSEPARATOR] = array('__AddCell', stSTARTING);
$aTransitions[stSTARTING][evNEWLINE] = array('__AddRow', stSTARTING);
$aTransitions[stSTARTING][evTEXTQUAL] = array('', stQUALIFIED);
$aTransitions[stSTARTING][evOTHERCHAR] = array('__AddChar', stRAW);
$aTransitions[stSTARTING][evEND] = array('__AddRow', stSTARTING);
$aTransitions[stRAW][evBLANK] = array('__AddChar', stRAW);
$aTransitions[stRAW][evSEPARATOR] = array('__AddCellTrimmed', stSTARTING);
$aTransitions[stRAW][evNEWLINE] = array('__AddRowTrimmed', stSTARTING);
$aTransitions[stRAW][evTEXTQUAL] = array('__AddChar', stRAW);
$aTransitions[stRAW][evOTHERCHAR] = array('__AddChar', stRAW);
$aTransitions[stRAW][evEND] = array('__AddRowTrimmed', stSTARTING);
$aTransitions[stQUALIFIED][evBLANK] = array('__AddChar', stQUALIFIED);
$aTransitions[stQUALIFIED][evSEPARATOR] = array('__AddChar', stQUALIFIED);
$aTransitions[stQUALIFIED][evNEWLINE] = array('__AddChar', stQUALIFIED);
$aTransitions[stQUALIFIED][evTEXTQUAL] = array('', stESCAPED);
$aTransitions[stQUALIFIED][evOTHERCHAR] = array('__AddChar', stQUALIFIED);
$aTransitions[stQUALIFIED][evEND] = array('__AddRow', stSTARTING);
$aTransitions[stESCAPED][evBLANK] = array('', stESCAPED);
$aTransitions[stESCAPED][evSEPARATOR] = array('__AddCell', stSTARTING);
$aTransitions[stESCAPED][evNEWLINE] = array('__AddRow', stSTARTING);
$aTransitions[stESCAPED][evTEXTQUAL] = array('__AddChar', stQUALIFIED);
$aTransitions[stESCAPED][evOTHERCHAR] = array('__AddChar', stSTARTING);
$aTransitions[stESCAPED][evEND] = array('__AddRow', stSTARTING);
// Reset parser variables
$this->m_sCurrCell = '';
$this->m_aCurrRow = array();
$this->m_iToSkip = $iToSkip;
$this->m_aDataSet = array();
$iDataLength = strlen($this->m_sCSVData);
$iState = stSTARTING;
for($i = 0; $i <= $iDataLength ; $i++)
{
$sLine = trim($sLine);
if (substr($sLine, 0, 1) == '#') continue;
if (empty($sLine)) continue;
foreach (explode($this->m_sSep, $sLine) as $value)
if ($i == $iDataLength)
{
if (is_numeric($value))
$iEvent = evEND;
}
else
{
$c = $this->m_sCSVData[$i];
if ($c == $this->m_sSep)
{
$this->SetSkipLines(0);
return 0;
$iEvent = evSEPARATOR;
}
elseif ($c == ' ')
{
$iEvent = evBLANK;
}
elseif ($c == "\t")
{
$iEvent = evBLANK;
}
elseif ($c == "\n")
{
$iEvent = evNEWLINE;
}
elseif ($c == $this->m_sTextQualifier)
{
$iEvent = evTEXTQUAL;
}
else
{
$iEvent = evOTHERCHAR;
}
}
$this->SetSkipLines(1);
return 1;
}
}
function ToArray($aFieldMap = null, $iMax = 0)
{
// $aFieldMap is an array of col_index=>col_name
// $iMax is to limit the count of rows computed
$aRes = array();
$iCount = 0;
$iSkipped = 0;
foreach(explode("\n", $this->m_sCSVData) as $sLine)
{
$sLine = trim($sLine);
if (substr($sLine, 0, 1) == '#') continue;
if (empty($sLine)) continue;
if ($iSkipped < $this->m_iSkip)
$sAction = $aTransitions[$iState][$iEvent][0];
$iState = $aTransitions[$iState][$iEvent][1];
if (!empty($sAction))
{
$iSkipped++;
continue;
$aCallSpec = array($this, $sAction);
if (is_callable($aCallSpec))
{
call_user_func($aCallSpec, $c, $aFieldMap);
}
else
{
throw new CSVParserException("CSVParser: unknown verb '$sAction'");
}
}
foreach (explode($this->m_sSep, $sLine) as $iCol=>$sValue)
{
if (is_array($aFieldMap)) $sColRef = $aFieldMap[$iCol];
else $sColRef = $iCol;
$aRes[$iCount][$sColRef] = $sValue;
}
$iCount++;
if (($iMax > 0) && ($iCount >= $iMax)) break;
$iLineCount = count($this->m_aDataSet);
if (($iMax > 0) && ($iLineCount >= $iMax)) break;
}
return $aRes;
return $this->m_aDataSet;
}
public function ListFields()
{
// Take the first valuable line
foreach(explode("\n", $this->m_sCSVData) as $sLine)
{
$sLine = trim($sLine);
if (substr($sLine, 0, 1) == '#') continue;
if (empty($sLine)) continue;
// We've got the first valuable line, that's it!
break;
}
$aRet = array();
foreach (explode($this->m_sSep, $sLine) as $iCol=>$value)
{
if ($this->m_iSkip == 0)
{
// No header to help us
$sLabel = "field $iCol";
}
else
{
$sLabel = "$value";
}
$aRet[] = $sLabel;
}
return $aRet;
$aHeader = $this->ToArray(0, null, 1);
return $aHeader[0];
}
}

View File

@@ -1,16 +1,27 @@
<?php
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* data generator
* helps the consultants in creating dummy data sets, for various test purposes (validation, usability, scalability)
*
* @package tbd
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @author Denis Flaven <denisflave@free.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version 1.1.1.1 $
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
/**
@@ -350,7 +361,7 @@ class cmdbDataGenerator
{
$oOrg = null;
$oFilter = new CMDBSearchFilter('bizOrganization');
$oFilter->AddCondition('pkey', $sId, '=');
$oFilter->AddCondition('id', $sId, '=');
$oSet = new CMDBObjectSet($oFilter);
if ($oSet->Count() > 0)
{

View File

@@ -1,30 +1,34 @@
<?php
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* ???
* the class a persistent object must be derived from
* Class dbObject: the root of persistent classes
*
* @package iTopORM
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @author Denis Flaven <denisflave@free.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version 1.1.1.1 $
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
require_once('metamodel.class.php');
/**
* A persistent object, as defined by the metamodel
*
* @package iTopORM
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version $itopversion$
*/
abstract class DBObject
{
@@ -35,16 +39,22 @@ abstract class DBObject
private $m_aCurrValues = array();
protected $m_aOrigValues = array();
private $m_bDirty = false; // The object may have incorrect external keys, then any attempt of reload must be avoided
private $m_bDirty = false; // Means: "a modification is ongoing"
// The object may have incorrect external keys, then any attempt of reload must be avoided
private $m_bCheckStatus = null; // Means: the object has been verified and is consistent with integrity rules
// if null, then the check has to be performed again to know the status
protected $m_aCheckIssues = null;
protected $m_aAsArgs = null; // The current object as a standard argument (cache)
private $m_bFullyLoaded = false; // Compound objects can be partially loaded
private $m_aLoadedAtt = array(); // Compound objects can be partially loaded, array of sAttCode
// Use the MetaModel::NewObject to build an object (do we have to force it?)
public function __construct($aRow = null)
public function __construct($aRow = null, $sClassAlias = '')
{
if (!empty($aRow))
{
$this->FromRow($aRow);
$this->FromRow($aRow, $sClassAlias);
$this->m_bFullyLoaded = $this->IsFullyLoaded();
return;
}
@@ -72,6 +82,7 @@ abstract class DBObject
}
}
// Read-only <=> Written once (archive)
public function RegisterAsDirty()
{
// While the object may be written to the DB, it is NOT possible to reload it
@@ -170,17 +181,24 @@ abstract class DBObject
$this->m_bFullyLoaded = true;
}
protected function FromRow($aRow)
protected function FromRow($aRow, $sClassAlias = '')
{
if (strlen($sClassAlias) == 0)
{
// Default to the current class
$sClassAlias = get_class($this);
}
$this->m_iKey = null;
$this->m_bIsInDB = true;
$this->m_aCurrValues = array();
$this->m_aOrigValues = array();
$this->m_aLoadedAtt = array();
$this->m_bCheckStatus = true;
// Get the key
//
$sKeyField = "id";
$sKeyField = $sClassAlias."id";
if (!array_key_exists($sKeyField, $aRow))
{
// #@# Bug ?
@@ -211,9 +229,10 @@ abstract class DBObject
// then one column will be found with an empty suffix, the others have a suffix
// Take care: the function isset will return false in case the value is null,
// which is something that could happen on open joins
if (array_key_exists($sAttCode, $aRow))
$sAttRef = $sClassAlias.$sAttCode;
if (array_key_exists($sAttRef, $aRow))
{
$value = $oAttDef->FromSQLToValue($aRow, $sAttCode);
$value = $oAttDef->FromSQLToValue($aRow, $sAttRef);
$this->m_aCurrValues[$sAttCode] = $value;
$this->m_aOrigValues[$sAttCode] = $value;
@@ -233,13 +252,8 @@ abstract class DBObject
if ($sAttCode == 'finalclass')
{
// Ignore it - this attribute is set upon object creation and that's it
//throw new CoreWarning('Attempting to set the value for the internal attribute \"finalclass\"', array('current value'=>$this->Get('finalclass'), 'new value'=>$value));
return;
}
if (!array_key_exists($sAttCode, MetaModel::ListAttributeDefs(get_class($this))))
{
throw new CoreException("Unknown attribute code '$sAttCode' for the class ".get_class($this));
}
$oAttDef = MetaModel::GetAttributeDef(get_class($this), $sAttCode);
if ($this->m_bIsInDB && !$this->m_bFullyLoaded && !$this->m_bDirty)
{
@@ -248,12 +262,7 @@ abstract class DBObject
// + consistency does not make sense !
$this->Reload();
}
if($oAttDef->IsScalar() && !$oAttDef->IsNullAllowed() && is_null($value))
{
throw new CoreWarning("null not allowed for attribute '$sAttCode', setting default value");
$this->m_aCurrValues[$sAttCode] = $oAttDef->GetDefaultValue();
return;
}
if ($oAttDef->IsExternalKey() && is_object($value))
{
// Setting an external key with a whole object (instead of just an ID)
@@ -261,11 +270,14 @@ abstract class DBObject
// (useful when building objects in memory and not from a query)
if ( (get_class($value) != $oAttDef->GetTargetClass()) && (!is_subclass_of($value, $oAttDef->GetTargetClass())))
{
throw new CoreWarning("Trying to set the value of '$sAttCode', to an object of class '".get_class($value)."', whereas it's an ExtKey to '".$oAttDef->GetTargetClass()."'. Ignored");
$this->m_aCurrValues[$sAttCode] = $oAttDef->GetDefaultValue();
throw new CoreUnexpectedValue("Trying to set the value of '$sAttCode', to an object of class '".get_class($value)."', whereas it's an ExtKey to '".$oAttDef->GetTargetClass()."'. Ignored");
}
else
{
// The object has changed, reset caches
$this->m_bCheckStatus = null;
$this->m_aAsArgs = null;
$this->m_aCurrValues[$sAttCode] = $value->GetKey();
foreach(MetaModel::ListAttributeDefs(get_class($this)) as $sCode => $oDef)
{
@@ -279,17 +291,13 @@ abstract class DBObject
}
if(!$oAttDef->IsScalar() && !is_object($value))
{
throw new CoreWarning("scalar not allowed for attribute '$sAttCode', setting default value (empty list)");
$this->m_aCurrValues[$sAttCode] = $oAttDef->GetDefaultValue();
return;
throw new CoreUnexpectedValue("scalar not allowed for attribute '$sAttCode', setting default value (empty list)");
}
if($oAttDef->IsLinkSet())
{
if((get_class($value) != 'DBObjectSet') && !is_subclass_of($value, 'DBObjectSet'))
{
throw new CoreWarning("expecting a set of persistent objects (found a '".get_class($value)."'), setting default value (empty list)");
$this->m_aCurrValues[$sAttCode] = $oAttDef->GetDefaultValue();
return;
throw new CoreUnexpectedValue("expecting a set of persistent objects (found a '".get_class($value)."'), setting default value (empty list)");
}
$oObjectSet = $value;
@@ -298,15 +306,21 @@ abstract class DBObject
// not working fine :-( if (!is_subclass_of($sSetClass, $sLinkClass))
if ($sSetClass != $sLinkClass)
{
throw new CoreWarning("expecting a set of '$sLinkClass' objects (found a set of '$sSetClass'), setting default value (empty list)");
$this->m_aCurrValues[$sAttCode] = $oAttDef->GetDefaultValue();
return;
throw new CoreUnexpectedValue("expecting a set of '$sLinkClass' objects (found a set of '$sSetClass'), setting default value (empty list)");
}
}
$this->m_aCurrValues[$sAttCode] = $oAttDef->MakeRealValue($value);
$this->RegisterAsDirty(); // Make sure we do not reload it anymore... before saving it
$realvalue = $oAttDef->MakeRealValue($value);
$this->m_aCurrValues[$sAttCode] = $realvalue;
// The object has changed, reset caches
$this->m_bCheckStatus = null;
$this->m_aAsArgs = null;
// Make sure we do not reload it anymore... before saving it
$this->RegisterAsDirty();
}
public function Get($sAttCode)
{
if (!array_key_exists($sAttCode, MetaModel::ListAttributeDefs(get_class($this))))
@@ -315,10 +329,9 @@ abstract class DBObject
}
if ($this->m_bIsInDB && !$this->m_aLoadedAtt[$sAttCode] && !$this->m_bDirty)
{
// #@# non-scalar attributes.... handle that differentely
// #@# non-scalar attributes.... handle that differently
$this->Reload();
}
$this->ComputeFields();
return $this->m_aCurrValues[$sAttCode];
}
@@ -331,7 +344,30 @@ abstract class DBObject
return $this->m_aOrigValues[$sAttCode];
}
public function ComputeFields()
/**
* Updates the value of an external field by (re)loading the object
* corresponding to the external key and getting the value from it
* @param string $sAttCode Attribute code of the external field to update
* @return void
*/
protected function UpdateExternalField($sAttCode)
{
$oAttDef = MetaModel::GetAttributeDef(get_class($this), $sAttCode);
if ($oAttDef->IsExternalField())
{
$sTargetClass = $oAttDef->GetTargetClass();
$objkey = $this->Get($oAttDef->GetKeyAttCode());
$oObj = MetaModel::GetObject($sTargetClass, $objkey);
if (is_object($oObj))
{
$value = $oObj->Get($oAttDef->GetExtAttCode());
$this->Set($sAttCode, $value);
}
}
}
// Compute scalar attributes that depend on any other type of attribute
public function DoComputeValues()
{
if (is_callable(array($this, 'ComputeValues')))
{
@@ -364,7 +400,8 @@ abstract class DBObject
$aAvailableFields = array();
foreach ($aExtKeyFriends as $sDispAttCode => $oExtField)
{
$aAvailableFields[$oExtField->GetExtAttCode()] = $oExtField->GetAsHTML($this->Get($oExtField->GetCode()));
// $aAvailableFields[$oExtField->GetExtAttCode()] = $oExtField->GetAsHTML($this->Get($oExtField->GetCode()));
$aAvailableFields[$oExtField->GetExtAttCode()] = $this->Get($oExtField->GetCode());
}
$sTargetClass = $oAtt->GetTargetClass(EXTKEY_ABSOLUTE);
@@ -375,16 +412,67 @@ abstract class DBObject
return $oAtt->GetAsHTML($this->Get($sAttCode));
}
public function GetEditValue($sAttCode)
{
$sClass = get_class($this);
$oAtt = MetaModel::GetAttributeDef($sClass, $sAttCode);
if ($oAtt->IsExternalKey())
{
$sTargetClass = $oAtt->GetTargetClass();
if ($this->IsNew())
{
// The current object exists only in memory, don't try to query it in the DB !
// instead let's query for the object pointed by the external key, and get its name
$targetObjId = $this->Get($sAttCode);
$oTargetObj = MetaModel::GetObject($sTargetClass, $targetObjId, false); // false => not sure it exists
if (is_object($oTargetObj))
{
$sEditValue = $oTargetObj->GetName();
}
else
{
$sEditValue = 0;
}
}
else
{
$aAvailableFields = array();
// retrieve the "external fields" linked to this external key
foreach (MetaModel::GetExternalFields(get_class($this), $sAttCode) as $oExtField)
{
$aAvailableFields[$oExtField->GetExtAttCode()] = $oExtField->GetAsHTML($this->Get($oExtField->GetCode()));
}
// Use the "name" of the target class as the label of the hyperlink
// unless it's not available in the external fields...
$sExtClassNameAtt = MetaModel::GetNameAttributeCode($sTargetClass);
if (isset($aAvailableFields[$sExtClassNameAtt]))
{
$sEditValue = $aAvailableFields[$sExtClassNameAtt];
}
else
{
$sEditValue = implode(' / ', $aAvailableFields);
}
}
}
else
{
$sEditValue = $oAtt->GetEditValue($this->Get($sAttCode));
}
return $sEditValue;
}
public function GetAsXML($sAttCode)
{
$oAtt = MetaModel::GetAttributeDef(get_class($this), $sAttCode);
return $oAtt->GetAsXML($this->Get($sAttCode));
}
public function GetAsCSV($sAttCode, $sSeparator = ';', $sSepEscape = ',')
public function GetAsCSV($sAttCode, $sSeparator = ',', $sTextQualifier = '"')
{
$oAtt = MetaModel::GetAttributeDef(get_class($this), $sAttCode);
return $oAtt->GetAsCSV($this->Get($sAttCode), $sSeparator, $sSepEscape);
return $oAtt->GetAsCSV($this->Get($sAttCode), $sSeparator, $sTextQualifier);
}
protected static function MakeHyperLink($sObjClass, $sObjKey, $aAvailableFields)
@@ -424,6 +512,15 @@ abstract class DBObject
}
$this->m_iKey = $iNewKey;
}
/**
* Get the icon representing this object
* @param boolean $bImgTag If true the result is a full IMG tag (or an emtpy string if no icon is defined)
* @return string Either the full IMG tag ($bImgTag == true) or just the path to the icon file
*/
public function GetIcon($bImgTag = true)
{
return MetaModel::GetClassIcon(get_class($this), $bImgTag);
}
public function GetName()
{
@@ -447,11 +544,37 @@ abstract class DBObject
}
else
{
$aStates = MetaModel::EnumStates(get_class($this));
return $aStates[$this->Get($sStateAttCode)]['label'];
return $this->Get($sStateAttCode);
}
}
public function GetStateLabel()
{
$sStateAttCode = MetaModel::GetStateAttributeCode(get_class($this));
if (empty($sStateAttCode))
{
return '';
}
else
{
$sStateValue = $this->Get($sStateAttCode);
return MetaModel::GetStateLabel(get_class($this), $sStateValue);
}
}
public function GetStateDescription()
{
$sStateAttCode = MetaModel::GetStateAttributeCode(get_class($this));
if (empty($sStateAttCode))
{
return '';
}
else
{
$sStateValue = $this->Get($sStateAttCode);
return MetaModel::GetStateDescription(get_class($this), $sStateValue);
}
}
/**
* Returns the set of flags (OPT_ATT_HIDDEN, OPT_ATT_READONLY, OPT_ATT_MANDATORY...)
* for the given attribute in the current state of the object
@@ -470,6 +593,8 @@ abstract class DBObject
}
// check if the given (or current) value is suitable for the attribute
// return true if successfull
// return the error desciption otherwise
public function CheckValue($sAttCode, $value = null)
{
if (!is_null($value))
@@ -482,31 +607,55 @@ abstract class DBObject
}
$oAtt = MetaModel::GetAttributeDef(get_class($this), $sAttCode);
if ($oAtt->IsExternalKey())
if (!$oAtt->IsWritable())
{
if (!$oAtt->IsNullAllowed() || ($toCheck != 0) )
return true;
}
elseif ($oAtt->IsNull($toCheck))
{
if ($oAtt->IsNullAllowed())
{
try
return true;
}
else
{
return "Null not allowed";
}
}
elseif ($oAtt->IsExternalKey())
{
if (!MetaModel::SkipCheckExtKeys())
{
$sTargetClass = $oAtt->GetTargetClass();
$oTargetObj = MetaModel::GetObject($sTargetClass, $toCheck, false /*must be found*/, true /*allow all data*/);
if (is_null($oTargetObj))
{
$oTargetObj = MetaModel::GetObject($oAtt->GetTargetClass(), $toCheck);
return true;
}
catch (CoreException $e)
{
return false;
return "Target object not found ($sTargetClass::$toCheck)";
}
}
}
elseif ($oAtt->IsWritable() && $oAtt->IsScalar())
elseif ($oAtt->IsScalar())
{
$aValues = $oAtt->GetAllowedValues();
$aValues = $oAtt->GetAllowedValues($this->ToArgs());
if (count($aValues) > 0)
{
if (!array_key_exists($toCheck, $aValues))
{
return false;
return "Value not allowed [$toCheck]";
}
}
if (!is_null($iMaxSize = $oAtt->GetMaxSize()))
{
$iLen = strlen($toCheck);
if ($iLen > $iMaxSize)
{
return "String too long (found $iLen, limited to $iMaxSize)";
}
}
if (!$oAtt->CheckFormat($toCheck))
{
return "Wrong format [$toCheck]";
}
}
return true;
}
@@ -517,45 +666,60 @@ abstract class DBObject
return true;
}
// check if it is allowed to record the new object into the database
// check integrity rules (before inserting or updating the object)
// a displayable error is returned
// Note: checks the values and consistency
public function CheckToInsert()
public function DoCheckToWrite()
{
$aIssues = array();
$this->DoComputeValues();
$this->m_aCheckIssues = array();
foreach(MetaModel::ListAttributeDefs(get_class($this)) as $sAttCode=>$oAttDef)
{
if (!$this->CheckValue($sAttCode))
$res = $this->CheckValue($sAttCode);
if ($res !== true)
{
$aIssues[$sAttCode] = array(
'issue' => 'unexpected value'
);
// $res contains the error description
$this->m_aCheckIssues[] = "Unexpected value for attribute '$sAttCode': $res";
}
}
if (count($aIssues) > 0)
if (count($this->m_aCheckIssues) > 0)
{
return array(false, $aIssues);
// No need to check consistency between attributes if any of them has
// an unexpected value
return;
}
if (!$this->CheckConsistency())
$res = $this->CheckConsistency();
if ($res !== true)
{
return array(false, $aIssues);
// $res contains the error description
$this->m_aCheckIssues[] = "Consistency rules not followed: $res";
}
return array(true, $aIssues);
}
// check if it is allowed to update the existing object into the database
// a displayable error is returned
// Note: checks the values and consistency
public function CheckToUpdate()
final public function CheckToWrite()
{
foreach(MetaModel::ListAttributeDefs(get_class($this)) as $sAttCode=>$oAttDef)
if (MetaModel::SkipCheckToWrite())
{
if (!$this->CheckValue($sAttCode)) return false;
return array(true, array());
}
if (!$this->CheckConsistency()) return false;
return true;
if (is_null($this->m_bCheckStatus))
{
$oKPI = new ExecutionKPI();
$this->DoCheckToWrite();
$oKPI->ComputeStats('CheckToWrite', get_class($this));
if (count($this->m_aCheckIssues) == 0)
{
$this->m_bCheckStatus = true;
}
else
{
$this->m_bCheckStatus = false;
}
}
return array($this->m_bCheckStatus, $this->m_aCheckIssues);
}
// check if it is allowed to delete the existing object from the database
// a displayable error is returned
public function CheckToDelete()
@@ -568,10 +732,32 @@ abstract class DBObject
$aDelta = array();
foreach ($aProposal as $sAtt => $proposedValue)
{
if (!array_key_exists($sAtt, $this->m_aOrigValues) || ($this->m_aOrigValues[$sAtt] != $proposedValue))
if (!array_key_exists($sAtt, $this->m_aOrigValues))
{
// The value was not set
$aDelta[$sAtt] = $proposedValue;
}
elseif(is_object($proposedValue))
{
// The value is an object, the comparison is not strict
// #@# todo - should be even less strict => add verb on AttributeDefinition: Compare($a, $b)
if ($this->m_aOrigValues[$sAtt] != $proposedValue)
{
$aDelta[$sAtt] = $proposedValue;
}
}
else
{
// The value is a scalar, the comparison must be 100% strict
if($this->m_aOrigValues[$sAtt] !== $proposedValue)
{
//echo "$sAtt:<pre>\n";
//var_dump($this->m_aOrigValues[$sAtt]);
//var_dump($proposedValue);
//echo "</pre>\n";
$aDelta[$sAtt] = $proposedValue;
}
}
}
return $aDelta;
}
@@ -615,10 +801,14 @@ abstract class DBObject
{
$aOriginalList = $oOriginalSet->ToArray();
$aNewSet = $oLinks->ToArray();
$aToDelete = array_diff($aOriginalList, $aNewSet);
foreach ($aToDelete as $iKey => $oObject)
foreach($aOriginalList as $iId => $oObject)
{
$oObject->DBDelete();
if (!array_key_exists($iId, $aNewSet))
{
// It disappeared from the list
$oObject->DBDelete();
}
}
}
}
@@ -626,6 +816,10 @@ abstract class DBObject
private function DBInsertSingleTable($sTableClass)
{
$sTable = MetaModel::DBGetTable($sTableClass);
// Abstract classes or classes having no specific attribute do not have an associated table
if ($sTable == '') return;
$sClass = get_class($this);
// fields in first array, values in the second
@@ -653,10 +847,16 @@ abstract class DBObject
if (count($aValuesToWrite) == 0) return false;
$sTable = MetaModel::DBGetTable($sTableClass);
$sInsertSQL = "INSERT INTO $sTable (".join(",", $aFieldsToWrite).") VALUES (".join(", ", $aValuesToWrite).")";
$sInsertSQL = "INSERT INTO `$sTable` (".join(",", $aFieldsToWrite).") VALUES (".join(", ", $aValuesToWrite).")";
$iNewKey = CMDBSource::InsertInto($sInsertSQL);
if (MetaModel::DBIsReadOnly())
{
$iNewKey = -1;
}
else
{
$iNewKey = CMDBSource::InsertInto($sInsertSQL);
}
// Note that it is possible to have a key defined here, and the autoincrement expected, this is acceptable in a non root class
if (empty($this->m_iKey))
{
@@ -665,7 +865,7 @@ abstract class DBObject
}
return $this->m_iKey;
}
// Insert of record for the new object into the database
// Returns the key of the newly created object
public function DBInsertNoReload()
@@ -679,7 +879,8 @@ abstract class DBObject
$sRootClass = MetaModel::GetRootClass($sClass);
// Ensure the update of the values (we are accessing the data directly)
$this->ComputeFields();
$this->DoComputeValues();
$this->OnInsert();
if ($this->m_iKey < 0)
{
@@ -692,10 +893,17 @@ abstract class DBObject
{
if (empty($this->m_iKey))
{
throw new CoreWarning("Missing key for the object to write - This class is supposed to have a user defined key, not an autonumber");
throw new CoreWarning("Missing key for the object to write - This class is supposed to have a user defined key, not an autonumber", array('class' => $sRootClass));
}
}
// Ultimate check - ensure DB integrity
list($bRes, $aIssues) = $this->CheckToWrite();
if (!$bRes)
{
throw new CoreException("Object not following integrity rules - it will not be written into the DB", array('class' => $sClass, 'id' => $this->GetKey(), 'issues' => $aIssues));
}
// First query built upon on the root class, because the ID must be created first
$this->m_iKey = $this->DBInsertSingleTable($sRootClass);
@@ -709,12 +917,17 @@ abstract class DBObject
foreach(MetaModel::EnumParentClasses($sClass) as $sParentClass)
{
if ($sParentClass == $sRootClass) continue;
if (MetaModel::DBGetTable($sParentClass) == "") continue;
$this->DBInsertSingleTable($sParentClass);
}
$this->DBWriteLinks();
$this->m_bIsInDB = true;
$this->m_bDirty = false;
// Arg cache invalidated (in particular, it needs the object key -could be improved later)
$this->m_aAsArgs = null;
$this->AfterInsert();
// Activate any existing trigger
$sClass = get_class($this);
@@ -733,10 +946,14 @@ abstract class DBObject
public function DBInsert()
{
$this->DBInsertNoReload();
$this->m_bDirty = false;
$this->Reload();
return $this->m_iKey;
}
public function DBInsertTracked(CMDBChange $oVoid)
{
return $this->DBInsert();
}
// Creates a copy of the current object into the database
// Returns the id of the newly created object
@@ -746,6 +963,18 @@ abstract class DBObject
$this->m_iKey = $iNewKey;
return $this->DBInsert();
}
/**
* This function is automatically called after cloning an object with the "clone" PHP language construct
* The purpose of this method is to reset the appropriate attributes of the object in
* order to make sure that the newly cloned object is really distinct from its clone
*/
public function __clone()
{
$this->m_bIsInDB = false;
$this->m_bDirty = true;
$this->m_iKey = self::GetNextTempId(get_class($this));
}
// Update a record
public function DBUpdate()
@@ -754,12 +983,24 @@ abstract class DBObject
{
throw new CoreException("DBUpdate: could not update a newly created object, please call DBInsert instead");
}
$this->DoComputeValues();
$this->OnUpdate();
$aChanges = $this->ListChanges();
if (count($aChanges) == 0)
{
throw new CoreWarning("Attempting to update an unchanged object");
//throw new CoreWarning("Attempting to update an unchanged object");
return;
}
// Ultimate check - ensure DB integrity
list($bRes, $aIssues) = $this->CheckToWrite();
if (!$bRes)
{
throw new CoreException("Object not following integrity rules - it will not be written into the DB", array('class' => get_class($this), 'id' => $this->GetKey(), 'issues' => $aIssues));
}
$bHasANewExternalKeyValue = false;
foreach($aChanges as $sAttCode => $valuecurr)
{
@@ -775,12 +1016,17 @@ abstract class DBObject
$oFilter->AddCondition('id', $this->m_iKey, '=');
$sSQL = MetaModel::MakeUpdateQuery($oFilter, $aChanges);
CMDBSource::Query($sSQL);
if (!MetaModel::DBIsReadOnly())
{
CMDBSource::Query($sSQL);
}
}
$this->DBWriteLinks();
$this->m_bDirty = false;
$this->AfterUpdate();
// Reload to get the external attributes
if ($bHasANewExternalKeyValue)
{
@@ -789,6 +1035,11 @@ abstract class DBObject
return $this->m_iKey;
}
public function DBUpdateTracked(CMDBChange $oVoid)
{
return $this->DBUpdate();
}
// Make the current changes persistent - clever wrapper for Insert or Update
public function DBWrite()
@@ -802,20 +1053,32 @@ abstract class DBObject
return $this->DBInsert();
}
}
// Delete a record
public function DBDelete()
{
$oFilter = new DBObjectSearch(get_class($this));
$oFilter->AddCondition('id', $this->m_iKey, '=');
$this->OnDelete();
$sSQL = MetaModel::MakeDeleteQuery($oFilter);
CMDBSource::Query($sSQL);
if (!MetaModel::DBIsReadOnly())
{
CMDBSource::Query($sSQL);
}
$this->AfterDelete();
$this->m_bIsInDB = false;
$this->m_iKey = null;
}
public function DBDeleteTracked(CMDBChange $oVoid)
{
$this->DBDelete();
}
public function EnumTransitions()
{
$sStateAttCode = MetaModel::GetStateAttributeCode(get_class($this));
@@ -862,13 +1125,14 @@ abstract class DBObject
// Change state triggers...
$sClass = get_class($this);
$oSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT TriggerOnStateLeave AS t WHERE t.target_class='$sClass' AND t.state='$sPreviousState'"));
$sClassList = implode("', '", MetaModel::EnumParentClasses($sClass, ENUM_PARENT_CLASSES_ALL));
$oSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT TriggerOnStateLeave AS t WHERE t.target_class IN ('$sClassList') AND t.state='$sPreviousState'"));
while ($oTrigger = $oSet->Fetch())
{
$oTrigger->DoActivate($this->ToArgs('this'));
}
$oSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT TriggerOnStateEnter AS t WHERE t.target_class='$sClass' AND t.state='$sNewState'"));
$oSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT TriggerOnStateEnter AS t WHERE t.target_class IN ('$sClassList') AND t.state='$sNewState'"));
while ($oTrigger = $oSet->Fetch())
{
$oTrigger->DoActivate($this->ToArgs('this'));
@@ -878,22 +1142,72 @@ abstract class DBObject
}
// Make standard context arguments
public function ToArgs($sArgName)
// Note: Needs to be reviewed because it is currently called once per attribute when an object is written (CheckToWrite / CheckValue)
// Several options here:
// 1) cache the result
// 2) set only the object ref and resolve the values iif needed from contextual templates and queries (easy for the queries, not for the templates)
public function ToArgs($sArgName = 'this')
{
$aScalarArgs = array();
$aScalarArgs[$sArgName] = $this->GetKey();
$aScalarArgs[$sArgName.'->id'] = $this->GetKey();
$aScalarArgs[$sArgName.'->hyperlink()'] = $this->GetHyperlink();
$aScalarArgs[$sArgName.'->name()'] = $this->GetName();
$sClass = get_class($this);
foreach(MetaModel::ListAttributeDefs($sClass) as $sAttCode => $oAttDef)
if (is_null($this->m_aAsArgs))
{
$aScalarArgs[$sArgName.'->'.$sAttCode] = $this->Get($sAttCode);
$oKPI = new ExecutionKPI();
$aScalarArgs = array();
$aScalarArgs[$sArgName] = $this->GetKey();
$aScalarArgs[$sArgName.'->id'] = $this->GetKey();
$aScalarArgs[$sArgName.'->object()'] = $this;
$aScalarArgs[$sArgName.'->hyperlink()'] = $this->GetHyperlink();
// #@# Prototype for a user portal - to be dehardcoded later
$sToPortal = utils::GetAbsoluteUrlPath().'../portal/index.php?operation=details&id='.$this->GetKey();
$aScalarArgs[$sArgName.'->hyperlink(portal)'] = '<a href="'.$sToPortal.'">'.$this->GetName().'</a>';
$aScalarArgs[$sArgName.'->name()'] = $this->GetName();
$sClass = get_class($this);
foreach(MetaModel::ListAttributeDefs($sClass) as $sAttCode => $oAttDef)
{
$aScalarArgs[$sArgName.'->'.$sAttCode] = $this->Get($sAttCode);
if ($oAttDef->IsScalar())
{
// #@# Note: This has been proven to be quite slow, this can slow down bulk load
$sAsHtml = $this->GetAsHtml($sAttCode);
$aScalarArgs[$sArgName.'->html('.$sAttCode.')'] = $sAsHtml;
$aScalarArgs[$sArgName.'->label('.$sAttCode.')'] = strip_tags($sAsHtml);
}
}
$this->m_aAsArgs = $aScalarArgs;
$oKPI->ComputeStats('ToArgs', get_class($this));
}
return $aScalarArgs;
return $this->m_aAsArgs;
}
// To be optionaly overloaded
protected function OnInsert()
{
}
// To be optionaly overloaded
protected function AfterInsert()
{
}
// To be optionaly overloaded
protected function OnUpdate()
{
}
// To be optionaly overloaded
protected function AfterUpdate()
{
}
// To be optionaly overloaded
protected function OnDelete()
{
}
// To be optionaly overloaded
protected function AfterDelete()
{
}
// Return an empty set for the parent of all
public static function GetRelationQueries($sRelCode)
@@ -912,8 +1226,8 @@ abstract class DBObject
$iDepth = $bPropagate ? $iMaxDepth - 1 : 0;
$oFlt = DBObjectSearch::FromSibusQL($sQuery, array(), $this);
$oObjSet = new DBObjectSet($oFlt);
$oFlt = DBObjectSearch::FromOQL($sQuery);
$oObjSet = new DBObjectSet($oFlt, array(), $this->ToArgs());
while ($oObj = $oObjSet->Fetch())
{
$sRootClass = MetaModel::GetRootClass(get_class($oObj));
@@ -948,7 +1262,7 @@ abstract class DBObject
if (!$oExtKeyAttDef->IsExternalKey(EXTKEY_ABSOLUTE)) continue;
$oSearch = new DBObjectSearch($sRemoteClass);
$oSearch->AddCondition($sExtKeyAttCode, $this->GetKey());
$oSearch->AddCondition($sExtKeyAttCode, $this->GetKey(), '=');
$oSet = new CMDBObjectSet($oSearch);
if ($oSet->Count() > 0)
{
@@ -962,11 +1276,22 @@ abstract class DBObject
return $aDependentObjects;
}
public function GetDeletionScheme()
/**
* $aDeletedObjs = array(); // [class][key] => structure
* $aResetedObjs = array(); // [class][key] => object
*/
public function GetDeletionScheme(&$aDeletedObjs, &$aResetedObjs, $aVisited = array())
{
if (array_key_exists(get_class($this), $aVisited))
{
if (in_array($this->GetKey(), $aVisited[get_class($this)]))
{
return;
}
}
$aVisited[get_class($this)] = $this->GetKey();
$aDependentObjects = $this->GetReferencingObjects();
$aDeletedObjs = array(); // [class][key] => structure
$aResetedObjs = array(); // [class][key] => object
foreach ($aDependentObjects as $sRemoteClass => $aPotentialDeletes)
{
foreach ($aPotentialDeletes as $sRemoteExtKey => $aData)
@@ -1009,13 +1334,17 @@ abstract class DBObject
// First time we find the given object in the list
// (and most likely case is that no other occurence will be found)
$aDeletedObjs[$sRemoteClass][$iId]['to_delete'] = $oDependentObj;
$aDeletedObjs[$sRemoteClass][$iId]['auto_delete'] = ($iDeletePropagationOption == DEL_AUTO);
$aDeletedObjs[$sRemoteClass][$iId]['auto_delete'] = ($iDeletePropagationOption == DEL_AUTO);
// Recursively inspect this object
if ($iDeletePropagationOption == DEL_AUTO)
{
$oDependentObj->GetDeletionScheme($aDeletedObjs, $aResetedObjs, $aVisited);
}
}
}
}
}
}
return array($aDeletedObjs, $aResetedObjs);
}
}

View File

@@ -1,51 +1,32 @@
<?php
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* Define filters for a given class of objects (formerly named "filter")
*
* @package iTopORM
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @author Denis Flaven <denisflave@free.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version 1.1.1.1 $
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
/**
* Sibusql - value set start
* @package iTopORM
*/
define('VS_START', '{');
/**
* Sibusql - value set end
* @package iTopORM
*/
define('VS_END', '}');
define('SIBUSQLPARAMREGEXP', "/\\$\\[(.*)\\:(.*)\\:(.*)\\]/U");
define('SIBUSQLTHISREGEXP', "/this\\.(.*)/U");
/**
* Define filters for a given class of objects (formerly named "filter")
*
* @package iTopORM
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @author Denis Flaven <denisflave@free.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @mytagrom youpi
* @since 1.0
* @version 1.1.1.1 $
*/
class DBObjectSearch
{
private $m_sClass;
private $m_sClassAlias;
private $m_aClasses; // queried classes (alias => class name)
private $m_aClasses; // queried classes (alias => class name), the first item is the class corresponding to this filter (the rest is coming from subfilters)
private $m_aSelectedClasses; // selected for the output (alias => class name)
private $m_oSearchCondition;
private $m_aParams;
private $m_aFullText;
@@ -53,15 +34,18 @@ class DBObjectSearch
private $m_aReferencedBy;
private $m_aRelatedTo;
public function __construct($sClass, $sClassAlias = '')
// By default, some information may be hidden to the current user
// But it may happen that we need to disable that feature
private $m_bAllowAllData = false;
public function __construct($sClass, $sClassAlias = null)
{
if (empty($sClassAlias)) $sClassAlias = $sClass;
if (is_null($sClassAlias)) $sClassAlias = $sClass;
assert('is_string($sClass)');
assert('MetaModel::IsValidClass($sClass)'); // #@# could do better than an assert, or at least give the caller's reference
// => idee d'un assert avec call stack (autre utilisation = echec sur query SQL)
if (empty($sClassAlias)) $sClassAlias = $sClass;
$this->m_sClass = $sClass;
$this->m_sClassAlias = $sClassAlias;
$this->m_aSelectedClasses = array($sClassAlias => $sClass);
$this->m_aClasses = array($sClassAlias => $sClass);
$this->m_oSearchCondition = new TrueExpression;
$this->m_aParams = array();
@@ -71,6 +55,51 @@ class DBObjectSearch
$this->m_aRelatedTo = array();
}
public function AllowAllData() {$this->m_bAllowAllData = true;}
public function IsAllDataAllowed() {return $this->m_bAllowAllData;}
public function GetClassName($sAlias) {return $this->m_aClasses[$sAlias];}
public function GetJoinedClasses() {return $this->m_aClasses;}
public function GetClass()
{
return reset($this->m_aSelectedClasses);
}
public function GetClassAlias()
{
reset($this->m_aSelectedClasses);
return key($this->m_aSelectedClasses);
}
public function GetFirstJoinedClass()
{
return reset($this->m_aClasses);
}
public function GetFirstJoinedClassAlias()
{
reset($this->m_aClasses);
return key($this->m_aClasses);
}
public function SetSelectedClasses($aNewSet)
{
$this->m_aSelectedClasses = array();
foreach ($aNewSet as $sAlias => $sClass)
{
if (!array_key_exists($sAlias, $this->m_aClasses))
{
throw new CoreException('Unexpected class alias', array('alias'=>$sAlias, 'expected'=>$this->m_aClasses));
}
$this->m_aSelectedClasses[$sAlias] = $sClass;
}
}
public function GetSelectedClasses()
{
return $this->m_aSelectedClasses;
}
public function IsAny()
{
// #@# todo - if (!$this->m_oSearchCondition->IsTrue()) return false;
@@ -173,9 +202,9 @@ class DBObjectSearch
}
if (!empty($sConditionDesc))
{
return "Objects of class '$this->m_sClass', $sConditionDesc";
return "Objects of class '".$this->GetClass()."', $sConditionDesc";
}
return "Any object of class '$this->m_sClass'";
return "Any object of class '".$this->GetClass()."'";
}
protected function TransferConditionExpression($oFilter, $aTranslation)
@@ -190,7 +219,6 @@ class DBObjectSearch
{
$this->m_oSearchCondition = new TrueExpression();
// ? is that usefull/enough, do I need to rebuild the list after the subqueries ?
// $this->m_aClasses = array($this->m_sClassAlias => $this->m_sClass);
}
public function AddConditionExpression($oExpression)
@@ -200,23 +228,28 @@ class DBObjectSearch
public function AddCondition($sFilterCode, $value, $sOpCode = null)
{
// #@# backward compatibility for pkey/id
if (strtolower(trim($sFilterCode)) == 'pkey') $sFilterCode = 'id';
// #@# todo - obsolete smoothly, first send exceptions
// throw new CoreException('SibusQL has been obsoleted, please update your queries', array('sibusql'=>$sQuery, 'oql'=>$oFilter->ToOQL()));
MyHelpers::CheckKeyInArray('filter code', $sFilterCode, MetaModel::GetClassFilterDefs($this->m_sClass));
$oFilterDef = MetaModel::GetClassFilterDef($this->m_sClass, $sFilterCode);
MyHelpers::CheckKeyInArray('filter code', $sFilterCode, MetaModel::GetClassFilterDefs($this->GetClass()));
$oFilterDef = MetaModel::GetClassFilterDef($this->GetClass(), $sFilterCode);
$oField = new FieldExpression($sFilterCode, $this->GetClassAlias());
if (empty($sOpCode))
{
$sOpCode = $oFilterDef->GetLooseOperator();
if ($sFilterCode == 'id')
{
$sOpCode = '=';
}
else
{
$oAttDef = MetaModel::GetAttributeDef($this->GetClass(), $sFilterCode);
$oNewCondition = $oAttDef->GetSmartConditionExpression($value, $oField, $this->m_aParams);
$this->AddConditionExpression($oNewCondition);
return;
}
}
MyHelpers::CheckKeyInArray('operator', $sOpCode, $oFilterDef->GetOperators());
// Preserve backward compatibility - quick n'dirty way to change that API semantic
//
$oField = new FieldExpression($sFilterCode, $this->m_sClassAlias);
switch($sOpCode)
{
case 'SameDay':
@@ -286,14 +319,20 @@ class DBObjectSearch
protected function AddToNameSpace(&$aClassAliases, &$aAliasTranslation)
{
$sOrigAlias = $this->m_sClassAlias;
$sOrigAlias = $this->GetClassAlias();
if (array_key_exists($sOrigAlias, $aClassAliases))
{
$this->m_sClassAlias = MetaModel::GenerateUniqueAlias($aClassAliases, $sOrigAlias, $this->m_sClass);
$sNewAlias = MetaModel::GenerateUniqueAlias($aClassAliases, $sOrigAlias, $this->GetClass());
$this->m_aSelectedClasses[$sNewAlias] = $this->GetClass();
unset($this->m_aSelectedClasses[$sOrigAlias]);
// Translate the condition expression with the new alias
$aAliasTranslation[$sOrigAlias]['*'] = $this->m_sClassAlias;
$aAliasTranslation[$sOrigAlias]['*'] = $sNewAlias;
}
// add the alias into the filter aliases list
$aClassAliases[$this->GetClassAlias()] = $this->GetClass();
foreach($this->m_aPointingTo as $sExtKeyAttCode=>$oFilter)
{
$oFilter->AddToNameSpace($aClassAliases, $aAliasTranslation);
@@ -429,12 +468,6 @@ class DBObjectSearch
}
}
public function GetClassName($sAlias) {return $this->m_aClasses[$sAlias];}
public function GetClasses() {return $this->m_aClasses;}
public function GetClass() {return $this->m_sClass;}
public function GetClassAlias() {return $this->m_sClassAlias;}
public function GetCriteria() {return $this->m_oSearchCondition;}
public function GetCriteria_FullText() {return $this->m_aFullText;}
public function GetCriteria_PointingTo($sKeyAttCode = "")
@@ -474,110 +507,21 @@ class DBObjectSearch
return $this->m_oSearchCondition->Render($this->m_aParams, false);
}
public function serialize()
public function serialize($bDevelopParams = false, $aContextParams = null)
{
// Efficient but resulting in long strings:
// -> return (base64_encode(serialize($this)));
$sValue = $this->GetClass()."\n";
$sValue .= $this->GetClassAlias()."\n";
foreach($this->m_aClasses as $sClassAlias => $sClass)
{
// A stands for "Aliases"
$sValue .= "A:$sClassAlias:$sClass\n";
}
foreach($this->m_aFullText as $sFullText)
{
// F stands for "Full text"
$sValue .= "F:".$sFullText."\n";
}
$sValue .= "C:".$this->m_oSearchCondition->serialize()."\n";
foreach($this->m_aPointingTo as $sExtKey=>$oFilter)
{
// P stands for "Pointing to"
$sValue .= "P:".$sExtKey.":".$oFilter->serialize()."\n";
}
foreach($this->m_aReferencedBy as $sForeignClass=>$aReferences)
{
foreach($aReferences as $sForeignExtKeyAttCode=>$oForeignFilter)
{
// R stands for "Referenced by"
$sValue .= "R:".$sForeignExtKeyAttCode.":".$oForeignFilter->serialize()."\n";
}
}
foreach($this->m_aRelatedTo as $aRelatedTo)
{
$oFilter = $aRelatedTo['flt'];
$sRelCode = $aRelatedTo['relcode'];
$iMaxDepth = $aRelatedTo['maxdepth'];
$sValue .= "T:".$oFilter->serialize().":$sRelCode:$iMaxDepth\n";
}
if (count($this->m_aParams) > 0)
{
foreach($this->m_aParams as $sName => $sArgValue)
{
// G stands for arGument
$sValue .= "G:$sName:$sArgValue\n";
}
}
return base64_encode($sValue);
$sOql = $this->ToOql($bDevelopParams, $aContextParams);
return base64_encode(serialize(array($sOql, $this->m_aParams)));
}
static public function unserialize($sValue)
{
// See comment above...
// -> return (unserialize(base64_decode($sValue)));
$sClearText = base64_decode($sValue);
$aValues = explode("\n", $sClearText);
$i = 0;
$sClass = $aValues[$i++];
$sClassAlias = $aValues[$i++];
$oFilter = new DBObjectSearch($sClass, $sClassAlias);
while($i < count($aValues) && !empty($aValues[$i]))
{
$aCondition = explode(":", $aValues[$i++]);
switch ($aCondition[0])
{
case "A":
$oFilter->m_aClasses[$aCondition[1]] = $aCondition[2];
break;
case "F":
$oFilter->AddCondition_FullText($aCondition[1]);
break;
case "C":
$oFilter->m_oSearchCondition = Expression::unserialize($aCondition[1]);
break;
case "P":
//$oAtt = DBObject::GetAttributeDef($sClass, $aCondition[1]);
//$sRemoteClass = $oAtt->GetTargetClass();
$oSubFilter = self::unserialize($aCondition[2]);
$sExtKeyAttCode = $aCondition[1];
$oFilter->AddCondition_PointingTo($oSubFilter, $sExtKeyAttCode);
break;
case "R":
$oRemoteFilter = self::unserialize($aCondition[2]);
$sExtKeyAttCodeToMe = $aCondition[1];
$oFilter->AddCondition_ReferencedBy($oRemoteFilter, $sExtKeyAttCodeToMe);
break;
case "T":
$oSubFilter = self::unserialize($aCondition[1]);
$sRelCode = $aCondition[2];
$iMaxDepth = $aCondition[3];
$oFilter->AddCondition_RelatedTo($oSubFilter, $sRelCode, $iMaxDepth);
break;
case "G":
$oFilter->m_aParams[$aCondition[1]] = $aCondition[2];
break;
default:
throw new CoreException("invalid filter definition (cannot unserialize the data, clear text = '$sClearText')");
}
}
return $oFilter;
$aData = unserialize(base64_decode($sValue));
$sOql = $aData[0];
$aParams = $aData[1];
// We've tried to use gzcompress/gzuncompress, but for some specific queries
// it was not working at all (See Trac #193)
// gzuncompress was issuing a warning "data error" and the return object was null
return self::FromOQL($sOql, $aParams);
}
// SImple BUt Structured Query Languag - SubuSQL
@@ -616,27 +560,74 @@ class DBObjectSearch
return $retValue;
}
public function ToOQL(&$aParams = null)
// Alternative to object mapping: the data are transfered directly into an array
// This is 10 times faster than creating a set of objects, and makes sense when optimization is required
public function ToDataArray($aColumns = array(), $aOrderBy = array(), $aArgs = array())
{
$bRetrofitParams = (!is_null($aParams));
if (is_null($aParams))
$sSQL = MetaModel::MakeSelectQuery($this, $aOrderBy, $aArgs);
$resQuery = CMDBSource::Query($sSQL);
if (!$resQuery) return;
if (count($aColumns) == 0)
{
if (count($this->m_aParams) > 0)
$aColumns = array_keys(MetaModel::ListAttributeDefs($this->GetClass()));
// Add the standard id (as first column)
array_unshift($aColumns, 'id');
}
$aQueryCols = CMDBSource::GetColumns($resQuery);
$sClassAlias = $this->GetClassAlias();
$aColMap = array();
foreach ($aColumns as $sAttCode)
{
$sColName = $sClassAlias.$sAttCode;
if (in_array($sColName, $aQueryCols))
{
$aParams = $this->m_aParams;
$aColMap[$sAttCode] = $sColName;
}
}
$aRes = array();
while ($aRow = CMDBSource::FetchArray($resQuery))
{
$aMappedRow = array();
foreach ($aColMap as $sAttCode => $sColName)
{
$aMappedRow[$sAttCode] = $aRow[$sColName];
}
$aRes[] = $aMappedRow;
}
CMDBSource::FreeResult($resQuery);
return $aRes;
}
public function ToOQL($bDevelopParams = false, $aContextParams = null)
{
// Currently unused, but could be useful later
$bRetrofitParams = false;
if ($bDevelopParams)
{
if (is_null($aContextParams))
{
$aParams = array_merge($this->m_aParams);
}
else
{
$aParams = array_merge($aContextParams, $this->m_aParams);
}
$bRetrofitParams = false;
}
else
{
if (count($this->m_aParams) > 0)
{
$aParams = array_merge($aParams, $this->m_aParams);
}
$bRetrofitParams = true;
// Leave it as is, the rendering will be made with parameters in clear
$aParams = null;
}
$sSelectedClasses = implode(', ', array_keys($this->m_aSelectedClasses));
$sRes = 'SELECT '.$sSelectedClasses.' FROM';
$sRes = "SELECT ".$this->GetClass().' AS '.$this->GetClassAlias();
$sRes .= ' '.$this->GetClass().' AS '.$this->GetClassAlias();
$sRes .= $this->ToOQL_Joins();
$sRes .= " WHERE ".$this->m_oSearchCondition->Render($aParams, $bRetrofitParams);
@@ -667,77 +658,6 @@ class DBObjectSearch
return $sRes;
}
public function ToSibusQL()
{
return "NONONO";
}
static private function privProcessParams($sQuery, array $aParams, $oDbObject)
{
$iPlaceHoldersCount = preg_match_all(SIBUSQLPARAMREGEXP, $sQuery, $aMatches, PREG_SET_ORDER);
if ($iPlaceHoldersCount > 0)
{
foreach($aMatches as $aMatch)
{
$sStringToSearch = $aMatch[0];
$sParameterName = $aMatch[1];
$sDefaultValue = $aMatch[2];
$sDescription = $aMatch[3];
$sValue = $sDefaultValue;
if (array_key_exists($sParameterName, $aParams))
{
$sValue = $aParams[$sParameterName];
unset($aParams[$sParameterName]);
}
else if (is_object($oDbObject))
{
if (strpos($sParameterName, "this.") === 0)
{
$sAttCode = substr($sParameterName, strlen("this."));
if ($sAttCode == 'id')
{
$sValue = $oDbObject->GetKey();
}
else if ($sAttCode == 'class')
{
$sValue = get_class($oDbObject);
}
else if (MetaModel::IsValidAttCode(get_class($oDbObject), $sAttCode))
{
$sValue = $oDbObject->Get($sAttCode);
}
}
}
$sQuery = str_replace($sStringToSearch, $sValue, $sQuery);
}
}
if (count($aParams) > 0)
{
// throw new CoreException("Unused parameter(s) for this SibusQL expression: (".implode(', ', array_keys($aParams)).")");
}
return $sQuery;
}
static public function ListSibusQLParams($sQuery)
{
$aRet = array();
$iPlaceHoldersCount = preg_match_all(SIBUSQLPARAMREGEXP, $sQuery, $aMatches, PREG_SET_ORDER);
if ($iPlaceHoldersCount > 0)
{
foreach($aMatches as $aMatch)
{
$sStringToSearch = $aMatch[0];
$sParameterName = $aMatch[1];
$sDefaultValue = $aMatch[2];
$sDescription = $aMatch[3];
$aRet[$sParameterName]["description"] = $sDescription;
$aRet[$sParameterName]["default"] = $sDefaultValue;
}
}
return $aRet;
}
protected function OQLExpressionToCondition($sQuery, $oExpression, $aClassAliases)
{
if ($oExpression instanceof BinaryOqlExpression)
@@ -802,11 +722,25 @@ class DBObjectSearch
}
elseif ($oExpression instanceof ListOqlExpression)
{
return new ListExpression($oExpression->GetItems());
$aItems = array();
foreach ($oExpression->GetItems() as $oItemExpression)
{
$aItems[] = $this->OQLExpressionToCondition($sQuery, $oItemExpression, $aClassAliases);
}
return new ListExpression($aItems);
}
elseif ($oExpression instanceof FunctionOqlExpression)
{
return new FunctionExpression($oExpression->GetVerb(), $oExpression->GetArgs());
$aArgs = array();
foreach ($oExpression->GetArgs() as $oArgExpression)
{
$aArgs[] = $this->OQLExpressionToCondition($sQuery, $oArgExpression, $aClassAliases);
}
return new FunctionExpression($oExpression->GetVerb(), $aArgs);
}
elseif ($oExpression instanceof IntervalOqlExpression)
{
return new IntervalExpression($oExpression->GetValue(), $oExpression->GetUnit());
}
else
{
@@ -814,9 +748,26 @@ class DBObjectSearch
}
}
// Create a search definition that leads to 0 result, still a valid search object
static public function FromEmptySet($sClass)
{
$oResultFilter = new DBObjectSearch($sClass);
$oResultFilter->m_oSearchCondition = new FalseExpression;
return $oResultFilter;
}
static protected $m_aOQLQueries = array();
static public function FromOQL($sQuery)
// Do not filter out depending on user rights
// In particular when we are currently in the process of evaluating the user rights...
static public function FromOQL_AllData($sQuery, $aParams = null)
{
$oRes = self::FromOQL($sQuery, $aParams);
$oRes->AllowAllData();
return $oRes;
}
static public function FromOQL($sQuery, $aParams = null)
{
if (empty($sQuery)) return null;
@@ -912,12 +863,31 @@ class DBObjectSearch
}
}
// Check and prepare the select information
$aSelected = array();
foreach ($oOqlQuery->GetSelectedClasses() as $oClassDetails)
{
$sClassToSelect = $oClassDetails->GetValue();
if (!array_key_exists($sClassToSelect, $aAliases))
{
throw new OqlNormalizeException('Unknown class [alias]', $sQuery, $oClassDetails, array_keys($aAliases));
}
$aSelected[$sClassToSelect] = $aAliases[$sClassToSelect];
}
$oResultFilter->m_aClasses = $aAliases;
$oResultFilter->SetSelectedClasses($aSelected);
$oConditionTree = $oOqlQuery->GetCondition();
if ($oConditionTree instanceof Expression)
{
$oResultFilter->m_oSearchCondition = $oResultFilter->OQLExpressionToCondition($sQuery, $oConditionTree, $aAliases);
}
if (!is_null($aParams))
{
$oResultFilter->m_aParams = $aParams;
}
if ($bOQLCacheEnabled)
{
self::$m_aOQLQueries[$sQuery] = clone $oResultFilter;
@@ -926,111 +896,6 @@ class DBObjectSearch
return $oResultFilter;
}
static public function FromSibusQL($sQuery, array $aParams = array(), $oObject = null)
{
if (empty($sQuery)) return null;
$sQuery = self::privProcessParams($sQuery, $aParams, $oObject);
if (preg_match('@^\\s*SELECT@', $sQuery))
{
return self::FromOQL($sQuery, $aParams, $oObject);
}
$iSepPos = strpos($sQuery, ":");
if ($iSepPos === false)
{
// Only the class was specified -> all rows are required
$sClass = trim($sQuery);
$oFilter = new DBObjectSearch($sClass);
}
else
{
$sClass = trim(substr($sQuery, 0, $iSepPos));
$sConds = trim(substr($sQuery, $iSepPos + 1));
$aValues = explode(" AND ", $sConds);
$oFilter = new DBObjectSearch($sClass);
foreach ($aValues as $sCond)
{
$sCond = trim($sCond);
if (strpos($sCond, "* HAS ") === 0)
{
$sValue = self::Expression2Value(substr($sCond, strlen("* HAS ")));
$oFilter->AddCondition_FullText($sValue);
}
else if (preg_match("@^(\S+) IN \\((.+)\\)$@", $sCond, $aMatches))
{
$sExtKeyAttCode = $aMatches[1];
$sFilterExp = $aMatches[2];
$oSubFilter = self::FromSibuSQL($sFilterExp);
$oFilter->AddCondition_PointingTo($oSubFilter, $sExtKeyAttCode);
}
else if (strpos($sCond, "PKEY IS ") === 0)
{
if (preg_match("@^PKEY IS (\S+) IN \\((.+)\\)$@", $sCond, $aMatches))
{
$sExtKeyAttCodeToMe = $aMatches[1];
$sFilterExp = $aMatches[2];
$oRemoteFilter = self::FromSibuSQL($sFilterExp);
$oFilter->AddCondition_ReferencedBy($oRemoteFilter, $sExtKeyAttCodeToMe);
}
}
else if (strpos($sCond, "RELATED") === 0)
{
if (preg_match("@^RELATED\s*\\((.+)\\)\s*TO\s*\\((.+)\\)@", trim($sCond), $aMatches))
{
$aRelation = explode(',', trim($aMatches[1]));
$sRelCode = trim($aRelation[0]);
$iMaxDepth = intval(trim($aRelation[1]));
$sFilterExp = trim($aMatches[2]);
$oSubFilter = self::FromSibuSQL($sFilterExp);
$oFilter->AddCondition_RelatedTo($oSubFilter, $sRelCode, $iMaxDepth);
}
}
else
{
$sOperandExpr = "'.*'|\d+|-\d+|".VS_START.".+".VS_END;
if (preg_match("@^(\S+)\s+(.*)\s+($sOperandExpr)$@", $sCond, $aMatches))
{
$sFltCode = trim($aMatches[1]);
$sOpCode = trim($aMatches[2]);
$value = self::Expression2Value($aMatches[3]);
$oFilter->AddCondition($sFltCode, $value, $sOpCode);
}
else
{
throw new CoreException("Wrong format for filter definition: '$sQuery'");
}
}
}
}
// #@# todo - obsolete smoothly, first give the OQL version !
// throw new CoreException('SibusQL has been obsoleted, please update your queries', array('sibusql'=>$sQuery, 'oql'=>$oFilter->ToOQL()));
return $oFilter;
}
// Sexy display of a SibuSQL expression
static public function SibuSQLAsHtml($sQuery)
{
$sQuery = htmlentities($sQuery);
$aParams = self::ListSibusQLParams($sQuery);
$aParamValues = array();
foreach ($aParams as $sParamName => $aParamInfo)
{
$sDescription = $aParamInfo["description"];
$sDefaultValue = $aParamInfo["default"];
$aParamValues[$sParamName] = "<span style=\"background-color:#aaa;\" title\"$sDescription (default to '$sDefaultValue')\">$sParamName</span>";
}
$sQuery = self::privProcessParams($sQuery, $aParamValues, null);
return $sQuery;
}
public function toxpath()
{
// #@# a voir...

View File

@@ -1,17 +1,34 @@
<?php
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* Object set management
*
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
/**
* A set of persistent objects, could be heterogeneous
*
* @package iTopORM
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @author Denis Flaven <denisflave@free.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version 1.1.1.1 $
*/
class DBObjectSet
{
private $m_oFilter;
@@ -21,14 +38,16 @@ class DBObjectSet
private $m_aId2Row;
private $m_iCurrRow;
public function __construct(DBObjectSearch $oFilter, $aOrderBy = array(), $aArgs = array())
public function __construct(DBObjectSearch $oFilter, $aOrderBy = array(), $aArgs = array(), $iLimitCount = 0, $iLimitStart = 0)
{
$this->m_oFilter = $oFilter;
$this->m_aOrderBy = $aOrderBy;
$this->m_aArgs = $aArgs;
$this->m_iLimitCount = $iLimitCount;
$this->m_iLimitStart = $iLimitStart;
$this->m_bLoaded = false;
$this->m_aData = array();
$this->m_aData = array(); // array of (row => array of (classalias) => object)
$this->m_aId2Row = array();
$this->m_iCurrRow = 0;
}
@@ -41,7 +60,7 @@ class DBObjectSet
{
$sRet = '';
$this->Rewind();
$sRet .= "Set (".$this->m_oFilter->ToSibuSQL().")<br/>\n";
$sRet .= "Set (".$this->m_oFilter->ToOQL().")<br/>\n";
$sRet .= "Query: <pre style=\"font-size: smaller; display:inline;\">".MetaModel::MakeSelectQuery($this->m_oFilter, array()).")</pre>\n";
$sRet .= $this->Count()." records<br/>\n";
@@ -72,15 +91,55 @@ class DBObjectSet
return $oRetSet;
}
// create an object set ex nihilo
// input = array of objects
static public function FromArray($sClass, $aObjects)
{
$oFilter = new CMDBSearchFilter($sClass);
$oRetSet = new self($oFilter);
$oRetSet->m_bLoaded = true; // no DB load
$oRetSet->AddObjectArray($aObjects);
$oRetSet->AddObjectArray($aObjects, $sClass);
return $oRetSet;
}
// create an object set ex nihilo
// aClasses = array of (alias => class)
// input = array of (array of (classalias => object))
static public function FromArrayAssoc($aClasses, $aObjects)
{
// In a perfect world, we should create a complete tree of DBObjectSearch,
// but as we lack most of the information related to the objects,
// let's create one search definition
$sClass = reset($aClasses);
$sAlias = key($aClasses);
$oFilter = new CMDBSearchFilter($sClass, $sAlias);
$oRetSet = new self($oFilter);
$oRetSet->m_bLoaded = true; // no DB load
foreach($aObjects as $rowIndex => $aObjectsByClassAlias)
{
$oRetSet->AddObjectExtended($aObjectsByClassAlias);
}
return $oRetSet;
}
static public function FromLinkSet($oObject, $sLinkSetAttCode, $sExtKeyToRemote)
{
$oLinkAttCode = MetaModel::GetAttributeDef(get_class($oObject), $sLinkSetAttCode);
$oExtKeyAttDef = MetaModel::GetAttributeDef($oLinkAttCode->GetLinkedClass(), $sExtKeyToRemote);
$sTargetClass = $oExtKeyAttDef->GetTargetClass();
$oLinkSet = $oObject->Get($sLinkSetAttCode);
$aTargets = array();
while ($oLink = $oLinkSet->Fetch())
{
$aTargets[] = MetaModel::GetObject($sTargetClass, $oLink->Get($sExtKeyToRemote));
}
return self::FromArray($sTargetClass, $aTargets);
}
public function ToArray($bWithId = true)
{
$aRet = array();
@@ -99,6 +158,30 @@ class DBObjectSet
return $aRet;
}
public function ToArrayOfValues()
{
if (!$this->m_bLoaded) $this->Load();
$aRet = array();
foreach($this->m_aData as $iRow => $aObjects)
{
foreach($aObjects as $sClassAlias => $oObject)
{
$aRet[$iRow][$sClassAlias.'.'.'id'] = $oObject->GetKey();
$sClass = get_class($oObject);
foreach(MetaModel::ListAttributeDefs($sClass) as $sAttCode => $oAttDef)
{
if ($oAttDef->IsScalar())
{
$sAttName = $sClassAlias.'.'.$sAttCode;
$aRet[$iRow][$sAttName] = $oObject->Get($sAttCode);
}
}
}
}
return $aRet;
}
public function GetColumnAsArray($sAttCode, $bWithId = true)
{
$aRet = array();
@@ -127,24 +210,56 @@ class DBObjectSet
return $this->m_oFilter->GetClass();
}
public function GetSelectedClasses()
{
return $this->m_oFilter->GetSelectedClasses();
}
public function GetRootClass()
{
return MetaModel::GetRootClass($this->GetClass());
}
public function SetLimit($iLimitCount, $iLimitStart = 0)
{
$this->m_iLimitCount = $iLimitCount;
$this->m_iLimitStart = $iLimitStart;
}
public function GetLimitCount()
{
return $this->m_iLimitCount;
}
public function GetLimitStart()
{
return $this->m_iLimitStart;
}
public function Load()
{
if ($this->m_bLoaded) return;
$sSQL = MetaModel::MakeSelectQuery($this->m_oFilter, $this->m_aOrderBy, $this->m_aArgs);
if ($this->m_iLimitCount > 0)
{
$sSQL = MetaModel::MakeSelectQuery($this->m_oFilter, $this->m_aOrderBy, $this->m_aArgs, $this->m_iLimitCount, $this->m_iLimitStart);
}
else
{
$sSQL = MetaModel::MakeSelectQuery($this->m_oFilter, $this->m_aOrderBy, $this->m_aArgs);
}
$resQuery = CMDBSource::Query($sSQL);
if (!$resQuery) return;
$sClass = $this->m_oFilter->GetClass();
while ($aRow = CMDBSource::FetchArray($resQuery))
{
$sClass = $this->m_oFilter->GetClass();
$oObject = MetaModel::GetObjectByRow($sClass, $aRow);
$this->AddObject($oObject);
$aObjects = array();
foreach ($this->m_oFilter->GetSelectedClasses() as $sClassAlias => $sClass)
{
$oObject = MetaModel::GetObjectByRow($sClass, $aRow, $sClassAlias);
$aObjects[$sClassAlias] = $oObject;
}
$this->AddObjectExtended($aObjects);
}
CMDBSource::FreeResult($resQuery);
@@ -153,11 +268,16 @@ class DBObjectSet
public function Count()
{
if (!$this->m_bLoaded) $this->Load();
return count($this->m_aData);
$sSQL = MetaModel::MakeSelectQuery($this->m_oFilter, $this->m_aOrderBy, $this->m_aArgs, 0, 0, true);
$resQuery = CMDBSource::Query($sSQL);
if (!$resQuery) return 0;
$aRow = CMDBSource::FetchArray($resQuery);
CMDBSource::FreeResult($resQuery);
return $aRow['COUNT'];
}
public function Fetch()
public function Fetch($sClassAlias = '')
{
if (!$this->m_bLoaded) $this->Load();
@@ -165,11 +285,32 @@ class DBObjectSet
{
return null;
}
$oRetObj = $this->m_aData[$this->m_iCurrRow];
if (strlen($sClassAlias) == 0)
{
$sClassAlias = $this->m_oFilter->GetClassAlias();
}
$oRetObj = $this->m_aData[$this->m_iCurrRow][$sClassAlias];
$this->m_iCurrRow++;
return $oRetObj;
}
// Return the whole line if several classes have been specified in the query
//
public function FetchAssoc()
{
if (!$this->m_bLoaded) $this->Load();
if ($this->m_iCurrRow >= count($this->m_aData))
{
return null;
}
$aRetObjects = $this->m_aData[$this->m_iCurrRow];
$this->m_iCurrRow++;
return $aRetObjects;
}
public function Rewind()
{
$this->Seek(0);
@@ -183,24 +324,35 @@ class DBObjectSet
return $this->m_iCurrRow;
}
public function AddObject($oObject)
public function AddObject($oObject, $sClassAlias = '')
{
// ?usefull? if ($oObject->GetClass() != $this->GetClass()) return;
if (strlen($sClassAlias) == 0)
{
$sClassAlias = $this->m_oFilter->GetClassAlias();
}
// it is mandatory to avoid duplicates
if (array_key_exists($oObject->GetKey(), $this->m_aId2Row)) return;
// Do not load here, because the load uses that method too
$iNextPos = count($this->m_aData);
$this->m_aData[$iNextPos] = $oObject;
$this->m_aId2Row[$oObject->GetKey()] = $iNextPos;
$this->m_aData[$iNextPos][$sClassAlias] = $oObject;
$this->m_aId2Row[$sClassAlias][$oObject->GetKey()] = $iNextPos;
}
public function AddObjectArray($aObjects)
protected function AddObjectExtended($aObjectArray)
{
$iNextPos = count($this->m_aData);
foreach ($aObjectArray as $sClassAlias => $oObject)
{
$this->m_aData[$iNextPos][$sClassAlias] = $oObject;
$this->m_aId2Row[$sClassAlias][$oObject->GetKey()] = $iNextPos;
}
}
public function AddObjectArray($aObjects, $sClassAlias = '')
{
// #@# todo - add a check on the object class ?
foreach ($aObjects as $oObj)
{
$this->AddObject($oObj);
$this->AddObject($oObj, $sClassAlias);
}
}
@@ -229,10 +381,11 @@ class DBObjectSet
$oNewSet = DBObjectSet::FromScratch($this->GetClass());
$sClassAlias = $this->m_oFilter->GetClassAlias();
$oObjectSet->Seek(0);
while ($oObject = $oObjectSet->Fetch())
{
if (array_key_exists($oObject->GetKey(), $this->m_aId2Row))
if (array_key_exists($oObject->GetKey(), $this->m_aId2Row[$sClassAlias]))
{
$oNewSet->AddObject($oObject);
}
@@ -250,10 +403,11 @@ class DBObjectSet
$oNewSet = DBObjectSet::FromScratch($this->GetClass());
$sClassAlias = $this->m_oFilter->GetClassAlias();
$oObjectSet->Seek(0);
while ($oObject = $oObjectSet->Fetch())
{
if (!array_key_exists($oObject->GetKey(), $this->m_aId2Row))
if (!array_key_exists($oObject->GetKey(), $this->m_aId2Row[$sClassAlias]))
{
$oNewSet->AddObject($oObject);
}
@@ -263,11 +417,23 @@ class DBObjectSet
public function GetRelatedObjects($sRelCode, $iMaxDepth = 99)
{
$aRelatedObjs = array();
$aVisited = array(); // optimization for consecutive calls of MetaModel::GetRelatedObjects
$this->Seek(0);
while ($oObject = $this->Fetch())
{
$aRelatedObjs = $oObject->GetRelatedObjects($sRelCode, $iMaxDepth, $aVisited);
$aMore = $oObject->GetRelatedObjects($sRelCode, $iMaxDepth, $aVisited);
foreach ($aMore as $sClass => $aRelated)
{
foreach ($aRelated as $iObj => $oObj)
{
if (!isset($aRelatedObjs[$sClass][$iObj]))
{
$aRelatedObjs[$sClass][$iObj] = $oObj;
}
}
}
}
return $aRelatedObjs;
}

View File

@@ -0,0 +1,159 @@
<?php
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* Database properties - manage database instances in a complex installation
*
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
/**
* A database property
*
* @package iTopORM
*/
class DBProperty extends DBObject
{
public static function Init()
{
$aParams = array
(
"category" => "cloud",
"key_type" => "autoincrement",
"name_attcode" => "name",
"state_attcode" => "",
"reconc_keys" => array(),
"db_table" => "priv_db_properties",
"db_key_field" => "id",
"db_finalclass_field" => "",
);
MetaModel::Init_Params($aParams);
//MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeString("name", array("allowed_values"=>null, "sql"=>"name", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("description", array("allowed_values"=>null, "sql"=>"description", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("value", array("allowed_values"=>null, "sql"=>"value", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeDateTime("change_date", array("allowed_values"=>null, "sql"=>"change_date", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("change_comment", array("allowed_values"=>null, "sql"=>"change_comment", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
}
/**
* Helper to check wether the table has been created into the DB
* (this table did not exist in 1.0.1 and older versions)
*/
public static function IsInstalled()
{
$sTable = MetaModel::DBGetTable(__CLASS__);
if (CMDBSource::IsTable($sTable))
{
return true;
}
else
{
return false;
}
return false;
}
public static function SetProperty($sName, $sValue, $sComment = '', $sDescription = null)
{
try
{
$oSearch = DBObjectSearch::FromOQL('SELECT DBProperty WHERE name = :name');
$oSet = new DBObjectSet($oSearch, array(), array('name' => $sName));
if ($oSet->Count() == 0)
{
$oProp = new DBProperty();
$oProp->Set('name', $sName);
$oProp->Set('description', $sDescription);
$oProp->Set('value', $sValue);
$oProp->Set('change_date', time());
$oProp->Set('change_comment', $sComment);
$oProp->DBInsert();
}
elseif ($oSet->Count() == 1)
{
$oProp = $oSet->fetch();
if (!is_null($sDescription))
{
$oProp->Set('description', $sDescription);
}
$oProp->Set('value', $sValue);
$oProp->Set('change_date', time());
$oProp->Set('change_comment', $sComment);
$oProp->DBUpdate();
}
else
{
// Houston...
throw new CoreException('duplicate db property');
}
}
catch (MySQLException $e)
{
// This might be because the table could not be found,
// let's check it and discard silently if this is really the case
if (self::IsInstalled())
{
throw $e;
}
IssueLog::Error('Attempting to write a DBProperty while the module has not been installed');
}
}
public static function GetProperty($sName, $default = null)
{
try
{
$oSearch = DBObjectSearch::FromOQL('SELECT DBProperty WHERE name = :name');
$oSet = new DBObjectSet($oSearch, array(), array('name' => $sName));
$iCount = $oSet->Count();
if ($iCount == 0)
{
//throw new CoreException('unknown db property', array('name' => $sName));
$sValue = $default;
}
elseif ($iCount == 1)
{
$oProp = $oSet->fetch();
$sValue = $oProp->Get('value');
}
else
{
// $iCount > 1
// Houston...
throw new CoreException('duplicate db property', array('name' => $sName, 'count' => $iCount));
}
}
catch (MySQLException $e)
{
// This might be because the table could not be found,
// let's check it and discard silently if this is really the case
if (self::IsInstalled())
{
throw $e;
}
$sValue = $default;
}
return $sValue;
}
}
?>

235
core/dict.class.inc.php Normal file
View File

@@ -0,0 +1,235 @@
<?php
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* Class Dict
* Management of localizable strings
*
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
class DictException extends CoreException
{
}
class DictExceptionUnknownLanguage extends DictException
{
public function __construct($sLanguageCode)
{
$aContext = array();
$aContext['language_code'] = $sLanguageCode;
parent::__construct('Unknown localization language', $aContext);
}
}
class DictExceptionMissingString extends DictException
{
public function __construct($sLanguageCode, $sStringCode)
{
$aContext = array();
$aContext['language_code'] = $sLanguageCode;
$aContext['string_code'] = $sStringCode;
parent::__construct('Missing localized string', $aContext);
}
}
define('DICT_ERR_STRING', 1); // when a string is missing, return the identifier
define('DICT_ERR_EXCEPTION', 2); // when a string is missing, throw an exception
//define('DICT_ERR_LOG', 3); // when a string is missing, log an error
class Dict
{
protected static $m_iErrorMode = DICT_ERR_STRING;
protected static $m_sDefaultLanguage = 'EN US';
protected static $m_sCurrentLanguage = null; // No language selected by default
protected static $m_aLanguages = array(); // array( code => array( 'description' => '...', 'localized_description' => '...') ...)
protected static $m_aData = array();
public static function SetDefaultLanguage($sLanguageCode)
{
if (!array_key_exists($sLanguageCode, self::$m_aLanguages))
{
throw new DictExceptionUnknownLanguage($sLanguageCode);
}
self::$m_sDefaultLanguage = $sLanguageCode;
}
public static function SetUserLanguage($sLanguageCode)
{
if (!array_key_exists($sLanguageCode, self::$m_aLanguages))
{
throw new DictExceptionUnknownLanguage($sLanguageCode);
}
self::$m_sCurrentLanguage = $sLanguageCode;
}
public static function GetCurrentLanguage()
{
if (self::$m_sCurrentLanguage == null) // May happen when no user is logged in (i.e login screen, non authentifed page)
{
// In which case let's use the default language
return self::$m_sDefaultLanguage;
}
return self::$m_sCurrentLanguage;
}
//returns a hash array( code => array( 'description' => '...', 'localized_description' => '...') ...)
public static function GetLanguages()
{
return self::$m_aLanguages;
}
// iErrorMode from {DICT_ERR_STRING, DICT_ERR_EXCEPTION}
public static function SetErrorMode($iErrorMode)
{
self::$m_iErrorMode = $iErrorMode;
}
public static function S($sStringCode, $sDefault = null)
{
// Attempt to find the string in the user language
//
if (!array_key_exists(self::GetCurrentLanguage(), self::$m_aData))
{
// It may happen, when something happens before the dictionnaries get loaded
return $sStringCode;
}
$aCurrentDictionary = self::$m_aData[self::GetCurrentLanguage()];
if (array_key_exists($sStringCode, $aCurrentDictionary))
{
return $aCurrentDictionary[$sStringCode];
}
// Attempt to find the string in the default language
//
$aDefaultDictionary = self::$m_aData[self::$m_sDefaultLanguage];
if (array_key_exists($sStringCode, $aDefaultDictionary))
{
return $aDefaultDictionary[$sStringCode];
}
// Attempt to find the string in english
//
$aDefaultDictionary = self::$m_aData['EN US'];
if (array_key_exists($sStringCode, $aDefaultDictionary))
{
return $aDefaultDictionary[$sStringCode];
}
// Could not find the string...
//
switch (self::$m_iErrorMode)
{
case DICT_ERR_STRING:
if (is_null($sDefault))
{
return $sStringCode;
}
else
{
return $sDefault;
}
break;
case DICT_ERR_EXCEPTION:
default:
throw new DictExceptionMissingString(self::$m_sCurrentLanguage, $sStringCode);
break;
}
return 'bug!';
}
public static function Format($sFormatCode /*, ... arguments ....*/)
{
$sLocalizedFormat = self::S($sFormatCode);
$aArguments = func_get_args();
if ($sLocalizedFormat == $sFormatCode)
{
// Make sure the information will be displayed (ex: an error occuring before the dictionary gets loaded)
return $sFormatCode.' - '.implode(', ', $aArguments);
}
array_shift($aArguments);
return vsprintf($sLocalizedFormat, $aArguments);
}
// sLanguageCode: Code identifying the language i.e. FR-FR
// sEnglishLanguageDesc: Description of the language code, in English. i.e. French (France)
// sLocalizedLanguageDesc: Description of the language code, in its own language. i.e. Français (France)
// aEntries: Hash array of dictionnary entries
public static function Add($sLanguageCode, $sEnglishLanguageDesc, $sLocalizedLanguageDesc, $aEntries)
{
if (!array_key_exists($sLanguageCode, self::$m_aLanguages))
{
self::$m_aLanguages[$sLanguageCode] = array('description' => $sEnglishLanguageDesc, 'localized_description' => $sLocalizedLanguageDesc);
self::$m_aData[$sLanguageCode] = array();
}
self::$m_aData[$sLanguageCode] = array_merge(self::$m_aData[$sLanguageCode], $aEntries);
}
public static function MakeStats($sLanguageCode, $sLanguageRef = 'EN US')
{
$aMissing = array(); // Strings missing for the target language
$aUnexpected = array(); // Strings defined for the target language, but not found in the reference dictionary
$aNotTranslated = array(); // Strings having the same value in both dictionaries
$aOK = array(); // Strings having different values in both dictionaries
foreach (self::$m_aData[$sLanguageRef] as $sStringCode => $sValue)
{
if (!array_key_exists($sStringCode, self::$m_aData[$sLanguageCode]))
{
$aMissing[$sStringCode] = $sValue;
}
}
foreach (self::$m_aData[$sLanguageCode] as $sStringCode => $sValue)
{
if (!array_key_exists($sStringCode, self::$m_aData[$sLanguageRef]))
{
$aUnexpected[$sStringCode] = $sValue;
}
else
{
// The value exists in the reference
$sRefValue = self::$m_aData[$sLanguageRef][$sStringCode];
if ($sValue == $sRefValue)
{
$aNotTranslated[$sStringCode] = $sValue;
}
else
{
$aOK[$sStringCode] = $sValue;
}
}
}
return array($aMissing, $aUnexpected, $aNotTranslated, $aOK);
}
public static function Dump()
{
MyHelpers::var_dump_html(self::$m_aData);
}
}
?>

View File

@@ -1,17 +1,29 @@
<?php
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* Send an mail (for notification, testing,... purposes)
* #@# TODO - replace by a more sophisticated mean (and update the prototype)
*
* @package iTopORM
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @author Denis Flaven <denisflave@free.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version 1.1.1.1 $
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
class EMail
{
protected $m_sBody;
@@ -77,6 +89,11 @@ class EMail
$this->m_aHeaders[$sKey] = $sValue;
}
}
public function SetReferences($sReferences)
{
$this->AddToHeader('References', $sReferences);
}
public function SetBody($sBody)
{
@@ -120,4 +137,4 @@ class EMail
}
?>
?>

View File

@@ -1,27 +1,38 @@
<?php
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* An application internal event
* Persistent class Event and derived
* Application internal events
* There is also a file log
*
* @package iTopORM
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @author Denis Flaven <denisflave@free.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version 1.1.1.1 $
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
class Event extends cmdbAbstractObject
{
public static function Init()
{
$aParams = array
(
"category" => "core/cmdb",
"name" => "Log Event",
"description" => "An application internal event",
"category" => "core/cmdb,view_in_gui",
"key_type" => "autoincrement",
"key_label" => "",
"name_attcode" => "",
"state_attcode" => "",
"reconc_keys" => array(),
@@ -32,13 +43,9 @@ class Event extends cmdbAbstractObject
);
MetaModel::Init_Params($aParams);
//MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeText("message", array("label"=>"message", "description"=>"short description of the event", "allowed_values"=>null, "sql"=>"message", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeDate("date", array("label"=>"date", "description"=>"date and time at which the changes have been recorded", "allowed_values"=>null, "sql"=>"date", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("userinfo", array("label"=>"user info", "description"=>"identification of the user that was doing the action that triggered this event", "allowed_values"=>null, "sql"=>"userinfo", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
//MetaModel::Init_InheritFilters();
MetaModel::Init_AddFilterFromAttribute("message");
MetaModel::Init_AddFilterFromAttribute("date");
MetaModel::Init_AddAttribute(new AttributeText("message", array("allowed_values"=>null, "sql"=>"message", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeDateTime("date", array("allowed_values"=>null, "sql"=>"date", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("userinfo", array("allowed_values"=>null, "sql"=>"userinfo", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
// Display lists
MetaModel::Init_SetZListItems('details', array('message', 'date', 'userinfo')); // Attributes to be displayed for the complete details
@@ -55,11 +62,8 @@ class EventNotification extends Event
{
$aParams = array
(
"category" => "core/cmdb",
"name" => "Notification event",
"description" => "Trace of a notification that has been sent",
"category" => "core/cmdb,view_in_gui",
"key_type" => "autoincrement",
"key_label" => "",
"name_attcode" => "",
"state_attcode" => "",
"reconc_keys" => array(),
@@ -70,14 +74,9 @@ class EventNotification extends Event
);
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeExternalKey("trigger_id", array("targetclass"=>"Trigger", "jointype"=> "", "label"=>"Trigger", "description"=>"user account", "allowed_values"=>null, "sql"=>"trigger_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalKey("action_id", array("targetclass"=>"Action", "jointype"=> "", "label"=>"user", "description"=>"user account", "allowed_values"=>null, "sql"=>"action_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeInteger("object_id", array("label"=>"Object id", "description"=>"object id (class defined by the trigger ?)", "allowed_values"=>null, "sql"=>"object_id", "default_value"=>0, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_InheritFilters();
MetaModel::Init_AddFilterFromAttribute("trigger_id");
MetaModel::Init_AddFilterFromAttribute("action_id");
MetaModel::Init_AddFilterFromAttribute("object_id");
MetaModel::Init_AddAttribute(new AttributeExternalKey("trigger_id", array("targetclass"=>"Trigger", "jointype"=> "", "allowed_values"=>null, "sql"=>"trigger_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalKey("action_id", array("targetclass"=>"Action", "jointype"=> "", "allowed_values"=>null, "sql"=>"action_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeInteger("object_id", array("allowed_values"=>null, "sql"=>"object_id", "default_value"=>0, "is_null_allowed"=>false, "depends_on"=>array())));
// Display lists
MetaModel::Init_SetZListItems('details', array('date', 'userinfo', 'trigger_id', 'action_id', 'object_id')); // Attributes to be displayed for the complete details
@@ -95,11 +94,8 @@ class EventNotificationEmail extends EventNotification
{
$aParams = array
(
"category" => "core/cmdb",
"name" => "Email emission event",
"description" => "Trace of an email that has been sent",
"category" => "core/cmdb,view_in_gui",
"key_type" => "autoincrement",
"key_label" => "",
"name_attcode" => "",
"state_attcode" => "",
"reconc_keys" => array(),
@@ -110,17 +106,16 @@ class EventNotificationEmail extends EventNotification
);
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeText("to", array("label"=>"TO", "description"=>"TO", "allowed_values"=>null, "sql"=>"to", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("cc", array("label"=>"CC", "description"=>"CC", "allowed_values"=>null, "sql"=>"cc", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("bcc", array("label"=>"BCC", "description"=>"BCC", "allowed_values"=>null, "sql"=>"bcc", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("from", array("label"=>"From", "description"=>"Sender of the message", "allowed_values"=>null, "sql"=>"from", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("subject", array("label"=>"Subject", "description"=>"Subject", "allowed_values"=>null, "sql"=>"subject", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("body", array("label"=>"Body", "description"=>"Body", "allowed_values"=>null, "sql"=>"body", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_InheritFilters();
MetaModel::Init_AddAttribute(new AttributeText("to", array("allowed_values"=>null, "sql"=>"to", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("cc", array("allowed_values"=>null, "sql"=>"cc", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("bcc", array("allowed_values"=>null, "sql"=>"bcc", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("from", array("allowed_values"=>null, "sql"=>"from", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("subject", array("allowed_values"=>null, "sql"=>"subject", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("body", array("allowed_values"=>null, "sql"=>"body", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
// Display lists
MetaModel::Init_SetZListItems('details', array('date', 'userinfo', 'message', 'trigger_id', 'action_id', 'object_id', 'to', 'cc', 'bcc', 'from', 'subject', 'body')); // Attributes to be displayed for the complete details
MetaModel::Init_SetZListItems('list', array('date', 'userinfo', 'message', 'subject')); // Attributes to be displayed for a list
MetaModel::Init_SetZListItems('list', array('date', 'userinfo', 'message', 'to', 'subject')); // Attributes to be displayed for a list
// Search criteria
// MetaModel::Init_SetZListItems('standard_search', array('name')); // Criteria of the std search form
@@ -135,11 +130,8 @@ class EventIssue extends Event
{
$aParams = array
(
"category" => "core/cmdb",
"name" => "Issue event",
"description" => "Trace of an issue (warning, error, etc.)",
"category" => "core/cmdb,view_in_gui",
"key_type" => "autoincrement",
"key_label" => "",
"name_attcode" => "",
"state_attcode" => "",
"reconc_keys" => array(),
@@ -150,17 +142,13 @@ class EventIssue extends Event
);
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeString("issue", array("label"=>"Issue", "description"=>"What happened", "allowed_values"=>null, "sql"=>"issue", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("impact", array("label"=>"Impact", "description"=>"What are the consequences", "allowed_values"=>null, "sql"=>"impact", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("page", array("label"=>"Page", "description"=>"HTTP entry point", "allowed_values"=>null, "sql"=>"page", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("arguments_post", array("label"=>"Posted arguments", "description"=>"HTTP POST arguments", "allowed_values"=>null, "sql"=>"arguments_post", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("arguments_get", array("label"=>"URL arguments", "description"=>"HTTP GET arguments", "allowed_values"=>null, "sql"=>"arguments_get", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("callstack", array("label"=>"Callstack", "description"=>"Call stack", "allowed_values"=>null, "sql"=>"callstack", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeBlob("data", array("label"=>"Data", "description"=>"More information", "allowed_values"=>null, "sql"=>"data", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_InheritFilters();
MetaModel::Init_AddFilterFromAttribute("issue");
MetaModel::Init_AddFilterFromAttribute("impact");
MetaModel::Init_AddAttribute(new AttributeString("issue", array("allowed_values"=>null, "sql"=>"issue", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("impact", array("allowed_values"=>null, "sql"=>"impact", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("page", array("allowed_values"=>null, "sql"=>"page", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributePropertySet("arguments_post", array("allowed_values"=>null, "sql"=>"arguments_post", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributePropertySet("arguments_get", array("allowed_values"=>null, "sql"=>"arguments_get", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeTable("callstack", array("allowed_values"=>null, "sql"=>"callstack", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributePropertySet("data", array("allowed_values"=>null, "sql"=>"data", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
// Display lists
MetaModel::Init_SetZListItems('details', array('date', 'userinfo', 'issue', 'impact', 'page', 'arguments_post', 'arguments_get', 'callstack', 'data')); // Attributes to be displayed for the complete details
@@ -169,6 +157,69 @@ class EventIssue extends Event
// MetaModel::Init_SetZListItems('standard_search', array('name')); // Criteria of the std search form
// MetaModel::Init_SetZListItems('advanced_search', array('name')); // Criteria of the advanced search form
}
protected function OnInsert()
{
// Init page information: name, arguments
//
$this->Set('page', @$GLOBALS['_SERVER']['SCRIPT_NAME']);
if (array_key_exists('_GET', $GLOBALS) && is_array($GLOBALS['_GET']))
{
$this->Set('arguments_get', $GLOBALS['_GET']);
}
else
{
$this->Set('arguments_get', array());
}
if (array_key_exists('_POST', $GLOBALS) && is_array($GLOBALS['_POST']))
{
$aPost = array();
foreach($GLOBALS['_POST'] as $sKey => $sValue)
{
if (is_string($sValue))
{
if (strlen($sValue) < 256)
{
$aPost[$sKey] = $sValue;
}
else
{
$aPost[$sKey] = "!long string: ".strlen($sValue). " chars";
}
}
else
{
// Not a string
$aPost[$sKey] = (string) $sValue;
}
}
$this->Set('arguments_post', $aPost);
}
else
{
$this->Set('arguments_post', array());
}
$sLength = strlen($this->Get('issue'));
if ($sLength > 255)
{
$this->Set('issue', substr($this->Get('issue'), 0, 200)." -truncated ($sLength chars)");
}
$sLength = strlen($this->Get('impact'));
if ($sLength > 255)
{
$this->Set('impact', substr($this->Get('impact'), 0, 200)." -truncated ($sLength chars)");
}
$sLength = strlen($this->Get('page'));
if ($sLength > 255)
{
$this->Set('page', substr($this->Get('page'), 0, 200)." -truncated ($sLength chars)");
}
}
}
@@ -178,11 +229,8 @@ class EventWebService extends Event
{
$aParams = array
(
"category" => "core/cmdb",
"name" => "Web service event",
"description" => "Trace of an web service call",
"category" => "core/cmdb,view_in_gui",
"key_type" => "autoincrement",
"key_label" => "",
"name_attcode" => "",
"state_attcode" => "",
"reconc_keys" => array(),
@@ -193,15 +241,13 @@ class EventWebService extends Event
);
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeString("verb", array("label"=>"Verb", "description"=>"Name of the operation", "allowed_values"=>null, "sql"=>"verb", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
//MetaModel::Init_AddAttribute(new AttributeStructure("arguments", array("label"=>"Arguments", "description"=>"Operation arguments", "allowed_values"=>null, "sql"=>"data", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeBoolean("result", array("label"=>"Result", "description"=>"Overall success/failure", "allowed_values"=>null, "sql"=>"result", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("log_info", array("label"=>"Info log", "description"=>"Result info log", "allowed_values"=>null, "sql"=>"log_info", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("log_warning", array("label"=>"Warning log", "description"=>"Result warning log", "allowed_values"=>null, "sql"=>"log_warning", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("log_error", array("label"=>"Error log", "description"=>"Result error log", "allowed_values"=>null, "sql"=>"log_error", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("data", array("label"=>"Data", "description"=>"Result data", "allowed_values"=>null, "sql"=>"data", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_InheritFilters();
MetaModel::Init_AddAttribute(new AttributeString("verb", array("allowed_values"=>null, "sql"=>"verb", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
//MetaModel::Init_AddAttribute(new AttributeStructure("arguments", array("allowed_values"=>null, "sql"=>"data", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeBoolean("result", array("allowed_values"=>null, "sql"=>"result", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("log_info", array("allowed_values"=>null, "sql"=>"log_info", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("log_warning", array("allowed_values"=>null, "sql"=>"log_warning", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("log_error", array("allowed_values"=>null, "sql"=>"log_error", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("data", array("allowed_values"=>null, "sql"=>"data", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
// Display lists
MetaModel::Init_SetZListItems('details', array('date', 'userinfo', 'verb', 'result', 'log_info', 'log_warning', 'log_error', 'data')); // Attributes to be displayed for the complete details

View File

@@ -1,15 +1,26 @@
<?php
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* General definition of an expression tree (could be OQL, SQL or whatever)
*
* @package iTopORM
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @author Denis Flaven <denisflave@free.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version 1.1.1.1 $
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
class MissingQueryArgument extends CoreException
@@ -219,6 +230,19 @@ class TrueExpression extends ScalarExpression
}
}
class FalseExpression extends ScalarExpression
{
public function __construct()
{
parent::__construct(0);
}
public function IsTrue()
{
return false;
}
}
class FieldExpression extends UnaryExpression
{
protected $m_sParent;
@@ -337,6 +361,16 @@ class ListExpression extends Expression
$this->m_aExpressions = $aExpressions;
}
public static function FromScalars($aScalars)
{
$aExpressions = array();
foreach($aScalars as $value)
{
$aExpressions[] = new ScalarExpression($value);
}
return new ListExpression($aExpressions);
}
public function IsTrue()
{
// return true if we are certain that it will be true

View File

@@ -1,4 +1,29 @@
<?php
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* Definition of a filter
* Most of the time, a filter corresponds to an attribute, but we could imagine other search criteria
*
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
require_once('MyHelpers.class.inc.php');
@@ -8,12 +33,6 @@ require_once('MyHelpers.class.inc.php');
* Definition of a filter (could be made out of an existing attribute, or from an expression)
*
* @package iTopORM
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @author Denis Flaven <denisflave@free.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version 1.1.1.1 $
*/
abstract class FilterDefinition
{
@@ -96,11 +115,6 @@ abstract class FilterDefinition
* Match against the object unique identifier
*
* @package iTopORM
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version $itopversion$
*/
class FilterPrivateKey extends FilterDefinition
{
@@ -148,11 +162,6 @@ class FilterPrivateKey extends FilterDefinition
* Match against an existing attribute (the attribute type will determine the available operators)
*
* @package iTopORM
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version $itopversion$
*/
class FilterFromAttribute extends FilterDefinition
{
@@ -189,10 +198,10 @@ class FilterFromAttribute extends FilterDefinition
return $oAttDef->GetValuesDef();
}
public function GetAllowedValues($aArgs = array(), $sBeginsWith = '')
public function GetAllowedValues($aArgs = array(), $sContains = '')
{
$oAttDef = $this->Get("refattribute");
return $oAttDef->GetAllowedValues($aArgs, $sBeginsWith);
return $oAttDef->GetAllowedValues($aArgs, $sContains);
}
public function GetOperators()

196
core/kpi.class.inc.php Normal file
View File

@@ -0,0 +1,196 @@
<?php
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* Measures operations duration, memory usage, etc. (and some other KPIs)
*
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
class ExecutionKPI
{
static protected $m_bEnabled_Duration = false;
static protected $m_bEnabled_Memory = false;
static protected $m_aStats = array();
protected $m_fStarted = null;
protected $m_iInitialMemory = null;
static public function EnableDuration()
{
self::$m_bEnabled_Duration = true;
}
static public function EnableMemory()
{
self::$m_bEnabled_Memory = true;
}
static public function ReportStats()
{
foreach (self::$m_aStats as $sOperation => $aOpStats)
{
echo "<h2>KPIs for $sOperation</h2>\n";
$fTotalOp = 0;
$iTotalOp = 0;
$fMinOp = null;
$fMaxOp = 0;
echo "<ul>\n";
foreach ($aOpStats as $sArguments => $aEvents)
{
$fTotalInter = 0;
$fMinInter = null;
$fMaxInter = 0;
foreach ($aEvents as $fDuration)
{
$fTotalInter += $fDuration;
$fMinInter = is_null($fMinInter) ? $fDuration : min($fMinInter, $fDuration);
$fMaxInter = max($fMaxInter, $fDuration);
$fMinOp = is_null($fMinOp) ? $fDuration : min($fMinOp, $fDuration);
$fMaxOp = max($fMaxOp, $fDuration);
}
$fTotalOp += $fTotalInter;
$iTotalOp++;
$iCountInter = count($aEvents);
$sTotalInter = round($fTotalInter, 3)."s";
if ($iCountInter > 1)
{
$sMinInter = round($fMinInter, 3)."s";
$sMaxInter = round($fMaxInter, 3)."s";
$sTimeDesc = "$sTotalInter (from $sMinInter to $sMaxInter) in $iCountInter times";
}
else
{
$sTimeDesc = "$sTotalInter";
}
echo "<li>Spent $sTimeDesc, on: <span style=\"font-size:60%\">$sArguments</span></li>\n";
}
echo "</ul>\n";
echo "<ul>Sumary for $sOperation\n";
echo "<li>Total: $iTotalOp (".round($fTotalOp, 3).")</li>\n";
echo "<li>Min: ".round($fMinOp, 3)."</li>\n";
echo "<li>Max: ".round($fMaxOp, 3)."</li>\n";
echo "<li>Avg: ".round($fTotalOp / $iTotalOp, 3)."</li>\n";
echo "</ul>\n";
}
}
public function __construct()
{
$this->ResetCounters();
}
// Get the duration since startup, and reset the counter for the next measure
//
public function ComputeAndReport($sOperationDesc)
{
if (self::$m_bEnabled_Duration)
{
$fStopped = MyHelpers::getmicrotime();
$fDuration = $fStopped - $this->m_fStarted;
$this->Report($sOperationDesc.' / duration: '.round($fDuration, 3));
}
if (self::$m_bEnabled_Memory)
{
$iMemory = self::memory_get_usage();
$iMemoryUsed = $iMemory - $this->m_iInitialMemory;
$this->Report($sOperationDesc.' / memory: '.self::MemStr($iMemoryUsed).' (Total: '.self::MemStr($iMemory).')');
if (function_exists('memory_get_peak_usage'))
{
$iMemoryPeak = memory_get_peak_usage();
$this->Report($sOperationDesc.' / memory peak: '.self::MemStr($iMemoryPeak));
}
}
$this->ResetCounters();
}
public function ComputeStats($sOperation, $sArguments)
{
if (self::$m_bEnabled_Duration)
{
$fStopped = MyHelpers::getmicrotime();
$fDuration = $fStopped - $this->m_fStarted;
self::$m_aStats[$sOperation][$sArguments][] = $fDuration;
}
}
protected function ResetCounters()
{
if (self::$m_bEnabled_Duration)
{
$this->m_fStarted = MyHelpers::getmicrotime();
}
if (self::$m_bEnabled_Memory)
{
$this->m_iInitialMemory = self::memory_get_usage();
}
}
protected function Report($sText)
{
echo "$sText<br/>\n";
}
static protected function MemStr($iMemory)
{
return round($iMemory / 1024).' Kb';
}
static protected function memory_get_usage()
{
if (function_exists('memory_get_usage'))
{
return memory_get_usage(true);
}
// Copied from the PHP manual
//
//If its Windows
//Tested on Win XP Pro SP2. Should work on Win 2003 Server too
//Doesn't work for 2000
//If you need it to work for 2000 look at http://us2.php.net/manual/en/function.memory-get-usage.php#54642
if (substr(PHP_OS,0,3) == 'WIN')
{
$output = array();
exec('tasklist /FI "PID eq ' . getmypid() . '" /FO LIST', $output);
return preg_replace( '/[\D]/', '', $output[5] ) * 1024;
}
else
{
//We now assume the OS is UNIX
//Tested on Mac OS X 10.4.6 and Linux Red Hat Enterprise 4
//This should work on most UNIX systems
$pid = getmypid();
exec("ps -eo%mem,rss,pid | grep $pid", $output);
$output = explode(" ", $output[0]);
//rss is given in 1024 byte units
return $output[1] * 1024;
}
}
}
?>

146
core/log.class.inc.php Normal file
View File

@@ -0,0 +1,146 @@
<?php
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* File logging
*
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
class FileLog
{
protected $m_sFile = ''; // log is disabled if this is empty
public function __construct($sFileName = '')
{
$this->m_sFile = $sFileName;
}
public function Error($sText)
{
self::Write("Error | ".$sText);
}
public function Warning($sText)
{
self::Write("Warning | ".$sText);
}
public function Info($sText)
{
self::Write("Info | ".$sText);
}
public function Ok($sText)
{
self::Write("Ok | ".$sText);
}
protected function Write($sText)
{
if (strlen($this->m_sFile) == 0) return;
$hLogFile = @fopen($this->m_sFile, 'a');
if ($hLogFile !== false)
{
$sDate = date('Y-m-d H:i:s');
fwrite($hLogFile, "$sDate | $sText\n");
fclose($hLogFile);
}
}
}
class SetupLog
{
protected static $m_oFileLog;
public static function Enable($sTargetFile)
{
self::$m_oFileLog = new FileLog($sTargetFile);
}
public static function Error($sText)
{
self::$m_oFileLog->Error($sText);
}
public static function Warning($sText)
{
self::$m_oFileLog->Warning($sText);
}
public static function Info($sText)
{
self::$m_oFileLog->Info($sText);
}
public static function Ok($sText)
{
self::$m_oFileLog->Ok($sText);
}
}
class IssueLog
{
protected static $m_oFileLog;
public static function Enable($sTargetFile)
{
self::$m_oFileLog = new FileLog($sTargetFile);
}
public static function Error($sText)
{
self::$m_oFileLog->Error($sText);
}
public static function Warning($sText)
{
self::$m_oFileLog->Warning($sText);
}
public static function Info($sText)
{
self::$m_oFileLog->Info($sText);
}
public static function Ok($sText)
{
self::$m_oFileLog->Ok($sText);
}
}
class ToolsLog
{
protected static $m_oFileLog;
public static function Enable($sTargetFile)
{
self::$m_oFileLog = new FileLog($sTargetFile);
}
public static function Error($sText)
{
self::$m_oFileLog->Error($sText);
}
public static function Warning($sText)
{
self::$m_oFileLog->Warning($sText);
}
public static function Info($sText)
{
self::$m_oFileLog->Info($sText);
}
public static function Ok($sText)
{
self::$m_oFileLog->Ok($sText);
}
}
?>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,37 @@
<?php
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* Class ModuleHandler
* Defines the API to implement module specific actions during page execution
*
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
abstract class ModuleHandlerAPI
{
public static function OnMetaModelStarted()
{
}
public static function OnMenuCreation()
{
}
}
?>

Some files were not shown because too many files have changed in this diff Show More