plugins/Gallery.php
changeset 42 7c6e2e97aa08
parent 39 e9a7e37bdadd
equal deleted inserted replaced
41:0944c9354e9c 42:7c6e2e97aa08
     1 <?php
     1 <?php
     2 /**!info**
     2 /**!info**
     3 {
     3 {
     4   "Plugin Name"  : "Snapr",
     4 	"Plugin Name"  : "Snapr",
     5   "Plugin URI"   : "http://enanocms.org/plugin/snapr",
     5 	"Plugin URI"   : "http://enanocms.org/plugin/snapr",
     6   "Description"  : "Provides an intuitive image gallery system with a browser, viewer for individual images, upload interface, and comment system integration.",
     6 	"Description"  : "Provides an intuitive image gallery system with a browser, viewer for individual images, upload interface, and comment system integration.",
     7   "Author"       : "Dan Fuhry",
     7 	"Author"       : "Dan Fuhry",
     8   "Version"      : "0.1b3",
     8 	"Version"      : "0.1b4",
     9   "Author URI"   : "http://enanocms.org/",
     9 	"Author URI"   : "http://enanocms.org/",
    10   "Version list" : ['0.1b1', '0.1b2', '0.1 beta 3', '0.1b3']
    10 	"Version list" : ['0.1b1', '0.1b2', '0.1 beta 3', '0.1b3', '0.1b4']
    11 }
    11 }
    12 **!*/
    12 **!*/
    13 
    13 
    14 global $db, $session, $paths, $template, $plugins; // Common objects
    14 global $db, $session, $paths, $template, $plugins; // Common objects
    15 
    15 
    16 define('GALLERY_VERSION', '0.1b2');
    16 define('GALLERY_VERSION', '0.1b2');
    17 
    17 
    18 if ( !defined('ENANO_ATLEAST_1_1') )
    18 if ( !defined('ENANO_ATLEAST_1_1') )
    19 {
    19 {
    20   $fn = basename(__FILE__);
    20 	$fn = basename(__FILE__);
    21   setConfig("plugin_$fn", '0');
    21 	setConfig("plugin_$fn", '0');
    22   die_semicritical('Snapr can\'t load on this site', '<p>This version of Snapr requires Enano 1.1.6 or later.</p>');
    22 	die_semicritical('Snapr can\'t load on this site', '<p>This version of Snapr requires Enano 1.1.6 or later.</p>');
    23 }
    23 }
    24 
    24 
    25 $magick_path = getConfig('imagemagick_path', '/usr/bin/convert');
    25 $magick_path = getConfig('imagemagick_path', '/usr/bin/convert');
    26 $have_gd_scale_support = function_exists('imagecreatetruecolor') && function_exists('imagejpeg') && function_exists('imagecopyresampled');
    26 $have_gd_scale_support = function_exists('imagecreatetruecolor') && function_exists('imagejpeg') && function_exists('imagecopyresampled');
    27 if ( (!file_exists($magick_path) || !is_executable($magick_path)) && !$have_gd_scale_support )
    27 if ( (!file_exists($magick_path) || !is_executable($magick_path)) && !$have_gd_scale_support )
    28 {
    28 {
    29   $fn = basename(__FILE__);
    29 	$fn = basename(__FILE__);
    30   // set disabled flag with new plugin system
    30 	// set disabled flag with new plugin system
    31   if ( defined('ENANO_ATLEAST_1_1') && defined('PLUGIN_DISABLED') )
    31 	if ( defined('ENANO_ATLEAST_1_1') && defined('PLUGIN_DISABLED') )
    32   {
    32 	{
    33     $q = $db->sql_query('UPDATE ' . table_prefix . "plugins SET plugin_flags = plugin_flags | " . PLUGIN_DISABLED . " WHERE plugin_filename = 'Gallery.php';");
    33 		$q = $db->sql_query('UPDATE ' . table_prefix . "plugins SET plugin_flags = plugin_flags | " . PLUGIN_DISABLED . " WHERE plugin_filename = 'Gallery.php';");
    34     if ( !$q )
    34 		if ( !$q )
    35       $db->_die();
    35 			$db->_die();
    36 	  
    36 	  
    37     // kill off cache
    37 		// kill off cache
    38     global $cache;
    38 		global $cache;
    39     $cache->purge('plugins');
    39 		$cache->purge('plugins');
    40   }
    40 	}
    41   else
    41 	else
    42   {
    42 	{
    43     // old plugin system
    43 		// old plugin system
    44     setConfig("plugin_$fn", '0');
    44 		setConfig("plugin_$fn", '0');
    45   }
    45 	}
    46   
    46 	
    47   die_semicritical('Snapr can\'t load on this site', '<p>You must have ImageMagick or GD installed and working to use this plugin. The plugin has been disabled, please setup ImageMagick and then re-enable it.</p>');
    47 	die_semicritical('Snapr can\'t load on this site', '<p>You must have ImageMagick or GD installed and working to use this plugin. The plugin has been disabled, please setup ImageMagick and then re-enable it.</p>');
    48 }
    48 }
       
    49 
       
    50 $plugins->attachHook('pgsql_set_serial_list', '$primary_keys[table_prefix."gallery"] = "img_id";');
    49 
    51 
    50 /**!install dbms="mysql"; **
    52 /**!install dbms="mysql"; **
    51 
    53 
    52 CREATE TABLE {{TABLE_PREFIX}}gallery(
    54 CREATE TABLE {{TABLE_PREFIX}}gallery(
    53 	img_id int(12) NOT NULL auto_increment,
    55 	img_id int(12) NOT NULL auto_increment,
    57 	img_desc longtext NOT NULL DEFAULT '',
    59 	img_desc longtext NOT NULL DEFAULT '',
    58 	print_sizes longtext NOT NULL DEFAULT '',
    60 	print_sizes longtext NOT NULL DEFAULT '',
    59 	img_filename varchar(255) NOT NULL,
    61 	img_filename varchar(255) NOT NULL,
    60 	img_time_upload int(12) NOT NULL DEFAULT 0,
    62 	img_time_upload int(12) NOT NULL DEFAULT 0,
    61 	img_time_mod int(12) NOT NULL DEFAULT 0,
    63 	img_time_mod int(12) NOT NULL DEFAULT 0,
       
    64 	img_author int(12) NOT NULL DEFAULT 1,
    62 	img_tags longtext,
    65 	img_tags longtext,
    63 	PRIMARY KEY ( img_id )
    66 	PRIMARY KEY ( img_id )
    64 );
    67 );
    65 
    68 
    66 CREATE FULLTEXT INDEX {{TABLE_PREFIX}}gal_idx ON {{TABLE_PREFIX}}gallery(img_title, img_desc);
    69 CREATE FULLTEXT INDEX {{TABLE_PREFIX}}gal_idx ON {{TABLE_PREFIX}}gallery(img_title, img_desc);
    89 **!*/
    92 **!*/
    90 
    93 
    91 /**!upgrade dbms="mysql"; from="0.1 beta 3"; to="0.1b3"; **
    94 /**!upgrade dbms="mysql"; from="0.1 beta 3"; to="0.1b3"; **
    92 **!*/
    95 **!*/
    93 
    96 
       
    97 /**!upgrade dbms="mysql"; from="0.1b3"; to="0.1b4"; **
       
    98 ALTER TABLE {{TABLE_PREFIX}}gallery ADD COLUMN img_author int(12) NOT NULL DEFAULT 1;
       
    99 ALTER TABLE {{TABLE_PREFIX}}gallery ADD COLUMN processed tinyint(1) NOT NULL DEFAULT 1;
       
   100 -- Set all images to authorship by the first administrator we can find
       
   101 UPDATE {{TABLE_PREFIX}}gallery SET img_author = ( SELECT user_id FROM {{TABLE_PREFIX}}users WHERE user_level = 9 ORDER BY user_id DESC LIMIT 1 ), processed = 1;
       
   102 
       
   103 **!*/
       
   104 
    94 require( ENANO_ROOT . '/plugins/gallery/functions.php' );
   105 require( ENANO_ROOT . '/plugins/gallery/functions.php' );
    95 require( ENANO_ROOT . '/plugins/gallery/nssetup.php' );
   106 require( ENANO_ROOT . '/plugins/gallery/nssetup.php' );
    96 require( ENANO_ROOT . '/plugins/gallery/viewimage.php' );
   107 require( ENANO_ROOT . '/plugins/gallery/viewimage.php' );
    97 require( ENANO_ROOT . '/plugins/gallery/browser.php' );
   108 require( ENANO_ROOT . '/plugins/gallery/browser.php' );
    98 require( ENANO_ROOT . '/plugins/gallery/upload.php' );
   109 require( ENANO_ROOT . '/plugins/gallery/upload.php' );