Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
get start the project management page:
projects list is based on WP_List_Table Add new porject is working, we are using server side validation.
- Loading branch information
Showing
4 changed files
with
451 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,37 @@ | ||
<?php | ||
// load context. | ||
$pm_context = wptc_widget_pm_context(); | ||
?> | ||
|
||
<div class='wrap'> | ||
<h2>WordPress Trac Client - Management</h2> | ||
|
||
<?php | ||
// handle submit | ||
wptc_handle_pm_submit($pm_context); | ||
|
||
switch($pm_context['action']) { | ||
case 'newproject': | ||
wptc_widget_new_project(); | ||
break; | ||
case 'list': | ||
default: | ||
wptc_widget_projects_list(); | ||
break; | ||
} | ||
?> | ||
|
||
<?php | ||
if ($DEBUG) { | ||
global $wptc_db_version; | ||
//wptc_create_tables(); | ||
$file = __FILE__; | ||
$path = MY_PLUGIN_PATH; | ||
$filename = basename(__FILE__); | ||
echo <<<EOT | ||
<p>$wptc_db_version</p> | ||
<p>file: $file, basename: $filename</p> | ||
<p>MY_PLUGIN_PATH: {$path}</p> | ||
EOT; | ||
} | ||
?> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
<?php | ||
|
||
wp_enqueue_script("wp_ajax_response"); | ||
$DEBUG = False; | ||
|
||
if (isset($_POST['wptc_settings_form_submit']) && | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<?php | ||
|
||
function wptc_logging($msg) { | ||
|
||
// TODO: this should never go prodcution! | ||
$DEBUG = false; | ||
if($DEBUG) { | ||
$logfile = fopen(ABSPATH . 'logging.log', "a"); | ||
// time stamp | ||
fwrite($logfile, $msg . "\n"); | ||
fclose($logfile); | ||
} | ||
} | ||
|
||
/** | ||
* create database tables for the project management | ||
* if force create tables, all data will be droped. | ||
* default is NOT force to create tables. | ||
*/ | ||
function wptc_create_tables($force=false) { | ||
|
||
require_once(ABSPATH . "wp-admin/includes/upgrade.php"); | ||
|
||
// the project table. | ||
$sql = "CREATE TABLE " . WPTC_PROJECT . " ( | ||
id mediumint(9) not null auto_increment, | ||
name varchar(100) not null, | ||
description varchar(512) not null default '', | ||
PRIMARY KEY (id), | ||
KEY name (name) | ||
);"; | ||
wptc_logging("create project table: " . $sql); | ||
dbDelta($sql); | ||
|
||
// the project metadata table. | ||
// the type will be one of [milestone, version] | ||
$sql = "CREATE TABLE " . WPTC_PROJECT_METADATA . " ( | ||
id mediumint(9) not null auto_increment, | ||
name varchar(100) not null, | ||
project_id mediumint(9) not null, | ||
type varchar(64) not null, | ||
description varchar(512) not null default '', | ||
due_date datetime not null default '0000-00-00 00:00:00', | ||
PRIMARY KEY (id), | ||
KEY id (id) | ||
);"; | ||
wptc_logging("crate project metadata table: ". $sql); | ||
dbDelta($sql); | ||
} | ||
|
||
/** | ||
* return all projects | ||
*/ | ||
function wptc_get_projects() { | ||
|
||
global $wpdb; | ||
|
||
$query = "select * from " . WPTC_PROJECT; | ||
$projects = $wpdb->get_results($query, ARRAY_A); | ||
return $projects; | ||
} | ||
|
||
function wptc_add_project($name, $description) { | ||
|
||
global $wpdb; | ||
|
||
$success = $wpdb->insert( | ||
WPTC_PROJECT, | ||
array( | ||
'name' => $name, | ||
'description' => $description | ||
), | ||
array( | ||
'%s', | ||
'%s' | ||
) | ||
); | ||
|
||
return $success; | ||
} | ||
|
||
function wptc_get_project($name) { | ||
|
||
global $wpdb; | ||
|
||
$query = "select * from " . WPTC_PROJECT . | ||
" where name = %s"; | ||
$query = $wpdb->prepare($query, $name); | ||
$project = $wpdb->get_row($query, ARRAY_A); | ||
|
||
return $project; | ||
} |
Oops, something went wrong.