Compare commits

..

1440 Commits

Author SHA1 Message Date
Denis Flaven
62510e2b04 Fix for Trac #670: XSS vulnerability issue.
SVN:1.2[2588]
2013-01-22 17:38:01 +00:00
Denis Flaven
f33c821306 Merged, the implementation of Track #582: "stable name" for synchro_data_xxx tables
SVN:1.2[2404]
2012-10-29 15:36:55 +00:00
Denis Flaven
11d0e9f52b Do not perform time consuming computations for building the menus if there are too many objects in a list (limit is configurable).
SVN:1.2[2344]
2012-10-24 14:04:57 +00:00
Denis Flaven
3330fd79d0 Bug fix: regression introduced by revision 2278.
SVN:1.2[2340]
2012-10-24 13:20:26 +00:00
Denis Flaven
02e0a61dcf Optimization to speed-up the "group-by" tables. (The complete solution is implemented in 2.0)
SVN:1.2[2338]
2012-10-24 13:13:15 +00:00
Romain Quetiez
2bb8028d4d Fixed regression (CSV import - unknown method utils::GetConfig)
SVN:1.2[2322]
2012-10-22 08:07:46 +00:00
Romain Quetiez
891b22909a #583 Losing attachments when performing massive change
SVN:1.2[2286]
2012-10-18 09:39:37 +00:00
Denis Flaven
463748b6da Properly handle all types of fields when entering values via the state transition "wizard" screen
SVN:1.2[2279]
2012-10-17 14:05:10 +00:00
Denis Flaven
fc2878b6d1 Properly handle a change of an external key...
SVN:1.2[2276]
2012-10-17 13:25:32 +00:00
Romain Quetiez
17919f5389 Portal: enable adding dependent attributes in the request creation form -reintegrated from trunk
SVN:1.2[2274]
2012-10-17 12:54:19 +00:00
Romain Quetiez
e54b1d2ff4 Portal: enable adding dependent attributes in the request creation form -reintegrated from trunk
SVN:1.2[2271]
2012-10-17 12:17:28 +00:00
Romain Quetiez
523fb8bd25 Fixed issue in the portal: the list of opened requests and closed request where messed up when pagination was activated on both lists -reintegrated from trunk
SVN:1.2[2268]
2012-10-17 09:12:01 +00:00
Romain Quetiez
fad77fb9fa CSV import: added a flag to disable the history tab (too long to display, when the feature is heavily used), reintegrated from trunk
SVN:1.2[2265]
2012-10-16 14:47:22 +00:00
Erwan Taloc
8da92c9251 add iTop favicon
SVN:1.2[2171]
2012-09-10 09:39:31 +00:00
Erwan Taloc
977d616ef2 Rename translation of Friendly name attribute to Friendly Name
SVN:1.2[2148]
2012-08-09 12:59:44 +00:00
Romain Quetiez
29faa739c1 Reintegrated fixes from branch 1.2.1 (2116,2118,2119)
- HTML attributes > 64 Kb
- Log of notification displayed as HTML

SVN:1.2[2120]
2012-07-04 09:23:12 +00:00
Denis Flaven
b986f63a67 Bug fix: $this->label(attcode)$ used inside Email Notifications should not contain HTML entities since this not an HTML fragment.
SVN:1.2[2117]
2012-06-29 15:11:35 +00:00
Denis Flaven
8fa3a6d47d Localization of the title of the login page
SVN:1.2[2112]
2012-06-15 13:30:07 +00:00
Denis Flaven
0e6876b068 Localization of the title of the login page
SVN:1.2[2111]
2012-06-15 13:27:16 +00:00
Denis Flaven
8d962f4bdb Fix for Trac #559: ldap user can login with blank password
SVN:1.2[2109]
2012-06-14 16:28:14 +00:00
Denis Flaven
3b8f945c44 Fixed Trac #558: properly parse strings containing hexadecimal sequences (i.e. 'QWERTY0xCUIOP').
Note that for now hexadecimal numbers are parsed but not interpreted properly...

SVN:1.2[2104]
2012-06-14 09:22:01 +00:00
Romain Quetiez
9600c89a1f Fixed regression (See #556) due to the existence of an overload of the protected API GetUserOrgs, reintegrated from branch 1.2.1
SVN:1.2[2100]
2012-06-14 09:12:25 +00:00
Denis Flaven
d01202ba33 Reload the impact/depends on graph only on demand for better performance, via the new Refresh button
SVN:1.2[2088]
2012-06-07 13:57:17 +00:00
Romain Quetiez
1bc1a0a1b2 #556 Merged in branch 1.2
SVN:1.2[2083]
2012-06-05 15:46:24 +00:00
Romain Quetiez
37ea4cb5e3 Reintegrated changes from trunk, to uncompile legacy data models
SVN:1.2[2080]
2012-06-05 11:18:10 +00:00
Denis Flaven
c4a003f620 Make the 'filter' conditions on ExtKey applicable also when searching on derived classes.
SVN:1.2[1991]
2012-05-16 12:23:54 +00:00
Denis Flaven
7a8ee0353a Protects against too long strings when logging web services events
SVN:1.2[1961]
2012-04-19 11:17:20 +00:00
Romain Quetiez
6b526ba455 #541 Fixed bug in the export for spreadsheet (time format)
SVN:1.2[1946]
2012-04-06 09:41:43 +00:00
Denis Flaven
9d9b923b7e Properly log-off (and report the issue in the log) in case we fail to create a user during the CAS Synchro
SVN:1.2[1942]
2012-04-04 10:09:07 +00:00
Erwan Taloc
fcaad0cd07 Add web link to link class in schema.php for an attribute linkset
SVN:1.2[1937]
2012-04-03 11:18:23 +00:00
Romain Quetiez
da875dd945 #540 Data synchro: the option "write if empty" was not implemented
SVN:1.2[1933]
2012-03-29 13:32:35 +00:00
Denis Flaven
2a71bf5008 Bug fix: to do not try to access a DataSource while it's being deleted
SVN:1.2[1929]
2012-03-27 11:26:31 +00:00
Denis Flaven
9b36ebc106 Bug fix: support [+] button inside linkedsets.. with constraints
SVN:1.2[1926]
2012-03-22 17:19:06 +00:00
Denis Flaven
1a507b7aa4 CAS integration. Done.
SVN:1.2[1921]
2012-03-22 15:30:23 +00:00
Denis Flaven
178ee28596 CAS integration continuing
SVN:1.2[1919]
2012-03-22 15:16:22 +00:00
Denis Flaven
e44a5d2980 CAS integration:
- regression fix: support patterns for the MemberOf groups filtering
- activate/de-activate the profiles synchronization using the 'cas_update_profiles' configuration flag
- provide default profile(s) when creating a new user from CAS, only if no match is found for assigning profiles from the CAS MemberOf group(s).

SVN:1.2[1917]
2012-03-22 10:53:09 +00:00
Denis Flaven
828c02db0b Bug fix: support [+] button inside linkedsets.. with constraints
SVN:1.2[1914]
2012-03-22 09:38:03 +00:00
Denis Flaven
d1e4e2109f Bug fix: support [+] button inside linkedsets.. with constraints
SVN:1.2[1913]
2012-03-22 09:35:25 +00:00
Denis Flaven
b7a9b340b8 Bug fix: support [+] button inside linkedsets.. with constraints
SVN:1.2[1912]
2012-03-22 09:11:45 +00:00
Denis Flaven
3731cf6dc1 The date picker fills the "time" part of the field with 00:00:00 when picking a DateTime instead of just a Date.
SVN:1.2[1910]
2012-03-21 10:53:33 +00:00
Denis Flaven
0e7fc5e5c4 Bug fix: support [+] button inside linkedsets
SVN:1.2[1908]
2012-03-21 10:36:55 +00:00
Denis Flaven
bc62c06894 Rollback of the modification: For forward compatibility... It was already implemented !
SVN:1.2[1907]
2012-03-21 10:28:45 +00:00
Denis Flaven
4ed85c23de Allow to specify the name of the PDF to download
SVN:1.2[1905]
2012-03-20 16:55:20 +00:00
Denis Flaven
b6c1347f27 For forward compatibility...
SVN:1.2[1904]
2012-03-20 16:54:13 +00:00
Denis Flaven
237eefcbc6 LinkedSets can be read-only too...
SVN:1.2[1898]
2012-03-19 17:17:45 +00:00
Denis Flaven
5ee3c69898 Make the class "TriggerOnPortalUpdate" importable
SVN:1.2[1896]
2012-03-16 12:58:23 +00:00
Denis Flaven
53b3ae8016 Enhanced fix for Trac #503. Don't drop the column before re-creating it, in case the data can be converted by MySQL.
SVN:1.2[1892]
2012-03-14 16:15:53 +00:00
Denis Flaven
26b6bfaf7f Added detecting of missing columns in the synchro_data_xxx tables (in case of duplicate SQL column names in the orignal data model). See Trac #503.
SVN:1.2[1891]
2012-03-14 16:02:39 +00:00
Denis Flaven
1a659cc4d0 Experimental support of PDF output for iTop pages, provided that mPDF is installed in lib/MPDF
SVN:1.2[1876]
2012-03-07 16:40:22 +00:00
Denis Flaven
b000900d6c Stylesheet enhancements to support printing...
SVN:1.2[1875]
2012-03-07 14:42:28 +00:00
Denis Flaven
f68ec1cef1 Typo
SVN:1.2[1874]
2012-03-04 18:13:06 +00:00
Denis Flaven
3fb867d393 - Current block Id not passed to the chart ?
SVN:1.2[1873]
2012-03-04 17:53:28 +00:00
Denis Flaven
fe559eb492 Small fix for genericity
SVN:1.2[1872]
2012-03-04 17:51:53 +00:00
Denis Flaven
0041afd6d0 - Current block Id not passed to the chart ?
SVN:1.2[1871]
2012-03-04 17:48:03 +00:00
Denis Flaven
dc1b5b0d4c - Bug fix: the hierarchical key in Organizations is not always named 'parent_id' !
SVN:1.2[1868]
2012-02-27 16:15:08 +00:00
Denis Flaven
10a930b7b2 Typo!
SVN:1.2[1862]
2012-02-21 14:03:35 +00:00
Denis Flaven
72b6089db8 Added the ability to Find then Remove a tab inside a page
SVN:1.2[1860]
2012-02-20 17:13:53 +00:00
Denis Flaven
0cfb1c3a83 Fix in case there is only one non-shared organization.
SVN:1.2[1858]
2012-02-17 12:52:35 +00:00
Denis Flaven
36a73535a5 Delay the storage of the dictionary in the cache to allow for its alteration during the initialization of the classes
SVN:1.2[1856]
2012-02-17 12:47:58 +00:00
Denis Flaven
9382b89277 Distinguish between creation and modification rights
SVN:1.2[1854]
2012-02-17 12:43:55 +00:00
Romain Quetiez
6d14da15cf Implemented the capability to implemented a separate module for sharing objects between the silos:
+ possibility for a plugin to alter the definition of a class (add an attribute)
+ fixed a bug (low exposure) in the cache for MetaModel::GetObject()
+ possibility to have computed fields on links (list of fields in the form now based on the ZList 'list')

SVN:1.2[1853]
2012-02-17 09:35:06 +00:00
Denis Flaven
3113205f88 Allow to add some headers like content-type.
SVN:1.2[1852]
2012-02-10 12:42:34 +00:00
Denis Flaven
09bd8052d7 Allow more than 64K for the email body (including attachments)
SVN:1.2[1850]
2012-02-10 12:25:21 +00:00
Denis Flaven
85f0b79203 Update to the Italian translation
SVN:1.2[1848]
2012-02-08 14:39:30 +00:00
Romain Quetiez
81145d7b1c Improved the change tracking to simplify the development of plugins (1st step... still to be drastically simplified)
SVN:1.2[1847]
2012-02-08 14:24:45 +00:00
Denis Flaven
7e6d1c2ce4 Performance improvements of the autocomplete: don't trigger a search when there is no expression to search !
SVN:1.2[1846]
2012-02-07 13:34:40 +00:00
Denis Flaven
364259daa5 Restore the previous state of URLMaker after building a notification
SVN:1.2[1845]
2012-02-07 09:32:29 +00:00
Denis Flaven
7b270294f6 Fix for query modifiers plug-ins
SVN:1.2[1843]
2012-02-07 09:12:45 +00:00
Romain Quetiez
c7aa00e81a Implemented the capability to modify queries by the mean of a plugin (make it work with APC cache)
SVN:1.2[1842]
2012-02-06 10:54:35 +00:00
Romain Quetiez
f9e7446e7b Reverted (removed test code)
SVN:1.2[1841]
2012-02-03 17:22:54 +00:00
Romain Quetiez
493ab80965 Implemented the capability to modify queries by the mean of a plugin (beta)
SVN:1.2[1840]
2012-02-03 17:16:27 +00:00
Denis Flaven
e623467782 Readme updated for the 1.2.1 release.
SVN:1.2[1838]
2012-02-01 10:27:10 +00:00
Denis Flaven
32208fcbfc Readme updated for the 1.2.1 release.
SVN:1.2[1837]
2012-02-01 10:24:31 +00:00
Denis Flaven
dcbff406f7 Fix to the Brazilian translation: thanks to Google translate !
SVN:1.2[1836]
2012-01-31 17:51:15 +00:00
Denis Flaven
017dfe641c Update to the Brazilian translation, thanks to Marco Tulio
SVN:1.2[1834]
2012-01-31 17:48:02 +00:00
Denis Flaven
fad258cd2d (Tried to) improve the display of the Synchronization Tooltip that "sometimes" does not work on IE 8...
SVN:1.2[1832]
2012-01-31 17:30:59 +00:00
Denis Flaven
3470ce18e8 Removed a (useless) hardcoded reference to FunctionalCI
SVN:1.2[1830]
2012-01-31 15:39:35 +00:00
Denis Flaven
af710c549f SQL Block with parameters were always displayed as table, whatever their type...
SVN:1.2[1828]
2012-01-31 15:04:23 +00:00
Denis Flaven
ee938d674d Fixed typos during the copy/paste for automatic account creation
SVN:1.2[1826]
2012-01-31 12:36:05 +00:00
Denis Flaven
423de35cf5 Fixed the encoding of mail headers !
SVN:1.2[1825]
2012-01-31 12:35:34 +00:00
Denis Flaven
6a7af8ad73 Make the OQLQuery class import-able
SVN:1.2[1822]
2012-01-30 17:46:00 +00:00
Denis Flaven
89732d6e52 Put some default reconciliation keys to ease the use of CSV import
SVN:1.2[1820]
2012-01-30 17:42:54 +00:00
Denis Flaven
cddeab2c90 Protect against empty list of reconciliation keys
SVN:1.2[1818]
2012-01-30 17:38:45 +00:00
Denis Flaven
d9d84703ae Fix to have the proper use of GetEditValue... thanks to C. Naud
SVN:1.2[1817]
2012-01-30 12:49:04 +00:00
Romain Quetiez
c3de9ecf10 Export for spreadsheets: transform keys (id of the queried object or external keys) into the corresponding friendly name
SVN:1.2[1815]
2012-01-30 10:58:21 +00:00
Denis Flaven
cf37a50b3d Enhancements to the German localization
SVN:1.2[1814]
2012-01-30 10:45:27 +00:00
Romain Quetiez
4db30648c2 Object details: log always displayed AFTER plugin data
SVN:1.2[1812]
2012-01-27 13:51:17 +00:00
Denis Flaven
8de84d5ec7 Fixed Trac#518 : Properly pass the context (i.e. currently selected org) to the auto-refresh lists
SVN:1.2[1810]
2012-01-25 10:27:23 +00:00
Denis Flaven
459a271d11 Fixed Trac#522: issue with non-ASCII characters in notifications subject.
SVN:1.2[1809]
2012-01-24 18:24:34 +00:00
Denis Flaven
9da00b83b2 Added the ability to display a custom welcome/disclaimer message at the bottom of the login form.
SVN:1.2[1807]
2012-01-24 15:24:25 +00:00
Denis Flaven
0c8ef6a690 Why put "APPROOT/modules/" as the AbsoluteUrlAppRoot in the portal ??
SVN:1.2[1804]
2012-01-24 14:26:39 +00:00
Denis Flaven
cdefd7a4c6 Hmmm, also may cause troubles for bug #519...
SVN:1.2[1801]
2012-01-24 13:04:39 +00:00
Romain Quetiez
4f057ac29f Improved the check on data model consistency: detection of SQL columns used by two attributes
SVN:1.2[1800]
2012-01-24 13:01:55 +00:00
Denis Flaven
ab16588f87 Fix for Trac#519 - change password bug !
SVN:1.2[1799]
2012-01-24 13:00:15 +00:00
Denis Flaven
07d8da9d99 Added the "search" form on top of the list of users
SVN:1.2[1796]
2012-01-20 15:24:33 +00:00
Romain Quetiez
c539f19ce9 Optimized memory usage when auditing large volumes of CIs (10'000 items was requiring 200 Mb, it now runs with 32 Mb -including the 30Mb overhead!)
SVN:1.2[1795]
2012-01-20 15:03:07 +00:00
Denis Flaven
3635e60850 Typo fix
SVN:1.2[1794]
2012-01-20 14:19:56 +00:00
Denis Flaven
b278b84f46 Fixed #481: localized characters in Service / Service Category name and description were not properly displayed.
SVN:1.2[1793]
2012-01-20 14:16:20 +00:00
Romain Quetiez
04647970a8 Case log now largely bigger than 64 Kilobytes... (reintegrated change made in trunk)
SVN:1.2[1791]
2012-01-19 15:32:48 +00:00
Romain Quetiez
fe58f6bd19 Fixed regression in the tool to test queries: losing the query when there is a syntax error
SVN:1.2[1788]
2012-01-19 10:13:36 +00:00
Romain Quetiez
0d6cd529a1 #516 and #517 Improved the export (specify fields for multi-column queries) and web queries (default field list)
SVN:1.2[1786]
2012-01-18 16:59:09 +00:00
Denis Flaven
2a155fe8ee Added SetMessageId for forward compatibility with SwiftMailer
SVN:1.2[1785]
2012-01-18 10:05:12 +00:00
Romain Quetiez
3f381a3530 Partially de-hardcoded against the subdirectory "modules", so that 1.2.1 should be compatible with modules running under 2.0.
SVN:1.2[1778]
2012-01-17 15:26:02 +00:00
Denis Flaven
7fadb5e08b Added self-registering / user synchronization extensibility
SVN:1.2[1760]
2012-01-11 16:01:11 +00:00
Denis Flaven
5d4476f48b Added self-registering / user synchronization extensibility
SVN:1.2[1757]
2012-01-11 14:31:44 +00:00
Romain Quetiez
2fbb37cc2f Readme updated, ready for 1.2.1 beta
SVN:1.2[1753]
2011-12-22 10:34:00 +00:00
Denis Flaven
6801ecb266 Updated the readme file to prepare for the 1.2.1 beta release
SVN:1.2[1752]
2011-12-22 10:29:27 +00:00
Romain Quetiez
fa821d3a9b #512 Allow the CLI mode for export.php
SVN:1.2[1750]
2011-12-21 15:28:50 +00:00
Denis Flaven
00f9deeaa5 Updated the readme file to prepare for the 1.2.1 beta release
SVN:1.2[1747]
2011-12-21 15:14:41 +00:00
Romain Quetiez
58cfc1d51b CSV import (both std and related to the data synchro) can be used with a tab (keyword 'tab', case insensitive)
SVN:1.2[1746]
2011-12-21 14:46:03 +00:00
Denis Flaven
af8b3b972d Fixed Trac #480: properly take into account the 'min_autocomplete_chars' settings.
SVN:1.2[1745]
2011-12-21 14:23:20 +00:00
Denis Flaven
07671f40fd Allow a module to restrict the access to a given menu/group by redeclaring the menu with restricted rights. All rights are combined with the AND operator.
SVN:1.2[1743]
2011-12-21 14:17:03 +00:00
Denis Flaven
3da5c65fe4 Allow to filter which class(es) of objects are displayed in the graphical impact analysis view
SVN:1.2[1742]
2011-12-21 14:15:27 +00:00
Romain Quetiez
489be44b90 #489 Data synchro: reintegrated the latest improvements from trunk.
SVN:1.2[1740]
2011-12-21 13:45:07 +00:00
Denis Flaven
912088d017 Fixed Trac #486: SQL dashboards limitations
SVN:1.2[1730]
2011-12-20 15:17:14 +00:00
Denis Flaven
06620133b6 Bug fix: missing (but useless) parameter in ExpandArgs causes a notice...
SVN:1.2[1728]
2011-12-20 12:41:05 +00:00
Denis Flaven
95d7a24630 Keep the current value iin the search form when reloading the search form for a different (sub)class. For example Contact => Person.
SVN:1.2[1726]
2011-12-19 17:30:02 +00:00
Denis Flaven
cb0e1d8ef3 When searching objects to add to the current object (n:n relationship), set the default search params in order to stay in the current silo.
SVN:1.2[1724]
2011-12-19 16:50:39 +00:00
Denis Flaven
d321ebc8e4 Bug fix: apply the AllowedValues constraints(as default values) when selecting elements via the "magnifier" button or creating an new element via the "plus" button... also make sure that allowed values is enforced
SVN:1.2[1721]
2011-12-15 10:46:48 +00:00
Romain Quetiez
c149ec8e2c #485 Improved the end-user experience with Excel and the web queries (added a phrasebook) + link to test the OQL attributes (query phrasebook or email actions, etc.) including the handlink of query arguments) + fixed wrong prototypes for a few implementations of GetBareProperties()
SVN:1.2[1719]
2011-12-14 17:44:06 +00:00
Denis Flaven
281adfb043 Bug fix: apply the AllowedValues constraints(as default values) when selecting elements via the "magnifier" button or creating an new element via the "plus" button.
SVN:1.2[1715]
2011-12-13 14:43:33 +00:00
Romain Quetiez
4244029087 #485 Export for MS Excel web queries: format=spreadsheet
SVN:1.2[1713]
2011-12-13 14:30:36 +00:00
Denis Flaven
78e173d5fb Bug fix: paginated lists were broken in the Impact Analysis "List" tab
SVN:1.2[1708]
2011-12-07 10:41:13 +00:00
Romain Quetiez
6b8abce03a - commited merge information (done earlier) -
SVN:1.2[1705]
2011-12-06 13:52:44 +00:00
Denis Flaven
33a7005069 - Bug ! Incorrectly appending a parameter ?version= to linked scripts already containing a parameter in their URL !
- changed the parameter name to itopversion to avoid collisions

SVN:1.2[1702]
2011-12-01 17:18:47 +00:00
Denis Flaven
006a6037d1 Increased Suhosin minimum value for get_max_value to 2048 due to a bug seen on some installations
SVN:1.2[1700]
2011-11-30 13:23:32 +00:00
Denis Flaven
e2f8be1745 Use the default language when creating a new user from CAS
SVN:1.2[1698]
2011-11-29 15:56:24 +00:00
Denis Flaven
ebae45f6a5 Support patterns for casMemberof
SVN:1.2[1696]
2011-11-29 15:36:58 +00:00
Denis Flaven
0685835d49 Allow to log entries on behalf of another user
SVN:1.2[1694]
2011-11-24 17:22:19 +00:00
Romain Quetiez
1b1e88f9a4 In french, organiZation takes an S
SVN:1.2[1691]
2011-11-23 15:30:11 +00:00
Denis Flaven
b90f443e75 - Don't create warnings for empty ext keys (i.e. empty string)
- Properly record multiple warnings
- Don't record warnings in case of creation error (error has precedence)

SVN:1.2[1689]
2011-11-23 09:55:44 +00:00
Romain Quetiez
4da64a64b1 Cosmetic on the API of the dictionnary (internal)
SVN:1.2[1686]
2011-11-21 17:03:36 +00:00
Denis Flaven
6673e171dc Properly handle restrictions (e.g. AllowedValues) on objects that are used as n:n relationships managed via LinksWidget.
SVN:1.2[1685]
2011-11-21 13:08:10 +00:00
Denis Flaven
afee7297cc Properly handle restrictions (e.g. AllowedValues) on objects that are used as n:n relationships managed via LinksWidget.
SVN:1.2[1683]
2011-11-21 10:57:50 +00:00
Denis Flaven
3cc8b5b88a Enhancement: when an (optional) external key cannot be reconciled, log a warning on the replica. the replicas containing a warning are then processed everytime in case the ext key changes
Also improved the search/display of replicas

SVN:1.2[1678]
2011-11-18 11:42:29 +00:00
Romain Quetiez
b2e6981b24 Fixed bug in change tracking: it was impossible to factorize code creating objects in the background either in the context of an object update or in the context of the application of a stimulus
SVN:1.2[1674]
2011-11-18 10:46:42 +00:00
Denis Flaven
c0a79fa573 Prevent warnings when checking the available stimuli in the menu...
SVN:1.2[1672]
2011-11-16 17:26:27 +00:00
Denis Flaven
02ad6d19fe Prevent Javascript errors in case a name contains a quote.
SVN:1.2[1670]
2011-11-15 13:12:22 +00:00
Denis Flaven
d16308ab62 - Reload the object after applying a stimulus, in case an action has an effect on an external field...
SVN:1.2[1665]
2011-11-14 10:44:31 +00:00
Denis Flaven
4598959bc2 - Reload the object after applying a stimulus, in case an action has an effect on an external field...
SVN:1.2[1664]
2011-11-14 10:43:06 +00:00
Denis Flaven
65a3755f81 - Regression from previous fix: don't Reload an object before saving it !
SVN:1.2[1662]
2011-11-10 16:37:18 +00:00
Denis Flaven
dc46c65499 - Don't activate triggers if the transition fails
- Reload the object, in case some custom action changed an external object

SVN:1.2[1659]
2011-11-10 10:12:43 +00:00
Denis Flaven
9d691c8e56 Removed obsolete code which caused a warning in bulk_stimulus
SVN:1.2[1658]
2011-11-10 10:07:28 +00:00
Denis Flaven
99f897bff7 Better error handling in case of OQL error
SVN:1.2[1657]
2011-11-09 17:07:25 +00:00
Denis Flaven
8d83447222 Added the capability for plug-ins to "listen" to add/remove attachment events.
SVN:1.2[1652]
2011-10-28 12:46:22 +00:00
Romain Quetiez
dcc8ad08a4 New helper class: TemplateString - to allow extended syntaxes such as $this->location_id->org_id->parent_id->name$... to be progressively introduced and replace the heavy ToArgs()
SVN:1.2[1646]
2011-10-24 13:45:49 +00:00
Denis Flaven
c1b0b73b51 Bug fix: Trac #494. It seems that PHPSoap does not understand the <wsdl:documentation> tag.
SVN:1.2[1644]
2011-10-21 08:42:13 +00:00
Romain Quetiez
81173decca Fixed issue: nobody in the list of persons to notify for portal users (security takes precedence)
SVN:1.2[1641]
2011-10-21 08:05:07 +00:00
Denis Flaven
9aca062bf5 Enhancement to provide a forward compatible API for some external plugins: support adding attachments to an email in a "clean" way.
SVN:1.2[1640]
2011-10-20 16:33:46 +00:00
Denis Flaven
09aba95d0a Fixed Trac #493: incorrect display of Users' Grant Matrix
SVN:1.2[1635]
2011-10-17 09:27:23 +00:00
Denis Flaven
1683ca2dd6 Merged some enhancements fro the trunk to better keep track of sent emails
SVN:1.2[1634]
2011-10-13 15:42:59 +00:00
Denis Flaven
9e732d6045 Fixed Trac #487: resizable text areas disappeared when located on the second tab !
SVN:1.2[1628]
2011-10-04 10:52:03 +00:00
Denis Flaven
69df343bd2 Automatic synchro of CAS/LDAP users
SVN:1.2[1627]
2011-10-03 14:07:29 +00:00
Denis Flaven
eb8f49ebfe Initializes the admin contact's phone number, in case it is a mandatory field in the data model...
SVN:1.2[1623]
2011-09-30 08:03:45 +00:00
Denis Flaven
398e294604 Prevent crash when trying to load the favicon during the setup !
SVN:1.2[1621]
2011-09-29 15:27:25 +00:00
Denis Flaven
d04c6bccd5 Added a link to a favicon (icon in the browser's bar and tab)
SVN:1.2[1619]
2011-09-29 14:54:03 +00:00
Denis Flaven
f00c7c6bc2 GetValueLabel is used in some dashboards... make sure that it is available for any attribute
SVN:1.2[1617]
2011-09-29 09:46:58 +00:00
Denis Flaven
d30e8c359f Make sure that the organisation's drop-down list is not bigger than the left menu...
SVN:1.2[1616]
2011-09-29 09:44:38 +00:00
Romain Quetiez
2bd4a61c00 #485 Export.php improved for integration into Excel / web queries (bug with IIS/HTTPS, limitation on the size of the OQL)
SVN:1.2[1613]
2011-09-29 08:12:28 +00:00
Romain Quetiez
ba3080594c #485 Export.php improved for integration into Excel / web queries (bug with IIS/HTTPS, limitation on the size of the OQL)
SVN:trunk[1612]
2011-09-29 08:07:37 +00:00
Romain Quetiez
e35c8323df Merge most recent (few) bug fixes from trunk
SVN:1.2[1611]
2011-09-28 14:38:37 +00:00
Romain Quetiez
e4e814281d #484 Fixed issue with IIS ("Wrong password" at first prompt)
SVN:1.2[1610]
2011-09-28 12:59:40 +00:00
Romain Quetiez
a3a94cccbb #484 Fixed issue with IIS ("Wrong password" at first prompt)
SVN:trunk[1609]
2011-09-28 12:55:15 +00:00
Denis Flaven
635cb424a2 Fixed Trac #482: OpenSearch broken.
SVN:1.2[1608]
2011-09-28 10:50:58 +00:00
Romain Quetiez
e8c8e4a0d7 #481 Special characters not transcribed correctly in Portal (regression in 1.2)
SVN:trunk[1607]
2011-09-28 10:17:53 +00:00
Denis Flaven
5b3350f6d5 Fixed Trac #482: link to OpenSearch Xml page was broken
SVN:trunk[1606]
2011-09-28 10:07:27 +00:00
Denis Flaven
b454b24e0f Rename the cron.params file to avoid overwriting the current config when updating.
SVN:trunk[1605]
2011-09-23 14:14:58 +00:00
Romain Quetiez
e95aa6cc69 Merged latest changes in module Attachments (bug fix on install and cosmetic improvements)
SVN:1.2[1604]
2011-09-23 13:49:26 +00:00
Romain Quetiez
c58fd17fc9 Fixed regression on attribute labels; introduced in [1582]
SVN:1.2[1603]
2011-09-23 13:36:57 +00:00
Romain Quetiez
099afb5451 Fixed regression on attribute labels; introduced in [1581]
SVN:trunk[1602]
2011-09-23 13:30:21 +00:00
Denis Flaven
ec226ce76d Cosmetic fix: the "loading..." indicator was visible/spinning when reloading any other field of the form !
SVN:trunk[1601]
2011-09-22 16:37:47 +00:00
Denis Flaven
5080bd58d5 Removed some Debug/Warning messages
SVN:trunk[1600]
2011-09-22 16:35:33 +00:00
Romain Quetiez
efdec7a343 #478 Fixed issue in the audit: the results are wrong whenever an organization is selected
SVN:1.2[1599]
2011-09-22 12:08:11 +00:00
Denis Flaven
5ec37fd26a - Fix a problem with the upgrade (case sensitive table name & prefix)
SVN:trunk[1598]
2011-09-22 11:58:42 +00:00
Romain Quetiez
2352c05d36 Fixed security issue: the attachments were visible by anybody (by forming URLs manually), whatever the allowed organizations. The change requires the execution of the setup/migration procedure.
SVN:1.2[1597]
2011-09-22 11:58:31 +00:00
Denis Flaven
8ae92cb50e - Fix a problem with the upgrade (case sensitive table name & prefix)
- Display a message when there is no attachment

SVN:trunk[1596]
2011-09-22 11:53:49 +00:00
Romain Quetiez
f82a4ada23 #478 Fixed issue in the audit: the results are wrong whenever an organization is selected
SVN:trunk[1595]
2011-09-22 11:40:30 +00:00
Denis Flaven
e5ce12ed0a Make the template system work for real !
SVN:trunk[1594]
2011-09-22 11:15:40 +00:00
Denis Flaven
428f1a26cc Typo ! Impact: Unknown ?
SVN:trunk[1593]
2011-09-22 11:08:34 +00:00
Romain Quetiez
9976999a88 Portal: updated dictionary for new buttton "reopen request"
SVN:trunk[1592]
2011-09-22 10:08:36 +00:00
Romain Quetiez
da2b8ab4c0 Fixed security issue: the attachments were visible by anybody (by forming URLs manually), whatever the allowed organizations. The change requires the execution of the setup/migration procedure.
SVN:trunk[1591]
2011-09-22 09:04:12 +00:00
Romain Quetiez
0de75db474 Portal (regression with the latest implementation, causing a warning)
SVN:trunk[1590]
2011-09-21 12:59:16 +00:00
Romain Quetiez
23634964a5 #477 Could not specify more than one reconciliation key (regression) + took the opportunity to enhance protection against XSS injection (using column names in the data)
SVN:1.2[1589]
2011-09-21 12:39:22 +00:00
Romain Quetiez
b014596172 #477 Could not specify more than one reconciliation key (regression) + took the opportunity to enhance protection against XSS injection (using column names in the data)
SVN:trunk[1588]
2011-09-21 12:27:08 +00:00
Romain Quetiez
b46ed4764d Fixed bug in the new portal: the wizard validation was inoperant when several selection lists were proposed
SVN:trunk[1587]
2011-09-20 13:50:11 +00:00
Romain Quetiez
2b1aecda53 Fixed recent regression on the portal (confusion btw GetContactId and GetUserId)
SVN:trunk[1586]
2011-09-20 08:22:54 +00:00
Romain Quetiez
619252db99 Merge fix on previous change (fixed #473, but getting a warning)
SVN:1.2[1585]
2011-09-19 11:49:43 +00:00
Romain Quetiez
19318973ca Fixed warning (strict standards) on previous fix
SVN:trunk[1584]
2011-09-19 11:44:04 +00:00
Romain Quetiez
ca4dbd833c (record merge info)
SVN:1.2[1583]
2011-09-19 10:58:40 +00:00
Romain Quetiez
f62a3b22a3 #473 Could not load NW interfaces (reconciliation issue) - merged from trunk
SVN:1.2[1582]
2011-09-19 10:55:24 +00:00
Romain Quetiez
cac76a7e08 #473 Could not load NW interfaces (reconciliation issue)
SVN:trunk[1581]
2011-09-19 10:36:47 +00:00
Romain Quetiez
88416bca5d Created branch 1.2
SVN:1.2[1580]
2011-09-19 10:30:29 +00:00
Romain Quetiez
abd645ca98 Fixed regressions in the portal
SVN:trunk[1579]
2011-09-15 15:25:30 +00:00
Romain Quetiez
7301cb9369 Updated the dictionnaries for the latest changes into the portal
SVN:trunk[1578]
2011-09-15 10:26:50 +00:00
Romain Quetiez
559de3d38f Portal reworked (code factorization, allowing for paginated lists) + added the list of closed tickets (+search)
SVN:trunk[1577]
2011-09-15 10:06:46 +00:00
Denis Flaven
552ffd79b1 Always use a drop-down list for external keys in search forms
SVN:trunk[1575]
2011-09-14 07:38:40 +00:00
Denis Flaven
aae8ca7b8b Added credentials for the security advices
SVN:trunk[1574]
2011-09-13 14:58:40 +00:00
Denis Flaven
13c636cab6 Prevent email header injection
SVN:trunk[1573]
2011-09-13 14:55:34 +00:00
Denis Flaven
cc40fc5d91 Exclude a (risky) and unused file for the build
SVN:trunk[1572]
2011-09-13 14:38:52 +00:00
Denis Flaven
bddfdb4a28 Fixed Trac #468: wrong path to the doc#installationInstructions
SVN:trunk[1571]
2011-09-12 11:22:29 +00:00
Denis Flaven
6bc639c6ce Enhanced error message in case of "file too big error" (more user friendly and not admin oriented)
SVN:trunk[1570]
2011-09-12 09:48:54 +00:00
Denis Flaven
9b8ae03413 - Properly display names containing XML entities (& < > and ")
- Don't drag items by their (invisible) tooltip !

SVN:trunk[1569]
2011-09-10 16:24:26 +00:00
Denis Flaven
17f00198d3 Fix for #404: context was lost when performing a drill-down in the flash navigator.
SVN:trunk[1568]
2011-09-10 16:20:50 +00:00
Denis Flaven
5041ec2e0c Regression on accentuated characters due to bad (forgotten) encoding on htmlentities (Trac #446)
SVN:trunk[1567]
2011-09-09 16:18:01 +00:00
Denis Flaven
ee4f7e5b6a Don't forget to track the count of updated objects...
SVN:trunk[1566]
2011-09-09 16:11:51 +00:00
Denis Flaven
cbb40b85dc Typo in a (not yet used) function !
SVN:trunk[1565]
2011-09-08 15:29:35 +00:00
Denis Flaven
9aca772209 Fix for Trac#446: prevent XSS vulnerabilities
SVN:trunk[1564]
2011-09-08 13:33:47 +00:00
Denis Flaven
c4db9cd84e More fixes for Trac#446: XSS vulnerabilities with vectors containing double quotes
SVN:trunk[1563]
2011-09-08 13:21:32 +00:00
Romain Quetiez
205e80f8a5 #446 XSS vector through the page title
SVN:trunk[1562]
2011-09-08 10:30:18 +00:00
Romain Quetiez
06e9bd0c25 #446 XSS vector on the login web page
SVN:trunk[1561]
2011-09-08 10:28:14 +00:00
Denis Flaven
1c812f8b34 Bug fix: subsequent audit results were wrong when a 'negative' rule was used.
SVN:trunk[1560]
2011-09-07 12:12:10 +00:00
Romain Quetiez
f3c5759721 Updated the readme file
SVN:trunk[1559]
2011-09-07 07:58:22 +00:00
Denis Flaven
69368a39cb Fix radio buttons for enum values.
SVN:trunk[1558]
2011-09-06 12:47:42 +00:00
Denis Flaven
ab5849b3cd Fix: properly manage validation field for vertical radio buttons.
SVN:trunk[1557]
2011-09-06 10:25:06 +00:00
Denis Flaven
1ab796bd40 One more fix for #404: context was lost when performing a bulk delete.
SVN:trunk[1556]
2011-09-06 08:07:18 +00:00
Denis Flaven
c1221054b4 Prevent a crash when displaying the details of a change (from the CSV "history" tab)
SVN:trunk[1555]
2011-09-05 16:28:31 +00:00
Denis Flaven
3bd681bc9d Bug fix: hyperlink to create a new object was wrong (typo)
SVN:trunk[1554]
2011-09-02 15:54:32 +00:00
Denis Flaven
b33989ec62 Added the ability to specify programmatically the scope for "favorite organizations". Note the the end-user can still restrict this list even further using the "Preferences" page.
SVN:trunk[1553]
2011-09-01 14:06:51 +00:00
Denis Flaven
b3121eebae Typos in the Brazilian localization, found by Bruno Cassaro. Thanks Bruno !
SVN:trunk[1552]
2011-09-01 13:07:09 +00:00
Denis Flaven
7d8971139b Missing sanitization filter for 1 parameter: fixed !
SVN:trunk[1551]
2011-09-01 11:50:34 +00:00
Denis Flaven
04f20860dc Add the name of the synchro data source as an external field in case we need to make a CSV export
SVN:trunk[1550]
2011-09-01 10:50:57 +00:00
Denis Flaven
8f21b9dabb Bug fix: prevent a warning when doing modify-all as a non-admin user.
SVN:trunk[1549]
2011-09-01 10:49:56 +00:00
Romain Quetiez
eb89610465 Readme file ready for release 1.2
SVN:trunk[1548]
2011-08-31 15:37:48 +00:00
Denis Flaven
13f4e90ee6 Make sure that we trigger a change event whenever we pickup a different value for an external key (either via the magnifier button or via the hierarchy button)
SVN:trunk[1547]
2011-08-31 14:39:55 +00:00
Denis Flaven
29f1dd5a69 Prevent an exception in some (rare?) conditions where an incorrect value was set in a temporary object....cf Trac #466
SVN:trunk[1546]
2011-08-31 14:28:41 +00:00
Romain Quetiez
a7e937ec58 Regression: the default language was German!
SVN:trunk[1545]
2011-08-31 13:09:50 +00:00
Denis Flaven
bc2a8a8c4a Improved verification to the PHP file upload settings to avoid troubles later... (Trac #284)
SVN:trunk[1544]
2011-08-31 09:03:26 +00:00
Denis Flaven
c9b0a2b561 Enhance ObjectDetailsTemplate to manage bulk actions and synchronized attributes.
SVN:trunk[1543]
2011-08-30 15:47:57 +00:00
Romain Quetiez
5fcea9bf69 #437 Regressions in the beta - wrong reporting of the bulk update
SVN:trunk[1542]
2011-08-30 15:09:54 +00:00
Denis Flaven
3b42c86f46 Regression due to the interaction of the two previous fixes. (Trac #444 and Trac #448)
SVN:trunk[1541]
2011-08-30 11:12:14 +00:00
Romain Quetiez
038fe30fbe #363 Charts not displaying with IE8 + IIS + HTTPS
SVN:trunk[1540]
2011-08-30 10:13:58 +00:00
Denis Flaven
aa95e51e00 Fixed Trac #444: preserve sort order and page size when reloading a paginated list.
SVN:trunk[1539]
2011-08-30 09:38:06 +00:00
Romain Quetiez
6a78c7dcc2 Internal: Fixed regression introduced in [1365] and present in the beta version (overviews not working with HTTPS)
SVN:trunk[1538]
2011-08-30 09:20:29 +00:00
Romain Quetiez
17aa1d1fc0 #464 While upgrading iTop, copy the values from change/start_date to ticket/start_date (iif the current value is null)
SVN:trunk[1537]
2011-08-29 16:28:08 +00:00
Romain Quetiez
24244f1bac Rollback: restored attributes removed by mistake
SVN:trunk[1536]
2011-08-29 16:26:17 +00:00
Romain Quetiez
f7be35848c Internal: detect unused columns while upgrading
SVN:trunk[1535]
2011-08-29 15:37:58 +00:00
Denis Flaven
1aa7ff14fe Removing duplicate fields
SVN:trunk[1534]
2011-08-29 15:02:59 +00:00
Denis Flaven
c33a508376 Removing duplicate fields
SVN:trunk[1533]
2011-08-29 15:02:12 +00:00
Romain Quetiez
37ec8b12f3 Upgrade/toolkit: improved the data sources update procedure (no need to create "direct" linkset attributes, remove old attributes, more verbose)
SVN:trunk[1532]
2011-08-29 13:23:57 +00:00
Romain Quetiez
dde3efc0c7 Upgrade: adjust data sources, and be more verbose about upgrades in the DB (HKeys and data sources)
SVN:trunk[1531]
2011-08-29 13:20:44 +00:00
Romain Quetiez
54f3dec7a9 Upgrade: fails to recreate a view when is has become invalid (missing attribute)
SVN:trunk[1530]
2011-08-29 13:18:30 +00:00
Denis Flaven
6be497ee7d Fixed Trac#465: incorrect logic when resetting the 'ConnectedToInterface'
SVN:trunk[1529]
2011-08-29 11:55:13 +00:00
Denis Flaven
5d9d44dc5e Fix: detection of the Suhosin extension during the installation and tell the user if the get_max_value is too small.
SVN:trunk[1528]
2011-08-29 11:49:22 +00:00
Denis Flaven
d547394ba2 Fixed Trac#448: paginated display broken after reloading a page containing a list where the page size is set to 'All'
SVN:trunk[1527]
2011-08-26 11:07:29 +00:00
Denis Flaven
ace0a3e278 Finishing fix of Trac449:display selection of favorite organizations
SVN:trunk[1526]
2011-08-26 10:45:46 +00:00
Denis Flaven
dd9cb27971 Fixed Trac #449: properly reload the current selection when the list of Favorite Organizations is a paginated list.
SVN:trunk[1525]
2011-08-26 10:34:54 +00:00
Denis Flaven
a3dc8ab3d7 Added the ability to reload a selection fro a paginated list.
SVN:trunk[1524]
2011-08-26 10:33:37 +00:00
Denis Flaven
496bf386be Force the rebuilding of hierarchical keys on every upgrade, since in 1.2-beta the rebuilding of HK was buggy. (May be the cause of the bugs: #459, #460 and #461)
SVN:trunk[1523]
2011-08-26 09:08:54 +00:00
Denis Flaven
c337616fea Fix: regression for tickets with just a default initial state.
SVN:trunk[1522]
2011-08-26 07:26:30 +00:00
Denis Flaven
186ba76092 Added a flag to force the import to cinutnue even in case of SQL error... useful for debugging don't use in production ;-)
SVN:trunk[1521]
2011-08-25 17:37:56 +00:00
Denis Flaven
20a06c9212 Fixed a warning...
SVN:trunk[1520]
2011-08-25 17:03:12 +00:00
Romain Quetiez
e515dfb434 Cosmetics: regression due to an unnecessary protection against XSS attacks
SVN:trunk[1519]
2011-08-25 16:35:38 +00:00
Romain Quetiez
2ee85dd407 Customization: added a check against reuse of an attribute code (collision can happen easily with inheritance)
SVN:trunk[1518]
2011-08-25 16:10:57 +00:00
Denis Flaven
6df6e4a9cc - Allow creation of an ticket in a different initial state via the new 'initial_state_path' attribute.
- Support update of CaseLog fields in bulk_modify mode.

SVN:trunk[1517]
2011-08-25 16:04:58 +00:00
Romain Quetiez
c74c955973 Internal: it is possible to override the user authorized organizations
SVN:trunk[1516]
2011-08-25 15:45:45 +00:00
Romain Quetiez
a3a4fd0a75 Dictionary: English was proposed twice in the list of available languages!
SVN:trunk[1515]
2011-08-25 12:01:04 +00:00
Romain Quetiez
c7f3ac0361 Internal: suppressed a warning on ormCaseLog
SVN:trunk[1514]
2011-08-25 11:57:18 +00:00
Romain Quetiez
21002574ce Notifications: case log in plain text (this->case_log) or the latest entry (this->head(case_log))
SVN:trunk[1513]
2011-08-25 11:49:15 +00:00
Romain Quetiez
64cae5b58b Portal: activate TriggerOnPortalUpdate
SVN:trunk[1512]
2011-08-25 11:46:23 +00:00
Romain Quetiez
cc1105ff60 Email test: under IIS it was not detecting Windows correctly, and the help message was therefore completely wrong.
SVN:trunk[1511]
2011-08-25 10:04:21 +00:00
Romain Quetiez
71655f0632 Fixed regression (shortcut actions, display a list of objects not deriving from cmdbAbstract)
SVN:trunk[1510]
2011-08-25 09:29:52 +00:00
Denis Flaven
6e4e5be35d Allow TriggerOnPortalUpdate to work also on derived classes: i.e a trigger defined for the class 'Ticket' will be called when a 'UserRequest' (derived from Ticket) will be updated from the portal.
SVN:trunk[1509]
2011-08-25 08:03:39 +00:00
Denis Flaven
872a424a78 Bug fix: allow modifying an object as if in target state, before applying the stimulus (cf PortalWebpage).
SVN:trunk[1508]
2011-08-24 16:00:28 +00:00
Denis Flaven
612c355e03 Bug fix: allow modifying an object as if in target state, before applying the stimulus (cf PortalWebpage).
SVN:trunk[1507]
2011-08-24 15:58:56 +00:00
Denis Flaven
ffa9b21364 Bug fix: allow modifying an object as if in target state, before applying the stimulus (cf PortalWebpage).
SVN:trunk[1506]
2011-08-24 15:58:22 +00:00
Denis Flaven
180311fd0a Fixed a side effect of Trac#446 (XSS)
SVN:trunk[1505]
2011-08-24 15:56:48 +00:00
Denis Flaven
16b7714139 Default shortcut actions are now a parameter
SVN:trunk[1504]
2011-08-24 14:11:57 +00:00
Denis Flaven
c6865cf63d Default shortcut actions are now a parameter
SVN:trunk[1503]
2011-08-24 14:11:25 +00:00
Denis Flaven
905d9b5931 Apply organization filtering to subclasses of Organization as well.
SVN:trunk[1502]
2011-08-24 13:54:27 +00:00
Denis Flaven
0850370275 Bug fix: let accented characters pass through the autocomplete
SVN:trunk[1501]
2011-08-24 13:53:19 +00:00
Romain Quetiez
38591f444e Fixed regression on latest fix (Hkeys and inheritance)
SVN:trunk[1500]
2011-08-24 10:49:39 +00:00
Denis Flaven
ae36aa1f74 German localization update, thanks to Stephan Rosenke.
SVN:trunk[1499]
2011-08-23 16:55:01 +00:00
Denis Flaven
264af56591 Pass the final class to GetShortcutActions
SVN:trunk[1498]
2011-08-23 13:56:09 +00:00
Denis Flaven
0a2c9d0e37 Automatic rebuild of the dictionary list during setup, based on the content of the 'dictionaries' folder.
SVN:trunk[1497]
2011-08-23 13:13:08 +00:00
Denis Flaven
9d9d53c967 Fix regression on hierarchical keys
SVN:trunk[1496]
2011-08-23 11:14:25 +00:00
Denis Flaven
54315f41e4 Bug fix: computation of allowed stimuli was wrong
SVN:trunk[1495]
2011-08-23 09:17:19 +00:00
Denis Flaven
a04e7ea375 Bug fix in HierarchicalKey: host class can be different from target class in case of derived classes.
SVN:trunk[1494]
2011-08-23 07:24:55 +00:00
Erwan Taloc
795296e6e3 update after test made by Erwan
SVN:trunk[1493]
2011-08-23 07:13:28 +00:00
Denis Flaven
98ac85c098 Added the display of the total count of objects above 'group by' blocks.
SVN:trunk[1492]
2011-08-22 16:42:28 +00:00
Romain Quetiez
e53c07393c Internal: improved the API of PortalWebPage
SVN:trunk[1491]
2011-08-22 10:09:21 +00:00
Denis Flaven
48d66447b7 Support an abstract "Organization" class: if it's the case don't create any Org neither Person during the setup.
SVN:trunk[1490]
2011-08-22 10:06:48 +00:00
Romain Quetiez
54b4f67ed6 Fixed regression due to the enhanced security (ignore a field in CSV import)
SVN:trunk[1489]
2011-08-22 08:49:52 +00:00
Denis Flaven
9836797da9 Regression due to XSS fix (#446): auto-refresh block was showing an assertion failed message. Fixed.
SVN:trunk[1488]
2011-08-22 08:37:08 +00:00
Romain Quetiez
931a260435 Fixed regression due to the enhanced security (param file)
SVN:trunk[1487]
2011-08-22 08:32:25 +00:00
Denis Flaven
2a6d36b9cd Bug fix: (post 1.2-beta) warning message (undefined variable aFavoriteActions) when displaying a list for a non-admin user...
SVN:trunk[1486]
2011-08-22 08:19:35 +00:00
Denis Flaven
9420c14c13 Fixed a (post 1.2-beta) regression: bulk modify and bluk apply stimulus were broken.
SVN:trunk[1485]
2011-08-22 08:18:07 +00:00
Romain Quetiez
272807ba56 Export.php - fixed a regression (specifying no field list resulting in an error)
SVN:trunk[1484]
2011-08-22 07:38:38 +00:00
Denis Flaven
d05ea1863c Fixed a (post 1.2-beta) regression: bulk modify and bluk apply stimulus were broken.
SVN:trunk[1483]
2011-08-21 16:41:23 +00:00
Denis Flaven
6c8e021727 Fixed Trac# 457: crash when deleting two organizations.
SVN:trunk[1482]
2011-08-19 17:14:06 +00:00
Romain Quetiez
266135b1b9 #452 Export.php - field list can be specified also for HTML output
SVN:trunk[1481]
2011-08-19 16:14:50 +00:00
Denis Flaven
02fc610a18 Bug fix: "shortcut" actions were not perserving the current tab. Fixed.
SVN:trunk[1480]
2011-08-19 16:08:27 +00:00
Denis Flaven
e2aa3cc69f Enhancement: provide a warning (popup) message when navigating away from an edition form.
SVN:trunk[1479]
2011-08-19 15:50:17 +00:00
Denis Flaven
de516c0ce4 Fixed Trac #458: back button was asking to fill the mandatory fields !
SVN:trunk[1478]
2011-08-19 15:41:05 +00:00
Romain Quetiez
92ac1fe2ca #148 Allow overloading attribute/enum labels in the dictionary
SVN:trunk[1477]
2011-08-19 15:30:43 +00:00
Romain Quetiez
cc7844ea10 Security: protected bulk modify against HTTP/Post piracy
SVN:trunk[1476]
2011-08-19 15:26:05 +00:00
Denis Flaven
22bdc02b1b Support the selection (via an autocomplete) in a list that contains duplicates
SVN:trunk[1475]
2011-08-19 15:00:33 +00:00
Romain Quetiez
e8586515e3 Fixed regression (HKeys)
SVN:trunk[1474]
2011-08-19 08:51:16 +00:00
Romain Quetiez
071a30d928 Cosmetic on the portal
SVN:trunk[1473]
2011-08-19 07:42:19 +00:00
Denis Flaven
488f1c47bf Fixed Trac #456: 'contact_list' was considered as read-only on tickets.
SVN:trunk[1472]
2011-08-19 07:32:19 +00:00
Romain Quetiez
c15976f148 Internal: leverage display block for displaying link sets in the portal
SVN:trunk[1471]
2011-08-18 16:32:31 +00:00
Romain Quetiez
6f8e2e60ce Internal: the transaction mechanism was inoperant when a form was built within the target page.
SVN:trunk[1470]
2011-08-18 15:00:39 +00:00
Denis Flaven
b7b8da0848 Fixed the computation of IPs in a subnet that failed (returned negative numbers) on some versions of PHP compiled in 32-bit.
SVN:trunk[1469]
2011-08-18 12:05:30 +00:00
Denis Flaven
2f1803b3b6 A mandatory case log field is now considered as 'filled' if it contains a previous entry
SVN:trunk[1468]
2011-08-18 10:45:41 +00:00
Denis Flaven
58e61c9d6b A mandatory case log field is now considered as 'filled' if it contains a previous entry
SVN:trunk[1467]
2011-08-18 10:44:37 +00:00
Denis Flaven
ddd98b9335 Different display for 'Date' fields: shorter field than DateTime since there is no "time" part.
SVN:trunk[1466]
2011-08-18 09:51:10 +00:00
Denis Flaven
278b84ee38 The default value for Date fields is different than for DateTime fields: no 'time' part at the end (use the attribute's own format)
SVN:trunk[1465]
2011-08-18 09:50:16 +00:00
Denis Flaven
c0764bce74 Added smart search for 'Date' fields (and not only DateTime)
SVN:trunk[1464]
2011-08-18 09:48:44 +00:00
Denis Flaven
7cf0e2f747 Bug fix: incorrect detection of the need to fix HK, leading to incorrect data in case of upgrade.
SVN:trunk[1463]
2011-08-18 07:01:08 +00:00
Romain Quetiez
c7e8627679 Fixed regression on the paginated lists
SVN:trunk[1462]
2011-08-17 15:56:34 +00:00
Denis Flaven
1c7d5b8fd2 Added support for an abstract Organization (or Person) class during setup !
SVN:trunk[1461]
2011-08-17 15:20:32 +00:00
Denis Flaven
18217e4adb Bug fix: (side effect of fixing #445) paginate the lists when performing a selection.
SVN:trunk[1460]
2011-08-16 17:07:54 +00:00
Denis Flaven
1357e7e225 Bug fix: paginated display was always displaying 5 items by default...
SVN:trunk[1459]
2011-08-16 16:42:02 +00:00
Denis Flaven
a941c2d14e Allow updating/recomputing of read-only attributes on the fly in the edit form.
SVN:trunk[1458]
2011-08-16 16:16:26 +00:00
Denis Flaven
cb55a75bcf Allow updating/recomputing of read-only attributes on the fly in the edit form.
Also fixed a regerssion due to #446

SVN:trunk[1457]
2011-08-16 15:58:09 +00:00
Denis Flaven
1e20253229 Bug fix: don't assume that the hierachical key is called 'parent_id'
SVN:trunk[1456]
2011-08-16 15:54:22 +00:00
Denis Flaven
53a48dc8e0 Fixed Trac #447: interfaces not showing up on the details of a server when an org is selected: there were collisions in the internal query parameters names ! This is now fixed.
SVN:trunk[1455]
2011-08-16 10:01:14 +00:00
Denis Flaven
2ad9d69396 Implemented the OQL operator ABOVE (and its variants ABOVE STRICT, NOT ABOVE and NOT ABOVE STRICT) that returns the (indirect) parents of a given node in a hierarchy. It's the opposite to 'BELOW' that returns the (indirect) children.
SVN:trunk[1454]
2011-08-16 08:14:11 +00:00
Denis Flaven
74baca3a7b Enhanced interface for complex SLA computations...
SVN:trunk[1453]
2011-08-15 14:06:03 +00:00
Denis Flaven
2bd8700c90 Implementing Trac #419: provide means for the toolkit to fix synchro data sources
SVN:trunk[1452]
2011-08-15 14:01:51 +00:00
Denis Flaven
51bd6cdf97 #446 continuing: sanitizing parameters...
SVN:trunk[1451]
2011-08-15 13:55:59 +00:00
Denis Flaven
b02021a4ff Still fixing regressions caused by Trac#446: XSS vulnerabilities...
SVN:trunk[1450]
2011-08-12 10:06:33 +00:00
Denis Flaven
96f3350029 Fixed the display of 'Used IP Addresses' (i.e. Network interfaces) in the details of a Subnet object.
SVN:trunk[1449]
2011-08-12 09:19:53 +00:00
Romain Quetiez
e2e4c53b0d Fix after security fix
SVN:trunk[1448]
2011-08-11 16:31:59 +00:00
Denis Flaven
9c6605f7e7 Allow export of the config information for documentation purposes
SVN:trunk[1447]
2011-08-11 12:01:53 +00:00
Denis Flaven
f481652666 Trac #445: output of export.php should not be "paginated" !
Bug fix: the number of items displayed in the "paginated" view should be "min_display_limit", as listed in the drop down-box and not always 10 !

SVN:trunk[1446]
2011-08-11 11:59:55 +00:00
Denis Flaven
212389f43e One more regression due to #446: fixed !
SVN:trunk[1445]
2011-08-11 11:57:44 +00:00
Denis Flaven
f68680ada1 Still working on #446: oops, one parameter missing...
SVN:trunk[1444]
2011-08-11 10:53:37 +00:00
Denis Flaven
6859326646 Fixed Trac#446: XSS vulnerabilities... to be tested !
Also fixed the display/download links on documents that were both doing exactly the same thing !

SVN:trunk[1443]
2011-08-11 10:17:03 +00:00
Romain Quetiez
a129c9814f Readme for 1.2 Beta
SVN:trunk[1441]
2011-08-09 09:37:48 +00:00
Denis Flaven
05ee0caec2 Fixed the "more information" url in the itop-config-mgmt module
SVN:trunk[1440]
2011-08-09 08:55:29 +00:00
Denis Flaven
6fff9d6a20 Make the 'agent_id' visible in the state "new" to allow the creation and assigment of a ticket in one click.
SVN:trunk[1439]
2011-08-09 08:34:14 +00:00
Denis Flaven
d2955557bf Allow $SERVER_NAME$ as a placeholder for the server's name in the application root url. Useful for multiple virtual hosts or test systems using DHCP...
SVN:trunk[1438]
2011-08-09 07:57:11 +00:00
Denis Flaven
aa00cd9ae7 "Shortcut" actions are displayed as buttons on the same line as the usual "Actions" button.
SVN:trunk[1437]
2011-08-09 07:51:08 +00:00
Denis Flaven
aa9d9ed578 New config parameter: buttons_position: top | bottom | both
SVN:trunk[1436]
2011-08-09 07:47:50 +00:00
Romain Quetiez
9bd6fa61c5 SQLBlock - removed Warnings in case of empty data set
SVN:trunk[1435]
2011-08-08 16:02:28 +00:00
Denis Flaven
f16997fb2d Productivity enhancement: apply directly the 'next_action' when creating or modifying an object with a life-cycle !
SVN:trunk[1434]
2011-08-08 15:40:51 +00:00
Romain Quetiez
f4c1cf0818 Fixed typo
SVN:trunk[1433]
2011-08-08 14:24:35 +00:00
Denis Flaven
01dd63f623 Cleanup of the way objects are displayed/edited: DisplayBareProperties is now used for displaying (i.e. read-only) or modifying/creating an object.
SVN:trunk[1432]
2011-08-08 12:52:32 +00:00
Denis Flaven
3393808c7a - Enhancement: can now specify 'order_by' in 'list' templates.
- New 'Shortcut Actions' displayed as buttons next to the 'Actions' popup menu.

SVN:trunk[1431]
2011-08-08 12:35:43 +00:00
Denis Flaven
772c892b15 New option DEL_MOVEUP (move the children up one level) for 'on_target_delete' for HierarchicalKey attributes.
SVN:trunk[1430]
2011-08-07 12:24:45 +00:00
Denis Flaven
435d943f47 Cleanup of the way objects are displayed/edited: DisplayBareProperties is now used for displaying (i.e. read-only) or modifying/creating an object. The means that:
1) the display/edition can be customized by overloading this method
2) the plug-ins's method OnDisplayProperties is now called in edition as well

A new class of template is introduced for building custom object displays: ObjectDetailsTemplate.

SVN:trunk[1429]
2011-08-07 08:12:07 +00:00
Denis Flaven
eab1060f8e Adapted the portal to support enhanced attachments either in 'properties' or 'relations'... this is transparent for the end-user of the portal.
SVN:trunk[1428]
2011-08-07 07:55:16 +00:00
Denis Flaven
cb8774370f Enhancement: new configuration parameter 'position' to enable 'attachments' to be displayed either as a separate tab 'Attachments' on inline in the 'Properties' tab (for example when used with a custom 'DisplayBareProperties'.)
SVN:trunk[1427]
2011-08-07 07:52:39 +00:00
Denis Flaven
23b1d15b64 New attribute 'display_style' for Strings, Enums and ExternalKeys: when the list is short, display it as a set of radio buttons instead of a drop-down list. Possible values: 'radio', 'radio_vertical' and 'radio_horizontal'. ('radio' == 'radio_vertical').
SVN:trunk[1426]
2011-08-06 09:51:06 +00:00
Denis Flaven
61727aca02 New configuration parameter: display_actions_at_top: avoid scrolling to see the buttons when assigning a ticket !
SVN:trunk[1425]
2011-08-05 13:28:21 +00:00
Denis Flaven
8cfebdf723 - New configuration parameter deadline_format to specify how to display Deadlines (date or time difference or a mix of the two)
SVN:trunk[1424]
2011-08-05 13:08:56 +00:00
Denis Flaven
506702c50b Enhancement: added the capability to filter (based on user's defined preferences the list of organizations displayed in the drop-down menu)
SVN:trunk[1423]
2011-08-05 11:45:12 +00:00
Denis Flaven
b9de1df6a8 Release note review
SVN:trunk[1422]
2011-08-03 13:49:27 +00:00
Denis Flaven
a7175007be Preparing for the 1.2-beta release
SVN:trunk[1421]
2011-08-03 10:37:55 +00:00
Denis Flaven
5d8acbb41a New type of trigger: TriggerOnPortalUpdate, called when the end-user updates a ticket from the portal.
SVN:trunk[1420]
2011-08-03 10:36:34 +00:00
Denis Flaven
3ccbeac996 Oops, missing Portuguese (Brazilian) dictionary files...
SVN:trunk[1419]
2011-08-03 09:25:19 +00:00
Denis Flaven
1643ba8e9c Added support for the 'Attachments' plug-in into the portal
SVN:trunk[1418]
2011-08-02 10:36:43 +00:00
Denis Flaven
768dbd8946 New module to easily manage attachments
SVN:trunk[1417]
2011-08-02 10:29:59 +00:00
Denis Flaven
c2d02a2394 Put back wsdl documentation
SVN:trunk[1416]
2011-08-02 08:30:43 +00:00
Denis Flaven
b26f2738f6 German localization enhancement by Stephan Rosenke. Thanks Stephan !
SVN:trunk[1415]
2011-08-02 07:53:39 +00:00
Denis Flaven
781ec7e33a In CLI mode, do not depend on the current directory: the script can be run from anywhere.
SVN:trunk[1414]
2011-08-01 16:13:37 +00:00
Denis Flaven
d09db3a920 Better error message if the configuration file exists but is not readable
SVN:trunk[1413]
2011-08-01 16:12:24 +00:00
Denis Flaven
998a8692cb Use a hierarchical key for the parent/child relationship with groups
SVN:trunk[1412]
2011-08-01 15:53:55 +00:00
Denis Flaven
b83ac447e8 Don't make the case log hidden, since it's not hidden in the portal !
SVN:trunk[1411]
2011-08-01 15:46:23 +00:00
Denis Flaven
6688f1811e Improved error handling when loading linkedset as attributes in one go
SVN:trunk[1410]
2011-08-01 15:08:22 +00:00
Denis Flaven
ec26750b58 Bug fix: when changing the currently selected organization, go back to the initial (Welcome) menu instead of trying to stay on the same menu... which caused troubles (e.g. "New Contact" => assertion failed)
SVN:trunk[1409]
2011-08-01 14:17:43 +00:00
Denis Flaven
0f0abc0501 Added a new web service to create UserRequest tickets (similarly to Incidents tickets). Based on code from Vincenzo Todisco.
SVN:trunk[1408]
2011-08-01 14:07:54 +00:00
Denis Flaven
9ad6f2c994 Draft of the 1.2 readme file...
SVN:trunk[1407]
2011-08-01 13:50:07 +00:00
Denis Flaven
abab47558b Adding Japanese translation kindly provided by Tadeshi Kaneda
SVN:trunk[1406]
2011-08-01 13:34:48 +00:00
Denis Flaven
f3147be8f6 Adding Japanese translation
SVN:trunk[1405]
2011-08-01 13:33:34 +00:00
Denis Flaven
af185b79c8 Bug fix: missing title for the menu 'All Opened Changes'
SVN:trunk[1404]
2011-08-01 12:50:26 +00:00
Denis Flaven
3fc686e403 Bug fix: do not modify the page's address (by changing the final anchor) when clicking on a page in a paginated display. Otherwise this interferes with the tabbed navigation.
SVN:trunk[1403]
2011-08-01 12:37:05 +00:00
Denis Flaven
f5ea073c2b Bug fix: when removing a module (like Incident Management) that contained Triggers to such objects, the remaining triggers must be deleted because they reference a non-existing class.
SVN:trunk[1402]
2011-08-01 11:51:11 +00:00
Denis Flaven
aa6d7578d1 Fixed issues when adding/removing modules during the setup:
- When adding modules: the data model was not refreshed in the cache before attempting to load "structure" (or "sample") data
- When removing a module: remaining (invalid) triggers were still used.

SVN:trunk[1401]
2011-08-01 10:30:22 +00:00
Denis Flaven
05338caa23 Modified misleading/outdated comment in the configuration file.
SVN:trunk[1400]
2011-08-01 10:24:36 +00:00
Denis Flaven
a6ac78d7c1 Fix: Make sure that the flash object respects the z-order otherwise the hierarchy/organization picker appears behind the Flash in Chrome and IE.
SVN:trunk[1399]
2011-07-31 19:38:27 +00:00
Denis Flaven
9bcf78bfd6 Enhancement: the number of items is displayed (statically) in the header of the each "details" tab.
SVN:trunk[1398]
2011-07-31 10:45:03 +00:00
Denis Flaven
9c97df5186 MapContextParam: call the parent just in case...
SVN:trunk[1397]
2011-07-31 09:40:00 +00:00
Denis Flaven
c2a8fd4e09 Enhancement: allow to search on Organization's parent and Location's parent.
SVN:trunk[1396]
2011-07-31 09:38:26 +00:00
Denis Flaven
c8b6ec08e7 Bug fix: properly process field names followed by a star (which simply indicates an important field in the CSV import)
SVN:trunk[1395]
2011-07-31 09:30:55 +00:00
Denis Flaven
4293230416 Don't display an error (assertion failed) if the user selects nothing (i.e -- select one --) in the "CSV template" tab.
SVN:trunk[1394]
2011-07-31 09:12:41 +00:00
Denis Flaven
bfddec242b - Fixed the combination of the "PointingTo" conditions, especially when combining several "BELOW" conditions for the same criteria (used for security and context purposes)
- Make sure that the "security" limitiation provided by GetSelectFilter is applied only once to a given filter to avoid the creation of unneeded complex queries

SVN:trunk[1393]
2011-07-31 09:01:45 +00:00
Denis Flaven
ee3652acad Added a useful function for debugging: DebugBacktrace which provides a "light" version of PHP's built-in debug_backtrace().
SVN:trunk[1392]
2011-07-31 08:57:04 +00:00
Denis Flaven
5baa213e6a Better initialization of objects from the "Context" values:
- map the parameters (for example for Provider Contract)
- set the default values when creating a "secondary" object via the (+) button

SVN:trunk[1391]
2011-07-31 08:54:59 +00:00
Denis Flaven
ca8ea8dd02 Fixed the parsing of OQL error messages
SVN:trunk[1390]
2011-07-30 17:25:49 +00:00
Denis Flaven
308d2626a9 Added test cases for the new BELOW operator
SVN:trunk[1389]
2011-07-30 17:23:39 +00:00
Denis Flaven
8cab8dd7b7 Filter audit results using the hierarchies
SVN:trunk[1388]
2011-07-29 10:29:28 +00:00
Denis Flaven
0a5e37c592 Oops: Make sure that the default add-on for SLA computation is enabled by default
SVN:trunk[1387]
2011-07-29 10:27:37 +00:00
Denis Flaven
72326435ce Make sure that the default add-on for SLA computation is enabled by default
SVN:trunk[1386]
2011-07-29 10:14:44 +00:00
Denis Flaven
ca9f17d6e1 Fixed a bug when using a hierarchy of locations, since locatins genreally depends on the object's organization
SVN:trunk[1385]
2011-07-29 10:09:14 +00:00
Denis Flaven
ff89c4d424 CAS authentication improvements:
- Check if the user is part of a group (memberOf)
- Fixed the use of the 'redirect_service' when logging-out

SVN:trunk[1384]
2011-07-28 17:39:49 +00:00
Denis Flaven
fa3b7ce545 Thumbs.db has nothing to do in SVN
SVN:trunk[1383]
2011-07-28 15:21:33 +00:00
Denis Flaven
c85feb7cea - Use the new HierarchicalKeys for Organization and Locations and use the hierarchy of organization for the profiles/user rights.
SVN:trunk[1382]
2011-07-28 15:14:49 +00:00
Denis Flaven
d50f812694 Fix: broken context usage when no context (neither org nor menu) at all
SVN:trunk[1381]
2011-07-28 15:12:16 +00:00
Denis Flaven
c7e27a836a Make sure that the root URL ends with a slash
SVN:trunk[1380]
2011-07-28 13:45:51 +00:00
Denis Flaven
c8a1380bef - Fixed the reporting about the previous version
SVN:trunk[1379]
2011-07-28 13:19:58 +00:00
Denis Flaven
7732c9bc6a Exclude build.bash from the build
SVN:trunk[1378]
2011-07-28 11:26:58 +00:00
Denis Flaven
82c57972c6 Fixing bug #404: context lost when doing certain actions. What was fixed:
- Run Query
- Display Data Model Schema
- Drill-down in charts (OQL & SQL)
- Paginated lists (actually a regression)

What remains:
- Global search...
- Drill-down in Flash "impacts / depends on"

SVN:trunk[1377]
2011-07-27 16:39:17 +00:00
Denis Flaven
0cc0c820a5 Fixed Trac #410: added translation for ticket status (and other enum fields) when displaying the History tab.
SVN:trunk[1376]
2011-07-27 13:06:45 +00:00
Denis Flaven
9150a569a7 Make sure that the dependent fields are initialized in the proper order when applying a stimulus on a n object.
SVN:trunk[1375]
2011-07-27 12:55:16 +00:00
Denis Flaven
3c76b90a48 Added an option to the paginated display: display all elements on one page.
SVN:trunk[1374]
2011-07-27 10:24:06 +00:00
Denis Flaven
5f2a5d9cfa - Fixed Trac #433: triggers creation was incorrect when iTop was installed with a 'prefix' for the DB tables.
- Fixed a bug due to the previous renaming of UpdateObject...

SVN:trunk[1372]
2011-07-26 16:45:02 +00:00
Denis Flaven
4e40702809 Fixed the construction of the menus' URLs:
- The context was not passed all the time (due to typos)
- When the context was empty an extra ampersand was added at the end of the URL, which caused a malformed URL for the 'tab selector' when modifying an object. (i.e the object always opened on the 'Properties' tab instead of the current tab).

SVN:trunk[1371]
2011-07-26 16:22:24 +00:00
Denis Flaven
a2b8813628 - Renamed the method 'UpdateObject' into 'UpdateObjectFromPostedForm' to avoid misunderstandings.
- Fixed (again !) Trac #427: unable to empty a linkset when editing an object.

SVN:trunk[1370]
2011-07-26 16:18:19 +00:00
Denis Flaven
751ab5a4b4 Implemented enhancement #130: keywords to narrow the scope of the global search
SVN:trunk[1369]
2011-07-26 14:18:33 +00:00
Denis Flaven
b6bcade4c0 Better (?) handling of deletion issues during the synchro...
SVN:trunk[1368]
2011-07-26 13:27:03 +00:00
Denis Flaven
d6be6ca92c Fix display issues with the portal's top menu bar.
SVN:trunk[1367]
2011-07-26 13:25:37 +00:00
Denis Flaven
9024e0b2db Use absolute URLs as much as possible to be independent from the page being executed...
SVN:trunk[1366]
2011-07-26 13:24:28 +00:00
Denis Flaven
ecca1aa070 Use absolute URLs as much as possible to be independent from the page being executed...
SVN:trunk[1365]
2011-07-26 13:22:45 +00:00
Denis Flaven
3fde682653 Make sure that the AJax calls use a full/absolute path to the page they call so that they can be embedded anywhere inside the application (i.e. in plug-ins supplied pages as well as 'regular' app pages).
SVN:trunk[1364]
2011-07-26 12:21:53 +00:00
Denis Flaven
aee8a98d84 Implemented two new options for CAS:
- logout_redirect_service
- memberOf

SVN:trunk[1363]
2011-07-26 09:43:21 +00:00
Denis Flaven
3ab670e8c2 Implemented two new options for CAS:
- logout_redirect_service
- memberOf

SVN:trunk[1362]
2011-07-26 09:42:46 +00:00
Denis Flaven
1fc7ce3b81 - Allow search forms to be open by default
- Don't make textarea resizable

SVN:trunk[1361]
2011-07-26 09:41:27 +00:00
Denis Flaven
e8c44951a1 Added two new options for CAS:
- logout_redirect_service
- memberOf

SVN:trunk[1360]
2011-07-26 09:39:45 +00:00
Denis Flaven
c11ca679d4 - Make sure that resulsts tables are always sortable.
SVN:trunk[1359]
2011-07-25 14:32:11 +00:00
Denis Flaven
46781c349f - Setup tested under IE8
- Added migration code, during the setup, for the hierarchical keys

SVN:trunk[1358]
2011-07-25 14:14:05 +00:00
Denis Flaven
189b802452 - Always display the number of elements (and the number of elements selected) when displaying a list.
- Nicer display of paginated lists

SVN:trunk[1357]
2011-07-25 12:25:50 +00:00
Denis Flaven
6b7687c80b - Nicer display of paginated lists
SVN:trunk[1356]
2011-07-25 12:24:23 +00:00
Denis Flaven
906abd5fe6 - Always display the number of elements (and the number of elements selected) when displaying a list.
- Nicer display of paginated lists

SVN:trunk[1355]
2011-07-25 12:23:40 +00:00
Denis Flaven
0c539aada9 Always display the number of elements (and the number of elements selected) when displaying a list.
SVN:trunk[1354]
2011-07-25 12:22:49 +00:00
Denis Flaven
a3611f7f63 Added support of hierarchy in the manipulation of external keys:
- widget

SVN:trunk[1353]
2011-07-22 12:21:21 +00:00
Denis Flaven
d62d6e14c8 Added support of hierarchy in the manipulation of external keys:
- widget

SVN:trunk[1352]
2011-07-22 12:15:49 +00:00
Denis Flaven
4cd4d91225 Added support of hierarchy in the manipulation of external keys:
- widget
- search criteria

SVN:trunk[1351]
2011-07-22 12:15:25 +00:00
Denis Flaven
5257287421 Added support of hierarchy in the manipulation of external keys:
- widget
- search criteria

SVN:trunk[1350]
2011-07-22 12:14:59 +00:00
Denis Flaven
7e60a9fce7 Implementation of a new type of ExternalKey attribute: HierarchicalKey. This attribute implements the "nested set" model and is used to define a hierarchy of an arbitrary depth of objects of the same class. With this new feature it is possible to retrieve in one OQL query (and in one sql query as well) all the children of a given organization.
I'm still keeping (commented out) some of the traces helpful for debugging the construction of the OQL queries.

SVN:trunk[1349]
2011-07-22 12:07:09 +00:00
Denis Flaven
b80cc36fb5 TO BE TESTED: New step in the wizard confirmation of the URL to be used for accessing the application.
SVN:trunk[1348]
2011-07-22 11:55:41 +00:00
Denis Flaven
0e75824247 For the setup: try to make the URL detection work even if the actual PHP file is not part of the URL (i.e when index.php is implicitely added when browsing a folder)
SVN:trunk[1347]
2011-07-22 11:53:02 +00:00
Denis Flaven
7470c8e72e Use the SLAComputation utility to allow plug-ins to implement more complex SLA computation schemes.
SVN:trunk[1346]
2011-07-18 15:08:44 +00:00
Denis Flaven
a04f0ee816 Helper module to plug complex SLA computation schemes. This basic modules performs the simplest computation corresponding to a 24x7 (no holidays) model.
SVN:trunk[1345]
2011-07-18 15:00:50 +00:00
Denis Flaven
d37244e6e2 - Search forms are now expandable/collapsible in the portal, like in the main UI
SVN:trunk[1344]
2011-07-12 11:07:56 +00:00
Denis Flaven
82c4f43c4f Manage properly default parameters for linksets
SVN:trunk[1343]
2011-07-12 11:07:04 +00:00
Romain Quetiez
1c2c244273 Veepee - fixed issue
SVN:trunk[1342]
2011-07-08 12:34:07 +00:00
Romain Quetiez
a991a84a8e New feature: online help on search inputs (date format and operators)
SVN:trunk[1341]
2011-07-08 11:40:57 +00:00
Romain Quetiez
532912984d Preset the object creation form with values (scalars or lists) by the mean of GET arguments. E.g. .../UI.php&operation=new&class=Team&default[org_id]=161&default[member_list][-1234][id]=&default[member_list][-1234][role]=manager
SVN:trunk[1340]
2011-07-07 15:45:35 +00:00
Romain Quetiez
265ef1e1ce Typo in french dictionary
SVN:trunk[1339]
2011-07-07 09:34:40 +00:00
Denis Flaven
70ad369ad6 - removed some debug traces !!
SVN:trunk[1337]
2011-07-06 17:12:18 +00:00
Denis Flaven
723685b4cb - Fixed Trac #429: web browser can crash when a text field contains several times the same URL !!!
SVN:trunk[1336]
2011-07-06 17:09:36 +00:00
Denis Flaven
061711afc8 Added support for OnFormCancel
SVN:trunk[1335]
2011-07-06 16:29:40 +00:00
Denis Flaven
8b6a8f02a4 - Bug fix: n:n wizard, context was lost when searching for objects of a derived class to be added.
- Bug fix: 'Apply stimulus multiple" was saying: "Please select at least one object"

SVN:trunk[1334]
2011-07-06 16:23:54 +00:00
Denis Flaven
893ec0f097 - Allow plug-ins to record specific changes in the object's history
SVN:trunk[1333]
2011-07-06 16:21:19 +00:00
Denis Flaven
7c9d4c76a9 Protect against a multiple stimulus on a set based on an abstract class.
SVN:trunk[1332]
2011-07-05 14:07:02 +00:00
Denis Flaven
52fb63c0ee Handle the OnBeforeUnload events to call OnFormCancel handlers when needed so that the plug-ins have a chance to perform some cleanup.
SVN:trunk[1328]
2011-07-05 08:46:31 +00:00
Denis Flaven
8a547bf104 Internal regressions fixes !!!
SVN:trunk[1327]
2011-07-04 16:36:07 +00:00
Denis Flaven
0019ab216a Fixed a typo: utils::ReadMultipleSelection
SVN:trunk[1326]
2011-07-04 15:44:07 +00:00
Denis Flaven
8d52cd3a58 Fixed a typo: utils::ReadMultipleSelection
SVN:trunk[1325]
2011-07-04 15:02:36 +00:00
Romain Quetiez
c7fbe56423 PPortal web page improvements: protected update feature (class/attcodes explicitely restricted)
SVN:trunk[1324]
2011-07-04 09:54:58 +00:00
Denis Flaven
5ff5ea71de Fixed Trac#424: error when updating the Data Synchro statistics
SVN:trunk[1323]
2011-07-04 08:29:16 +00:00
Denis Flaven
6297526da6 Fixed Trac #427: unable to remove all items from a linkset when editing an object.
SVN:trunk[1322]
2011-07-04 08:21:19 +00:00
Romain Quetiez
56ac89f6a6 Portal web page improvements: wizard buttons and welcome message
SVN:trunk[1321]
2011-07-04 07:26:16 +00:00
Romain Quetiez
aa46ab1a67 Portal users: limit their access depending on their organization!!!!
SVN:trunk[1320]
2011-07-01 15:09:29 +00:00
Romain Quetiez
645b02b2d1 #415 Could not limit user on some organization (symptom: wrong queries... org_id does not exist...)
SVN:trunk[1319]
2011-07-01 15:08:38 +00:00
Romain Quetiez
b2c5f183ec Portal web page improvements: integrating the attachments
SVN:trunk[1318]
2011-07-01 07:48:09 +00:00
Romain Quetiez
c6b60731d8 Internal cosmetic on duration attribute
SVN:trunk[1317]
2011-07-01 07:43:53 +00:00
Denis Flaven
fd2f40f070 - Protect against invalid attributes...
- Use the new absolute URL mechanism
- Added custom sort and Zebra tables for non paginated lists

SVN:trunk[1316]
2011-06-30 17:08:59 +00:00
Denis Flaven
9fef41404f - Added drill-down capability for OQL charts (pie and bars)
- fixed asbolute root path for drill down links

SVN:trunk[1315]
2011-06-30 16:04:18 +00:00
Denis Flaven
017aec3ae8 Added drill-down capability to the SQL blocks
SVN:trunk[1314]
2011-06-30 15:34:56 +00:00
Denis Flaven
2ae4aca687 Added support of 'drill-down' (i.e on_click) on bar charts
SVN:trunk[1313]
2011-06-30 14:38:13 +00:00
Denis Flaven
692fd91801 Finalizing the pagination: a few bug fixes and some cleanup...
SVN:trunk[1312]
2011-06-29 15:09:10 +00:00
Denis Flaven
12ec9c3ba1 Finalizing the pagination: a few bug fixes and some cleanup...
SVN:trunk[1311]
2011-06-29 15:08:36 +00:00
Romain Quetiez
ac5e40f4ed Factorized some code into PortalWebPage (still needs to be used in the std portal implementation)
SVN:trunk[1310]
2011-06-29 09:10:07 +00:00
Denis Flaven
f44afb8ee6 New implementation for displaying long lists: pagination
SVN:trunk[1309]
2011-06-29 08:57:39 +00:00
Denis Flaven
9e01277e49 New implementation for displaying long lists: pagination
SVN:trunk[1308]
2011-06-29 08:56:27 +00:00
Denis Flaven
73dc5eb922 New implementation for displaying long lists: pagination
SVN:trunk[1307]
2011-06-29 08:53:26 +00:00
Romain Quetiez
a5091d9af0 Fixed regression: magic_quote_runtime could be deprecated with recent versions of PHP (setup)
SVN:trunk[1306]
2011-06-28 15:13:10 +00:00
Romain Quetiez
a573d3cfa0 #423 Finalized
SVN:trunk[1305]
2011-06-28 14:28:01 +00:00
Romain Quetiez
c4b7497770 #423 Fixed issues with application root URL = f(mode CLI, modules, web server techno, etc.)
SVN:trunk[1304]
2011-06-28 10:30:03 +00:00
Romain Quetiez
1964658584 Fixed an issue in the internal error reporting (user rights not sufficient to update an object)
SVN:trunk[1303]
2011-06-28 10:23:41 +00:00
Romain Quetiez
077b7be2a4 Fixed regressions with DBObjectSet, impacting the new paginated lists and their menus
SVN:trunk[1302]
2011-06-28 09:32:13 +00:00
Denis Flaven
22c6df1a7a Fixed Trac #422 (detection of magic_quotes_runtime)
SVN:trunk[1301]
2011-06-24 14:46:21 +00:00
Romain Quetiez
54d5497f0a Fixed issues with pagination + core limitations in the use of Object Sets (wrong filter when adding objects to a set)
SVN:trunk[1300]
2011-06-24 09:53:45 +00:00
Romain Quetiez
9d2a8d0a67 Fixed regression with the display of lists based on class that is not a leaf (aka standalone) class
SVN:trunk[1299]
2011-06-23 12:32:15 +00:00
Denis Flaven
20024729ec New implementation for displaying long lists: pagination
SVN:trunk[1298]
2011-06-23 11:01:33 +00:00
Denis Flaven
43315f50ea New implementation for displaying long lists: pagination
SVN:trunk[1297]
2011-06-23 11:01:03 +00:00
Denis Flaven
46edbbbd2b New implementation for displaying long lists: pagination
SVN:trunk[1296]
2011-06-23 10:47:05 +00:00
Denis Flaven
dc3713f0ea New implementation for displaying long lists: pagination
SVN:trunk[1295]
2011-06-23 10:46:10 +00:00
Denis Flaven
01a4a04364 New implementation for displaying long lists: pagination
SVN:trunk[1294]
2011-06-23 10:43:41 +00:00
Romain Quetiez
7384191fb6 Fixed issues in ExtKey Widget
SVN:trunk[1293]
2011-06-22 15:26:36 +00:00
Romain Quetiez
b8c930016f Cosmetic
SVN:trunk[1292]
2011-06-22 08:16:59 +00:00
Romain Quetiez
5d37201391 Fixed issue in the computation of the application absolute path (Windows)
SVN:trunk[1291]
2011-06-22 08:15:30 +00:00
Romain Quetiez
2c8963784c #420 - Data synchro logs: increased the size of the attribute last_error
SVN:trunk[1290]
2011-06-21 15:01:56 +00:00
Romain Quetiez
c42fa13b92 Templates: new type of block = sqlblock, allows for displaying tables/charts based in SQL queries (much quicker for Group By operations)
SVN:trunk[1289]
2011-06-21 13:12:02 +00:00
Romain Quetiez
c02d62044c Dashboard templates: fixed issue with asynchronous mode (still some cosmetic issues) with itopblock and the table format
SVN:trunk[1288]
2011-06-21 13:10:11 +00:00
Denis Flaven
7bcb4ed3b2 New implementation of GetAbsoluteUrlRootPath that no longer requires any parameter.
SVN:trunk[1287]
2011-06-20 14:18:24 +00:00
Denis Flaven
834e9c48e1 Added a display value for the null (i.e empty) value of a combo/autocomplete.
SVN:trunk[1286]
2011-06-20 14:17:24 +00:00
Denis Flaven
ddfc84db6a - New implementation of the UIExtKeyWidget that is no longer limited to editing an attribute of an object
- When needed the drop-down list of organizations is replaced by an autocomplete

SVN:trunk[1285]
2011-06-15 17:06:46 +00:00
Denis Flaven
b4a7d0b86c - New implementation of the UIExtKeyWidget that is no longer limited to editing an attribute of an object
- When needed the drop-down list of organizations is replaced by an autocomplete

SVN:trunk[1284]
2011-06-15 17:06:26 +00:00
Denis Flaven
02cafd0e0b - New implementation of the UIExtKeyWidget that is no longer limited to editing an attribute of an object
- When needed the drop-down list of organizations is replaced by an autocomplete

SVN:trunk[1283]
2011-06-15 17:05:58 +00:00
Denis Flaven
f5891a531e New icon to trigger the filtering on organizations
SVN:trunk[1282]
2011-06-15 17:01:44 +00:00
Romain Quetiez
4681b03646 #122 Optimized the load of data set (do not load unused columns, was provoking the swapping of MySQL tmp memory tables)
SVN:trunk[1281]
2011-06-15 11:59:25 +00:00
Denis Flaven
733953ac99 CAS integration: added support of JA-SIG Central Authentication Service (CAS) with log-off support, using phpCAS API.
SVN:trunk[1280]
2011-06-10 14:51:17 +00:00
Romain Quetiez
4837984ac3 Optimization: autocomplete = do not load every object when determining the list of matches
SVN:trunk[1279]
2011-06-10 09:02:42 +00:00
Romain Quetiez
4efd93defe Optimization: cache the Count of items in an object set
SVN:trunk[1278]
2011-06-08 14:42:51 +00:00
Romain Quetiez
35f7d143b8 Optimization: displaying 1000 object would take real long if many organizations are loaded into iTop (querying all the orgs for each object)
SVN:trunk[1277]
2011-06-08 14:31:22 +00:00
Denis Flaven
d48fd1a12e First prototype (not yet tested) of CAS integration.
SVN:trunk[1276]
2011-06-08 13:34:43 +00:00
Romain Quetiez
a0900cd732 Optimization: do not load the full set of items when it comes to displaying an autocomplete!
SVN:trunk[1275]
2011-06-08 13:30:56 +00:00
Romain Quetiez
64b4922499 Fixed issue in the data model consistency check
SVN:trunk[1274]
2011-05-24 10:26:16 +00:00
Romain Quetiez
4574126428 #408 Case log not working with PHP < 5.3 - the fix preserves the compatibility with installed version (but the dates are lost)
SVN:trunk[1273]
2011-05-23 14:56:09 +00:00
Romain Quetiez
9704dd8e35 Improved import.php and synchro_import.php: added 'date_format' (example: %d/%m/%Y %H:%i:%s)
SVN:trunk[1272]
2011-05-23 13:42:33 +00:00
Romain Quetiez
f8d794bc93 Reduces the annoyance of bug #408 (dates not visible in the case log if PHP < 5.3)
SVN:trunk[1271]
2011-05-20 13:42:57 +00:00
Romain Quetiez
5c7c7b98ee Dehardcoded against 'ticket_log', allowing for several case log attributes
SVN:trunk[1270]
2011-05-19 14:38:46 +00:00
Romain Quetiez
3826c1f886 #405 Could not install without the module 'User Request Management'
SVN:trunk[1269]
2011-05-13 16:00:21 +00:00
Romain Quetiez
58844b04ef #403 Partial installation not working (error on ticket form)
SVN:trunk[1268]
2011-05-13 15:09:55 +00:00
Romain Quetiez
178f7f3426 Typo in dictionary
SVN:trunk[1267]
2011-05-06 09:05:22 +00:00
Denis Flaven
8b0214eeee Preparing for the 1.1 release.
SVN:trunk[1265]
2011-05-04 08:56:59 +00:00
Denis Flaven
c6454c5a8e Completed the Portuguese/Brazilian translation, thanks to Marco Tulio !
SVN:trunk[1264]
2011-05-02 15:36:32 +00:00
Denis Flaven
6fd3bdbef4 Final touch to the 1.1 build: readme "touch" and "doc" review.
SVN:trunk[1263]
2011-05-02 13:18:12 +00:00
Denis Flaven
4a12c531e6 Last finishing touch to the Italian localization. Now 100% complete !
SVN:trunk[1262]
2011-05-02 13:06:37 +00:00
Denis Flaven
df086c8ce2 - Better display of the "Resolved Request" form, where the user can submit their satisfaction & feedbacks. Now aligned with the display of the ticket's details.
SVN:trunk[1261]
2011-05-02 12:58:32 +00:00
Romain Quetiez
d66e413289 Typo in french dictionary
SVN:trunk[1260]
2011-05-02 12:37:14 +00:00
Romain Quetiez
938d383efd #379 GetAbsoluteUrlRoot becomes GetAbsoluteUrlAppRoot which will simplify the development of plugins, fixed a cosmetic issue in export.php (format: html + iTop not installed in the url root path)
SVN:trunk[1259]
2011-05-02 09:34:45 +00:00
Romain Quetiez
cc35e41028 Ooooops -removed debugging traces
SVN:trunk[1258]
2011-05-02 08:48:46 +00:00
Denis Flaven
0771fd0636 Completion of the Italian localization !
SVN:trunk[1257]
2011-04-29 14:26:17 +00:00
Denis Flaven
e4fa7ba983 Properly manage carriage returns/line feeds in CaseLog records.
SVN:trunk[1256]
2011-04-29 13:57:46 +00:00
Denis Flaven
109e8f6157 Undoing previous commit - keep the old icon, shouldn't have been changed.
SVN:trunk[1255]
2011-04-29 13:53:37 +00:00
Romain Quetiez
99bce469a1 CSV import: regression due to a recent enhancement (labels) and the fact that some labels are redundant (e.g. "Location" used both for Server/location_id and Server/location_name
SVN:trunk[1254]
2011-04-29 12:30:56 +00:00
Denis Flaven
e439797767 Fixed Character encoding issues in the Hungarian translation.
SVN:trunk[1253]
2011-04-29 09:48:56 +00:00
Denis Flaven
7f17acf553 Added Hungarian translation (and fixed the default dictionaries for Italian as well).
SVN:trunk[1252]
2011-04-28 17:23:45 +00:00
Denis Flaven
5e64834b06 Fixed Trac #301: don't force users back into the portal if they are not "portal" users.
SVN:trunk[1251]
2011-04-28 15:43:44 +00:00
Romain Quetiez
79fbec3675 Readme updated with latest fixes
SVN:trunk[1250]
2011-04-28 15:41:46 +00:00
Denis Flaven
f4e796f607 Implemented Trac #347: Allow portal users to update their tickets by adding a comment which gets appended to the log.
SVN:trunk[1249]
2011-04-28 15:31:22 +00:00
Romain Quetiez
0d710d0464 #355 (continuation of the fix) import.php to support localized names in the specification of reconciliation keys, and allowing to specify an external key though it is given as an external field in the input columns
SVN:trunk[1248]
2011-04-28 14:02:01 +00:00
Romain Quetiez
40701f3f36 Added helper tools to ease the setup of cron.php
SVN:trunk[1247]
2011-04-28 12:02:44 +00:00
Romain Quetiez
fcabb8fc43 CRON default duration set to 10 minutes
SVN:trunk[1246]
2011-04-28 08:47:44 +00:00
Romain Quetiez
4c64419f19 Finalized the doc and readme for release 1.1
SVN:trunk[1245]
2011-04-28 08:44:46 +00:00
Romain Quetiez
c8c388dac5 Using iTop in mode CLI: let PHP display the fatal error "unknown function mysql_connect:
SVN:trunk[1244]
2011-04-28 07:50:22 +00:00
Romain Quetiez
374858ef73 Fixed bug: Web services in CLI mode failing with an error when attempting to include APPROOT
SVN:trunk[1243]
2011-04-28 07:28:40 +00:00
Romain Quetiez
d45149a327 Readme for 1.1 RC (draft)
SVN:trunk[1242]
2011-04-27 08:39:13 +00:00
Denis Flaven
0ea9968797 Fixed Trac #391: Support Agent profile was wrong (no rights to modify UserRequest tickets).
SVN:trunk[1241]
2011-04-27 08:06:13 +00:00
Denis Flaven
b68ac3916f Aligned the display of the case log (and properties) of a ticket in the User Portal to what is done in the normal UI: better look (multi-column, fieldsets, wider case log at the bottom).
SVN:trunk[1240]
2011-04-26 16:49:28 +00:00
Romain Quetiez
e5c46340d1 Plugin API: added OnIsModified()
SVN:trunk[1239]
2011-04-26 16:03:01 +00:00
Romain Quetiez
1e6887062f Data synchro: added the support of link sets (to import user accounts)
SVN:trunk[1238]
2011-04-26 15:29:16 +00:00
Romain Quetiez
fc0f6b636e Data sync: fixed issue with the check while creating a new data source (depending on the target class)
SVN:trunk[1237]
2011-04-26 15:24:13 +00:00
Denis Flaven
bcb1864963 Fixed Trac#385: clearing an autocomplete foeld (for instance in a search form) now has an immediate effect.
SVN:trunk[1236]
2011-04-26 13:41:08 +00:00
Denis Flaven
3a1932b742 Typo: double PHP closing tag !
SVN:trunk[1235]
2011-04-26 13:38:56 +00:00
Denis Flaven
438f7f19c0 Italian localization
SVN:trunk[1234]
2011-04-26 13:37:58 +00:00
Denis Flaven
15b8b18b90 Adding Italian localization, thanks to Marialaura Colantoni
SVN:trunk[1233]
2011-04-22 15:59:31 +00:00
Denis Flaven
b9f467f08f Dictionary files that follow the naming convention <Lang>.dict.<ModuleName>.php are now loaded automatically without the need to specify them explicitely in the module definition file.
SVN:trunk[1232]
2011-04-22 15:53:21 +00:00
Denis Flaven
9f779b8dfe English dictionary cleanup/completion.
SVN:trunk[1231]
2011-04-22 15:51:23 +00:00
Denis Flaven
8ce3c48446 New option group_by_expr for "group_by' display blocks (to be used in templates) to specify a PHP expression to use for the group by. This allows to build dashboards where dates are grouped by the day of the month, for example.
SVN:trunk[1230]
2011-04-22 15:49:01 +00:00
Denis Flaven
f84d91e482 Removed the 'bgiframe' javascript , which was designed for fixing IE6 issues only and causes troubles with IE9.
SVN:trunk[1229]
2011-04-22 15:45:19 +00:00
Denis Flaven
c6493f6cdc Dictionary files that follow the naming convention <Lang>.dict.<ModuleName>.php are now loaded automatically without the need to specify them explicitely in the module definition file.
SVN:trunk[1228]
2011-04-22 15:44:50 +00:00
Romain Quetiez
fb87911677 #378 Data Synchro - leave the replica in state 'synchronized' if failing to update (update then delete)
SVN:trunk[1227]
2011-04-22 14:52:33 +00:00
Romain Quetiez
60b2162d84 Data synchro: added notifications in case of error + fixed a bug in the error reporting (reconciliation on null values, last error was not recorded)
SVN:trunk[1226]
2011-04-22 13:54:16 +00:00
Denis Flaven
e42b0513a0 Removed the 'bgiframe' javascript , which was designed for fixing IE6 issues only and causes troubles with IE9.
SVN:trunk[1225]
2011-04-22 13:30:41 +00:00
Romain Quetiez
f92a7df522 Data synchro: added "contact to notify in case of error"
SVN:trunk[1224]
2011-04-21 09:30:30 +00:00
Romain Quetiez
b7bd1a5943 Data synchro: if the object is deleted from within iTop, do cleanup sync table and replica as well
SVN:trunk[1223]
2011-04-21 09:04:34 +00:00
Denis Flaven
69f21b9b79 - English dictionary completion for 1.1 !
SVN:trunk[1222]
2011-04-20 16:11:47 +00:00
Romain Quetiez
6614a90e38 Wiki formatting: automatic detection of urls
SVN:trunk[1221]
2011-04-20 11:47:21 +00:00
Romain Quetiez
88a29fd8d1 #370 standard argument for CLI/REST services: param_file
SVN:trunk[1220]
2011-04-19 15:48:39 +00:00
Denis Flaven
7e2982b848 Added methods to trace the completion of the localization.
SVN:trunk[1219]
2011-04-19 13:22:18 +00:00
Denis Flaven
ed5d59153b Update/cleanup to the French dictionary.
SVN:trunk[1218]
2011-04-19 13:21:01 +00:00
Romain Quetiez
ab3fd7f1b4 Internal: keep track of class declaration source files
SVN:trunk[1217]
2011-04-19 12:22:32 +00:00
Denis Flaven
6e685feb9f Fixed the creation of the "Portal" profile that now behaves like a standard profile and therefore requires the proper rights.
SVN:trunk[1216]
2011-04-13 13:11:51 +00:00
Denis Flaven
d8c5f26aed Fix for IE8: On IE <button type="submit"> does not submit the form if an onClick action is specified !
SVN:trunk[1215]
2011-04-13 09:53:59 +00:00
Romain Quetiez
ada0b310ae cron.php - Fixed error message
SVN:trunk[1214]
2011-04-13 09:16:37 +00:00
Denis Flaven
1f43ba3654 Oops: missing file in the commit.
SVN:trunk[1213]
2011-04-13 09:16:07 +00:00
Denis Flaven
cb1628c759 Documentation updated for the 1.1-beta release. Still to be finalized for 1.1-RC.
SVN:trunk[1212]
2011-04-12 13:09:46 +00:00
Romain Quetiez
605edc261d Readme file ok for the Beta
SVN:trunk[1211]
2011-04-12 13:04:20 +00:00
Denis Flaven
46e7bbe2c8 Bug fix: prevent (infinite) recursion when building search form with external keys, that point to search form with external keys, etc...
Now support nested search dialogs properly...

SVN:trunk[1210]
2011-04-12 09:37:52 +00:00
Romain Quetiez
a6ac44204c Readme for 1.1 beta (draft)
SVN:trunk[1209]
2011-04-12 08:51:10 +00:00
Denis Flaven
af63233fac Styles fix for IE8.
SVN:trunk[1208]
2011-04-11 16:18:20 +00:00
Romain Quetiez
b1b913d891 Fixed mix btw French and English dictionaries (regression)
SVN:trunk[1207]
2011-04-11 16:18:14 +00:00
Denis Flaven
be5bbdf26c IE8 bug: one comma too many !
SVN:trunk[1206]
2011-04-11 16:17:25 +00:00
Denis Flaven
b03e9a969c Relative path to the setup's documentation.
SVN:trunk[1205]
2011-04-11 12:35:48 +00:00
Denis Flaven
c56c662be7 French translation cleanup: removed the doubled backslahes \\
SVN:trunk[1204]
2011-04-11 12:13:20 +00:00
Denis Flaven
6d34c2aa93 - Partial bug fix: enhancement to support extkey widgets (autocomplete) in nested search forms... still not completely fixed, bug showing some progress.
SVN:trunk[1203]
2011-04-11 12:11:57 +00:00
Denis Flaven
af20723c8c Fix the display width of case logs. Make sure that the field wraps even in case of very long strings inside the field.
SVN:trunk[1202]
2011-04-11 11:54:15 +00:00
Denis Flaven
35f09c3091 Don't use removed a field !
SVN:trunk[1201]
2011-04-11 10:27:12 +00:00
Denis Flaven
5f04a54df3 Profiles adjustements: make some links delete-able by Service Mgrs and Problem Mgrs.
SVN:trunk[1200]
2011-04-11 09:20:57 +00:00
Denis Flaven
19bbde6144 - Cleanup of the dictionary usage.
- Improvements to the French translation.

SVN:trunk[1199]
2011-04-11 09:11:00 +00:00
Denis Flaven
6fe81320c0 - English dictionary completion.
SVN:trunk[1198]
2011-04-11 08:39:18 +00:00
Erwan Taloc
d1c808b2c3 Update change Mgmt Module to display properly fields
Update French dictionary for Problem Management

SVN:trunk[1197]
2011-04-08 13:02:09 +00:00
Erwan Taloc
e3697c37f3 Mise à jour DEL MANUAL for SoftwareInstances
SVN:trunk[1196]
2011-04-08 12:42:18 +00:00
Denis Flaven
a9c6d81130 - Dictionary entries (partial) for the SynchroDataSource objects
SVN:trunk[1195]
2011-04-08 12:26:05 +00:00
Romain Quetiez
8ff40fb4b8 Deletion: entirely reviewed to take into account the objects being synchronized by an external data source, or the plugins constraints.
SVN:trunk[1194]
2011-04-08 11:29:25 +00:00
Denis Flaven
037d6cc4ba - Special handling (using some custom code - temporary solution) of the 'ticket_log' attribute: the attribute is displayed at the bottom of the "Properties" page and takes the whole width of the page.
SVN:trunk[1193]
2011-04-08 10:22:18 +00:00
Denis Flaven
4b1726c1ca Proper display of the menu !
SVN:trunk[1192]
2011-04-08 10:09:52 +00:00
Erwan Taloc
0fac58248e Update Display for tickets.
Add naming convention for Person and Database Instances

SVN:trunk[1191]
2011-04-07 19:09:42 +00:00
Denis Flaven
3a486f8edd - Adjusted the default ITIL profiles definitions
SVN:trunk[1190]
2011-04-07 16:12:07 +00:00
Denis Flaven
4fefaa5658 Make sure that we initialize the list of modules with just the default config and not the previous config. Setup now supports removing modules (even if the actual data are NOT removed from the database, yet).
SVN:trunk[1189]
2011-04-07 08:22:57 +00:00
Denis Flaven
65ef621e6f - Bug fix: Bulk modify was failing on a list of tickets in different states.
SVN:trunk[1188]
2011-04-07 07:47:28 +00:00
Denis Flaven
1a818f309d - Revised styles for a nicer/cleaner display of the details and forms.
SVN:trunk[1187]
2011-04-07 07:44:09 +00:00
Denis Flaven
1a74fe1ec3 Bug fix: when doing a bulk modify (or bulk apply stimulus) the external keys that were read-only in the edition form were displayed as "ClassName #id" instead of using their friendly name. This is now fixed, but requires a load of the target object.
SVN:trunk[1186]
2011-04-06 19:13:08 +00:00
Denis Flaven
089a9fcf4a - Make sure that the data (smaples and structure) from hidden modules are loaded as well. (Symptom: sample EmailNotifications were not loaded)
- Make sure that the "synchrodatasource" file gets loaded as part of the "standard" app modules, even when upgrading "in-place" an existing iTop configuration file.

SVN:trunk[1185]
2011-04-06 18:42:27 +00:00
Denis Flaven
e1df33c7d0 - Make the triggers and email action search-able and export/import-able using the standard user interface.
SVN:trunk[1184]
2011-04-06 18:40:22 +00:00
Denis Flaven
ee0fcdd42e Fixed Trac #371: popup dialog's dimensions (welcome screen and create or lookup dialogs) are now adjusted to fit into the screen.
SVN:trunk[1183]
2011-04-06 18:21:43 +00:00
Denis Flaven
7908b87881 - Make sure that the search form preserves it's "action" (i.e. target page) when reloading (when specifying a derived class). This was breaking the UniversalSearch page.
- Prepare for the style cleanup
- Don't display the menu to create a new 'Email Notification" when listing the notifications sent on a ticket (in the Notifications tab) !

SVN:trunk[1182]
2011-04-06 16:39:42 +00:00
Denis Flaven
8e359682ae - Make the navigation (Back / Cancel) work properly on bulk actions.
- Prepare for the style cleanup.

SVN:trunk[1181]
2011-04-06 16:34:44 +00:00
Denis Flaven
8f2089e1f6 - Fixed an error appearing only for non admins.
- Admin menu should never appear for non-admins, even empty
- Synchro Data Source objects are for admins only

SVN:trunk[1180]
2011-04-06 15:18:59 +00:00
Denis Flaven
8d61af3d22 Adjusting the French translation.
SVN:trunk[1179]
2011-04-06 09:43:35 +00:00
Denis Flaven
5e234eefe9 Special class/style for form details.
SVN:trunk[1178]
2011-04-05 13:42:43 +00:00
Romain Quetiez
25c529a797 #359 Dehardcoded the timezone (while preserving 'Europe/Paris' as the default)
SVN:trunk[1177]
2011-04-05 12:22:38 +00:00
Denis Flaven
446a8f74fb Enhancement of the forms presentation.
SVN:trunk[1176]
2011-04-05 12:13:44 +00:00
Denis Flaven
144af46e8b Fixed Track #375: Display scroll bars appropriately when dealing with big CSV load jobs.
SVN:trunk[1175]
2011-04-04 17:19:09 +00:00
Romain Quetiez
d33217285a New option: apc_cache.query_ttl (defaults to 3600s)
SVN:trunk[1174]
2011-04-04 16:20:18 +00:00
Romain Quetiez
6ff5b499b0 AttributeCaseLog finalized (history, easy migration of AttributeText, wiki formatting)
SVN:trunk[1173]
2011-04-04 14:15:33 +00:00
Denis Flaven
0c084c0b17 Delayed startup for all non-important javascript effects to speed-up the display of the pages.
SVN:trunk[1172]
2011-04-04 14:11:07 +00:00
Romain Quetiez
36dd9fc05e New option: apc_cache.enabled = true by default (beta)
SVN:trunk[1171]
2011-04-04 14:04:30 +00:00
Denis Flaven
4febe204e1 - Finishing touch to the DataExchange: various cosmetic fixes
SVN:trunk[1170]
2011-04-04 13:03:11 +00:00
Denis Flaven
9e2c556805 Load the config before using it !
SVN:trunk[1169]
2011-04-04 10:18:03 +00:00
Denis Flaven
3a0be981d6 Added the detection & logging of APC.
SVN:trunk[1168]
2011-04-04 09:57:35 +00:00
Romain Quetiez
44f661cea4 APC cache: fixed an issue with cache reset
SVN:trunk[1167]
2011-04-04 08:58:59 +00:00
Denis Flaven
195c1dabf8 New type of Attribute "CaseLog" (under construction !)
SVN:trunk[1166]
2011-04-04 08:37:30 +00:00
Denis Flaven
ce13b05363 Fixed Trac#367: typo !
SVN:trunk[1165]
2011-04-01 10:48:11 +00:00
Denis Flaven
be4674de11 Fixed Trac#368: (regression compared to 1.0.2) textarea was too small when exporting a list as CSV.
SVN:trunk[1164]
2011-04-01 10:43:07 +00:00
Denis Flaven
911d4177cc - Various fixes an finishing touch to the setup: support of "named" root modules, streamlined back/next processing, cleaner "summary" screen, etc...
SVN:trunk[1163]
2011-04-01 10:02:40 +00:00
Denis Flaven
237e36f562 - Protect against javascript js files being kept in the browser's cache when upgrading an iTop instance.
SVN:trunk[1162]
2011-04-01 09:58:53 +00:00
Romain Quetiez
5fa64ab3d2 Deletion: the message "object deleted" was displayed twice since the last review of the deletion
SVN:trunk[1161]
2011-04-01 07:29:08 +00:00
Romain Quetiez
ad98b8893f Cosmetic: changed error message when dependencies cannot be solved
SVN:trunk[1160]
2011-04-01 07:15:09 +00:00
Romain Quetiez
851b41670e New setup: fixed bug in the HTML (missing Next button on IE8)
SVN:trunk[1159]
2011-03-31 13:03:09 +00:00
Romain Quetiez
d4321ec1ce #366 Global search case sensitive or not working at all (issue with COLLATION)
SVN:trunk[1158]
2011-03-31 08:29:02 +00:00
Denis Flaven
e3ac7067f7 New implementation of the setup:
- All actions are performed asynchronously at the end of the setup
- Supports upgrading and reinstalling (to add modules)

SVN:trunk[1157]
2011-03-30 17:28:01 +00:00
Denis Flaven
eb3d226b3d Change the default collation to be consistent with the DB definition.
SVN:trunk[1156]
2011-03-30 15:37:10 +00:00
Romain Quetiez
5a30986690 Setup: Speedup profiles creation, and implemented incremental update for application upgrade
SVN:trunk[1155]
2011-03-30 08:34:39 +00:00
Romain Quetiez
b423e98295 Optimizations:
- Setup: grouped CREATE TABLE / ALTER TABLE statements in one single CREATE table
- Every page: cache the prepared queries and data model into APC
Cleanup: removed unused verb RegisterPlugin
Fix: GetObject could fail (could not find the reference from within the forum)

SVN:trunk[1154]
2011-03-30 08:30:42 +00:00
Romain Quetiez
bdf46e8136 Optimization in the setup: 10 queries to insert the 1500 action grant records
SVN:trunk[1153]
2011-03-29 14:43:22 +00:00
Romain Quetiez
d4bfa4c48f Optimization in the setup: 10 queries to insert the 1500 action grant records
SVN:trunk[1152]
2011-03-29 14:28:47 +00:00
Romain Quetiez
30a1528a28 Removed the AttributeWikiText which was strictly equivalent to AttributeText
SVN:trunk[1151]
2011-03-29 14:13:16 +00:00
Romain Quetiez
7ae02a7c5b Enablers for the current setup improvements
SVN:trunk[1150]
2011-03-28 14:03:34 +00:00
Denis Flaven
e5682fd2e9 Plug-ins integration: added the ability to manage attachments while creating a new object.
SVN:trunk[1149]
2011-03-25 17:09:50 +00:00
Romain Quetiez
c1b5614268 New verb for application extensions: OnFormCancel
SVN:trunk[1148]
2011-03-25 13:50:49 +00:00
Denis Flaven
5ad7ea1b7b Fixed Trac #365: Give the user some feedback when the password was successfully changed/set. Note that iTop does not check that the new password is different from the old one.
SVN:trunk[1147]
2011-03-24 17:34:00 +00:00
Romain Quetiez
30f4ff8765 Fixed a bug with APC version < 3.0.7
SVN:trunk[1146]
2011-03-24 17:01:59 +00:00
Denis Flaven
bec8b57fe1 Implementation of bulk modify and bulk apply stimulus... to be tested !
SVN:trunk[1145]
2011-03-23 16:22:35 +00:00
Romain Quetiez
9b50124513 Dev: improved performance measure tooling
SVN:trunk[1144]
2011-03-23 14:09:51 +00:00
Denis Flaven
c9b4468f17 Experimental support of APC to speed-up the application.
SVN:trunk[1143]
2011-03-23 14:09:39 +00:00
Romain Quetiez
3790c8f7d5 Fixed a regression in the deletion (and simplified the algorithm, though more queries will be issued)
SVN:trunk[1142]
2011-03-23 08:38:49 +00:00
Romain Quetiez
8f4ee29c69 #362 New capability for attributes derived from AttributeString: specify a validation_pattern (regexp)
SVN:trunk[1141]
2011-03-21 16:06:41 +00:00
Romain Quetiez
cf737bb8ad Added a query usage example with REGEXP
SVN:trunk[1140]
2011-03-21 15:28:31 +00:00
Romain Quetiez
a222b33566 CRON - admin only + queues with timer (field 'planned')
SVN:trunk[1139]
2011-03-21 15:17:08 +00:00
Romain Quetiez
78396eafe3 Cron - enabled mode CLI
SVN:trunk[1138]
2011-03-21 11:41:08 +00:00
Romain Quetiez
de5ccf5908 Background processes - API ready for periodicity management
SVN:trunk[1137]
2011-03-21 11:17:42 +00:00
Romain Quetiez
c3bd0b1b9e Check SLA for tickets, integrated into the internal CRON architecture (and moved into the Tickets module)
SVN:trunk[1136]
2011-03-21 10:57:37 +00:00
Romain Quetiez
736247f6e1 Email sent in asynchronous mode: forgot cron.php
SVN:trunk[1135]
2011-03-18 12:17:04 +00:00
Romain Quetiez
3074683274 Email sent in asynchronous mode: forgot two files...
SVN:trunk[1134]
2011-03-18 12:13:04 +00:00
Denis Flaven
4929f94c20 Protect the output of the config file against values containing quotes.
SVN:trunk[1133]
2011-03-18 11:22:23 +00:00
Romain Quetiez
b8b20f82d7 Email sent in asynchronous mode (established the base for an application internal CRON, task queue, etc.) with adjustable configuration (disable by default). Also improved the OQL: IS_NULL() and REGEXP have been added.
SVN:trunk[1132]
2011-03-18 11:15:09 +00:00
Romain Quetiez
7989cf622f CSV import: fixed a few issues (restricted to N-N links) + added arguments to the export page, to allow for exporting N-N links
SVN:trunk[1130]
2011-03-15 12:19:04 +00:00
Romain Quetiez
f3cc490295 #328 Added the capability to import/export link sets in CSV format
SVN:trunk[1129]
2011-03-14 14:11:08 +00:00
Romain Quetiez
52a47b193d #360 Wrong COUNT when using JOINS (+ other conditions)
SVN:trunk[1128]
2011-03-11 17:47:03 +00:00
Denis Flaven
cfbf77544e Adjust the relative path to 'ajax.render.php' so that it can be called from the portal pages as well.
SVN:trunk[1125]
2011-03-11 11:11:56 +00:00
Romain Quetiez
0b32f511b8 Plugin API - alpha version
SVN:trunk[1124]
2011-03-11 11:04:50 +00:00
Denis Flaven
bca713a964 Search forms enhancement: when a search criteria is an external (foreign) key, use an autocomplete instead of of drop-down list, when the number of different values is too big, as in other forms.
SVN:trunk[1123]
2011-03-09 16:39:58 +00:00
Romain Quetiez
692f7060ea #355 CSV Import (non interactive) now supporting localized column headers, making it possible to import directly data generated by the interactive export. NOTE: to achieve this, the default separator is now the coma (whereas the default separator in XCel sheets is the semicolumn)
SVN:trunk[1122]
2011-03-09 09:19:03 +00:00
Romain Quetiez
4fa9933dc7 #340 Fixed OQL parsing issue - parameters in IN()/NOT IN() clauses
SVN:trunk[1121]
2011-03-08 15:51:11 +00:00
Denis Flaven
45134e182d Fixed Trac#313: Provider contracts are filtered on the 'provider_id' - for filtering in the UI via the drop-down list of Organizations and for the security profiles ("Allowed Organizations"). The mapping for 'org_id', if any, is now taken into account by the security.
SVN:trunk[1120]
2011-03-08 12:31:16 +00:00
Romain Quetiez
38a502aa25 #271 Internal - Removed a workaround made unnecessary with fix [1108]
SVN:trunk[1119]
2011-03-08 12:23:04 +00:00
Denis Flaven
49e05acd4b Fixed Trac #156: make sure the hierarchical ZLists are supported everywhere (final cleanup).
SVN:trunk[1118]
2011-03-08 11:19:38 +00:00
Denis Flaven
089407119b Thanks to Schlobinux for the fix of Trac#336.
SVN:trunk[1117]
2011-03-08 10:52:58 +00:00
Denis Flaven
6262fa1d26 Fix Trac #336: verification of the directory of the temporary config file was wrong... however the script still assumes that the temporary config file and the final one are stored in the same place... at the root of the iTop installation.
SVN:trunk[1116]
2011-03-08 10:48:35 +00:00
Romain Quetiez
c4cca2b2f8 #348 Multi-column queries not working fine with open joins and if null values to be displayed
SVN:trunk[1115]
2011-03-08 10:46:03 +00:00
Denis Flaven
d5353c111c Fixed Trac#356 (Audit results filtered by context) and #357 (Audit results list not expandable)
SVN:trunk[1114]
2011-03-08 10:31:13 +00:00
Denis Flaven
fd79d30483 Fixed Trac #353: no menu for DBServerInstance objects.
SVN:trunk[1113]
2011-03-07 17:12:30 +00:00
Denis Flaven
d708ef585b Fixed Trac#344: default search behavior for enumerated attributes (and similar types: 'Class', 'Language' and 'FinalClass') is now a strict '=' instead of 'contains'.
SVN:trunk[1112]
2011-03-07 17:06:17 +00:00
Romain Quetiez
6ac06d7e47 #352 Web Service CreateTicket: Search the service subcategory given the found service_id (if not already specified)
SVN:trunk[1111]
2011-03-07 16:58:46 +00:00
Romain Quetiez
019888caff #305 Specified the charset in any call to htmlentities()
SVN:trunk[1110]
2011-03-07 16:43:20 +00:00
Romain Quetiez
e36646a3e6 Fixed undocumented issue: in read-only mode, stimulus where still allowed
SVN:trunk[1109]
2011-03-07 16:40:26 +00:00
Romain Quetiez
8b6672c0dd Data Exchange - Fixed issue in DBObjectSet, doubling the count of SynchroAttribute initially created
SVN:trunk[1108]
2011-03-03 08:34:24 +00:00
Denis Flaven
3d4e76d8b0 Synchro Data Sources Implementation on going...
SVN:trunk[1107]
2011-03-02 17:06:56 +00:00
Romain Quetiez
cf8174d54e Data Exchange - Improved to allow the import of complex attributes like passwords and documents + few fixes
SVN:trunk[1106]
2011-03-02 14:38:12 +00:00
Denis Flaven
33f1ec8bf3 Data Exchange implementation in progress...
SVN:trunk[1105]
2011-03-02 10:49:12 +00:00
Denis Flaven
be1d8674f3 Data Exchange implementation in progress...
SVN:trunk[1104]
2011-03-02 09:12:15 +00:00
Romain Quetiez
76b5bfb19e Data Exchange - Cleanup
SVN:trunk[1103]
2011-03-01 16:33:09 +00:00
Romain Quetiez
bddb8b4c92 Data Exchange - Format and save traces (config option: synchro_trace)
SVN:trunk[1102]
2011-03-01 16:21:04 +00:00
Romain Quetiez
67f8ddf5a8 Data Exchange - Implemented reconciliation on external keys
SVN:trunk[1101]
2011-03-01 13:47:09 +00:00
Denis Flaven
f3f2eb5c79 Synchro Data Sources Implementation on going...
SVN:trunk[1100]
2011-03-01 09:01:44 +00:00
Romain Quetiez
a1b9bdaf66 Data Exchange - Improved handling of deletion (inc. the reporting of it)
SVN:trunk[1099]
2011-02-25 17:22:51 +00:00
Denis Flaven
e020bad17d Synchro Data Sources Implementation on going...
SVN:trunk[1098]
2011-02-24 18:45:13 +00:00
Romain Quetiez
36278d59a8 Data Exchange - Implemented checks on sync startup (user identity, task state, protection against entire obsolescence) and added a "last error" into the logs
SVN:trunk[1097]
2011-02-24 17:21:48 +00:00
Denis Flaven
20d0d33b60 Synchro Data Sources Implementation on going...
SVN:trunk[1096]
2011-02-24 17:09:50 +00:00
Romain Quetiez
573712e9af Data Exchange - Fixed issue when a field is selected for reconciliation but not for update
SVN:trunk[1095]
2011-02-24 15:37:21 +00:00
Romain Quetiez
5897ae5bb9 Data Exchange - Simulation in synchro_import.php now relying on MySQL transactions
SVN:trunk[1094]
2011-02-24 08:47:46 +00:00
Romain Quetiez
cd71f02fad Data Exchange - Implemented reconciliation options + cosmetics on synchro_exec
SVN:trunk[1093]
2011-02-23 17:32:21 +00:00
Denis Flaven
e4df8c8c92 Added synchron statistics and their first display...
SVN:trunk[1092]
2011-02-23 16:49:00 +00:00
Romain Quetiez
d1879d0433 Data Exchange - Simulate mode on synchro_exec + cleanup in traces + handling of null values
SVN:trunk[1091]
2011-02-23 14:55:51 +00:00
Denis Flaven
9e636b1ce5 New display of the "Synchro status/log"
SVN:trunk[1090]
2011-02-23 14:37:23 +00:00
Denis Flaven
cccea50159 Added an extra parameter 'simulate'
SVN:trunk[1089]
2011-02-22 15:21:40 +00:00
Romain Quetiez
3441911781 Fixed regression on AttributeInteger
SVN:trunk[1088]
2011-02-22 14:26:00 +00:00
Romain Quetiez
c97f4d5ee7 Data Exchange - Log statistics
SVN:trunk[1087]
2011-02-22 14:20:46 +00:00
Romain Quetiez
4c637548ac Fixed regression in the audit (new way to translate OQL expression having an impact on DBObjectSearch::MergeWith)
SVN:trunk[1086]
2011-02-21 16:35:47 +00:00
Denis Flaven
721ca8c652 Continuing the implementation of the DataExchange
SVN:trunk[1085]
2011-02-16 17:31:32 +00:00
Romain Quetiez
293877d78a Data Exchange - Replica objects must not be derived from cmdbAbstractObject
SVN:trunk[1084]
2011-02-11 13:15:41 +00:00
Romain Quetiez
d92f89fbe6 Data Exchange - Finalized deletion, changed the definition of attributes (update/reconcile), added an automated test
SVN:trunk[1083]
2011-02-11 09:01:16 +00:00
Romain Quetiez
1da6a264d0 Automatic deletion of links lnkSolutionToCI
SVN:trunk[1082]
2011-02-10 15:13:24 +00:00
Denis Flaven
89b58d44cd Removed a "assertion failed" error message.
SVN:trunk[1080]
2011-02-09 09:44:00 +00:00
Denis Flaven
0b93e6f79e Fixed an incorrect detection of the maximum recursion level
SVN:trunk[1079]
2011-02-08 16:25:18 +00:00
Denis Flaven
eb0ba24d7d - Data Exchange implementation... in progress.
SVN:trunk[1078]
2011-02-08 13:34:47 +00:00
Romain Quetiez
64521eb758 Fixed regression (implementation of the data exchange)
SVN:trunk[1074]
2011-02-07 16:29:49 +00:00
Denis Flaven
2d65325f6f New configuration setting (and new class of Log objects) to keep track of the application's usage: an entry in the log is added each time a user connects to the application. (This feature is disabled by default)
SVN:trunk[1073]
2011-02-07 15:55:39 +00:00
Denis Flaven
a97238c3cd Fixed Trac #351: undefined variable sClass...
SVN:trunk[1072]
2011-02-07 15:51:24 +00:00
Romain Quetiez
ce993b60e4 Data Exchange - Removed the state 'deleted': instead, delete the replica!
SVN:trunk[1068]
2011-02-03 16:39:58 +00:00
Romain Quetiez
283f7dc9f8 CSV import web service - cosmetics on the reporting in case the data set is empty
SVN:trunk[1067]
2011-02-03 15:50:48 +00:00
Romain Quetiez
4441fb41b9 Data Exchange - Fixed a corner case issue (a replica going directly from new to obsolete, then touched again -> back into the picture)
SVN:trunk[1066]
2011-02-03 15:36:37 +00:00
Romain Quetiez
34322045df Data Exchange - forgot a change in the previous commit
SVN:trunk[1065]
2011-02-03 09:57:47 +00:00
Romain Quetiez
b73da47775 Data Exchange - new web service to update data tables
SVN:trunk[1064]
2011-02-03 09:55:17 +00:00
Denis Flaven
3d8ffba2fa Mention that the database user must have the "CREATE VIEW and TRIGGER" privileges for the setup to work fine.
SVN:trunk[1063]
2011-02-03 09:41:32 +00:00
Denis Flaven
f9a380b12d DataExchange: implementation in progress.
SVN:trunk[1062]
2011-02-02 14:48:45 +00:00
Romain Quetiez
a9a530a2cb Core: Join any table to an OQL query (prerequisite to Data Exchange)
SVN:trunk[1061]
2011-02-01 16:54:10 +00:00
Romain Quetiez
ba822a655e Wiki: add links to objects in text attributes
SVN:trunk[1060]
2011-02-01 13:40:51 +00:00
Romain Quetiez
20ec91e9f3 Data ExchangeData Exchange - data structure (ready for sync)
SVN:trunk[1059]
2011-02-01 12:56:26 +00:00
Romain Quetiez
735a9729c0 Data Exchange - data structure
SVN:trunk[1058]
2011-01-31 15:53:07 +00:00
Romain Quetiez
1a52f4de72 #149 Implemented friendly names
SVN:trunk[1057]
2011-01-26 09:43:35 +00:00
Denis Flaven
cb0610bf0b Readme for iTop 1.0.2
SVN:trunk[1055]
2011-01-18 11:38:24 +00:00
Denis Flaven
20ea4644b4 Remove an ambiguous naming when performing a CSV import of DBServerInstance objects.
SVN:trunk[1054]
2011-01-18 11:37:21 +00:00
Denis Flaven
fde336d8dd Cosmetics: make the login & change password form look the same on all browsers.
SVN:trunk[1053]
2011-01-18 09:07:46 +00:00
Denis Flaven
bc78b19ba7 Fixed Trac #348: no validation needed when pressing "Restart".
SVN:trunk[1052]
2011-01-18 09:00:26 +00:00
Denis Flaven
a4883076f8 Fixed Trac #338: when updating a 'dependent' field, don't forget to cascade the refresh in case this field has its own dependent fields.
SVN:trunk[1051]
2011-01-17 17:11:03 +00:00
Denis Flaven
57a0e2d47e Fixed Trac #345: hidden or read-only parameters in a form were not taken into account for computing the allowed values.
SVN:trunk[1050]
2011-01-17 15:13:28 +00:00
Denis Flaven
5a41992739 Trying to make CKEditor work with the "ExtKey" widget. (Trac #343)
Seems to be functional but there is still an "uncaught exception" that pops up from nowhere when closing the dialog.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

@@ -1,5 +1,66 @@
<?php
require_once("../application/utils.inc.php");
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* Class ApplicationContext
*
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
require_once(APPROOT."/application/utils.inc.php");
/**
* Interface for directing end-users to the relevant application
*/
interface iDBObjectURLMaker
{
public static function MakeObjectURL($sClass, $iId);
}
/**
* Direct end-users to the standard iTop application: UI.php
*/
class iTopStandardURLMaker implements iDBObjectURLMaker
{
public static function MakeObjectURL($sClass, $iId)
{
$sPage = DBObject::ComputeStandardUIPage($sClass);
$sAbsoluteUrl = utils::GetAbsoluteUrlAppRoot();
$sUrl = "{$sAbsoluteUrl}pages/$sPage?operation=details&class=$sClass&id=$iId";
return $sUrl;
}
}
/**
* Direct end-users to the standard Portal application
*/
class PortalURLMaker implements iDBObjectURLMaker
{
public static function MakeObjectURL($sClass, $iId)
{
$sAbsoluteUrl = utils::GetAbsoluteUrlAppRoot();
$sUrl = "{$sAbsoluteUrl}portal/index.php?operation=details&class=$sClass&id=$iId";
return $sUrl;
}
}
/**
* Helper class to store and manipulate the parameters that make the application's context
*
@@ -16,12 +77,16 @@ class ApplicationContext
protected $aValues;
protected static $aDefaultValues; // Cache shared among all instances
public function __construct()
public function __construct($bReadContext = true)
{
$this->aNames = array(
'org_id', 'menu'
);
$this->ReadContext();
if ($bReadContext)
{
$this->ReadContext();
}
}
/**
@@ -30,22 +95,56 @@ class ApplicationContext
*/
protected function ReadContext()
{
if (empty(self::$aDefaultValues))
if (!isset(self::$aDefaultValues))
{
self::$aDefaultValues = array();
$aContext = utils::ReadParam('c', array());
foreach($this->aNames as $sName)
{
$sValue = utils::ReadParam($sName, '');
$sValue = isset($aContext[$sName]) ? $aContext[$sName] : '';
// TO DO: check if some of the context parameters are mandatory (or have default values)
if (!empty($sValue))
{
self::$aDefaultValues[$sName] = $sValue;
}
// Hmm, there must be a better (more generic) way to handle the case below:
// When there is only one possible (allowed) organization, the context must be
// fixed to this org
if ($sName == 'org_id')
{
if (MetaModel::IsValidClass('Organization'))
{
$oSearchFilter = new DBObjectSearch('Organization');
$oSearchFilter->SetModifierProperty('UserRightsGetSelectFilter', 'bSearchMode', true);
$oSet = new CMDBObjectSet($oSearchFilter);
$iCount = $oSet->Count();
if ($iCount == 1)
{
// Only one possible value for org_id, set it in the context
$oOrg = $oSet->Fetch();
self::$aDefaultValues[$sName] = $oOrg->GetKey();
}
}
}
}
}
$this->aValues = self::$aDefaultValues;
}
/**
* Returns the current value for the given parameter
* @param string $sParamName Name of the parameter to read
* @return mixed The value for this parameter
*/
public function GetCurrentValue($sParamName, $defaultValue = '')
{
if (isset($this->aValues[$sParamName]))
{
return $this->aValues[$sParamName];
}
return $defaultValue;
}
/**
* Returns the context as string with the format name1=value1&name2=value2....
* return string The context as a string to be appended to an href property
@@ -55,7 +154,7 @@ class ApplicationContext
$aParams = array();
foreach($this->aValues as $sName => $sValue)
{
$aParams[] = $sName.'='.urlencode($sValue);
$aParams[] = "c[$sName]".'='.urlencode($sValue);
}
return implode("&", $aParams);
}
@@ -69,7 +168,7 @@ class ApplicationContext
$sContext = "";
foreach($this->aValues as $sName => $sValue)
{
$sContext .= "<input type=\"hidden\" name=\"$sName\" value=\"$sValue\" />\n";
$sContext .= "<input type=\"hidden\" name=\"c[$sName]\" value=\"".htmlentities($sValue, ENT_QUOTES, 'UTF-8')."\" />\n";
}
return $sContext;
}
@@ -80,7 +179,21 @@ class ApplicationContext
*/
public function GetAsHash()
{
return $this->aValues;
$aReturn = array();
foreach($this->aValues as $sName => $sValue)
{
$aReturn["c[$sName]"] = $sValue;
}
return $aReturn;
}
/**
* Returns an array of the context parameters NAMEs
* @return array The list of context parameters
*/
public function GetNames()
{
return $this->aNames;
}
/**
* Removes the specified parameter from the context, for example when the same parameter
@@ -95,5 +208,154 @@ class ApplicationContext
unset($this->aValues[$sParamName]);
}
}
/**
* Initializes the given object with the default values provided by the context
*/
public function InitObjectFromContext(DBObject &$oObj)
{
$sClass = get_class($oObj);
foreach($this->GetNames() as $key)
{
$aCallSpec = array($sClass, 'MapContextParam');
if (is_callable($aCallSpec))
{
$sAttCode = call_user_func($aCallSpec, $key); // Returns null when there is no mapping for this parameter
}
if (MetaModel::IsValidAttCode($sClass, $sAttCode))
{
$oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
if ($oAttDef->IsWritable())
{
$value = $this->GetCurrentValue($key, null);
if (!is_null($value))
{
$oObj->Set($sAttCode, $value);
}
}
}
}
}
static $m_sUrlMakerClass = null;
/**
* Set the current application url provider
* @param sClass string Class implementing iDBObjectURLMaker
* @return void
*/
public static function SetUrlMakerClass($sClass = 'iTopStandardURLMaker')
{
$sPrevious = self::GetUrlMakerClass();
self::$m_sUrlMakerClass = $sClass;
$_SESSION['UrlMakerClass'] = $sClass;
return $sPrevious;
}
/**
* Get the current application url provider
* @return string the name of the class
*/
public static function GetUrlMakerClass()
{
if (is_null(self::$m_sUrlMakerClass))
{
if (isset($_SESSION['UrlMakerClass']))
{
self::$m_sUrlMakerClass = $_SESSION['UrlMakerClass'];
}
else
{
self::$m_sUrlMakerClass = 'iTopStandardURLMaker';
}
}
return self::$m_sUrlMakerClass;
}
/**
* Get the current application url provider
* @return string the name of the class
*/
public static function MakeObjectUrl($sObjClass, $sObjKey, $sUrlMakerClass = null, $bWithNavigationContext = true)
{
$oAppContext = new ApplicationContext();
if (is_null($sUrlMakerClass))
{
$sUrlMakerClass = self::GetUrlMakerClass();
}
$sUrl = call_user_func(array($sUrlMakerClass, 'MakeObjectUrl'), $sObjClass, $sObjKey);
if (strlen($sUrl) > 0)
{
if ($bWithNavigationContext)
{
return $sUrl."&".$oAppContext->GetForLink();
}
else
{
return $sUrl;
}
}
else
{
return '';
}
}
protected static $m_aPluginProperties = null;
/**
* Load plugin properties for the current session
* @return void
*/
protected static function LoadPluginProperties()
{
if (isset($_SESSION['PluginProperties']))
{
self::$m_aPluginProperties = $_SESSION['PluginProperties'];
}
else
{
self::$m_aPluginProperties = array();
}
}
/**
* Set plugin properties
* @param sPluginClass string Class implementing any plugin interface
* @param sProperty string Name of the property
* @param value scalar Value (numeric or string)
* @return void
*/
public static function SetPluginProperty($sPluginClass, $sProperty, $value)
{
if (is_null(self::$m_aPluginProperties)) self::LoadPluginProperties();
self::$m_aPluginProperties[$sPluginClass][$sProperty] = $value;
$_SESSION['PluginProperties'][$sPluginClass][$sProperty] = $value;
}
/**
* Get plugin properties
* @param sPluginClass string Class implementing any plugin interface
* @return array of sProperty=>value pairs
*/
public static function GetPluginProperties($sPluginClass)
{
if (is_null(self::$m_aPluginProperties)) self::LoadPluginProperties();
if (array_key_exists($sPluginClass, self::$m_aPluginProperties))
{
return self::$m_aPluginProperties[$sPluginClass];
}
else
{
return array();
}
}
}
?>

View File

@@ -0,0 +1,51 @@
<?php
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* Class iPlugin
* Management of application plugin
*
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
interface iApplicationUIExtension
{
public function OnDisplayProperties($oObject, WebPage $oPage, $bEditMode = false);
public function OnDisplayRelations($oObject, WebPage $oPage, $bEditMode = false);
public function OnFormSubmit($oObject, $sFormPrefix = '');
public function OnFormCancel($sTempId); // temp id is made of session_id and transaction_id, it identifies the object in a unique way
public function EnumUsedAttributes($oObject); // Not yet implemented
public function GetIcon($oObject); // Not yet implemented
public function GetHilightClass($oObject);
public function EnumAllowedActions(DBObjectSet $oSet);
}
interface iApplicationObjectExtension
{
public function OnIsModified($oObject);
public function OnCheckToWrite($oObject);
public function OnCheckToDelete($oObject);
public function OnDBUpdate($oObject, $oChange = null);
public function OnDBInsert($oObject, $oChange = null);
public function OnDBDelete($oObject, $oChange = null);
}
?>

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

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

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,28 @@
<?php
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* Class iTopWizardWebPage
*
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
require_once('itopwebpage.class.inc.php');
/**
* Web page to display a wizard in the iTop framework
@@ -24,7 +48,7 @@ class iTopWizardWebPage extends iTopWebPage
$sStyle = ($iIndex == $this->m_iCurrentStep) ? 'wizActiveStep' : 'wizStep';
$aSteps[] = "<div class=\"$sStyle\"><span>$sStepTitle</span></div>";
}
$sWizardHeader = "<div class=\"wizHeader\"><h1>{$this->s_title}</h1>\n".implode("<div class=\"wizSeparator\"><img align=\"bottom\" src=\"../images/wizArrow.gif\"></div>", $aSteps)."<br style=\"clear:both;\"/></div>\n";
$sWizardHeader = "<div class=\"wizHeader\"><h1>".htmlentities($this->s_title, ENT_QUOTES, 'UTF-8')."</h1>\n".implode("<div class=\"wizSeparator\"><img align=\"bottom\" src=\"../images/wizArrow.gif\"></div>", $aSteps)."<br style=\"clear:both;\"/></div>\n";
$this->s_content = "$sWizardHeader<div class=\"wizContainer\">".$this->s_content."</div>";
parent::output();
}

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,826 @@
<?php
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* Class PortalWebPage
*
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
require_once(APPROOT."/application/nicewebpage.class.inc.php");
require_once(APPROOT."/application/applicationcontext.class.inc.php");
require_once(APPROOT."/application/user.preferences.class.inc.php");
define('BUTTON_CANCEL', 1);
define('BUTTON_BACK', 2);
define('BUTTON_NEXT', 4);
define('BUTTON_FINISH', 8);
define('PARAM_ARROW_SEP', '_x_');
class TransactionException extends Exception
{
}
/**
* Web page with some associated CSS and scripts (jquery) for a fancier display
* of the Portal web page
*/
class PortalWebPage extends NiceWebPage
{
/**
* Portal menu
*/
protected $m_sWelcomeMsg;
protected $m_aMenuButtons;
public function __construct($sTitle, $sAlternateStyleSheet = '')
{
$this->m_sWelcomeMsg = '';
$this->m_aMenuButtons = array();
parent::__construct($sTitle);
$this->add_header("Content-type: text/html; charset=utf-8");
$this->add_header("Cache-control: no-cache");
$this->add_linked_stylesheet("../css/jquery.treeview.css");
$this->add_linked_stylesheet("../css/jquery.autocomplete.css");
$sAbsURLAppRoot = addslashes(utils::GetAbsoluteUrlAppRoot()); // Pass it to Javascript scripts
$oAppContext = new ApplicationContext();
$sAppContext = addslashes($oAppContext->GetForLink());
if ($sAlternateStyleSheet != '')
{
$this->add_linked_stylesheet("../portal/$sAlternateStyleSheet/portal.css");
}
else
{
$this->add_linked_stylesheet("../portal/portal.css");
}
$this->add_linked_script('../js/jquery.layout.min.js');
$this->add_linked_script('../js/jquery.ba-bbq.min.js');
$this->add_linked_script("../js/jquery.tablehover.js");
$this->add_linked_script("../js/jquery.treeview.js");
$this->add_linked_script("../js/jquery.autocomplete.js");
$this->add_linked_script("../js/jquery.positionBy.js");
$this->add_linked_script("../js/jquery.popupmenu.js");
$this->add_linked_script("../js/date.js");
$this->add_linked_script("../js/jquery.tablesorter.min.js");
$this->add_linked_script("../js/jquery.tablesorter.pager.js");
$this->add_linked_script("../js/jquery.blockUI.js");
$this->add_linked_script("../js/utils.js");
$this->add_linked_script("../js/forms-json-utils.js");
$this->add_linked_script("../js/swfobject.js");
$this->add_linked_script("../js/jquery.qtip-1.0.min.js");
$this->add_ready_script(
<<<EOF
try
{
//add new widget called TruncatedList to properly display truncated lists when they are sorted
$.tablesorter.addWidget({
// give the widget a id
id: "truncatedList",
// format is called when the on init and when a sorting has finished
format: function(table)
{
// Check if there is a "truncated" line
this.truncatedList = false;
if ($("tr td.truncated",table).length > 0)
{
this.truncatedList = true;
}
if (this.truncatedList)
{
$("tr td",table).removeClass('truncated');
$("tr:last td",table).addClass('truncated');
}
}
});
$.tablesorter.addWidget({
// give the widget a id
id: "myZebra",
// format is called when the on init and when a sorting has finished
format: function(table)
{
// Replace the 'red even' lines by 'red_even' since most browser do not support 2 classes selector in CSS, etc..
$("tbody tr:even",table).addClass('even');
$("tbody tr.red:even",table).removeClass('red').removeClass('even').addClass('red_even');
$("tbody tr.orange:even",table).removeClass('orange').removeClass('even').addClass('orange_even');
$("tbody tr.green:even",table).removeClass('green').removeClass('even').addClass('green_even');
}
});
$(".date-pick").datepicker({
showOn: 'button',
buttonImage: '../images/calendar.png',
buttonImageOnly: true,
dateFormat: 'yy-mm-dd',
constrainInput: false,
changeMonth: true,
changeYear: true
});
//$('.resizable').resizable(); // Make resizable everything that claims to be resizable !
$('.caselog_header').click( function () { $(this).toggleClass('open').next('.caselog_entry').toggle(); });
}
catch(err)
{
// Do something with the error !
alert(err);
}
EOF
);
$this->add_script(
<<<EOF
function CheckSelection(sMessage, sInputId)
{
var bResult;
if (sInputId.length > 0)
{
bResult = ($('input[name='+sInputId+']:checked').length > 0);
}
else
{
// First select found...
bResult = ($('input:checked').length > 0);
}
if (!bResult)
{
alert(sMessage);
}
return bResult;
}
function GetAbsoluteUrlAppRoot()
{
return '$sAbsURLAppRoot';
}
function AddAppContext(sURL)
{
var sContext = '$sAppContext';
if (sContext.length > 0)
{
if (sURL.indexOf('?') == -1)
{
return sURL+'?'+sContext;
}
return sURL+'&'+sContext;
}
return sURL;
}
function GoBack(sFormId)
{
var form = $('#'+sFormId);
var step_back = $('input[name=step_back]');
form.unbind('submit'); // De-activate validation
step_back.val(1);
form.submit(); // Go
}
function GoHome()
{
var form = $('FORM');
form.unbind('submit'); // De-activate validation
window.location.href = '?operation=';
return false;
}
function SetWizardNextStep(sStep)
{
var next_step = $('input[id=next_step]');
next_step.val(sStep);
}
EOF
);
// For Wizard helper to process the ajax replies
$this->add('<div id="ajax_content"></div>');
}
public function SetCurrentTab($sTabLabel = '')
{
}
/**
* Specify a welcome message (optional)
*/
public function SetWelcomeMessage($sMsg)
{
$this->m_sWelcomeMsg = $sMsg;
}
/**
* Add a button to the portal's main menu
*/
public function AddMenuButton($sId, $sLabel, $sHyperlink)
{
$this->m_aMenuButtons[] = array('id' => $sId, 'label' => $sLabel, 'hyperlink' => $sHyperlink);
}
var $m_bEnableDisconnectButton = true;
public function EnableDisconnectButton($bEnable)
{
$this->m_bEnableDisconnectButton = $bEnable;
}
public function output()
{
$sMenu = '';
if ($this->m_bEnableDisconnectButton)
{
$this->AddMenuButton('logoff', 'Portal:Disconnect', utils::GetAbsoluteUrlAppRoot().'pages/logoff.php'); // This menu is always present and is the last one
}
foreach($this->m_aMenuButtons as $aMenuItem)
{
$sMenu .= "<a class=\"button\" id=\"{$aMenuItem['id']}\" href=\"{$aMenuItem['hyperlink']}\"><span>".Dict::S($aMenuItem['label'])."</span></a>";
}
$this->s_content = '<div id="portal"><div id="welcome">'.$this->m_sWelcomeMsg.'</div><div id="banner"><div id="logo"></div><div id="menu">'.$sMenu.'</div></div><div id="content">'.$this->s_content.'</div></div>';
parent::output();
}
/**
* Displays a list of objects, without any hyperlink (except for the object's details)
* @param DBObjectSet $oSet The set of objects to display
* @param Array $aZList The ZList (list of field codes) to use for the tabular display
* @param String $sEmptyListMessage Message displayed whenever the list is empty
* @return string The HTML text representing the list
*/
public function DisplaySet($oSet, $aZList, $sEmptyListMessage = '')
{
if ($oSet->Count() > 0)
{
$sClass = $oSet->GetClass();
if (is_subclass_of($sClass, 'cmdbAbstractObject'))
{
// Home-made and very limited display of an object set
$sUniqueId = $sClass.$this->GetUniqueId();
$this->add("<div id=\"$sUniqueId\">\n"); // The id here MUST be the same as currentId, otherwise the pagination will be broken
cmdbAbstractObject::DisplaySet($this, $oSet, array('currentId' => $sUniqueId, 'menu' => false, 'zlist' => false, 'extra_fields' => implode(',', $aZList)));
$this->add("</div>\n");
}
else
{
// Home-made and very limited display of an object set
$aAttribs = array();
$aValues = array();
$aAttribs['key'] = array('label' => MetaModel::GetName($sClass), 'description' => '');
foreach($aZList as $sAttCode)
{
$oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
$aAttribs[$sAttCode] = array('label' => $oAttDef->GetLabel(), 'description' => $oAttDef->GetDescription());
}
while($oObj = $oSet->Fetch())
{
$aRow = array();
$aRow['key'] = '<a href="./index.php?operation=details&class='.get_class($oObj).'&id='.$oObj->GetKey().'">'.$oObj->GetName().'</a>';
$sHilightClass = $oObj->GetHilightClass();
if ($sHilightClass != '')
{
$aRow['@class'] = $sHilightClass;
}
foreach($aZList as $sAttCode)
{
$aRow[$sAttCode] = $oObj->GetAsHTML($sAttCode);
}
$aValues[$oObj->GetKey()] = $aRow;
}
$this->table($aAttribs, $aValues);
}
}
elseif (strlen($sEmptyListMessage) > 0)
{
$this->add($sEmptyListMessage);
}
}
/**
* Display the attributes of an object (no title, no form)
* @param Object $oObj Any kind of object
* @param aAttList The list of attributes to display
* @return void
*/
public function DisplayObjectDetails($oObj, $aAttList)
{
$sClass = get_class($oObj);
$aDetails = array();
foreach($aAttList as $sAttCode)
{
$iFlags = $oObj->GetAttributeFlags($sAttCode);
$oAttDef = MetaModel::GetAttributeDef(get_class($oObj), $sAttCode);
if ( (!$oAttDef->IsLinkSet()) && (($iFlags & OPT_ATT_HIDDEN) == 0) )
{
// Don't display linked set and non-visible attributes (in this state)
$sDisplayValue = $oObj->GetAsHTML($sAttCode);
$aDetails[] = array('label' => '<span title="'.MetaModel::GetDescription($sClass, $sAttCode).'">'.MetaModel::GetLabel($sClass, $sAttCode).'</span>', 'value' => $sDisplayValue);
}
}
$this->details($aDetails);
}
/**
* DisplayObjectLinkset
* @param Object $oObj Any kind of object
* @param $sLinkSetAttCode The attribute code of the link set attribute to display
* @param $sRemoteAttCode The external key on the linked class, pointing to the remote objects
* @param $aZList The list of attribute of the remote object
* @param $sEmptyListMessage The message to display if the list is empty
* @return void
*/
public function DisplayObjectLinkset($oObj, $sLinkSetAttCode, $sRemoteAttCode, $aZList, $sEmptyListMessage = '', $oSearchRestriction = null)
{
if (empty($sEmptyListMessage))
{
$sEmptyListMessage = Dict::S('UI:Search:NoObjectFound');
}
$oLinkSet = $oObj->Get($sLinkSetAttCode);
if ($oLinkSet->Count() > 0)
{
$sClass = $oLinkSet->GetClass();
$oExtKeyToRemote = MetaModel::GetAttributeDef($sClass, $sRemoteAttCode);
$sRemoteClass = $oExtKeyToRemote->GetTargetClass();
if (is_null($oSearchRestriction))
{
$oObjSearch = new DBObjectSearch($sRemoteClass);
}
else
{
$oObjSearch = $oSearchRestriction;
}
$oObjSearch->AddCondition_ReferencedBy($oLinkSet->GetFilter(), $sRemoteAttCode);
$aExtraParams = array('menu' => false, 'zlist' => false, 'extra_fields' => implode(',', $aZList));
$oBlock = new DisplayBlock($oObjSearch, 'list', false);
$oBlock->Display($this, 1, $aExtraParams);
}
elseif (strlen($sEmptyListMessage) > 0)
{
$this->add($sEmptyListMessage);
}
}
protected function DisplaySearchField($sClass, $sAttSpec, $aExtraParams, $sPrefix, $sFieldName = null)
{
if (is_null($sFieldName))
{
$sFieldName = str_replace('->', PARAM_ARROW_SEP, $sAttSpec);
}
$iPos = strpos($sAttSpec, '->');
if ($iPos !== false)
{
$sAttCode = substr($sAttSpec, 0, $iPos);
$sSubSpec = substr($sAttSpec, $iPos + 2);
if (!MetaModel::IsValidAttCode($sClass, $sAttCode))
{
throw new Exception("Invalid attribute code '$sClass/$sAttCode' in search specification '$sAttSpec'");
}
$oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
if ($oAttDef->IsLinkSet())
{
$sTargetClass = $oAttDef->GetLinkedClass();
}
elseif ($oAttDef->IsExternalKey(EXTKEY_ABSOLUTE))
{
$sTargetClass = $oAttDef->GetTargetClass(EXTKEY_ABSOLUTE);
}
else
{
throw new Exception("Attribute specification '$sAttSpec', '$sAttCode' should be either a link set or an external key");
}
$this->DisplaySearchField($sTargetClass, $sSubSpec, $aExtraParams, $sPrefix, $sFieldName);
}
else
{
// $sAttSpec is an attribute code
//
$this->add('<span style="white-space: nowrap;padding:5px;display:inline-block;">');
$sFilterValue = '';
$sFilterValue = utils::ReadParam($sPrefix.$sFieldName, '', false, 'raw_data');
$sFilterOpCode = null; // Use the default 'loose' OpCode
$oAttDef = MetaModel::GetAttributeDef($sClass, $sAttSpec);
if ($oAttDef->IsExternalKey())
{
$sTargetClass = $oAttDef->GetTargetClass();
$oAllowedValues = new DBObjectSet(new DBObjectSearch($sTargetClass));
$iFieldSize = $oAttDef->GetMaxSize();
$iMaxComboLength = $oAttDef->GetMaximumComboLength();
$this->add("<label>".MetaModel::GetFilterLabel($sClass, $sAttSpec).":</label>&nbsp;");
//$oWidget = UIExtKeyWidget::DIsplayFromAttCode($sAttSpec, $sClass, $oAttDef->GetLabel(), $oAllowedValues, $sFilterValue, $sPrefix.$sFieldName, false, '', $sPrefix, '');
//$this->add($oWidget->Display($this, $aExtraParams, true /* bSearchMode */));
$aExtKeyParams = $aExtraParams;
$aExtKeyParams['iFieldSize'] = $oAttDef->GetMaxSize();
$aExtKeyParams['iMinChars'] = $oAttDef->GetMinAutoCompleteChars();
// DisplayFromAttCode($this, $sAttCode, $sClass, $sTitle, $oAllowedValues, $value, $iInputId, $bMandatory, $sFieldName = '', $sFormPrefix = '', $aArgs, $bSearchMode = false)
$sHtml = UIExtKeyWidget::DisplayFromAttCode($this, $sAttSpec, $sClass, $oAttDef->GetLabel(), $oAllowedValues, $sFilterValue, $sPrefix.$sFieldName, false, $sPrefix.$sFieldName, $sPrefix, $aExtKeyParams, true);
$this->add($sHtml);
}
else
{
$aAllowedValues = MetaModel::GetAllowedValues_flt($sClass, $sAttSpec, $aExtraParams);
if (is_null($aAllowedValues))
{
// Any value is possible, display an input box
$this->add("<label>".MetaModel::GetFilterLabel($sClass, $sAttSpec).":</label>&nbsp;<input class=\"textSearch\" name=\"$sPrefix$sFieldName\" value=\"$sFilterValue\"/>\n");
}
else
{
//Enum field or external key, display a combo
$sValue = "<select name=\"$sPrefix$sFieldName\">\n";
$sValue .= "<option value=\"\">".Dict::S('UI:SearchValue: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";
$this->add("<label>".MetaModel::GetFilterLabel($sClass, $sAttSpec).":</label>&nbsp;$sValue\n");
}
}
unset($aExtraParams[$sFieldName]);
$this->add('</span> ');
$sTip = $oAttDef->GetHelpOnSmartSearch();
if (strlen($sTip) > 0)
{
$sTip = addslashes($sTip);
$sTip = str_replace(array("\n", "\r"), " ", $sTip);
// :input does represent in form visible input (INPUT, SELECT, TEXTAREA)
$this->add_ready_script("$(':input[name={$sPrefix}$sFieldName]').qtip( { content: '$sTip', show: 'mouseover', hide: 'mouseout', style: { name: 'dark', tip: 'leftTop' }, position: { corner: { target: 'rightMiddle', tooltip: 'leftTop' }} } );");
}
}
}
public function DisplaySearchForm($sClass, $aAttList, $aExtraParams, $sPrefix, $bClosed = true)
{
$sCSSClass = ($bClosed) ? 'DrawerClosed' : '';
$this->add("<div id=\"ds_$sPrefix\" class=\"SearchDrawer $sCSSClass\">\n");
$this->add_ready_script(
<<<EOF
$("#dh_$sPrefix").click( function() {
$("#ds_$sPrefix").slideToggle('normal', function() { $("#ds_$sPrefix").parent().resize(); } );
$("#dh_$sPrefix").toggleClass('open');
});
EOF
);
$this->add("<form id=\"search_$sClass\" action=\"\" method=\"post\">\n"); // Don't use $_SERVER['SCRIPT_NAME'] since the form may be called asynchronously (from ajax.php)
// $this->add("<h2>".Dict::Format('UI:SearchFor_Class_Objects', 'xxxxxx')."</h2>\n");
$this->add("<p>\n");
foreach($aAttList as $sAttSpec)
{
//$oAppContext->Reset($sAttSpec); // Make sure the same parameter will not be passed twice
$this->DisplaySearchField($sClass, $sAttSpec, $aExtraParams, $sPrefix);
}
$this->add("</p>\n");
$this->add("<p align=\"right\"><input type=\"submit\" value=\"".Dict::S('UI:Button:Search')."\"></p>\n");
foreach($aExtraParams as $sName => $sValue)
{
$this->add("<input type=\"hidden\" name=\"$sName\" value=\"$sValue\" />\n");
}
// $this->add($oAppContext->GetForForm());
$this->add("</form>\n");
$this->add("</div>\n");
$this->add("<div class=\"HRDrawer\"></div>\n");
$this->add("<div id=\"dh_$sPrefix\" class=\"DrawerHandle\">".Dict::S('UI:SearchToggle')."</div>\n");
}
/**
* Read parameters from the page
* Parameters that were absent from the page's parameters are not set in the resulting hash array
* @input string $sMethod Either get or post
* @return Hash Array of name => value corresponding to the parameters that were passed to the page
*/
public function ReadAllParams($sParamList, $sPrefix = 'attr_')
{
$aParams = explode(',', $sParamList);
$aValues = array();
foreach($aParams as $sName)
{
$sName = trim($sName);
$value = utils::ReadParam($sPrefix.$sName, null, false, 'raw_data');
if (!is_null($value))
{
$aValues[$sName] = $value;
}
}
return $aValues;
}
/**
* Outputs a list of parameters as hidden fields
* Example: attr_dummy[-123][id] = "blah"
* @param Hash $aParameters Array name => value for the parameters
* @param Array $aExclude The list of parameters that must not be handled this way (probably already in the visible part of the form)
* @return void
*/
protected function DumpHiddenParamsInternal($sName, $value)
{
if (is_array($value))
{
foreach($value as $sKey => $item)
{
$this->DumpHiddenParamsInternal($sName.'['.$sKey.']', $item);
}
}
else
{
$this->Add("<input type=\"hidden\" name=\"$sName\" value=\"$value\">");
}
}
/**
* Outputs a list of parameters as hidden field into the current page
* (must be called when inside a form)
* @param Hash $aParameters Array name => value for the parameters
* @param Array $aExclude The list of parameters that must not be handled this way (probably already in the visible part of the form)
* @return void
*/
public function DumpHiddenParams($aParameters, $aExclude = null, $sPrefix = 'attr_')
{
foreach($aParameters as $sAttCode => $value)
{
if (is_null($aExclude) || !in_array($sAttCode, $aExclude))
{
$this->DumpHiddenParamsInternal($sPrefix.$sAttCode, $value);
}
}
}
public function PostedParamsToFilter($sClass, $aAttList, $sPrefix)
{
$oFilter = new DBObjectSearch($sClass);
$iCountParams = 0;
foreach($aAttList as $sAttSpec)
{
$sFieldName = str_replace('->', PARAM_ARROW_SEP, $sAttSpec);
$value = utils::ReadPostedParam($sPrefix.$sFieldName, null, 'raw_data');
if (!is_null($value) && strlen($value) > 0)
{
$oFilter->AddConditionAdvanced($sAttSpec, $value);
$iCountParams++;
}
}
if ($iCountParams == 0)
{
return null;
}
else
{
return $oFilter;
}
}
/**
* Updates the object form POSTED arguments, and writes it into the DB (applies a stimuli if requested)
* @param DBObject $oObj The object to update
* $param array $aAttList If set, this will limit the list of updated attributes
* @return void
*/
public function DoUpdateObjectFromPostedForm(DBObject $oObj, $aAttList = null)
{
$sTransactionId = utils::ReadPostedParam('transaction_id', '');
if (!utils::IsTransactionValid($sTransactionId))
{
throw new TransactionException();
}
$sClass = get_class($oObj);
$sStimulus = trim(utils::ReadPostedParam('apply_stimulus', ''));
$sTargetState = '';
if (!empty($sStimulus))
{
// Compute the target state
$aTransitions = $oObj->EnumTransitions();
if (!isset($aTransitions[$sStimulus]))
{
throw new ApplicationException(Dict::Format('UI:Error:Invalid_Stimulus_On_Object_In_State', $sStimulus, $oObj->GetName(), $oObj->GetStateLabel()));
}
$sTargetState = $aTransitions[$sStimulus]['target_state'];
}
$oObj->UpdateObjectFromPostedForm('' /* form prefix */, $aAttList, $sTargetState);
// Optional: apply a stimulus
//
if (!empty($sStimulus))
{
if (!$oObj->ApplyStimulus($sStimulus))
{
throw new Exception("Cannot apply stimulus '$sStimulus' to {$oObj->GetName()}");
}
}
// Record the change
//
$oMyChange = MetaModel::NewObject("CMDBChange");
$oMyChange->Set("date", time());
$sUserString = CMDBChange::GetCurrentUserName();
$oMyChange->Set("userinfo", $sUserString);
$iChangeId = $oMyChange->DBInsert();
$oObj->DBUpdateTracked($oMyChange);
// Trigger ?
//
$aClasses = MetaModel::EnumParentClasses($sClass, ENUM_PARENT_CLASSES_ALL);
$sClassList = implode(", ", CMDBSource::Quote($aClasses));
$oSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT TriggerOnPortalUpdate AS t WHERE t.target_class IN ($sClassList)"));
while ($oTrigger = $oSet->Fetch())
{
$oTrigger->DoActivate($oObj->ToArgs('this'));
}
$this->p("<h1>".Dict::Format('UI:Class_Object_Updated', MetaModel::GetName(get_class($oObj)), $oObj->GetName())."</h1>\n");
}
/**
* Find the object of the specified Class/ID.
* @param WebPage $oP The current page
* @return DBObject The found object, or throws an exception in case of failure
*/
public function FindObjectFromArgs($aAllowedClasses = null)
{
$sClass = utils::ReadParam('class', '', true, 'class');
$iId = utils::ReadParam('id', 0, true, 'integer');
if (empty($sClass))
{
throw new Exception("Missing argument 'class'");
}
if (!MetaModel::IsValidClass($sClass))
{
throw new Exception("Wrong value for argument 'class': $sClass");
}
if ($iId == 0)
{
throw new Exception("Missing argument 'id'");
}
if(!is_null($aAllowedClasses))
{
$bAllowed = false;
foreach($aAllowedClasses as $sParentClass)
{
if (MetaModel::IsParentClass($sParentClass, $sClass))
{
$bAllowed = true;
}
}
if (!$bAllowed)
{
throw new Exception("Class '$sClass not allowed in this implementation'");
}
}
$oObj = MetaModel::GetObject($sClass, $iId, false);
if (!is_object($oObj))
{
throw new Exception("Could not find the object $sClass/$iId");
}
return $oObj;
}
var $m_sWizardId = null;
public function WizardFormStart($sId = '', $sNextStep = null, $bAttachment = false, $sMethod = 'post')
{
$this->m_sWizardId = $sId;
// multipart... needed for file upload
$this->add("<form id=\"{$this->m_sWizardId}\" method=\"$sMethod\" enctype=\"multipart/form-data\">\n");
$aPreviousSteps = $this->GetWizardStepHistory();
if (utils::ReadParam('step_back', 0) == 1)
{
// Back into the past history
array_pop($aPreviousSteps);
}
else
{
// Moving forward
array_push($aPreviousSteps, utils::ReadParam('next_step'));
}
$sStepHistory = implode(',', $aPreviousSteps);
$this->add("<input type=\"hidden\" id=\"step_history\" name=\"step_history\" value=\"$sStepHistory\">");
if (!is_null($sNextStep))
{
$this->add("<input type=\"hidden\" id=\"next_step\" name=\"next_step\" value=\"$sNextStep\">");
}
$this->add("<input type=\"hidden\" id=\"step_back\" name=\"step_back\" value=\"0\">");
$sTransactionId = utils::GetNewTransactionId();
$this->SetTransactionId($sTransactionId);
$this->add("<input type=\"hidden\" id=\"transaction_id\" name=\"transaction_id\" value=\"$sTransactionId\">\n");
$this->add_ready_script("$(window).unload(function() { OnUnload('$sTransactionId') } );\n");
}
public function WizardFormButtons($iButtonFlags)
{
$aButtons = array();
if ($iButtonFlags & BUTTON_CANCEL)
{
$aButtons[] = "<input id=\"btn_cancel\" type=\"button\" value=\"".Dict::S('UI:Button:Cancel')."\" onClick=\"GoHome();\">";
}
if ($iButtonFlags & BUTTON_BACK)
{
$aButtons[] = "<input id=\"btn_back\" type=\"submit\" value=\"".Dict::S('UI:Button:Back')."\" onClick=\"GoBack('{$this->m_sWizardId}');\">";
}
if ($iButtonFlags & BUTTON_NEXT)
{
$aButtons[] = "<input id=\"btn_next\" type=\"submit\" value=\"".Dict::S('UI:Button:Next')."\">";
}
if ($iButtonFlags & BUTTON_FINISH)
{
$aButtons[] = "<input id=\"btn_finish\" type=\"submit\" value=\"".Dict::S('UI:Button:Finish')."\">";
}
$this->add('<div id="buttons">');
$this->add(implode('', $aButtons));
$this->add('</div>');
}
public function WizardFormEnd()
{
$this->add("</form>\n");
}
public function GetWizardStep()
{
if (utils::ReadParam('step_back', 0) == 1)
{
// Take the value into the history - one level above
$aPreviousSteps = $this->GetWizardStepHistory();
array_pop($aPreviousSteps);
return end($aPreviousSteps);
}
else
{
return utils::ReadParam('next_step');
}
}
protected function GetWizardStepHistory()
{
$sRawHistory = trim(utils::ReadParam('step_history', '', false, 'raw_data'));
if (strlen($sRawHistory) == 0)
{
return array();
}
else
{
return explode(',', $sRawHistory);
}
}
public function WizardCheckSelectionOnSubmit($sMessageIfNoSelection, $sInputName = '')
{
$this->add_ready_script(
<<<EOF
$('#{$this->m_sWizardId}').submit(function() {
return CheckSelection('$sMessageIfNoSelection', '$sInputName');
});
EOF
);
}
}
?>

View File

@@ -0,0 +1,107 @@
<?php
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* Persistent class Event and derived
* Application internal events
* There is also a file log
*
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
abstract class Query extends cmdbAbstractObject
{
public static function Init()
{
$aParams = array
(
"category" => "core/cmdb,view_in_gui,application",
"key_type" => "autoincrement",
"name_attcode" => "name",
"state_attcode" => "",
"reconc_keys" => array(),
"db_table" => "priv_query",
"db_key_field" => "id",
"db_finalclass_field" => "realclass",
"display_template" => "",
);
MetaModel::Init_Params($aParams);
//MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeString("name", array("allowed_values"=>null, "sql"=>"name", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("description", array("allowed_values"=>null, "sql"=>"description", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("fields", array("allowed_values"=>null, "sql"=>"fields", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
// Display lists
MetaModel::Init_SetZListItems('details', array('name', 'description', 'fields')); // Attributes to be displayed for the complete details
MetaModel::Init_SetZListItems('list', array('description')); // Attributes to be displayed for a list
// Search criteria
// MetaModel::Init_SetZListItems('standard_search', array('name')); // Criteria of the std search form
// MetaModel::Init_SetZListItems('advanced_search', array('name')); // Criteria of the advanced search form
}
}
class QueryOQL extends Query
{
public static function Init()
{
$aParams = array
(
"category" => "core/cmdb,view_in_gui,application",
"key_type" => "autoincrement",
"name_attcode" => "name",
"state_attcode" => "",
"reconc_keys" => array(),
"db_table" => "priv_query_oql",
"db_key_field" => "id",
"db_finalclass_field" => "",
"display_template" => "",
);
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeOQL("oql", array("allowed_values"=>null, "sql"=>"oql", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
// Display lists
MetaModel::Init_SetZListItems('details', array('name', 'description', 'oql', 'fields')); // Attributes to be displayed for the complete details
MetaModel::Init_SetZListItems('list', array('description')); // Attributes to be displayed for a list
// Search criteria
// MetaModel::Init_SetZListItems('standard_search', array('name')); // Criteria of the std search form
// MetaModel::Init_SetZListItems('advanced_search', array('name')); // Criteria of the advanced search form
}
function DisplayBareProperties(WebPage $oPage, $bEditMode = false, $sPrefix = '', $aExtraParams = array())
{
parent::DisplayBareProperties($oPage, $bEditMode, $sPrefix, $aExtraParams);
if (!$bEditMode)
{
$sUrl = utils::GetAbsoluteUrlAppRoot().'webservices/export.php?format=spreadsheet&login_mode=basic&query='.$this->GetKey();
$sOql = $this->Get('oql');
$oSearch = DBObjectSearch::FromOQL($sOql);
$aParameters = $oSearch->GetQueryParams();
foreach($aParameters as $sParam => $val)
{
$sUrl .= '&arg_'.$sParam.'=["'.$sParam.'"]';
}
$oPage->p(Dict::S('UI:Query:UrlForExcel').':<br/><textarea cols="80" rows="3" READONLY>'.$sUrl.'</textarea>');
}
}
}
?>

View File

@@ -0,0 +1,531 @@
<?php
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* SqlBlock - display tables or charts, given an SQL query - use cautiously!
*
*
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
require_once(APPROOT.'/application/webpage.class.inc.php');
require_once(APPROOT.'/application/utils.inc.php');
require_once(APPROOT.'/pages/php-ofc-library/open-flash-chart.php');
/**
* Helper class to design optimized dashboards, based on an SQL query
*
*/
class SqlBlock
{
protected $m_sQuery;
protected $m_aColumns;
protected $m_sTitle;
protected $m_sType;
protected $m_aParams;
public function __construct($sQuery, $aColumns, $sTitle, $sType, $aParams = array())
{
$this->m_sQuery = $sQuery;
$this->m_aColumns = $aColumns;
$this->m_sTitle = $sTitle;
$this->m_sType = $sType;
$this->m_aParams = $aParams;
}
/**
* Constructs a SqlBlock object from an XML template
/*
*
* <sqlblock>
* <sql>SELECT date_format(start_date, '%d') AS Date, count(*) AS Count FROM ticket WHERE DATE_SUB(NOW(), INTERVAL 15 DAY) &lt; start_date AND finalclass = 'UserIssue' GROUP BY date_format(start_date, '%d') AND $CONDITION(param1, ticket.org_id)$</sql>
* <type>table</type>
* <title>UserRequest:Overview-Title</title>
* <parameter>
* <name>param1</name>
* <type>context</type>
* <mapping>org_id</mapping>
* </parameter>
* <column>
* <name>Date</name>
* <label>UserRequest:Overview-Date</label>
* <drilldown></drilldown>
* </column>
* <column>
* <name>Count</name>
* <label>UserRequest:Overview-Count</label>
* <drilldown>SELECT UserIssue WHERE date_format(start_date, '%d') = :Date</drilldown>
* </column>
* </sqlblock>
*
* Tags
* - sql: a (My)SQL query. Do not forget to use html entities (e.g. &lt; for <)
* - type: table (default), bars or pie. If bars or pie is selected only the two first columns are taken into account.
* - title: optional title, typed in clear or given as a dictionnary entry
* - parameter: specifies how to map the context parameters (namely org_id) to a given named parameter in the query.
* The expression $CONDITION(<param_name>, <sql_column_name>) will be automatically replaced by:
* either the string "1" if there is no restriction on the organisation in iTop
* or the string "(<sql_column_name>=<value_of_org_id>)" if there is a limitation to one organizations in iTop
* or the string "(<sql_column_name> IN (<values_of_org_id>))" if there is a limitation to a given set of organizations in iTop
* - column: specification of a column (not displayed if omitted)
* - column / name: name of the column in the SQL query (use aliases)
* - column / label: label, typed in clear or given as a dictionnary entry
* - column / drilldown: NOT IMPLEMENTED YET - OQL with parameters corresponding to column names (in the query)
*
* @param $sTemplate string The XML template
* @return DisplayBlock The DisplayBlock object, or null if the template is invalid
*/
public static function FromTemplate($sTemplate)
{
$oXml = simplexml_load_string('<root>'.$sTemplate.'</root>', 'SimpleXMLElement', LIBXML_NOCDATA);
if (false)
{
// Debug
echo "<pre>\n";
print_r($oXml);
echo "</pre>\n";
}
if (isset($oXml->title))
{
$sTitle = (string)$oXml->title;
}
if (isset($oXml->type))
{
$sType = (string)$oXml->type;
}
else
{
$sType = 'table';
}
if (!isset($oXml->sql))
{
throw new Exception('Missing tag "sql" in sqlblock');
}
$sQuery = (string)$oXml->sql;
$aColumns = array();
if (isset($oXml->column))
{
foreach ($oXml->column AS $oColumnData)
{
if (!isset($oColumnData->name))
{
throw new Exception("Missing tag 'name' in sqlblock/column");
}
$sName = (string) $oColumnData->name;
if (strlen($sName) == 0)
{
throw new Exception("Empty tag 'name' in sqlblock/column");
}
$aColumns[$sName] = array();
if (isset($oColumnData->label))
{
$sLabel = (string)$oColumnData->label;
if (strlen($sLabel) > 0)
{
$aColumns[$sName]['label'] = Dict::S($sLabel);
}
}
if (isset($oColumnData->drilldown))
{
$sDrillDown = (string)$oColumnData->drilldown;
if (strlen($sDrillDown) > 0)
{
$aColumns[$sName]['drilldown'] = $sDrillDown;
}
}
}
}
$aParams = array();
if (isset($oXml->parameter))
{
foreach ($oXml->parameter AS $oParamData)
{
if (!isset($oParamData->name))
{
throw new Exception("Missing tag 'name' for parameter in sqlblock/column");
}
$sName = (string) $oParamData->name;
if (strlen($sName) == 0)
{
throw new Exception("Empty tag 'name' for parameter in sqlblock/column");
}
if (!isset($oParamData->mapping))
{
throw new Exception("Missing tag 'mapping' for parameter in sqlblock/column");
}
$sMapping = (string) $oParamData->mapping;
if (strlen($sMapping) == 0)
{
throw new Exception("Empty tag 'mapping' for parameter in sqlblock/column");
}
if (isset($oParamData->type))
{
$sParamType = $oParamData->type;
}
else
{
$sParamType = 'context';
}
$aParams[$sName] = array('mapping' => $sMapping, 'type' => $sParamType);
}
}
return new SqlBlock($sQuery, $aColumns, $sTitle, $sType, $aParams);
}
/**
* Applies the defined parameters into the SQL query
* @return string the SQL query to execute
*/
public function BuildQuery()
{
$oAppContext = new ApplicationContext();
$sQuery = $this->m_sQuery;
$sQuery = str_replace('$DB_PREFIX$', MetaModel::GetConfig()->GetDBSubname(), $sQuery); // put the tables DB prefix (if any)
foreach($this->m_aParams as $sName => $aParam)
{
if ($aParam['type'] == 'context')
{
$sSearchPattern = '/\$CONDITION\('.$sName.',([^\)]+)\)\$/';
$value = $oAppContext->GetCurrentValue($aParam['mapping']);
if (empty($value))
{
$sSQLExpr = '(1)';
}
else
{
// Special case for managing the hierarchy of organizations
if (($aParam['mapping'] == 'org_id') && ( MetaModel::IsValidClass('Organization')))
{
$sHierarchicalKeyCode = MetaModel::IsHierarchicalClass('Organization');
if ($sHierarchicalKeyCode != false)
{
// organizations are in hierarchy... gather all the orgs below the given one...
$sOQL = "SELECT Organization AS node JOIN Organization AS root ON node.$sHierarchicalKeyCode BELOW root.id WHERE root.id = :value";
$oSet = new DBObjectSet(DBObjectSearch::FromOQL($sOQL), array(), array('value' => $value));
$aOrgIds = array();
while($oOrg = $oSet->Fetch())
{
$aOrgIds[]= $oOrg->GetKey();
}
$sSQLExpr = '($1 IN('.implode(',', $aOrgIds).'))';
}
else
{
$sSQLExpr = '($1 = '.CMDBSource::Quote($value).')';
}
}
else
{
$sSQLExpr = '($1 = '.CMDBSource::Quote($value).')';
}
}
$sQuery = preg_replace($sSearchPattern, $sSQLExpr, $sQuery);
}
}
return $sQuery;
}
public function RenderContent(WebPage $oPage, $aExtraParams = array())
{
if (empty($aExtraParams['currentId']))
{
$sId = 'sqlblock_'.$oPage->GetUniqueId(); // Works only if the page is not an Ajax one !
}
else
{
$sId = $aExtraParams['currentId'];
}
// $oPage->add($this->GetRenderContent($oPage, $aExtraParams, $sId));
$sQuery = $this->BuildQuery();
$res = CMDBSource::Query($sQuery);
$aQueryCols = CMDBSource::GetColumns($res);
// Prepare column definitions (check + give default values)
//
foreach($this->m_aColumns as $sName => $aColumnData)
{
if (!in_array($sName, $aQueryCols))
{
throw new Exception("Unknown column name '$sName' in sqlblock column");
}
if (!isset($aColumnData['label']))
{
$this->m_aColumns[$sName]['label'] = $sName;
}
if (isset($aColumnData['drilldown']) && !empty($aColumnData['drilldown']))
{
// Check if the OQL is valid
try
{
$this->m_aColumns[$sName]['filter'] = DBObjectSearch::FromOQL($aColumnData['drilldown']);
}
catch(OQLException $e)
{
unset($aColumnData['drilldown']);
}
}
}
if (strlen($this->m_sTitle) > 0)
{
$oPage->add("<h2>".Dict::S($this->m_sTitle)."</h2>\n");
}
switch ($this->m_sType)
{
case 'bars':
case 'pie':
$aColNames = array_keys($this->m_aColumns);
$sXColName = $aColNames[0];
$sYColName = $aColNames[1];
$aData = array();
$aRows = array();
while($aRow = CMDBSource::FetchArray($res))
{
$aData[$aRow[$sXColName]] = $aRow[$sYColName];
$aRows[$aRow[$sXColName]] = $aRow;
}
$this->RenderChart($oPage, $sId, $aData, $this->m_aColumns[$sYColName]['drilldown'], $aRows);
break;
default:
case 'table':
$oAppContext = new ApplicationContext();
$sContext = $oAppContext->GetForLink();
if (!empty($sContext))
{
$sContext = '&'.$sContext;
}
$aDisplayConfig = array();
foreach($this->m_aColumns as $sName => $aColumnData)
{
$aDisplayConfig[$sName] = array('label' => $aColumnData['label'], 'description' => '');
}
$aDisplayData = array();
while($aRow = CMDBSource::FetchArray($res))
{
$aSQLColNames = array_keys($aRow);
$aDisplayRow = array();
foreach($this->m_aColumns as $sName => $aColumnData)
{
if (isset($aColumnData['filter']))
{
$sFilter = $aColumnData['drilldown'];
$sClass = $aColumnData['filter']->GetClass();
$sFilter = str_replace('SELECT '.$sClass, '', $sFilter);
foreach($aSQLColNames as $sColName)
{
$sFilter = str_replace(':'.$sColName, "'".addslashes( $aRow[$sColName] )."'", $sFilter);
}
$sURL = utils::GetAbsoluteUrlAppRoot().'pages/UI.php?operation=search_oql&search_form=0&oql_class='.$sClass.'&oql_clause='.urlencode($sFilter).'&format=html'.$sContext;
$aDisplayRow[$sName] = '<a href="'.$sURL.'">'.$aRow[$sName]."</a>";
}
else
{
$aDisplayRow[$sName] = $aRow[$sName];
}
}
$aDisplayData[] = $aDisplayRow;
}
$oPage->table($aDisplayConfig, $aDisplayData);
break;
}
}
public function GetRenderContent(WebPage $oPage, $aExtraParams = array(), $sId)
{
$sHtml = '';
return $sHtml;
}
protected function RenderChart($oPage, $sId, $aValues, $sDrillDown = '', $aRows = array())
{
// 1- Compute Open Flash Chart data
//
$aValueKeys = array();
$index = 0;
if ((count($aValues) > 0) && ($sDrillDown != ''))
{
$oFilter = DBObjectSearch::FromOQL($sDrillDown);
$sClass = $oFilter->GetClass();
$sOQLClause = str_replace('SELECT '.$sClass, '', $sDrillDown);
$aSQLColNames = array_keys(current($aRows)); // Read the list of columns from the current (i.e. first) element of the array
$oAppContext = new ApplicationContext();
$sURL = utils::GetAbsoluteUrlAppRoot().'pages/UI.php?operation=search_oql&search_form=0&oql_class='.$sClass.'&format=html&'.$oAppContext->GetForLink().'&oql_clause=';
}
$aURLs = array();
foreach($aValues as $key => $value)
{
// Make sure that values are integers (so that max() will work....)
// and build an array of STRING with the keys (numeric keys are transformed into string by PHP :-(
$aValues[$key] = (int)$value;
$aValueKeys[] = (string)$key;
// Build the custom query for the 'drill down' on each element
if ($sDrillDown != '')
{
$sFilter = $sOQLClause;
foreach($aSQLColNames as $sColName)
{
$sFilter = str_replace(':'.$sColName, "'".addslashes( $aRows[$key][$sColName] )."'", $sFilter);
$aURLs[$index] = $sURL.urlencode($sFilter);
}
}
$index++;
}
$oChart = new open_flash_chart();
if ($this->m_sType == 'bars')
{
$oChartElement = new bar_glass();
if (count($aValues) > 0)
{
$maxValue = max($aValues);
}
else
{
$maxValue = 1;
}
$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 );
$aBarValues = array();
foreach($aValues as $iValue)
{
$oBarValue = new bar_value($iValue);
$oBarValue->on_click("ofc_drilldown_{$sId}");
$aBarValues[] = $oBarValue;
}
$oChartElement->set_values($aBarValues);
//$oChartElement->set_values(array_values($aValues));
$oXAxis = new x_axis();
$oXLabels = new x_axis_labels();
// set them vertical
$oXLabels->set_vertical();
// set the label text
$oXLabels->set_labels($aValueKeys);
// Add the X Axis Labels to the X Axis
$oXAxis->set_labels( $oXLabels );
$oChart->set_x_axis( $oXAxis );
}
else
{
$oChartElement = new pie();
$oChartElement->set_start_angle( 35 );
$oChartElement->set_animate( true );
$oChartElement->set_tooltip( '#label# - #val# (#percent#)' );
$oChartElement->set_colours( array('#FF8A00', '#909980', '#2C2B33', '#CCC08D', '#596664') );
$aData = array();
foreach($aValues as $sValue => $iValue)
{
$oPieValue = new pie_value($iValue, $sValue); //@@ BUG: not passed via ajax !!!
$oPieValue->on_click("ofc_drilldown_{$sId}");
$aData[] = $oPieValue;
}
$oChartElement->set_values( $aData );
$oChart->x_axis = null;
}
// Title given in HTML
//$oTitle = new title($this->m_sTitle);
//$oChart->set_title($oTitle);
$oChart->set_bg_colour('#FFFFFF');
$oChart->add_element( $oChartElement );
$sData = $oChart->toPrettyString();
$sData = json_encode($sData);
// 2- Declare the Javascript function that will render the chart data\
//
$oPage->add_script(
<<< EOF
function ofc_get_data_{$sId}()
{
return $sData;
}
EOF
);
if (count($aURLs) > 0)
{
$sURLList = '';
foreach($aURLs as $index => $sURL)
{
$sURLList .= "\taURLs[$index] = '".addslashes($sURL)."';\n";
}
$oPage->add_script(
<<< EOF
function ofc_drilldown_{$sId}(index)
{
var aURLs = new Array();
{$sURLList}
var sURL = aURLs[index];
window.location.href = sURL; // Navigate !
}
EOF
);
}
// 3- Insert the Open Flash chart
//
$oPage->add("<div id=\"$sId\"><div>\n");
$oPage->add_ready_script(
<<<EOF
swfobject.embedSWF( "../images/open-flash-chart.swf",
"{$sId}",
"100%", "300","9.0.0",
"expressInstall.swf",
{"get-data":"ofc_get_data_{$sId}", "id":"{$sId}"},
{'wmode': 'transparent'}
);
EOF
);
}
}
?>

View File

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

View File

@@ -1,5 +1,29 @@
<?php
require_once('../application/displayblock.class.inc.php');
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* Class DisplayTemplate
*
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
require_once(APPROOT.'/application/displayblock.class.inc.php');
/**
* This class manages the special template format used internally to build the iTop web pages
*/
@@ -11,7 +35,15 @@ class DisplayTemplate
public function __construct($sTemplate)
{
$this->m_aTags = array('itopblock', 'itoptabs', 'itoptab', 'itoptoggle');
$this->m_aTags = array (
'itopblock',
'itopcheck',
'itoptabs',
'itoptab',
'itoptoggle',
'itopstring',
'sqlblock'
);
$this->m_sTemplate = $sTemplate;
}
@@ -31,11 +63,23 @@ class DisplayTemplate
$oPage->add(substr($this->m_sTemplate, $iBeforeTagPos, $iStart - $iBeforeTagPos));
if ($sTag == DisplayBlock::TAG_BLOCK)
{
$oBlock = DisplayBlock::FromTemplate($sOuterTag);
if (is_object($oBlock))
try
{
$oBlock->Display($oPage, 'block_'.self::$iBlockCount, $aParams);
$oBlock = DisplayBlock::FromTemplate($sOuterTag);
if (is_object($oBlock))
{
$oBlock->Display($oPage, 'block_'.self::$iBlockCount, $aParams);
}
}
catch(OQLException $e)
{
$oPage->p('Error in template (please contact your administrator) - Invalid query<!--'.$sOuterTag.'-->');
}
catch(Exception $e)
{
$oPage->p('Error in template (please contact your administrator)<!--'.$e->getMessage().'--><!--'.$sOuterTag.'-->');
}
self::$iBlockCount++;
}
else
@@ -50,7 +94,6 @@ class DisplayTemplate
$iStart = $iEnd;
$iEnd = strlen($this->m_sTemplate);
$iCount++;
if ($iCount > 10) break; //@@@ Why ?? Debug ??
}
$oPage->add(substr($this->m_sTemplate, $iAfterTagPos));
}
@@ -126,30 +169,53 @@ class DisplayTemplate
$oPage->AddTabContainer('Tabs_'.$iTabContainerCount);
$oPage->SetCurrentTabContainer('Tabs_'.$iTabContainerCount);
$iTabContainerCount++;
//$oPage->p('Content:<pre>'.htmlentities($sContent).'</pre>');
//$oPage->p('Content:<pre>'.htmlentities($sContent, ENT_QUOTES, 'UTF-8').'</pre>');
$oTemplate = new DisplayTemplate($sContent);
$oTemplate->Render($oPage, array()); // no params to apply, they have already been applied
$oPage->SetCurrentTabContainer('');
break;
case 'itopcheck':
$sClassName = $aAttributes['class'];
if (MetaModel::IsValidClass($sClassName) && UserRights::IsActionAllowed($sClassName, UR_ACTION_READ))
{
$oTemplate = new DisplayTemplate($sContent);
$oTemplate->Render($oPage, array()); // no params to apply, they have already been applied
}
else
{
// Leave a trace for those who'd like to understand why nothing is displayed
$oPage->add("<!-- class $sClassName does not exist, skipping some part of the template -->\n");
}
break;
case 'itoptab':
$oPage->SetCurrentTab(str_replace('_', ' ', $aAttributes['name']));
$oPage->SetCurrentTab(Dict::S(str_replace('_', ' ', $aAttributes['name'])));
$oTemplate = new DisplayTemplate($sContent);
$oTemplate->Render($oPage, array()); // no params to apply, they have already been applied
//$oPage->p('iTop Tab Content:<pre>'.htmlentities($sContent).'</pre>');
//$oPage->p('iTop Tab Content:<pre>'.htmlentities($sContent, ENT_QUOTES, 'UTF-8').'</pre>');
$oPage->SetCurrentTab('');
break;
case 'itoptoggle':
$sName = isset($aAttributes['name']) ? $aAttributes['name'] : 'Tagada';
$bOpen = isset($aAttributes['open']) ? $aAttributes['open'] : true;
$oPage->StartCollapsibleSection($sName, $bOpen);
$oPage->StartCollapsibleSection(Dict::S($sName), $bOpen);
$oTemplate = new DisplayTemplate($sContent);
$oTemplate->Render($oPage, array()); // no params to apply, they have already been applied
//$oPage->p('iTop Tab Content:<pre>'.htmlentities($sContent).'</pre>');
//$oPage->p('iTop Tab Content:<pre>'.htmlentities($sContent, ENT_QUOTES, 'UTF-8').'</pre>');
$oPage->EndCollapsibleSection();
break;
case 'itopstring':
$oPage->add(Dict::S($sContent));
break;
case 'sqlblock':
$oBlock = SqlBlock::FromTemplate($sContent);
$oBlock->RenderContent($oPage);
break;
case 'itopblock': // No longer used, handled by DisplayBlock::FromTemplate see above
$oPage->add("<!-- Application Error: should be handled by DisplayBlock::FromTemplate -->");
break;
@@ -165,36 +231,172 @@ class DisplayTemplate
*/
static public function UnitTest()
{
require_once('../application/startup.inc.php');
require_once("../application/itopwebpage.class.inc.php");
require_once(APPROOT.'/application/startup.inc.php');
require_once(APPROOT."/application/itopwebpage.class.inc.php");
$sTemplate = '<div class="page_header">
<div class="actions_details"><a href="#"><span>Actions</span></a></div>
<h1>$class$: <span class="hilite">$name$</span></h1>
<itopblock blockclass="HistoryBlock" type="toggle" encoding="text/oql">SELECT CMDBChangeOp WHERE objkey = $pkey$ AND objclass = \'$class$\'</itopblock>
<itopblock blockclass="HistoryBlock" type="toggle" encoding="text/oql">SELECT CMDBChangeOp WHERE objkey = $id$ AND objclass = \'$class$\'</itopblock>
</div>
<img src="../../images/connect_to_network.png" style="margin-top:-10px; margin-right:10px; float:right">
<itopblock blockclass="DisplayBlock" asynchronous="false" type="bare_details" encoding="text/sibusql">bizNetworkDevice: pkey = $pkey$</itopblock>
<itoptabs>
<itoptab name="Interfaces">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/sibusql">bizInterface: device_id = $pkey$</itopblock>
<itopblock blockclass="DisplayBlock" type="list" encoding="text/oql">SELECT Interface AS i WHERE i.device_id = $id$</itopblock>
</itoptab>
<itoptab name="Contacts">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/sibusql">bizContact: PKEY IS contact_id IN (ContactsLinks: object_id = $pkey$)</itopblock>
<itopblock blockclass="DisplayBlock" type="list" encoding="text/oql">SELECT Contact AS c JOIN lnkContactToCI AS l ON l.contact_id = c.id WHERE l.ci_id = $id$</itopblock>
</itoptab>
<itoptab name="Documents">
<itopblock blockclass="DisplayBlock" type="list" encoding="text/sibusql">bizDocument: PKEY IS doc_id IN (lnkDocumentRealObject: object_id = $pkey$)</itopblock>
<itopblock blockclass="DisplayBlock" type="list" encoding="text/oql">SELECT Document AS d JOIN lnkDocumentToCI as l ON l.document_id = d.id WHERE l.ci_id = $id$)</itopblock>
</itoptab>
</itoptabs>';
$oPage = new iTopWebPage('Unit Test', 3);
//$oPage->add("Template content: <pre>".htmlentities($sTemplate)."</pre>\n");
$oPage = new iTopWebPage('Unit Test');
//$oPage->add("Template content: <pre>".htmlentities($sTemplate, ENT_QUOTES, 'UTF-8')."</pre>\n");
$oTemplate = new DisplayTemplate($sTemplate);
$oTemplate->Render($oPage, array('class'=>'Network device','pkey'=> 271, 'name' => 'deliversw01.mecanorama.fr', 'org_id' => 3));
$oPage->output();
}
}
//DisplayTemplate::UnitTest();
/**
* Special type of template for displaying the details of an object
* On top of the defaut 'blocks' managed by the parent class, the following placeholders
* are available in such a template:
* $attribute_code$ An attribute of the object (in edit mode this is the input for the attribute)
* $attribute_code->label()$ The label of an attribute
* $PlugIn:plugInClass->properties()$ The ouput of OnDisplayProperties of the specified plugInClass
*/
class ObjectDetailsTemplate extends DisplayTemplate
{
public function __construct($sTemplate, $oObj, $sFormPrefix = '')
{
parent::__construct($sTemplate);
$this->m_oObj = $oObj;
$this->m_sPrefix = $sFormPrefix;
}
public function Render(WebPage $oPage, $aParams = array(), $bEditMode = false)
{
$sStateAttCode = MetaModel :: GetStateAttributeCode(get_class($this->m_oObj));
$aTemplateFields = array();
preg_match_all('/\\$this->([a-z0-9_]+)\\$/', $this->m_sTemplate, $aMatches);
$aTemplateFields = $aMatches[1];
preg_match_all('/\\$this->field\\(([a-z0-9_]+)\\)\\$/', $this->m_sTemplate, $aMatches);
$aTemplateFields = array_merge($aTemplateFields, $aMatches[1]);
$aFieldsComments = (isset($aParams['fieldsComments'])) ? $aParams['fieldsComments'] : array();
$aFieldsMap = array();
$sClass = get_class($this->m_oObj);
// Renders the fields used in the template
foreach(MetaModel::ListAttributeDefs(get_class($this->m_oObj)) as $sAttCode => $oAttDef)
{
$aParams['this->label('.$sAttCode.')'] = $oAttDef->GetLabel();
$aParams['this->comments('.$sAttCode.')'] = isset($aFieldsComments[$sAttCode]) ? $aFieldsComments[$sAttCode] : '';
$iInputId = '2_'.$sAttCode; // TODO: generate a real/unique prefix...
if (in_array($sAttCode, $aTemplateFields))
{
if ($this->m_oObj->IsNew())
{
$iFlags = $this->m_oObj->GetInitialStateAttributeFlags($sAttCode);
}
else
{
$iFlags = $this->m_oObj->GetAttributeFlags($sAttCode);
}
if (($iFlags & OPT_ATT_MANDATORY) && $this->m_oObj->IsNew())
{
$iFlags = $iFlags & ~OPT_ATT_READONLY; // Mandatory fields cannot be read-only when creating an object
}
if ((!$oAttDef->IsWritable()) || ($sStateAttCode == $sAttCode))
{
$iFlags = $iFlags | OPT_ATT_READONLY;
}
if ($iFlags & OPT_ATT_HIDDEN)
{
$aParams['this->label('.$sAttCode.')'] = '';
$aParams['this->field('.$sAttCode.')'] = '';
$aParams['this->comments('.$sAttCode.')'] = '';
$aParams['this->'.$sAttCode] = '';
}
else
{
if ($bEditMode && ($iFlags & (OPT_ATT_READONLY|OPT_ATT_SLAVE)))
{
// Check if the attribute is not read-only because of a synchro...
$aReasons = array();
$sSynchroIcon = '';
if ($iFlags & OPT_ATT_SLAVE)
{
$iSynchroFlags = $this->m_oObj->GetSynchroReplicaFlags($sAttCode, $aReasons);
$sSynchroIcon = "&nbsp;<img id=\"synchro_$sInputId\" src=\"../images/transp-lock.png\" style=\"vertical-align:middle\"/>";
$sTip = '';
foreach($aReasons as $aRow)
{
$sTip .= "<p>Synchronized with {$aRow['name']} - {$aRow['description']}</p>";
}
$oPage->add_ready_script("$('#synchro_$iInputId').qtip( { content: '$sTip', show: 'mouseover', hide: 'mouseout', style: { name: 'dark', tip: 'leftTop' }, position: { corner: { target: 'rightMiddle', tooltip: 'leftTop' }} } );");
}
// Attribute is read-only
$sHTMLValue = "<span id=\"field_{$iInputId}\">".$this->m_oObj->GetAsHTML($sAttCode);
$sHTMLValue .= '<input type="hidden" id="'.$iInputId.'" name="attr_'.$sAttCode.'" value="'.htmlentities($this->m_oObj->Get($sAttCode), ENT_QUOTES, 'UTF-8').'"/></span>';
$aFieldsMap[$sAttCode] = $iInputId;
$aParams['this->comments('.$sAttCode.')'] = $sSynchroIcon;
}
if ($bEditMode && !($iFlags & OPT_ATT_READONLY)) //TODO: check the data synchro status...
{
$aParams['this->field('.$sAttCode.')'] = "<span id=\"field_{$iInputId}\">".$this->m_oObj->GetFormElementForField($oPage, $sClass, $sAttCode, $oAttDef,
$this->m_oObj->Get($sAttCode),
$this->m_oObj->GetEditValue($sAttCode),
$iInputId, // InputID
'',
$iFlags,
array('this' => $this->m_oObj) // aArgs
).'</span>';
$aFieldsMap[$sAttCode] = $iInputId;
}
else
{
$aParams['this->field('.$sAttCode.')'] = $this->m_oObj->GetAsHTML($sAttCode);
}
$aParams['this->'.$sAttCode] = "<table class=\"field\"><tr><td class=\"label\">".$aParams['this->label('.$sAttCode.')'].":</td><td>".$aParams['this->field('.$sAttCode.')']."</td><td>".$aParams['this->comments('.$sAttCode.')']."</td></tr></table>";
}
}
}
// Renders the PlugIns used in the template
preg_match_all('/\\$PlugIn:([A-Za-z0-9_]+)->properties\\(\\)\\$/', $this->m_sTemplate, $aMatches);
$aPlugInProperties = $aMatches[1];
foreach($aPlugInProperties as $sPlugInClass)
{
$oInstance = MetaModel::GetPlugins('iApplicationUIExtension', $sPlugInClass);
if ($oInstance != null) // Safety check...
{
$offset = $oPage->start_capture();
$oInstance->OnDisplayProperties($this->m_oObj, $oPage, $bEditMode);
$sContent = $oPage->end_capture($offset);
$aParams["PlugIn:{$sPlugInClass}->properties()"]= $sContent;
}
else
{
$aParams["PlugIn:{$sPlugInClass}->properties()"]= "Missing PlugIn: $sPlugInClass";
}
}
$offset = $oPage->start_capture();
parent::Render($oPage, $aParams);
$sContent = $oPage->end_capture($offset);
// Remove empty table rows in case some attributes are hidden...
$sContent = preg_replace('/<tr[^>]*>\s*(<td[^>]*>\s*<\\/td>)+\s*<\\/tr>/im', '', $sContent);
$oPage->add($sContent);
return $aFieldsMap;
}
}
//DisplayTemplate::UnitTest();
?>

View File

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

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,580 @@
<?php
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* Class UIExtKeyWidget
* UI wdiget for displaying and editing external keys when
* A simple drop-down list is not enough...
*
* The layout is the following
*
* +-- #label_<id> (input)-------+ +-----------+
* | | | Browse... |
* +-----------------------------+ +-----------+
*
* And the popup dialog has the following layout:
*
* +------------------- ac_dlg_<id> (div)-----------+
* + +--- ds_<id> (div)---------------------------+ |
* | | +------------- fs_<id> (form)------------+ | |
* | | | +--------+---+ | | |
* | | | | Class | V | | | |
* | | | +--------+---+ | | |
* | | | | | |
* | | | S e a r c h F o r m | | |
* | | | +--------+ | | |
* | | | | Search | | | |
* | | | +--------+ | | |
* | | +----------------------------------------+ | |
* | +--------------+-dh_<id>-+--------------------+ |
* | \ Search / |
* | +------+ |
* | +--- fr_<id> (form)--------------------------+ |
* | | +------------ dr_<id> (div)--------------+ | |
* | | | | | |
* | | | S e a r c h R e s u l t s | | |
* | | | | | |
* | | +----------------------------------------+ | |
* | | +--------+ +-----+ | |
* | | | Cancel | | Add | | |
* | | +--------+ +-----+ | |
* | +--------------------------------------------+ |
* +------------------------------------------------+
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
require_once(APPROOT.'/application/webpage.class.inc.php');
require_once(APPROOT.'/application/displayblock.class.inc.php');
class UIExtKeyWidget
{
protected $iId;
protected $sTargetClass;
protected $sAttCode;
protected $bSearchMode;
//public function __construct($sAttCode, $sClass, $sTitle, $oAllowedValues, $value, $iInputId, $bMandatory, $sNameSuffix = '', $sFieldPrefix = '', $sFormPrefix = '')
static public function DisplayFromAttCode($oPage, $sAttCode, $sClass, $sTitle, $oAllowedValues, $value, $iInputId, $bMandatory, $sFieldName = '', $sFormPrefix = '', $aArgs, $bSearchMode = false)
{
$oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
$sTargetClass = $oAttDef->GetTargetClass();
$iMaxComboLength = $oAttDef->GetMaximumComboLength();
$bAllowTargetCreation = $oAttDef->AllowTargetCreation();
if (!$bSearchMode)
{
$sDisplayStyle = $oAttDef->GetDisplayStyle();
}
else
{
$sDisplayStyle = 'select'; // In search mode, always use a drop-down list
}
$oWidget = new UIExtKeyWidget($sTargetClass, $iInputId, $sAttCode, $bSearchMode);
return $oWidget->Display($oPage, $iMaxComboLength, $bAllowTargetCreation, $sTitle, $oAllowedValues, $value, $iInputId, $bMandatory, $sFieldName, $sFormPrefix, $aArgs, null, $sDisplayStyle);
}
public function __construct($sTargetClass, $iInputId, $sAttCode = '', $bSearchMode = false)
{
$this->sTargetClass = $sTargetClass;
$this->iId = $iInputId;
$this->sAttCode = $sAttCode;
$this->bSearchMode = $bSearchMode;
}
/**
* Get the HTML fragment corresponding to the linkset editing widget
* @param WebPage $oP The web page used for all the output
* @param Hash $aArgs Extra context arguments
* @return string The HTML fragment to be inserted into the page
*/
public function Display(WebPage $oPage, $iMaxComboLength, $bAllowTargetCreation, $sTitle, $oAllowedValues, $value, $iInputId, $bMandatory, $sFieldName, $sFormPrefix = '', $aArgs = array(), $bSearchMode = null, $sDisplayStyle = 'select')
{
if (!is_null($bSearchMode))
{
$this->bSearchMode = $bSearchMode;
}
$sTitle = addslashes($sTitle);
$oPage->add_linked_script('../js/extkeywidget.js');
$oPage->add_linked_script('../js/forms-json-utils.js');
$bCreate = (!$this->bSearchMode) && (!MetaModel::IsAbstract($this->sTargetClass)) && (UserRights::IsActionAllowed($this->sTargetClass, UR_ACTION_BULK_MODIFY) && $bAllowTargetCreation);
$bExtensions = true;
$sMessage = Dict::S('UI:Message:EmptyList:UseSearchForm');
$sAttrFieldPrefix = ($this->bSearchMode) ? '' : 'attr_';
$sHTMLValue = "<span style=\"white-space:nowrap\">"; // no wrap
$sFilter = addslashes($oAllowedValues->GetFilter()->ToOQL());
if($this->bSearchMode)
{
$sWizHelper = 'null';
$sWizHelperJSON = "''";
$sJSSearchMode = 'true';
}
else
{
if (isset($aArgs['wizHelper']))
{
$sWizHelper = $aArgs['wizHelper'];
}
else
{
$sWizHelper = 'oWizardHelper'.$sFormPrefix;
}
$sWizHelperJSON = $sWizHelper.'.UpdateWizardToJSON()';
$sJSSearchMode = 'false';
}
if (is_null($oAllowedValues))
{
throw new Exception('Implementation: null value for allowed values definition');
}
elseif ($oAllowedValues->Count() < $iMaxComboLength)
{
// Discrete list of values, use a SELECT or RADIO buttons depending on the config
switch($sDisplayStyle)
{
case 'radio':
case 'radio_horizontal':
case 'radio_vertical':
$sValidationField = "<span id=\"v_{$this->iId}\"></span>";
$sHTMLValue = '';
$bVertical = ($sDisplayStyle != 'radio_horizontal');
$bExtensions = false;
$oAllowedValues->Rewind();
$aAllowedValues = array();
while($oObj = $oAllowedValues->Fetch())
{
$aAllowedValues[$oObj->GetKey()] = $oObj->GetName();
}
$sHTMLValue = $oPage->GetRadioButtons($aAllowedValues, $value, $this->iId, "{$sAttrFieldPrefix}{$sFieldName}", $bMandatory, $bVertical, $sValidationField);
$aEventsList[] ='change';
break;
case 'select':
default:
$sSelectMode = 'true';
$sHelpText = ''; //$this->oAttDef->GetHelpOnEdition();
$sHTMLValue = "<select title=\"$sHelpText\" name=\"{$sAttrFieldPrefix}{$sFieldName}\" id=\"$this->iId\">\n";
if ($this->bSearchMode)
{
$sDisplayValue = isset($aArgs['sDefaultValue']) ? $aArgs['sDefaultValue'] : Dict::S('UI:SearchValue:Any');
$sHTMLValue .= "<option value=\"\">$sDisplayValue</option>\n";
}
else
{
$sHTMLValue .= "<option value=\"\">".Dict::S('UI:SelectOne')."</option>\n";
}
$oAllowedValues->Rewind();
while($oObj = $oAllowedValues->Fetch())
{
$key = $oObj->GetKey();
$display_value = $oObj->GetName();
if (($oAllowedValues->Count() == 1) && ($bMandatory == 'true') )
{
// When there is only once choice, select it by default
$sSelected = ' selected';
}
else
{
$sSelected = ($value == $key) ? ' selected' : '';
}
$sHTMLValue .= "<option value=\"$key\"$sSelected>$display_value</option>\n";
}
$sHTMLValue .= "</select>\n";
$oPage->add_ready_script(
<<<EOF
oACWidget_{$this->iId} = new ExtKeyWidget('{$this->iId}', '{$this->sTargetClass}', '$sFilter', '$sTitle', true, $sWizHelper, '{$this->sAttCode}', $sJSSearchMode);
oACWidget_{$this->iId}.emptyHtml = "<div style=\"background: #fff; border:0; text-align:center; vertical-align:middle;\"><p>$sMessage</p></div>";
$('#$this->iId').bind('update', function() { oACWidget_{$this->iId}.Update(); } );
$('#$this->iId').bind('change', function() { $(this).trigger('extkeychange') } );
EOF
);
} // Switch
}
else
{
// Too many choices, use an autocomplete
$sSelectMode = 'false';
if (is_null($value) || ($value == 0)) // Null values are displayed as ''
{
$sDisplayValue = isset($aArgs['sDefaultValue']) ? $aArgs['sDefaultValue'] : '';
}
else
{
$sDisplayValue = $this->GetObjectName($value);
}
$iMinChars = isset($aArgs['iMinChars']) ? $aArgs['iMinChars'] : 3; //@@@ $this->oAttDef->GetMinAutoCompleteChars();
$iFieldSize = isset($aArgs['iFieldSize']) ? $aArgs['iFieldSize'] : 30; //@@@ $this->oAttDef->GetMaxSize();
// the input for the auto-complete
$sHTMLValue = "<input count=\"".$oAllowedValues->Count()."\" type=\"text\" id=\"label_$this->iId\" size=\"$iFieldSize\" value=\"$sDisplayValue\"/>&nbsp;";
$sHTMLValue .= "<img id=\"mini_search_{$this->iId}\" style=\"border:0;vertical-align:middle;cursor:pointer;\" src=\"../images/mini_search.gif\" onClick=\"oACWidget_{$this->iId}.Search();\"/>&nbsp;";
// another hidden input to store & pass the object's Id
$sHTMLValue .= "<input type=\"hidden\" id=\"$this->iId\" name=\"{$sAttrFieldPrefix}{$sFieldName}\" value=\"$value\" />\n";
$JSSearchMode = $this->bSearchMode ? 'true' : 'false';
// Scripts to start the autocomplete and bind some events to it
$oPage->add_ready_script(
<<<EOF
oACWidget_{$this->iId} = new ExtKeyWidget('{$this->iId}', '{$this->sTargetClass}', '$sFilter', '$sTitle', false, $sWizHelper, '{$this->sAttCode}', $sJSSearchMode);
oACWidget_{$this->iId}.emptyHtml = "<div style=\"background: #fff; border:0; text-align:center; vertical-align:middle;\"><p>$sMessage</p></div>";
$('#label_$this->iId').autocomplete(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php', { scroll:true, minChars:{$iMinChars}, autoFill:false, matchContains:true, mustMatch: true, keyHolder:'#{$this->iId}', extraParams:{operation:'ac_extkey', sTargetClass:'{$this->sTargetClass}',sFilter:'$sFilter',bSearchMode:$JSSearchMode, json: function() { return $sWizHelperJSON; } }});
$('#label_$this->iId').keyup(function() { if ($(this).val() == '') { $('#$this->iId').val(''); } } ); // Useful for search forms: empty value in the "label", means no value, immediatly !
$('#label_$this->iId').result( function(event, data, formatted) { OnAutoComplete('{$this->iId}', event, data, formatted); } );
$('#$this->iId').bind('update', function() { oACWidget_{$this->iId}.Update(); } );
if ($('#ac_dlg_{$this->iId}').length == 0)
{
$('body').append('<div id="ac_dlg_{$this->iId}"></div>');
}
EOF
);
}
if ($bExtensions && MetaModel::IsHierarchicalClass($this->sTargetClass) !== false)
{
$sHTMLValue .= "<img id=\"mini_tree_{$this->iId}\" style=\"border:0;vertical-align:middle;cursor:pointer;\" src=\"../images/mini_tree.gif\" onClick=\"oACWidget_{$this->iId}.HKDisplay();\"/>&nbsp;";
$oPage->add_ready_script(
<<<EOF
if ($('#ac_tree_{$this->iId}').length == 0)
{
$('body').append('<div id="ac_tree_{$this->iId}"></div>');
}
EOF
);
}
if ($bCreate && $bExtensions)
{
$sHTMLValue .= "<img id=\"mini_add_{$this->iId}\" style=\"border:0;vertical-align:middle;cursor:pointer;\" src=\"../images/mini_add.gif\" onClick=\"oACWidget_{$this->iId}.CreateObject();\"/>&nbsp;";
$oPage->add_ready_script(
<<<EOF
if ($('#ajax_{$this->iId}').length == 0)
{
$('body').append('<div id="ajax_{$this->iId}"></div>');
}
EOF
);
}
if ($sDisplayStyle == 'select')
{
$sHTMLValue .= "<span id=\"v_{$this->iId}\"></span>";
}
$sHTMLValue .= "</span>"; // end of no wrap
return $sHTMLValue;
}
public function GetSearchDialog(WebPage $oPage, $sTitle, $oCurrObject = null)
{
$sHTML = '<div class="wizContainer" style="vertical-align:top;"><div id="dc_'.$this->iId.'">';
if ( ($oCurrObject != null) && ($this->sAttCode != ''))
{
$oAttDef = MetaModel::GetAttributeDef(get_class($oCurrObject), $this->sAttCode);
$aParams = array('query_params' => array('this' => $oCurrObject));
$oSet = $oAttDef->GetAllowedValuesAsObjectSet($aParams);
$oFilter = $oSet->GetFilter();
}
else
{
$aParams = array();
$oFilter = new DBObjectSearch($this->sTargetClass);
}
$oFilter->SetModifierProperty('UserRightsGetSelectFilter', 'bSearchMode', $this->bSearchMode);
$oBlock = new DisplayBlock($oFilter, 'search', false, $aParams);
$sHTML .= $oBlock->GetDisplay($oPage, $this->iId, array('open' => true, 'currentId' => $this->iId));
$sHTML .= "<form id=\"fr_{$this->iId}\" OnSubmit=\"return oACWidget_{$this->iId}.DoOk();\">\n";
$sHTML .= "<div id=\"dr_{$this->iId}\" style=\"vertical-align:top;background: #fff;height:100%;overflow:auto;padding:0;border:0;\">\n";
$sHTML .= "<div style=\"background: #fff; border:0; text-align:center; vertical-align:middle;\"><p>".Dict::S('UI:Message:EmptyList:UseSearchForm')."</p></div>\n";
$sHTML .= "</div>\n";
$sHTML .= "<input type=\"button\" id=\"btn_cancel_{$this->iId}\" value=\"".Dict::S('UI:Button:Cancel')."\" onClick=\"$('#ac_dlg_{$this->iId}').dialog('close');\">&nbsp;&nbsp;";
$sHTML .= "<input type=\"button\" id=\"btn_ok_{$this->iId}\" value=\"".Dict::S('UI:Button:Ok')."\" onClick=\"oACWidget_{$this->iId}.DoOk();\">";
$sHTML .= "<input type=\"hidden\" id=\"count_{$this->iId}\" value=\"0\">";
$sHTML .= "</form>\n";
$sHTML .= '</div></div>';
$sDialogTitle = addslashes($sTitle);
$oPage->add_ready_script(
<<<EOF
$('#ac_dlg_{$this->iId}').dialog({ width: $(window).width()*0.8, height: $(window).height()*0.8, autoOpen: false, modal: true, title: '$sDialogTitle', resizeStop: oACWidget_{$this->iId}.UpdateSizes, close: oACWidget_{$this->iId}.OnClose });
$('#fs_{$this->iId}').bind('submit.uiAutocomplete', oACWidget_{$this->iId}.DoSearchObjects);
$('#dc_{$this->iId}').resize(oACWidget_{$this->iId}.UpdateSizes);
EOF
);
$oPage->add($sHTML);
}
/**
* Search for objects to be selected
* @param WebPage $oP The page used for the output (usually an AjaxWebPage)
* @param string $sRemoteClass Name of the "remote" class to perform the search on, must be a derived class of sTargetClass
* @param Array $aAlreadyLinkedIds List of IDs of objects of "remote" class already linked, to be filtered out of the search
*/
public function SearchObjectsToSelect(WebPage $oP, $sFilter, $sRemoteClass = '', $oObj = null)
{
if (is_null($sFilter))
{
throw new Exception('Implementation: null value for allowed values definition');
}
try
{
if ($sRemoteClass != $this->sTargetClass)
{
//$oBaseClassFilter = DBObjectSearch::FromOQL($sFilter);
//$oFilter = new DBObjectSearch($sRemoteClass);
//$oFilter->AddConditionExpression($oBaseClassFilter->GetCriteria());
//$oFilter->TransferConditionExpression($oBaseClassFilter, array());
//$oFilter->TransferConditionExpression($oBaseClassFilter, array($this->sTargetClass => array('*' => $sRemoteClass.'_'.strtolower($this->sTargetClass))));
$sFilter = str_replace(" $this->sTargetClass ", " $sRemoteClass ", $sFilter);
$sFilter = str_replace("`$this->sTargetClass`", "`$sRemoteClass`", $sFilter);
$oFilter = DBObjectSearch::FromOQL($sFilter);
}
else
{
$oFilter = DBObjectSearch::FromOQL($sFilter);
}
//$oP->p($oFilter->ToOQL());
$oFilter->SetModifierProperty('UserRightsGetSelectFilter', 'bSearchMode', $this->bSearchMode);
$oBlock = new DisplayBlock($oFilter, 'list', false, array('query_params' => array('this' => $oObj)));
$oBlock->Display($oP, $this->iId.'_results', array('this' => $oObj, 'cssCount'=> '#count_'.$this->iId, 'menu' => false, 'selection_mode' => true, 'selection_type' => 'single')); // Don't display the 'Actions' menu on the results
}
catch(MissingQueryArgument $e)
{
// When used in a search form the $this parameter may be missing, in this case return all possible values...
// TODO check if we can improve this behavior...
$sOQL = 'SELECT '.$sRemoteClass;
$oFilter = DBObjectSearch::FromOQL($sOQL);
$oFilter->SetModifierProperty('UserRightsGetSelectFilter', 'bSearchMode', $this->bSearchMode);
//$oBlock = new DisplayBlock($oFilter, 'list', false);
//$oBlock->Display($oP, $this->iId.'_results', array('cssCount'=> '#count_'.$this->iId, 'menu' => false, 'selection_mode' => true, 'selection_type' => 'single')); // Don't display the 'Actions' menu on the results
}
}
/**
* Search for objects to be selected
* @param WebPage $oP The page used for the output (usually an AjaxWebPage)
* @param string $sFilter The OQL expression used to define/limit limit the scope of possible values
* @param DBObject $oObj The current object for the OQL context
* @param string $sContains The text of the autocomplete to filter the results
*/
public function AutoComplete(WebPage $oP, $sFilter, $oObj = null, $sContains)
{
if (is_null($sFilter))
{
throw new Exception('Implementation: null value for allowed values definition');
}
$oValuesSet = new ValueSetObjects($sFilter, 'friendlyname'); // Bypass GetName() to avoid the encoding by htmlentities
$oValuesSet->SetModifierProperty('UserRightsGetSelectFilter', 'bSearchMode', $this->bSearchMode);
$aValues = $oValuesSet->GetValues(array('this' => $oObj), $sContains);
foreach($aValues as $sKey => $sFriendlyName)
{
$oP->add(trim($sFriendlyName)."\t".$sKey."\n");
}
}
/**
* Get the display name of the selected object, to fill back the autocomplete
*/
public function GetObjectName($iObjId)
{
$aModifierProps = array();
$aModifierProps['UserRightsGetSelectFilter']['bSearchMode'] = $this->bSearchMode;
$oObj = MetaModel::GetObject($this->sTargetClass, $iObjId, false, false, $aModifierProps);
if ($oObj)
{
return $oObj->GetName();
}
else
{
return '';
}
}
/**
* Get the form to create a new object of the 'target' class
*/
public function GetObjectCreationForm(WebPage $oPage, $oCurrObject)
{
// Set all the default values in an object and clone this "default" object
$oNewObj = MetaModel::NewObject($this->sTargetClass);
// 1st - set context values
$oAppContext = new ApplicationContext();
$oAppContext->InitObjectFromContext($oNewObj);
// 2nd set the default values from the constraint on the external key... if any
if ( ($oCurrObject != null) && ($this->sAttCode != ''))
{
$oAttDef = MetaModel::GetAttributeDef(get_class($oCurrObject), $this->sAttCode);
$aParams = array('this' => $oCurrObject);
$oSet = $oAttDef->GetAllowedValuesAsObjectSet($aParams);
$aConsts = $oSet->ListConstantFields();
$sClassAlias = $oSet->GetFilter()->GetClassAlias();
if (isset($aConsts[$sClassAlias]))
{
foreach($aConsts[$sClassAlias] as $sAttCode => $value)
{
$oNewObj->Set($sAttCode, $value);
}
}
}
// 3rd - set values from the page argument 'default'
$oNewObj->UpdateObjectFromArg('default');
$sDialogTitle = addslashes($this->sTitle);
$oPage->add('<div id="ac_create_'.$this->iId.'"><div class="wizContainer" style="vertical-align:top;"><div id="dcr_'.$this->iId.'">');
$oPage->add("<h1>".MetaModel::GetClassIcon($this->sTargetClass)."&nbsp;".Dict::Format('UI:CreationTitle_Class', MetaModel::GetName($this->sTargetClass))."</h1>\n");
cmdbAbstractObject::DisplayCreationForm($oPage, $this->sTargetClass, $oNewObj, array(), array('formPrefix' => $this->iId, 'noRelations' => true));
$oPage->add('</div></div></div>');
// $oPage->add_ready_script("\$('#ac_create_$this->iId').dialog({ width: $(window).width()*0.8, height: 'auto', autoOpen: false, modal: true, title: '$sDialogTitle'});\n");
$oPage->add_ready_script("\$('#ac_create_$this->iId').dialog({ width: 'auto', height: 'auto', autoOpen: false, modal: true, title: '$sDialogTitle'});\n");
$oPage->add_ready_script("$('#dcr_{$this->iId} form').removeAttr('onsubmit');");
$oPage->add_ready_script("$('#dcr_{$this->iId} form').bind('submit.uilinksWizard', oACWidget_{$this->iId}.DoCreateObject);");
}
/**
* Display the hierarchy of the 'target' class
*/
public function DisplayHierarchy(WebPage $oPage, $sFilter, $currValue, $oObj)
{
$sDialogTitle = addslashes(Dict::Format('UI:HierarchyOf_Class', MetaModel::GetName($this->sTargetClass)));
$oPage->add('<div id="dlg_tree_'.$this->iId.'"><div class="wizContainer" style="vertical-align:top;"><div style="overflow:auto;background:#fff;margin-bottom:5px;" id="tree_'.$this->iId.'">');
$oPage->add('<table style="width:100%"><tr><td>');
if (is_null($sFilter))
{
throw new Exception('Implementation: null value for allowed values definition');
}
try
{
$oFilter = DBObjectSearch::FromOQL($sFilter);
$oFilter->SetModifierProperty('UserRightsGetSelectFilter', 'bSearchMode', $this->bSearchMode);
$oSet = new DBObjectSet($oFilter, array(), array('this' => $oObj));
}
catch(MissingQueryArgument $e)
{
// When used in a search form the $this parameter may be missing, in this case return all possible values...
// TODO check if we can improve this behavior...
$sOQL = 'SELECT '.$this->m_sTargetClass;
$oFilter = DBObjectSearch::FromOQL($sOQL);
$oFilter->SetModifierProperty('UserRightsGetSelectFilter', 'bSearchMode', $this->bSearchMode);
$oSet = new DBObjectSet($oFilter);
}
$sHKAttCode = MetaModel::IsHierarchicalClass($this->sTargetClass);
$this->DumpTree($oPage, $oSet, $sHKAttCode, $currValue);
$oPage->add('</td></tr></table>');
$oPage->add('</div>');
$oPage->add("<input type=\"button\" id=\"btn_cancel_{$this->iId}\" value=\"".Dict::S('UI:Button:Cancel')."\" onClick=\"$('#dlg_tree_{$this->iId}').dialog('close');\">&nbsp;&nbsp;");
$oPage->add("<input type=\"button\" id=\"btn_ok_{$this->iId}\" value=\"".Dict::S('UI:Button:Ok')."\" onClick=\"oACWidget_{$this->iId}.DoHKOk();\">");
$oPage->add('</div></div>');
$oPage->add_ready_script("\$('#tree_$this->iId ul').treeview();\n");
$oPage->add_ready_script("\$('#dlg_tree_$this->iId').dialog({ width: 'auto', height: 'auto', autoOpen: true, modal: true, title: '$sDialogTitle', resizeStop: oACWidget_{$this->iId}.OnHKResize, close: oACWidget_{$this->iId}.OnHKClose });\n");
}
/**
* Get the form to create a new object of the 'target' class
*/
public function DoCreateObject($oPage)
{
$oObj = MetaModel::NewObject($this->sTargetClass);
$aErrors = $oObj->UpdateObjectFromPostedForm($this->iId);
if (count($aErrors) == 0)
{
$oMyChange = MetaModel::NewObject("CMDBChange");
$oMyChange->Set("date", time());
$sUserString = CMDBChange::GetCurrentUserName();
$oMyChange->Set("userinfo", $sUserString);
$iChangeId = $oMyChange->DBInsert();
$oObj->DBInsertTracked($oMyChange);
return array('name' => $oObj->GetName(), 'id' => $oObj->GetKey());
}
else
{
return array('name' => implode(' ', $aErrors), 'id' => 0);
}
}
function DumpTree($oP, $oSet, $sParentAttCode, $currValue)
{
$aTree = array();
$aNodes = array();
while($oObj = $oSet->Fetch())
{
$iParentId = $oObj->Get($sParentAttCode);
if (!isset($aTree[$iParentId]))
{
$aTree[$iParentId] = array();
}
$aTree[$iParentId][$oObj->GetKey()] = $oObj->GetName();
$aNodes[$oObj->GetKey()] = $oObj;
}
$aParents = array_keys($aTree);
$aRoots = array();
foreach($aParents as $id)
{
if (!array_key_exists($id, $aNodes))
{
$aRoots[] = $id;
}
}
foreach($aRoots as $iRootId)
{
$this->DumpNodes($oP, $iRootId, $aTree, $aNodes, $currValue);
}
}
function DumpNodes($oP, $iRootId, $aTree, $aNodes, $currValue)
{
$bSelect = true;
$bMultiple = false;
$sSelect = '';
if (array_key_exists($iRootId, $aTree))
{
$aSortedRoots = $aTree[$iRootId];
asort($aSortedRoots);
$oP->add("<ul>\n");
foreach($aSortedRoots as $id => $sName)
{
if ($bSelect)
{
$sChecked = ($aNodes[$id]->GetKey() == $currValue) ? 'checked' : '';
if ($bMultiple)
{
$sSelect = '<input type="checkbox" value="'.$aNodes[$id]->GetKey().'" name="selectObject[]" '.$sChecked.'>&nbsp;';
}
else
{
$sSelect = '<input type="radio" value="'.$aNodes[$id]->GetKey().'" name="selectObject" '.$sChecked.'>&nbsp;';
}
}
$oP->add('<li>'.$sSelect.$aNodes[$id]->GetHyperlink());
$this->DumpNodes($oP, $id, $aTree, $aNodes, $currValue);
$oP->add("</li>\n");
}
$oP->add("</ul>\n");
}
}
}
?>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,41 +1,276 @@
<?php
require_once('../core/config.class.inc.php');
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
define('ITOP_CONFIG_FILE', '../config-itop.php');
/**
* Static class utils
*
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
require_once(APPROOT.'/core/config.class.inc.php');
require_once(APPROOT.'/application/transaction.class.inc.php');
define('ITOP_CONFIG_FILE', APPROOT.'/config-itop.php');
define('SERVER_NAME_PLACEHOLDER', '$SERVER_NAME$');
class FileUploadException extends Exception
{
}
/**
* Helper functions to interact with forms: read parameters, upload files...
* @package iTop
*/
class utils
{
private static $m_sConfigFile = ITOP_CONFIG_FILE;
private static $m_oConfig = null;
private static $m_bCASClient = false;
public static function ReadParam($sName, $defaultValue = "")
// Parameters loaded from a file, parameters of the page/command line still have precedence
private static $m_aParamsFromFile = null;
private static $m_aParamSource = array();
protected static function LoadParamFile($sParamFile)
{
return isset($_REQUEST[$sName]) ? $_REQUEST[$sName] : $defaultValue;
if (!file_exists($sParamFile))
{
throw new Exception("Could not find the parameter file: '$sParamFile'");
}
if (!is_readable($sParamFile))
{
throw new Exception("Could not load parameter file: '$sParamFile'");
}
$sParams = file_get_contents($sParamFile);
if (is_null(self::$m_aParamsFromFile))
{
self::$m_aParamsFromFile = array();
}
$aParamLines = explode("\n", $sParams);
foreach ($aParamLines as $sLine)
{
$sLine = trim($sLine);
// Ignore the line after a '#'
if (($iCommentPos = strpos($sLine, '#')) !== false)
{
$sLine = substr($sLine, 0, $iCommentPos);
$sLine = trim($sLine);
}
// Note: the line is supposed to be already trimmed
if (preg_match('/^(\S*)\s*=(.*)$/', $sLine, $aMatches))
{
$sParam = $aMatches[1];
$value = trim($aMatches[2]);
self::$m_aParamsFromFile[$sParam] = $value;
self::$m_aParamSource[$sParam] = $sParamFile;
}
}
}
public static function UseParamFile($sParamFileArgName = 'param_file', $bAllowCLI = true)
{
$sFileSpec = self::ReadParam($sParamFileArgName, '', $bAllowCLI, 'raw_data');
foreach(explode(',', $sFileSpec) as $sFile)
{
$sFile = trim($sFile);
if (!empty($sFile))
{
self::LoadParamFile($sFile);
}
}
}
/**
* Return the source file from which the parameter has been found,
* usefull when it comes to pass user credential to a process executed
* in the background
* @param $sName Parameter name
* @return The file name if any, or null
*/
public static function GetParamSourceFile($sName)
{
if (array_key_exists($sName, self::$m_aParamSource))
{
return self::$m_aParamSource[$sName];
}
else
{
return null;
}
}
public static function IsModeCLI()
{
$sSAPIName = php_sapi_name();
$sCleanName = strtolower(trim($sSAPIName));
if ($sCleanName == 'cli')
{
return true;
}
else
{
return false;
}
}
public static function ReadParam($sName, $defaultValue = "", $bAllowCLI = false, $sSanitizationFilter = 'parameter')
{
global $argv;
$retValue = $defaultValue;
if (!is_null(self::$m_aParamsFromFile))
{
if (isset(self::$m_aParamsFromFile[$sName]))
{
$retValue = self::$m_aParamsFromFile[$sName];
}
}
if (isset($_REQUEST[$sName]))
{
$retValue = $_REQUEST[$sName];
}
elseif ($bAllowCLI && isset($argv))
{
foreach($argv as $iArg => $sArg)
{
if (preg_match('/^--'.$sName.'=(.*)$/', $sArg, $aMatches))
{
$retValue = $aMatches[1];
}
}
}
return self::Sanitize($retValue, $defaultValue, $sSanitizationFilter);
}
public static function ReadPostedParam($sName, $defaultValue = "")
public static function ReadPostedParam($sName, $defaultValue = '', $sSanitizationFilter = 'parameter')
{
return isset($_POST[$sName]) ? $_POST[$sName] : $defaultValue;
$retValue = isset($_POST[$sName]) ? $_POST[$sName] : $defaultValue;
return self::Sanitize($retValue, $defaultValue, $sSanitizationFilter);
}
public static function Sanitize($value, $defaultValue, $sSanitizationFilter)
{
if ($value === $defaultValue)
{
// Preserve the real default value (can be used to detect missing mandatory parameters)
$retValue = $value;
}
else
{
$retValue = self::Sanitize_Internal($value, $sSanitizationFilter);
if ($retValue === false)
{
$retValue = $defaultValue;
}
}
return $retValue;
}
protected static function Sanitize_Internal($value, $sSanitizationFilter)
{
switch($sSanitizationFilter)
{
case 'integer':
$retValue = filter_var($value, FILTER_SANITIZE_NUMBER_INT);
break;
case 'class':
$retValue = $value;
if (!MetaModel::IsValidClass($value))
{
$retValue = false;
}
break;
case 'string':
$retValue = filter_var($value, FILTER_SANITIZE_SPECIAL_CHARS);
break;
case 'parameter':
case 'field_name':
if (is_array($value))
{
$retValue = array();
foreach($value as $key => $val)
{
$retValue[$key] = self::Sanitize_Internal($val, $sSanitizationFilter); // recursively check arrays
if ($retValue[$key] === false)
{
$retValue = false;
break;
}
}
}
else
{
switch($sSanitizationFilter)
{
case 'parameter':
$retValue = filter_var($value, FILTER_VALIDATE_REGEXP, array("options"=>array("regexp"=>'/^[ A-Za-z0-9_=-]*$/'))); // the '=' equal character is used in serialized filters
break;
case 'field_name':
$retValue = filter_var($value, FILTER_VALIDATE_REGEXP, array("options"=>array("regexp"=>'/^[A-Za-z0-9_]+(->[A-Za-z0-9_]+)*$/'))); // att_code or att_code->name or AttCode->Name or AttCode->Key2->Name
break;
}
}
break;
break;
default:
case 'raw_data':
$retValue = $value;
// Do nothing
}
return $retValue;
}
/**
* Reads an uploaded file and turns it into an ormDocument object - Triggers an exception in case of error
* @param string $sName Name of the input used from uploading the file
* @param string $sIndex If Name is an array of posted files, then the index must be used to point out the file
* @return ormDocument The uploaded file (can be 'empty' if nothing was uploaded)
*/
public static function ReadPostedDocument($sName)
public static function ReadPostedDocument($sName, $sIndex = null)
{
$oDocument = new ormDocument(); // an empty document
if(isset($_FILES[$sName]))
{
switch($_FILES[$sName]['error'])
$aFileInfo = $_FILES[$sName];
$sError = is_null($sIndex) ? $aFileInfo['error'] : $aFileInfo['error'][$sIndex];
switch($sError)
{
case UPLOAD_ERR_OK:
$doc_content = file_get_contents($_FILES[$sName]['tmp_name']);
$sMimeType = $_FILES[$sName]['type'];
$sTmpName = is_null($sIndex) ? $aFileInfo['tmp_name'] : $aFileInfo['tmp_name'][$sIndex];
$sMimeType = is_null($sIndex) ? $aFileInfo['type'] : $aFileInfo['type'][$sIndex];
$sName = is_null($sIndex) ? $aFileInfo['name'] : $aFileInfo['name'][$sIndex];
$doc_content = file_get_contents($sTmpName);
if (function_exists('finfo_file'))
{
// as of PHP 5.3 the fileinfo extension is bundled within PHP
@@ -51,9 +286,9 @@ class utils
$sMimeType = $sType;
}
}
@finfo_close($finfo);
@finfo_close($rInfo);
}
$oDocument = new ormDocument($doc_content, $sMimeType, $_FILES[$sName]['name']);
$oDocument = new ormDocument($doc_content, $sMimeType, $sName);
break;
case UPLOAD_ERR_NO_FILE:
@@ -62,27 +297,28 @@ class utils
case UPLOAD_ERR_FORM_SIZE:
case UPLOAD_ERR_INI_SIZE:
throw new FileUploadException("Uploaded file is too big. (Max allowed size is ".ini_get('upload_max_filesize').". Check you PHP configuration for upload_max_filesize.");
throw new FileUploadException(Dict::Format('UI:Error:UploadedFileTooBig', ini_get('upload_max_filesize')));
break;
case UPLOAD_ERR_PARTIAL:
throw new FileUploadException("File upload failed, file has been truncated.");
throw new FileUploadException(Dict::S('UI:Error:UploadedFileTruncated.'));
break;
case UPLOAD_ERR_NO_TMP_DIR:
throw new FileUploadException("Missing a temporary folder.");
throw new FileUploadException(Dict::S('UI:Error:NoTmpDir'));
break;
case UPLOAD_ERR_CANT_WRITE:
throw new FileUploadException("Unable to write the temporary file to the disk (upload_tmp_dir = ".ini_get('upload_tmp_dir').")");
throw new FileUploadException(Dict::Format('UI:Error:CannotWriteToTmp_Dir', ini_get('upload_tmp_dir')));
break;
case UPLOAD_ERR_EXTENSION:
throw new FileUploadException("File upload stopped by extension. (Original file name: ".$_FILES[$sName]['name'].")");
$sName = is_null($sIndex) ? $aFileInfo['name'] : $aFileInfo['name'][$sIndex];
throw new FileUploadException(Dict::Format('UI:Error:UploadStoppedByExtension_FileName', $sName));
break;
default:
throw new FileUploadException("File upload failed, unknown cause (Error code = ".$_FILES[$sName]['error'].")");
throw new FileUploadException(Dict::Format('UI:Error:UploadFailedUnknownCause_Code', $sError));
break;
}
@@ -90,16 +326,56 @@ class utils
return $oDocument;
}
/**
* Interprets the results posted by a normal or paginated list (in multiple selection mode)
* @param $oFullSetFilter DBObjectSearch The criteria defining the whole sets of objects being selected
* @return Array An arry of object IDs corresponding to the objects selected in the set
*/
public static function ReadMultipleSelection($oFullSetFilter)
{
$aSelectedObj = utils::ReadParam('selectObject', array());
$sSelectionMode = utils::ReadParam('selectionMode', '');
if ($sSelectionMode != '')
{
// Paginated selection
$aExceptions = utils::ReadParam('storedSelection', array());
if ($sSelectionMode == 'positive')
{
// Only the explicitely listed items are selected
$aSelectedObj = $aExceptions;
}
else
{
// All items of the set are selected, except the one explicitely listed
$aSelectedObj = array();
$oFullSet = new DBObjectSet($oFullSetFilter);
$sClassAlias = $oFullSetFilter->GetClassAlias();
$oFullSet->OptimizeColumnLoad(array($sClassAlias => array('friendlyname'))); // We really need only the IDs but it does not work since id is not a real field
while($oObj = $oFullSet->Fetch())
{
if (!in_array($oObj->GetKey(), $aExceptions))
{
$aSelectedObj[] = $oObj->GetKey();
}
}
}
}
return $aSelectedObj;
}
public static function GetNewTransactionId()
{
// TO DO implement the real mechanism here
return sprintf("%08x", rand(0,2000000000));
return privUITransaction::GetNewTransactionId();
}
public static function IsTransactionValid($sId)
public static function IsTransactionValid($sId, $bRemoveTransaction = true)
{
// TO DO implement the real mechanism here
return true;
return privUITransaction::IsTransactionValid($sId, $bRemoveTransaction);
}
public static function RemoveTransaction($sId)
{
return privUITransaction::RemoveTransaction($sId);
}
public static function ReadFromFile($sFileName)
@@ -108,19 +384,6 @@ class utils
return file_get_contents($sFileName);
}
/**
* Get access to the application config file
* @param none
* @return Config The Config object initialized from the application config file
*/
public static function GetConfig()
{
if (self::$m_oConfig == null)
{
self::$m_oConfig = new Config(ITOP_CONFIG_FILE);
}
return self::$m_oConfig;
}
/**
* Helper function to convert a value expressed in a 'user friendly format'
* as in php.ini, e.g. 256k, 2M, 1G etc. Into a number of bytes
@@ -148,23 +411,89 @@ class utils
return $iReturn;
}
/**
* Helper function to convert a string to a date, given a format specification. It replaces strtotime which does not allow for specifying a date in a french format (for instance)
* Example: StringToTime('01/05/11 12:03:45', '%d/%m/%y %H:%i:%s')
* @param string $sDate
* @param string $sFormat
* @return timestamp or false if the input format is not correct
*/
public static function StringToTime($sDate, $sFormat)
{
// Source: http://php.net/manual/fr/function.strftime.php
// (alternative: http://www.php.net/manual/fr/datetime.formats.date.php)
static $aDateTokens = null;
static $aDateRegexps = null;
if (is_null($aDateTokens))
{
$aSpec = array(
'%d' =>'(?<day>[0-9]{2})',
'%m' => '(?<month>[0-9]{2})',
'%y' => '(?<year>[0-9]{2})',
'%Y' => '(?<year>[0-9]{4})',
'%H' => '(?<hour>[0-2][0-9])',
'%i' => '(?<minute>[0-5][0-9])',
'%s' => '(?<second>[0-5][0-9])',
);
$aDateTokens = array_keys($aSpec);
$aDateRegexps = array_values($aSpec);
}
$sDateRegexp = str_replace($aDateTokens, $aDateRegexps, $sFormat);
if (preg_match('!^(?<head>)'.$sDateRegexp.'(?<tail>)$!', $sDate, $aMatches))
{
$sYear = isset($aMatches['year']) ? $aMatches['year'] : 0;
$sMonth = isset($aMatches['month']) ? $aMatches['month'] : 1;
$sDay = isset($aMatches['day']) ? $aMatches['day'] : 1;
$sHour = isset($aMatches['hour']) ? $aMatches['hour'] : 0;
$sMinute = isset($aMatches['minute']) ? $aMatches['minute'] : 0;
$sSecond = isset($aMatches['second']) ? $aMatches['second'] : 0;
return strtotime("$sYear-$sMonth-$sDay $sHour:$sMinute:$sSecond");
}
else
{
return false;
}
// http://www.spaweditor.com/scripts/regex/index.php
}
/**
* Returns an absolute URL to the current page
* @param $bQueryString bool True to also get the query string, false otherwise
* @return string The absolute URL to the current page
* Returns the absolute URL to the server's root path
* @return string The absolute URL to the server's root, without the first slash
*/
static public function GetAbsoluteUrl($bQueryString = true)
static public function GetAbsoluteUrlAppRoot()
{
$sUrl = MetaModel::GetConfig()->Get('app_root_url');
if (strpos($sUrl, SERVER_NAME_PLACEHOLDER) > -1)
{
if (isset($_SERVER['SERVER_NAME']))
{
$sServerName = $_SERVER['SERVER_NAME'];
}
else
{
// CLI mode ?
$sServerName = php_uname('n');
}
$sUrl = str_replace(SERVER_NAME_PLACEHOLDER, $sServerName, $sUrl);
}
return $sUrl;
}
static public function GetDefaultUrlAppRoot()
{
// Build an absolute URL to this page on this server/port
$sServerName = $_SERVER['SERVER_NAME'];
$sProtocol = isset($_SERVER['HTTPS']) ? 'https' : 'http';
$sServerName = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : '';
$sProtocol = (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS']!="off")) ? 'https' : 'http';
$iPort = isset($_SERVER['SERVER_PORT']) ? $_SERVER['SERVER_PORT'] : 80;
if ($sProtocol == 'http')
{
$sPort = ($_SERVER['SERVER_PORT'] == 80) ? '' : ':'.$_SERVER['SERVER_PORT'];
$sPort = ($iPort == 80) ? '' : ':'.$iPort;
}
else
{
$sPort = ($_SERVER['SERVER_PORT'] == 443) ? '' : ':'.$_SERVER['SERVER_PORT'];
$sPort = ($iPort == 443) ? '' : ':'.$iPort;
}
// $_SERVER['REQUEST_URI'] is empty when running on IIS
// Let's use Ivan Tcholakov's fix (found on www.dokeos.com)
@@ -181,19 +510,215 @@ class utils
}
$_SERVER['REQUEST_URI'] = $sPath;
}
$sPath = $_SERVER['REQUEST_URI'];
if (!$bQueryString)
{
// remove all the parameters from the query string
$iQuestionMarkPos = strpos($sPath, '?');
if ($iQuestionMarkPos !== false)
{
$sPath = substr($sPath, 0, $iQuestionMarkPos);
}
}
$sUrl = "$sProtocol://{$sServerName}{$sPort}{$sPath}";
$sPath = $_SERVER['REQUEST_URI'];
// remove all the parameters from the query string
$iQuestionMarkPos = strpos($sPath, '?');
if ($iQuestionMarkPos !== false)
{
$sPath = substr($sPath, 0, $iQuestionMarkPos);
}
$sAbsoluteUrl = "$sProtocol://{$sServerName}{$sPort}{$sPath}";
$sCurrentScript = realpath($_SERVER['SCRIPT_FILENAME']);
$sCurrentScript = str_replace('\\', '/', $sCurrentScript); // canonical path
$sAppRoot = str_replace('\\', '/', APPROOT); // canonical path
$sCurrentRelativePath = str_replace($sAppRoot, '', $sCurrentScript);
$sAppRootPos = strpos($sAbsoluteUrl, $sCurrentRelativePath);
if ($sAppRootPos !== false)
{
$sAppRootUrl = substr($sAbsoluteUrl, 0, $sAppRootPos); // remove the current page and path
}
else
{
// Second attempt without index.php at the end...
$sCurrentRelativePath = str_replace('index.php', '', $sCurrentRelativePath);
$sAppRootPos = strpos($sAbsoluteUrl, $sCurrentRelativePath);
if ($sAppRootPos !== false)
{
$sAppRootUrl = substr($sAbsoluteUrl, 0, $sAppRootPos); // remove the current page and path
}
else
{
// No luck...
throw new Exception("Failed to determine application root path $sAbsoluteUrl ($sCurrentRelativePath) APPROOT:'$sAppRoot'");
}
}
return $sAppRootUrl;
}
/**
* Returns the absolute URL to the modules root path
* Hardcoded here for compatibility with iTop 2.0 modules
* @return string The absolute URL to the modules
*/
static public function GetAbsoluteUrlModulesRoot()
{
$sUrl = self::GetAbsoluteUrlAppRoot().'modules/';
return $sUrl;
}
/**
* Tells whether or not log off operation is supported.
* Actually in only one case:
* 1) iTop is using an internal authentication
* 2) the user did not log-in using the "basic" mode (i.e basic authentication) or by passing credentials in the URL
* @return boolean True if logoff is supported, false otherwise
*/
static function CanLogOff()
{
$bResult = false;
if(isset($_SESSION['login_mode']))
{
$sLoginMode = $_SESSION['login_mode'];
switch($sLoginMode)
{
case 'external':
$bResult = false;
break;
case 'form':
case 'basic':
case 'url':
case 'cas':
default:
$bResult = true;
}
}
return $bResult;
}
/**
* Initializes the CAS client
*/
static function InitCASClient()
{
$sCASIncludePath = MetaModel::GetConfig()->Get('cas_include_path');
include_once($sCASIncludePath.'/CAS.php');
$bCASDebug = MetaModel::GetConfig()->Get('cas_debug');
if ($bCASDebug)
{
phpCAS::setDebug(APPROOT.'/error.log');
}
if (!self::$m_bCASClient)
{
// Initialize phpCAS
$sCASVersion = MetaModel::GetConfig()->Get('cas_version');
$sCASHost = MetaModel::GetConfig()->Get('cas_host');
$iCASPort = MetaModel::GetConfig()->Get('cas_port');
$sCASContext = MetaModel::GetConfig()->Get('cas_context');
phpCAS::client($sCASVersion, $sCASHost, $iCASPort, $sCASContext, false /* session already started */);
self::$m_bCASClient = true;
$sCASCACertPath = MetaModel::GetConfig()->Get('cas_server_ca_cert_path');
if (empty($sCASCACertPath))
{
// If no certificate authority is provided, do not attempt to validate
// the server's certificate
// THIS SETTING IS NOT RECOMMENDED FOR PRODUCTION.
// VALIDATING THE CAS SERVER IS CRUCIAL TO THE SECURITY OF THE CAS PROTOCOL!
phpCAS::setNoCasServerValidation();
}
else
{
phpCAS::setCasServerCACert($sCASCACertPath);
}
}
}
static function DebugBacktrace($iLimit = 5)
{
$aFullTrace = debug_backtrace();
$aLightTrace = array();
for($i=1; ($i<=$iLimit && $i < count($aFullTrace)); $i++) // Skip the last function call... which is the call to this function !
{
$aLightTrace[$i] = $aFullTrace[$i]['function'].'(), called from line '.$aFullTrace[$i]['line'].' in '.$aFullTrace[$i]['file'];
}
echo "<p><pre>".print_r($aLightTrace, true)."</pre></p>\n";
}
/**
* Execute the given iTop PHP script, passing it the current credentials
* Only CLI mode is supported, because of the need to hand the credentials over to the next process
* Throws an exception if the execution fails or could not be attempted (config issue)
* @param string $sScript Name and relative path to the file (relative to the iTop root dir)
* @param hash $aArguments Associative array of 'arg' => 'value'
* @return array(iCode, array(output lines))
*/
/**
*/
static function ExecITopScript($sScriptName, $aArguments)
{
$aDisabled = explode(', ', ini_get('disable_functions'));
if (in_array('exec', $aDisabled))
{
throw new Exception("The PHP exec() function has been disabled on this server");
}
$sPHPExec = trim(MetaModel::GetConfig()->Get('php_path'));
if (strlen($sPHPExec) == 0)
{
throw new Exception("The path to php must not be empty. Please set a value for 'php_path' in your configuration file.");
}
$sAuthUser = self::ReadParam('auth_user', '', 'raw_data');
$sAuthPwd = self::ReadParam('auth_pwd', '', 'raw_data');
$sParamFile = self::GetParamSourceFile('auth_user');
if (is_null($sParamFile))
{
$aArguments['auth_user'] = $sAuthUser;
$aArguments['auth_pwd'] = $sAuthPwd;
}
else
{
$aArguments['param_file'] = $sParamFile;
}
$aArgs = array();
foreach($aArguments as $sName => $value)
{
// Note: See comment from the 23-Apr-2004 03:30 in the PHP documentation
// It suggests to rely on pctnl_* function instead of using escapeshellargs
$aArgs[] = "--$sName=".escapeshellarg($value);
}
$sArgs = implode(' ', $aArgs);
$sScript = realpath(APPROOT.$sScriptName);
if (!file_exists($sScript))
{
throw new Exception("Could not find the script file '$sScriptName' from the directory '".APPROOT."'");
}
$sCommand = '"'.$sPHPExec.'" '.escapeshellarg($sScript).' -- '.$sArgs;
if (version_compare(phpversion(), '5.3.0', '<'))
{
if (substr(PHP_OS,0,3) == 'WIN')
{
// Under Windows, and for PHP 5.2.x, the whole command has to be quoted
// Cf PHP doc: http://php.net/manual/fr/function.exec.php, comment from the 27-Dec-2010
$sCommand = '"'.$sCommand.'"';
}
}
$sLastLine = exec($sCommand, $aOutput, $iRes);
if ($iRes == 1)
{
throw new Exception(Dict::S('Core:ExecProcess:Code1')." - ".$sCommand);
}
elseif ($iRes == 255)
{
$sErrors = implode("\n", $aOutput);
throw new Exception(Dict::S('Core:ExecProcess:Code255')." - ".$sCommand.":\n".$sErrors);
}
//$aOutput[] = $sCommand;
return array($iRes, $aOutput);
}
}
?>

View File

@@ -1,4 +1,28 @@
<?php
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* Class WebPage
*
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
/**
* Simple helper class to ease the production of HTML pages
*
@@ -21,7 +45,14 @@ class WebPage
protected $a_include_stylesheets;
protected $a_headers;
protected $a_base;
protected $iNextId;
protected $iTransactionId;
protected $sContentType;
protected $sContentDisposition;
protected $sContentFileName;
protected $s_sOutputFormat;
protected $a_OutputOptions;
public function __construct($s_title)
{
$this->s_title = $s_title;
@@ -33,6 +64,13 @@ class WebPage
$this->a_linked_stylesheets = array();
$this->a_headers = array();
$this->a_base = array( 'href' => '', 'target' => '');
$this->iNextId = 0;
$this->iTransactionId = 0;
$this->sContentType = '';
$this->sContentDisposition = '';
$this->sContentFileName = '';
$this->s_OutputFormat = utils::ReadParam('output_format', 'html');
$this->a_OutputOptions = array();
ob_start(); // Start capturing the output
}
@@ -62,11 +100,11 @@ class WebPage
}
/**
* Add any text or HTML fragment at the end of the body of the page
* Add any text or HTML fragment (identified by an ID) at the end of the body of the page
* This is useful to add hidden content, DIVs or FORMs that should not
* be embedded into each other.
*/
public function add_at_the_end($s_html)
public function add_at_the_end($s_html, $sId = '')
{
$this->s_deferred_content .= $s_html;
}
@@ -79,6 +117,14 @@ class WebPage
$this->add($this->GetP($s_html));
}
/**
* Add a pre-formatted text to the body of the page
*/
public function pre($s_html)
{
$this->add('<pre>'.$s_html.'</pre>');
}
/**
* Add a paragraph to the body of the page
*/
@@ -87,6 +133,13 @@ class WebPage
return "<p>$s_html</p>\n";
}
/**
* Adds a tabular content to the web page
* @param Hash $aConfig Configuration of the table: hash array of 'column_id' => 'Column Label'
* @param Hash $aData Hash array. Data to display in the table: each row is made of 'column_id' => Data. A column 'pkey' is expected for each row
* @param Hash $aParams Hash array. Extra parameters for the table.
* @return void
*/
public function table($aConfig, $aData, $aParams = array())
{
$this->add($this->GetTable($aConfig, $aData, $aParams));
@@ -111,38 +164,33 @@ class WebPage
$sHtml .= "<tbody>\n";
foreach($aData as $aRow)
{
if (false) //(isset($aParams['preview']) && $aParams['preview'])
{
$sHtml .= "<tr id=\"Row_".$iNbTables."_".$aRow['key']."\" onClick=\"DisplayPreview(".$iNbTables.",".$aRow['key'].",'".$aParams['class']."')\">\n";
}
else if (isset($aRow['key']))
{
$sHtml .= "<tr onDblClick=\"DisplayDetails(".$aRow['key'].",'".$aParams['class']."')\">\n";
}
else
{
$sHtml .= "<tr>\n";
}
foreach($aConfig as $sName=>$aAttribs)
{
$sClass = isset($aAttribs['class']) ? 'class="'.$aAttribs['class'].'"' : '';
if ($sName != 'key')
{
$sValue = ($aRow[$sName] === '') ? '&nbsp;' : $aRow[$sName];
$sHtml .= "<td $sClass>$sValue</td>\n";
}
else
{
$sUIPage = cmdbAbstractObject::ComputeUIPage($aParams['class']);
$sHtml .= "<td><a class=\"no-arrow\" href=\"$sUIPage?operation=details&id=".$aRow['key']."&class=".$aParams['class']."&".$oAppContext->GetForLink()."\"><img src=\"../images/zoom.gif\" title=\"Details\" border=\"0\"></a></td>\n";
}
}
$sHtml .= "</tr>\n";
$sHtml .= $this->GetTableRow($aRow, $aConfig);
}
$sHtml .= "</tbody>\n";
$sHtml .= "</table>\n";
return $sHtml;
}
public function GetTableRow($aRow, $aConfig)
{
$sHtml = '';
if (isset($aRow['@class'])) // Row specific class, for hilighting certain rows
{
$sHtml .= "<tr class=\"{$aRow['@class']}\">";
}
else
{
$sHtml .= "<tr>";
}
foreach($aConfig as $sName=>$aAttribs)
{
$sClass = isset($aAttribs['class']) ? 'class="'.$aAttribs['class'].'"' : '';
$sValue = ($aRow[$sName] === '') ? '&nbsp;' : $aRow[$sName];
$sHtml .= "<td $sClass>$sValue</td>";
}
$sHtml .= "</tr>";
return $sHtml;
}
/**
* Add some Javascript to the header of the page
@@ -172,7 +220,7 @@ class WebPage
*/
public function add_linked_script($s_linked_script)
{
$this->a_linked_scripts[] = $s_linked_script;
$this->a_linked_scripts[$s_linked_script] = $s_linked_script;
}
/**
@@ -208,13 +256,35 @@ class WebPage
$this->add($this->GetDetails($aFields));
}
/**
* Records the current state of the 'html' part of the page output
* @return mixed The current state of the 'html' output
*/
public function start_capture()
{
return strlen($this->s_content);
}
/**
* Returns the part of the html output that occurred since the call to start_capture
* and removes this part from the current html output
* @param $offset mixed The value returned by start_capture
* @return string The part of the html output that was added since the call to start_capture
*/
public function end_capture($offset)
{
$sCaptured = substr($this->s_content, $offset);
$this->s_content = substr($this->s_content, 0, $offset);
return $sCaptured;
}
/**
* Build a special kind of TABLE useful for displaying the details of an object from a hash array of data
*/
public function GetDetails($aFields)
{
$sHtml = "<table>\n";
$sHtml = "<table class=\"details\">\n";
$sHtml .= "<tbody>\n";
foreach($aFields as $aAttrib)
{
@@ -228,12 +298,62 @@ class WebPage
{
$sHtml .= "<td class=\"label\">".$aAttrib['label']."</td><td>".$aAttrib['value']."</td>\n";
}
$sComment = (isset($aAttrib['comments'])) ? $aAttrib['comments'] : '&nbsp;';
$sInfo = (isset($aAttrib['infos'])) ? $aAttrib['infos'] : '&nbsp;';
$sHtml .= "<td>$sComment</td><td>$sInfo</td>\n";
$sHtml .= "</tr>\n";
}
$sHtml .= "</tbody>\n";
$sHtml .= "</table>\n";
return $sHtml;
}
/**
* Build a set of radio buttons suitable for editing a field/attribute of an object (including its validation)
* @param $aAllowedValues hash Array of value => display_value
* @param $value mixed Current value for the field/attribute
* @param $iId mixed Unique Id for the input control in the page
* @param $sFieldName string The name of the field, attr_<$sFieldName> will hold the value for the field
* @param $bMandatory bool Whether or not the field is mandatory
* @param $bVertical bool Disposition of the radio buttons vertical or horizontal
* @param $sValidationField string HTML fragment holding the validation field (exclamation icon...)
* @return string The HTML fragment corresponding to the radio buttons
*/
public function GetRadioButtons($aAllowedValues, $value, $iId, $sFieldName, $bMandatory, $bVertical, $sValidationField)
{
$idx = 0;
$sHTMLValue = '';
foreach($aAllowedValues as $key => $display_value)
{
if ((count($aAllowedValues) == 1) && ($bMandatory == 'true') )
{
// When there is only once choice, select it by default
$sSelected = ' checked';
}
else
{
$sSelected = ($value == $key) ? ' checked' : '';
}
$sHTMLValue .= "<input type=\"radio\" id=\"{$iId}_{$key}\" name=\"radio_$sFieldName\" onChange=\"$('#{$iId}').val(this.value).trigger('change');\" value=\"$key\"$sSelected><label class=\"radio\" for=\"{$iId}_{$key}\">&nbsp;$display_value</label>&nbsp;";
if ($bVertical)
{
if ($idx == 0)
{
// Validation icon at the end of the first line
$sHTMLValue .= "&nbsp;{$sValidationField}\n";
}
$sHTMLValue .= "<br>\n";
}
$idx++;
}
$sHTMLValue .= "<input type=\"hidden\" id=\"$iId\" name=\"$sFieldName\" value=\"$value\"/>";
if (!$bVertical)
{
// Validation icon at the end of the line
$sHTMLValue .= "&nbsp;{$sValidationField}\n";
}
return $sHTMLValue;
}
/**
* Outputs (via some echo) the complete HTML page by assembling all its elements
@@ -249,10 +369,21 @@ class WebPage
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n";
echo "<html>\n";
echo "<head>\n";
echo "<title>{$this->s_title}</title>\n";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n";
echo "<title>".htmlentities($this->s_title, ENT_QUOTES, 'UTF-8')."</title>\n";
echo $this->get_base_tag();
foreach($this->a_linked_scripts as $s_script)
{
// Make sure that the URL to the script contains the application's version number
// so that the new script do NOT get reloaded from the cache when the application is upgraded
if (strpos($s_script, '?') === false)
{
$s_script .= "?itopversion=".ITOP_VERSION;
}
else
{
$s_script .= "&itopversion=".ITOP_VERSION;
}
echo "<script type=\"text/javascript\" src=\"$s_script\"></script>\n";
}
if (count($this->a_scripts)>0)
@@ -286,14 +417,18 @@ class WebPage
}
echo "</style>\n";
}
if (class_exists('MetaModel') && MetaModel::GetConfig())
{
echo "<link rel=\"shortcut icon\" href=\"".utils::GetAbsoluteUrlAppRoot()."images/favicon.ico\" />\n";
}
echo "</head>\n";
echo "<body>\n";
echo $this->s_content;
echo self::FilterXSS($this->s_content);
if (trim($s_captured_output) != "")
{
echo "<div class=\"raw_output\">$s_captured_output</div>\n";
echo "<div class=\"raw_output\">".self::FilterXSS($s_captured_output)."</div>\n";
}
echo $this->s_deferred_content;
echo '<div id="at_the_end">'.self::FilterXSS($this->s_deferred_content).'</div>';
echo "</body>\n";
echo "</html>\n";
}
@@ -329,5 +464,122 @@ class WebPage
}
return $sTag;
}
/**
* Get an ID (for any kind of HTML tag) that is guaranteed unique in this page
* @return int The unique ID (in this page)
*/
public function GetUniqueId()
{
return $this->iNextId++;
}
/**
* Set the content-type (mime type) for the page's content
* @param $sContentType string
* @return void
*/
public function SetContentType($sContentType)
{
$this->sContentType = $sContentType;
}
/**
* Set the content-disposition (mime type) for the page's content
* @param $sDisposition string The disposition: 'inline' or 'attachment'
* @param $sFileName string The original name of the file
* @return void
*/
public function SetContentDisposition($sDisposition, $sFileName)
{
$this->sContentDisposition = $sDisposition;
$this->sContentFileName = $sFileName;
}
/**
* Set the transactionId of the current form
* @param $iTransactionId integer
* @return void
*/
public function SetTransactionId($iTransactionId)
{
$this->iTransactionId = $iTransactionId;
}
/**
* Returns the transactionId of the current form
* @return integer The current transactionID
*/
public function GetTransactionId()
{
return $this->iTransactionId;
}
public static function FilterXSS($sHTML)
{
return str_ireplace('<script', '&lt;script', $sHTML);
}
/**
* What is the currently selected output format
* @return string The selected output format: html, pdf...
*/
public function GetOutputFormat()
{
return $this->s_OutputFormat;
}
/**
* Check whether the desired output format is possible or not
* @param string $sOutputFormat The desired output format: html, pdf...
* @return bool True if the format is Ok, false otherwise
*/
function IsOutputFormatAvailable($sOutputFormat)
{
$bResult = false;
switch($sOutputFormat)
{
case 'html':
$bResult = true; // Always supported
break;
case 'pdf':
$bResult = @is_readable(APPROOT.'lib/MPDF/mpdf.php');
break;
}
return $bResult;
}
/**
* Retrieves the value of a named output option for the given format
* @param string $sFormat The format: html or pdf
* @param string $sOptionName The name of the option
* @return mixed false if the option was never set or the options's value
*/
public function GetOutputOption($sFormat, $sOptionName)
{
if (isset($this->a_OutputOptions[$sFormat][$sOptionName]))
{
return $this->a_OutputOptions[$sFormat][$sOptionName];
}
return false;
}
/**
* Sets a named output option for the given format
* @param string $sFormat The format for which to set the option: html or pdf
* @param string $sOptionName the name of the option
* @param mixed $sValue The value of the option
*/
public function SetOutputOption($sFormat, $sOptionName, $sValue)
{
if (!isset($this->a_OutputOptions[$sFormat]))
{
$this->a_OutputOptions[$sFormat] = array($sOptionName => $sValue);
}
else
{
$this->a_OutputOptions[$sFormat][$sOptionName] = $sValue;
}
}
}
?>
?>

View File

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

View File

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

12
approot.inc.php Normal file
View File

@@ -0,0 +1,12 @@
<?php
define('APPROOT', dirname(__FILE__).'/');
define('MODULESROOT', APPROOT.'modules/');
if (function_exists('microtime'))
{
$fItopStarted = microtime(true);
}
else
{
$fItopStarted = 1000 * time();
}
?>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,17 +1,36 @@
<?php
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
require_once('../core/email.class.inc.php');
/**
* Persistent classes (internal): user defined actions
*
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
require_once(APPROOT.'/core/asynctask.class.inc.php');
require_once(APPROOT.'/core/email.class.inc.php');
/**
* A user defined action, to customize the application
*
* @package iTopORM
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @author Denis Flaven <denisflave@free.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version 1.1.1.1 $
*/
abstract class Action extends cmdbAbstractObject
{
@@ -20,13 +39,10 @@ abstract class Action extends cmdbAbstractObject
$aParams = array
(
"category" => "core/cmdb",
"name" => "action",
"description" => "Custom action",
"key_type" => "autoincrement",
"key_label" => "",
"name_attcode" => "name",
"state_attcode" => "",
"reconc_keys" => array(),
"reconc_keys" => array('name'),
"db_table" => "priv_action",
"db_key_field" => "id",
"db_finalclass_field" => "realclass",
@@ -34,17 +50,13 @@ abstract class Action extends cmdbAbstractObject
);
MetaModel::Init_Params($aParams);
//MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeString("name", array("label"=>"Name", "description"=>"label", "allowed_values"=>null, "sql"=>"name", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("description", array("label"=>"Description", "description"=>"one line description", "allowed_values"=>null, "sql"=>"description", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeEnum("status", array("label"=>"Status", "description"=>"In production or ?", "allowed_values"=>new ValueSetEnum(array('test'=>'Being tested' ,'enabled'=>'In production', 'disabled'=>'Inactive')), "sql"=>"status", "default_value"=>"test", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeLinkedSetIndirect("related_triggers", array("label"=>"Related Triggers", "description"=>"Triggers linked to this action", "linked_class"=>"lnkTriggerAction", "ext_key_to_me"=>"action_id", "ext_key_to_remote"=>"trigger_id", "allowed_values"=>null, "count_min"=>0, "count_max"=>0, "depends_on"=>array())));
//MetaModel::Init_InheritFilters();
MetaModel::Init_AddFilterFromAttribute("name");
MetaModel::Init_AddFilterFromAttribute("description");
MetaModel::Init_AddAttribute(new AttributeString("name", array("allowed_values"=>null, "sql"=>"name", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("description", array("allowed_values"=>null, "sql"=>"description", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeEnum("status", array("allowed_values"=>new ValueSetEnum(array('test'=>'Being tested' ,'enabled'=>'In production', 'disabled'=>'Inactive')), "sql"=>"status", "default_value"=>"test", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeLinkedSetIndirect("trigger_list", array("linked_class"=>"lnkTriggerAction", "ext_key_to_me"=>"action_id", "ext_key_to_remote"=>"trigger_id", "allowed_values"=>null, "count_min"=>0, "count_max"=>0, "depends_on"=>array())));
// Display lists
MetaModel::Init_SetZListItems('details', array('name', 'description', 'status')); // Attributes to be displayed for the complete details
MetaModel::Init_SetZListItems('details', array('name', 'description', 'status', 'trigger_list')); // Attributes to be displayed for the complete details
MetaModel::Init_SetZListItems('list', array('finalclass', 'name', 'description', 'status')); // Attributes to be displayed for a list
// Search criteria
// MetaModel::Init_SetZListItems('standard_search', array('name')); // Criteria of the std search form
@@ -83,12 +95,6 @@ abstract class Action extends cmdbAbstractObject
* A notification
*
* @package iTopORM
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @author Denis Flaven <denisflave@free.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version 1.1.1.1 $
*/
abstract class ActionNotification extends Action
{
@@ -97,13 +103,10 @@ abstract class ActionNotification extends Action
$aParams = array
(
"category" => "core/cmdb",
"name" => "notification",
"description" => "Notification (abstract)",
"key_type" => "autoincrement",
"key_label" => "",
"name_attcode" => "name",
"state_attcode" => "",
"reconc_keys" => array(),
"reconc_keys" => array('name'),
"db_table" => "priv_action_notification",
"db_key_field" => "id",
"db_finalclass_field" => "",
@@ -112,10 +115,8 @@ abstract class ActionNotification extends Action
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();
MetaModel::Init_InheritFilters();
// Display lists
MetaModel::Init_SetZListItems('details', array('name', 'description', 'status')); // Attributes to be displayed for the complete details
MetaModel::Init_SetZListItems('details', array('name', 'description', 'status', 'trigger_list')); // Attributes to be displayed for the complete details
MetaModel::Init_SetZListItems('list', array('finalclass', 'name', 'description', 'status')); // Attributes to be displayed for a list
// Search criteria
// MetaModel::Init_SetZListItems('standard_search', array('name')); // Criteria of the std search form
@@ -127,12 +128,6 @@ abstract class ActionNotification extends Action
* An email notification
*
* @package iTopORM
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @author Denis Flaven <denisflave@free.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version 1.1.1.1 $
*/
class ActionEmail extends ActionNotification
{
@@ -140,14 +135,11 @@ class ActionEmail extends ActionNotification
{
$aParams = array
(
"category" => "core/cmdb",
"name" => "email notification",
"description" => "Action: Email notification",
"category" => "core/cmdb,bizmodel",
"key_type" => "autoincrement",
"key_label" => "",
"name_attcode" => "name",
"state_attcode" => "",
"reconc_keys" => array(),
"reconc_keys" => array('name'),
"db_table" => "priv_action_email",
"db_key_field" => "id",
"db_finalclass_field" => "",
@@ -156,24 +148,22 @@ class ActionEmail extends ActionNotification
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeEmailAddress("test_recipient", array("label"=>"Test recipient", "description"=>"Detination in case status is set to \"Test\"", "allowed_values"=>null, "sql"=>"test_recipient", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeEmailAddress("test_recipient", array("allowed_values"=>null, "sql"=>"test_recipient", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("from", array("label"=>"From", "description"=>"Will be sent into the email header", "allowed_values"=>null, "sql"=>"from", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("reply_to", array("label"=>"Reply to", "description"=>"Will be sent into the email header", "allowed_values"=>null, "sql"=>"reply_to", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeOQL("to", array("label"=>"To", "description"=>"Destination of the email", "allowed_values"=>null, "sql"=>"to", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeOQL("cc", array("label"=>"Cc", "description"=>"Carbon Copy", "allowed_values"=>null, "sql"=>"cc", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeOQL("bcc", array("label"=>"bcc", "description"=>"Blind Carbon Copy", "allowed_values"=>null, "sql"=>"bcc", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeTemplateString("subject", array("label"=>"subject", "description"=>"Title of the email", "allowed_values"=>null, "sql"=>"subject", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeTemplateText("body", array("label"=>"body", "description"=>"Contents of the email", "allowed_values"=>null, "sql"=>"body", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeEnum("importance", array("label"=>"importance", "description"=>"Importance flag", "allowed_values"=>new ValueSetEnum('low,normal,high'), "sql"=>"importance", "default_value"=>'normal', "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_InheritFilters();
MetaModel::Init_AddAttribute(new AttributeString("from", array("allowed_values"=>null, "sql"=>"from", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("reply_to", array("allowed_values"=>null, "sql"=>"reply_to", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeOQL("to", array("allowed_values"=>null, "sql"=>"to", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeOQL("cc", array("allowed_values"=>null, "sql"=>"cc", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeOQL("bcc", array("allowed_values"=>null, "sql"=>"bcc", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeTemplateString("subject", array("allowed_values"=>null, "sql"=>"subject", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeTemplateText("body", array("allowed_values"=>null, "sql"=>"body", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeEnum("importance", array("allowed_values"=>new ValueSetEnum('low,normal,high'), "sql"=>"importance", "default_value"=>'normal', "is_null_allowed"=>false, "depends_on"=>array())));
// Display lists
MetaModel::Init_SetZListItems('details', array('name', 'description', 'status', 'test_recipient', 'from', 'reply_to', 'to', 'cc', 'bcc', 'subject', 'body', 'importance')); // Attributes to be displayed for the complete details
MetaModel::Init_SetZListItems('details', array('name', 'description', 'status', 'test_recipient', 'from', 'reply_to', 'to', 'cc', 'bcc', 'subject', 'body', 'importance', 'trigger_list')); // Attributes to be displayed for the complete details
MetaModel::Init_SetZListItems('list', array('name', 'status', 'to', 'subject')); // Attributes to be displayed for a list
// Search criteria
// MetaModel::Init_SetZListItems('standard_search', array('name')); // Criteria of the std search form
MetaModel::Init_SetZListItems('standard_search', array('name','description', 'status', 'subject')); // Criteria of the std search form
// MetaModel::Init_SetZListItems('advanced_search', array('name')); // Criteria of the advanced search form
}
@@ -193,8 +183,9 @@ class ActionEmail extends ActionNotification
try
{
$oSearch = DBObjectSearch::FromOQL($sOQL);
$oSearch->AllowAllData();
}
catch (OqlException $e)
catch (OQLException $e)
{
$this->m_aMailErrors[] = "query syntax error for recipient '$sRecipAttCode'";
return $e->getMessage();
@@ -230,83 +221,161 @@ class ActionEmail extends ActionNotification
public function DoExecute($oTrigger, $aContextArgs)
{
$this->m_iRecipients = 0;
$this->m_aMailErrors = array();
$bRes = false; // until we do succeed in sending the email
try
{
// Determine recicipients
//
$sTo = $this->FindRecipients('to', $aContextArgs);
$sCC = $this->FindRecipients('cc', $aContextArgs);
$sBCC = $this->FindRecipients('bcc', $aContextArgs);
$sFrom = $this->Get('from');
$sReplyTo = $this->Get('reply_to');
$sSubject = MetaModel::ApplyParams($this->Get('subject'), $aContextArgs);
$sBody = MetaModel::ApplyParams($this->Get('body'), $aContextArgs);
$oEmail = new Email();
if ($this->IsBeingTested())
{
$oEmail->SetSubject('TEST['.$sSubject.']');
$sTestBody = $sBody;
$sTestBody .= "<div style=\"border: dashed;\">\n";
$sTestBody .= "<h1>Testing email notification ".$this->GetHyperlink()."</h1>\n";
$sTestBody .= "<p>The email should be sent with the following properties\n";
$sTestBody .= "<ul>\n";
$sTestBody .= "<li>TO: $sTo</li>\n";
$sTestBody .= "<li>CC: $sCC</li>\n";
$sTestBody .= "<li>BCC: $sBCC</li>\n";
$sTestBody .= "<li>From: $sFrom</li>\n";
$sTestBody .= "<li>Reply-To: $sReplyTo</li>\n";
$sTestBody .= "</ul>\n";
$sTestBody .= "</p>\n";
$sTestBody .= "</div>\n";
$oEmail->SetBody($sTestBody);
$oEmail->SetRecipientTO($this->Get('test_recipient'));
$oEmail->SetRecipientFrom($this->Get('test_recipient'));
}
else
{
$oEmail->SetSubject($sSubject);
$oEmail->SetBody($sBody);
$oEmail->SetRecipientTO($sTo);
$oEmail->SetRecipientCC($sCC);
$oEmail->SetRecipientBCC($sBCC);
$oEmail->SetRecipientFrom($sFrom);
$oEmail->SetRecipientReplyTo($sReplyTo);
}
if (empty($this->m_aMailErrors))
{
if ($this->m_iRecipients == 0)
{
$this->m_aMailErrors[] = 'No recipient';
}
else
{
$this->m_aMailErrors = array_merge($this->m_aMailErrors, $oEmail->Send());
}
}
}
catch (Exception $e)
{
$this->m_aMailErrors[] = $e->getMessage();
}
$oLog = new EventNotificationEmail();
if (empty($this->m_aMailErrors))
if (MetaModel::IsLogEnabledNotification())
{
$oLog = new EventNotificationEmail();
if ($this->IsBeingTested())
{
$oLog->Set('message', 'TEST - Notification sent ('.$this->Get('test_recipient').')');
}
else
{
$oLog->Set('message', 'Notification sent');
$oLog->Set('message', 'Notification pending');
}
$oLog->Set('userinfo', UserRights::GetUser());
$oLog->Set('trigger_id', $oTrigger->GetKey());
$oLog->Set('action_id', $this->GetKey());
$oLog->Set('object_id', $aContextArgs['this->object()']->GetKey());
// Must be inserted now so that it gets a valid id that will make the link
// between an eventual asynchronous task (queued) and the log
$oLog->DBInsertNoReload();
}
else
{
$oLog = null;
}
try
{
$sRes = $this->_DoExecute($oTrigger, $aContextArgs, $oLog);
if ($this->IsBeingTested())
{
$sPrefix = 'TEST ('.$this->Get('test_recipient').') - ';
}
else
{
$sPrefix = '';
}
$oLog->Set('message', $sPrefix.$sRes);
}
catch (Exception $e)
{
if ($oLog)
{
$oLog->Set('message', 'Error: '.$e->getMessage());
}
}
if ($oLog)
{
$oLog->DBUpdate();
}
}
protected function _DoExecute($oTrigger, $aContextArgs, &$oLog)
{
$sPreviousUrlMaker = ApplicationContext::SetUrlMakerClass();
$aHeaders = array();
try
{
$this->m_iRecipients = 0;
$this->m_aMailErrors = array();
$bRes = false; // until we do succeed in sending the email
// Determine recicipients
//
$sTo = $this->FindRecipients('to', $aContextArgs);
$sCC = $this->FindRecipients('cc', $aContextArgs);
$sBCC = $this->FindRecipients('bcc', $aContextArgs);
$sFrom = $this->Get('from');
$sReplyTo = $this->Get('reply_to');
$sSubject = MetaModel::ApplyParams($this->Get('subject'), $aContextArgs);
$sBody = MetaModel::ApplyParams($this->Get('body'), $aContextArgs);
$oObj = $aContextArgs['this->object()'];
$sMessageId = sprintf('<iTop_%s_%d_%f@%s.openitop.org>', get_class($oObj), $oObj->GetKey(), microtime(true /* get as float*/), MetaModel::GetConfig()->Get('session_name'));
$sReference = $sMessageId;
$aHeaders['Message-ID'] = $sMessageId;
}
catch(Exception $e)
{
ApplicationContext::SetUrlMakerClass($sPreviousUrlMaker);
throw $e;
}
ApplicationContext::SetUrlMakerClass($sPreviousUrlMaker);
if (!is_null($oLog))
{
// Note: we have to secure this because those values are calculated
// inside the try statement, and we would like to keep track of as
// many data as we could while some variables may still be undefined
if (isset($sTo)) $oLog->Set('to', $sTo);
if (isset($sCC)) $oLog->Set('cc', $sCC);
if (isset($sBCC)) $oLog->Set('bcc', $sBCC);
if (isset($sFrom)) $oLog->Set('from', $sFrom);
if (isset($sSubject)) $oLog->Set('subject', $sSubject);
if (isset($sBody)) $oLog->Set('body', $sBody);
}
$oEmail = new EMail('', '', '', $aHeaders);
if ($this->IsBeingTested())
{
$oEmail->SetSubject('TEST['.$sSubject.']');
$sTestBody = $sBody;
$sTestBody .= "<div style=\"border: dashed;\">\n";
$sTestBody .= "<h1>Testing email notification ".$this->GetHyperlink()."</h1>\n";
$sTestBody .= "<p>The email should be sent with the following properties\n";
$sTestBody .= "<ul>\n";
$sTestBody .= "<li>TO: $sTo</li>\n";
$sTestBody .= "<li>CC: $sCC</li>\n";
$sTestBody .= "<li>BCC: $sBCC</li>\n";
$sTestBody .= "<li>From: $sFrom</li>\n";
$sTestBody .= "<li>Reply-To: $sReplyTo</li>\n";
$sTestBody .= "<li>References: $sReference</li>\n";
$sTestBody .= "</ul>\n";
$sTestBody .= "</p>\n";
$sTestBody .= "</div>\n";
$oEmail->SetBody($sTestBody);
$oEmail->SetRecipientTO($this->Get('test_recipient'));
$oEmail->SetRecipientFrom($this->Get('test_recipient'));
$oEmail->SetReferences($sReference);
}
else
{
$oEmail->SetSubject($sSubject);
$oEmail->SetBody($sBody);
$oEmail->SetRecipientTO($sTo);
$oEmail->SetRecipientCC($sCC);
$oEmail->SetRecipientBCC($sBCC);
$oEmail->SetRecipientFrom($sFrom);
$oEmail->SetRecipientReplyTo($sReplyTo);
$oEmail->SetReferences($sReference);
}
if (empty($this->m_aMailErrors))
{
if ($this->m_iRecipients == 0)
{
return 'No recipient';
}
else
{
$iRes = $oEmail->Send($aErrors, false, $oLog); // allow asynchronous mode
switch ($iRes)
{
case EMAIL_SEND_OK:
return "Sent";
case EMAIL_SEND_PENDING:
return "Pending";
case EMAIL_SEND_ERROR:
return "Errors: ".implode(', ', $aErrors);
}
}
}
else
@@ -319,31 +388,8 @@ class ActionEmail extends ActionNotification
{
$sError = 'Unknown reason';
}
if ($this->IsBeingTested())
{
$oLog->Set('message', 'TEST - Notification was not sent: '.$sError);
}
else
{
$oLog->Set('message', 'Notification was not sent: '.$sError);
}
return 'Notification was not sent: '.$sError;
}
$oLog->Set('userinfo', UserRights::GetUser());
$oLog->Set('trigger_id', $oTrigger->GetKey());
$oLog->Set('action_id', $this->GetKey());
$oLog->Set('object_id', $aContextArgs['this->id']);
// Note: we have to secure this because those values are calculated
// inside the try statement, and we would like to keep track of as
// many data as we could while some variables may still be undefined
if (isset($sTo)) $oLog->Set('to', $sTo);
if (isset($sCC)) $oLog->Set('cc', $sCC);
if (isset($sBCC)) $oLog->Set('bcc', $sBCC);
if (isset($sFrom)) $oLog->Set('from', $sFrom);
if (isset($sSubject)) $oLog->Set('subject', $sSubject);
if (isset($sBody)) $oLog->Set('body', $sBody);
$oLog->DBInsertNoReload();
}
}
?>
?>

View File

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

View File

@@ -0,0 +1,192 @@
<?php
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* Persistent classes (internal): user defined actions
*
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
class ExecAsyncTask implements iBackgroundProcess
{
public function GetPeriodicity()
{
return 2; // seconds
}
public function Process($iTimeLimit)
{
$sOQL = "SELECT AsyncTask WHERE ISNULL(started) AND (ISNULL(planned) OR (planned < NOW()))";
$oSet = new CMDBObjectSet(DBObjectSearch::FromOQL($sOQL), array('created' => true) /* order by*/, array());
$iProcessed = 0;
while ((time() < $iTimeLimit) && ($oTask = $oSet->Fetch()))
{
$oTask->Set('started', time());
$oTask->DBUpdate();
$oTask->Process();
$iProcessed++;
$oTask->DBDelete();
}
if ($iProcessed == $oSet->Count())
{
return "processed $iProcessed tasks";
}
else
{
return "processed $iProcessed tasks (remaining: ".($oSet->Count() - $iProcessed).")";
}
}
}
/**
* A
*
* @package iTopORM
*/
abstract class AsyncTask extends DBObject
{
public static function Init()
{
$aParams = array
(
"category" => "core/cmdb",
"key_type" => "autoincrement",
"name_attcode" => array('created'),
"state_attcode" => "",
"reconc_keys" => array(),
"db_table" => "priv_async_task",
"db_key_field" => "id",
"db_finalclass_field" => "realclass",
"display_template" => "",
);
MetaModel::Init_Params($aParams);
//MetaModel::Init_InheritAttributes();
// MetaModel::Init_AddAttribute(new AttributeString("name", array("allowed_values"=>null, "sql"=>"name", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeDateTime("created", array("allowed_values"=>null, "sql"=>"created", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeDateTime("started", array("allowed_values"=>null, "sql"=>"started", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
// planned... still not used - reserved for timer management
MetaModel::Init_AddAttribute(new AttributeDateTime("planned", array("allowed_values"=>null, "sql"=>"planned", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalKey("event_id", array("targetclass"=>"Event", "jointype"=> "", "allowed_values"=>null, "sql"=>"event_id", "is_null_allowed"=>true, "on_target_delete"=>DEL_SILENT, "depends_on"=>array())));
// Display lists
// MetaModel::Init_SetZListItems('details', array()); // Attributes to be displayed for the complete details
// MetaModel::Init_SetZListItems('list', array()); // Attributes to be displayed for a list
// Search criteria
// MetaModel::Init_SetZListItems('standard_search', array('name')); // Criteria of the std search form
// MetaModel::Init_SetZListItems('advanced_search', array('name')); // Criteria of the advanced search form
}
protected function OnInsert()
{
$this->Set('created', time());
}
public function Process()
{
$sStatus = $this->DoProcess();
if ($this->Get('event_id') != 0)
{
$oEventLog = MetaModel::GetObject('Event', $this->Get('event_id'));
$oEventLog->Set('message', $sStatus);
$oEventLog->DBUpdate();
}
}
abstract public function DoProcess();
}
/**
* An email notification
*
* @package iTopORM
*/
class AsyncSendEmail extends AsyncTask
{
public static function Init()
{
$aParams = array
(
"category" => "core/cmdb",
"key_type" => "autoincrement",
"name_attcode" => "created",
"state_attcode" => "",
"reconc_keys" => array(),
"db_table" => "priv_async_send_email",
"db_key_field" => "id",
"db_finalclass_field" => "",
"display_template" => "",
);
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeText("to", array("allowed_values"=>null, "sql"=>"to", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("subject", array("allowed_values"=>null, "sql"=>"subject", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeLongText("body", array("allowed_values"=>null, "sql"=>"body", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("header", array("allowed_values"=>null, "sql"=>"header", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
// Display lists
// MetaModel::Init_SetZListItems('details', array('name', 'description', 'status', 'test_recipient', 'from', 'reply_to', 'to', 'cc', 'bcc', 'subject', 'body', 'importance', 'trigger_list')); // Attributes to be displayed for the complete details
// MetaModel::Init_SetZListItems('list', array('name', 'status', 'to', 'subject')); // Attributes to be displayed for a list
// Search criteria
// MetaModel::Init_SetZListItems('standard_search', array('name')); // Criteria of the std search form
// MetaModel::Init_SetZListItems('advanced_search', array('name')); // Criteria of the advanced search form
}
static public function AddToQueue($sTo, $sSubject, $sBody, $aHeaders, $oLog)
{
$oNew = MetaModel::NewObject(__class__);
if ($oLog)
{
$oNew->Set('event_id', $oLog->GetKey());
}
$oNew->Set('to', $sTo);
$oNew->Set('subject', $sSubject);
$oNew->Set('body', $sBody);
$sHeaders = serialize($aHeaders);
$oNew->Set('header', $sHeaders);
$oNew->DBInsert();
}
public function DoProcess()
{
$sTo = $this->Get('to');
$sSubject = $this->Get('subject');
$sBody = $this->Get('body');
$sHeaders = $this->Get('header');
$aHeaders = unserialize($sHeaders);
$oEmail = new EMail($sTo, $sSubject, $sBody, $aHeaders);
$iRes = $oEmail->Send($aIssues, true /* force synchro !!!!! */);
switch ($iRes)
{
case EMAIL_SEND_OK:
return "Sent";
case EMAIL_SEND_PENDING:
return "Bug - the email should be sent in synchronous mode";
case EMAIL_SEND_ERROR:
return "Failed: ".implode(', ', $aIssues);
}
}
}
?>

File diff suppressed because it is too large Load Diff

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

@@ -1,21 +1,43 @@
<?php
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* Class cmdbObject
*
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
/**
* cmdbObjectClass
* the file to include, then the core is yours
*
* @package iTopORM
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @author Denis Flaven <denisflave@free.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version 1.1.1.1 $
*/
require_once('coreexception.class.inc.php');
require_once('config.class.inc.php');
require_once('log.class.inc.php');
require_once('kpi.class.inc.php');
require_once('dict.class.inc.php');
require_once('attributedef.class.inc.php');
require_once('filterdef.class.inc.php');
@@ -37,6 +59,10 @@ require_once('dbobject.class.php');
require_once('dbobjectsearch.class.php');
require_once('dbobjectset.class.php');
require_once('backgroundprocess.inc.php');
require_once('asynctask.class.inc.php');
require_once('dbproperty.class.inc.php');
// db change tracking data model
require_once('cmdbchange.class.inc.php');
require_once('cmdbchangeop.class.inc.php');
@@ -50,104 +76,40 @@ require_once('cmdbchangeop.class.inc.php');
// Romain: temporary moved into application.inc.php (see explanations there)
//require_once('event.class.inc.php');
require_once('templatestring.class.inc.php');
require_once('csvparser.class.inc.php');
require_once('bulkchange.class.inc.php');
require_once('userrights.class.inc.php');
//
// Error handling
// To be finalized... or removed ?
//
function cmdbErrorHandler($errno, $errstr, $errfile, $errline)
{
// font-family: Courier-New, Courier, Arial, Helevtica;
$sErrorStyle = "
background-color: #ffaaaa;
color: #000000;
border: 1px dashed #000000;
padding: 0.25em;
margin-top: 1em;
";
$sCallStackStyle = "
font-size: smaller;
background-color: #ffcccc;
color: #000000;
border: 1px dashed #000000;
padding: 0.25em;
margin-top: 1em;
";
switch ($errno)
{
case E_USER_ERROR:
case E_ERROR:
echo "<div style=\"$sErrorStyle\">\n";
echo "<b>Error</b> [$errno] $errstr<br />\n";
echo "<div style=\"$sCallStackStyle\">\n";
MyHelpers::dump_callstack(1);
echo "</div>\n";
echo "Hereafter the biz model internals:<br />\n";
echo "<pre>\n";
MetaModel::static_var_dump();
echo "</pre>\n";
echo "Aborting...<br />\n";
echo "</div>\n";
exit(1);
break;
case E_USER_WARNING:
case E_WARNING:
echo "<div style=\"background-color:#FAA;\">\n";
echo "<b>Warning</b> [$errno] $errstr<br />\n";
echo "<div style=\"background-color:#FCC;\">\n";
MyHelpers::dump_callstack(1);
echo "</div>\n";
echo "</div>\n";
break;
case E_USER_NOTICE:
case E_NOTICE:
echo "<div style=\"background-color:#FAA;\">\n";
echo "<b>Notice</b> [$errno] $errstr<br />\n";
echo "<div style=\"background-color:#FCC;\">\n";
MyHelpers::dump_callstack(1);
echo "</div>\n";
echo "</div>\n";
break;
default:
echo "Unknown error type: [$errno] $errstr<br />\n";
MyHelpers::dump_callstack(1);
break;
}
}
error_reporting(E_ALL | E_STRICT);
//set_error_handler("cmdbErrorHandler");
//
//
//
/**
* A persistent object, which changes are accurately recorded
*
* @package iTopORM
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @author Denis Flaven <denisflave@free.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version 1.1.1.1 $
*/
abstract class CMDBObject extends DBObject
{
protected $m_datCreated;
protected $m_datUpdated;
// Note: this value is static, but that could be changed because it is sometimes a real issue (see update of interfaces / connected_to
protected static $m_oCurrChange = null;
public static function SetCurrentChange(CMDBChange $oChange)
{
self::$m_oCurrChange = $oChange;
}
//
// Todo: simplify the APIs and do not pass the current change as an argument anymore
// SetCurrentChange to be invoked in very few cases (UI.php, CSV import, Data synchro)
// GetCurrentChange to be called ONCE (!) by CMDBChangeOp::OnInsert ($this->Set('change', ..GetCurrentChange())
// GetCurrentChange to create a default change if not already done in the current context
//
public static function GetCurrentChange()
{
return self::$m_oCurrChange;
}
private function RecordObjCreation(CMDBChange $oChange)
{
$oMyChangeOp = MetaModel::NewObject("CMDBChangeOpCreate");
@@ -173,7 +135,47 @@ abstract class CMDBObject extends DBObject
$oAttDef = MetaModel::GetAttributeDef(get_class($this), $sAttCode);
if ($oAttDef->IsLinkSet()) continue; // #@# temporary
if ($oAttDef instanceOf AttributeBlob)
if ($oAttDef instanceOf AttributeOneWayPassword)
{
// One Way encrypted passwords' history is stored -one way- encrypted
$oMyChangeOp = MetaModel::NewObject("CMDBChangeOpSetAttributeOneWayPassword");
$oMyChangeOp->Set("change", $oChange->GetKey());
$oMyChangeOp->Set("objclass", get_class($this));
$oMyChangeOp->Set("objkey", $this->GetKey());
$oMyChangeOp->Set("attcode", $sAttCode);
if (array_key_exists($sAttCode, $aOrigValues))
{
$original = $aOrigValues[$sAttCode];
}
else
{
$original = '';
}
$oMyChangeOp->Set("prev_pwd", $original);
$iId = $oMyChangeOp->DBInsertNoReload();
}
elseif ($oAttDef instanceOf AttributeEncryptedString)
{
// Encrypted string history is stored encrypted
$oMyChangeOp = MetaModel::NewObject("CMDBChangeOpSetAttributeEncrypted");
$oMyChangeOp->Set("change", $oChange->GetKey());
$oMyChangeOp->Set("objclass", get_class($this));
$oMyChangeOp->Set("objkey", $this->GetKey());
$oMyChangeOp->Set("attcode", $sAttCode);
if (array_key_exists($sAttCode, $aOrigValues))
{
$original = $aOrigValues[$sAttCode];
}
else
{
$original = '';
}
$oMyChangeOp->Set("prevstring", $original);
$iId = $oMyChangeOp->DBInsertNoReload();
}
elseif ($oAttDef instanceOf AttributeBlob)
{
// Data blobs
$oMyChangeOp = MetaModel::NewObject("CMDBChangeOpSetAttributeBlob");
@@ -193,6 +195,17 @@ abstract class CMDBObject extends DBObject
$oMyChangeOp->Set("prevdata", $original);
$iId = $oMyChangeOp->DBInsertNoReload();
}
elseif ($oAttDef instanceOf AttributeCaseLog)
{
$oMyChangeOp = MetaModel::NewObject("CMDBChangeOpSetAttributeCaseLog");
$oMyChangeOp->Set("change", $oChange->GetKey());
$oMyChangeOp->Set("objclass", get_class($this));
$oMyChangeOp->Set("objkey", $this->GetKey());
$oMyChangeOp->Set("attcode", $sAttCode);
$oMyChangeOp->Set("lastentry", $value->GetLatestEntryIndex());
$iId = $oMyChangeOp->DBInsertNoReload();
}
elseif ($oAttDef instanceOf AttributeText)
{
// Data blobs
@@ -205,6 +218,10 @@ abstract class CMDBObject extends DBObject
if (array_key_exists($sAttCode, $aOrigValues))
{
$original = $aOrigValues[$sAttCode];
if ($original instanceof ormCaseLog)
{
$original = $original->GetText();
}
}
else
{
@@ -238,6 +255,35 @@ abstract class CMDBObject extends DBObject
}
}
/**
* Helper to ultimately check user rights before writing (Insert, Update or Delete)
* The check should never fail, because the UI should prevent from such a usage
* Anyhow, if the user has found a workaround... the security gets enforced here
*/
protected function CheckUserRights($bSkipStrongSecurity, $iActionCode)
{
if (is_null($bSkipStrongSecurity))
{
// This is temporary
// We have implemented this safety net right before releasing iTop 1.0
// and we decided that it was too risky to activate it
// Anyhow, users willing to have a very strong security could set
// skip_strong_security = 0, in the config file
$bSkipStrongSecurity = MetaModel::GetConfig()->Get('skip_strong_security');
}
if (!$bSkipStrongSecurity)
{
$sClass = get_class($this);
$oSet = DBObjectSet::FromObject($this);
if (!UserRights::IsActionAllowed($sClass, $iActionCode, $oSet))
{
// Intrusion detected
throw new SecurityException('You are not allowed to modify objects of class: '.$sClass);
}
}
}
public function DBInsert()
{
if(!is_object(self::$m_oCurrChange))
@@ -247,19 +293,25 @@ abstract class CMDBObject extends DBObject
return $this->DBInsertTracked_Internal();
}
public function DBInsertTracked(CMDBChange $oChange)
public function DBInsertTracked(CMDBChange $oChange, $bSkipStrongSecurity = null)
{
$this->CheckUserRights($bSkipStrongSecurity, UR_ACTION_MODIFY);
$oPreviousChange = self::$m_oCurrChange;
self::$m_oCurrChange = $oChange;
$ret = $this->DBInsertTracked_Internal();
self::$m_oCurrChange = null;
self::$m_oCurrChange = $oPreviousChange;
return $ret;
}
public function DBInsertTrackedNoReload(CMDBChange $oChange)
public function DBInsertTrackedNoReload(CMDBChange $oChange, $bSkipStrongSecurity = null)
{
$this->CheckUserRights($bSkipStrongSecurity, UR_ACTION_MODIFY);
$oPreviousChange = self::$m_oCurrChange;
self::$m_oCurrChange = $oChange;
$ret = $this->DBInsertTracked_Internal(true);
self::$m_oCurrChange = null;
self::$m_oCurrChange = $oPreviousChange;
return $ret;
}
@@ -288,9 +340,10 @@ abstract class CMDBObject extends DBObject
public function DBCloneTracked(CMDBChange $oChange, $newKey = null)
{
$oPreviousChange = self::$m_oCurrChange;
self::$m_oCurrChange = $oChange;
$this->DBCloneTracked_Internal($newKey);
self::$m_oCurrChange = null;
self::$m_oCurrChange = $oPreviousChange;
}
protected function DBCloneTracked_Internal($newKey = null)
@@ -311,11 +364,14 @@ abstract class CMDBObject extends DBObject
return $this->DBUpdateTracked_internal();
}
public function DBUpdateTracked(CMDBChange $oChange)
public function DBUpdateTracked(CMDBChange $oChange, $bSkipStrongSecurity = null)
{
$this->CheckUserRights($bSkipStrongSecurity, UR_ACTION_MODIFY);
$oPreviousChange = self::$m_oCurrChange;
self::$m_oCurrChange = $oChange;
$this->DBUpdateTracked_Internal();
self::$m_oCurrChange = null;
self::$m_oCurrChange = $oPreviousChange;
}
protected function DBUpdateTracked_Internal()
@@ -324,7 +380,7 @@ abstract class CMDBObject extends DBObject
$aChanges = $this->ListChanges();
if (count($aChanges) == 0)
{
throw new CoreWarning("Attempting to update an unchanged object");
//throw new CoreWarning("Attempting to update an unchanged object");
return;
}
@@ -335,26 +391,29 @@ abstract class CMDBObject extends DBObject
return $ret;
}
public function DBDelete()
public function DBDelete(&$oDeletionPlan = null)
{
if(!self::$m_oCurrChange)
{
throw new CoreException("DBDelete() could not be used here, please use DBDeleteTracked() instead");
}
return $this->DBDeleteTracked_Internal();
return $this->DBDeleteTracked_Internal($oDeletionPlan);
}
public function DBDeleteTracked(CMDBChange $oChange)
public function DBDeleteTracked(CMDBChange $oChange, $bSkipStrongSecurity = null, &$oDeletionPlan = null)
{
$this->CheckUserRights($bSkipStrongSecurity, UR_ACTION_DELETE);
$oPreviousChange = self::$m_oCurrChange;
self::$m_oCurrChange = $oChange;
$this->DBDeleteTracked_Internal();
self::$m_oCurrChange = null;
$this->DBDeleteTracked_Internal($oDeletionPlan);
self::$m_oCurrChange = $oPreviousChange;
}
protected function DBDeleteTracked_Internal()
protected function DBDeleteTracked_Internal(&$oDeletionPlan = null)
{
$prevkey = $this->GetKey();
$ret = parent::DBDelete();
$ret = parent::DBDelete($oDeletionPlan);
$this->RecordObjDeletion(self::$m_oCurrChange, $prevkey);
return $ret;
}
@@ -370,9 +429,10 @@ abstract class CMDBObject extends DBObject
public static function BulkDeleteTracked(CMDBChange $oChange, DBObjectSearch $oFilter)
{
$oPreviousChange = self::$m_oCurrChange;
self::$m_oCurrChange = $oChange;
$this->BulkDeleteTracked_Internal($oFilter);
self::$m_oCurrChange = null;
self::$m_oCurrChange = $oPreviousChange;
}
protected static function BulkDeleteTracked_Internal(DBObjectSearch $oFilter)
@@ -381,7 +441,7 @@ abstract class CMDBObject extends DBObject
// Get the list of objects to delete (and record data before deleting the DB records)
$oObjSet = new CMDBObjectSet($oFilter);
$aObjAndKeys = array(); // array of pkey=>object
$aObjAndKeys = array(); // array of id=>object
while ($oItem = $oObjSet->Fetch())
{
$aObjAndKeys[$oItem->GetKey()] = $oItem;
@@ -409,9 +469,10 @@ abstract class CMDBObject extends DBObject
public static function BulkUpdateTracked(CMDBChange $oChange, DBObjectSearch $oFilter, array $aValues)
{
$oPreviousChange = self::$m_oCurrChange;
self::$m_oCurrChange = $oChange;
$this->BulkUpdateTracked_Internal($oFilter, $aValues);
self::$m_oCurrChange = null;
self::$m_oCurrChange = $oPreviousChange;
}
protected static function BulkUpdateTracked_Internal(DBObjectSearch $oFilter, array $aValues)
@@ -450,12 +511,6 @@ abstract class CMDBObject extends DBObject
* TODO: investigate how to get rid of this class that was made to workaround some language limitation... or a poor design!
*
* @package iTopORM
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @author Denis Flaven <denisflave@free.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version 1.1.1.1 $
*/
class CMDBObjectSet extends DBObjectSet
{
@@ -468,36 +523,46 @@ class CMDBObjectSet extends DBObjectSet
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 !!!!!
$oFilter->AddConditionExpression(new FalseExpression());
$oRetSet = new self($oFilter);
// NOTE: THIS DOES NOT WORK IF m_bLoaded is private in the base class (and you will not get any error message)
$oRetSet->m_bLoaded = true; // no DB load
return $oRetSet;
}
// create an object set ex nihilo
// input = array of objects
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);
$oRetSet = self::FromScratch($sClass);
$oRetSet->AddObjectArray($aObjects, $sClass);
return $oRetSet;
}
static public function FromArrayAssoc($aClasses, $aObjects)
{
// In a perfect world, we should create a complete tree of DBObjectSearch,
// but as we lack most of the information related to the objects,
// let's create one search definition
$sClass = reset($aClasses);
$sAlias = key($aClasses);
$oFilter = new CMDBSearchFilter($sClass, $sAlias);
$oRetSet = new CMDBObjectSet($oFilter);
$oRetSet->m_bLoaded = true; // no DB load
foreach($aObjects as $rowIndex => $aObjectsByClassAlias)
{
$oRetSet->AddObjectExtended($aObjectsByClassAlias);
}
return $oRetSet;
}
}
/**
* TODO: investigate how to get rid of this class that was made to workaround some language limitation... or a poor design!
*
* @package iTopORM
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @author Denis Flaven <denisflave@free.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version 1.1.1.1 $
*/
class CMDBSearchFilter extends DBObjectSearch
{

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,35 +1,59 @@
<?php
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* Object set management
*
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
/**
* A set of persistent objects, could be heterogeneous
*
* @package iTopORM
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @author Denis Flaven <denisflave@free.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version 1.1.1.1 $
*/
class DBObjectSet
{
private $m_oFilter;
private $m_aAddedIds; // Ids of objects added (discrete lists)
private $m_aOrderBy;
public $m_bLoaded;
private $m_aData;
private $m_aId2Row;
private $m_iCurrRow;
public function __construct(DBObjectSearch $oFilter, $aOrderBy = array(), $aArgs = array())
public function __construct(DBObjectSearch $oFilter, $aOrderBy = array(), $aArgs = array(), $aExtendedDataSpec = null, $iLimitCount = 0, $iLimitStart = 0)
{
$this->m_oFilter = $oFilter;
$this->m_aAddedIds = array();
$this->m_aOrderBy = $aOrderBy;
$this->m_aArgs = $aArgs;
$this->m_aAttToLoad = null;
$this->m_aExtendedDataSpec = $aExtendedDataSpec;
$this->m_iLimitCount = $iLimitCount;
$this->m_iLimitStart = $iLimitStart;
$this->m_bLoaded = false;
$this->m_aData = array();
$this->m_aId2Row = array();
$this->m_iCount = null; // null if unknown yet
$this->m_bLoaded = false; // true when the filter has been used OR the set is built step by step (AddObject...)
$this->m_aData = array(); // array of (row => array of (classalias) => object/null)
$this->m_aId2Row = array(); // array of (pkey => index in m_aData)
$this->m_iCurrRow = 0;
}
@@ -41,7 +65,7 @@ class DBObjectSet
{
$sRet = '';
$this->Rewind();
$sRet .= "Set (".$this->m_oFilter->ToSibuSQL().")<br/>\n";
$sRet .= "Set (".$this->m_oFilter->ToOQL().")<br/>\n";
$sRet .= "Query: <pre style=\"font-size: smaller; display:inline;\">".MetaModel::MakeSelectQuery($this->m_oFilter, array()).")</pre>\n";
$sRet .= $this->Count()." records<br/>\n";
@@ -57,6 +81,46 @@ class DBObjectSet
return $sRet;
}
public function OptimizeColumnLoad($aAttToLoad)
{
if (is_null($aAttToLoad))
{
$this->m_aAttToLoad = null;
}
else
{
// Complete the attribute list with the attribute codes
$aAttToLoadWithAttDef = array();
foreach($aAttToLoad as $sClassAlias => $aAttList)
{
$aSelectedClasses = $this->m_oFilter->GetSelectedClasses();
$sClass = $aSelectedClasses[$sClassAlias];
foreach($aAttList as $sAttToLoad)
{
$oAttDef = MetaModel::GetAttributeDef($sClass, $sAttToLoad);
$aAttToLoadWithAttDef[$sClassAlias][$sAttToLoad] = $oAttDef;
if ($oAttDef->IsExternalKey())
{
// Add the external key friendly name anytime
$oFriendlyNameAttDef = MetaModel::GetAttributeDef($sClass, $sAttToLoad.'_friendlyname');
$aAttToLoadWithAttDef[$sClassAlias][$sAttToLoad.'_friendlyname'] = $oFriendlyNameAttDef;
}
}
// Add the friendly name anytime
$oFriendlyNameAttDef = MetaModel::GetAttributeDef($sClass, 'friendlyname');
$aAttToLoadWithAttDef[$sClassAlias]['friendlyname'] = $oFriendlyNameAttDef;
// Make sure that the final class is requested anytime, whatever the specification (needed for object construction!)
if (!MetaModel::IsStandaloneClass($sClass) && !array_key_exists('finalclass', $aAttList))
{
$aAttToLoadWithAttDef[$sClassAlias]['finalclass'] = MetaModel::GetAttributeDef($sClass, 'finalclass');
}
}
$this->m_aAttToLoad = $aAttToLoadWithAttDef;
}
}
static public function FromObject($oObject)
{
$oRetSet = self::FromScratch(get_class($oObject));
@@ -66,21 +130,60 @@ class DBObjectSet
static public function FromScratch($sClass)
{
$oFilter = new CMDBSearchFilter($sClass);
$oFilter = new DBObjectSearch($sClass);
$oFilter->AddConditionExpression(new FalseExpression());
$oRetSet = new self($oFilter);
$oRetSet->m_bLoaded = true; // no DB load
return $oRetSet;
}
// create an object set ex nihilo
// input = array of objects
static public function FromArray($sClass, $aObjects)
{
$oFilter = new CMDBSearchFilter($sClass);
$oRetSet = self::FromScratch($sClass);
$oRetSet->AddObjectArray($aObjects, $sClass);
return $oRetSet;
}
// create an object set ex nihilo
// aClasses = array of (alias => class)
// input = array of (array of (classalias => object))
static public function FromArrayAssoc($aClasses, $aObjects)
{
// In a perfect world, we should create a complete tree of DBObjectSearch,
// but as we lack most of the information related to the objects,
// let's create one search definition
$sClass = reset($aClasses);
$sAlias = key($aClasses);
$oFilter = new CMDBSearchFilter($sClass, $sAlias);
$oRetSet = new self($oFilter);
$oRetSet->m_bLoaded = true; // no DB load
$oRetSet->AddObjectArray($aObjects);
foreach($aObjects as $rowIndex => $aObjectsByClassAlias)
{
$oRetSet->AddObjectExtended($aObjectsByClassAlias);
}
return $oRetSet;
}
static public function FromLinkSet($oObject, $sLinkSetAttCode, $sExtKeyToRemote)
{
$oLinkAttCode = MetaModel::GetAttributeDef(get_class($oObject), $sLinkSetAttCode);
$oExtKeyAttDef = MetaModel::GetAttributeDef($oLinkAttCode->GetLinkedClass(), $sExtKeyToRemote);
$sTargetClass = $oExtKeyAttDef->GetTargetClass();
$oLinkSet = $oObject->Get($sLinkSetAttCode);
$aTargets = array();
while ($oLink = $oLinkSet->Fetch())
{
$aTargets[] = MetaModel::GetObject($sTargetClass, $oLink->Get($sExtKeyToRemote));
}
return self::FromArray($sTargetClass, $aTargets);
}
public function ToArray($bWithId = true)
{
$aRet = array();
@@ -99,6 +202,53 @@ class DBObjectSet
return $aRet;
}
public function ToArrayOfValues()
{
if (!$this->m_bLoaded) $this->Load();
$aSelectedClasses = $this->m_oFilter->GetSelectedClasses();
$aRet = array();
foreach($this->m_aData as $iRow => $aObjects)
{
foreach($aObjects as $sClassAlias => $oObject)
{
if (is_null($oObject))
{
$aRet[$iRow][$sClassAlias.'.'.'id'] = null;
}
else
{
$aRet[$iRow][$sClassAlias.'.'.'id'] = $oObject->GetKey();
}
if (is_null($oObject))
{
$sClass = $aSelectedClasses[$sClassAlias];
}
else
{
$sClass = get_class($oObject);
}
foreach(MetaModel::ListAttributeDefs($sClass) as $sAttCode => $oAttDef)
{
if ($oAttDef->IsScalar())
{
$sAttName = $sClassAlias.'.'.$sAttCode;
if (is_null($oObject))
{
$aRet[$iRow][$sAttName] = null;
}
else
{
$aRet[$iRow][$sAttName] = $oObject->Get($sAttCode);
}
}
}
}
}
return $aRet;
}
public function GetColumnAsArray($sAttCode, $bWithId = true)
{
$aRet = array();
@@ -119,7 +269,20 @@ class DBObjectSet
public function GetFilter()
{
return $this->m_oFilter;
if (count($this->m_aAddedIds) == 0)
{
return $this->m_oFilter;
}
else
{
$oFilter = clone $this->m_oFilter;
$oIdListExpr = ListExpression::FromScalars(array_keys($this->m_aAddedIds));
$oIdExpr = new FieldExpression('id', $oFilter->GetClassAlias());
$oIdInList = new BinaryExpression($oIdExpr, 'IN', $oIdListExpr);
$oFilter->MergeConditionExpression($oIdInList);
return $oFilter;
}
}
public function GetClass()
@@ -127,37 +290,99 @@ class DBObjectSet
return $this->m_oFilter->GetClass();
}
public function GetSelectedClasses()
{
return $this->m_oFilter->GetSelectedClasses();
}
public function GetRootClass()
{
return MetaModel::GetRootClass($this->GetClass());
}
public function GetArgs()
{
return $this->m_aArgs;
}
public function SetLimit($iLimitCount, $iLimitStart = 0)
{
$this->m_iLimitCount = $iLimitCount;
$this->m_iLimitStart = $iLimitStart;
}
public function GetLimitCount()
{
return $this->m_iLimitCount;
}
public function GetLimitStart()
{
return $this->m_iLimitStart;
}
public function Load()
{
if ($this->m_bLoaded) return;
// Note: it is mandatory to set this value now, to protect against reentrance
$this->m_bLoaded = true;
$sSQL = MetaModel::MakeSelectQuery($this->m_oFilter, $this->m_aOrderBy, $this->m_aArgs);
if ($this->m_iLimitCount > 0)
{
$sSQL = MetaModel::MakeSelectQuery($this->m_oFilter, $this->m_aOrderBy, $this->m_aArgs, $this->m_aAttToLoad, $this->m_aExtendedDataSpec, $this->m_iLimitCount, $this->m_iLimitStart);
}
else
{
$sSQL = MetaModel::MakeSelectQuery($this->m_oFilter, $this->m_aOrderBy, $this->m_aArgs, $this->m_aAttToLoad, $this->m_aExtendedDataSpec);
}
$resQuery = CMDBSource::Query($sSQL);
if (!$resQuery) return;
$sClass = $this->m_oFilter->GetClass();
while ($aRow = CMDBSource::FetchArray($resQuery))
{
$sClass = $this->m_oFilter->GetClass();
$oObject = MetaModel::GetObjectByRow($sClass, $aRow);
$this->AddObject($oObject);
$aObjects = array();
foreach ($this->m_oFilter->GetSelectedClasses() as $sClassAlias => $sClass)
{
if (is_null($aRow[$sClassAlias.'id']))
{
$oObject = null;
}
else
{
$oObject = MetaModel::GetObjectByRow($sClass, $aRow, $sClassAlias, $this->m_aAttToLoad, $this->m_aExtendedDataSpec);
}
$aObjects[$sClassAlias] = $oObject;
}
$this->AddObjectExtended($aObjects, true /* internal load */);
}
CMDBSource::FreeResult($resQuery);
$this->m_bLoaded = true;
}
public function Count()
{
if (!$this->m_bLoaded) $this->Load();
return count($this->m_aData);
if ($this->m_bLoaded && ($this->m_iLimitCount == 0) && ($this->m_iLimitStart == 0))
{
return count($this->m_aData);
}
else
{
if (is_null($this->m_iCount))
{
$sSQL = MetaModel::MakeSelectQuery($this->m_oFilter, $this->m_aOrderBy, $this->m_aArgs, null, null, 0, 0, true);
$resQuery = CMDBSource::Query($sSQL);
if (!$resQuery) return 0;
$aRow = CMDBSource::FetchArray($resQuery);
CMDBSource::FreeResult($resQuery);
$this->m_iCount = $aRow['COUNT'];
}
return $this->m_iCount;
}
}
public function Fetch()
public function Fetch($sClassAlias = '')
{
if (!$this->m_bLoaded) $this->Load();
@@ -165,14 +390,38 @@ class DBObjectSet
{
return null;
}
$oRetObj = $this->m_aData[$this->m_iCurrRow];
if (strlen($sClassAlias) == 0)
{
$sClassAlias = $this->m_oFilter->GetClassAlias();
}
$oRetObj = $this->m_aData[$this->m_iCurrRow][$sClassAlias];
$this->m_iCurrRow++;
return $oRetObj;
}
// Return the whole line if several classes have been specified in the query
//
public function FetchAssoc()
{
if (!$this->m_bLoaded) $this->Load();
if ($this->m_iCurrRow >= count($this->m_aData))
{
return null;
}
$aRetObjects = $this->m_aData[$this->m_iCurrRow];
$this->m_iCurrRow++;
return $aRetObjects;
}
public function Rewind()
{
$this->Seek(0);
if ($this->m_bLoaded)
{
$this->Seek(0);
}
}
public function Seek($iRow)
@@ -183,24 +432,52 @@ class DBObjectSet
return $this->m_iCurrRow;
}
public function AddObject($oObject)
public function AddObject($oObject, $sClassAlias = '')
{
// ?usefull? if ($oObject->GetClass() != $this->GetClass()) return;
if (!$this->m_bLoaded) $this->Load();
// it is mandatory to avoid duplicates
if (array_key_exists($oObject->GetKey(), $this->m_aId2Row)) return;
if (strlen($sClassAlias) == 0)
{
$sClassAlias = $this->m_oFilter->GetClassAlias();
}
// Do not load here, because the load uses that method too
$iNextPos = count($this->m_aData);
$this->m_aData[$iNextPos] = $oObject;
$this->m_aId2Row[$oObject->GetKey()] = $iNextPos;
$this->m_aData[$iNextPos][$sClassAlias] = $oObject;
if (!is_null($oObject))
{
$this->m_aId2Row[$sClassAlias][$oObject->GetKey()] = $iNextPos;
$this->m_aAddedIds[$oObject->GetKey()] = true;
}
}
public function AddObjectArray($aObjects)
protected function AddObjectExtended($aObjectArray, $bInternalLoad = false)
{
if (!$this->m_bLoaded) $this->Load();
$iNextPos = count($this->m_aData);
foreach ($aObjectArray as $sClassAlias => $oObject)
{
$this->m_aData[$iNextPos][$sClassAlias] = $oObject;
if (!is_null($oObject))
{
$this->m_aId2Row[$sClassAlias][$oObject->GetKey()] = $iNextPos;
if (!$bInternalLoad)
{
$this->m_aAddedIds[$oObject->GetKey()] = true;
}
}
}
}
public function AddObjectArray($aObjects, $sClassAlias = '')
{
if (!$this->m_bLoaded) $this->Load();
// #@# todo - add a check on the object class ?
foreach ($aObjects as $oObj)
{
$this->AddObject($oObj);
$this->AddObject($oObj, $sClassAlias);
}
}
@@ -229,10 +506,11 @@ class DBObjectSet
$oNewSet = DBObjectSet::FromScratch($this->GetClass());
$sClassAlias = $this->m_oFilter->GetClassAlias();
$oObjectSet->Seek(0);
while ($oObject = $oObjectSet->Fetch())
{
if (array_key_exists($oObject->GetKey(), $this->m_aId2Row))
if (array_key_exists($oObject->GetKey(), $this->m_aId2Row[$sClassAlias]))
{
$oNewSet->AddObject($oObject);
}
@@ -240,6 +518,43 @@ class DBObjectSet
return $oNewSet;
}
// Note: This verb works only with objects existing in the database
//
public function HasSameContents($oObjectSet)
{
if ($this->GetRootClass() != $oObjectSet->GetRootClass())
{
return false;
}
if (!$this->m_bLoaded) $this->Load();
if ($this->Count() != $oObjectSet->Count())
{
return false;
}
$sClassAlias = $this->m_oFilter->GetClassAlias();
$oObjectSet->Rewind();
while ($oObject = $oObjectSet->Fetch())
{
$iObjectKey = $oObject->GetKey();
if ($iObjectKey < 0)
{
return false;
}
if (!array_key_exists($iObjectKey, $this->m_aId2Row[$sClassAlias]))
{
return false;
}
$iRow = $this->m_aId2Row[$sClassAlias][$iObjectKey];
$oSibling = $this->m_aData[$iRow][$sClassAlias];
if (!$oObject->Equals($oSibling))
{
return false;
}
}
return true;
}
public function CreateDelta($oObjectSet)
{
if ($this->GetRootClass() != $oObjectSet->GetRootClass())
@@ -250,10 +565,11 @@ class DBObjectSet
$oNewSet = DBObjectSet::FromScratch($this->GetClass());
$sClassAlias = $this->m_oFilter->GetClassAlias();
$oObjectSet->Seek(0);
while ($oObject = $oObjectSet->Fetch())
{
if (!array_key_exists($oObject->GetKey(), $this->m_aId2Row))
if (!array_key_exists($oObject->GetKey(), $this->m_aId2Row[$sClassAlias]))
{
$oNewSet->AddObject($oObject);
}
@@ -263,14 +579,176 @@ class DBObjectSet
public function GetRelatedObjects($sRelCode, $iMaxDepth = 99)
{
$aRelatedObjs = array();
$aVisited = array(); // optimization for consecutive calls of MetaModel::GetRelatedObjects
$this->Seek(0);
while ($oObject = $this->Fetch())
{
$aRelatedObjs = $oObject->GetRelatedObjects($sRelCode, $iMaxDepth, $aVisited);
$aMore = $oObject->GetRelatedObjects($sRelCode, $iMaxDepth, $aVisited);
foreach ($aMore as $sClass => $aRelated)
{
foreach ($aRelated as $iObj => $oObj)
{
if (!isset($aRelatedObjs[$sClass][$iObj]))
{
$aRelatedObjs[$sClass][$iObj] = $oObj;
}
}
}
}
return $aRelatedObjs;
}
/**
* Builds an object that contains the values that are common to all the objects
* in the set. If for a given attribute, objects in the set have various values
* then the resulting object will contain null for this value.
* @param $aValues Hash Output: the distribution of the values, in the set, for each attribute
* @return Object
*/
public function ComputeCommonObject(&$aValues)
{
$sClass = $this->GetClass();
$aList = MetaModel::ListAttributeDefs($sClass);
$aValues = array();
foreach($aList as $sAttCode => $oAttDef)
{
if ($oAttDef->IsScalar())
{
$aValues[$sAttCode] = array();
}
}
$this->Rewind();
while($oObj = $this->Fetch())
{
foreach($aList as $sAttCode => $oAttDef)
{
if ($oAttDef->IsScalar() && $oAttDef->IsWritable())
{
$currValue = $oObj->Get($sAttCode);
if (is_object($currValue)) continue; // Skip non scalar values...
if(!array_key_exists($currValue, $aValues[$sAttCode]))
{
$aValues[$sAttCode][$currValue] = array('count' => 1, 'display' => $oObj->GetAsHTML($sAttCode));
}
else
{
$aValues[$sAttCode][$currValue]['count']++;
}
}
}
}
foreach($aValues as $sAttCode => $aMultiValues)
{
if (count($aMultiValues) > 1)
{
uasort($aValues[$sAttCode], 'HashCountComparison');
}
}
// Now create an object that has values for the homogenous values only
$oCommonObj = new $sClass(); // @@ What if the class is abstract ?
$aComments = array();
$iFormId = cmdbAbstractObject::GetNextFormId(); // Identifier that prefixes all the form fields
$sReadyScript = '';
$aDependsOn = array();
$sFormPrefix = '2_';
foreach($aList as $sAttCode => $oAttDef)
{
if ($oAttDef->IsScalar() && $oAttDef->IsWritable())
{
if ($oAttDef->GetEditClass() == 'One Way Password')
{
$oCommonObj->Set($sAttCode, null);
}
else
{
$iCount = count($aValues[$sAttCode]);
if ($iCount == 1)
{
// Homogenous value
reset($aValues[$sAttCode]);
$aKeys = array_keys($aValues[$sAttCode]);
$currValue = $aKeys[0]; // The only value is the first key
$oCommonObj->Set($sAttCode, $currValue);
}
else
{
// Non-homogenous value
$oCommonObj->Set($sAttCode, null);
}
}
}
}
$this->Rewind();
return $oCommonObj;
}
/**
* List the constant fields (and their value) in the given query
* @return Hash [Alias][AttCode] => value
*/
public function ListConstantFields()
{
$aScalarArgs = $this->ExpandArgs();
$aConst = $this->m_oFilter->ListConstantFields();
foreach($aConst as $sClassAlias => $aVals)
{
foreach($aVals as $sCode => $oExpr)
{
if ($oExpr instanceof ScalarExpression)
{
$aConst[$sClassAlias][$sCode] = $oExpr->GetValue();
}
else //Variable
{
$aConst[$sClassAlias][$sCode] = $aScalarArgs[$oExpr->GetName()];
}
}
}
return $aConst;
}
protected function ExpandArgs()
{
$aScalarArgs = $this->m_oFilter->GetInternalParams();
foreach($this->m_aArgs as $sArgName => $value)
{
if (MetaModel::IsValidObject($value))
{
$aScalarArgs = array_merge($aScalarArgs, $value->ToArgs($sArgName));
}
else
{
$aScalarArgs[$sArgName] = (string) $value;
}
}
$aScalarArgs['current_contact_id'] = UserRights::GetContactId();
return $aScalarArgs;
}
public function ApplyParameters()
{
$aScalarArgs = $this->ExpandArgs();
$this->m_oFilter->ApplyParameters($aScalarArgs);
}
}
/**
* Helper function to perform a custom sort of a hash array
*/
function HashCountComparison($a, $b) // Sort descending on 'count'
{
if ($a['count'] == $b['count'])
{
return 0;
}
return ($a['count'] > $b['count']) ? -1 : 1;
}
?>

View File

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

View File

@@ -0,0 +1,288 @@
<?php
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* Class dbObject: the root of persistent classes
*
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
class DeleteException extends CoreException
{
}
/**
* Deletion plan (other objects to be deleted/modified, eventual issues, etc.)
*
* @package iTopORM
*/
class DeletionPlan
{
//protected $m_aIssues;
protected $m_bFoundStopper;
protected $m_bFoundSecurityIssue;
protected $m_bFoundManualDelete;
protected $m_bFoundManualOperation;
protected $m_iToDelete;
protected $m_iToUpdate;
protected $m_aToDelete;
protected $m_aToUpdate;
protected static $m_aModeUpdate = array(
DEL_SILENT => array(
DEL_SILENT => DEL_SILENT,
DEL_AUTO => DEL_AUTO,
DEL_MANUAL => DEL_MANUAL
),
DEL_MANUAL => array(
DEL_SILENT => DEL_MANUAL,
DEL_AUTO => DEL_AUTO,
DEL_MANUAL => DEL_MANUAL
),
DEL_AUTO => array(
DEL_SILENT => DEL_AUTO,
DEL_AUTO => DEL_AUTO,
DEL_MANUAL => DEL_AUTO
)
);
public function __construct()
{
$this->m_iToDelete = 0;
$this->m_iToUpdate = 0;
$this->m_aToDelete = array();
$this->m_aToUpdate = array();
$this->m_bFoundStopper = false;
$this->m_bFoundSecurityIssue = false;
$this->m_bFoundManualDelete = false;
$this->m_bFoundManualOperation = false;
}
public function ComputeResults()
{
foreach($this->m_aToDelete as $sClass => $aToDelete)
{
foreach($aToDelete as $iId => $aData)
{
$this->m_iToDelete++;
if (isset($aData['issue']))
{
$this->m_bFoundStopper = true;
$this->m_bFoundManualOperation = true;
if (isset($aData['issue_security']))
{
$this->m_bFoundSecurityIssue = true;
}
}
if ($aData['mode'] == DEL_MANUAL)
{
$this->m_bFoundStopper = true;
$this->m_bFoundManualDelete = true;
}
}
}
foreach($this->m_aToUpdate as $sClass => $aToUpdate)
{
foreach($aToUpdate as $iId => $aData)
{
$this->m_iToUpdate++;
$oObject = $aData['to_reset'];
$aExtKeyLabels = array();
foreach ($aData['attributes'] as $sRemoteExtKey => $aRemoteAttDef)
{
$oObject->Set($sRemoteExtKey, $aData['values'][$sRemoteExtKey]);
$aExtKeyLabels[] = $aRemoteAttDef->GetLabel();
}
$this->m_aToUpdate[$sClass][$iId]['attributes_list'] = implode(', ', $aExtKeyLabels);
list($bRes, $aIssues, $bSecurityIssues) = $oObject->CheckToWrite();
if (!$bRes)
{
$this->m_aToUpdate[$sClass][$iId]['issue'] = implode(', ', $aIssues);
$this->m_bFoundStopper = true;
if ($bSecurityIssues)
{
$this->m_aToUpdate[$sClass][$iId]['issue_security'] = true;
$this->m_bFoundSecurityIssue = true;
}
}
}
}
}
public function GetIssues()
{
$aIssues = array();
foreach ($this->m_aToDelete as $sClass => $aToDelete)
{
foreach ($aToDelete as $iId => $aData)
{
if (isset($aData['issue']))
{
$aIssues[] = $aData['issue'];
}
}
}
foreach ($this->m_aToUpdate as $sClass => $aToUpdate)
{
foreach ($aToUpdate as $iId => $aData)
{
if (isset($aData['issue']))
{
$aIssues[] = $aData['issue'];
}
}
}
return $aIssues;
}
public function ListDeletes()
{
return $this->m_aToDelete;
}
public function ListUpdates()
{
return $this->m_aToUpdate;
}
public function GetTargetCount()
{
return $this->m_iToDelete + $this->m_iToUpdate;
}
public function FoundStopper()
{
return $this->m_bFoundStopper;
}
public function FoundSecurityIssue()
{
return $this->m_bFoundSecurityIssue;
}
public function FoundManualOperation()
{
return $this->m_bFoundManualOperation;
}
public function FoundManualDelete()
{
return $this->m_bFoundManualDelete;
}
public function FoundManualUpdate()
{
}
public function AddToDelete($oObject, $iDeletionMode = null)
{
if (is_null($iDeletionMode))
{
$bRequestedExplicitely = true;
$iDeletionMode = DEL_AUTO;
}
else
{
$bRequestedExplicitely = false;
}
$sClass = get_class($oObject);
$iId = $oObject->GetKey();
if (isset($this->m_aToUpdate[$sClass][$iId]))
{
unset($this->m_aToUpdate[$sClass][$iId]);
}
if (isset($this->m_aToDelete[$sClass][$iId]))
{
if ($this->m_aToDelete[$sClass][$iId]['requested_explicitely'])
{
// No change: let it in mode DEL_AUTO
}
else
{
$iPrevDeletionMode = $this->m_aToDelete[$sClass][$iId]['mode'];
$iNewDeletionMode = self::$m_aModeUpdate[$iPrevDeletionMode][$iDeletionMode];
$this->m_aToDelete[$sClass][$iId]['mode'] = $iNewDeletionMode;
if ($bRequestedExplicitely)
{
// This object was in the root list
$this->m_aToDelete[$sClass][$iId]['requested_explicitely'] = true;
$this->m_aToDelete[$sClass][$iId]['mode'] = DEL_AUTO;
}
}
}
else
{
$this->m_aToDelete[$sClass][$iId] = array(
'to_delete' => $oObject,
'mode' => $iDeletionMode,
'requested_explicitely' => $bRequestedExplicitely,
);
}
}
public function SetDeletionIssues($oObject, $aIssues, $bSecurityIssue)
{
if (count($aIssues) > 0)
{
$sClass = get_class($oObject);
$iId = $oObject->GetKey();
$this->m_aToDelete[$sClass][$iId]['issue'] = implode(', ', $aIssues);
if ($bSecurityIssue)
{
$this->m_aToDelete[$sClass][$iId]['issue_security'] = true;
}
}
}
public function AddToUpdate($oObject, $oAttDef, $value = 0)
{
$sClass = get_class($oObject);
$iId = $oObject->GetKey();
if (isset($this->m_aToDelete[$sClass][$iId]))
{
// skip... it should be deleted anyhow !
}
else
{
if (!isset($this->m_aToUpdate[$sClass][$iId]))
{
$this->m_aToUpdate[$sClass][$iId] = array(
'to_reset' => $oObject,
);
}
$this->m_aToUpdate[$sClass][$iId]['attributes'][$oAttDef->GetCode()] = $oAttDef;
$this->m_aToUpdate[$sClass][$iId]['values'][$oAttDef->GetCode()] = $value;
}
}
}
?>

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

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

View File

@@ -1,33 +1,51 @@
<?php
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* Send an mail (for notification, testing,... purposes)
* #@# TODO - replace by a more sophisticated mean (and update the prototype)
*
* @package iTopORM
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @author Denis Flaven <denisflave@free.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version 1.1.1.1 $
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
define ('EMAIL_SEND_OK', 0);
define ('EMAIL_SEND_PENDING', 1);
define ('EMAIL_SEND_ERROR', 2);
class EMail
{
protected $m_sBody;
protected $m_sSubject;
protected $m_sTo;
protected $m_aHeaders; // array of key=>value
protected $m_aAttachments;
public function __construct()
public function __construct($sTo = '', $sSubject = '', $sBody = '', $aHeaders = array())
{
$this->m_sTo = '';
$this->m_sSubject = '';
$this->m_sBody = '';
$this->m_aHeaders = array();
$this->m_sTo = $sTo;
$this->m_sSubject = $sSubject;
$this->m_sBody = $sBody;
$this->m_aHeaders = $aHeaders;
$this->m_aAttachments = array();
}
// Errors management : not that simple because we need that function to be
// executed in the background, while making sure that any issue would be reported clearly
protected $m_aMailErrors; //array of strings explaining the issues
@@ -38,14 +56,33 @@ class EMail
$this->m_aMailErrors[] = $sCleanMessage;
}
protected function SendAsynchronous(&$aIssues, $oLog = null)
{
try
{
AsyncSendEmail::AddToQueue($this->m_sTo, $this->m_sSubject, $this->m_sBody, $this->m_aHeaders, $oLog);
}
catch(Exception $e)
{
$aIssues = array($e->GetMessage());
return EMAIL_SEND_ERROR;
}
$aIssues = array();
return EMAIL_SEND_PENDING;
}
// returns a list of issues if any
public function Send()
protected function SendSynchronous(&$aIssues, $oLog = null)
{
$sHeaders = 'MIME-Version: 1.0' . "\r\n";
// ! the case is important for MS-Outlook
$sHeaders .= 'Content-Type: text/html; charset=UTF-8' . "\r\n";
$sHeaders .= 'Content-Transfer-Encoding: 8bit' . "\r\n";
if (!array_key_exists('Content-Type', $this->m_aHeaders))
{
$sHeaders .= 'Content-Type: text/html; charset=UTF-8' . "\r\n";
}
if (!array_key_exists('Content-Transfer-Encoding', $this->m_aHeaders))
{
$sHeaders .= 'Content-Transfer-Encoding: 8bit' . "\r\n";
}
foreach ($this->m_aHeaders as $sKey => $sValue)
{
$sHeaders .= "$sKey: $sValue\r\n";
@@ -57,8 +94,8 @@ class EMail
set_error_handler(array($this, 'mail_error_handler'));
$bRes = mail
(
$this->m_sTo,
$this->m_sSubject,
str_replace(array("\n", "\r"), ' ', $this->m_sTo), // Prevent header injection
$this->EncodeHeaderField($this->m_sSubject), // Prevent header injection & MIME Encode charsets
$this->m_sBody,
$sHeaders
);
@@ -67,10 +104,40 @@ class EMail
{
$this->m_aMailErrors[] = 'Unknown reason';
}
return $this->m_aMailErrors;
if (count($this->m_aMailErrors) > 0)
{
$aIssues = $this->m_aMailErrors;
return EMAIL_SEND_ERROR;
}
else
{
$aIssues = array();
return EMAIL_SEND_OK;
}
}
protected function AddToHeader($sKey, $sValue)
public function Send(&$aIssues, $bForceSynchronous = false, $oLog = null)
{
$this->BuildMessage(); // assemble the attachments into the header/body structure
if ($bForceSynchronous)
{
return $this->SendSynchronous($aIssues, $oLog);
}
else
{
$bConfigASYNC = MetaModel::GetConfig()->Get('email_asynchronous');
if ($bConfigASYNC)
{
return $this->SendAsynchronous($aIssues, $oLog);
}
else
{
return $this->SendSynchronous($aIssues, $oLog);
}
}
}
public function AddToHeader($sKey, $sValue)
{
if (strlen($sValue) > 0)
{
@@ -78,6 +145,16 @@ class EMail
}
}
public function SetMessageId($sId)
{
$this->AddToHeader('Message-ID', $sId);
}
public function SetReferences($sReferences)
{
$this->AddToHeader('References', $sReferences);
}
public function SetBody($sBody)
{
$this->m_sBody = $sBody;
@@ -118,6 +195,48 @@ class EMail
$this->AddToHeader('Reply-To', $sAddress);
}
public function AddAttachment($data, $sFileName, $sMimeType)
{
$this->m_aAttachments[] = array('data' => $data, 'filename' => $sFileName, 'mimeType' => $sMimeType);
}
/**
* Takes care of the attachments (if any) to build the header/body of the message before storing or sending it
*/
protected function BuildMessage()
{
if (count($this->m_aAttachments) == 0) return; // Nothing to do if there are no attachments
$sDelimiter = '== iTopEmailPart---'.md5(date('r', time()))." ==";
$sContentType = isset($this->m_aHeaders['Content-Type']) ? $this->m_aHeaders['Content-Type'] : 'text/html; charset="UTF-8"';
$sContentHeader = "Content-Type: $sContentType\r\n";
$this->m_aHeaders['Content-Type'] = "multipart/mixed; boundary=\"{$sDelimiter}\"";
$aAttachments = array();
foreach($this->m_aAttachments as $aAttach)
{
$sAttachmentHeader = "Content-Type: {$aAttach['mimeType']};\r\n Name=\"{$aAttach['filename']}\"\r\n";
$sAttachmentHeader .= "Content-Transfer-Encoding: base64\r\nContent-Disposition: attachment;\r\n filename=\"{$aAttach['filename']}\"\r\n";
$sAttachmentHeader .= "\r\n";
$sAttachment = chunk_split(base64_encode($aAttach['data']));
$aAttachments[] = $sAttachmentHeader.$sAttachment."\r\n";
}
$this->m_sBody = "This is a multi-part message in MIME format.\r\n--".$sDelimiter."\r\n".$sContentHeader."\r\n".$this->m_sBody."\r\n--".$sDelimiter."\r\n";
$this->m_sBody .= implode("--".$sDelimiter."\r\n", $aAttachments);
$this->m_sBody .= "--".$sDelimiter."--";
}
/**
* MIME encode the content of a header field according to RFC2047
* @param string $sFieldContent the content of the header to encode
* @return string The encoded string
*/
protected function EncodeHeaderField($sFieldContent)
{
$sTemp = str_replace(array("\n", "\r"), ' ', $sFieldContent);
$sTemp = iconv_mime_encode('Tagada', $sTemp, array('scheme' => 'Q', 'input-charset' => 'UTF-8', 'output-charset' => 'UTF-8'));
return preg_replace('/^Tagada: /', '', $sTemp);
}
}
?>
?>

View File

@@ -1,27 +1,38 @@
<?php
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* An application internal event
* Persistent class Event and derived
* Application internal events
* There is also a file log
*
* @package iTopORM
* @author Romain Quetiez <romainquetiez@yahoo.fr>
* @author Denis Flaven <denisflave@free.fr>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.itop.com
* @since 1.0
* @version 1.1.1.1 $
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
class Event extends cmdbAbstractObject
class Event extends DBObject implements iDisplay
{
public static function Init()
{
$aParams = array
(
"category" => "core/cmdb",
"name" => "Log Event",
"description" => "An application internal event",
"category" => "core/cmdb,view_in_gui",
"key_type" => "autoincrement",
"key_label" => "",
"name_attcode" => "",
"state_attcode" => "",
"reconc_keys" => array(),
@@ -32,21 +43,80 @@ class Event extends cmdbAbstractObject
);
MetaModel::Init_Params($aParams);
//MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeText("message", array("label"=>"message", "description"=>"short description of the event", "allowed_values"=>null, "sql"=>"message", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeDate("date", array("label"=>"date", "description"=>"date and time at which the changes have been recorded", "allowed_values"=>null, "sql"=>"date", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("userinfo", array("label"=>"user info", "description"=>"identification of the user that was doing the action that triggered this event", "allowed_values"=>null, "sql"=>"userinfo", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
//MetaModel::Init_InheritFilters();
MetaModel::Init_AddFilterFromAttribute("message");
MetaModel::Init_AddFilterFromAttribute("date");
MetaModel::Init_AddAttribute(new AttributeText("message", array("allowed_values"=>null, "sql"=>"message", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeDateTime("date", array("allowed_values"=>null, "sql"=>"date", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("userinfo", array("allowed_values"=>null, "sql"=>"userinfo", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
// MetaModel::Init_AddAttribute(new AttributeString("userinfo", array("allowed_values"=>null, "sql"=>"userinfo", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
// Display lists
MetaModel::Init_SetZListItems('details', array('message', 'date', 'userinfo')); // Attributes to be displayed for the complete details
MetaModel::Init_SetZListItems('details', array('date', 'message', 'userinfo')); // Attributes to be displayed for the complete details
MetaModel::Init_SetZListItems('list', array('date', 'finalclass', 'message')); // Attributes to be displayed for a list
// Search criteria
// MetaModel::Init_SetZListItems('standard_search', array('name')); // Criteria of the std search form
// MetaModel::Init_SetZListItems('advanced_search', array('name')); // Criteria of the advanced search form
}
/**
* Maps the given context parameter name to the appropriate filter/search code for this class
* @param string $sContextParam Name of the context parameter, i.e. 'org_id'
* @return string Filter code, i.e. 'customer_id'
*/
public static function MapContextParam($sContextParam)
{
if ($sContextParam == 'menu')
{
return null;
}
else
{
return $sContextParam;
}
}
/**
* This function returns a 'hilight' CSS class, used to hilight a given row in a table
* There are currently (i.e defined in the CSS) 4 possible values HILIGHT_CLASS_CRITICAL,
* HILIGHT_CLASS_WARNING, HILIGHT_CLASS_OK, HILIGHT_CLASS_NONE
* To Be overridden by derived classes
* @param void
* @return String The desired higlight class for the object/row
*/
public function GetHilightClass()
{
// Possible return values are:
// HILIGHT_CLASS_CRITICAL, HILIGHT_CLASS_WARNING, HILIGHT_CLASS_OK, HILIGHT_CLASS_NONE
return HILIGHT_CLASS_NONE; // Not hilighted by default
}
public static function GetUIPage()
{
return 'UI.php';
}
function DisplayDetails(WebPage $oPage, $bEditMode = false)
{
// Object's details
//$this->DisplayBareHeader($oPage, $bEditMode);
$oPage->AddTabContainer(OBJECT_PROPERTIES_TAB);
$oPage->SetCurrentTabContainer(OBJECT_PROPERTIES_TAB);
$oPage->SetCurrentTab(Dict::S('UI:PropertiesTab'));
$this->DisplayBareProperties($oPage, $bEditMode);
}
function DisplayBareProperties(WebPage $oPage, $bEditMode = false, $sPrefix = '', $aExtraParams = array())
{
if ($bEditMode) return; // Not editable
$aDetails = array();
$sClass = get_class($this);
$aZList = MetaModel::FlattenZlist(MetaModel::GetZListItems($sClass, 'details'));
foreach( $aZList as $sAttCode)
{
$sDisplayValue = $this->GetAsHTML($sAttCode);
$aDetails[] = array('label' => '<span title="'.MetaModel::GetDescription($sClass, $sAttCode).'">'.MetaModel::GetLabel($sClass, $sAttCode).'</span>', 'value' => $sDisplayValue);
}
$oPage->Details($aDetails);
}
}
class EventNotification extends Event
@@ -55,11 +125,8 @@ class EventNotification extends Event
{
$aParams = array
(
"category" => "core/cmdb",
"name" => "Notification event",
"description" => "Trace of a notification that has been sent",
"category" => "core/cmdb,view_in_gui",
"key_type" => "autoincrement",
"key_label" => "",
"name_attcode" => "",
"state_attcode" => "",
"reconc_keys" => array(),
@@ -70,18 +137,13 @@ class EventNotification extends Event
);
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeExternalKey("trigger_id", array("targetclass"=>"Trigger", "jointype"=> "", "label"=>"Trigger", "description"=>"user account", "allowed_values"=>null, "sql"=>"trigger_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalKey("action_id", array("targetclass"=>"Action", "jointype"=> "", "label"=>"user", "description"=>"user account", "allowed_values"=>null, "sql"=>"action_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeInteger("object_id", array("label"=>"Object id", "description"=>"object id (class defined by the trigger ?)", "allowed_values"=>null, "sql"=>"object_id", "default_value"=>0, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_InheritFilters();
MetaModel::Init_AddFilterFromAttribute("trigger_id");
MetaModel::Init_AddFilterFromAttribute("action_id");
MetaModel::Init_AddFilterFromAttribute("object_id");
MetaModel::Init_AddAttribute(new AttributeExternalKey("trigger_id", array("targetclass"=>"Trigger", "jointype"=> "", "allowed_values"=>null, "sql"=>"trigger_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalKey("action_id", array("targetclass"=>"Action", "jointype"=> "", "allowed_values"=>null, "sql"=>"action_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeInteger("object_id", array("allowed_values"=>null, "sql"=>"object_id", "default_value"=>0, "is_null_allowed"=>false, "depends_on"=>array())));
// Display lists
MetaModel::Init_SetZListItems('details', array('date', 'userinfo', 'trigger_id', 'action_id', 'object_id')); // Attributes to be displayed for the complete details
MetaModel::Init_SetZListItems('list', array('date', 'userinfo')); // Attributes to be displayed for a list
MetaModel::Init_SetZListItems('details', array('date', 'message', 'userinfo', 'trigger_id', 'action_id', 'object_id')); // Attributes to be displayed for the complete details
MetaModel::Init_SetZListItems('list', array('date', 'message')); // Attributes to be displayed for a list
// Search criteria
// MetaModel::Init_SetZListItems('standard_search', array('name')); // Criteria of the std search form
// MetaModel::Init_SetZListItems('advanced_search', array('name')); // Criteria of the advanced search form
@@ -95,11 +157,8 @@ class EventNotificationEmail extends EventNotification
{
$aParams = array
(
"category" => "core/cmdb",
"name" => "Email emission event",
"description" => "Trace of an email that has been sent",
"category" => "core/cmdb,view_in_gui",
"key_type" => "autoincrement",
"key_label" => "",
"name_attcode" => "",
"state_attcode" => "",
"reconc_keys" => array(),
@@ -110,17 +169,16 @@ class EventNotificationEmail extends EventNotification
);
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeText("to", array("label"=>"TO", "description"=>"TO", "allowed_values"=>null, "sql"=>"to", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("cc", array("label"=>"CC", "description"=>"CC", "allowed_values"=>null, "sql"=>"cc", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("bcc", array("label"=>"BCC", "description"=>"BCC", "allowed_values"=>null, "sql"=>"bcc", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("from", array("label"=>"From", "description"=>"Sender of the message", "allowed_values"=>null, "sql"=>"from", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("subject", array("label"=>"Subject", "description"=>"Subject", "allowed_values"=>null, "sql"=>"subject", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("body", array("label"=>"Body", "description"=>"Body", "allowed_values"=>null, "sql"=>"body", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_InheritFilters();
MetaModel::Init_AddAttribute(new AttributeText("to", array("allowed_values"=>null, "sql"=>"to", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("cc", array("allowed_values"=>null, "sql"=>"cc", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("bcc", array("allowed_values"=>null, "sql"=>"bcc", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("from", array("allowed_values"=>null, "sql"=>"from", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("subject", array("allowed_values"=>null, "sql"=>"subject", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeHTML("body", array("allowed_values"=>null, "sql"=>"body", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
// Display lists
MetaModel::Init_SetZListItems('details', array('date', 'userinfo', 'message', 'trigger_id', 'action_id', 'object_id', 'to', 'cc', 'bcc', 'from', 'subject', 'body')); // Attributes to be displayed for the complete details
MetaModel::Init_SetZListItems('list', array('date', 'userinfo', 'message', 'subject')); // Attributes to be displayed for a list
MetaModel::Init_SetZListItems('list', array('date', 'message', 'to', 'subject')); // Attributes to be displayed for a list
// Search criteria
// MetaModel::Init_SetZListItems('standard_search', array('name')); // Criteria of the std search form
@@ -135,11 +193,8 @@ class EventIssue extends Event
{
$aParams = array
(
"category" => "core/cmdb",
"name" => "Issue event",
"description" => "Trace of an issue (warning, error, etc.)",
"category" => "core/cmdb,view_in_gui",
"key_type" => "autoincrement",
"key_label" => "",
"name_attcode" => "",
"state_attcode" => "",
"reconc_keys" => array(),
@@ -150,17 +205,13 @@ class EventIssue extends Event
);
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeString("issue", array("label"=>"Issue", "description"=>"What happened", "allowed_values"=>null, "sql"=>"issue", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("impact", array("label"=>"Impact", "description"=>"What are the consequences", "allowed_values"=>null, "sql"=>"impact", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("page", array("label"=>"Page", "description"=>"HTTP entry point", "allowed_values"=>null, "sql"=>"page", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("arguments_post", array("label"=>"Posted arguments", "description"=>"HTTP POST arguments", "allowed_values"=>null, "sql"=>"arguments_post", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("arguments_get", array("label"=>"URL arguments", "description"=>"HTTP GET arguments", "allowed_values"=>null, "sql"=>"arguments_get", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("callstack", array("label"=>"Callstack", "description"=>"Call stack", "allowed_values"=>null, "sql"=>"callstack", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeBlob("data", array("label"=>"Data", "description"=>"More information", "allowed_values"=>null, "sql"=>"data", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_InheritFilters();
MetaModel::Init_AddFilterFromAttribute("issue");
MetaModel::Init_AddFilterFromAttribute("impact");
MetaModel::Init_AddAttribute(new AttributeString("issue", array("allowed_values"=>null, "sql"=>"issue", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("impact", array("allowed_values"=>null, "sql"=>"impact", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("page", array("allowed_values"=>null, "sql"=>"page", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributePropertySet("arguments_post", array("allowed_values"=>null, "sql"=>"arguments_post", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributePropertySet("arguments_get", array("allowed_values"=>null, "sql"=>"arguments_get", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeTable("callstack", array("allowed_values"=>null, "sql"=>"callstack", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributePropertySet("data", array("allowed_values"=>null, "sql"=>"data", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
// Display lists
MetaModel::Init_SetZListItems('details', array('date', 'userinfo', 'issue', 'impact', 'page', 'arguments_post', 'arguments_get', 'callstack', 'data')); // Attributes to be displayed for the complete details
@@ -169,6 +220,69 @@ class EventIssue extends Event
// MetaModel::Init_SetZListItems('standard_search', array('name')); // Criteria of the std search form
// MetaModel::Init_SetZListItems('advanced_search', array('name')); // Criteria of the advanced search form
}
protected function OnInsert()
{
// Init page information: name, arguments
//
$this->Set('page', @$GLOBALS['_SERVER']['SCRIPT_NAME']);
if (array_key_exists('_GET', $GLOBALS) && is_array($GLOBALS['_GET']))
{
$this->Set('arguments_get', $GLOBALS['_GET']);
}
else
{
$this->Set('arguments_get', array());
}
if (array_key_exists('_POST', $GLOBALS) && is_array($GLOBALS['_POST']))
{
$aPost = array();
foreach($GLOBALS['_POST'] as $sKey => $sValue)
{
if (is_string($sValue))
{
if (strlen($sValue) < 256)
{
$aPost[$sKey] = $sValue;
}
else
{
$aPost[$sKey] = "!long string: ".strlen($sValue). " chars";
}
}
else
{
// Not a string
$aPost[$sKey] = (string) $sValue;
}
}
$this->Set('arguments_post', $aPost);
}
else
{
$this->Set('arguments_post', array());
}
$sLength = strlen($this->Get('issue'));
if ($sLength > 255)
{
$this->Set('issue', substr($this->Get('issue'), 0, 200)." -truncated ($sLength chars)");
}
$sLength = strlen($this->Get('impact'));
if ($sLength > 255)
{
$this->Set('impact', substr($this->Get('impact'), 0, 200)." -truncated ($sLength chars)");
}
$sLength = strlen($this->Get('page'));
if ($sLength > 255)
{
$this->Set('page', substr($this->Get('page'), 0, 200)." -truncated ($sLength chars)");
}
}
}
@@ -178,11 +292,8 @@ class EventWebService extends Event
{
$aParams = array
(
"category" => "core/cmdb",
"name" => "Web service event",
"description" => "Trace of an web service call",
"category" => "core/cmdb,view_in_gui",
"key_type" => "autoincrement",
"key_label" => "",
"name_attcode" => "",
"state_attcode" => "",
"reconc_keys" => array(),
@@ -193,15 +304,13 @@ class EventWebService extends Event
);
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeString("verb", array("label"=>"Verb", "description"=>"Name of the operation", "allowed_values"=>null, "sql"=>"verb", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
//MetaModel::Init_AddAttribute(new AttributeStructure("arguments", array("label"=>"Arguments", "description"=>"Operation arguments", "allowed_values"=>null, "sql"=>"data", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeBoolean("result", array("label"=>"Result", "description"=>"Overall success/failure", "allowed_values"=>null, "sql"=>"result", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("log_info", array("label"=>"Info log", "description"=>"Result info log", "allowed_values"=>null, "sql"=>"log_info", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("log_warning", array("label"=>"Warning log", "description"=>"Result warning log", "allowed_values"=>null, "sql"=>"log_warning", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("log_error", array("label"=>"Error log", "description"=>"Result error log", "allowed_values"=>null, "sql"=>"log_error", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("data", array("label"=>"Data", "description"=>"Result data", "allowed_values"=>null, "sql"=>"data", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_InheritFilters();
MetaModel::Init_AddAttribute(new AttributeString("verb", array("allowed_values"=>null, "sql"=>"verb", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
//MetaModel::Init_AddAttribute(new AttributeStructure("arguments", array("allowed_values"=>null, "sql"=>"data", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeBoolean("result", array("allowed_values"=>null, "sql"=>"result", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("log_info", array("allowed_values"=>null, "sql"=>"log_info", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("log_warning", array("allowed_values"=>null, "sql"=>"log_warning", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("log_error", array("allowed_values"=>null, "sql"=>"log_error", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeText("data", array("allowed_values"=>null, "sql"=>"data", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
// Display lists
MetaModel::Init_SetZListItems('details', array('date', 'userinfo', 'verb', 'result', 'log_info', 'log_warning', 'log_error', 'data')); // Attributes to be displayed for the complete details
@@ -212,4 +321,43 @@ class EventWebService extends Event
}
}
class EventLoginUsage extends Event
{
public static function Init()
{
$aParams = array
(
"category" => "core/cmdb,view_in_gui",
"key_type" => "autoincrement",
"name_attcode" => "",
"state_attcode" => "",
"reconc_keys" => array(),
"db_table" => "priv_event_loginusage",
"db_key_field" => "id",
"db_finalclass_field" => "",
);
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();
MetaModel::Init_AddAttribute(new AttributeExternalKey("user_id", array("targetclass"=>"User", "jointype"=> "", "allowed_values"=>null, "sql"=>"user_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
$aZList = array('date', 'user_id');
if (MetaModel::IsValidAttCode('Contact', 'name'))
{
MetaModel::Init_AddAttribute(new AttributeExternalField("contact_name", array("allowed_values"=>null, "extkey_attcode"=>"user_id", "target_attcode"=>"contactid", "is_null_allowed"=>true, "depends_on"=>array())));
$aZList[] = 'contact_name';
}
if (MetaModel::IsValidAttCode('Contact', 'email'))
{
MetaModel::Init_AddAttribute(new AttributeExternalField("contact_email", array("allowed_values"=>null, "extkey_attcode"=>"user_id", "target_attcode"=>"email", "is_null_allowed"=>true, "depends_on"=>array())));
$aZList[] = 'contact_email';
}
// Display lists
MetaModel::Init_SetZListItems('details', array_merge($aZList, array('userinfo', 'message'))); // Attributes to be displayed for the complete details
MetaModel::Init_SetZListItems('list', array_merge($aZList, array('userinfo'))); // Attributes to be displayed for a list
// Search criteria
MetaModel::Init_SetZListItems('standard_search', $aZList); // Criteria of the std search form
// MetaModel::Init_SetZListItems('advanced_search', array('name')); // Criteria of the advanced search form
}
}
?>

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