public function add_notification($notification_data, $notification_type_name = 'gfksx.thanksforposts.notification.type.thanks') { if ($this->notification_exists($notification_data, $notification_type_name)) { $this->notification_manager->update_notifications($notification_type_name, $notification_data); } else { $this->notification_manager->add_notifications($notification_type_name, $notification_data); } }
/** * Process adding dates * @param \phpbb\event\data $event * @param bool $is_member_or_owner */ protected function process_add_date($event, $is_member_or_owner) { $add_dates = $this->request->variable('add_date', '', true); if (empty($add_dates)) { return array(); } if (!$is_member_or_owner) { return array($this->user->lang('NOT_AUTH_HOOKUP')); } $hookup_errors = array(); $add_dates = array_map("trim", explode("\n", $add_dates)); //replace german date formats $add_dates = preg_replace('#(\\d{1,2})\\. ?(\\d{1,2})\\. ?(\\d{2})[,:]?[,: ]#', '20$3-$2-$1 ', $add_dates); $add_dates = preg_replace('#(\\d{1,2})\\. ?(\\d{1,2})\\. ?(\\d{4})[,:]?[,: ]#', '$3-$2-$1 ', $add_dates); $date_added = false; foreach ($add_dates as $date) { $text_match = preg_match('#\\#(.*)#', $date, $text); //strtotime uses the local (server) timezone, so parse manually and use gmmktime to ignore any timezone if (!preg_match('#(\\d{4})-(\\d{1,2})-(\\d{1,2}) (\\d{1,2}):(\\d{2})#', $date) && !$text_match) { $hookup_errors[] = "{$date}: {$this->user->lang['INVALID_DATE']}"; } else { $hookup_continue = true; if ($text_match) { $text = trim($text[1]); $date_time = '0'; } else { $text = null; $date_time = $this->user->get_timestamp_from_format('Y-m-d H:i', $date); if ($date_time < time()) { $hookup_continue = false; $hookup_errors[] = "{$date}: {$this->user->lang['CANNOT_ADD_PAST']}"; } } if ($hookup_continue) { //check for duplicate if (!$this->hookup->add_date($date_time, $text)) { $hookup_errors[] = sprintf($this->user->lang['DATE_ALREADY_ADDED'], $this->user->format_date($date_time, $text)); } else { $date_added = true; } } } } if ($date_added) { // Notification $notify_data = array('user_id' => $this->user->data['user_id'], 'topic_title' => $event['topic_data']['topic_title'], 'topic_id' => $event['topic_id'], 'forum_id' => $event['forum_id']); $this->notification_manager->update_notifications('gn36.hookup.notification.type.date_added', $notify_data); } return $hookup_errors; }
/** * Adds the notifications during submitting a post. * We've rebuild the if/else switch/case constructs here the same way there are in * submit_post() function, so we should achieve the same notifications as "notification.type.quote". * * @param string $mode The mode of this submit * @param int $post_visibility Post visibility state as number (see constants) * @param string $username The real username for this post (including guest things) * @param array $data The post data * @param mixed $subject The real post subject */ public function submit_post_notifications($mode, $post_visibility, $username, $data, $subject) { $poster_id = $mode == 'edit' ? $data['poster_id'] : (int) $this->user->data['user_id']; $current_time = $data['post_time'] > 0 ? $data['post_time'] : time(); // Send Notifications $notification_data = array_merge($data, array('topic_title' => isset($data['topic_title']) ? $data['topic_title'] : $subject, 'post_username' => $username, 'poster_id' => $poster_id, 'post_text' => $data['message'], 'post_time' => $current_time, 'post_subject' => $subject)); if ($post_visibility == ITEM_APPROVED) { switch ($mode) { case 'post': case 'reply': case 'quote': $this->notification_manager->add_notifications(array('wolfsblvt.mentions.notification.type.mention'), $notification_data); break; case 'edit_topic': case 'edit_first_post': case 'edit': case 'edit_last_post': $this->notification_manager->update_notifications(array('wolfsblvt.mentions.notification.type.mention'), $notification_data); break; } } }