/**
 * creates all tables for the gallery
 * called during register_activation hook
 * 
 * @access internal
 * @return void
**/
function flag_install()
{
    global $wpdb, $wp_version;
    // Check for capability
    if (!current_user_can('activate_plugins')) {
        return;
    }
    flag_capabilities();
    // upgrade function changed in WordPress 2.3
    require_once ABSPATH . 'wp-admin/includes/upgrade.php';
    // add charset & collate like wp core
    $charset_collate = '';
    if ($wpdb->has_cap('collation')) {
        if (!empty($wpdb->charset)) {
            $charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset}";
        }
        if (!empty($wpdb->collate)) {
            $charset_collate .= " COLLATE {$wpdb->collate}";
        }
    }
    $flagpictures = $wpdb->prefix . 'flag_pictures';
    $flaggallery = $wpdb->prefix . 'flag_gallery';
    $flagcomments = $wpdb->prefix . 'flag_comments';
    $flagalbum = $wpdb->prefix . 'flag_album';
    if ($wpdb->get_var("show tables like '{$flagpictures}'") != $flagpictures) {
        $sql = "CREATE TABLE " . $flagpictures . " (\r\n\t\tpid BIGINT(20) NOT NULL AUTO_INCREMENT ,\r\n\t\tgalleryid BIGINT(20) DEFAULT '0' NOT NULL ,\r\n\t\tfilename VARCHAR(255) NOT NULL ,\r\n\t\tdescription MEDIUMTEXT NULL ,\r\n\t\talttext MEDIUMTEXT NULL ,\r\n\t\tlink TEXT NULL ,\r\n\t\timagedate DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',\r\n\t\tmodified TIMESTAMP NOT NULL ON UPDATE CURRENT_TIMESTAMP,\r\n\t\texclude TINYINT NULL DEFAULT '0',\r\n\t\tsortorder BIGINT(20) DEFAULT '0' NOT NULL ,\r\n\t\tlocation TEXT,\r\n\t\tcity TINYTEXT,\r\n\t\tstate TINYTEXT,\r\n\t\tcountry TINYTEXT,\r\n\t\tcredit TEXT,\r\n\t\tcopyright TEXT,\r\n\t\tcommentson INT(1) UNSIGNED NOT NULL DEFAULT '1',\r\n\t\thitcounter INT(11) UNSIGNED DEFAULT '0',\r\n\t\ttotal_value INT(11) UNSIGNED DEFAULT '0',\r\n\t\ttotal_votes INT(11) UNSIGNED DEFAULT '0',\r\n\t\tused_ips LONGTEXT,\r\n\t\tmeta_data LONGTEXT,\r\n\t\tPRIMARY KEY pid (pid)\r\n\t\t) {$charset_collate};";
        dbDelta($sql);
    }
    if ($wpdb->get_var("show tables like '{$flaggallery}'") != $flaggallery) {
        $sql = "CREATE TABLE " . $flaggallery . " (\r\n\t\tgid BIGINT(20) NOT NULL AUTO_INCREMENT ,\r\n\t\tname VARCHAR(255) NOT NULL ,\r\n\t\tpath MEDIUMTEXT NULL ,\r\n\t\ttitle MEDIUMTEXT NULL ,\r\n\t\tgaldesc MEDIUMTEXT NULL ,\r\n\t\tpreviewpic BIGINT(20) NULL DEFAULT '0' ,\r\n\t\tsortorder BIGINT(20) DEFAULT '0' NOT NULL ,\r\n\t\tauthor BIGINT(20) NOT NULL DEFAULT '0' ,\r\n\t\tstatus TINYINT NULL DEFAULT '0' ,\r\n\t\tPRIMARY KEY gid (gid)\r\n\t\t) {$charset_collate};";
        dbDelta($sql);
    }
    if ($wpdb->get_var("show tables like '{$flagcomments}'") != $flagcomments) {
        $sql = "CREATE TABLE " . $flagcomments . " (\r\n\t\tcid int(11) unsigned NOT NULL auto_increment,\r\n\t\townerid int(11) unsigned NOT NULL default '0',\r\n\t\tname varchar(255) NOT NULL default '',\r\n\t\temail varchar(255) NOT NULL default '',\r\n\t\twebsite varchar(255) default NULL,\r\n\t\tdate datetime default NULL,\r\n\t\tcomment text,\r\n\t\tinmoderation int(1) unsigned NOT NULL default '0',\r\n\t\tPRIMARY KEY  (cid),\r\n\t\tKEY ownerid (ownerid)\r\n\t\t) {$charset_collate};";
        dbDelta($sql);
    }
    if (!$wpdb->get_var("SHOW TABLES LIKE '{$flagalbum}'")) {
        $sql = "CREATE TABLE " . $flagalbum . " (\r\n\t\tid BIGINT(20) NOT NULL AUTO_INCREMENT ,\r\n\t\tname VARCHAR(255) NOT NULL ,\r\n\t\tpreviewpic BIGINT(20) DEFAULT '0' NOT NULL ,\r\n\t\talbumdesc MEDIUMTEXT NULL ,\r\n\t\tcategories LONGTEXT NOT NULL,\r\n\t\tPRIMARY KEY id (id)\r\n\t\t) {$charset_collate};";
        dbDelta($sql);
    }
    // check one table again, to be sure
    if (!$wpdb->get_var("SHOW TABLES LIKE '{$flagpictures}'")) {
        update_option("flag_init_check", __('Flash Album Gallery : Tables could not created, please check your database settings', 'flash-album-gallery'));
        return;
    }
    $options = get_option('flag_options');
    // set the default settings, if we didn't upgrade
    if (empty($options)) {
        flag_default_options();
    }
    // if all is passed , save the VERSIONs
    add_option("flag_db_version", FLAG_DBVERSION);
    add_option("flagVersion", FLAGVERSION);
    include_once dirname(__FILE__) . '/tuning.php';
    flag_tune(false);
}
Exemple #2
0
/**
 * Show the Setup Box and some info for Flash Album Gallery
 * 
 * @return void
 */
