本文整理汇总了PHP中Notification类的典型用法代码示例。如果您正苦于以下问题:PHP Notification类的具体用法?PHP Notification怎么用?PHP Notification使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Notification类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetNotification
public function testGetNotification()
{
$SofortLibNotification = new Notification();
$statusNotification = '';
$this->assertFalse($SofortLibNotification->getNotification($statusNotification));
$statusNotification = '<?xml version="1.0" encoding="UTF-8"?>
<status_notification>
<transaction>1324-1234-5483-4891</transaction>
<time>2010-04-14T19:01:08+02:00</time>
</status_notification>';
$notification = '1324-1234-5483-4891';
$this->assertEquals($notification, $SofortLibNotification->getNotification($statusNotification));
$statusNotification = '<?xml version="1.0" encoding="UTF-8"?>
<status_test>
<transaction>1324-1234-5483-4891</transaction>
<time>2010-04-14T19:01:08+02:00</time>
</status_test>';
$this->assertFalse($SofortLibNotification->getNotification($statusNotification));
$statusNotification = '<?xml version="1.0" encoding="UTF-8"?>
<status_notification>
<nontransaction>1324-1234-5483-4891</nontransaction>
<time>2010-04-14T19:01:08+02:00</time>
</status_notification>';
$this->assertFalse($SofortLibNotification->getNotification($statusNotification));
}
示例2: plugin_typology_uninstall
function plugin_typology_uninstall()
{
global $DB;
// Plugin tables deletion
$tables = array("glpi_plugin_typology_profiles", "glpi_plugin_typology_typologies", "glpi_plugin_typology_typologycriterias", "glpi_plugin_typology_typologycriteriadefinitions", "glpi_plugin_typology_typologies_items");
foreach ($tables as $table) {
$DB->query("DROP TABLE IF EXISTS `{$table}`;");
}
// Plugin adding information on general table deletion
$tables_glpi = array("glpi_displaypreferences", "glpi_documents_items", "glpi_bookmarks", "glpi_logs");
foreach ($tables_glpi as $table_glpi) {
$DB->query("DELETE FROM `{$table_glpi}` WHERE `itemtype` = 'PluginTypologyTypology';");
}
//drop rules
$Rule = new Rule();
$a_rules = $Rule->find("`sub_type`='PluginTypologyRuleTypology'");
foreach ($a_rules as $data) {
$Rule->delete($data);
}
$notif = new Notification();
$options = array('itemtype' => 'PluginTypologyTypology', 'event' => 'AlertNotValidatedTypology', 'FIELDS' => 'id');
foreach ($DB->request('glpi_notifications', $options) as $data) {
$notif->delete($data);
}
return true;
}
示例3: fire
/**
* Fire this notification on given comment object
*
* @param type $comment
*/
public static function fire($comment)
{
$targetCreatorId = $comment->content->user_id;
// gets also an new comment notification
// Get Users which are also commented this model
$userIds = array();
$otherComments = Comment::model()->findAllByAttributes(array('object_model' => $comment->object_model, 'object_id' => $comment->object_id));
foreach ($otherComments as $otherComment) {
if ($comment->created_by != $otherComment->created_by && $otherComment->created_by != $targetCreatorId) {
$userIds[] = $otherComment->created_by;
}
}
$userIds = array_unique($userIds);
// Write new Notification for them
foreach ($userIds as $userId) {
$notification = new Notification();
$notification->class = "AlsoCommentedNotification";
$notification->user_id = $userId;
$notification->space_id = $comment->space_id;
$notification->source_object_model = "Comment";
$notification->source_object_id = $comment->id;
$notification->target_object_model = $comment->object_model;
$notification->target_object_id = $comment->object_id;
$notification->save();
}
}
示例4: uninstall
/**
* Remove mreporting notifications from GLPI.
*
* @return array 'success' => true on success
*/
static function uninstall()
{
global $DB;
$queries = array();
// Remove NotificationTargets and Notifications
$notification = new Notification();
$result = $notification->find("itemtype = 'PluginMreportingNotification'");
foreach ($result as $row) {
$notification_id = $row['id'];
$queries[] = "DELETE FROM glpi_notificationtargets \n WHERE notifications_id = " . $notification_id;
$queries[] = "DELETE FROM glpi_notifications \n WHERE id = " . $notification_id;
}
// Remove NotificationTemplateTranslations and NotificationTemplates
$template = new NotificationTemplate();
$result = $template->find("itemtype = 'PluginMreportingNotification'");
foreach ($result as $row) {
$template_id = $row['id'];
$queries[] = "DELETE FROM glpi_notificationtemplatetranslations \n WHERE notificationtemplates_id = " . $template_id;
$queries[] = "DELETE FROM glpi_notificationtemplates \n WHERE id = " . $template_id;
}
foreach ($queries as $query) {
$DB->query($query);
}
return array('success' => true);
}
示例5: execute
public function execute(&$params)
{
$options =& $this->config['options'];
$notif = new Notification();
$notif->user = $this->parseOption('user', $params);
$notif->createdBy = 'API';
$notif->createDate = time();
// file_put_contents('triggerLog.txt',"\n".$notif->user,FILE_APPEND);
// if($this->parseOption('type',$params) == 'auto') {
// if(!isset($params['model']))
// return false;
// $notif->modelType = get_class($params['model']);
// $notif->modelId = $params['model']->id;
// $notif->type = $this->getNotifType();
// } else {
$notif->type = 'custom';
$notif->text = $this->parseOption('text', $params);
// }
if ($notif->save()) {
return array(true, "");
} else {
$errors = $notif->getErrors();
return array(false, array_shift($errors));
}
}
示例6: getLatestNotificationsAndCounts
public function getLatestNotificationsAndCounts($userId)
{
$notification = new Notification();
$listUnread = $notification->Find("toUser = ? and status = ?", array($userId, 'Unread'));
$unreadCount = count($listUnread);
$limit = $unreadCount < 10 ? 10 : $unreadCount;
$list = $notification->Find("toUser = ? order by time desc limit ?", array($userId, $limit));
$newList = array();
$fs = new FileService();
foreach ($list as $noti) {
if ($noti->fromEmployee > 0) {
$employee = $this->baseService->getElement('Employee', $noti->fromEmployee, null, true);
if (!empty($employee)) {
$employee = $fs->updateEmployeeImage($employee);
$noti->image = $employee->image;
if (empty($noti->image)) {
if ($employee->gender == 'Male') {
$noti->image = BASE_URL . "images/user_male.png";
} else {
$noti->image = BASE_URL . "images/user_female.png";
}
}
$newList[] = $noti;
}
} else {
$noti->image = BASE_URL . "images/icehrm.png";
$newList[] = $noti;
}
}
return array($unreadCount, $list);
}
示例7: check_writable_relative
function check_writable_relative($dir)
{
$uid = posix_getuid();
$gid = posix_getgid();
$user_info = posix_getpwuid($uid);
$user = $user_info['name'];
$group_info = posix_getgrgid($gid);
$group = $group_info['name'];
$fix_cmd = '. ' . _("To fix that, execute following commands as root") . ':<br><br>' . "cd " . getcwd() . "<br>" . "mkdir -p {$dir}<br>" . "chown {$user}:{$group} {$dir}<br>" . "chmod 0700 {$dir}";
if (!is_dir($dir)) {
$config_nt = array('content' => _("Required directory " . getcwd() . "{$dir} does not exist") . $fix_cmd, 'options' => array('type' => 'nf_warning', 'cancel_button' => FALSE), 'style' => 'width: 80%; margin: 20px auto;');
$nt = new Notification('nt_1', $config_nt);
$nt->show();
exit;
}
if (!($stat = stat($dir))) {
$config_nt = array('content' => _("Could not stat configs dir") . $fix_cmd, 'options' => array('type' => 'nf_warning', 'cancel_button' => FALSE), 'style' => 'width: 80%; margin: 20px auto;');
$nt = new Notification('nt_1', $config_nt);
$nt->show();
exit;
}
// 2 -> file perms (must be 0700)
// 4 -> uid (must be the apache uid)
// 5 -> gid (must be the apache gid)
if ($stat[2] != 16832 || $stat[4] !== $uid || $stat[5] !== $gid) {
$config_nt = array('content' => _("Invalid perms for configs dir") . $fix_cmd, 'options' => array('type' => 'nf_warning', 'cancel_button' => FALSE), 'style' => 'width: 80%; margin: 20px auto;');
$nt = new Notification('nt_1', $config_nt);
$nt->show();
exit;
}
}
示例8: fire
/**
* Fires this notification
*
* @param type $like
*/
public static function fire($like)
{
// Determine Space Id if exists
$spaceId = "";
if ($like->content->container instanceof Space) {
$spaceId = $like->content->container->id;
}
// Determine who created the liked content / content addon
$createdBy = "";
if ($like->source instanceof HActiveRecordContent) {
$createdBy = $like->source->content->created_by;
} elseif ($like->source instanceof HActiveRecordContentAddon) {
$createdBy = $like->source->created_by;
}
if ($createdBy != "" && $createdBy != $like->created_by) {
// Send Notification to owner
$notification = new Notification();
$notification->class = "NewLikeNotification";
$notification->user_id = $createdBy;
$notification->space_id = $spaceId;
$notification->source_object_model = "Like";
$notification->source_object_id = $like->id;
$notification->target_object_model = $like->object_model;
$notification->target_object_id = $like->object_id;
$notification->save();
}
}
示例9: display_errors
function display_errors($info_error)
{
$errors = implode("</div><div style='padding-top: 3px;'>", $info_error);
$error_msg = "<div>" . _("The following errors occurred:") . "</div><div style='padding-left: 15px;'><div>{$errors}</div></div>";
$config_nt = array('content' => $error_msg, 'options' => array('type' => 'nf_error', 'cancel_button' => FALSE), 'style' => 'width: 90%; margin: 20px auto; padding: 10px 0px; text-align: left; font-style: italic');
$nt = new Notification('nt_1', $config_nt);
return $nt->show(FALSE);
}
示例10: createForUserRecord
public static function createForUserRecord(User $user, PathRecord $record)
{
$notify = new Notification();
$notify->user_id = $user->id;
$notify->path_record_id = $record->id;
$notify->save();
return $notify;
}
示例11: createMessageObject
/**
* Creates a by $type parameter specified message
*
* @param string $type
* @param string $message
*
* @return Notification
*/
private function createMessageObject(string $type, string $message) : Notification
{
$msg = new Notification();
$msg->setType($type);
$msg->setMessage($message);
$this->handler->add($msg);
return $msg;
}
示例12: send
/**
* Send the given notification with Apple Push Notification Service Server.
*
* @param Notification $notification the notification to send
* @return boolean true on success, false if there was an error.
*/
public function send($notification)
{
$config = Config::getInstance();
$appRoot = $config->getString('appRootDir');
// Instanciate a new ApnsPHP_Push object, with the provider certificate
$push = new ApnsPHP_Push(ApnsPHP_Abstract::ENVIRONMENT_PRODUCTION, $appRoot . $config->getString('monitoring/notification/push/providerCertificateDir'));
// Set custom logger
$push->setLogger(new ApnsPHP_Log_Fruition());
// Set the Provider Certificate passphrase
$push->setProviderCertificatePassphrase($config->getString('monitoring/notification/push/passphrase'));
// Set the Root Certificate Autority to verify the Apple remote peer
$push->setRootCertificationAuthority($appRoot . $config->getString('monitoring/notification/push/rootCertificateAuthorityDir'));
// Get recipient list. If no registration id (user did not connect to the
// mobile app, we stop the process
$stringRecipients = $notification->getRecipient();
if (empty($stringRecipients)) {
Logger::info("No registration id was found. The notification is not sent.");
return false;
}
// Connect to the Apple Push Notification Service
$push->connect();
// Create a message for each device
$message = new ApnsPHP_Message();
$message->setText($notification->getContent());
$message->setSound();
$message->setExpiry(30);
// 60 seconds
$recipientList = explode(",", $notification->getRecipient());
foreach ($recipientList as $registrationId) {
$message->addRecipient($registrationId);
}
// Add the message to the message queue
$push->add($message);
// Send all messages in the message queue
$push->send();
// Disconnect from the Apple Push Notification Service
$push->disconnect();
// Examine the error message container.
$aErrorQueue = $push->getErrors();
if (!empty($aErrorQueue)) {
foreach ($aErrorQueue as $error) {
foreach ($error['ERRORS'] as $err) {
//For statusCode = 8, which is Invalid Token, we delete the token.
if ($err['statusCode'] == self::INVALID_TOKEN) {
if ($this->handlerErrorCallBack) {
$token = $error['MESSAGE']->getRecipient();
call_user_func($this->handlerErrorCallBack, $token);
}
}
Logger::error("Sending push notification failed. Error code: " . $err['statusCode'] . ". Message: " . $err['statusMessage']);
}
}
return false;
}
//If success
Logger::info("Notification sent with device token " . $notification->getRecipient());
return true;
}
示例13: getLatestNotificationsAndCounts
public function getLatestNotificationsAndCounts($userId)
{
$notification = new Notification();
$listUnread = $notification->Find("toUser = ? and status = ?", array($userId, 'Unread'));
$unreadCount = count($listUnread);
$limit = $unreadCount < 20 ? 20 : $unreadCount;
$list = $notification->Find("toUser = ? order by time desc limit ?", array($userId, $limit));
return array($unreadCount, $list);
}
示例14: show_notification
function show_notification($msg, $type = 'nf_error')
{
echo "<div class='container' style='width:100%;height:30px;margin:10px auto;text-align:center'>";
$config_nt = array('content' => $msg, 'options' => array('type' => $type, 'cancel_button' => FALSE), 'style' => ' margin:0 auto;text-align:center;');
$nt = new Notification('nt_panel', $config_nt);
$nt->show();
echo "</div>";
die;
}
示例15: checkAuthCreatedByStudent
/**
* A method to check whether a user is allowed to remove a notification
* In particular, if it's the student who created the notification, only a supervisor can
* remove it from the list (it is necessary for the supervisor to see every student action)
* @param Notification $notif the notification object
*/
private function checkAuthCreatedByStudent(Notification $notif)
{
# If it's the student who created the notification, only a supervisor can
# remove it from the list (it is necessary for the supervisor to see every student action)
$creatorUserType = $this->model('User', $notif->getCreatorUserId())->getType();
if ($creatorUserType == User::USER_TYPE_STUDENT && HTTPSession::getInstance()->USER_TYPE != User::USER_TYPE_SUPERVISOR) {
header('Location: ' . SITE_URL . 'notifications');
}
}