Compare commits

...

139 Commits
0.7.1 ... 0.8

Author SHA1 Message Date
Romain Quetiez
2d8f9a77e7 Released 0.8 the 1st of october
SVN:0.8[193]
2009-10-19 14:48:20 +00:00
Romain Quetiez
f885fae267 Finalizing sample data: removed the unused profile
SVN:code[189]
2009-10-01 16:40:06 +00:00
Romain Quetiez
0ff9788ccb Added sample data: service calls, known errors, infra grouping, and some links (e.g. contact/team)
SVN:code[188]
2009-10-01 14:27:51 +00:00
Romain Quetiez
7461cb3fd5 Welcome menu updated with Erwan's text (quickly reviewed)
SVN:code[187]
2009-09-30 13:30:13 +00:00
Romain Quetiez
2e3bcef593 Added new sample data (forgotten from last commit)
SVN:code[186]
2009-09-30 13:00:30 +00:00
Romain Quetiez
3210573143 Integrated the latest data model and sample data
SVN:code[185]
2009-09-29 16:12:40 +00:00
Romain Quetiez
0f0113e578 Temporarily removed the TAB "OQL query", until it gets finalized with the link management
SVN:code[184]
2009-09-28 08:45:01 +00:00
Romain Quetiez
dc9707ec4b Fixed inconsistency in the CSV import : a bixServer objects had two fields (one was inherited) having the same label, leading to a high level of confusion when doing a bulk load (matching the fields was not possible)
SVN:code[183]
2009-09-22 14:13:07 +00:00
Romain Quetiez
7e7072b1ec Fixed bug in CSV import: was not working when using private keys. Also fine tuned the field matching mechanism and now the CSV export/import are 100% symmetric
SVN:code[182]
2009-09-22 13:36:29 +00:00
Romain Quetiez
2e9f13c4c5 Deletion of objects:
- automatic delete of mandatory ext keys, and if the option is set in the data model (I've set the "manual" option by default, and the "auto" option for links)
- automatic reset of optional ext keys (several keys could be updated on one single object)
- takes into account the user rights
- security against the use of page arguments when the automatic deletion is not allowed
Known limitations:
- does not check that resetting an ext key could affect the lifecycle consistency (e.g. delete a workgroup referenced by a ticket)
- does not check recursively on the automatic deletion, which should not be a problem given the current data model (TBC)

SVN:code[181]
2009-09-18 16:12:38 +00:00
Romain Quetiez
637993e7eb Fixed bug on deletion: take the inheritance into account when checking for referencing objects (eg. a ticket linked to a PC was not seen)
SVN:code[180]
2009-09-18 09:35:21 +00:00
Romain Quetiez
e176e2090c CSV import now based on the "bulk modify" user access rights
SVN:code[179]
2009-09-17 15:57:27 +00:00
Romain Quetiez
c641161e17 Fixed a security hole: any user was allowed to edit users and profiles, and therefore could give himself admin rights - now, only admins are allowed to do that
Also added a debugging capability: user rights shown for any object class, on demand in URP_Users::DisplayBareRelations()

SVN:code[178]
2009-09-17 15:50:28 +00:00
Romain Quetiez
d299fd451a Fixed regression on access control for the stimuli (also ipmlemented a workaround to a bug with the mantatory link attributes)
SVN:code[177]
2009-09-17 13:38:25 +00:00
Romain Quetiez
5e757db532 Cosmetic: Now that we request a confirmation on Delete, show the option as 'Delete...'
SVN:code[176]
2009-09-17 12:51:34 +00:00
Romain Quetiez
abbc21b0cb Fixed bug when creating a login (flush privileges = reset the data cache)
SVN:code[175]
2009-09-17 12:50:33 +00:00
Romain Quetiez
723341d94a Plugged in the allowed values management into the modification form and the stimulus form (limitation: take care with the data model and fields that depend on each other, until we replace those forms with the wizard that is currently being used for the object creation)
SVN:code[174]
2009-09-17 08:56:07 +00:00
Romain Quetiez
aea6f2e86f Forgotten from commit Nr 169
SVN:code[173]
2009-09-17 08:02:59 +00:00
Denis Flaven
d809170a51 Correct "script" tag... just in case...
SVN:code[172]
2009-09-16 16:09:46 +00:00
Denis Flaven
96e2732015 - Allowed values is now implemented, so I removed the comment !
SVN:code[171]
2009-09-16 16:08:52 +00:00
Denis Flaven
0bbe615664 - Fix for Internet Explorer: Arrays must be properly closed!
SVN:code[170]
2009-09-16 16:07:28 +00:00
Romain Quetiez
103f5e4568 User Management: removed limitation on the user rights that could not be established without a given object set, and added a feedback in the user details page (grant summary, based on the results returned by the std user management API, thus is reliable)
SVN:code[169]
2009-09-16 16:01:12 +00:00
Romain Quetiez
152b97a24a Fixed a regression: autocomplete not working due to a change in the execution of the script rendered in Ajax
SVN:code[168]
2009-09-16 15:00:40 +00:00
Denis Flaven
427a8eb596 - removed debug trace
SVN:code[167]
2009-09-16 14:14:15 +00:00
Romain Quetiez
cc8e80240f Fixed wrong file path for the graphs (lifecyle), could not work but on a Windows platform
SVN:code[166]
2009-09-16 08:48:54 +00:00
Romain Quetiez
91717f3f3b New menus (source: Erwan)
SVN:code[165]
2009-09-16 08:39:02 +00:00
Romain Quetiez
27965cc922 Fixed a regression on the management of the allowed values and attribute dependencies (symptom: Browse button not working, error when creating a ticket with no CI attached to it)
SVN:code[164]
2009-09-16 08:03:42 +00:00
Romain Quetiez
199a4865a4 Disabled the features not finalized (cloning, bookmarking, bulk operations)
SVN:code[163]
2009-09-16 07:59:11 +00:00
Romain Quetiez
7e93b35215 Fixed regression: ticket "impact" was reset ; resulting from a conflict in the form fields names (impact used both in the main detail form and into hidden links forms)
SVN:code[162]
2009-09-16 07:56:14 +00:00
Romain Quetiez
4517c61049 Fixed regression: server status was reset
SVN:code[161]
2009-09-16 07:53:12 +00:00
Denis Flaven
56c70ee33b - New cache management for the lifecycle graphs
SVN:code[160]
2009-09-14 16:50:51 +00:00
Romain Quetiez
76af2bb997 Cosmetics on the bulk load (followed new test plan)
SVN:code[159]
2009-09-14 16:06:04 +00:00
Romain Quetiez
56060ccb80 New business model (Erwan)
SVN:code[158]
2009-09-14 16:04:12 +00:00
Romain Quetiez
4496dad999 Cosmetic: display the stimulus label in the profile grants sumary
SVN:code[157]
2009-09-14 08:55:41 +00:00
Romain Quetiez
3fa3bfc260 Fixed bug: could not empty a field
SVN:code[156]
2009-09-14 08:40:28 +00:00
Romain Quetiez
f618678044 Hyperlinks in the history logs presentation
SVN:code[155]
2009-09-14 08:38:52 +00:00
Romain Quetiez
aa7e93e80c Revised the CSV import: fixed issues with the external keys, added hyperlinks to the found objects, obsoleted the word 'pkey', replaced by 'id'
SVN:code[154]
2009-09-14 08:37:10 +00:00
Denis Flaven
07af5501c5 Disabled automatic population of Zlists which was buggy. Not all ZLists are made of AttCode !
SVN:code[153]
2009-09-12 19:58:20 +00:00
Denis Flaven
07b4040c9e - Removed debug output into the console thats breaks when Firebug is not installed (or on IE)
SVN:code[152]
2009-09-12 10:08:13 +00:00
Denis Flaven
8d76f47303 - 'Add...' butotn is now grayed when there is nothing to Add
- Better handling of AllowedValues, supporting autocompletes
- Cleanup unused code in wizard.utils.js

SVN:code[151]
2009-09-11 21:23:24 +00:00
Denis Flaven
d922b4c7f3 Field validation now preserves background images
SVN:code[150]
2009-09-11 21:20:45 +00:00
Denis Flaven
be825be157 - Automatic adjustment of the width and height of the ModalDlg to fit the document's size
SVN:code[149]
2009-09-11 20:36:34 +00:00
Denis Flaven
7e57ea5365 Implementation of AllowedValues for fields that depend on other fields
SVN:code[148]
2009-09-11 20:35:16 +00:00
Romain Quetiez
40489c0821 New class: bizSubnet, implementing a dedicated view for IP management
SVN:code[147]
2009-09-11 16:38:12 +00:00
Romain Quetiez
ea59cf0fa8 Improve the UI on object deletion: added a confirmation form and do check the dependencies so as to preserve the DB integrity
SVN:code[146]
2009-09-11 15:44:24 +00:00
Romain Quetiez
e81dd420a1 Bug fix - object creation
SVN:code[145]
2009-09-11 15:34:40 +00:00
Romain Quetiez
6115797eb0 Work in progress for integration of "allowed values"
SVN:code[144]
2009-09-11 15:33:06 +00:00
Romain Quetiez
2bbcf30e2d Added INET_ATON and INET_NTOA verbs to the OQL, and allowed carrier returns chars (\r) in the OQL (same as a whitespace)
SVN:code[143]
2009-09-11 12:38:46 +00:00
Romain Quetiez
4c33a6eb81 Fixed bug in the history of tickets (incident or any other type, for which the name is based on the ticket ID, which remained undetermined until the record is created)
SVN:code[142]
2009-09-11 12:03:34 +00:00
Romain Quetiez
455c703468 Fixed a stopper bug in the display of N-N links from the default object display procedure (not using templates)
SVN:code[141]
2009-09-11 08:42:57 +00:00
Denis Flaven
7618c38a05 Added the validation of mandatory form fields before submitting the creation / modification / clone forms.
SVN:code[140]
2009-09-11 06:01:32 +00:00
Romain Quetiez
c5cc6f34f8 Fixed bug on Update / WriteLinks
SVN:code[139]
2009-09-10 16:20:35 +00:00
Romain Quetiez
874019c32a fixed interface of DisplaySet function
SVN:code[138]
2009-09-10 16:01:28 +00:00
Denis Flaven
76787fd9fb Proper handling of the parameters to DisplaySet
SVN:code[137]
2009-09-10 15:34:07 +00:00
Denis Flaven
8f2ea080d9 - Fixed the "modify" screen to have the "wizard look (thin green border)
SVN:code[136]
2009-09-10 15:33:31 +00:00
Denis Flaven
8094e3083e Proper handling of the parameters to DisplaySet
SVN:code[135]
2009-09-10 15:32:29 +00:00
Romain Quetiez
a5a1ae756f Fixed issue with Date fields being mandatory (DB column created with attribute ON UPDATE CURRENT_TIMESTAMP)
SVN:code[134]
2009-09-10 14:29:29 +00:00
Romain Quetiez
e5d9ede18a Integrated data model changes to the data load (incidents/contracts and persons were not correctly loaded
SVN:code[133]
2009-09-10 14:28:08 +00:00
Denis Flaven
2a6de0bd28 Added an automatic naming for the change tickets based on their Id (Same as for Incident tickets but starting with C-).
SVN:code[132]
2009-09-10 14:08:22 +00:00
Denis Flaven
858e32065c Fixed the icon of date input fields
SVN:code[131]
2009-09-10 14:04:14 +00:00
Denis Flaven
c4a6f869ea - Fix the style of the loaded table
SVN:code[130]
2009-09-10 13:20:53 +00:00
Romain Quetiez
3c8cbeb170 Fixed cosmetic issue on the user management pages (wrong styles in the templates)
SVN:code[129]
2009-09-10 11:14:10 +00:00
Romain Quetiez
bfc2df25d7 Fixed issue: user always considered as being an admin (regression due to changes in the setup), user profile setup is finally done at 100% in the setup code.
SVN:code[128]
2009-09-10 10:58:45 +00:00
Denis Flaven
e7c7bda520 Use the latest version (unmodified) of autocomplete instead of an old - and customized - version.
SVN:code[127]
2009-09-10 09:03:16 +00:00
Denis Flaven
3025a01e88 Use the latest version (unmodified) of autocomplete instead of an old - and customized - version.
SVN:code[126]
2009-09-10 08:58:07 +00:00
Denis Flaven
dff00d7a7a Use the latest version (unmodified) of autocomplete instead of an old - and customized - version.
SVN:code[125]
2009-09-10 08:56:20 +00:00
Romain Quetiez
242ccc37d3 Added a logoff button
SVN:code[124]
2009-09-09 15:06:14 +00:00
Romain Quetiez
801a108e6b Cosmetics on the run query page
SVN:code[123]
2009-09-09 12:44:06 +00:00
Romain Quetiez
e0c7620560 Improved the run query page: added meaningfull examples, including "ticket of the user currently logged in", and did some cosmetics on the page (examples shown in a drawer) ; needed to add some options to the OQL (date intervals)
SVN:code[122]
2009-09-08 15:10:31 +00:00
Romain Quetiez
b11bfff1f5 Reworked the "run query" page: renamed, improved the examples
SVN:code[121]
2009-09-08 09:25:57 +00:00
Romain Quetiez
93cad0ef6c Finalized attribute labels in the business data model (each word in uppercase, same conventions on external keys)
SVN:code[120]
2009-09-08 08:29:57 +00:00
Romain Quetiez
ab801850dd Latest data model (Erwan) and few cosmetic changes (safer display of object hyperlinks)
SVN:code[119]
2009-09-07 14:29:49 +00:00
Romain Quetiez
3d4b45de26 Audit rules loaded as part of the structure of the application
SVN:code[118]
2009-09-07 14:25:04 +00:00
Denis Flaven
37cad7579e - Proper display on the n-n links
SVN:code[117]
2009-09-07 14:00:25 +00:00
Denis Flaven
4d1a5209db - Adjusted size of the CSV export
- nicer display for the modification of objects

SVN:code[116]
2009-09-07 13:58:53 +00:00
Denis Flaven
565891ce1c - Workaround for noit taking search parameters into account when displaying linked items.
SVN:code[115]
2009-09-07 13:57:12 +00:00
Denis Flaven
0b91c4724b - Style for auto-complete fields
SVN:code[114]
2009-09-07 13:54:45 +00:00
Denis Flaven
3849da02ac Limit the size of the table to fit the screen.
SVN:code[113]
2009-09-07 13:35:09 +00:00
Denis Flaven
657987f365 - Style for auto-complete fields
SVN:code[112]
2009-09-07 12:19:33 +00:00
Denis Flaven
18c875a326 Background image for auto-complete fields
SVN:code[111]
2009-09-07 12:18:09 +00:00
Romain Quetiez
6c286bf952 Finalization of the user management by profile (UI to manage the accounts), and some unrelated changes:
- Using class labels in the UI
- Data model: you may specify a set of allowed values from a query (see caller_id in bizIncident class), still not 100% used in the UI but does not generate any error
- Data model: you may specify a password field (AttributePassword replacing AttributeString)
- Setup: calling UserRight::Setup() right after calling UserRight::CreateAdministrator()
- Setup: administrator account created with "my organization" and a dedicated contact
- Menus: optimized the load of std menus (queries written in OQL to get the benefit of the query cache)
- Menus: admin tools, seen only by people having the "admin" profile
- Object edition: fixed bug with the display of N-N links in the form

SVN:code[110]
2009-09-04 15:22:40 +00:00
Romain Quetiez
a096d46a59 Improved the behavior when a link class to not have any other attributes than the external keys. Still, it requires some work to have this configuration working.
SVN:code[109]
2009-09-02 13:39:20 +00:00
Romain Quetiez
5cfcc1f516 In the UI, the class names have been replaced by the class labels
SVN:code[108]
2009-09-02 13:18:59 +00:00
Romain Quetiez
5ee94f9d3d Changed images paths into relative path (../images where it was still /images)
SVN:code[107]
2009-08-27 13:56:57 +00:00
Romain Quetiez
6cc4ab7e9d Fixed bug provoking a warning unseen so far but it was causing a fatal error during the installation, with IIS as web server
SVN:code[106]
2009-08-27 13:52:31 +00:00
Denis Flaven
dffab33080 Workaround for the missing REQUEST_URI on IIS
SVN:code[105]
2009-08-27 12:37:21 +00:00
Denis Flaven
31415e2482 - New user interface to manage n-n links
SVN:code[104]
2009-08-26 21:52:34 +00:00
Denis Flaven
cba7b556bd Fixed a missing display template
SVN:code[103]
2009-08-26 21:32:32 +00:00
Denis Flaven
d2a6a116b1 Fixed the disappearance of tabs when doing a 'reload'
SVN:code[102]
2009-08-25 19:48:37 +00:00
Denis Flaven
9130e5bcd0 New helper function IsModified
SVN:code[101]
2009-08-25 13:52:13 +00:00
Romain Quetiez
bc5ab17525 Improved the data load during the setup:
- Sample data are clearly separated from the structure data (inc. menus and user profiles)
- Both categories of data are enumerated from specific folders

SVN:code[100]
2009-08-24 16:40:11 +00:00
Denis Flaven
1a47af8c7b - Do NOT rely on PHP short open tags, for a better compatibility
- In case of exception, display the whole error string even if it contains HTML tags, sometimes ugly but sometimes VERY useful

SVN:code[99]
2009-08-22 09:52:12 +00:00
Denis Flaven
b4dbcbe9d8 Do NOT use PHP short open tags for a better compatibility
SVN:code[98]
2009-08-22 09:49:44 +00:00
Denis Flaven
1a3d8558c1 Do NOT use PHP short open tags for a better compatibility
SVN:code[97]
2009-08-22 09:49:13 +00:00
Denis Flaven
3cd364ab4b Make sure that we catch exceptions that may occur during the setup.
SVN:code[96]
2009-08-22 09:48:03 +00:00
Romain Quetiez
6c70bc4f03 Fixed issue #28, objects not created by the CSV import because mandatory external keys are not in the column set.
SVN:code[95]
2009-08-21 15:20:35 +00:00
Denis Flaven
852c063868 session_is_register is deprecated since PHP 5.3.0
SVN:code[94]
2009-08-21 13:57:38 +00:00
Romain Quetiez
2221709cc3 Finalized the module "user rights by profile". It is fully integrated with the application setup (inc. sample data). and it it now ready for developing the user management GUI
SVN:code[93]
2009-08-20 13:09:41 +00:00
Denis Flaven
0dc67869b5 - New search form allowing to perform OQL queries for any class of object
SVN:code[92]
2009-08-18 18:51:17 +00:00
Denis Flaven
8cf0103a0a - Improvements to the history log for large text fields
SVN:code[91]
2009-08-17 18:24:26 +00:00
Romain Quetiez
80a0d27cb0 User management by profile ready for integration with the UI
and some caching has been implemented for the building of queries (both from an OQL or from a programmatic query)

SVN:code[90]
2009-07-31 13:18:44 +00:00
Denis Flaven
59db699684 - Better display of the archives/change log on each object (Trac ticket #9)
SVN:code[89]
2009-07-24 15:44:51 +00:00
Romain Quetiez
367e678ff9 User management by profile moving forward: pages to check the projection of objects/users in user defined dimensions
Introduced parameters in OQL (:myvar)
Added the verb MetaModel::IsValidObject($oMyObj)

SVN:code[88]
2009-07-24 13:14:51 +00:00
Romain Quetiez
6659728058 Initialized dev of the user rights managed by profiles, it is still not usable by the application, but its data model is likely to be stable.
SVN:code[87]
2009-07-21 08:48:30 +00:00
Denis Flaven
a8d04b8a2e - new test case for JOINs
SVN:code[86]
2009-07-20 13:41:21 +00:00
Denis Flaven
650e5fcbd8 - Fixed bug #31: HTML display in the "export" page uses the appropriate stylesheet.
SVN:code[85]
2009-07-19 09:34:32 +00:00
Denis Flaven
039edd245d - enhancement: trap exceptions to keep a nice display in case of error
SVN:code[84]
2009-07-19 09:32:44 +00:00
Denis Flaven
4eb723b073 - reintegrated the changes (mostly bug fixes) from the 0.7.2 branch
SVN:code[83]
2009-07-18 17:24:25 +00:00
Denis Flaven
62fa1bfbf6 - Bug fix: emailed URL was still wrong for lists of objects
SVN:code[82]
2009-07-18 13:27:05 +00:00
Denis Flaven
85222612a9 - Bug fix: added the missing display template
SVN:code[81]
2009-07-16 06:49:33 +00:00
Denis Flaven
c4687e5899 - Fixed audit menu
- Removed backup/restore menu that is not working...
- Moved 'export' to the 'webservices' directory

SVN:code[80]
2009-07-08 16:13:10 +00:00
Denis Flaven
560345247e - The page was broken because there was no user login !
SVN:code[79]
2009-07-08 16:10:17 +00:00
Denis Flaven
48b63973a3 - The page was broken because there was no user login !
SVN:code[78]
2009-07-08 16:09:01 +00:00
Denis Flaven
fc15934dd0 - Fixed location of the "audit" page in the menu. Was broken if iTop was not installed at the root of the web server.
SVN:code[77]
2009-07-08 16:07:51 +00:00
Denis Flaven
6ef3961567 Fixed bug #24: choice of organizations was limited to organization in "implementation".
SVN:code[76]
2009-07-08 15:05:54 +00:00
Denis Flaven
0841f8f2d9 Fixed bug #24: choice of organizations was limited to organization in "implementation".
SVN:code[75]
2009-07-08 14:53:53 +00:00
Denis Flaven
9577fb5dd9 Incremented version number to 0.7.2
SVN:code[74]
2009-06-27 08:33:47 +00:00
Denis Flaven
427ccbe14c - bug fix: Ticket #1 (Life Cycle Schema not displayed)
SVN:code[73]
2009-06-27 08:32:46 +00:00
Denis Flaven
6520653306 - Bug fix: Ticket #2 (User rights not applied properly)
SVN:code[72]
2009-06-27 08:31:31 +00:00
Denis Flaven
c8b9954eef - Bug fix: Ticket #2 (User rights not applied properly)
SVN:code[71]
2009-06-27 08:30:13 +00:00
Denis Flaven
35a4611959 - Enhancement: display the current user's name in the top part of the window
SVN:code[70]
2009-06-27 08:28:58 +00:00
Denis Flaven
94904537ad - Bug fix: Ticket #3 (email hyperlink was wrong)
SVN:code[69]
2009-06-27 08:27:44 +00:00
Denis Flaven
5c55ffabf9 Fix for Ticket #22 (impossible to create change or incident tickets)
SVN:code[68]
2009-06-26 14:33:48 +00:00
Denis Flaven
46b8606b63 Fix for Ticket #22 (impossible to create change or incident tickets)
SVN:code[67]
2009-06-26 14:32:13 +00:00
Denis Flaven
b41421737e - Fixed sample data
SVN:code[66]
2009-06-26 12:56:04 +00:00
Denis Flaven
08cf5a8600 Preparing release 0.7.2
SVN:code[65]
2009-06-26 12:42:51 +00:00
Romain Quetiez
e8ec2968b3 CSVImport: Removed calls to deprecated method GetHyperLink
SVN:code[64]
2009-04-30 16:05:20 +00:00
Denis Flaven
74626cfe73 Removed CSVParser since the "old" version is already present in the CSV import page...
SVN:code[63]
2009-04-30 06:04:38 +00:00
Denis Flaven
8521f36fa2 Preparing to release 0.7.1
SVN:code[62]
2009-04-29 20:49:08 +00:00
Denis Flaven
dd95a1fcac Use non realistic persons...
SVN:code[61]
2009-04-29 20:38:51 +00:00
Denis Flaven
f126590165 Fixed bugs:
2783651 - New object - finalclass field is editable
2783643 - Number of objects displayed on result lists takes too much space
2783638 - PHP internal class name displayed in templates instead of class label
2783631 - Page "Admin tools/Backup-Restore" not working, removed !
2783629 - Menu "Admin Tools/Export" not working
2783625 - Cosmetics on new object wizard title

SVN:code[60]
2009-04-29 20:34:00 +00:00
Denis Flaven
b08ac55d93 New intermediate version
SVN:code[59]
2009-04-29 19:39:17 +00:00
Denis Flaven
0126c1322e Fixed bugs linked to the bookmark creation:
- There must be a user specific menu entry in the list of menuNodes
- The asynchronous ajax page must use the authentication stored in the session
- The query must be stored in OQL instead of sibusQL

SVN:code[58]
2009-04-28 13:24:12 +00:00
Denis Flaven
5ca45d7a82 Fixed bugs linked to the bookmark creation:
- There must be a user specific menu entry in the list of menuNodes
- The asynchronous ajax page must use the authentication stored in the session
- The query must be stored in OQL instead of sibusQL

SVN:code[57]
2009-04-28 11:52:38 +00:00
Denis Flaven
4c1156df76 SVN:code[56] 2009-04-28 11:30:40 +00:00
Denis Flaven
6545595f19 Moved under "trunk" to be able to track releases under "tags"
SVN:code[55]
2009-04-28 09:03:12 +00:00
Denis Flaven
27c05b460b Well identified releases of itop
SVN:code[54]
2009-04-28 08:53:56 +00:00
Denis Flaven
6e519e592f Main trunk (i.e. latest development version) of itop
SVN:code[53]
2009-04-28 08:52:21 +00:00
Romain Quetiez
a4663ebed1 Optimized the setup (not only), shortened to 37s (used to be 120s)
- DBObject::DBInsert(Tracked)NoReload() must be used when it is not required to use the object
- MetaModel::GetObject() has a cache, the operation is 5 times faster
- Changes tracking do not store the initial value, but only value changes
Reworked the CSV import to have it rely on the bulk change API
Bulk change to check the external keys (DB integrity)
Replaced trigger_error (Core only!) by the use of Exceptions (still, some new Exception classes should be defined)
Unit tests do display the call stack in a user friendly format

SVN:code[52]
2009-04-27 07:27:54 +00:00
1720 changed files with 194499 additions and 15 deletions

View File

@@ -270,6 +270,29 @@ class UserRightsMatrix extends UserRightsAddOnAPI
}
}
}
// Create the "My Bookmarks" menu item (parent_id = 0, rank = 6)
if ($bNewUser)
{
$bAddMenu = true;
}
else
{
$oSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT menuNode WHERE type = 'user' AND parent_id = 0 AND user_id = $iUserId"));
$bAddMenu = ($oSet->Count() < 1);
}
if ($bAddMenu)
{
$oMenu = MetaModel::NewObject('menuNode');
$oMenu->Set('type', 'user');
$oMenu->Set('parent_id', 0); // It's a toplevel entry
$oMenu->Set('rank', 6); // Located just above the Admin Tools section (=7)
$oMenu->Set('name', 'My Bookmarks');
$oMenu->Set('label', 'My Favorite Items');
$oMenu->Set('hyperlink', 'UI.php');
$oMenu->Set('template', '<p></p><p></p><p style="text-align:center; font-family:Georgia, Times, serif; font-size:32px;">My bookmarks</p><p style="text-align:center; font-family:Georgia, Times, serif; font-size:14px;"><i>This section contains my most favorite search results</i></p>');
$oMenu->Set('user_id', $iUserId);
$oMenu->DBInsert();
}
}