function flag_overview_setup()
{
    global $flag;
    if (isset($_POST['resetdefault'])) {
        check_admin_referer('flag_uninstall');
        include_once dirname(__FILE__) . '/flag_install.php';
        include_once dirname(__FILE__) . '/tuning.php';
        flag_default_options();
        flag_tune(true, true);
        $flag->define_constant();
        $flag->load_options();
        flagGallery::show_message(__('Reset all settings to default parameter', 'flag'));
    }
    if (isset($_POST['uninstall'])) {
        check_admin_referer('flag_uninstall');
        include_once dirname(__FILE__) . '/flag_install.php';
        flag_uninstall();
        flagGallery::show_message(__('Uninstall sucessful ! Now delete the plugin and enjoy your life ! Good luck !', 'flag'));
    }
    ?>
		<div class="submitbox" id="submitpost">
			<div id="minor-publishing">
				<div id="misc-publishing-actions">
					<div class="misc-pub-section">
						<span id="plugin-home" class="icon">
							<strong><a href="http://codeasily.com/wordpress-plugins/flag/" style="text-decoration: none;"><?php 
    _e('Plugin Home', 'flag');
    ?>
</a></strong>
						</span>
					</div>
					<div class="misc-pub-section">
						<span id="plugin-comments" class="icon">
							<a href="http://codeasily.com/community/forum/flagallery-wordpress-plugin/" style="text-decoration: none;"><?php 
    _e('Plugin Forum', 'flag');
    ?>
</a>
						</span>
					</div>
					<div class="misc-pub-section">
						<span id="rate-plugin" class="icon">
							<a href="http://wordpress.org/extend/plugins/flash-album-gallery/" style="text-decoration: none;"><?php 
    _e('Rate Plugin', 'flag');
    ?>
</a>
						</span>
					</div>
					<div class="misc-pub-section curtime misc-pub-section-last">
						<span id="contact-me" class="icon">
							<a href="http://codeasily.com/support/contact/" style="text-decoration: none;"><?php 
    _e('Contact Me', 'flag');
    ?>
</a>
						</span>
					</div>
				</div>
			</div>
		</div>
	<?php 
    if (!IS_WPMU || flag_wpmu_site_admin()) {
        ?>
	<div id="major-publishing-actions">
	<form id="resetsettings" name="resetsettings" method="post">
		<?php 
        wp_nonce_field('flag_uninstall');
        ?>
			<div id="save-action" class="alignleft">
				<input class="button" id="save-post" type="submit" name="resetdefault" value="<?php 
        _e('Reset settings', 'flag');
        ?>
" onclick="javascript:check=confirm('<?php 
        _e('Reset all options to default settings ?\\n\\nChoose [Cancel] to Stop, [OK] to proceed.\\n', 'flag');
        ?>
');if(check==false) return false;" />
			</div>
			<div id="preview-action" class="alignright">
				<input type="submit" name="uninstall" class="button delete" value="<?php 
        _e('Uninstall plugin', 'flag');
        ?>
" onclick="javascript:check=confirm('<?php 
        _e('You are about to Uninstall this plugin from WordPress.\\nThis action is not reversible.\\n\\nChoose [Cancel] to Stop, [OK] to Uninstall.\\n', 'flag');
        ?>
');if(check==false) return false;" />
			</div>
			<br class="clear" />
	</form>
	</div>
	<?php 
    }
    ?>

<?php 
}