Index: CommentController.class.php =================================================================== --- CommentController.class.php (revision 177) +++ CommentController.class.php (working copy) @@ -90,14 +90,38 @@ $object->subscribeUser(logged_user()); } // if } // if - + + + // Try to send notification on comments other than Messages (messages already managed by subscription) + if (!($comment->getObject() instanceof ProjectMessage)) { + // Try to send notifications but don't break submission in case of an error + // define all the users to be notified - here all project users, from all companies. + // Restrictions if comment is private is taken into account in newOtherComment() + try { + $notify_people = array(); + $project_companies = active_project()->getCompanies(); + foreach ($project_companies as $project_company) { + $company_users = $project_company->getUsersOnProject(active_project()); + if (is_array($company_users)) { + foreach ($company_users as $company_user) { + $notify_people[] = $company_user; + } // if + } // if + } // if + + //notify + Notifier::newOtherComment($comment, $notify_people); // send notification email... + } catch(Exception $e) { + } // try + } // if + DB::commit(); flash_success(lang('success add comment')); $redirect_to = $comment->getViewUrl(); if (!is_valid_url($redirect_to)) { - $redirect_to = $object->getViewUrl(); + $redirect_to = $object->getObjectUrl(); } // if $this->redirectToUrl($redirect_to);