View File

@@ -0,0 +1,649 @@
<?php
require_once('../core/cmdbobject.class.inc.php');
require_once('../application/utils.inc.php');
require_once('../application/applicationcontext.class.inc.php');
require_once('../application/ui.linkswidget.class.inc.php');
////////////////////////////////////////////////////////////////////////////////////
/**
* Abstract class that implements some common and useful methods for displaying
* the objects
*/
////////////////////////////////////////////////////////////////////////////////////
abstract class cmdbAbstractObject extends CMDBObject
{
public static function GetUIPage()
{
return './UI.php';
}
public static function ComputeUIPage($sClass)
{
static $aUIPagesCache = array(); // Cache to store the php page used to display each class of object
if (!isset($aUIPagesCache[$sClass]))
{
$UIPage = false;
if (is_callable("$sClass::GetUIPage"))
{
$UIPage = eval("return $sClass::GetUIPage();"); // May return false in case of error
}
$aUIPagesCache[$sClass] = $UIPage === false ? './UI.php' : $UIPage;
}
$sPage = $aUIPagesCache[$sClass];
return $sPage;
}
protected static function MakeHyperLink($sObjClass, $sObjKey, $aAvailableFields)
{
$oAppContext = new ApplicationContext();
$sExtClassNameAtt = MetaModel::GetNameAttributeCode($sObjClass);
$sPage = self::ComputeUIPage($sObjClass);
// Use the "name" of the target class as the label of the hyperlink
// unless it's not available in the external attributes...
if (isset($aAvailableFields[$sExtClassNameAtt]))
{
$sLabel = $aAvailableFields[$sExtClassNameAtt];
}
else
{
$sLabel = implode(' / ', $aAvailableFields);
}
$sHint = htmlentities("$sObjClass::$sObjKey");
return "<a href=\"$sPage?operation=details&class=$sObjClass&id=$sObjKey&".$oAppContext->GetForLink()."\" title=\"$sHint\">$sLabel</a>";
}
public function GetDisplayValue($sAttCode)
{
$sDisplayValue = "";
$sStateAttCode = MetaModel::GetStateAttributeCode(get_class($this));
if ($sStateAttCode == $sAttCode)
{
$aStates = MetaModel::EnumStates(get_class($this));
$sDisplayValue = $aStates[$this->Get($sAttCode)]['label'];
}
else
{
$oAtt = MetaModel::GetAttributeDef(get_class($this), $sAttCode);
if ($oAtt->IsExternalKey())
{
// retrieve the "external fields" linked to this external key
$sTargetClass = $oAtt->GetTargetClass();
$aAvailableFields = array();
foreach (MetaModel::GetExternalFields(get_class($this), $sAttCode) as $oExtField)
{
$aAvailableFields[$oExtField->GetExtAttCode()] = $oExtField->GetAsHTML($this->Get($oExtField->GetCode()));
}
$sExtClassNameAtt = MetaModel::GetNameAttributeCode($sTargetClass);
// Use the "name" of the target class as the label of the hyperlink
// unless it's not available in the external fields...
if (isset($aAvailableFields[$sExtClassNameAtt]))
{
$sDisplayValue = $aAvailableFields[$sExtClassNameAtt];
}
else
{
$sDisplayValue = implode(' / ', $aAvailableFields);
}
}
else
{
$sDisplayValue = $this->GetAsHTML($sAttCode);
}
}
return $sDisplayValue;
}
function DisplayBareDetails(web_page $oPage)
{
$oPage->add($this->GetBareDetails($oPage));
}
function GetDisplayName()
{
return $this->GetAsHTML(MetaModel::GetNameAttributeCode(get_class($this)));
}
function GetBareDetails(web_page $oPage)
{
$sHtml = '';
$oAppContext = new ApplicationContext();
$sStateAttCode = MetaModel::GetStateAttributeCode(get_class($this));
$aDetails = array();
$sClass = get_class($this);
$aList = MetaModel::GetZListItems($sClass, 'details');
foreach($aList as $sAttCode)
{
$iFlags = $this->GetAttributeFlags($sAttCode);
if ( ($iFlags & OPT_ATT_HIDDEN) == 0)
{
// The field is visible in the current state of the object
if ($sStateAttCode == $sAttCode)
{
// Special display for the 'state' attribute itself
$sDisplayValue = $this->GetState();
}
else
{
$sDisplayValue = $this->GetAsHTML($sAttCode);
}
$aDetails[] = array('label' => MetaModel::GetLabel($sClass, $sAttCode), 'value' => $sDisplayValue);
}
}
$sHtml .= $oPage->GetDetails($aDetails);
return $sHtml;
}
function DisplayDetails(web_page $oPage)
{
$sTemplate = Utils::ReadFromFile(MetaModel::GetDisplayTemplate(get_class($this)));
if (!empty($sTemplate))
{
$oTemplate = new DisplayTemplate($sTemplate);
$oTemplate->Render($oPage, array('class_name'=> MetaModel::GetName(get_class($this)),'class'=> get_class($this),'pkey'=> $this->GetKey(), 'name' => $this->GetName()));
}
else
{
// Standard Header with name, actions menu and history block
$oPage->add("<div class=\"page_header\">\n");
$oSingletonFilter = new DBObjectSearch(get_class($this));
$oSingletonFilter->AddCondition('pkey', array($this->GetKey()));
$oBlock = new MenuBlock($oSingletonFilter, 'popup', false);
$oBlock->Display($oPage, -1);
$oPage->add("<h1>".Metamodel::GetName(MetaModel::GetName(get_class($this))).": <span class=\"hilite\">".$this->GetDisplayName()."</span></h1>\n");
$oHistoryFilter = new DBObjectSearch('CMDBChangeOpSetAttribute');
$oHistoryFilter->AddCondition('objkey', $this->GetKey());
$oBlock = new HistoryBlock($oHistoryFilter, 'toggle', false);
$oBlock->Display($oPage, -1);
$oPage->add("</div>\n");
// Object's details
// template not found display the object using the *old style*
self::DisplayBareDetails($oPage);
// Related objects
$oPage->AddTabContainer('Related Objects');
$oPage->SetCurrentTabContainer('Related Objects');
foreach(MetaModel::ListAttributeDefs(get_class($this)) as $sAttCode=>$oAttDef)
{
if ((get_class($oAttDef) == 'AttributeLinkedSetIndirect') || (get_class($oAttDef) == 'AttributeLinkedSet'))
{
$oPage->SetCurrentTab($oAttDef->GetLabel());
$oPage->p($oAttDef->GetDescription());
if (get_class($oAttDef) == 'AttributeLinkedSet')
{
$sTargetClass = $oAttDef->GetLinkedClass();
$oFilter = new DBObjectSearch($sTargetClass);
$oFilter->AddCondition($oAttDef->GetExtKeyToMe(), $this->GetKey()); // @@@ condition has same name as field ??
$oBlock = new DisplayBlock($oFilter, 'list', false);
$oBlock->Display($oPage, 0);
}
else // get_class($oAttDef) == 'AttributeLinkedSetIndirect'
{
$sLinkClass = $oAttDef->GetLinkedClass();
// Transform the DBObjectSet into a CMBDObjectSet !!!
$aLinkedObjects = $this->Get($sAttCode)->ToArray(false);
if (count($aLinkedObjects) > 0)
{
$oSet = CMDBObjectSet::FromArray($sLinkClass, $aLinkedObjects);
$this->DisplaySet($oPage, $oSet, $oAttDef->GetExtKeyToMe());
}
}
}
}
$oPage->SetCurrentTab('');
}
}
function DisplayPreview(web_page $oPage)
{
$aDetails = array();
$sClass = get_class($this);
$aList = MetaModel::GetZListItems($sClass, 'preview');
foreach($aList as $sAttCode)
{
$aDetails[] = array('label' => MetaModel::GetLabel($sClass, $sAttCode), 'value' =>$this->GetAsHTML($sAttCode));
}
$oPage->details($aDetails);
}
// Comment by Rom: this helper may be used to display objects of class DBObject
// -> I am using this to display the changes history
public static function DisplaySet(web_page $oPage, CMDBObjectSet $oSet, $sLinkageAttribute = '')
{
$oPage->add(self::GetDisplaySet($oPage, $oSet, $sLinkageAttribute));
}
public static function GetDisplaySet(web_page $oPage, CMDBObjectSet $oSet, $sLinkageAttribute = '', $bDisplayMenu = true)
{
$sHtml = '';
$oAppContext = new ApplicationContext();
$sClassName = $oSet->GetFilter()->GetClass();
$aAttribs = array();
$aList = MetaModel::GetZListItems($sClassName, 'list');
if (!empty($sLinkageAttribute))
{
// The set to display is in fact a set of links between the object specified in the $sLinkageAttribute
// and other objects...
// The display will then group all the attributes related to the link itself:
// | Link_attr1 | link_attr2 | ... || Object_attr1 | Object_attr2 | Object_attr3 | .. | Object_attr_n |
$aAttDefs = MetaModel::ListAttributeDefs($sClassName);
assert(isset($aAttDefs[$sLinkageAttribute]));
$oAttDef = $aAttDefs[$sLinkageAttribute];
assert($oAttDef->IsExternalKey());
// First display all the attributes specific to the link record
foreach($aList as $sLinkAttCode)
{
$oLinkAttDef = $aAttDefs[$sLinkAttCode];
if ( (!$oLinkAttDef->IsExternalKey()) && (!$oLinkAttDef->IsExternalField()) )
{
$aDisplayList[] = $sLinkAttCode;
}
}
// Then display all the attributes neither specific to the link record nor to the 'linkage' object (because the latter are constant)
foreach($aList as $sLinkAttCode)
{
$oLinkAttDef = $aAttDefs[$sLinkAttCode];
if (($oLinkAttDef->IsExternalKey() && ($sLinkAttCode != $sLinkageAttribute))
|| ($oLinkAttDef->IsExternalField() && ($oLinkAttDef->GetKeyAttCode()!=$sLinkageAttribute)) )
{
$aDisplayList[] = $sLinkAttCode;
}
}
// First display all the attributes specific to the link
// Then display all the attributes linked to the other end of the relationship
$aList = $aDisplayList;
}
foreach($aList as $sAttCode)
{
$aAttribs['key'] = array('label' => '', 'description' => 'Click to display');
$aAttribs[$sAttCode] = array('label' => MetaModel::GetLabel($sClassName, $sAttCode), 'description' => MetaModel::GetDescription($sClassName, $sAttCode));
}
$aValues = array();
$oSet->Seek(0);
while ($oObj = $oSet->Fetch())
{
$aRow['key'] = $oObj->GetKey();
foreach($aList as $sAttCode)
{
$aRow[$sAttCode] = $oObj->GetAsHTML($sAttCode);
}
$aValues[] = $aRow;
}
$oMenuBlock = new MenuBlock($oSet->GetFilter());
$sHtml .= '<table class="listContainer">';
$sColspan = '';
if ($bDisplayMenu)
{
$sColspan = 'colspan="2"';
$sHtml .= '<tr class="containerHeader"><td>&nbsp;'.$oSet->Count().' object(s)</td><td>';
$sHtml .= $oMenuBlock->GetRenderContent($oPage, $sLinkageAttribute);
$sHtml .= '</td></tr>';
}
$sHtml .= "<tr><td $sColspan>";
$sHtml .= $oPage->GetTable($aAttribs, $aValues, array('class'=>$sClassName, 'filter'=>$oSet->GetFilter()->serialize(), 'preview' => true));
$sHtml .= '</td></tr>';
$sHtml .= '</table>';
return $sHtml;
}
static function DisplaySetAsCSV(web_page $oPage, CMDBObjectSet $oSet, $aParams = array())
{
$oPage->add(self::GetSetAsCSV($oSet, $aParams));
}
static function GetSetAsCSV(DBObjectSet $oSet, $aParams = array())
{
$sSeparator = isset($aParams['separator']) ? $aParams['separator'] : ','; // default separator is comma
$sTextQualifier = isset($aParams['text_qualifier']) ? $aParams['text_qualifier'] : '"'; // default text qualifier is double quote
$oAppContext = new ApplicationContext();
$sClassName = $oSet->GetFilter()->GetClass();
$aAttribs = array();
$aList = MetaModel::GetZListItems($sClassName, 'details');
$aHeader = array();
$aHeader[] = MetaModel::GetKeyLabel($sClassName);
foreach($aList as $sAttCode)
{
$aHeader[] = MetaModel::GetLabel($sClassName, $sAttCode);
}
$sHtml = '#'.$oSet->GetFilter()->ToOQL()."\n";
$sHtml .= implode($sSeparator, $aHeader)."\n";
$oSet->Seek(0);
while ($oObj = $oSet->Fetch())
{
$aRow = array();
$aRow[] = $oObj->GetKey();
foreach($aList as $sAttCode)
{
if (strstr($oObj->Get($sAttCode), $sSeparator)) // Escape the text only when it contains the separator
{
$aRow[] = $sTextQualifier.$oObj->Get($sAttCode).$sTextQualifier;
}
else
{
$aRow[] = $oObj->Get($sAttCode);
}
}
$sHtml .= implode($sSeparator, $aRow)."\n";
}
return $sHtml;
}
static function DisplaySetAsXML(web_page $oPage, CMDBObjectSet $oSet, $aParams = array())
{
$oAppContext = new ApplicationContext();
$sClassName = $oSet->GetFilter()->GetClass();
$aAttribs = array();
$aList = MetaModel::GetZListItems($sClassName, 'details');
$oPage->add("<Set>\n");
$oSet->Seek(0);
while ($oObj = $oSet->Fetch())
{
$oPage->add("<$sClassName id=\"".$oObj->GetKey()."\">\n");
foreach(MetaModel::ListAttributeDefs($sClassName) as $sAttCode=>$oAttDef)
{
if (($oAttDef->IsWritable()) && ($oAttDef->IsScalar()) && ($sAttCode != 'finalclass') )
{
$sValue = $oObj->GetAsXML($sAttCode);
$oPage->add("<$sAttCode>$sValue</$sAttCode>\n");
}
}
$oPage->add("</$sClassName>\n");
}
$oPage->add("</Set>\n");
}
// By rom
function DisplayChangesLog(web_page $oPage)
{
$oFltChangeOps = new CMDBSearchFilter('CMDBChangeOpSetAttribute');
$oFltChangeOps->AddCondition('objkey', $this->GetKey(), '=');
$oFltChangeOps->AddCondition('objclass', get_class($this), '=');
$oSet = new CMDBObjectSet($oFltChangeOps, array('date' => false)); // order by date descending (i.e. false)
$count = $oSet->Count();
if ($count > 0)
{
$oPage->p("Changes log ($count):");
self::DisplaySet($oPage, $oSet);
}
else
{
$oPage->p("Changes log is empty");
}
}
public static function DisplaySearchForm(web_page $oPage, CMDBObjectSet $oSet, $aExtraParams = array())
{
$oPage->add(self::GetSearchForm($oPage, $oSet, $aExtraParams));
}
public static function GetSearchForm(web_page $oPage, CMDBObjectSet $oSet, $aExtraParams = array())
{
$sHtml = '';
$numCols=4;
$sClassName = $oSet->GetFilter()->GetClass();
$oUnlimitedFilter = new DBObjectSearch($sClassName);
$sHtml .= "<form>\n";
$index = 0;
$sHtml .= "<table>\n";
$aFilterCriteria = $oSet->GetFilter()->GetCriteria();
$aMapCriteria = array();
foreach($aFilterCriteria as $aCriteria)
{
$aMapCriteria[$aCriteria['filtercode']][] = array('value' => $aCriteria['value'], 'opcode' => $aCriteria['opcode']);
}
$aList = MetaModel::GetZListItems($sClassName, 'standard_search');
foreach($aList as $sFilterCode)
{
if (($index % $numCols) == 0)
{
if ($index != 0)
{
$sHtml .= "</tr>\n";
}
$sHtml .= "<tr>\n";
}
$sFilterValue = '';
$sFilterValue = utils::ReadParam($sFilterCode, '');
$sFilterOpCode = null; // Use the default 'loose' OpCode
if (empty($sFilterValue))
{
if (isset($aMapCriteria[$sFilterCode]))
{
if (count($aMapCriteria[$sFilterCode]) > 1)
{
$sFilterValue = '* mixed *';
}
else
{
$sFilterValue = $aMapCriteria[$sFilterCode][0]['value'];
$sFilterOpCode = $aMapCriteria[$sFilterCode][0]['opcode'];
}
if ($sFilterCode != 'company')
{
$oUnlimitedFilter->AddCondition($sFilterCode, $sFilterValue, $sFilterOpCode);
}
}
}
$aAllowedValues = MetaModel::GetAllowedValues_flt($sClassName, $sFilterCode, array(), '');
if ($aAllowedValues != null)
{
//Enum field or external key, display a combo
$sValue = "<select name=\"$sFilterCode\">\n";
$sValue .= "<option value=\"\">* Any *</option>\n";
foreach($aAllowedValues as $key => $value)
{
if ($sFilterValue == $key)
{
$sSelected = ' selected';
}
else
{
$sSelected = '';
}
$sValue .= "<option value=\"$key\"$sSelected>$value</option>\n";
}
$sValue .= "</select>\n";
$sHtml .= "<td><label>".MetaModel::GetFilterLabel($sClassName, $sFilterCode).":</label></td><td>$sValue</td>\n";
}
else
{
// Any value is possible, display an input box
$sHtml .= "<td><label>".MetaModel::GetFilterLabel($sClassName, $sFilterCode).":</label></td><td><input class=\"textSearch\" name=\"$sFilterCode\" value=\"$sFilterValue\"/></td>\n";
}
$index++;
}
if (($index % $numCols) != 0)
{
$sHtml .= "<td colspan=\"".(2*($numCols - ($index % $numCols)))."\"></td>\n";
}
$sHtml .= "</tr>\n";
$sHtml .= "<tr><td colspan=\"".(2*$numCols)."\" align=\"right\"><input type=\"submit\" value=\" Search \"></td></tr>\n";
$sHtml .= "</table>\n";
foreach($aExtraParams as $sName => $sValue)
{
$sHtml .= "<input type=\"hidden\" name=\"$sName\" value=\"$sValue\">\n";
}
$sHtml .= "<input type=\"hidden\" name=\"dosearch\" value=\"1\">\n";
$sHtml .= "</form>\n";
// Soem Debug dumps...
//$sHtml .= "<tt>".$oSet->GetFilter()->__DescribeHTML()."</tt><br/>\n";
//$sHtml .= "<tt>encoding=\"text/serialize\" : ".$oSet->GetFilter()->serialize()."</tt><br/>\n";
//$sHtml .= "<tt>encoding=\"text/sibusql\" : ".$oSet->GetFilter()->ToSibusQL()."</tt><br/>\n";
//$sHtml .= "<tt>(Unlimited) ".$oUnlimitedFilter->__DescribeHTML()."</tt><br/>\n";
//$sHtml .= "<tt>encoding=\"text/serialize\" : ".$oUnlimitedFilter->serialize()."</tt><br/>\n";
//$sHtml .= "<tt>encoding=\"text/sibusql\" : ".$oUnlimitedFilter->ToSibusQL()."</tt>\n";
return $sHtml;
}
public static function GetFormElementForField($oPage, $sClass, $sAttCode, $oAttDef, $value = '', $sDisplayValue = '', $iId = '')
{
static $iInputId = 0;
if (!empty($iId))
{
$iInputId = $iId;
}
else
{
$iInputId++;
}
if (!$oAttDef->IsExternalField())
{
switch($oAttDef->GetEditClass())
{
case 'Date':
$sHTMLValue = "<input type=\"text\" size=\"20\" name=\"attr_$sAttCode\" value=\"$value\" id=\"$iInputId\" class=\"date-pick\"/>";
break;
case 'Text':
$sHTMLValue = "<textarea name=\"attr_$sAttCode\" rows=\"8\" cols=\"40\" id=\"$iInputId\">$value</textarea>";
break;
case 'List':
$oWidget = new UILinksWidget($sClass, $sAttCode, $iInputId);
$sHTMLValue = $oWidget->Display($oPage, $value);
break;
case 'String':
default:
$aAllowedValues = MetaModel::GetAllowedValues_att($sClass, $sAttCode, array(), '');
if ($aAllowedValues !== null)
{
//Enum field or external key, display a combo
if (count($aAllowedValues) == 0)
{
$sHTMLValue = "<input type=\"text\" size=\"70\" value=\"\" name=\"attr_$sAttCode\" id=\"$iInputId\"/>";
}
else if (count($aAllowedValues) > 50)
{
// too many choices, use an autocomplete
// The input for the auto complete
$sHTMLValue = "<input type=\"text\" id=\"label_$iInputId\" size=\"50\" name=\"\" value=\"$sDisplayValue\" />";
// another hidden input to store & pass the object's Id
$sHTMLValue .= "<input type=\"hidden\" id=\"$iInputId\" name=\"attr_$sAttCode\" value=\"$value\" />\n";
$oPage->add_ready_script("\$('#label_$iInputId').autocomplete('./ajax.render.php', { minChars:3, onItemSelect:selectItem, onFindValue:findValue, formatItem:formatItem, autoFill:true, keyHolder:'#$iInputId', extraParams:{operation:'autocomplete', sclass:'$sClass',attCode:'".$sAttCode."'}});");
}
else
{
// Few choices, use a normal 'select'
$sHTMLValue = "<select name=\"attr_$sAttCode\" id=\"$iInputId\">\n";
foreach($aAllowedValues as $key => $display_value)
{
$sSelected = ($value == $key) ? ' selected' : '';
$sHTMLValue .= "<option value=\"$key\"$sSelected>$display_value</option>\n";
}
$sHTMLValue .= "</select>\n";
}
}
else
{
$sHTMLValue = "<input type=\"text\" size=\"50\" name=\"attr_$sAttCode\" value=\"$value\" id=\"$iInputId\">";
}
}
}
return $sHTMLValue;
}
public function DisplayModifyForm(web_page $oPage)
{
$oAppContext = new ApplicationContext();
$sStateAttCode = MetaModel::GetStateAttributeCode(get_class($this));
$iKey = $this->GetKey();
$aDetails = array();
$oPage->add("<form method=\"post\">\n");
foreach(MetaModel::ListAttributeDefs(get_class($this)) as $sAttCode=>$oAttDef)
{
if ('finalclass' == $sAttCode) // finalclass is a reserved word, hardcoded !
{
// Do nothing, the class field is always hidden, it cannot be edited
}
else if ($sStateAttCode == $sAttCode)
{
// State attribute is always read-only from the UI
$sHTMLValue = $this->GetState();
$aDetails[] = array('label' => $oAttDef->GetLabel(), 'value' => $sHTMLValue);
}
else if (!$oAttDef->IsExternalField())
{
$iFlags = $this->GetAttributeFlags($sAttCode);
if ($iFlags & OPT_ATT_HIDDEN)
{
// Attribute is hidden, do nothing
}
else
{
if ($iFlags & OPT_ATT_READONLY)
{
// Attribute is read-only
$sHTMLValue = $this->GetAsHTML($sAttCode);
}
else
{
$sValue = $this->Get($sAttCode);
$sDisplayValue = $this->GetDisplayValue($sAttCode);
$sHTMLValue = self::GetFormElementForField($oPage, get_class($this), $sAttCode, $oAttDef, $sValue, $sDisplayValue);
}
$aDetails[] = array('label' => $oAttDef->GetLabel(), 'value' => $sHTMLValue);
}
}
}
$oPage->details($aDetails);
$oPage->add("<input type=\"hidden\" name=\"id\" value=\"$iKey\">\n");
$oPage->add("<input type=\"hidden\" name=\"class\" value=\"".get_class($this)."\">\n");
$oPage->add("<input type=\"hidden\" name=\"operation\" value=\"apply_modify\">\n");
$oPage->add("<input type=\"hidden\" name=\"transaction_id\" value=\"".utils::GetNewTransactionId()."\">\n");
$oPage->add($oAppContext->GetForForm());
$oPage->add("<button type=\"button\" class=\"action\" onClick=\"goBack()\"><span>Cancel</span></button>&nbsp;&nbsp;&nbsp;&nbsp;\n");
$oPage->add("<button type=\"submit\" class=\"action\"><span>Apply</span></button>\n");
$oPage->add("</form>\n");
}
public static function DisplayCreationForm(web_page $oPage, $sClass, $oObjectToClone = null)
{
$oAppContext = new ApplicationContext();
$aDetails = array();
$sOperation = ($oObjectToClone == null) ? 'apply_new' : 'apply_clone';
$sStateAttCode = MetaModel::GetStateAttributeCode(get_class($oObjectToClone));
$oPage->add("<form method=\"post\">\n");
foreach(MetaModel::ListAttributeDefs($sClass) as $sAttCode=>$oAttDef)
{
if ('finalclass' == $sAttCode) // finalclass is a reserved word, hardcoded !
{
// Do nothing, the class field is always hidden, it cannot be edited
}
else if ($sStateAttCode == $sAttCode)
{
// State attribute is always read-only from the UI
$sHTMLValue = $oObjectToClone->GetState();
$aDetails[] = array('label' => $oAttDef->GetLabel(), 'value' => $sHTMLValue);
}
else if (!$oAttDef->IsExternalField())
{
$sValue = ($oObjectToClone == null) ? '' : $oObjectToClone->Get($sAttCode);
$sDisplayValue = ($oObjectToClone == null) ? '' : $oObjectToClone->GetDisplayValue($sAttCode);
$sHTMLValue = self::GetFormElementForField($oPage, $sClass, $sAttCode, $oAttDef, $sValue, $sDisplayValue);
$aDetails[] = array('label' => $oAttDef->GetLabel(), 'value' => $sHTMLValue);
}
}
$oPage->details($aDetails);
if ($oObjectToClone != null)
{
$oPage->add("<input type=\"hidden\" name=\"clone_id\" value=\"".$oObjectToClone->GetKey()."\">\n");
}
$oPage->add("<input type=\"hidden\" name=\"class\" value=\"$sClass\">\n");
$oPage->add("<input type=\"hidden\" name=\"operation\" value=\"$sOperation\">\n");
$oPage->add("<input type=\"hidden\" name=\"transaction_id\" value=\"".utils::GetNewTransactionId()."\">\n");
$oPage->add($oAppContext->GetForForm());
$oPage->add("<button type=\"button\" class=\"action\" onClick=\"goBack()\"><span>Cancel</span></button>&nbsp;&nbsp;&nbsp;&nbsp;\n");
$oPage->add("<button type=\"submit\" class=\"action\"><span>Apply</span></button>\n");
$oPage->add("</form>\n");
}
}
?>

