For the 1.0 Beta version I have been updating qWikiOffice to use definitions for modules, libraries and privileges.
A definition is simply JSON data that defines the particular module, library or privilege. I was thinking to support the ability to have the definitions in files located in a protected directory (definitions/), or in a database table (qo_definitions).
Below are some sample definitions that I am currently using. I am curious for any feedback.
Edit:
Definitions are only meant to be used server side.
The only definition data that is also passed to the client is the privilege data that the member's group has assigned to it. The isAllowedTo() function of the App (App.js) uses it.
A module definition
- Code: Select all
{
"defines": "module",
"id": "mod-qopreferences",
"data": {
"type": "system/preferences",
"about": {
"author": "Todd Murdock",
"description": "Allows users to set and save their desktop preferences",
"name": "Preferences",
"url": "www.qwikioffice.com",
"version": "1.0"
},
"dependencies": [
{ "id": "lib-colorpicker" },
{ "id": "lib-explorerview" }
],
"locale": {
"class": "QoDesk.QoPreferences.Locale",
"directory": "qwiki/preferences/client/locale/",
"languages": [ "en" ]
},
"client": {
"class": "QoDesk.QoPreferences",
"css": [
{
"directory": "qwiki/preferences/client/resources/",
"files": [ "styles.css" ]
}
],
"javascript": [
{
"directory": "qwiki/preferences/client/",
"files": [ "QoPreferences.js" ]
},
{
"directory": "qwiki/preferences/client/lib/",
"files": [ "Appearance.js", "AutoRun.js", "Background.js", "Grid.js", "Nav.js", "Quickstart.js", "Shortcuts.js" ]
}
],
"launcher": {
"config": {
"iconCls": "pref-icon",
"shortcutIconCls": "pref-shortcut-icon",
"text": "Preferences",
"tooltip": "<b>Preferences</b><br />Allows you to modify your desktop"
},
"paths": {
"toolmenu": "/"
}
}
},
"server": {
"actions": [
{ "id": "saveAppearance", "description": "Allow member to save appearance" },
{ "id": "saveAutorun", "description": "Allow member to save which modules run at start up" },
{ "id": "saveBackground", "description": "Allow member to save a wallpaper as the background" },
{ "id": "saveQuickstart", "description": "Allow member to save which modules appear in the Quick Start panel" },
{ "id": "saveShortcut", "description": "Allow member to save which modules appear as a Shortcut" },
{ "id": "viewThemes", "description": "Allow member to view the available themes" },
{ "id": "viewWallpapers", "description": "Allow member to view the available wallpapers" }
],
"class": "QoPreferences",
"file": "qwiki/preferences/server/QoPreferences.php"
}
}
}
A library definition. A library is a widget, package, etc. that can be shared among modules.
- Code: Select all
{
"defines": "library",
"id": "lib-colorpicker",
"data": {
"dependencies": [
{ "id": "lib-hexfield" }
],
"client": {
"css": [
{
"directory": "color-picker/resources/",
"files": [ "styles.css" ]
}
],
"javascript": [
{
"directory": "color-picker/",
"files": [ "Ext.ux.ColorPicker.js" ]
}
]
}
}
}
A privilege definition. The data consists of module ids the member has access to load. The module id child items are the server methods that can be called. They can a value of 0 or 1 (meaning disallow or allow).
- Code: Select all
{
"defines": "privilege",
"id": "prv-demo",
"description": "Demo member. Has limited access. Can not Add, Edit or Delete.",
"data": {
"mod-qwikimail": {
"addMemberFolder": 0,
"loadMemberFolders": 1
},
"mod-qopreferences": {
"saveAppearance": 0,
"saveAutorun": 0,
"saveBackground": 0,
"saveQuickstart": 0,
"saveShortcut": 0,
"viewThemes": 1,
"viewWallpapers": 1
},
"mod-demolayout": 1,
"mod-demogrid": 1,
"mod-demobogus": 1,
"mod-demotabs": 1,
"mod-demoacc": 1
}
}
