Permissions on CCK node fields
I put together a quick module to allow admins to restrict some CCK fields based on user roles. You can check it out here:
update: This is a real module now, see: http://drupal.org/project/cck_field_perms
I put together a quick module to allow admins to restrict some CCK fields based on user roles. You can check it out here:
update: This is a real module now, see: http://drupal.org/project/cck_field_perms
Here’s the cleaned up version of the media mover hook. Changes are: renamed “new_config” to “new config”, added “edit config”, created support for editing and deleting individual configurations. There’s quite a bit of clean up on the main media_mover module in this round, but obviously there is a fair bit to go, particularly in the admin side of things.
I’m considering adding a testing option into the hook to provide the admin an opportunity to run a config and see live error reporting on a specific configuration. Since there are potentially so many places for issues, it would be nice to get a report instead of digging through drupal’s error logs.
Additionally, while the module currently runs on cron, I’d like to expose each configuration (ie: a set of harvest, process, and store settings) as an action so that a specific configuration can be run via workflows. Originally, I had planned on integrating this system directly with workflows, but I think this is a better way to integrate because of the tight integration between the three parts of the process.
/**
* Implementation of media_mover hook
*/
function media_mover_media_mover($op, $action = null, $configuration = null, &$file = array() ) {
switch ($op) {
// give your driver a distinct name
case 'name':
return "Media Mover module";
break;
// create a new configuration option set
// $action is used to ensure namespacing is kept consistent, form
// elements must be named $form[{$action}:your variable name]
// returns a form array
case 'new config':
switch($action){
case "harvest:select drupal uploaded files":
return _media_mover_admin_harvest_new_config($action);
break;
}
break;
// create edit configuration option set
// $action is used to ensure namespacing is kept consistent, form
// elements must be named $form[{$action}:your variable name]
// $configuration is an array, settings stored on a per config basis
case 'edit config':
switch($action){
case "harvest:select drupal uploaded files":
return _media_mover_admin_harvest_edit_config($action, $configuration);
break;
}
break;
// set standard configuration for this module
// displayed on admin/settings/media_mover
// returns a form array
case 'admin':
return _media_mover_admin();
break;
// defines what type of driver this module is
// array of harvest, process, storage
// a module may operate more than one verb
case 'verbs':
return array("harvest");
break;
// defines the name of what this module does
// array of definitions
case 'actions':
return array("select drupal uploaded files");
break;
// defines directories (under master media_mover directory)
// this module uses
// array of directories, will be created under the default
// media_mover directory, set in admin
case 'directories':
break;
// allows for module to add additional data in a different db
// add file to db action. called from media_mover's mm_files_db_add
// by default, medial_mover's files table is used. $file is available
case 'add':
break;
// allows for module to fetch additional data
// added to $file to db action. called from media_mover's mm_files_db_fetch
// by default, medial_mover's files table is used. $file is available
case 'fetch':
break;
// allows for module to update additional critera
// add file to db action. called from media_mover's mm_files_db_update
// by default, medial_mover's files table is used. $file is available
case 'update':
break;
// functions called on harvest op
// returns an array of $files
case 'harvest':
return _mm_harvest();
break;
// functions called on process op
case 'process':
break;
// functions called on storage op
case 'storage':
break;
// custom theme a file assoicated with this module
case 'theme':
break;
default:
return;
break;
}
return;
}
I’ve been working over the weekend to finish up the media mover hook system. I think I’ve finally finished out the final form of the hook and the different options that are available. Here’s a commented version of what I’m using in the media_mover.inc file
/**
* Implementation of media_mover hook
*/
function media_mover_media_mover($op, $action = null, $config = null, &$file = array() ) {
switch ($op) {
// give your driver a name
case 'name':
return "Media Mover module";
break;
// create a new configuration option set
// $type is used to ensure namespacing is kept consistent
// in the form xname space.
// returns a form array
case 'new_config':
switch($action){
case "harvest:select drupal uploaded files":
return _media_mover_admin_harvest_config($action);
break;
}
break;
// set standard configuration for this module
// displayed on admin/settings/media_mover
// returns a form array
case 'admin':
return _media_mover_admin();
break;
// defines what type of driver this module is
// array of harvest, process, storage
case 'verbs':
return array("harvest");
break;
// defines the name of what this module does
// array of definitions
case 'actions':
return array("select drupal uploaded files");
break;
// defines directories (under master media_mover directory)
// this module uses
// array of directories, will be created under the default
// media_mover directory, set in admin
case 'directories':
break;
// allows for module to add additional data in a different db
// add file to db action. called from media_mover's mm_files_db_add
// by default, medial_mover's files table is used. $file is available
case 'add':
break;
// allows for module to fetch additional data
// add file to db action. called from media_mover's mm_files_db_fetch
// by default, medial_mover's files table is used. $file is available
case 'fetch':
break;
// allows for module to update additional critera
// add file to db action. called from media_mover's mm_files_db_update
// by default, medial_mover's files table is used. $file is available
case 'update':
break;
// functions called on harvest op
// returns an array of $files
case 'harvest':
return _mm_harvest();
break;
// functions called on process op
case 'process':
break;
// functions called on storage op
case 'storage':
break;
// custom theme a file assoicated with this module
case 'theme':
break;
default:
return;
break;
}
return;
}
update 12/9/06:
I’ve done quite a bit of working pulling together and administrative system. It’s by no means polished, but the database is storing each set of configurations (for harvest, process, and storage) and can pull each of these out for each run of of the configuration. This means that it’s possible to have multiple runs of say a video conversion with different conversion rates.
The media_mover hook is almost stable at this point, the major piece left is the “save” function which keeps track of how files were moved around and created.
—-
For a few reasons, I’ve decided to announce the media mover module long before it’s ready for complete release. One is that it’s clear other people in the drupal community are really looking to tackle media handling, particularly video processing, another is that it’s high time that I get the code that I did for flunk arnold project out into the world in a more public way.
So first the disclaimer: this code is raw. It’s not been baked yet at all. That being said, the rough concept is in place.
What it is
The Media Mover module is a module which allows admins to setup a media move process which gathers files, processes them and stores them. Media Mover does little on its own- it calls a set of modules which implement the media_mover hook and plugs them together in to media mover scripts.
What it does
Media mover is a handler module for a set of driver modules. It basically runs the three types of actions that any one media move can have: harvest, process, storage.
Currently I have a harvest process which uses the drupal files table, a process process which uses ffmpeg to convert video files, and an amazon s3 module which stores the completed files on amazon. I have to build the administrative side of things, but I have it running now so that you can pass in something like:
$config->harvest->module = "media_mover";
$config->harvest->action = "db";
$config->process->module = "mm_ffmpeg";
$config->process->action = "create thumbnail from video";
$config->process->configuration = "";
$config->storage->module = "mm_s3";
$config->storage->action = "move file to amazon s3 service";
$configurations[] = $config;What’s kind of fun about this is that you can stuff these configs into an array, and process the media again to do something different, eg, duplicating the above and changing the process action to:
$config->process->action = "convert video";Which would go back through the same files and process the uploaded files and turn them into videos.
I still have a fair bit of abstracting, code clean up and error handling to implement, but I created a hook media_mover which allows you to create your own handler:
function media_mover_media_mover($op, &$file = array()) {
switch ($op) {
case 'name':
return "Media Mover module";
break;case ‘configuration’:break;case ‘admin’:case ‘actions’:
return array(1 => “select drupal uploaded files”);
break;
case ‘directories’:
return array(’converted’, ‘converted/thumbnails’);
break;
case ‘harvest’:
return _mm_get_list_of_files();
break;
case ‘process’:
break;
case ’storage’:
break;
default:
return;
break;
}
return;
}
There is a large amount of work to go, particularly writing a configuration system that is allows admins to sets of configurations, however, I think things are exciting enough to start imaging what kind of modules could be built…. let’s see:
Since it’s now possible to use it, I think I’m getting close to wanting to solicit comments, however, until I build the configuration builder, it’s only really useful for admins.
I’ll be posting updates as things progress. This code is going to be public available and will be through out the development process.
Please note, this tarball includes the Storage3 amazon library from http://blog.apokalyptik.com/Storage3/ and some pear libraries. Don’t expect this to work if you’re downloading it. Do expect to look at the media_mover hook and think about how 1) it could be better 2) how to make some amazing module that could plug into this