View File

@@ -0,0 +1,682 @@
<?php
require_once('../application/webpage.class.inc.php');
require_once('../application/utils.inc.php');
require_once('../core/userrights.class.inc.php');
/**
* Helper class to manage 'blocks' of HTML pieces that are parts of a page and contain some list of cmdb objects
*
* Each block is actually rendered as a <div></div> tag that can be rendered synchronously
* or as a piece of Javascript/JQuery/Ajax that will get its content from another page (ajax.render.php).
* The list of cmdbObjects to be displayed into the block is defined by a filter
* Right now the type of display is either: list, count, bare_details, details, csv, modify or search
* - list produces a table listing the objects
* - count produces a paragraphs with a sentence saying 'cont' objects found
* - bare_details displays just the details of the attributes of the object (best if only one)
* - details display the full details of each object found using its template (best if only one)
* - csv displays a textarea with the CSV export of the list of objects
* - modify displays the form to modify an object (best if only one)
* - search displays a search form with the criteria of the filter set
*/
class DisplayBlock
{
const TAG_BLOCK = 'itopblock';
protected $m_oFilter;
protected $m_sStyle;
protected $m_bAsynchronous;
protected $m_aParams;
protected $m_oSet;
public function __construct(DBObjectSearch $oFilter, $sStyle = 'list', $bAsynchronous = false, $aParams = array(), $oSet = null)
{
$this->m_oFilter = $oFilter;
$this->m_sStyle = $sStyle;
$this->m_bAsynchronous = $bAsynchronous;
$this->m_aParams = $aParams;
$this->m_oSet = $oSet;
}
/**
* Constructs a DisplayBlock object from a DBObjectSet already in memory
* @param $oSet DBObjectSet
* @return DisplayBlock The DisplayBlock object, or null if the creation failed
*/
public static function FromObjectSet(DBObjectSet $oSet, $sStyle, $aParams = array())
{
$oDummyFilter = new DBObjectSearch($oSet->GetClass());
$oBlock = new DisplayBlock($oDummyFilter, $sStyle, false, $aParams, $oSet); // DisplayBlocks built this way are synchronous
return $oBlock;
}
/**
* Constructs a DisplayBlock object from an XML template
* @param $sTemplate string The XML template
* @return DisplayBlock The DisplayBlock object, or null if the template is invalid
*/
public static function FromTemplate($sTemplate)
{
$iStartPos = stripos($sTemplate, '<'.self::TAG_BLOCK.' ',0);
$iEndPos = stripos($sTemplate, '</'.self::TAG_BLOCK.'>', $iStartPos);
if (($iStartPos === false) || ($iEndPos === false)) return null; // invalid template
$sITopBlock = substr($sTemplate,$iStartPos, $iEndPos-$iStartPos);
$sITopData = substr($sITopBlock, 1+stripos($sITopBlock, ">"));
$sITopTag = substr($sITopBlock, 0, stripos($sITopBlock, ">"));
$aMatches = array();
$sBlockClass = "DisplayBlock";
$bAsynchronous = false;
$sBlockType = 'list';
$sEncoding = 'text/serialize';
if (preg_match('/ type="(.*)"/U',$sITopTag, $aMatches))
{
$sBlockType = strtolower($aMatches[1]);
}
if (preg_match('/ asynchronous="(.*)"/U',$sITopTag, $aMatches))
{
$bAsynchronous = (strtolower($aMatches[1]) == 'true');
}
if (preg_match('/ blockclass="(.*)"/U',$sITopTag, $aMatches))
{
$sBlockClass = $aMatches[1];
}
if (preg_match('/ objectclass="(.*)"/U',$sITopTag, $aMatches))
{
$sObjectClass = $aMatches[1];
}
if (preg_match('/ encoding="(.*)"/U',$sITopTag, $aMatches))
{
$sEncoding = strtolower($aMatches[1]);
}
if (preg_match('/ linkage="(.*)"/U',$sITopTag, $aMatches))
{
// The list to display is a list of links to the specified object
$sExtKey = strtolower($aMatches[1]);
$aParams['linkage'] = $sExtKey; // Name of the Ext. Key that make this linkage
}
// Parameters contains a list of extra parameters for the block
// the syntax is param_name1:value1;param_name2:value2;...
$aParams = array();
if (preg_match('/ parameters="(.*)"/U',$sITopTag, $aMatches))
{
$sParameters = $aMatches[1];
$aPairs = explode(';', $sParameters);
foreach($aPairs as $sPair)
{
if (preg_match('/(.*)\:(.*)/',$sPair, $aMatches))
{
$aParams[trim($aMatches[1])] = trim($aMatches[2]);
}
}
}
switch($sEncoding)
{
case 'text/serialize':
$oFilter = CMDBSearchFilter::unserialize($sITopData);
break;
case 'text/sibusql':
$oFilter = CMDBSearchFilter::FromSibusQL($sITopData);
break;
case 'text/oql':
$oFilter = CMDBSearchFilter::FromOQL($sITopData);
break;
}
return new $sBlockClass($oFilter, $sBlockType, $bAsynchronous, $aParams);
}
public function Display(web_page $oPage, $sId, $aExtraParams = array())
{
$aExtraParams = array_merge($aExtraParams, $this->m_aParams);
if (!$this->m_bAsynchronous)
{
// render now
$oPage->add("<div id=\"$sId\" class=\"display_block\">\n");
$this->RenderContent($oPage, $aExtraParams);
$oPage->add("</div>\n");
}
else
{
// render it as an Ajax (asynchronous) call
$sFilter = $this->m_oFilter->serialize();
$oPage->add("<div id=\"$sId\" class=\"display_block loading\">\n");
$oPage->p("<img src=\"../images/indicator_arrows.gif\"> Loading...");
$oPage->add("</div>\n");
$oPage->add('
<script language="javascript">
$.get("ajax.render.php?filter='.$sFilter.'&style='.$this->m_sStyle.'",
{ operation: "ajax" },
function(data){
$("#'.$sId.'").empty();
$("#'.$sId.'").append(data);
$("#'.$sId.'").removeClass("loading");
}
);
</script>'); // TO DO: add support for $aExtraParams in asynchronous/Ajax mode
}
}
public function GetDisplay(web_page $oPage, $sId, $aExtraParams = array())
{
$sHtml = '';
$aExtraParams = array_merge($aExtraParams, $this->m_aParams);
if (!$this->m_bAsynchronous)
{
// render now
$sHtml .= "<div id=\"$sId\" class=\"display_block\">\n";
$sHtml .= $this->GetRenderContent($oPage, $aExtraParams);
$sHtml .= "</div>\n";
}
else
{
// render it as an Ajax (asynchronous) call
$sFilter = $this->m_oFilter->serialize();
$sHtml .= "<div id=\"$sId\" class=\"display_block loading\">\n";
$sHtml .= $oPage->GetP("<img src=\"../images/indicator_arrows.gif\"> Loading...");
$sHtml .= "</div>\n";
$sHtml .= '
<script language="javascript">
$.get("ajax.render.php?filter='.$sFilter.'&style='.$this->m_sStyle.'",
{ operation: "ajax" },
function(data){
$("#'.$sId.'").empty();
$("#'.$sId.'").append(data);
$("#'.$sId.'").removeClass("loading");
}
);
</script>'; // TO DO: add support for $aExtraParams in asynchronous/Ajax mode
}
return $sHtml;
}
public function RenderContent(web_page $oPage, $aExtraParams = array())
{
$oPage->add($this->GetRenderContent($oPage, $aExtraParams));
}
public function GetRenderContent(web_page $oPage, $aExtraParams = array())
{
$sHtml = '';
// Add the extra params into the filter if they make sense for such a filter
$bDoSearch = utils::ReadParam('dosearch', false);
if ($this->m_oSet == null)
{
$aFilterCodes = array_keys(MetaModel::GetClassFilterDefs($this->m_oFilter->GetClass()));
foreach($aFilterCodes as $sFilterCode)
{
$sExternalFilterValue = utils::ReadParam($sFilterCode, '');
if (isset($aExtraParams[$sFilterCode]))
{
$this->m_oFilter->AddCondition($sFilterCode, $aExtraParams[$sFilterCode]); // Use the default 'loose' operator
}
else if ($bDoSearch && $sExternalFilterValue != "")
{
$this->m_oFilter->AddCondition($sFilterCode, $sExternalFilterValue); // Use the default 'loose' operator
}
}
$this->m_oSet = new CMDBObjectSet($this->m_oFilter);
}
switch($this->m_sStyle)
{
case 'count':
if (isset($aExtraParams['group_by']))
{
$sGroupByField = $aExtraParams['group_by'];
$aGroupBy = array();
while($oObj = $this->m_oSet->Fetch())
{
$sValue = $oObj->Get($sGroupByField);
$aGroupBy[$sValue] = isset($aGroupBy[$sValue]) ? $aGroupBy[$sValue]+1 : 1;
}
$sFilter = urlencode($this->m_oFilter->serialize());
$aData = array();
foreach($aGroupBy as $sValue => $iCount)
{
$aData[] = array ( 'group' => $sValue,
'value' => "<a href=\"./UI.php?operation=search&dosearch=1&filter=$sFilter&$sGroupByField=".urlencode($sValue)."\">$iCount</a>"); // TO DO: add the context information
}
$sHtml .= $oPage->GetTable(array('group' => array('label' => MetaModel::GetLabel($this->m_oFilter->GetClass(), $sGroupByField), 'description' => ''), 'value' => array('label'=>'Count', 'description' => 'Number of elements')), $aData);
}
else
{
// Simply count the number of elements in the set
$iCount = $oSet->Count();
$sHtml .= $oPage->GetP("$iCount objects matching the criteria.");
}
break;
case 'list':
$bDashboardMode = isset($aExtraParams['dashboard']) ? ($aExtraParams['dashboard'] == 'true') : false;
if ( ($this->m_oSet->Count()> 0) && (UserRights::IsActionAllowed($this->m_oSet->GetClass(), UR_ACTION_READ, $this->m_oSet) == UR_ALLOWED_YES) )
{
$sLinkage = isset($aExtraParams['linkage']) ? $aExtraParams['linkage'] : '';
$sHtml .= cmdbAbstractObject::GetDisplaySet($oPage, $this->m_oSet, $sLinkage, !$bDashboardMode /* bDisplayMenu */);
}
else
{
$sHtml .= $oPage->GetP("No object to display.");
$sClass = $this->m_oFilter->GetClass();
if (!$bDashboardMode)
{
if (UserRights::IsActionAllowed($sClass, UR_ACTION_MODIFY, $this->m_oSet) == UR_ALLOWED_YES)
{
$sHtml .= $oPage->GetP("<a href=\"./UI.php?operation=new&class=$sClass\">Click here to create a new ".Metamodel::GetName($sClass)."</a>\n");
}
}
}
break;
case 'details':
if (UserRights::IsActionAllowed($this->m_oSet->GetClass(), UR_ACTION_READ, $this->m_oSet) == UR_ALLOWED_YES)
{
while($oObj = $this->m_oSet->Fetch())
{
$sHtml .= $oObj->GetDetails($oPage);
}
}
break;
case 'bare_details':
if (UserRights::IsActionAllowed($this->m_oSet->GetClass(), UR_ACTION_READ, $this->m_oSet) == UR_ALLOWED_YES)
{
while($oObj = $this->m_oSet->Fetch())
{
$sHtml .= $oObj->GetBareDetails($oPage);
}
}
break;
case 'csv':
if (UserRights::IsActionAllowed($this->m_oSet->GetClass(), UR_ACTION_READ, $this->m_oSet) == UR_ALLOWED_YES)
{
$sHtml .= "<textarea style=\"width:100%;height:98%\">\n";
$sHtml .= cmdbAbstractObject::GetSetAsCSV($this->m_oSet);
$sHtml .= "</textarea>\n";
}
break;
case 'modify':
if (UserRights::IsActionAllowed($this->m_oSet->GetClass(), UR_ACTION_MODIFY, $this->m_oSet) == UR_ALLOWED_YES)
{
while($oObj = $this->m_oSet->Fetch())
{
$sHtml .= $oObj->GetModifyForm($oPage);
}
}
break;
case 'search':
$iSearchSectionId = 1;
$sStyle = (isset($aExtraParams['open']) && ($aExtraParams['open'] == 'true')) ? 'SearchDrawer' : 'SearchDrawer DrawerClosed';
$sHtml .= "<div id=\"Search_$iSearchSectionId\" class=\"$sStyle\">\n";
$sHtml .= "<h1>Search form for ".Metamodel::GetName($this->m_oSet->GetClass())."</h1>\n";
$oPage->add_ready_script("\$(\"#LnkSearch_$iSearchSectionId\").click(function() {\$(\"#Search_$iSearchSectionId\").slideToggle('normal'); $(\"#LnkSearch_$iSearchSectionId\").toggleClass('open');});");
$sHtml .= cmdbAbstractObject::GetSearchForm($oPage, $this->m_oSet, $aExtraParams);
$sHtml .= "</div>\n";
$sHtml .= "<div class=\"HRDrawer\"/></div>\n";
$sHtml .= "<div id=\"LnkSearch_$iSearchSectionId\" class=\"DrawerHandle\">Search</div>\n";
break;
case 'pie_chart':
$sGroupBy = isset($aExtraParams['group_by']) ? $aExtraParams['group_by'] : '';
$sFilter = $this->m_oFilter->ToOQL();
$sHtml .= "
<OBJECT classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"
codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\"
WIDTH=\"400\"
HEIGHT=\"250\"
id=\"charts\"
ALIGN=\"\">
<PARAM NAME=movie VALUE=\"../images/charts.swf?library_path=../images/charts_library&xml_source=".urlencode("../pages/ajax.render.php?operation=pie_chart&group_by=$sGroupBy&encoding=oql&filter=".urlencode($sFilter))."\">
<PARAM NAME=\"quality\" VALUE=\"high\">
<PARAM NAME=\"bgcolor\" VALUE=\"#ffffff\">
<EMBED src=\"../images/charts.swf?library_path=../images/charts_library&xml_source=".urlencode("../pages/ajax.render.php?operation=pie_chart&group_by=$sGroupBy&encoding=oql&filter=".urlencode($sFilter))."\"
quality=\"high\"
bgcolor=\"#ffffff\"
WIDTH=\"400\"
HEIGHT=\"250\"
NAME=\"charts\"
ALIGN=\"\"
swLiveConnect=\"true\"
TYPE=\"application/x-shockwave-flash\"
PLUGINSPAGE=\"http://www.macromedia.com/go/getflashplayer\">
</EMBED>
</OBJECT>
";
break;
case 'pie_chart_ajax':
if (isset($aExtraParams['group_by']))
{
$sGroupByField = $aExtraParams['group_by'];
$aGroupBy = array();
while($oObj = $this->m_oSet->Fetch())
{
$sValue = $oObj->Get($sGroupByField);
$aGroupBy[$sValue] = isset($aGroupBy[$sValue]) ? $aGroupBy[$sValue]+1 : 1;
}
$sFilter = urlencode($this->m_oFilter->serialize());
$aData = array();
$sHtml .= "<chart>\n";
$sHtml .= "<chart_type>3d pie</chart_type>\n";
$sHtml .= "<chart_data>\n";
$sHtml .= "<row>\n";
$sHtml .= "<null/>\n";
foreach($aGroupBy as $sValue => $void)
{
$sHtml .= "<string>$sValue</string>\n";
}
$sHtml .= "</row>\n";
$sHtml .= "<row>\n";
$sHtml .= "<string></string>\n";
foreach($aGroupBy as $void => $iCount)
{
$sHtml .= "<number>$iCount</number>\n";
}
$sHtml .= "</row>\n";
$sHtml .= "</chart_data>\n";
$sHtml .= "
<chart_value color='ffffff' alpha='90' font='arial' bold='true' size='10' position='inside' prefix='' suffix='' decimals='0' separator='' as_percentage='true' />
<draw>
<text color='000000' alpha='10' font='arial' rotation='0' bold='true' size='30' x='0' y='140' width='400' height='150' h_align='center' v_align='bottom'>|||||||||||||||||||||||||||||||||||||||||||||||</text>
</draw>
<legend_label layout='horizontal' bullet='circle' font='arial' bold='true' size='13' color='000000' alpha='85' />
<legend_rect fill_color='ffffff' fill_alpha='10' line_color='ffffff' line_alpha='50' line_thickness='0' />
<series_color>
<color>ddaa41</color>
<color>88dd11</color>
<color>4e62dd</color>
<color>ff8811</color>
<color>4d4d4d</color>
<color>5a4b6e</color>
<color>1188ff</color>
</series_color>
";
$sHtml .= "</chart>\n";
}
else
{
// Simply count the number of elements in the set
$iCount = $oSet->Count();
$sHtml .= "<chart>\n</chart>\n";
}
break;
case 'open_flash_chart':
static $iChartCounter = 0;
$sChartType = isset($aExtraParams['chart_type']) ? $aExtraParams['chart_type'] : 'pie';
$sTitle = isset($aExtraParams['chart_title']) ? $aExtraParams['chart_title'] : '';
$sGroupBy = isset($aExtraParams['group_by']) ? $aExtraParams['group_by'] : '';
$sFilter = $this->m_oFilter->ToOQL();
$sHtml .= "<script>
swfobject.embedSWF(\"../images/open-flash-chart.swf\", \"my_chart_{$iChartCounter}\", \"400\", \"400\",\"9.0.0\", \"expressInstall.swf\",
{\"data-file\":\"".urlencode("../pages/ajax.render.php?operation=open_flash_chart&params[group_by]=$sGroupBy&params[chart_type]=$sChartType&params[chart_title]=$sTitle&encoding=oql&filter=".urlencode($sFilter))."\"});
</script>\n";
$sHtml .= "<div id=\"my_chart_{$iChartCounter}\">Here goes the chart</div>\n";
$iChartCounter++;
break;
case 'open_flash_chart_ajax':
include './php-ofc-library/open-flash-chart.php';
$sChartType = isset($aExtraParams['chart_type']) ? $aExtraParams['chart_type'] : 'pie';
$oChart = new open_flash_chart();
switch($sChartType)
{
case 'bars':
$oChartElement = new bar_glass();
if (isset($aExtraParams['group_by']))
{
$sGroupByField = $aExtraParams['group_by'];
$aGroupBy = array();
while($oObj = $this->m_oSet->Fetch())
{
$sValue = $oObj->Get($sGroupByField);
$aGroupBy[$sValue] = isset($aGroupBy[$sValue]) ? $aGroupBy[$sValue]+1 : 1;
}
$sFilter = urlencode($this->m_oFilter->serialize());
$aData = array();
$aLabels = array();
foreach($aGroupBy as $sValue => $iValue)
{
$aData[] = $iValue;
$aLabels[] = $sValue;
}
$maxValue = max($aData);
$oYAxis = new y_axis();
$aMagicValues = array(1,2,5,10);
$iMultiplier = 1;
$index = 0;
$iTop = $aMagicValues[$index % count($aMagicValues)]*$iMultiplier;
while($maxValue > $iTop)
{
$index++;
$iTop = $aMagicValues[$index % count($aMagicValues)]*$iMultiplier;
if (($index % count($aMagicValues)) == 0)
{
$iMultiplier = $iMultiplier * 10;
}
}
//echo "oYAxis->set_range(0, $iTop, $iMultiplier);\n";
$oYAxis->set_range(0, $iTop, $iMultiplier);
$oChart->set_y_axis( $oYAxis );
$oChartElement->set_values( $aData );
$oXAxis = new x_axis();
$oXLabels = new x_axis_labels();
// set them vertical
$oXLabels->set_vertical();
// set the label text
$oXLabels->set_labels($aLabels);
// Add the X Axis Labels to the X Axis
$oXAxis->set_labels( $oXLabels );
$oChart->set_x_axis( $oXAxis );
}
break;
case 'pie':
default:
$oChartElement = new pie();
$oChartElement->set_start_angle( 35 );
$oChartElement->set_animate( true );
$oChartElement->set_tooltip( '#label# - #val# (#percent#)' );
if (isset($aExtraParams['group_by']))
{
$sGroupByField = $aExtraParams['group_by'];
$aGroupBy = array();
while($oObj = $this->m_oSet->Fetch())
{
$sValue = $oObj->Get($sGroupByField);
$aGroupBy[$sValue] = isset($aGroupBy[$sValue]) ? $aGroupBy[$sValue]+1 : 1;
}
$sFilter = urlencode($this->m_oFilter->serialize());
$aData = array();
foreach($aGroupBy as $sValue => $iValue)
{
$aData[] = new pie_value($iValue, $sValue);
}
$oChartElement->set_values( $aData );
$oChart->x_axis = null;
}
}
if (isset($aExtraParams['chart_title'])) //@@ BUG: not passed via ajax !!!
{
$oTitle = new title( $aExtraParams['chart_title'] );
$oChart->set_title( $oTitle );
}
$oChart->set_bg_colour('#FFFFFF');
$oChart->add_element( $oChartElement );
$sHtml = $oChart->toPrettyString();
break;
default:
// Unsupported style, do nothing.
$sHtml .= "Error: unsupported style of block: ".$this->m_sStyle;
}
return $sHtml;
}
}
/**
* Helper class to manage 'blocks' of HTML pieces that are parts of a page and contain some list of cmdb objects
*
* Each block is actually rendered as a <div></div> tag that can be rendered synchronously
* or as a piece of Javascript/JQuery/Ajax that will get its content from another page (ajax.render.php).
* The list of cmdbObjects to be displayed into the block is defined by a filter
* Right now the type of display is either: list, count or details
* - list produces a table listing the objects
* - count produces a paragraphs with a sentence saying 'cont' objects found
* - details display (as table) the details of each object found (best if only one)
*/
class HistoryBlock extends DisplayBlock
{
public function GetRenderContent(web_page $oPage, $aExtraParams = array())
{
$sHtml = '';
// Add the extra params into the filter if they make sense for such a filter
$aFilterCodes = array_keys(MetaModel::GetClassFilterDefs($this->m_oFilter->GetClass()));
foreach($aFilterCodes as $sFilterCode)
{
if (isset($aExtraParams[$sFilterCode]))
{
$this->m_oFilter->AddCondition($sFilterCode, $aExtraParams[$sFilterCode]); // Use the default 'loose' operator
}
}
$oSet = new CMDBObjectSet($this->m_oFilter, array('date'=>false));
$sHtml .= "<!-- filter: ".($this->m_oFilter->ToOQL())."-->\n";
switch($this->m_sStyle)
{
case 'toggle':
$oLatestChangeOp = $oSet->Fetch();
if (is_object($oLatestChangeOp))
{
global $oContext; // User Context.. should be statis instead of global...
// There is one change in the list... only when the object has been created !
$sDate = $oLatestChangeOp->GetAsHTML('date');
$oChange = $oContext->GetObject('CMDBChange', $oLatestChangeOp->Get('change'));
$sUserInfo = $oChange->GetAsHTML('userinfo');
$oSet->Load(); // Reset the pointer to the beginning of the set: there should be a better way to do this...
$sHtml .= $oPage->GetStartCollapsibleSection("Last modified on $sDate by $sUserInfo.");
$sHtml .= cmdbAbstractObject::GetDisplaySet($oPage, $oSet);
$sHtml .= $oPage->GetEndCollapsibleSection();
}
break;
default:
$sHtml .= parent::GetRenderContent($oPage, $aExtraParams);
}
return $sHtml;
}
}
class MenuBlock extends DisplayBlock
{
public function GetRenderContent(web_page $oPage, $aExtraParams = array())
{
$sHtml = '';
$oAppContext = new ApplicationContext();
$sContext = $oAppContext->GetForLink();
$sClass = $this->m_oFilter->GetClass();
$oSet = new CMDBObjectSet($this->m_oFilter);
$sFilter = $this->m_oFilter->serialize();
$aActions = array();
$sUIPage = cmdbAbstractObject::ComputeUIPage($sClass);
switch($oSet->Count())
{
case 0:
// No object in the set, the only possible action is "new"
$bIsModifyAllowed = UserRights::IsActionAllowed($sClass, UR_ACTION_MODIFY, $oSet);
if ($bIsModifyAllowed) { $aActions[] = array ('label' => 'New', 'url' => "../page/$sUIPage?operation=new&class=$sClass&$sContext"); }
break;
case 1:
$oObj = $oSet->Fetch();
$id = $oObj->GetKey();
$bIsModifyAllowed = UserRights::IsActionAllowed($sClass, UR_ACTION_MODIFY, $oSet);
$bIsDeleteAllowed = UserRights::IsActionAllowed($sClass, UR_ACTION_DELETE, $oSet);
$bIsBulkModifyAllowed = UserRights::IsActionAllowed($sClass, UR_ACTION_BULK_MODIFY, $oSet);
$bIsBulkDeleteAllowed = UserRights::IsActionAllowed($sClass, UR_ACTION_BULK_DELETE, $oSet);
// Just one object in the set, possible actions are "new / clone / modify and delete"
if (isset($aExtraParams['linkage']))
{
if ($bIsModifyAllowed) { $aActions[] = array ('label' => 'New...', 'url' => "#"); }
if ($bIsBulkModifyAllowed) { $aActions[] = array ('label' => 'Modify All...', 'url' => "#"); }
if ($bIsBulkDeleteAllowed) { $aActions[] = array ('label' => 'Remove All', 'url' => "#"); }
if ($bIsModifyAllowed | $bIsDeleteAllowed) { $aActions[] = array ('label' => 'Manage Links...', 'url' => "#"); }
}
else
{
$aActions[] = array ('label' => 'eMail', 'url' => "mailto:?subject=".$oSet->GetFilter()->__DescribeHTML()."&body=".urlencode("http://localhost:81/pages/UI.php?operation=search&filter=$sFilter&$sContext"));
$aActions[] = array ('label' => 'CSV Export', 'url' => "../pages/$sUIPage?operation=search&filter=$sFilter&format=csv&$sContext");
$aActions[] = array ('label' => 'Bookmark...', 'url' => "../pages/ajax.render.php?operation=create&class=$sClass&filter=$sFilter", 'class' => 'jqmTrigger');
if ($bIsModifyAllowed) { $aActions[] = array ('label' => 'New...', 'url' => "../pages/$sUIPage?operation=new&class=$sClass&$sContext"); }
if ($bIsModifyAllowed) { $aActions[] = array ('label' => 'Clone...', 'url' => "../pages/$sUIPage?operation=clone&class=$sClass&id=$id&$sContext"); }
if ($bIsModifyAllowed) { $aActions[] = array ('label' => 'Modify...', 'url' => "../pages/$sUIPage?operation=modify&class=$sClass&id=$id&$sContext"); }
if ($bIsDeleteAllowed) { $aActions[] = array ('label' => 'Delete', 'url' => "../pages/$sUIPage?operation=delete&class=$sClass&id=$id&$sContext"); }
}
$aTransitions = $oObj->EnumTransitions();
$aStimuli = Metamodel::EnumStimuli($sClass);
foreach($aTransitions as $sStimulusCode => $aTransitionDef)
{
$iActionAllowed = UserRights::IsStimulusAllowed($sClass, $sStimulusCode, $oSet);
switch($iActionAllowed)
{
case UR_ALLOWED_YES:
$aActions[] = array('label' => $aStimuli[$sStimulusCode]->Get('label'), 'url' => "../pages/UI.php?operation=stimulus&stimulus=$sStimulusCode&class=$sClass&id=$id&$sContext");
break;
case UR_ALLOWED_DEPENDS:
$aActions[] = array('label' => $aStimuli[$sStimulusCode]->Get('label').' (*)', 'url' => "../pages/UI.php?operation=stimulus&stimulus=$sStimulusCode&class=$sClass&id=$id&$sContext");
break;
default:
// Do nothing
}
}
//print_r($aTransitions);
break;
default:
// Check rights
// New / Modify
$bIsModifyAllowed = UserRights::IsActionAllowed($sClass, UR_ACTION_MODIFY, $oSet);
$bIsBulkModifyAllowed = UserRights::IsActionAllowed($sClass, UR_ACTION_BULK_MODIFY, $oSet);
$bIsBulkDeleteAllowed = UserRights::IsActionAllowed($sClass, UR_ACTION_BULK_DELETE, $oSet);
if (isset($aExtraParams['linkage']))
{
$bIsDeleteAllowed = UserRights::IsActionAllowed($sClass, UR_ACTION_DELETE, $oSet);
if ($bIsModifyAllowed) { $aActions[] = array ('label' => 'New...', 'url' => "#"); }
if ($bIsBulkModifyAllowed) { $aActions[] = array ('label' => 'Modify All...', 'url' => "#"); }
if ($bIsBulkDeleteAllowed) { $aActions[] = array ('label' => 'Remove All', 'url' => "#"); }
if ($bIsModifyAllowed | $bIsDeleteAllowed) { $aActions[] = array ('label' => 'Manage Links...', 'url' => "#"); }
}
else
{
// many objects in the set, possible actions are: new / modify all / delete all
$aActions[] = array ('label' => 'eMail', 'url' => "mailto:?subject=".$oSet->GetFilter()->__DescribeHTML()."&body=".urlencode("http://localhost:81/pages/UI.php?operation=search&filter=$sFilter&$sContext"));
$aActions[] = array ('label' => 'CSV Export', 'url' => "../pages/$sUIPage?operation=search&filter=$sFilter&format=csv&$sContext");
$aActions[] = array ('label' => 'Bookmark...', 'url' => "../pages/ajax.render.php?operation=create&class=$sClass&filter=$sFilter", 'class' => 'jqmTrigger');
if ($bIsModifyAllowed) { $aActions[] = array ('label' => 'New...', 'url' => "../pages/$sUIPage?operation=new&class=$sClass&$sContext"); }
if ($bIsBulkModifyAllowed) { $aActions[] = array ('label' => 'Modify All...', 'url' => "../pages/$sUIPage?operation=modify_all&filter=$sFilter&$sContext"); }
if ($bIsBulkDeleteAllowed) { $aActions[] = array ('label' => 'Delete All', 'url' => "../pages/$sUIPage?operation=delete_all&filter=$sFilter&$sContext"); }
}
}
$sHtml .= "<div class=\"jd_menu_itop\"><ul class=\"jd_menu jd_menu_itop\">\n<li>Actions\n<ul>\n";
foreach ($aActions as $aAction)
{
$sClass = isset($aAction['class']) ? " class=\"{$aAction['class']}\"" : "";
$sHtml .= "<li><a href=\"{$aAction['url']}\"$sClass>{$aAction['label']}</a></li>\n<li>\n";
}
$sHtml .= "</ul>\n</li>\n</ul></div>\n";
$oPage->add_ready_script("$(\"ul.jd_menu\").jdMenu();\n");
return $sHtml;
}
}
?>

View File

@@ -89,14 +89,17 @@ class menuNode extends DBObject
return $this->Get('hyperlink')."?".implode("&", $aParams);
}
public function GetChildNodesSet($sType)
public function GetChildNodesSet($sType = null)
{
$oSearchFilter = new DBObjectSearch("menuNode");
$oSearchFilter->AddCondition('parent_id', $this->GetKey(), '=');
$oSearchFilter->AddCondition('type', $sType, '=');
if ($sType == 'user')
if ($sType != null)
{
$oSearchFilter->AddCondition('user_id', UserRights::GetUserId(), '=');
$oSearchFilter->AddCondition('type', $sType, '=');
if ($sType == 'user')
{
$oSearchFilter->AddCondition('user_id', UserRights::GetUserId(), '=');
}
}
$oSet = new CMDBObjectSet($oSearchFilter, array('rank' => true));
return $oSet;
@@ -184,10 +187,13 @@ class menuNode extends DBObject
{
$oSearchFilter = new DbObjectSearch("menuNode");
$oSearchFilter->AddCondition('parent_id', 0, '=');
$oSearchFilter->AddCondition('type', $sType, '=');
if ($sType == 'user')
if ($sType != null)
{
$oSearchFilter->AddCondition('user_id', UserRights::GetUserId(), '=');
$oSearchFilter->AddCondition('type', $sType, '=');
if ($sType == 'user')
{
$oSearchFilter->AddCondition('user_id', UserRights::GetUserId(), '=');
}
}
$oRootSet = new CMDBObjectSet($oSearchFilter, array('rank' => true));
while($oNode = $oRootSet->Fetch())
@@ -207,10 +213,13 @@ class menuNode extends DBObject
$oSearchFilter = new DBObjectSearch("menuNode");
$oSearchFilter->AddCondition('parent_id', $this->Get('parent_id'));
$oSearchFilter->AddCondition('rank', $this->Get('rank'), '>');
$oSearchFilter->AddCondition('type', $sType, '=');
if ($sType == 'user')
if ($sType != null)
{
$oSearchFilter->AddCondition('user_id', UserRights::GetUserId(), '=');
$oSearchFilter->AddCondition('type', $sType, '=');
if ($sType == 'user')
{
$oSearchFilter->AddCondition('user_id', UserRights::GetUserId(), '=');
}
}
$oSet = new DBObjectSet($oSearchFilter, array('rank'=> true)); // Order by rank (true means ascending)
return $oSet;

View File

@@ -0,0 +1,301 @@
<?php
require_once('../application/webpage.class.inc.php');
require_once('../application/displayblock.class.inc.php');
class UILinksWidget
{
protected $m_sClass;
protected $m_sAttCode;
protected $m_iInputId;
public function __construct($sClass, $sAttCode, $iInputId)
{
$this->m_sClass = $sClass;
$this->m_sAttCode = $sAttCode;
$this->m_iInputId = $iInputId;
}
public function Display(web_page $oPage, $oCurrentValuesSet = null)
{
$sHTMLValue = '';
$sTargetClass = self::GetTargetClass($this->m_sClass, $this->m_sAttCode);
$aAllowedValues = MetaModel::GetAllowedValues_att($this->m_sClass, $this->m_sAttCode, array(), '');
$oAttDef = MetaModel::GetAttributeDef($this->m_sClass, $this->m_sAttCode);
$sExtKeyToRemote = $oAttDef->GetExtKeyToRemote();
$sExtKeyToMe = $oAttDef->GetExtKeyToMe();
$sStateAttCode = MetaModel::GetStateAttributeCode($this->m_sClass);
$sDefaultState = MetaModel::GetDefaultState($this->m_sClass);
$sLinkedClass = $oAttDef->GetLinkedClass();
foreach(MetaModel::ListAttributeDefs($sLinkedClass) as $sAttCode=>$oAttDef)
{
if ($sStateAttCode == $sAttCode)
{
// State attribute is always hidden from the UI
}
else if (!$oAttDef->IsExternalField() && ($sAttCode != $sExtKeyToMe) && ($sAttCode != $sExtKeyToRemote))
{
$iFlags = MetaModel::GetAttributeFlags($this->m_sClass, $sDefaultState, $sAttCode);
if ( !($iFlags & OPT_ATT_HIDDEN) && !($iFlags & OPT_ATT_READONLY) )
{
$aAttributes[] = $sAttCode;
}
}
}
$sAttributes = "['".implode("','", $aAttributes)."']";
if ($oCurrentValuesSet != null)
{
// Serialize the link set into a JSon object
$aCurrentValues = array();
$sRow = '{';
while($oLinkObj = $oCurrentValuesSet->Fetch())
{
foreach($aAttributes as $sLinkAttCode)
{
$sRow.= "\"$sLinkAttCode\": \"".addslashes($oLinkObj->Get($sLinkAttCode))."\", ";
}
$sRow .= "\"$sExtKeyToRemote\": ".$oLinkObj->Get($sExtKeyToRemote).'}';
$aCurrentValues[] = $sRow;
}
$sJSON = '['.implode(',', $aCurrentValues).']';
}
// 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>\n";
$sHTMLValue .= "oLinkWidget{$this->m_iInputId} = new LinksWidget('{$this->m_iInputId}', '$sLinkedClass', '$sExtKeyToMe', '$sExtKeyToRemote', $sAttributes);\n";
$sHTMLValue .= "</script>\n";
$sHTMLValue .= $this->GetObjectPickerDialog($oPage, $sTargetClass, 'oLinkWidget'.$this->m_iInputId.'.OnOk');
$sHTMLValue .= $this->GetLinkObjectDialog($oPage, $this->m_iInputId);
$sHTMLValue .= "<input type=\"text\" id=\"ac_{$this->m_iInputId}\" size=\"35\" name=\"\" value=\"\" style=\"border: 1px solid red;\" />";
$sHTMLValue .= "<input type=\"button\" 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}\"/>\n";
$sHTMLValue .= "<input type=\"hidden\" id=\"{$this->m_iInputId}\" name=\"attr_{$this->m_sAttCode}\" value=\"\"/>\n";
$oPage->add_ready_script("\$('#{$this->m_iInputId}').val('$sJSON');\n\$('#ac_{$this->m_iInputId}').autocomplete('./ajax.render.php', { 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}});");
}
else
{
// Few choices, use a normal 'select'
$sHTMLValue = "<select name=\"attr_{$this->m_sAttCode}\" id=\"{$this->m_iInputId}\">\n";
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);
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));
}
}
$sHTMLValue .= "</div>\n";
return $sHTMLValue;
}
/**
* This static function is called by the Ajax Page when there is a need to fill an autocomplete combo
* @param $oPage web_page 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 $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(web_page $oPage, UserContext $oContext, $sClass, $sAttCode, $sName, $iMaxCount)
{
$aAllowedValues = MetaModel::GetAllowedValues_att($sClass, $sAttCode, array() /* $aArgs */, $sName);
if ($aAllowedValues != null)
{
$iCount = $iMaxCount;
foreach($aAllowedValues as $key => $value)
{
$oPage->add($value."|".$key."\n");
$iCount--;
if ($iCount == 0) break;
}
}
else // No limitation to the allowed values
{
// Search for all the object of the linked class
$oAttDef = $oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
$sLinkedClass = $oAttDef->GetLinkedClass();
$sSearchClass = self::GetTargetClass($sClass, $sAttCode);
$oFilter = $oContext->NewFilter($sSearchClass);
$sSearchAttCode = MetaModel::GetNameAttributeCode($sSearchClass);
$oFilter->AddCondition($sSearchAttCode, $sName, 'Begins with');
$oSet = new CMDBObjectSet($oFilter, array($sSearchAttCode => true));
$iCount = 0;
while( ($iCount < $iMaxCount) && ($oObj = $oSet->fetch()) )
{
$oPage->add($oObj->GetName()."|".$oObj->GetKey()."\n");
$iCount++;
}
}
}
/**
* This static function is called by the Ajax Page display a set of objects being linked
* to the object being created
* @param $oPage web_page The ajax page used for the put^put (sent back to the browser
* @param $sClass string The name of the class 'linking class' which is the class of the objects to display
* @param $sAttCode string The name of the attribute is the main object being created
* @param $sSet JSON serialized set of objects
* @return void
*/
static public function RenderSet($oPage, $sClass, $sJSONSet, $sExtKeyToMe)
{
$aSet = json_decode($sJSONSet, true); // true means hash array instead of object
$oSet = CMDBObjectSet::FromScratch($sClass);
foreach($aSet as $aObject)
{
$oObj = MetaModel::NewObject($sClass);
foreach($aObject as $sAttCode => $value)
{
$oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
if ($oAttDef->IsExternalKey())
{
$oTargetObj = MetaModel::GetObject($oAttDef->GetTargetClass(), $value); // @@ optimization, don't do & query per object in the set !
$oObj->Set($sAttCode, $oTargetObj);
}
else
{
$oObj->Set($sAttCode, $value);
}
}
$oSet->AddObject($oObj);
}
cmdbAbstractObject::DisplaySet($oPage, $oSet, $sExtKeyToMe);
}
protected static function GetTargetClass($sClass, $sAttCode)
{
$oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
$sLinkedClass = $oAttDef->GetLinkedClass();
switch(get_class($oAttDef))
{
case 'AttributeLinkedSetIndirect':
$oLinkingAttDef = MetaModel::GetAttributeDef($sLinkedClass, $oAttDef->GetExtKeyToRemote());
$sTargetClass = $oLinkingAttDef->GetTargetClass();
break;
case 'AttributeLinkedSet':
$sTargetClass = $sLinkedClass;
break;
}
return $sTargetClass;
}
protected function GetObjectPickerDialog($oPage, $sTargetClass, $sOkFunction)
{
$sHTML = <<< EOF
<div class="jqmWindow" id="ManageObjectsDlg_{$this->m_iInputId}">
<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">
<button type="button" class="jqmClose" onClick="$('#ManageObjectsDlg_{$this->m_iInputId}').jqmHide(); $sOkFunction('$sTargetClass', 'selected_objects')"> Ok </button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<button type="button" class="jqmClose"> Cancel</button>
</td>
</tr>
</table>
</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;
}
protected function GetLinkObjectDialog($oPage, $sId)
{
$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=\"page_header\"><h1 id=\"LinkObject_DlgTitle\">$sLinkedClass attributes</h1></div>\n";
$sHTML .= "<form>\n";
$index = 0;
$aAttrsMap = array();
foreach(MetaModel::ListAttributeDefs($sLinkedClass) as $sAttCode=>$oAttDef)
{
if ($sStateAttCode == $sAttCode)
{
// 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)
{
// Attribute is hidden, do nothing
}
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);
}
$aDetails[] = array('label' => $oAttDef->GetLabel(), 'value' => $sHTMLValue);
}
}
}
$sHTML .= $oPage->GetDetails($aDetails);
$sHTML .= "<button type=\"button\" class=\"jqmClose\" onClick=\"oLinkWidget$sId.OnLinkOk()\"> Ok </button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<button type=\"button\" class=\"jqmClose\" onClick=\"LinkWidget$sId.OnLinkCancel()\"> Cancel</button>\n";
$sHTML .= "</form>\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,260 @@
<?php
class UIWizard
{
protected $m_oPage;
protected $m_sClass;
protected $m_sTargetState;
protected $m_aWizardSteps;
public function __construct($oPage, $sClass, $sTargetState = '')
{
$this->m_oPage = $oPage;
$this->m_sClass = $sClass;
if (empty($sTargetState))
{
$sTargetState = MetaModel::GetDefaultState($sClass);
}
$this->m_sTargetState = $sTargetState;
$this->m_aWizardSteps = $this->ComputeWizardStructure();
}
public function GetObjectClass() { return $this->m_sClass; }
public function GetTargetState() { return $this->m_sTargetState; }
public function GetWizardStructure() { return $this->m_aWizardSteps; }
/**
* Displays one step of the wizard
*/
public function DisplayWizardStep($aStep, $iStepIndex, &$iMaxInputId, &$aFieldsMap, $bFinishEnabled = false)
{
$this->m_oPage->add("<div class=\"wizContainer\" id=\"wizStep$iStepIndex\" style=\"display:none;\">\n");
$this->m_oPage->add("<a name=\"step$iStepIndex\" />\n");
$aStates = MetaModel::EnumStates($this->m_sClass);
$aDetails = array();
$sJSHandlerCode = ''; // Javascript code to be executed each time this step of the wizard is entered
foreach($aStep as $sAttCode)
{
if ($sAttCode != 'finalclass') // Do not displa the attribute that stores the actual class name
{
$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;
$aPrerequisites = $oAttDef->GetPrerequisiteAttributes();
if ($iOptions & (OPT_ATT_MANDATORY | OPT_ATT_MUSTCHANGE | OPT_ATT_MUSTPROMPT))
{
$aFields[$sAttCode] = array();
foreach($aPrerequisites as $sCode)
{
$aFields[$sAttCode][$sCode] = '';
}
}
if (count($aPrerequisites) > 0)
{
$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
$sHTMLValue = cmdbAbstractObject::GetFormElementForField($this->m_oPage, $this->m_sClass, $sAttCode, $oAttDef, $oDefaultValuesSet, '', "att_$iMaxInputId");
$aFieldsMap[$iMaxInputId] = $sAttCode;
$aDetails[] = array('label' => $oAttDef->GetLabel().$sFieldFlag, 'value' => "<div id=\"field_$iMaxInputId\">$sHTMLValue</div>");
if ($oAttDef->GetValuesDef() != null)
{
$sJSHandlerCode .= "\toWizardHelper.RequestAllowedValues('$sAttCode');\n";
}
if ($oAttDef->GetDefaultValue() != null)
{
$sJSHandlerCode .= "\toWizardHelper.RequestDefaultValue('$sAttCode');\n";
}
if ($oAttDef->IsLinkSet())
{
$sJSHandlerCode .= "\toLinkWidgetatt_$iMaxInputId.Init();";
}
$iMaxInputId++;
}
}
//$aDetails[] = array('label' => '', 'value' => '<input type="button" value="Next &gt;&gt;">');
$this->m_oPage->details($aDetails);
$sBackButtonDisabled = ($iStepIndex <= 1) ? 'disabled' : '';
$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)\">
</div>\n");
$this->m_oPage->add("
<script>
function OnEnterStep{$iStepIndex}()
{
oWizardHelper.ResetQuery();
$sJSHandlerCode
oWizardHelper.AjaxQueryServer();
}
</script>\n");
$this->m_oPage->add("</div>\n\n");
}
/**
* Display the final step of the wizard: a confirmation screen
*/
public function DisplayFinalStep($iStepIndex, $aFieldsMap)
{
$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->add("<form method=\"post\" action=\"../pages/UI.php\">\n");
$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");
$this->m_oPage->add("<script>\n");
$this->m_oPage->add("function OnEnterStep$iStepIndex() {\n");
foreach($aFieldsMap as $iInputId => $sAttCode)
{
$this->m_oPage->add("\toWizardHelper.UpdateCurrentValue('$sAttCode');\n");
}
$this->m_oPage->add("\toWizardHelper.Preview('object_preview');\n");
$this->m_oPage->add("\t$('#wizard_json_obj').val(oWizardHelper.ToJSON());\n");
$this->m_oPage->add("}\n");
$this->m_oPage->add("</script>\n");
$this->m_oPage->add("<div id=\"object_preview\">\n");
$this->m_oPage->add("</div>\n");
$this->m_oPage->add("<input type=\"submit\" value=\"Create {$this->m_sClass}\">\n");
$this->m_oPage->add("</form>\n");
$this->m_oPage->add("</div>\n");
}
/**
* Compute the order of the fields & pages in the wizard
* @param $oPage iTopWebPage The current page (used to display error messages)
* @param $sClass string Name of the class
* @param $sStateCode string Code of the target state of the object
* @return hash Two dimensional array: each element represents the list of fields for a given page
*/
protected function ComputeWizardStructure()
{
$aWizardSteps = array( 'mandatory' => array(), 'optional' => array());
$aFieldsDone = array(); // Store all the fields that are already covered by a previous step of the wizard
$aStates = MetaModel::EnumStates($this->m_sClass);
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)
{
$oAttDef = MetaModel::GetAttributeDef($this->m_sClass, $sAttCode);
$sAttLabel = $oAttDef->GetLabel();
if ($iOptions & (OPT_ATT_MANDATORY | OPT_ATT_MUSTCHANGE | OPT_ATT_MUSTPROMPT))
{
$aPrerequisites = $oAttDef->GetPrerequisiteAttributes();
$aFields[$sAttCode] = array();
foreach($aPrerequisites as $sCode)
{
$aFields[$sAttCode][$sCode] = '';
}
}
}
// Now use the dependencies between the fields to order them
while(count($aFields) > 0)
{
$aCurrentStep = array();
foreach($aFields as $sAttCode => $aDependencies)
{
// All fields with no remaining dependencies can be entered at this
// step of the wizard
if (count($aDependencies) == 0)
{
$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]);
}
}
}
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;
}
}
// 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)
{
$iOptions = (isset($aStates[$this->m_sTargetState]['attribute_list'][$sAttCode])) ? $aStates[$this->m_sTargetState]['attribute_list'][$sAttCode] : 0;
if ( ($sStateAttCode != $sAttCode) &&
(!$oAttDef->IsExternalField()) &&
(($iOptions & (OPT_ATT_HIDDEN | OPT_ATT_READONLY)) == 0) &&
(!isset($aFieldsDone[$sAttCode])) )
{
// 'State', external fields, read-only and hidden fields
// and fields that are already listed in the wizard
// are removed from the 'optional' part of the wizard
$oAttDef = MetaModel::GetAttributeDef($this->m_sClass, $sAttCode);
$aPrerequisites = $oAttDef->GetPrerequisiteAttributes();
$aFields[$sAttCode] = array();
foreach($aPrerequisites as $sCode)
{
if (!isset($aFieldsDone[$sCode]))
{
// retain only the dependencies that were not covered
// in the 'mandatory' part of the wizard
$aFields[$sAttCode][$sCode] = '';
}
}
}
}
// Now use the dependencies between the fields to order them
while(count($aFields) > 0)
{
$aCurrentStep = array();
foreach($aFields as $sAttCode => $aDependencies)
{
// All fields with no remaining dependencies can be entered at this
// step of the wizard
if (count($aDependencies) == 0)
{
$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]);
}
}
}
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.");
print_r($aFields);
break;
}
$aWizardSteps['optional'][] = $aCurrentStep;
}
return $aWizardSteps;
}
}
?>

