Index: language/en_us/emails.php =================================================================== --- language/en_us/emails.php (revision 159) +++ language/en_us/emails.php (working copy) @@ -4,6 +4,7 @@ // Titles 'new message' => 'New message', + 'new task' => 'New task', 'new comment' => 'New comment', 'your account created' => 'Your account has been created', 'your password' => 'Your password', @@ -14,9 +15,11 @@ 'user password reseted' => 'Your password has been reset. New password is \'%s\'.', - 'dont reply wraning' => 'THIS IS A SYSTEM NOTIFICATION. DO NOT REPLY TO THIS EMAIL!', - 'new message posted' => 'New message "%s" has been posted in the "%s" project', + 'dont reply wraning' => 'THIS IS SYSTEM NOTIFICATION. DO NOT REPLY TO THIS EMAIL!', + 'new message posted' => 'New message "%s" has been posted in "%s" project', + 'new task posted' => 'New task "%s" has been posted in "%s" project', 'view new message' => 'View that message', + 'view new task' => 'View task', 'new comment posted' => 'New comment on "%s" has been posted', 'view new comment' => 'View that comment', @@ -21,7 +24,7 @@ 'new comment posted' => 'New comment on "%s" has been posted', 'view new comment' => 'View that comment', - 'user created your account' => '%s created a new account for you', + 'user created your account' => '%s created new account for you', 'visit and login' => 'Visit %s and login with', 'milestone assigned' => 'Milestone "%s" has been assigned to you', @@ -29,4 +32,4 @@ ); // array -?> +?> \ No newline at end of file Index: language/en_us/project_interface.php =================================================================== --- language/en_us/project_interface.php (revision 159) +++ language/en_us/project_interface.php (working copy) @@ -2,7 +2,7 @@ // Array of langs return array( - 'upcoming milestones in next 30 days' => 'Upcoming milestones (in the next 30 days)', + 'upcoming milestones in next 30 days' => 'Upcoming milestones (in next 30 days)', 'show all upcoming milestones' => 'Show all upcoming milestones (total %s)', 'recent activities' => 'Recent activities', @@ -11,11 +11,11 @@ // Options and descriptions 'important message desc' => 'Important messages are listed in the "Important messages" sidebar on the project messages page', - 'important file desc' => 'Important files are listed in the sidebar of files section in the "Important files" block', + 'important file desc' => 'Important files are listed in the sidebar of files section in "Important files" block', 'enable comments' => 'Enable comments', 'enable comments desc' => 'Users that can view this object can post comments on it. Select "No" to lock comments', 'enable anonymous comments' => 'Anonymous comments', - 'enable anonymous comments desc' => 'Allow anonymous comments be posted on this object. Anonymous comments can be posted through the API or other external sources (if enabled). The author must provide a name and valid email address. The source IP address will be logged.', + 'enable anonymous comments desc' => 'Allow anonymous comments be posted for this object. Anonymous comments can be posted through the API or other external sources (if enabled). The author must provide a name and valid email address. The source IP address will be logged.', 'completed task' => 'Completed task', 'completed tasks' => 'Completed tasks', @@ -34,10 +34,8 @@ 'comment posted on' => 'Posted on %s', 'comment posted on by' => 'Posted on %s by %s', 'completed on by' => '%s | %s', - 'completed on' => '%s', 'started on by' => '%s | %s', 'posted on by' => '%s | %s', - 'posted on' => '%s', 'milestone assigned to' => 'Assigned to %s', 'project started on' => 'Started on', @@ -53,9 +51,9 @@ 'no objects tagged with' => 'There are no objects in this project tagged with %s', 'tags widget description' => 'List of comma separated tags (example: "interface, javascript, public beta")', - 'project permissions form hint' => 'Using the permissions form you can easily add or remove companies and users and control their access permissions.', + 'project permissions form hint' => 'Using permissions form you can easily add or remove companies and users and control their access permissions.', - 'additional message text desc' => 'Additional message text is visible only on the comments page', + 'additional message text desc' => 'Additional message text is visible only on comments page', 'expand additional text' => 'Expand', 'collapse additional text' => 'Collapse', 'email notification' => 'Email notification', @@ -60,12 +58,13 @@ 'collapse additional text' => 'Collapse', 'email notification' => 'Email notification', 'email notification desc' => 'Notify selected people about this message via email', + 'email notification task' => 'Notify assigned user(s) via email', - 'attach existing file' => 'Attach an existing file (from the Files section)', - 'upload and attach' => 'Upload a new file and attach it to the message', + 'attach existing file' => 'Attach existing file (from Files section)', + 'upload and attach' => 'Upload new file and attach it to message', 'subscribers desc' => 'Subscribers will receive an email notification whenever someone (except themselves) posts a comment on this message', - 'admins can post comments on locked objects desc' => 'Comments are locked, but you as administrator still have the permissions to post comments. Note that if you expect replies from your clients and non-admin users you need to unlock comments for this object (set the "Enable comments" option to "Yes").', + 'admins can post comments on locked objects desc' => 'Comments are locked, but you as administrator still have the permissions to post comments. Note that if you expect replies from your clients and non-admin users you need to unlock comments for this object (set "Enable comments" option to "Yes").', 'all permissions' => 'All', 'can manage messages' => 'Manage messages', @@ -99,7 +98,7 @@ 'order by filename' => 'filename (a-z)', 'order by posttime' => 'date and time', 'all files' => 'All files', - 'upload file desc' => 'You can upload files of any type. The max file size you are allowed to upload is %s', + 'upload file desc' => 'You can upload files of any type. Max filesize you are allowed to upload is %s', 'file revision info short' => 'Revision #%s (created on %s)', 'file revision info long' => 'Revision #%s (by %s on %s)', 'file revision title short' => 'Revision #%s (created on %s)', @@ -105,7 +104,7 @@ 'file revision title short' => 'Revision #%s (created on %s)', 'file revision title long' => 'Revision #%s (by %s on %s)', 'update file' => 'Update file', - 'version file change' => 'Remember this change (the old file will be saved for reference)', + 'version file change' => 'Remember this change (old file will be saved for the reference)', 'last revision' => 'Last revision', 'revision comment' => 'Revision comment', 'initial versions' => '-- Initial version --', @@ -114,10 +113,10 @@ 'add attach file control' => 'Add file', 'remove attach file control' => 'Remove', - 'attach files to object desc' => 'Use this form to attach files to %s. You can attach one or many files. You can select any existing files from files section or upload new ones. New files will also be available through files section when you upload them.', + 'attach files to object desc' => 'Use this form to attach files to %s. You can attach one or many files. You can select any existing file from files section or upload new ones. New files will also be available through files section when you upload them.', 'select file' => 'Select a file', - 'admin notice comments disabled' => 'Comments are disabled for this object, but you as administrator still can comment. If you expect replies from other, non-admin users you should set "Enable comments" to "Yes".', + 'admin notice comments disabled' => 'Comments are disabled for this object, but you as administrator still can comment. If you expect replies from other, non-admin users you should set value of Enable comments option to Yes.', // iCal 'icalendar' => 'iCalendar', @@ -122,8 +121,8 @@ // iCal 'icalendar' => 'iCalendar', 'icalendar subscribe' => 'iCalendar', - 'icalendar subscribe desc' => 'Use this link to load milestone data into your favorite calendar application.', - 'icalendar password change notice' => 'Note: if you change your password the link to the calendar data will also change! You\'ll need to re-subscribe.', + 'icalendar subscribe desc' => 'Use this link to bring milestone data to your favorite calendar application.', + 'icalendar password change notice' => 'Note: if you change your password the link to the calendar data will also change! You\'ll need to resubscribe.', // Add project form 'success message' => 'Success message', @@ -146,4 +145,4 @@ ); // array -?> +?> \ No newline at end of file Index: application/views/notifier/new_task.php =================================================================== --- application/views/notifier/new_task.php (revision 0) +++ application/views/notifier/new_task.php (revision 0) @@ -0,0 +1,8 @@ +------------------------------------------------------------ + +------------------------------------------------------------ + getObjectName(), $new_task->getProject()->getName()) ?>. : + - getObjectUrl()) ?> + Company: getName() ?> +Project: getProject()->getName() ?> + -- \ No newline at end of file Index: application/views/task/task_list.php =================================================================== --- application/views/task/task_list.php (revision 159) +++ application/views/task/task_list.php (working copy) @@ -2,7 +2,7 @@ add_stylesheet_to_page('project/task_list.css'); ?>
-isPrivate()) { ?> +isPrivate()) { ?>
-getDescription()) { ?> +getDescription()) { ?>
getDescription()) ?>
-getOpenTasks())) { ?> +getOpenTasks())) { ?> -getOpenTasks() as $task) { ?> +getOpenTasks() as $task) { ?> -canChangeStatus(logged_user())) { ?> - +canChangeStatus(logged_user())) { ?> + @@ -42,7 +42,7 @@
getCompleteUrl(), false, lang('mark task as completed')) ?> getCompleteUrl(undo_htmlspecialchars($task_list->getOverviewUrl())), false, lang('mark task as completed')) ?> -getAssignedTo()) { ?> +getAssignedTo()) { ?> getAssignedTo()->getObjectName()) ?>: getText()) ?> canEdit(logged_user())) { ?> canDelete(logged_user())) { ?> @@ -56,7 +56,7 @@
-canAddTask(logged_user())) { ?> +canAddTask(logged_user())) { ?>
@@ -69,7 +69,9 @@ 'addTaskAssignTo' . $task_list->getId())) ?>
- +
+ 'notifyUser')) ?> +
'addTaskSubmit' . $task_list->getId())) ?> @@ -75,7 +77,7 @@
- + : : @@ -83,15 +85,15 @@ -getCompletedTasks())) { ?> +getCompletedTasks())) { ?>
-getCompletedTasks() as $task) { ?> +getCompletedTasks() as $task) { ?> - + -canChangeStatus(logged_user())) { ?> +canChangeStatus(logged_user())) { ?> @@ -109,7 +111,7 @@ - 5) { ?> + 5) { ?> @@ -120,17 +122,17 @@
: getProject()) ?>
canEdit(logged_user())) { + if($task_list->canEdit(logged_user())) { $options[] = '' . lang('edit') . ''; } // if - if ($task_list->canDelete(logged_user())) { + if($task_list->canDelete(logged_user())) { $options[] = '' . lang('delete') . ''; } // if - if ($task_list->canReorderTasks(logged_user())) { + if($task_list->canReorderTasks(logged_user())) { $options[] = '' . lang('reorder tasks') . ''; } // if ?> - +
@@ -137,4 +139,4 @@ - + \ No newline at end of file Index: application/controllers/TaskController.class.php =================================================================== --- application/controllers/TaskController.class.php (revision 159) +++ application/controllers/TaskController.class.php (working copy) @@ -42,7 +42,7 @@ */ function view_list() { $task_list = ProjectTaskLists::findById(get_id()); - if (!($task_list instanceof ProjectTaskList)) { + if(!($task_list instanceof ProjectTaskList)) { flash_error(lang('task list dnx')); $this->redirectTo('task'); } // if @@ -47,7 +47,7 @@ $this->redirectTo('task'); } // if - if (!$task_list->canView(logged_user())) { + if(!$task_list->canView(logged_user())) { flash_error(lang('no access permissions')); $this->redirectToReferer(get_url('task')); } // if @@ -69,7 +69,7 @@ */ function add_list() { - if (!ProjectTaskList::canAdd(logged_user(), active_project())) { + if(!ProjectTaskList::canAdd(logged_user(), active_project())) { flash_error(lang('no access permissions')); $this->redirectToReferer(get_url('task')); } // if @@ -76,7 +76,7 @@ $task_list = new ProjectTaskList(); $task_list_data = array_var($_POST, 'task_list'); - if (!is_array($task_list_data)) { + if(!is_array($task_list_data)) { $task_list_data = array( 'milestone_id' => array_var($_GET, 'milestone_id') ); // array @@ -85,7 +85,7 @@ tpl_assign('task_list_data', $task_list_data); tpl_assign('task_list', $task_list); - if (is_array(array_var($_POST, 'task_list'))) { + if(is_array(array_var($_POST, 'task_list'))) { $task_list->setFromAttributes($task_list_data); $task_list->setProjectId(active_project()->getId()); @@ -94,8 +94,8 @@ } $tasks = array(); - for ($i = 0; $i < 6; $i++) { - if (isset($task_list_data["task$i"]) && is_array($task_list_data["task$i"]) && (trim(array_var($task_list_data["task$i"], 'text')) <> '')) { + for($i = 0; $i < 6; $i++) { + if(isset($task_list_data["task$i"]) && is_array($task_list_data["task$i"]) && (trim(array_var($task_list_data["task$i"], 'text')) <> '')) { $assigned_to = explode(':', array_var($task_list_data["task$i"], 'assigned_to', '')); $tasks[] = array( 'text' => array_var($task_list_data["task$i"], 'text'), @@ -111,17 +111,35 @@ $task_list->save(); $task_list->setTagsFromCSV(array_var($task_list_data, 'tags')); - foreach ($tasks as $task_data) { + $notify_people_list = array(); + foreach($tasks as $task_data) { $task = new ProjectTask(); $task->setFromAttributes($task_data); $task_list->attachTask($task); - $task->save(); + $task->save(); + //load email nofitication array (notify_people[]) + try { + if((array_var($task_list_data, 'notify_user') == 'checked')) { + if($task->getAssignedToUserId()&& $task->getAssignedToUserId() != '0') { + $notify_people_list[] = $task->getAssignedToUser(); + } // if + }//if + } catch(Exception $e) { + + } // try } // foreach - - ApplicationLogs::createLog($task_list, active_project(), ApplicationLogs::ACTION_ADD); + + ApplicationLogs::createLog($task_list, active_project(), ApplicationLogs::ACTION_ADD); DB::commit(); + + //Send email notification for assigned tasks, if check box is "checked" + try { + Notifier::newTask($task, $notify_people_list); // send notification email... + } catch(Exception $e) { - flash_success(lang('success add task list', $task_list->getName())); + } // try + + flash_success(lang('success add task list', $task_list->getName())); $this->redirectToUrl($task_list->getViewUrl()); } catch(Exception $e) { @@ -144,7 +162,7 @@ $this->setTemplate('add_list'); $task_list = ProjectTaskLists::findById(get_id()); - if (!($task_list instanceof ProjectTaskList)) { + if(!($task_list instanceof ProjectTaskList)) { flash_error(lang('task list dnx')); $this->redirectTo('task'); } // if @@ -149,7 +167,7 @@ $this->redirectTo('task'); } // if - if (!$task_list->canEdit(logged_user())) { + if(!$task_list->canEdit(logged_user())) { flash_error(lang('no access permissions')); $this->redirectTo('task'); } // if @@ -155,7 +173,7 @@ } // if $task_list_data = array_var($_POST, 'task_list'); - if (!is_array($task_list_data)) { + if(!is_array($task_list_data)) { $tag_names = $task_list->getTagNames(); $task_list_data = array( 'name' => $task_list->getName(), @@ -168,7 +186,7 @@ tpl_assign('task_list', $task_list); tpl_assign('task_list_data', $task_list_data); - if (is_array(array_var($_POST, 'task_list'))) { + if(is_array(array_var($_POST, 'task_list'))) { $old_is_private = $task_list->isPrivate(); $task_list->setFromAttributes($task_list_data); if (!logged_user()->isMemberOfOwnerCompany()) { @@ -205,7 +223,7 @@ $this->setTemplate('del_list'); $task_list = ProjectTaskLists::findById(get_id()); - if (!($task_list instanceof ProjectTaskList)) { + if(!($task_list instanceof ProjectTaskList)) { flash_error(lang('task list dnx')); $this->redirectTo('task'); } // if @@ -210,7 +228,7 @@ $this->redirectTo('task'); } // if - if (!$task_list->canDelete(logged_user())) { + if(!$task_list->canDelete(logged_user())) { flash_error(lang('no access permissions')); $this->redirectTo('task'); } // if @@ -235,19 +253,19 @@ tpl_assign('error', new Error(lang('invalid login data'))); return $this->render(); } - try { - DB::beginWork(); - $task_list->delete(); - ApplicationLogs::createLog($task_list, active_project(), ApplicationLogs::ACTION_DELETE); - DB::commit(); - - flash_success(lang('success delete task list', $task_list->getName())); - } catch(Exception $e) { - DB::rollback(); - flash_error(lang('error delete task list')); - } // try - - $this->redirectTo('task'); + try { + DB::beginWork(); + $task_list->delete(); + ApplicationLogs::createLog($task_list, active_project(), ApplicationLogs::ACTION_DELETE); + DB::commit(); + + flash_success(lang('success delete task list', $task_list->getName())); + } catch(Exception $e) { + DB::rollback(); + flash_error(lang('error delete task list')); + } // try + + $this->redirectTo('task'); } else { flash_error(lang('error delete task list')); $this->redirectToUrl($task_list->getViewUrl()); @@ -262,7 +280,7 @@ */ function reorder_tasks() { $task_list = ProjectTaskLists::findById(get_id('task_list_id')); - if (!($task_list instanceof ProjectTaskList)) { + if(!($task_list instanceof ProjectTaskList)) { flash_error(lang('task list dnx')); $this->redirectTo('task'); } // if @@ -270,7 +288,7 @@ $back_to_list = (boolean) array_var($_GET, 'back_to_list'); $redirect_to = $back_to_list ? $task_list->getViewUrl() : get_url('task'); - if (!$task_list->canReorderTasks(logged_user())) { + if(!$task_list->canReorderTasks(logged_user())) { flash_error(lang('no access permissions')); $this->redirectToUrl($redirect_to); } // if @@ -276,7 +294,7 @@ } // if $tasks = $task_list->getOpenTasks(); - if (!is_array($tasks) || (count($tasks) < 1)) { + if(!is_array($tasks) || (count($tasks) < 1)) { flash_error(lang('no open task in task list')); $this->redirectToUrl($redirect_to); } // if @@ -285,13 +303,13 @@ tpl_assign('tasks', $tasks); tpl_assign('back_to_list', $back_to_list); - if (array_var($_POST, 'submitted') == 'submitted') { + if(array_var($_POST, 'submitted') == 'submitted') { $updated = 0; - foreach ($tasks as $task) { + foreach($tasks as $task) { $new_value = (integer) array_var($_POST, 'task_' . $task->getId()); - if ($new_value <> $task->getOrder()) { + if($new_value <> $task->getOrder()) { $task->setOrder($new_value); - if ($task->save()) { + if($task->save()) { $updated++; } // if } // if @@ -315,7 +333,7 @@ */ function add_task() { $task_list = ProjectTaskLists::findById(get_id('task_list_id')); - if (!($task_list instanceof ProjectTaskList)) { + if(!($task_list instanceof ProjectTaskList)) { flash_error(lang('task list dnx')); $this->redirectTo('task'); } // if @@ -320,7 +338,7 @@ $this->redirectTo('task'); } // if - if (!$task_list->canAddTask(logged_user())) { + if(!$task_list->canAddTask(logged_user())) { flash_error(lang('no access permissions')); $this->redirectTo('task'); } // if @@ -336,7 +354,7 @@ tpl_assign('task_data', $task_data); // Form is submited - if (is_array($task_data)) { + if(is_array($task_data)) { $task->setFromAttributes($task_data); $assigned_to = explode(':', array_var($task_data, 'assigned_to', '')); @@ -343,7 +361,7 @@ $task->setAssignedToCompanyId(array_var($assigned_to, 0, 0)); $task->setAssignedToUserId(array_var($assigned_to, 1, 0)); - try { + try { DB::beginWork(); $task->save(); @@ -350,9 +368,23 @@ $task_list->attachTask($task); ApplicationLogs::createLog($task, active_project(), ApplicationLogs::ACTION_ADD); DB::commit(); - + + // Try to send notifications but don't break submission in case of an error + try { + $notify_people = array(); + $userID = $task->getAssignedToUserId(); + if($userID && $userID != '0') { + $notify_people[] = $task->getAssignedToUser(); + } // if + + if((array_var($task_data, 'notify_user') == 'checked')) { + Notifier::newTask($task, $notify_people); // send notification email... + }//if + } catch(Exception $e) { + tpl_assign('error', $e); + } // try flash_success(lang('success add task')); - if ($back_to_list) { + if($back_to_list) { $this->redirectToUrl($task_list->getViewUrl()); } else { $this->redirectTo('task'); @@ -377,7 +409,7 @@ $this->setTemplate('add_task'); $task = ProjectTasks::findById(get_id()); - if (!($task instanceof ProjectTask)) { + if(!($task instanceof ProjectTask)) { flash_error(lang('task dnx')); $this->redirectTo('task'); } // if @@ -383,7 +415,7 @@ } // if $task_list = $task->getTaskList(); - if (!($task_list instanceof ProjectTaskList)) { + if(!($task_list instanceof ProjectTaskList)) { flash_error('task list dnx'); $this->redirectTo('task'); } // if @@ -388,7 +420,7 @@ $this->redirectTo('task'); } // if - if (!$task->canEdit(logged_user())) { + if(!$task->canEdit(logged_user())) { flash_error(lang('no access permissions')); $this->redirectTo('task'); } // if @@ -394,7 +426,7 @@ } // if $task_data = array_var($_POST, 'task'); - if (!is_array($task_data)) { + if(!is_array($task_data)) { $task_data = array( 'text' => $task->getText(), 'task_list_id' => $task->getTaskListId(), @@ -406,7 +438,7 @@ tpl_assign('task_list', $task_list); tpl_assign('task_data', $task_data); - if (is_array(array_var($_POST, 'task'))) { + if(is_array(array_var($_POST, 'task'))) { $task->setFromAttributes($task_data); $task->setTaskListId($task_list->getId()); // keep old task list id @@ -420,11 +452,11 @@ // Move? $new_task_list_id = (integer) array_var($task_data, 'task_list_id'); - if ($new_task_list_id && ($task->getTaskListId() <> $new_task_list_id)) { + if($new_task_list_id && ($task->getTaskListId() <> $new_task_list_id)) { // Move! $new_task_list = ProjectTaskLists::findById($new_task_list_id); - if ($new_task_list instanceof ProjectTaskList) { + if($new_task_list instanceof ProjectTaskList) { $task_list->detachTask($task, $new_task_list); // detach from old and attach to new list } // if @@ -436,7 +468,7 @@ flash_success(lang('success edit task')); // Redirect to task list. Check if we have updated task list ID first - if (isset($new_task_list) && ($new_task_list instanceof ProjectTaskList)) { + if(isset($new_task_list) && ($new_task_list instanceof ProjectTaskList)) { $this->redirectToUrl($new_task_list->getViewUrl()); } else { $this->redirectToUrl($task_list->getViewUrl()); @@ -462,7 +494,7 @@ $this->setTemplate('del_task'); $task = ProjectTasks::findById(get_id()); - if (!($task instanceof ProjectTask)) { + if(!($task instanceof ProjectTask)) { flash_error(lang('task dnx')); $this->redirectTo('task'); } // if @@ -468,7 +500,7 @@ } // if $task_list = $task->getTaskList(); - if (!($task_list instanceof ProjectTaskList)) { + if(!($task_list instanceof ProjectTaskList)) { flash_error('task list dnx'); $this->redirectTo('task'); } // if @@ -473,7 +505,7 @@ $this->redirectTo('task'); } // if - if (!$task->canDelete(logged_user())) { + if(!$task->canDelete(logged_user())) { flash_error(lang('no access permissions')); $this->redirectTo('task'); } // if @@ -499,19 +531,19 @@ tpl_assign('error', new Error(lang('invalid login data'))); return $this->render(); } - try { - DB::beginWork(); - $task->delete(); - ApplicationLogs::createLog($task, active_project(), ApplicationLogs::ACTION_DELETE); - DB::commit(); - - flash_success(lang('success delete task')); - } catch(Exception $e) { - DB::rollback(); - flash_error(lang('error delete task')); - } // try - - $this->redirectToUrl($task_list->getViewUrl()); + try { + DB::beginWork(); + $task->delete(); + ApplicationLogs::createLog($task, active_project(), ApplicationLogs::ACTION_DELETE); + DB::commit(); + + flash_success(lang('success delete task')); + } catch(Exception $e) { + DB::rollback(); + flash_error(lang('error delete task')); + } // try + + $this->redirectToUrl($task_list->getViewUrl()); } else { flash_error(lang('error delete task')); $this->redirectToUrl($task_list->getViewUrl()); @@ -527,7 +559,7 @@ */ function complete_task() { $task = ProjectTasks::findById(get_id()); - if (!($task instanceof ProjectTask)) { + if(!($task instanceof ProjectTask)) { flash_error(lang('task dnx')); $this->redirectTo('task'); } // if @@ -533,7 +565,7 @@ } // if $task_list = $task->getTaskList(); - if (!($task_list instanceof ProjectTaskList)) { + if(!($task_list instanceof ProjectTaskList)) { flash_error(lang('task list dnx')); $this->redirectTo('task'); } // if @@ -538,7 +570,7 @@ $this->redirectTo('task'); } // if - if (!$task->canChangeStatus(logged_user())) { + if(!$task->canChangeStatus(logged_user())) { flash_error(lang('no access permissions')); $this->redirectTo('task'); } // if @@ -544,7 +576,7 @@ } // if $redirect_to = array_var($_GET, 'redirect_to'); - if (!is_valid_url($redirect_to)) { + if(!is_valid_url($redirect_to)) { $redirect_to = get_referer($task_list->getViewUrl()); } // if @@ -572,7 +604,7 @@ */ function open_task() { $task = ProjectTasks::findById(get_id()); - if (!($task instanceof ProjectTask)) { + if(!($task instanceof ProjectTask)) { flash_error(lang('task dnx')); $this->redirectTo('task'); } // if @@ -578,7 +610,7 @@ } // if $task_list = $task->getTaskList(); - if (!($task_list instanceof ProjectTaskList)) { + if(!($task_list instanceof ProjectTaskList)) { flash_error(lang('task list dnx')); $this->redirectTo('task'); } // if @@ -583,7 +615,7 @@ $this->redirectTo('task'); } // if - if (!$task->canChangeStatus(logged_user())) { + if(!$task->canChangeStatus(logged_user())) { flash_error(lang('no access permissions')); $this->redirectTo('task'); } // if @@ -589,7 +621,7 @@ } // if $redirect_to = array_var($_GET, 'redirect_to'); - if ((trim($redirect_to) == '') || !is_valid_url($redirect_to)) { + if((trim($redirect_to) == '') || !is_valid_url($redirect_to)) { $redirect_to = get_referer($task_list->getViewUrl()); } // if @@ -610,4 +642,4 @@ } // TaskController -?> +?> \ No newline at end of file Index: application/models/notifier/Notifier.class.php =================================================================== --- application/models/notifier/Notifier.class.php (revision 159) +++ application/models/notifier/Notifier.class.php (working copy) @@ -69,6 +69,33 @@ } // newUserAccount /** + * Send new task notification to the list of users ($people) + * + * @param ProjectMessage $message New message + * @param array $people + * @return boolean + * @throws NotifierConnectionError + */ + static function newTask(ProjectTask $task, $people) { + if(!is_array($people) || !count($people)) { + return; // nothing here... + } // if + + tpl_assign('new_task', $task); + + $recepients = array(); + foreach($people as $user) { + $recepients[] = self::prepareEmailAddress($user->getEmail(), $user->getDisplayName()); + } // foreach + return self::sendEmail( + $recepients, + self::prepareEmailAddress($task->getCreatedBy()->getEmail(), $task->getCreatedByDisplayName()), + $task->getProject()->getName() . ' - ' . lang('new task'), + tpl_fetch(get_template_path('new_task', 'notifier')) + ); // send + } // newTask + + /** * Send new message notification to the list of users ($people) * * @param ProjectMessage $message New message @@ -77,7 +104,7 @@ * @throws NotifierConnectionError */ static function newMessage(ProjectMessage $message, $people) { - if (!is_array($people) || !count($people)) { + if(!is_array($people) || !count($people)) { return; // nothing here... } // if @@ -84,7 +111,7 @@ tpl_assign('new_message', $message); $recipients = array(); - foreach ($people as $user) { + foreach($people as $user) { $recipients[] = self::prepareEmailAddress($user->getEmail(), $user->getDisplayName()); } // foreach @@ -105,7 +132,7 @@ */ static function newMessageComment(Comment $comment) { $message = $comment->getObject(); - if (!($message instanceof ProjectMessage)) { + if(!($message instanceof ProjectMessage)) { throw new Error('Invalid comment object'); } // if @@ -110,7 +137,7 @@ } // if $all_subscribers = $message->getSubscribers(); - if (!is_array($all_subscribers)) { + if(!is_array($all_subscribers)) { return true; // no subscribers } // if @@ -115,13 +142,13 @@ } // if $recipients = array(); - foreach ($all_subscribers as $subscriber) { - if ($subscriber->getId() == $comment->getCreatedById()) { + foreach($all_subscribers as $subscriber) { + if($subscriber->getId() == $comment->getCreatedById()) { continue; // skip comment author } // if - if ($comment->isPrivate()) { - if ($subscriber->isMemberOfOwnerCompany()) { + if($comment->isPrivate()) { + if($subscriber->isMemberOfOwnerCompany()) { $recipients[] = self::prepareEmailAddress($subscriber->getEmail(), $subscriber->getDisplayName()); } // if } else { @@ -155,10 +182,10 @@ * @throws NotifierConnectionError */ function milestoneAssigned(ProjectMilestone $milestone) { - if ($milestone->isCompleted()) { + if($milestone->isCompleted()) { return true; // milestone has been already completed... } // if - if (!($milestone->getAssignedTo() instanceof User)) { + if(!($milestone->getAssignedTo() instanceof User)) { return true; // not assigned to user } // if @@ -186,7 +213,7 @@ * @return string */ static function prepareEmailAddress($email, $name = null) { - if (trim($name) && !self::getExchangeCompatible()) { + if(trim($name) && !self::getExchangeCompatible()) { return trim($name) . ' <' . trim($email) . '>'; } else { return trim($email); @@ -200,7 +227,7 @@ * @return boolean */ static function getExchangeCompatible() { - if (is_null(self::$exchange_compatible)) { + if(is_null(self::$exchange_compatible)) { self::$exchange_compatible = config_option('exchange_compatible', false); } // if return self::$exchange_compatible; @@ -207,21 +234,20 @@ } // getExchangeCompatible /** - * Send an email using Swift (send commands) - * - * @param string to_address - * @param string from_address - * @param string subject - * @param string body, optional - * @param string content-type,optional - * @param string content-transfer-encoding,optional - * @return bool successful - */ + * Send an email using Swift (send commands) + * + * @param string to_address + * @param string from_address + * @param string subject + * @param string body, optional + * @param string content-type,optional + * @param string content-transfer-encoding,optional + * @return bool successful + */ static function sendEmail($to, $from, $subject, $body = false, $type = 'text/plain', $encoding = '8bit') { - Env::useLibrary('swift'); - + Env::useLibrary('swift'); $mailer = self::getMailer(); - if (!($mailer instanceof Swift)) { + if(!($mailer instanceof Swift)) { throw new NotifierConnectionError(); } // if @@ -242,7 +268,7 @@ $mail_transport_config = config_option('mail_transport', self::MAIL_TRANSPORT_MAIL); // Emulate mail() - use NativeMail - if ($mail_transport_config == self::MAIL_TRANSPORT_MAIL) { + if($mail_transport_config == self::MAIL_TRANSPORT_MAIL) { $mailer = new Swift(new Swift_Connection_NativeMail()); return $mailer->isConnected() ? $mailer : null; @@ -247,7 +273,7 @@ return $mailer->isConnected() ? $mailer : null; // Use SMTP server - } elseif ($mail_transport_config == self::MAIL_TRANSPORT_SMTP) { + } elseif($mail_transport_config == self::MAIL_TRANSPORT_SMTP) { // Load SMTP config $smtp_server = config_option('smtp_server'); @@ -254,7 +280,7 @@ $smtp_port = config_option('smtp_port', 25); $smtp_secure_connection = config_option('smtp_secure_connection', self::SMTP_SECURE_CONNECTION_NO); $smtp_authenticate = config_option('smtp_authenticate', false); - if ($smtp_authenticate) { + if($smtp_authenticate) { $smtp_username = config_option('smtp_username'); $smtp_password = config_option('smtp_password'); } // if @@ -259,7 +285,7 @@ $smtp_password = config_option('smtp_password'); } // if - switch ($smtp_secure_connection) { + switch($smtp_secure_connection) { case self::SMTP_SECURE_CONNECTION_SSL: $transport = SWIFT_SSL; break; @@ -271,7 +297,7 @@ } // switch $mailer = new Swift(new Swift_Connection_SMTP($smtp_server, $smtp_port, $transport)); - if (!$mailer->isConnected()) { + if(!$mailer->isConnected()) { return null; } // if @@ -277,8 +303,8 @@ $mailer->setCharset('UTF-8'); - if ($smtp_authenticate) { - if ($mailer->authenticate($smtp_username, $smtp_password)) { + if($smtp_authenticate) { + if($mailer->authenticate($smtp_username, $smtp_password)) { return $mailer; } else { return null; @@ -293,5 +319,6 @@ } // if } // getMailer - } // Notifier -?> + } // Notifier + +?> \ No newline at end of file
getOpenUrl(), true, lang('mark task as open')) ?> <?php echo lang('completed task') ?>