diff options
author | Fabio Varesano <fax8@13637.no-reply.drupal.org> | 2005-07-03 12:27:45 +0000 |
---|---|---|
committer | Fabio Varesano <fax8@13637.no-reply.drupal.org> | 2005-07-03 12:27:45 +0000 |
commit | 1187c6d8afc79e67914d97026648b69621ecad16 (patch) | |
tree | 632295f508821f90659ff279dc131827a4e43d1c | |
parent | b5af38f899b7c7f125eb44d6b5c29303baffab4d (diff) | |
download | video-1187c6d8afc79e67914d97026648b69621ecad16.tar.gz video-1187c6d8afc79e67914d97026648b69621ecad16.tar.bz2 |
Added tests for required video field.
(videfile, size, videox, videoy)
-rw-r--r-- | TODO.txt | 2 | ||||
-rw-r--r-- | video.module | 40 |
2 files changed, 33 insertions, 9 deletions
@@ -1,8 +1,6 @@ TODO LIST (in order of importance) ----------- -- Write more documentation (help) - for this module - Figure out how to make Windows Media files play with relative URL in addition to a fully qualified one diff --git a/video.module b/video.module index c07defd..8de1995 100644 --- a/video.module +++ b/video.module @@ -334,18 +334,44 @@ function video_delete(&$node) { } /** - * Hook to see if a video exists already or not + * Hook to see if every video field has been submitted + * and contains a valid value. * * @param $node * object */ function video_validate(&$node) { - $result = db_query("SELECT * from {video} WHERE vidfile = '%s' and nid <> '%d'", $node->vidfile, $node->nid); - if (db_num_rows($result) > 0) { - $video = db_fetch_object($result); - $othernode = node_load(array('nid' => $video->nid)); - form_set_error('video', t('A video %link-to-existing using that link already exists', array("%link-to-existing" => l($othernode->title, 'node/' . $othernode->nid . '/edit')))); + //control needed fields + if(isset($node->vidfile)) { + if($node->vidfile == '') { + form_set_error('vidfile', t('You have to insert a valid file path for this video')); + } + else { + //let's see if we have it yet + $result = db_query("SELECT * from {video} WHERE vidfile = '%s' and nid <> '%d'", $node->vidfile, $node->nid); + if (db_num_rows($result) > 0) { + $video = db_fetch_object($result); + $othernode = node_load(array('nid' => $video->nid)); + form_set_error('vidfile', t('A video %link-to-existing using that link already exists', array("%link-to-existing" => l($othernode->title, 'node/' . $othernode->nid . '/edit')))); + } + } + } + + if(isset($node->videox) && $node->videox <= 0) { + form_set_error('videox', t('You have to insert a valid horizontal pixel size for this video')); + } + if(isset($node->videoy) && $node->videoy <= 0) { + form_set_error('videoy', t('You have to insert a valid vertical pixel size for this video')); + } + if(isset($node->size) && $node->size <= 0) { + form_set_error('videoy', t('You have to insert a valid file size for this video')); } +/* this doesn't work.. maybe someone can get it work.. + if((isset($node->playtime_minutes) && $node->playtime_minutes <= 0) || (isset($node->playtime_hours) && $node->playtime_hours <= 0) || (isset($node->playtime_seconds) && $node->playtime_seconds <= 0)) { + form_set_error('playtime_seconds', t('You have to insert valid playtime informations for this video')); + } +*/ + } /** @@ -575,7 +601,7 @@ function video_play() { /** * Themeable functions for playing videos. - * It prints a page with a quicktime player inside + * It prints a page with a player embedded * linked to the file record of the node. */ |