View File

@@ -0,0 +1,12 @@
<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 CMDBChangeOpSetAttribute 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="true" type="bare_details" encoding="text/sibusql">$class$: pkey = $pkey$</itopblock>
<itoptabs>
<itoptab name="Interfaces">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/sibusql">bizInterface: PKEY IS interface_id IN (bizCircuit: pkey = $pkey$)</itopblock>
</itoptab>
</itoptabs>

View File

@@ -0,0 +1,19 @@
<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 CMDBChangeOpSetAttribute 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="true" type="bare_details" encoding="text/sibusql">bizApplication: pkey = $pkey$</itopblock>
<itoptabs>
<itoptab name="Impacted_Client_Application">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/sibusql">lnkClientServer: server_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Application_Server">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/sibusql">lnkClientServer: client_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Contracts">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/sibusql">lnkInfraContract: infra_id = $pkey$</itopblock>
</itoptab>
</itoptabs>

View File

@@ -0,0 +1,17 @@
<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 CMDBChangeOpSetAttribute 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="true" type="bare_details" encoding="text/sibusql">$class$: pkey = $pkey$</itopblock>
<itoptabs>
<itoptab name="Impacted_Infrastructure">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/sibusql">lnkInfraChangeTicket: ticket_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Contacts_to_Notify">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/sibusql">lnkContactChange: change_id = $pkey$</itopblock>
</itoptab>
</itoptabs>
<br style="clear:both"/>

