Revision [19873]
This is an old revision of AdminActions made by OlivierBorowski on 2008-04-19 11:27:47.
Administration of Actions
This is the development page for the action administration module.
Main goals of this module
- allow finegrained access control on actions (preferably based on ACLs)
- make the "intranet" directory obsolete
- allow WikkaEdit to retrieve the list of installed actions and for each action its description, parameters...
Needed metadata
- action short name = tag name (eg : "files")
- action name (eg : "File upload form")
- action description (eg : "Display a form with file attachments to the current page.")
- parameter 1 short name (eg : "download")
- parameter 1 description (eg : "prints a link to the file specified in the string")
- parameter 1 mandatory (or optional) (boolean)
Where metadata are stored
- header in action file
Action file header contains all the required metadata, prefixed by a specific tag.
- separate data file (best method?)
Data formats :
1) PHP array (best method?)
<?php
$action_infos = array(
'category' => 'hidden',
'tag' => 'image',
'title' => 'Image',
'summary' => 'Display an image.',
'usage' => '',
'params' => array(
'url' => array(
'default_value' => 'url',
'description' => 'Image URL. Can be relative (images/img.png) or external (http://example.com/example.jpg)',
'mandatory' => 1
),
'title' => array(
'default_value' => 'text',
'description' => 'Image title',
'default' => 1
),
'alt' => array(
'default_value' => 'text',
'description' => 'Alternate text when image can\'t be displayed',
'default' => 1
),
'class' => array(
'default_value' => 'className',
'description' => 'Class name (defined in the CSS file)'
),
'link' => array(
'default_value' => 'url',
'description' => 'Add a link to the image'
)
)
);
?>
$action_infos = array(
'category' => 'hidden',
'tag' => 'image',
'title' => 'Image',
'summary' => 'Display an image.',
'usage' => '',
'params' => array(
'url' => array(
'default_value' => 'url',
'description' => 'Image URL. Can be relative (images/img.png) or external (http://example.com/example.jpg)',
'mandatory' => 1
),
'title' => array(
'default_value' => 'text',
'description' => 'Image title',
'default' => 1
),
'alt' => array(
'default_value' => 'text',
'description' => 'Alternate text when image can\'t be displayed',
'default' => 1
),
'class' => array(
'default_value' => 'className',
'description' => 'Class name (defined in the CSS file)'
),
'link' => array(
'default_value' => 'url',
'description' => 'Add a link to the image'
)
)
);
?>
+ fastest
- may introduce some errors (especially with comma or parentheses)
2) INI-file
[action]
category=hidden
tag=image
title=Image
summary=Display an image.
usage=
[url]
default_value=url
description=Image URL. Can be relative (images/img.png) or external (http://example.com/example.jpg)
mandatory=1
[title]
default_value=text
description=Image title
default=1
[alt]
default_value=text
description=Alternate text when image can't be displayed
default=1
[class]
default_value=className
description=Class name (defined in the CSS file)
[link]
default_value=url
description=Image title
category=hidden
tag=image
title=Image
summary=Display an image.
usage=
[url]
default_value=url
description=Image URL. Can be relative (images/img.png) or external (http://example.com/example.jpg)
mandatory=1
[title]
default_value=text
description=Image title
default=1
[alt]
default_value=text
description=Alternate text when image can't be displayed
default=1
[class]
default_value=className
description=Class name (defined in the CSS file)
[link]
default_value=url
description=Image title
+ easiest to read and write
- no hierarchical structure (action and parameters data are mixed together)
3) XML
<action>
<category>hidden</category>
<tag>image</tag>
<title>Image</title>
<summary>Display an image.</summary>
<usage></usage>
<params>
<url>
<default_value>url</default_value>
<description>Image URL. Can be relative (images/img.png) or external (http://example.com/example.jpg)</description>
<mandatory>1</mandatory>
</url>
<title>
<default_value>text</default_value>
<description>Image title</description>
<default>1</default>
</title>
<alt>
<default_value>text</default_value>
<description>Alternate text when image can't be displayed</description>
<default>1</default>
</alt>
<class>
<default_value>className</default_value>
<description>Class name (defined in the CSS file)</description>
</class>
<link>
<default_value>url</default_value>
<description>Image title</description>
</link>
</params>
</action>
<category>hidden</category>
<tag>image</tag>
<title>Image</title>
<summary>Display an image.</summary>
<usage></usage>
<params>
<url>
<default_value>url</default_value>
<description>Image URL. Can be relative (images/img.png) or external (http://example.com/example.jpg)</description>
<mandatory>1</mandatory>
</url>
<title>
<default_value>text</default_value>
<description>Image title</description>
<default>1</default>
</title>
<alt>
<default_value>text</default_value>
<description>Alternate text when image can't be displayed</description>
<default>1</default>
</alt>
<class>
<default_value>className</default_value>
<description>Class name (defined in the CSS file)</description>
</class>
<link>
<default_value>url</default_value>
<description>Image title</description>
</link>
</params>
</action>
- give headaches to read or write
- slow to parse
Caching metadata
Parsing the "/action" directory on each request is too slow. Moreover, additional data like action ACLs can't be stored in the file itself.Solution : add to the database two tables : "wikka_actions" and "wikka_action_params"
CREATE TABLE `wikka_actions` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`tag` VARCHAR(75) NOT NULL,
`title` VARCHAR(75) NOT NULL,
`summary` VARCHAR(200) NOT NULL,
`usage_infos` VARCHAR(400) NOT NULL,
`category` VARCHAR(75) NOT NULL,
`acl` text NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `tag` (`tag`),
KEY `category` (`category`)
) ENGINE=MyISAM;
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`tag` VARCHAR(75) NOT NULL,
`title` VARCHAR(75) NOT NULL,
`summary` VARCHAR(200) NOT NULL,
`usage_infos` VARCHAR(400) NOT NULL,
`category` VARCHAR(75) NOT NULL,
`acl` text NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `tag` (`tag`),
KEY `category` (`category`)
) ENGINE=MyISAM;
CREATE TABLE `wikka_action_params` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(75) NOT NULL,
`description` VARCHAR(400) NOT NULL,
`default_value` VARCHAR(75) NOT NULL,
`is_default` tinyint(1) NOT NULL,
`is_mandatory` tinyint(1) NOT NULL,
`action_tag` VARCHAR(75) NOT NULL,
PRIMARY KEY (`id`),
KEY `name` (`name`),
KEY `action_tag` (`action_tag`)
) ENGINE=MyISAM;
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(75) NOT NULL,
`description` VARCHAR(400) NOT NULL,
`default_value` VARCHAR(75) NOT NULL,
`is_default` tinyint(1) NOT NULL,
`is_mandatory` tinyint(1) NOT NULL,
`action_tag` VARCHAR(75) NOT NULL,
PRIMARY KEY (`id`),
KEY `name` (`name`),
KEY `action_tag` (`action_tag`)
) ENGINE=MyISAM;
"is_default" and "is_mandatory" could be stored in the same field (0=none, 1=default, 2=mandatory)
When metadata cache is updated
These databases are currently updated each time AdminAction is called (an "update action list" link may be a better solution)User interface
The UI is based on UserAdmin and PageAdminAction PageAdmin style.Action Tag | Action Title | ACLS |
---|---|---|
adminpages | Pages administration | * edit |
adminusers | Users administration | * edit |
backlinks | Backlinks | * edit |
calendar | Calendar | * edit |
checkversion | Version checker | * edit |
color | Text color | * edit |
contact | Administrator email address | * edit |
countpages | Count pages | * edit |
countusers | Count users | * edit |
emailpassword | Lost password form | * edit |
image | Image | * edit |
usersettings | My user settings | * edit |
countcomments | Count comments | * edit |
countowned | Count owned | * edit |
category | Category | * edit |
CategoryDevelopment