本文整理汇总了PHP中Notifier::newMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP Notifier::newMessage方法的具体用法?PHP Notifier::newMessage怎么用?PHP Notifier::newMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Notifier
的用法示例。
在下文中一共展示了Notifier::newMessage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add
/**
* Add message
*
* @access public
* @param void
* @return null
*/
function add()
{
$this->setTemplate('add_message');
if (!ProjectMessage::canAdd(logged_user(), active_project())) {
flash_error(lang('no access permissions'));
$this->redirectToReferer(get_url('message'));
}
// if
$message = new ProjectMessage();
tpl_assign('message', $message);
$message_data = array_var($_POST, 'message');
if (!is_array($message_data)) {
$message_data = array('milestone_id' => array_var($_GET, 'milestone_id'));
// array
}
// if
tpl_assign('message_data', $message_data);
if (is_array(array_var($_POST, 'message'))) {
try {
$uploaded_files = ProjectFiles::handleHelperUploads(active_project());
} catch (Exception $e) {
$uploaded_files = null;
}
// try
try {
$message->setFromAttributes($message_data);
$message->setProjectId(active_project()->getId());
// Options are reserved only for members of owner company
if (!logged_user()->isMemberOfOwnerCompany()) {
$message->setIsPrivate(false);
$message->setIsImportant(false);
$message->setCommentsEnabled(true);
$message->setAnonymousCommentsEnabled(false);
}
// if
DB::beginWork();
$message->save();
$message->subscribeUser(logged_user());
$message->setTagsFromCSV(array_var($message_data, 'tags'));
if (is_array($uploaded_files)) {
foreach ($uploaded_files as $uploaded_file) {
$message->attachFile($uploaded_file);
$uploaded_file->setIsPrivate($message->isPrivate());
$uploaded_file->setIsVisible(true);
$uploaded_file->setExpirationTime(EMPTY_DATETIME);
$uploaded_file->save();
}
// if
}
// if
ApplicationLogs::createLog($message, 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();
$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) {
if (array_var($message_data, 'notify_company_' . $project_company->getId()) == 'checked' || array_var($message_data, 'notify_user_' . $company_user->getId())) {
$message->subscribeUser($company_user);
// subscribe
$notify_people[] = $company_user;
}
// if
}
// if
}
// if
}
// if
Notifier::newMessage($message, $notify_people);
// send notification email...
} catch (Exception $e) {
}
// try
flash_success(lang('success add message', $message->getTitle()));
$this->redirectTo('message');
// Error...
} catch (Exception $e) {
DB::rollback();
if (is_array($uploaded_files)) {
foreach ($uploaded_files as $uploaded_file) {
$uploaded_file->delete();
}
// foreach
}
// if
$message->setNew(true);
tpl_assign('error', $e);
}
// try
//.........这里部分代码省略.........