View File

@@ -0,0 +1,18 @@
<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 CMDBChangeOpSetAttribute 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="true" type="bare_details" encoding="text/sibusql">bizContract: pkey = $pkey$</itopblock>
<itoptabs>
<itoptab name="Covered_Infrastructures">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/sibusql">lnkInfraContract: contract_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Contact">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/sibusql">lnkContactContract: contract_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Document">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/sibusql">lnkDocumentContract: contract_id = $pkey$</itopblock>
</itoptab>
</itoptabs>

View File

@@ -0,0 +1,8 @@
<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 CMDBChangeOpSetAttribute 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="true" type="bare_details" encoding="text/sibusql">$class$: pkey = $pkey$</itopblock>

View File

@@ -0,0 +1,13 @@
<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 CMDBChangeOpSetAttribute 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="true" type="bare_details" encoding="text/sibusql">$class$: pkey = $pkey$</itopblock>
<itoptabs>
<itoptab name="Version">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/sibusql">bizDocVersion: document = $pkey$</itopblock>
</itoptab>
</itoptabs>

View File

@@ -0,0 +1,16 @@
<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 CMDBChangeOpSetAttribute 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="true" type="bare_details" encoding="text/sibusql">bizInfraGroup: pkey = $pkey$</itopblock>
<itoptabs>
<itoptab name="Infrastructures">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/sibusql">lnkInfraGrouping: infra_group_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Contacts">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/sibusql">lnkContactRealObject: object_id = $pkey$</itopblock>
</itoptab>
</itoptabs>

