topic_group int(11) NOT NULL DEFAULT '0',
	topic_category int(11) NOT NULL DEFAULT '0',
	topic_subject varchar(256) NOT NULL,
	topic_post text NOT NULL,
	topic_owner int(11) NOT NULL,
	topic_date datetime NOT NULL,
	topic_parent int(11) NOT NULL,
	topic_views int(11) NOT NULL,
	topic_started datetime NOT NULL,
	topic_sticky int(11) NOT NULL DEFAULT '0',
	PRIMARY KEY  tid (tid)
	) CHARACTER SET utf8 COLLATE utf8_general_ci;";

	dbDelta($sql);
	
	if (!__wps__is_wpmu()) {

		$rows_affected = $wpdb->insert( $table_name, array( 
		'topic_category' => $new_category_id, 
		'topic_subject' => 'Welcome to the Forum', 
		'topic_post' => 'Welcome to the forum - this is a demonstration post and can be deleted.',
		'topic_owner' => 1,
		'topic_date' => date("Y-m-d H:i:s"),
		'topic_views' => 0,
		'topic_parent' => 0,
		'topic_started' => date("Y-m-d H:i:s")
		 ) );
		 
		$new_topic_id = $wpdb->insert_id;
		$rows_affected = $wpdb->insert( $table_name, array( 
		'topic_category' => $new_category_id, 
Beispiel #2
0
function __wps__install_row($handle, $name, $shortcode, $function, $config_url, $plugin_dir, $settings_url, $install_help) {

	if (substr($install_help, 0, 7) == '__wps__') {
		
		global $wpdb;
		$install_help = str_replace('\\', '/', $install_help);
		$name = str_replace('_', ' ', $name);
		
		$status = '';
		
		echo '<tr>';

				$style = (is_super_admin() && __wps__is_wpmu()) ? '' : 'display:none;';
				echo '<td style="'.$style.'text-align:center">';
				
					if ($function != '__wps__group' && $install_help != '__wps_activated') {
						$network_activated = get_option(WPS_OPTIONS_PREFIX.$function.'_network_activated') ? 'CHECKED' : '';
						echo '<input type="checkbox" name="'.$function.'_network_activated" '.$network_activated.' />';
					} else {
						echo __('n/a', WPS_TEXT_DOMAIN);
					}
				
				echo '</td>';
	
			echo '<td style="text-align:center">';
			
				if ($function != '__wps__group') {
					$activated = get_option(WPS_OPTIONS_PREFIX.$function.'_activated') ? 'CHECKED' : '';
					$style = !get_option(WPS_OPTIONS_PREFIX.$function.'_network_activated') ? $style = '' : $style = 'style="display:none"';
					if ($install_help != '__wps__activated') {
						echo '<input type="checkbox" '.$style.' name="'.$function.'_activated" '.$activated.' />';
						if ($network_activated) 
							echo '<img src="'.WPS_PLUGIN_URL.'/images/tick.png" />';
					} else {
						echo '<img src="'.WPS_PLUGIN_URL.'/images/tick.png" />';
					}
				} else {
					echo __('n/a', WPS_TEXT_DOMAIN);
				}
			
			echo '</td>';
						
			// Name of Plugin
			echo '<td style="height:30px">';
				echo $name;
				if (!file_exists(WP_PLUGIN_DIR.'/'.$plugin_dir))
					echo '<br><span style="color:red;font-weight:bold">'.WP_PLUGIN_DIR.'/'.$plugin_dir.' missing!</span>';
				if (isset($network_activated) && ($network_activated || $activated) ) {
					if (strpos($install_help, '__wps__') == 0) $install_help = substr($install_help, 7, strlen($install_help)-7);
					$install_help = str_replace("bronze__", "", $install_help);
					if ($install_help != '') $install_help = ' ['.$install_help.']';
				} else {
					$install_help = '';
				}
			echo '</td>';
					
			// Shortcode on a page?
			$sql = "SELECT ID FROM ".$wpdb->prefix."posts WHERE lower(post_content) LIKE '%[".$shortcode."]%' AND post_type = 'page' AND post_status = 'publish';";
			$pages = $wpdb->get_results($sql);	
			if ( ($pages) && ($shortcode != '') ) {
				$page = $pages[0];
				$url = str_replace(get_bloginfo('url'), '', get_permalink($page->ID));
				echo '<td>';
					echo '<a href="'.get_permalink($page->ID).'" target="_blank">'.$url.'</a> ';
					echo '[<a href="post.php?post='.$page->ID.'&action=edit">'.__('Edit', WPS_TEXT_DOMAIN).'</a>] ';
					if (isset($status) && $status == 'tick') {
						if ($settings_url != '') {
							echo '[<a href="'.$settings_url.'">'.__('Configure', WPS_TEXT_DOMAIN).'</a>]';
						}
					}
				if ( (isset($status)) && ($url != $config_url && $status != 'cross') ) $status = 'error';
				if ($config_url == '-') $status = 'tick';
				echo $install_help.'</td>';
			} else {
				$url = '';
				echo '<td>';
				if ( (isset($status)) && ($status != 'cross') && ($status != 'notinstalled') && ($shortcode != '') ) {
					$status = 'add';
					echo '<div style="padding-top:4px;float:left; width:175px">'.sprintf(__('Add [%s] to:', WPS_TEXT_DOMAIN), $shortcode).'</div>';
					echo '<input type="submit" class="button symposium_addnewpage" id="'.$name.'" title="'.$shortcode.'" value="'.__('New Page', WPS_TEXT_DOMAIN).'" />';
					$sql = "SELECT * FROM ".$wpdb->prefix."posts WHERE post_status = 'publish' AND post_type = 'page' ORDER BY post_title";
					$pages = $wpdb->get_results($sql);
					if ($pages) {
						echo ' '.__('or', WPS_TEXT_DOMAIN).' ';
						echo '<select id="symposium_pagechoice_'.$shortcode.'" style="width:120px">';
						foreach ($pages as $page) {
							echo '<option value="'.$page->ID.'">'.$page->post_title;
						}
						echo '</select> ';
						echo '<input type="submit" class="button symposium_addtopage" id="'.$name.'" title="'.$shortcode.'" value="'.__('Add', WPS_TEXT_DOMAIN).'" />';
					}
				} else {
					if (isset($status) && $status == 'tick') {
						if ($settings_url != '') {
							echo '[<a href="'.$settings_url.'">'.__('Configure', WPS_TEXT_DOMAIN).'</a>]';
						}
					}
					if ($function == '__wps__wysiwyg') {
						if (current_user_can('update_core'))
							echo __('Also activates optional forum BB Code Toolbar', WPS_TEXT_DOMAIN);
					}
					if ($function == '__wps__add_notification_bar') {
						if (current_user_can('update_core'))
							echo ' [<a href="http://www.wpsymposium.com/chat/" target="_blank">'.__('Read this!', WPS_TEXT_DOMAIN).'</a>]';
					}
					if (isset($status) && $status == '') $status = 'tick';
				}
				echo '</td>';
			}
			
		
			
			// Status
			echo '<td style="text-align:center">';
	
				// Fix URL
				$fixed_url = false;
				$current_value = get_option(WPS_OPTIONS_PREFIX.'_'.strtolower($handle).'_url');
					if ($current_value != $url) {
						update_option(WPS_OPTIONS_PREFIX.'_'.strtolower($handle).'_url', $url);
						$fixed_url = true;
						if ($url != '') {
							echo '[<a href="javascript:void(0)" class="symposium_help" title="'.sprintf(__("URL updated successfully. It is important to visit this page to complete installation; after you add a %s shortcode to a page; change pages with %s shortcodes; if you change WordPress Permalinks; or if you experience problems.", WPS_TEXT_DOMAIN), WPS_WL, WPS_WL).'">'.__('Updated ok!', WPS_TEXT_DOMAIN).'</a>]';
						} else {
							echo '[<a href="javascript:void(0)" class="symposium_help" title="'.sprintf(__("URL removed. It is important to visit this page to complete installation; after you add a %s shortcode to a page; change pages with %s shortcodes; if you change WordPress Permalinks; or if you experience problems.", WPS_TEXT_DOMAIN), WPS_WL, WPS_WL).'">'.__('URL removed', WPS_TEXT_DOMAIN).'</a>]';
						}
					} else {
						if ($current_value) {
							$status = 'tick';
						}
					}
				
				if (!$fixed_url) {
						
					if (isset($status) && $status == 'notinstalled') {
						if ($function != '__wps__gallery') {
							echo '[<a href="javascript:void(0)" class="symposium_help" title="'.$install_help.'">'.__('Install', WPS_TEXT_DOMAIN).'</a>]';
						} else {
							echo __('Coming soon', WPS_TEXT_DOMAIN);
						}
					}
					if (isset($status) && $status == 'tick') {
						echo '<img src="'.get_option(WPS_OPTIONS_PREFIX.'_images').'/smilies/good.png" />';
					}
					if (isset($status) && $status == 'upgrade') {
						echo '<img src="'.get_option(WPS_OPTIONS_PREFIX.'_images').'/warning.png" />';
					}
					if (isset($status) && $status == 'cross') {			
						echo '[<a href="plugins.php?plugin_status=inactive">'.__('Activate', WPS_TEXT_DOMAIN).'</a>]';
					}
		
					if (isset($status) && $status == 'add') {
						echo '<img src="'.get_option(WPS_OPTIONS_PREFIX.'_images').'/'.$status.'.png" />';
					}
					
				}
				
			echo '</td>';
	
			// Setting in database
			if (current_user_can('update_core')) {
				echo '<td class="symposium_url" style="background-color:#efefef">';
				
					$value = get_option(WPS_OPTIONS_PREFIX.'_'.strtolower($handle).'_url');
					if (!$value && $status != 'add') { 
						echo 'n/a';
					} else {
						if ($value != 'Important: Please Visit Installation Page!') {
							echo $value;
						}	
					}
				echo '</td>';
			}
			
		echo '</tr>';
		
	}

}