<?php
/* Definition of database tables.
*
* Written by: Chris Studholme
* Copyright: GPL (http://www.fsf.org/copyleft/gpl.html)
* $Id: tables.php,v 1.17 2003/12/23 06:07:15 cstudhol Exp $
*/
require("include/db_schema.php");
/* Notes regarding field descriptions:
* (multilingual) - value is a serialized associative php array
* with language as key and strings for values
* (php-array) - serialized general php array
* (CSV) - comma serparated value list
* obsolete - no longer used but can't be deleted because
* it was "not null" in the past
*/
$db_tables = array();
// master configuration data
$db_tables[] =
new db_table("config", array("key"), array(),
array(new db_field("key","varchar(32) not null"), // key (reserved word => must change)
new db_field("type","varchar(32)"), // type of value
new db_field("value","text"), // value
new db_field("description","text"), // description of value
new db_field("date_update","timestamp"), // date of last update
)
);
// query cache
$db_tables[] =
new db_table("cache", array("hash"), array(),
array(new db_field("hash","varchar(32) not null"), // hash of select query
new db_field("data","text"), // query results (php array)
new db_field("date_create","timestamp"), // date entry created
)
);
// image types
$db_tables[] =
new db_table("types",array("typeid"), array(),
array(new db_field("typeid","int not null"), // id (min 1, max 30, -1 thumbnail)
new db_field("name","text"), // name of type (multilingual)
//new db_field("name_plural","text"), // plural name (multilingual)
new db_field("preference","int"), // preferred order
new db_field("filename_prefix","text"), // filename prefix
new db_field("filename_suffix","text"), // filename suffix
new db_field("options_type","text"), // image options (php array)
new db_field("mimetype_src","text"), // mimetype of source (CSV)
new db_field("mimetype_dest","text"), // mimetype of destination
new db_field("date_update","timestamp"), // date of last update
)
);
// image sources (camera types)
$db_tables[] =
new db_table("sources",array("srcid"), array(),
array(new db_field("srcid","int not null"), // id
new db_field("description","text"), // description of source
new db_field("detect","text"), // detection parameters (php array)
new db_field("options_src","text"), // image options (php array)
new db_field("date_update","timestamp"), // date of last update
)
);
// list of keywords defined by administrator
$db_tables[] =
new db_table("keywords", array("wordid"), array(),
array(new db_field("wordid","int not null"), // id
new db_field("lang","varchar(8)"), // language (obsolete)
new db_field("word","text not null"), // the keyword (multilingual)
new db_field("nosearch","smallint"), // 1=can't search
new db_field("nopref","smallint"), // 1=can't use in preferences
)
);
// list of groups to which persons might belong
$db_tables[] =
new db_table("groups", array("groupid"), array(),
array(new db_field("groupid","int not null"), // id
new db_field("name_group","text"), // group name
new db_field("nosearch","smallint"), // 1=can't search
)
);
// list of persons who might appear in pictures
$db_tables[] =
new db_table("persons", array("personid"), array(),
array(new db_field("personid","int not null"), // id
new db_field("name_last","text"), // last name
new db_field("name_first","text"), // first (and other) names
new db_field("comment","text"), // private comment
new db_field("nosearch","smallint"), // 1=can't search
)
);
// groups to which each person belongs
$db_tables[] =
new db_table("person_groups", array("personid","groupid"), array("groupid"),
array(new db_field("personid","int not null"), // person id
new db_field("groupid","int not null"), // group id
)
);
// login name/password list
$db_tables[] =
new db_table("users", array("userid"), array("login"),
array(new db_field("userid","int not null"), // id
new db_field("login","varchar(32)"), // login name
new db_field("password","text"), // password (md5 encrypted)
new db_field("wordids_require","text"), // required keywords (CSV)
new db_field("wordids_deny","text"), // deny access to these pictures (CSV)
new db_field("wordids_search_default","text"), // default for new cookies (CSV)
new db_field("wordids_deny_default","text"), // default for new cookies (CSV)
new db_field("date_create","timestamp"), // date of creation
new db_field("date_update","timestamp"), // date of last update
new db_field("date_login","timestamp"), // date of last login
new db_field("admin","smallint"), // 1=administrator
)
);
// list of cookies given out
$db_tables[] =
new db_table("cookies", array("cookie"), array("cid"),
array(new db_field("cid","int not null"), // cookie id
new db_field("cookie","varchar(32) not null"), // cookie
new db_field("newcookie","varchar(32)"), // cookie to change to
new db_field("userid","int"), // user last logged in as
new db_field("addr","varchar(64)"), // address of last login
new db_field("date_create","timestamp"), // date of creation
new db_field("date_update","timestamp"), // date of last change
new db_field("date_login","timestamp"), // date of last login
//new db_field("type","text"), // preferred start page
new db_field("typeid","int"), // preferred image type
new db_field("lang","varchar(8)"), // preferred language
new db_field("name_caption","text"), // name for captions
new db_field("name_toc","text"), // name for public toc entries
new db_field("wordids_search","text"), // searched keywords (CSV list)
new db_field("wordids_deny","text"), // prevent showing of these pictures
new db_field("admin","smallint"), // 1=administrator
)
);
// list of pictures in photo album
$db_tables[] =
new db_table("pictures", array("picid"), array("type","path_thumb"),
array(new db_field("picid","int not null"), // id
new db_field("type","int not null"), // bitmap of types available
new db_field("srcid","int"), // source of image
new db_field("options_pic","text"), // image options (php array)
new db_field("path_thumb","text not null"), // path to thumbnail picture
new db_field("path_photos","text"), // path to photos (php array)
new db_field("path_original","text"), // path to original picture
new db_field("mimetype_original","text"), // mimetype of original
new db_field("date","timestamp"), // date picture was taken
new db_field("date_type","smallint"), // 0=date/time 1=date 2=guess
new db_field("date_update","timestamp"), // date of last record update
new db_field("date_update_image","timestamp"), // date of last image update
new db_field("date_view","timestamp"), // date of last viewing
new db_field("addr_view","varchar(64)"), // address of last viewing
new db_field("count_view","int"), // total number of viewings
)
);
// captions for each picture
$db_tables[] =
new db_table("picture_captions", array("picid","cid"), array("cid"),
array(new db_field("picid","int not null"), // id
new db_field("cid","int not null"), // cookie who posted
new db_field("addr","varchar(64)"), // address of who updated
new db_field("userid","int"), // user who updated
new db_field("name","text"), // name of poster (optional)
new db_field("caption","text"), // the caption (multilingual)
new db_field("lang","varchar(8)"), // language of caption (obsolete)
new db_field("date_create","timestamp"), // date of creation
new db_field("date_update","timestamp"), // date of last update
)
);
// keywords associated with each picture
$db_tables[] =
new db_table("picture_keywords", array("picid","wordid"), array("wordid"),
array(new db_field("picid","int not null"), // id
new db_field("wordid","int not null"), // id
)
);
// persons appearing in each picture
$db_tables[] =
new db_table("picture_persons", array("picid","personid"), array("personid"),
array(new db_field("picid","int not null"), // id
new db_field("personid","int not null"), // id
new db_field("location","text"), // where person is in picture
)
);
// table of contents (both public and private collections)
$db_tables[] =
new db_table("toc", array("collid"), array("cid"),
array(new db_field("collid","int not null"), // collection id
new db_field("cid","int"), // cookie for favorite collection
new db_field("forall","smallint"), // 1=visible to all
new db_field("seq","int"), // sequence
new db_field("name","text"), // short name of collection (multilingual)
new db_field("description","text"), // description of collection (multilingual)
new db_field("photographer","text"), // who are the photos credited to
new db_field("options_col","text"), // image options (php array)
new db_field("date_start","date"), // start date of photos
new db_field("date_end","date"), // end date of photos
new db_field("date_create","timestamp"), // date of creation
new db_field("date_update","timestamp"), // date of last update
)
);
// mapping of pictures to collections (and preferred ordering)
$db_tables[] =
new db_table("toc_pictures", array("collid","picid"), array("picid"),
array(new db_field("collid","int not null"), // collection id
new db_field("picid","int not null"), // picture id
new db_field("seq","int"), // sequence
)
);
// language dependent names and descriptions of toc entries (obsolete)
$db_tables[] =
new db_table("toc_names", array("collid","lang"), array(),
array(new db_field("collid","int not null"), // collection id
new db_field("lang","varchar(8)"), // language of name and desc
new db_field("name","text"), // short name of collection
new db_field("description","text"), // description of collection
)
);
$db_tables_defaults = array();
// default values for the config table
$db_tables_defaults["config"] =
array(
array("key"=>"db_version",
"type"=>"float",
"value"=>strval($DB_VERSION),
"description"=>"Current version of database tables."),
array("key"=>"copyright_name",
"type"=>"text",
"value"=>"Someone",
"description"=>"Full name of person to be considered coppyright owner of the content of the photo album (pictures and such)."),
array("key"=>"copyright_email",
"type"=>"text",
"value"=>"someone@somewhere.com",
"description"=>"Email address of copyright owner."),
array("key"=>"siteadmin_name",
"type"=>"text",
"value"=>"Someone",
"description"=>"Full name of site administrator."),
array("key"=>"siteadmin_email",
"type"=>"text",
"value"=>"someone@somewhere.com",
"description"=>"Email address of site administrator."),
array("key"=>"survey_email",
"type"=>"text",
"value"=>"someone@somewhere.com",
"description"=>"Email address to send comments to."),
array("key"=>"toc_max_entries",
"type"=>"int",
"value"=>"40",
"description"=>"Maximum number of TOC entries to display on one page."),
array("key"=>"toc_min_entries",
"type"=>"int",
"value"=>"20",
"description"=>"Minimum number of TOC entries to display on one page."),
array("key"=>"toc_overlap",
"type"=>"int",
"value"=>"1",
"description"=>"Number of TOC entries that overlap from one page to next."),
array("key"=>"thumb_max_entries",
"type"=>"int",
"value"=>"100",
"description"=>"Maximum number of photos to display on one page."),
array("key"=>"thumb_min_entries",
"type"=>"int",
"value"=>"20",
"description"=>"Minimum number of photos to display on one page."),
array("key"=>"thumb_overlap",
"type"=>"int",
"value"=>"1",
"description"=>"Number of photos that overlap from one page to next."),
array("key"=>"allow_custom",
"type"=>"boolean",
"value"=>"1",
"description"=>"Allow users to create custom versions of images."),
array("key"=>"allow_caption",
"type"=>"boolean",
"value"=>"1",
"description"=>"Allow users to add/edit captions."),
array("key"=>"allow_prefs",
"type"=>"boolean",
"value"=>"1",
"description"=>"Allow users to change their preferences."),
array("key"=>"default_lang",
"type"=>"language",
"value"=>$default_lang,
"description"=>"Default language."),
array("key"=>"default_style",
"type"=>"stylesheet",
"value"=>$default_style,
"description"=>"Default stylesheet."),
array("key"=>"auth_cookielogin_timelimit",
"type"=>"int",
"value"=>"90",
"description"=>"Maximum number of days that are allowed to pass between logins of a particular user w/o requiring a password to be entered. Set to 0 to disable cookielogin feature."),
array("key"=>"auth_cookielogin_location",
"type"=>"boolean",
"value"=>"1",
"description"=>"Set to yes to limit cookie logins (login w/o password) to users returning from the same address they previously logged in from."),
array("key"=>"auth_realm",
"type"=>"text",
"value"=>"Virtual Photo Album",
"description"=>"Realm for basic authentication."),
array("key"=>"options_global",
"type"=>"image_options",
"value"=>"a:1:{s:5:\"gamma\";d:1;}",
"description"=>"Global image processing parameters."),
);
// default values for types table
$db_tables_defaults["types"] =
array(
array("typeid"=>-1,
"name"=>array("en"=>"Thumbnail"),
//"name_plural"=>array("en"=>"Thumbnails"),
"preference"=>0,
"filename_prefix"=>"",
"filename_suffix"=>"t.jpg",
"options_type"=>array("bound"=>array(128,128),"jpeg_qual"=>75),
//"mimetype_src"=>, // ANY
"mimetype_dest"=>"image/jpeg"),
array("typeid"=>1,
"name"=>array("en"=>"Little Photo"),
//"name_plural"=>array("en"=>"Little Photos"),
"preference"=>1,
"filename_prefix"=>"",
"filename_suffix"=>"l.jpg",
"options_type"=>array("bound"=>array(512,480),"jpeg_qual"=>85),
//"mimetype_src"=>"", // ANY
"mimetype_dest"=>"image/jpeg"),
array("typeid"=>2,
"name"=>array("en"=>"Big Photo"),
//"name_plural"=>array("en"=>"Big Photos"),
"preference"=>2,
"filename_prefix"=>"",
"filename_suffix"=>"b.jpg",
"options_type"=>array("bound"=>array(768,600),"jpeg_qual"=>90),
//"mimetype_src"=>"", // ANY
"mimetype_dest"=>"image/jpeg"),
array("typeid"=>3,
"name"=>array("en"=>"Mini-movie"),
//"name_plural"=>array("en"=>"Mini-movies"),
"preference"=>3,
"filename_prefix"=>"",
"filename_suffix"=>".gif",
"options_type"=>array(),
"mimetype_src"=>"application/x-tar",
"mimetype_dest"=>"image/gif"),
);
// default values for sources table
$db_tables_defaults["sources"] =
array(
array("srcid"=>1,
"description"=>"PhotoCD",
"options_src"=>array("gamma"=>1),
"detect"=>array()),
array("srcid"=>2,
"description"=>"Scanned Prints",
"options_src"=>array("gamma"=>1),
"detect"=>array()),
array("srcid"=>3,
"description"=>"Canon PowerShot S300",
"options_src"=>array("gamma"=>1),
"detect"=>array()),
array("srcid"=>4,
"description"=>"Kodak DC120",
"options_src"=>array("gamma"=>1),
"detect"=>array()),
array("srcid"=>5,
"description"=>"Kodak DC240",
"options_src"=>array("gamma"=>1),
"detect"=>array()),
array("srcid"=>6,
"description"=>"Kodak DC265",
"options_src"=>array("gamma"=>1),
"detect"=>array()),
array("srcid"=>7,
"description"=>"Nikon CoolPix 950",
"options_src"=>array("gamma"=>1),
"detect"=>array()),
array("srcid"=>8,
"description"=>"Nikon CoolPix 990",
"options_src"=>array("gamma"=>1),
"detect"=>array()),
);
?>