View File

@@ -0,0 +1,14 @@
<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 CMDBChangeOpSetAttribute 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="true" type="bare_details" encoding="text/sibusql">bizInterface: pkey = $pkey$</itopblock>
<itoptabs>
<itoptab name="Linked_interfaces">
<itopblock blockclass="DisplayBlock" type="list" linkage="interface1_id" encoding="text/sibusql">lnkInterfaces: interface1_id = $pkey$</itopblock>
<itopblock blockclass="DisplayBlock" type="list" linkage="interface2_id" encoding="text/sibusql">lnkInterfaces: interface2_id = $pkey$</itopblock>
</itoptab>
</itoptabs>

View File

@@ -0,0 +1,11 @@
<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 CMDBChangeOpSetAttribute WHERE objkey = $pkey$ AND objclass = '$class$'</itopblock>
</div>
<itopblock blockclass="DisplayBlock" asynchronous="true" type="bare_details" encoding="text/sibusql">bizKnownError: pkey = $pkey$</itopblock>
<itoptabs>
<itoptab name="Related_infra">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/sibusql">lnkInfraError: error_id = $pkey$</itopblock>
</itoptab>
</itoptabs>

View File

@@ -0,0 +1,25 @@
<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 CMDBChangeOpSetAttribute 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="true" type="bare_details" encoding="text/sibusql">bizLocation: pkey = $pkey$</itopblock>
<itoptabs>
<itoptab name="Contacts">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/sibusql">bizContact: location_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Servers">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/sibusql">bizServer: location_id = $pkey$</itopblock>
</itoptab>
<itoptab name="PCs">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/sibusql">bizPC: location_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Network_Devices">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/sibusql">bizNetworkDevice: location_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Documents">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/sibusql">lnkDocumentRealObject: object_id = $pkey$</itopblock>
</itoptab>
</itoptabs>

