Skip to content

Commit

Permalink
added the function to remove project.
Browse files Browse the repository at this point in the history
this should not happen quite offen
  • Loading branch information
seanchen committed Feb 6, 2013
1 parent d5c2be1 commit 2226cb0
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 4 deletions.
4 changes: 2 additions & 2 deletions wp-trac-client/admin-manager.php
Expand Up @@ -10,8 +10,8 @@
wptc_handle_pm_submit($pm_context);

switch($pm_context['action']) {
case 'newproject':
wptc_widget_new_project();
case 'editproject':
wptc_widget_eidt_project();
break;
case 'list':
default:
Expand Down
14 changes: 14 additions & 0 deletions wp-trac-client/admin-tags.php
Expand Up @@ -90,3 +90,17 @@ function wptc_get_project($name) {

return $project;
}

function wptc_remove_project($name) {

global $wpdb;

$query = "delete from " . WPTC_PROJECT .
" where name = %s";
$query = $wpdb->prepare($query, $name);
// if error, false is return.
// else number of rows affected/selected.
$rows = $wpdb->query($query);

return $rows;
}
24 changes: 22 additions & 2 deletions wp-trac-client/admin-widgets.php
Expand Up @@ -64,9 +64,11 @@ function column_name($item) {
$aTemp = '<a href="?page=%s&action=%s&project=%s">%s</a>';
$actions = array(
'edit' => sprintf($aTemp, $_REQUEST['page'],
'edit',$item['id'], 'Edit'),
'editproject',$item['name'],
'Edit'),
'delete' => sprintf($aTemp, $_REQUEST['page'],
'delete',$item['id'], 'Delete'),
'deleteproject',$item['name'],
'Delete'),
);

// Return the title contents
Expand Down Expand Up @@ -286,6 +288,10 @@ function wptc_handle_pm_submit($context) {
$_POST['wptcaddproject_submit'] === 'Y') {

wptc_handle_add_new_project();
} else if(isset($_REQUEST['action']) &&
$_REQUEST['action'] === 'deleteproject') {
//
wptc_handle_delete_project();
}
}

Expand Down Expand Up @@ -321,3 +327,17 @@ function wptc_handle_add_new_project() {
EOT;
}
}

/**
* delete projects.
*/
function wptc_handle_delete_project() {

$name = $_REQUEST['project'];
wptc_remove_project($name);
echo <<<EOT
<div class="updated"><p><strong>
Project <em><b>$name</b></em> Removed!
</strong></p></div>
EOT;
}

0 comments on commit 2226cb0

Please sign in to comment.