Skip to content

Commit

Permalink
Merge pull request #17 from codehaiku/task-breaker-1.3-dev
Browse files Browse the repository at this point in the history
Task breaker 1.3 dev
  • Loading branch information
JosephGabito authored Nov 22, 2016
2 parents 8aa20a4 + 99038b8 commit 7384bd1
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 22 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
~Current Version:1.2~
~Current Version:1.3~

# Task Breaker

Expand Down
20 changes: 19 additions & 1 deletion core/conditional-tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ function task_breaker_can_add_task_comment( $project_id, $task_id = 0 ) {
}

return false;

}


Expand Down Expand Up @@ -308,4 +308,22 @@ function task_current_member_is_assign_to( $task_id = 0 ){

return false;
}

function task_breaker_is_project_group_public( $project_id = 0 ) {

$public_status = "public";

$group_id = task_breaker_get_project_group_id( $project_id );

$group = groups_get_group( $group_id );

if ( $public_status === $group->status ) {

return true;

}

return false;

}
?>
20 changes: 20 additions & 0 deletions core/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -682,4 +682,24 @@ function task_breaker_print_r( $raw, $type = '' ) {

return;
}

/**
* Get Project's group id by project ID.
*/
function task_breaker_get_project_group_id( $project_id = 0 ) {

$group_id = 0;

if ( 0 === $project_id ) {
return 0;
}

$group_id = absint( get_post_meta( $project_id, 'task_breaker_project_group_id', true ) );

if ( empty( $group_id ) ) {
return 0;
}

return $group_id;
}
?>
1 change: 1 addition & 0 deletions models/comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ public function set_ticket_id($ticket_id = 0) {
public function save() {

if ( empty( $this->user ) ) { return false; }

if ( empty( $this->ticket_id ) ) { return false; }

global $wpdb;
Expand Down
44 changes: 26 additions & 18 deletions models/tasks.php
Original file line number Diff line number Diff line change
Expand Up @@ -506,26 +506,30 @@ public function save( $args = array() ) {
global $wpdb;

$args = array(
'title' => $this->title,
'description' => $this->description,
'user' => $this->user_id,
'milestone_id' => $this->milestone_id,
'project_id' => $this->project_id,
'priority' => $this->priority,
'date_created' => date("Y-m-d H:i:s"),
'assign_users' => $this->group_members_assigned
);
'title' => $this->title,
'description' => $this->description,
'user' => $this->user_id,
'milestone_id' => $this->milestone_id,
'project_id' => $this->project_id,
'priority' => $this->priority,
'date_created' => date("Y-m-d H:i:s"),
'assign_users' => $this->group_members_assigned
);

$trimmed_title = trim( $this->title );

if ( empty( $trimmed_title ) ) {

return false;

}

$trimmed_description = trim( $this->description );

if ( empty( $trimmed_description ) ) {

return false;

}

$format = array(
Expand Down Expand Up @@ -580,15 +584,19 @@ public function save( $args = array() ) {

$action = sprintf( __( '%s added new task under %s', 'task_breaker' ), $bp_user_link, $task_breaker_project_name );

$new_activity_id = bp_activity_add(
array(
'user_id' => $this->user_id,
'action' => apply_filters( 'task_breaker_new_task_activity_action', $action, $this->user_id ),
'component' => 'project',
'content' => apply_filters( 'task_breaker_new_task_activity_descriptioin', sprintf( '<a href="%s" title="%s">#%d - %s</a>', $permalink . '#tasks/view/' . $last_insert_id, $this->title, $last_insert_id, $this->title ) ),
'type' => 'task_breaker_new_task',
)
);
if ( task_breaker_is_project_group_public( $this->project_id ) ) {

$new_activity_id = bp_activity_add(
array(
'user_id' => $this->user_id,
'action' => apply_filters( 'task_breaker_new_task_activity_action', $action, $this->user_id ),
'component' => 'project',
'content' => apply_filters( 'task_breaker_new_task_activity_descriptioin', sprintf( '<a href="%s" title="%s">#%d - %s</a>', $permalink . '#tasks/view/' . $last_insert_id, $this->title, $last_insert_id, $this->title ) ),
'type' => 'task_breaker_new_task',
)
);

}

// Send a notification to the assigned member
$exploded_members = explode( ",", $this->group_members_assigned );
Expand Down
4 changes: 2 additions & 2 deletions task-breaker.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Plugin Name: Task Breaker
* Description: A WordPress plug-in that will help you break some task!
* Version: 1.2
* Version: 1.3
* Author: Dunhakdis
* Author URI: http://dunhakdis.me
* Text Domain: task_breaker
Expand All @@ -16,7 +16,7 @@
exit();
}

define( 'TASK_BREAKER_VERSION', '0.1.1' );
define( 'TASK_BREAKER_VERSION', '1.3.0' );

define( 'TASK_BREAKER_PROJECT_LIMIT', 10 );

Expand Down

0 comments on commit 7384bd1

Please sign in to comment.