View File

@@ -0,0 +1,25 @@
<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 CMDBChangeOpSetAttribute 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="true" type="bare_details" encoding="text/sibusql">bizNetworkDevice: pkey = $pkey$</itopblock>
<itoptabs>
<itoptab name="Interfaces">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/sibusql">bizInterface: device_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Contacts">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/sibusql">lnkContactRealObject: object_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Incidents">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/sibusql">bizIncidentTicket: PKEY IS ticket_id IN (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="Documents">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/sibusql">lnkDocumentRealObject: object_id = $pkey$</itopblock>
</itoptab>
</itoptabs>

View File

@@ -0,0 +1,27 @@
<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 CMDBChangeOpSetAttribute 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="true" type="bare_details" encoding="text/sibusql">bizPC: pkey = $pkey$</itopblock>
<itoptabs>
<itoptab name="Installed_Application">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/sibusql">bizApplication: device_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Installed_Patches">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/sibusql">bizPatch: device_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Contacts">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/sibusql">lnkContactRealObject: object_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Interfaces">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/sibusql">bizInterface: device_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Incidents">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/sibusql">bizIncidentTicket: PKEY IS ticket_id IN (lnkInfraTicket: infra_id = $pkey$)</itopblock>
</itoptab>
<itoptab name="Documents">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/sibusql">bizDocument: PKEY IS doc_id IN (lnkDocumentRealObject: object_id = $pkey$)</itopblock>
</itoptab>
</itoptabs>

