本文整理汇总了PHP中Notifications::send方法的典型用法代码示例。如果您正苦于以下问题:PHP Notifications::send方法的具体用法?PHP Notifications::send怎么用?PHP Notifications::send使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Notifications
的用法示例。
在下文中一共展示了Notifications::send方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_sendmagic
/**
* action_sendmagic
*
* @access public
* @return array
*/
function action_sendmagic()
{
global $db, $baseurl;
// Check that the username exists
if (strpos(Post::val('user_name'), '@') === false) {
$user = Flyspray::getUserDetails(Flyspray::UserNameToId(Post::val('user_name')));
} else {
$user_id = $db->x->GetOne('SELECT user_id FROM {users} WHERE email_address = ?', null, Post::val('user_name'));
$user = Flyspray::getUserDetails($user_id);
}
// If the username doesn't exist, throw an error
if (!is_array($user) || !count($user)) {
return array(ERROR_RECOVER, L('usernotexist'));
}
$magic_url = md5(uniqid(mt_rand(), true));
// Insert the random "magic url" into the user's profile
$db->x->execParam('UPDATE {users}
SET magic_url = ?
WHERE user_id = ?', array($magic_url, $user['user_id']));
Notifications::send($user['user_id'], ADDRESS_USER, NOTIFY_PW_CHANGE, array($baseurl, $magic_url));
return array(SUBMIT_OK, L('magicurlsent'));
}
示例2: close_task
/**
* Closes a task
* @param integer $task_id
* @param integer $reason
* @param string $comment
* @param bool $mark100
* @access public
* @return bool
* @version 1.0
*/
function close_task($task_id, $reason, $comment, $mark100 = true)
{
global $db, $user, $fs;
$task = Flyspray::GetTaskDetails($task_id);
if (!$user->can_close_task($task)) {
return false;
}
if ($task['is_closed']) {
return false;
}
$db->x->autoExecute('{tasks}', array('date_closed' => time(), 'closed_by' => $user->id, 'closure_comment' => $comment, 'is_closed' => 1, 'resolution_reason' => $reason, 'last_edited_time' => time(), 'last_edited_by' => $user->id, 'percent_complete' => (bool) $mark100 * 100), MDB2_AUTOQUERY_UPDATE, sprintf('task_id = %d', $task_id));
if ($mark100) {
Flyspray::logEvent($task_id, 3, 100, $task['percent_complete'], 'percent_complete');
}
// [RED] Update last changed date
$db->x->execParam('UPDATE {redundant} SET last_changed_time = ?,
last_changed_by_real_name = ?, last_changed_by_user_name = ?,
closed_by_real_name = ?, closed_by_user_name = ?
WHERE task_id = ?', array(time(), $user->infos['real_name'], $user->infos['user_name'], $user->infos['real_name'], $user->infos['user_name'], $task_id));
Notifications::send($task_id, ADDRESS_TASK, NOTIFY_TASK_CLOSED);
Flyspray::logEvent($task_id, 2, $reason, $comment);
// If there's an admin request related to this, close it
$db->x->autoExecute('{admin_requests}', array('resolved_by' => $user->id, 'time_resolved' => time()), MDB2_AUTOQUERY_UPDATE, sprintf('task_id = %d AND request_type = 1', $task_id));
// duplicate
if ($reason == $fs->prefs['resolution_dupe']) {
$look = array('FS#', 'bug ');
foreach ($fs->projects as $project) {
$look[] = preg_quote($project['project_prefix'] . '#', '/');
}
preg_match("/\\b(" . implode('|', $look) . ")(\\d+)\\b/", $comment, $dupe_of);
if (count($dupe_of) >= 2) {
$existing = $db->x->getOne('SELECT count(*) FROM {related} WHERE this_task = ? AND related_task = ? AND related_type = 1', null, array($task_id, $dupe_of[1]));
if (!$existing) {
$db->x->autoExecute('{related}', array('this_task' => $task_id, 'related_task' => $dupe_of[1], 'related_type' => 1));
}
Backend::add_vote($task['opened_by'], $dupe_of[1]);
}
}
return true;
}
示例3: action_sendcode
function action_sendcode()
{
global $user, $db, $fs, $conf, $baseurl;
if (!Post::val('user_name') || !Post::val('real_name') || !Post::val('email_address')) {
// If the form wasn't filled out correctly, show an error
return array(ERROR_RECOVER, L('registererror'));
}
$email = Post::val('email_address');
$jabber_id = Post::val('jabber_id');
//email is mandatory
if (!$email || !Flyspray::check_email($email)) {
return array(ERROR_RECOVER, L('novalidemail'));
}
//jabber_id is optional
if ($jabber_id && !Jabber::check_jid($jabber_id)) {
return array(ERROR_RECOVER, L('novalidjabber'));
}
$user_name = Backend::clean_username(Post::val('user_name'));
// Limit lengths
$real_name = substr(trim(Post::val('real_name')), 0, 100);
// Remove doubled up spaces and control chars
$real_name = preg_replace('![\\x00-\\x1f\\s]+!u', ' ', $real_name);
if (!$user_name || !$real_name) {
return array(ERROR_RECOVER, L('entervalidusername'));
}
// Delete registration codes older than 24 hours
$yesterday = time() - 86400;
$db->x->execParam('DELETE FROM {registrations} WHERE reg_time < ?', $yesterday);
$taken = $db->x->getRow('SELECT u.user_id FROM {users} u, {registrations} r
WHERE u.user_name = ? OR r.user_name = ?', null, array($user_name, $user_name));
if ($taken) {
return array(ERROR_RECOVER, L('usernametaken'));
}
$taken = $db->x->getRow("SELECT user_id\n FROM {users}\n WHERE jabber_id = ? AND jabber_id != NULL\n OR email_address = ? AND email_address != NULL", null, array($jabber_id, $email));
if ($taken) {
return array(ERROR_RECOVER, L('emailtaken'));
}
if ($fs->prefs['use_recaptcha']) {
$solution = new reCAPTCHA_Solution();
$solution->privatekey = $fs->prefs['recaptcha_priv_key'];
$solution->challenge = Post::val('recaptcha_challenge_field');
$solution->response = Post::val('recaptcha_response_field');
$solution->remoteip = $_SERVER['REMOTE_ADDR'];
if (!$solution->isValid()) {
return array(ERROR_RECOVER, $solution->error_code);
}
}
$magic_url = substr(md5(uniqid(rand(), true)), 0, 20);
//send the email first.
if (Notifications::send(Post::val('email_address'), ADDRESS_EMAIL, NOTIFY_CONFIRMATION, array($baseurl, $magic_url, $user_name))) {
//email sent succefully, now update the database.
$reg_values = array('reg_time' => time(), 'user_name' => $user_name, 'real_name' => $real_name, 'email_address' => Post::val('email_address'), 'jabber_id' => Post::val('jabber_id'), 'notify_type' => Post::num('notify_type'), 'magic_url' => $magic_url, 'time_zone' => Post::num('time_zone'));
// Insert everything into the database
$query = $db->x->autoExecute('{registrations}', $reg_values);
if (!PEAR::isError($query)) {
return array(SUBMIT_OK, L('codesent'), $baseurl);
}
} else {
return array(ERROR_INPUT, L('codenotsent'));
}
}
示例4: action_requestclose
function action_requestclose($task)
{
global $proj, $user, $db;
if (Post::val('action') == 'requestclose') {
Flyspray::AdminRequest(1, $proj->id, $task['task_id'], $user->id, Post::val('reason_given'));
Flyspray::logEvent($task['task_id'], 20, Post::val('reason_given'));
} else {
Flyspray::AdminRequest(2, $proj->id, $task['task_id'], $user->id, Post::val('reason_given'));
Flyspray::logEvent($task['task_id'], 21, Post::val('reason_given'));
Backend::add_notification($user->id, $task['task_id']);
}
// Now, get the project managers' details for this project
$pms = $db->x->GetCol('SELECT u.user_id
FROM {users} u
LEFT JOIN {users_in_groups} uig ON u.user_id = uig.user_id
LEFT JOIN {groups} g ON uig.group_id = g.group_id
WHERE g.project_id = ? AND g.manage_project = 1', null, $proj->id);
if (count($pms)) {
Notifications::send($pms, ADDRESS_USER, NOTIFY_PM_REQUEST, array('task_id' => $task['task_id']));
}
return array(SUBMIT_OK, L('adminrequestmade'));
}