View File

@@ -0,0 +1,18 @@
<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 CMDBChangeOpSetAttribute 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="true" type="bare_details" encoding="text/sibusql">bizPerson: pkey = $pkey$</itopblock>
<itoptabs>
<itoptab name="Teams">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/sibusql">lnkContactRealObject: object_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Infrastructure">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/sibusql">lnkContactRealObject: contact_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Documents">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/sibusql">lnkDocumentRealObject: object_id = $pkey$</itopblock>
</itoptab>
</itoptabs>

View File

@@ -0,0 +1,30 @@
<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 CMDBChangeOpSetAttribute 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="true" type="bare_details" encoding="text/sibusql">bizServer: pkey = $pkey$</itopblock>
<itoptabs>
<itoptab name="Applications">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/sibusql">bizApplication: device_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Patches">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/sibusql">bizPatch: device_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Interfaces">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/sibusql">bizInterface: device_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Contacts">
<itopblock blockclass="DisplayBlock" type="list" linkage="object_id" encoding="text/sibusql">lnkContactRealObject: object_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Incidents">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/sibusql">bizIncidentTicket: PKEY IS ticket_id IN (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="Documents">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/sibusql">lnkDocumentRealObject: object_id = $pkey$</itopblock>
</itoptab>
</itoptabs>

View File

@@ -0,0 +1,13 @@
<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 CMDBChangeOpSetAttribute 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="true" type="bare_details" encoding="text/sibusql">$class$: pkey = $pkey$</itopblock>
<itoptabs>
<itoptab name="Contracts">
<itopblock blockclass="DisplayBlock" asynchronous="true" type="list" encoding="text/sibusql">bizContract: service_id = $pkey$</itopblock>
</itoptab>
</itoptabs>

View File

@@ -0,0 +1,13 @@
<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 CMDBChangeOpSetAttribute 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="true" 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

@@ -0,0 +1,21 @@
<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 CMDBChangeOpSetAttribute 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="true" type="bare_details" encoding="text/sibusql">$class$: pkey = $pkey$</itopblock>
<itoptabs>
<itoptab name="Members">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/sibusql">bizContact: PKEY IS object_id IN (lnkContactRealObject: contact_id = $pkey$)</itopblock>
</itoptab>
<itoptab name="Teams">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/sibusql">bizTeam: PKEY IS object_id IN (lnkContactRealObject: contact_id = $pkey$)</itopblock>
</itoptab>
<itoptab name="Infrastructure">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/sibusql">logInfra: PKEY IS object_id IN (lnkContactRealObject: contact_id = $pkey$)</itopblock>
</itoptab>
<itoptab name="Documents">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/sibusql">bizDocument: PKEY IS doc_id IN (lnkDocumentRealObject: object_id = $pkey$)</itopblock>
</itoptab>
</itoptabs>

View File

@@ -0,0 +1,21 @@
<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 CMDBChangeOpSetAttribute 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="true" type="bare_details" encoding="text/sibusql">$class$: pkey = $pkey$</itopblock>
<itoptabs>
<itoptab name="Impacted_Infrastructure">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/sibusql">lnkInfraTicket: ticket_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Related_Incidents">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/sibusql">lnkRelatedTicket: ticket_id = $pkey$</itopblock>
</itoptab>
<itoptab name="Contacts_to_Notify">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/sibusql">lnkContactTicket: ticket_id = $pkey$</itopblock>
</itoptab>
</itoptabs>
<br style="clear:both"/>

View File

@@ -0,0 +1,428 @@
<?php
/**
* 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('attributedef.class.inc.php');
require_once('filterdef.class.inc.php');
require_once('stimulus.class.inc.php');
require_once('valuesetdef.class.inc.php');
require_once('MyHelpers.class.inc.php');
require_once('expression.class.inc.php');
require_once('cmdbsource.class.inc.php');
require_once('sqlquery.class.inc.php');
require_once('oql/oqlquery.class.inc.php');
require_once('oql/oqlexception.class.inc.php');
require_once('oql/oql-parser.php');
require_once('oql/oql-lexer.php');
require_once('oql/oqlinterpreter.class.inc.php');
require_once('dbobject.class.php');
require_once('dbobjectsearch.class.php');
require_once('dbobjectset.class.php');
require_once('cmdbchange.class.inc.php');
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;
protected static $m_oCurrChange = null;
private function RecordObjCreation(CMDBChange $oChange)
{
$oMyChangeOp = MetaModel::NewObject("CMDBChangeOpCreate");
$oMyChangeOp->Set("change", $oChange->GetKey());
$oMyChangeOp->Set("objclass", get_class($this));
$oMyChangeOp->Set("objkey", $this->GetKey());
$iId = $oMyChangeOp->DBInsert();
}
private function RecordObjDeletion(CMDBChange $oChange, $objkey)
{
$oMyChangeOp = MetaModel::NewObject("CMDBChangeOpDelete");
$oMyChangeOp->Set("change", $oChange->GetKey());
$oMyChangeOp->Set("objclass", get_class($this));
$oMyChangeOp->Set("objkey", $objkey);
$iId = $oMyChangeOp->DBInsert();
}
private function RecordAttChanges(CMDBChange $oChange, array $aValues = array())
{
// $aValues is an array of $sAttCode => $value
// ... some values...
//
if (empty($aValues))
{
// ... or every object values
foreach(MetaModel::ListAttributeDefs(get_class($this)) as $sAttCode=>$oAttDef)
{
if ($oAttDef->IsLinkSet()) continue; // #@# temporary
$aValues[$sAttCode] = $this->Get($sAttCode);
}
}
foreach ($aValues as $sAttCode=> $value)
{
$oAttDef = MetaModel::GetAttributeDef(get_class($this), $sAttCode);
if ($oAttDef->IsLinkSet()) continue; // #@# temporary
$oMyChangeOp = MetaModel::NewObject("CMDBChangeOpSetAttribute");
$oMyChangeOp->Set("change", $oChange->GetKey());
$oMyChangeOp->Set("objclass", get_class($this));
$oMyChangeOp->Set("objkey", $this->GetKey());
$oMyChangeOp->Set("attcode", $sAttCode);
$oMyChangeOp->Set("newvalue", $value);
$iId = $oMyChangeOp->DBInsert();
}
}
public function DBInsert()
{
if(!is_object(self::$m_oCurrChange))
{
trigger_error("DBInsert() could not be used here, please use DBInsertTracked() instead", E_USER_ERROR);
}
return $this->DBInsertTracked_Internal();
}
public function DBInsertTracked(CMDBChange $oChange)
{
self::$m_oCurrChange = $oChange;
$ret = $this->DBInsertTracked_Internal();
self::$m_oCurrChange = null;
return $ret;
}
protected function DBInsertTracked_Internal()
{
$ret = parent::DBInsert();
$this->RecordObjCreation(self::$m_oCurrChange);
$this->RecordAttChanges(self::$m_oCurrChange);
return $ret;
}
public function DBClone($newKey = null)
{
if(!self::$m_oCurrChange)
{
trigger_error("DBClone() could not be used here, please use DBCloneTracked() instead", E_USER_ERROR);
}
return $this->DBCloneTracked_Internal();
}
public function DBCloneTracked(CMDBChange $oChange, $newKey = null)
{
self::$m_oCurrChange = $oChange;
$this->DBCloneTracked_Internal($newKey);
self::$m_oCurrChange = null;
}
protected function DBCloneTracked_Internal($newKey = null)
{
$newKey = parent::DBClone($newKey);
$oClone = MetaModel::GetObject(get_class($this), $newKey);
$oClone->RecordObjCreation(self::$m_oCurrChange);
$oClone->RecordAttChanges(self::$m_oCurrChange);
return $newKey;
}
public function DBUpdate()
{
if(!self::$m_oCurrChange)
{
trigger_error("DBUpdate() could not be used here, please use DBUpdateTracked() instead", E_USER_ERROR);
}
return $this->DBUpdateTracked_internal();
}
public function DBUpdateTracked(CMDBChange $oChange)
{
self::$m_oCurrChange = $oChange;
$this->DBUpdateTracked_Internal();
self::$m_oCurrChange = null;
}
protected function DBUpdateTracked_Internal()
{
// Copy the changes list before the update (the list should be reset afterwards)
$aChanges = $this->ListChanges();
if (count($aChanges) == 0)
{
trigger_error("Attempting to update an unchanged object", E_USER_NOTICE);
return;
}
$ret = parent::DBUpdate();
$this->RecordAttChanges(self::$m_oCurrChange, $aChanges);
return $ret;
}
public function DBDelete()
{
if(!self::$m_oCurrChange)
{
trigger_error("DBDelete() could not be used here, please use DBDeleteTracked() instead", E_USER_ERROR);
}
return $this->DBDeleteTracked_Internal();
}
public function DBDeleteTracked(CMDBChange $oChange)
{
self::$m_oCurrChange = $oChange;
$this->DBDeleteTracked_Internal();
self::$m_oCurrChange = null;
}
protected function DBDeleteTracked_Internal()
{
$prevkey = $this->GetKey();
$ret = parent::DBDelete();
$this->RecordObjDeletion(self::$m_oCurrChange, $prevkey);
return $ret;
}
public static function BulkDelete(DBObjectSearch $oFilter)
{
if(!self::$m_oCurrChange)
{
trigger_error("BulkDelete() could not be used here, please use BulkDeleteTracked() instead", E_USER_ERROR);
}
return $this->BulkDeleteTracked_Internal($oFilter);
}
public static function BulkDeleteTracked(CMDBChange $oChange, DBObjectSearch $oFilter)
{
self::$m_oCurrChange = $oChange;
$this->BulkDeleteTracked_Internal($oFilter);
self::$m_oCurrChange = null;
}
protected static function BulkDeleteTracked_Internal(DBObjectSearch $oFilter)
{
trigger_error("Change tracking not tested for bulk operations", E_USER_WARNING);
// 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
while ($oItem = $oObjSet->Fetch())
{
$aObjAndKeys[$oItem->GetKey()] = $oItem;
}
$oObjSet->FreeResult();
// Delete in one single efficient query
$ret = parent::BulkDelete($oFilter);
// Record... in many queries !!!
foreach($aObjAndKeys as $prevkey=>$oItem)
{
$oItem->RecordObjDeletion(self::$m_oCurrChange, $prevkey);
}
return $ret;
}
public static function BulkUpdate(DBObjectSearch $oFilter, array $aValues)
{
if(!self::$m_oCurrChange)
{
trigger_error("BulkUpdate() could not be used here, please use BulkUpdateTracked() instead", E_USER_ERROR);
}
return $this->BulkUpdateTracked_Internal($oFilter, $aValues);
}
public static function BulkUpdateTracked(CMDBChange $oChange, DBObjectSearch $oFilter, array $aValues)
{
self::$m_oCurrChange = $oChange;
$this->BulkUpdateTracked_Internal($oFilter, $aValues);
self::$m_oCurrChange = null;
}
protected static function BulkUpdateTracked_Internal(DBObjectSearch $oFilter, array $aValues)
{
// $aValues is an array of $sAttCode => $value
// Get the list of objects to update (and load it before doing the change)
$oObjSet = new CMDBObjectSet($oFilter);
$oObjSet->Load();
// Update in one single efficient query
$ret = parent::BulkUpdate($oFilter, $aValues);
// Record... in many queries !!!
while ($oItem = $oObjSet->Fetch())
{
$aChangedValues = $oItem->ListChangedValues($aValues);
$oItem->RecordAttChanges(self::$m_oCurrChange, $aChangedValues);
}
return $ret;
}
}
/**
* 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
{
// this is the public interface (?)
// I have to define those constructors here... :-(
// just to get the right object class in return.
// I have to think again to those things: maybe it will work fine if a have a constructor define here (?)
static public function FromScratch($sClass)
{
$oFilter = new CMDBSearchFilter($sClass);
$oRetSet = new CMDBObjectSet($oFilter); // THE ONLY DIFF IS HERE
// NOTE: THIS DOES NOT WORK IF m_bLoaded is private...
// BUT IT THAT CASE YOU DO NOT GET ANY ERROR !!!!!
$oRetSet->m_bLoaded = true; // no DB load
return $oRetSet;
}
static public function FromArray($sClass, $aObjects)
{
$oFilter = new CMDBSearchFilter($sClass);
$oRetSet = new CMDBObjectSet($oFilter); // THE ONLY DIFF IS HERE
// NOTE: THIS DOES NOT WORK IF m_bLoaded is private...
// BUT IT THAT CASE YOU DO NOT GET ANY ERROR !!!!!
$oRetSet->m_bLoaded = true; // no DB load
$oRetSet->AddObjectArray($aObjects);
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
{
// this is the public interface (?)
}
?>

View File

Before

Width:  |  Height:  |  Size: 559 B

After

Width:  |  Height:  |  Size: 559 B

View File

Before

Width:  |  Height:  |  Size: 764 B

After

Width:  |  Height:  |  Size: 764 B

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