コード例 #1
0
ファイル: mentions.php プロジェクト: melvingb/mentions
 /**
  * Sends notifications for approved topics
  * 
  * @param array $topic_info Array containing the topic_info (topic_id => topic_data) that is approved
  */
 public function approve_topics_notifications($topic_info)
 {
     foreach ($topic_info as $topic_id => $topic_data) {
         if ($topic_data['topic_visibility'] == ITEM_UNAPPROVED) {
             $this->notification_manager->add_notifications(array('wolfsblvt.mentions.notification.type.mention'), $topic_data);
         }
         $this->notification_manager->mark_notifications_read('wolfsblvt.mentions.notification.type.mention', $topic_data['post_id'], $this->user->data['user_id']);
     }
 }
コード例 #2
0
 /**
  * Notify users which had submitted their websites
  *
  * @return null
  */
 public function notifiy_submiters()
 {
     if (!class_exists('messenger')) {
         include $this->root_path . 'includes/functions_messenger.' . $this->php_ext;
     }
     $messenger = new \messenger(false);
     foreach ($this->links_data as $row) {
         $this->notification->mark_notifications_read('ernadoo.phpbbdirectory.notification.type.directory_website_in_queue', (int) $row['link_id'], false);
         // New notification system can't send mail to an anonymous user with an email adress storage in another table than phpbb_users
         if ($row['link_user_id'] == ANONYMOUS) {
             $username = $email = $row['link_guest_email'];
             $messenger->template('@ernadoo_phpbbdirectory/directory_website_' . $this->action, $row['user_lang']);
             $messenger->to($email, $username);
             $messenger->assign_vars(array('USERNAME' => htmlspecialchars_decode($username), 'LINK_NAME' => $row['link_name']));
             $messenger->send(NOTIFY_EMAIL);
         } else {
             $notification_data = array('user_from' => (int) $row['link_user_id'], 'link_id' => (int) $row['link_id'], 'link_name' => $row['link_name'], 'cat_name' => \ernadoo\phpbbdirectory\core\categorie::getname((int) $row['link_cat']), 'cat_id' => (int) $row['link_cat']);
             $this->notification->add_notifications('ernadoo.phpbbdirectory.notification.type.directory_website_' . $this->action, $notification_data);
         }
     }
 }
コード例 #3
0
 public function notification_markread($item_ids)
 {
     // Mark post notifications read for this user in this topic
     $this->notification_manager->mark_notifications_read(array('gfksx.thanksforposts.notification.type.thanks', 'gfksx.thanksforposts.notification.type.thanks_remove'), $item_ids, $this->user->data['user_id']);
 }
コード例 #4
0
    /**
     * Process all hookup stuff in viewtopic
     *
     * @param \phpbb\event\data $event
     */
    public function show_hookup_viewtopic($event)
    {
        // Check auth
        if (!$this->auth->acl_get('f_hookup', $event['forum_id']) && !$this->auth->acl_get('m_edit', $event['forum_id'])) {
            return;
        }
        if (!$this->hookup->load_hookup($event['topic_id'])) {
            // No hookup for this topic
            return;
        }
        // Load Language file
        $this->user->add_lang_ext('gn36/hookup', 'hookup');
        // Now process all submits, if any
        $hookup_errors = $this->process_submit($event);
        // If the hookup is disabled, then return now (also if we just disabled it)
        if (!$this->hookup->hookup_enabled) {
            return;
        }
        // Set the hookup as "viewed" for the current user:
        $this->hookup->set_user_data($this->user->data['user_id'], 0);
        $notifications_read = array('gn36.hookup.notification.type.invited', 'gn36.hookup.notification.type.user_added', 'gn36.hookup.notification.type.date_added', 'gn36.hookup.notification.type.active_date_set', 'gn36.hookup.notification.type.active_date_reset');
        $this->notification_manager->mark_notifications_read($notifications_read, $event['topic_id'], $this->user->data['user_id']);
        // We actually need to delete these to be able to send them again...
        // There must be a better solution to this, but there is no unique single value ID that can be used for this
        // We would need a combination of two numeric values to generate a unique ID (user_id <-> topic_id)
        // TODO
        // This will submit all changes to the db, including the ones processed in $this->process_submit();
        $this->hookup->submit();
        // Some frequently used data:
        $forum_id = $event['forum_id'];
        $topic_id = $event['topic_id'];
        $is_owner = $event['topic_data']['topic_poster'] == $this->user->data['user_id'] || $this->auth->acl_get('m_edit', $event['forum_id']);
        $is_member = isset($this->hookup->hookup_users[$this->user->data['user_id']]);
        $viewtopic_url = append_sid("{$this->phpbb_root_path}viewtopic.{$this->phpEx}?f={$forum_id}&t={$topic_id}");
        // TODO: populate lists for adding groups, deleting dates and users
        if ($is_owner) {
            // Populate group list
            $sql = 'SELECT group_id, group_name, group_type
				FROM ' . GROUPS_TABLE . '
				WHERE group_type <> ' . GROUP_HIDDEN . ' AND ' . $this->db->sql_in_set('group_name', array('GUESTS', 'BOTS'), true);
            $result = $this->db->sql_query($sql);
            $s_group_list = '';
            while ($row = $this->db->sql_fetchrow($result)) {
                $s_group_list .= '<option value="' . $row['group_id'] . '"' . ($row['group_type'] == GROUP_SPECIAL ? ' class="sep"' : '') . '>';
                $s_group_list .= $row['group_type'] == GROUP_SPECIAL ? $this->user->lang['G_' . $row['group_name']] : $row['group_name'];
                $s_group_list .= '</option>';
            }
            $this->db->sql_freeresult($result);
            $this->template->assign_var('S_GROUP_LIST', $s_group_list);
        }
        if (count($this->hookup->hookup_dates) == 0) {
            $hookup_errors[] = $this->user->lang['HOOKUP_NO_DATES'];
        }
        if (count($this->hookup->hookup_users) == 0) {
            $hookup_errors[] = $this->user->lang['HOOKUP_NO_USERS'];
        }
        $active_date_date = '-';
        if (isset($this->hookup->hookup_dates[$this->hookup->hookup_active_date])) {
            $active_date_date = $this->user->format_date($this->hookup->hookup_dates[$this->hookup->hookup_active_date]['date_time']);
            if ($this->hookup->hookup_dates[$this->hookup->hookup_active_date]['text'] != null) {
                $active_date_date = $this->hookup->hookup_dates[$this->hookup->hookup_active_date]['text'];
            }
        }
        $this->template->assign_vars(array('S_HAS_HOOKUP' => true, 'S_IS_HOOKUP_OWNER' => $is_owner, 'S_IS_HOOKUP_MEMBER' => $is_member, 'S_HAS_DATES' => empty($this->hookup->hookup_dates) ? false : true, 'S_HAS_USERS' => empty($this->hookup->hookup_users) ? false : true, 'S_IS_SELF_INVITE' => $this->hookup->hookup_self_invite, 'S_AUTORESET' => $this->hookup->hookup_autoreset, 'S_HOOKUP_ACTION' => $viewtopic_url, 'S_ACTIVE_DATE' => $this->hookup->hookup_active_date, 'ACTIVE_DATE_DATE' => $active_date_date, 'S_NUM_DATES' => count($this->hookup->hookup_dates), 'S_NUM_DATES_PLUS_1' => count($this->hookup->hookup_dates) + 1, 'U_UNSET_ACTIVE' => $viewtopic_url . '&amp;set_active=0', 'U_FIND_USERNAME' => append_sid("{$this->phpbb_root_path}memberlist.{$this->phpEx}", 'mode=searchuser&amp;form=ucp&amp;field=usernames'), 'UA_FIND_USERNAME' => append_sid("{$this->phpbb_root_path}memberlist.{$this->phpEx}", 'mode=searchuser&form=ucp&field=usernames', false), 'USER_COMMENT' => isset($this->hookup->hookup_users[$this->user->data['user_id']]) ? $this->hookup->hookup_users[$this->user->data['user_id']]['comment'] : '', 'HOOKUP_ERRORS' => count($hookup_errors) > 0 ? implode('<br />', $hookup_errors) : false, 'HOOKUP_YES' => hookup::HOOKUP_YES, 'HOOKUP_MAYBE' => hookup::HOOKUP_MAYBE, 'HOOKUP_NO' => hookup::HOOKUP_NO, 'HOOKUP_UNSET' => hookup::HOOKUP_UNSET, 'L_HOOKUP_YES' => $this->user->lang['HOOKUP_STATUS'][hookup::HOOKUP_YES], 'L_HOOKUP_NO' => $this->user->lang['HOOKUP_STATUS'][hookup::HOOKUP_NO], 'L_HOOKUP_MAYBE' => $this->user->lang['HOOKUP_STATUS'][hookup::HOOKUP_MAYBE], 'L_HOOKUP_UNSET' => $this->user->lang['HOOKUP_STATUS'][hookup::HOOKUP_UNSET], 'L_HOOKUP_Y' => $this->user->lang['HOOKUP_STATUS'][hookup::HOOKUP_YES][0], 'L_HOOKUP_N' => $this->user->lang['HOOKUP_STATUS'][hookup::HOOKUP_NO][0], 'L_HOOKUP_M' => $this->user->lang['HOOKUP_STATUS'][hookup::HOOKUP_MAYBE][0], 'S_EXT_PATH' => $this->hookup_path, 'S_LANG_NAME' => $this->user->lang_name));
        // Output dates
        foreach ($this->hookup->hookup_dates as $hookup_date) {
            $yes_count = $this->hookup->hookup_available_sums[$hookup_date['date_id']][hookup::HOOKUP_YES];
            $maybe_count = $this->hookup->hookup_available_sums[$hookup_date['date_id']][hookup::HOOKUP_MAYBE];
            $no_count = $this->hookup->hookup_available_sums[$hookup_date['date_id']][hookup::HOOKUP_NO];
            //$total_count = $yes_count + $maybe_count + $no_count; //unset_count?
            $total_count = count($this->hookup->hookup_users);
            $unset_count = $total_count - ($yes_count + $maybe_count + $no_count);
            $yes_percent = $total_count > 0 ? round($yes_count / $total_count * 100) : 0;
            $maybe_percent = $total_count > 0 ? round($maybe_count / $total_count * 100) : 0;
            $no_percent = $total_count > 0 ? round($no_count / $total_count * 100) : 0;
            $unset_percent = 100 - ($yes_percent + $maybe_percent + $no_percent);
            // More than 100%
            if ($unset_percent < 0) {
                if ($maybe_percent > 0) {
                    $maybe_percent--;
                } else {
                    $no_percent--;
                }
            }
            $full_date = $this->user->format_date($hookup_date['date_time']);
            $short_date = $this->user->format_date($hookup_date['date_time'], $this->user->lang['HOOKUP_DATEFORMAT']);
            if ($hookup_date['text'] != null) {
                $short_date = $full_date = $hookup_date['text'];
            }
            $this->template->assign_block_vars('date', array('ID' => $hookup_date['date_id'], 'DATE' => $short_date, 'FULL_DATE' => $full_date, 'YES_COUNT' => $yes_count, 'YES_PERCENT' => $yes_percent, 'MAYBE_COUNT' => $maybe_count, 'MAYBE_PERCENT' => $maybe_percent, 'NO_COUNT' => $no_count, 'NO_PERCENT' => $no_percent, 'UNSET_COUNT' => $unset_count, 'UNSET_PERCENT' => $unset_percent, 'S_IS_ACTIVE' => $hookup_date['date_id'] == $this->hookup->hookup_active_date, 'U_SET_ACTIVE' => $viewtopic_url . '&amp;set_active=' . $hookup_date['date_id']));
        }
        // Output details
        if (!empty($this->hookup->hookup_users)) {
            // Fetch User details
            $sql = 'SELECT user_id, username, user_colour FROM ' . USERS_TABLE . ' WHERE ' . $this->db->sql_in_set('user_id', array_keys($this->hookup->hookup_users));
            $result = $this->db->sql_query($sql);
            $user_details = array();
            while ($row = $this->db->sql_fetchrow($result)) {
                $user_details[$row['user_id']] = $row;
            }
        }
        foreach ($this->hookup->hookup_users as $hookup_user) {
            $is_self = $hookup_user['user_id'] == $this->user->data['user_id'];
            $this->template->assign_block_vars('user', array('ID' => $hookup_user['user_id'], 'NAME' => $user_details[$hookup_user['user_id']]['username'], 'COMMENT' => isset($hookup_user['comment']) ? $hookup_user['comment'] : '', 'USERNAME_FULL' => get_username_string('full', $hookup_user['user_id'], $user_details[$hookup_user['user_id']]['username'], $user_details[$hookup_user['user_id']]['user_colour']), 'IS_SELF' => $is_self));
            foreach ($this->hookup->hookup_dates as $hookup_date) {
                $available = isset($this->hookup->hookup_availables[$hookup_user['user_id']][$hookup_date['date_id']]) ? $this->hookup->hookup_availables[$hookup_user['user_id']][$hookup_date['date_id']] : hookup::HOOKUP_UNSET;
                $this->template->assign_block_vars('user.date', array('ID' => $hookup_date['date_id'], 'AVAILABLE' => $this->user->lang['HOOKUP_STATUS'][$available], 'STATUS_YES' => $available == hookup::HOOKUP_YES, 'STATUS_NO' => $available == hookup::HOOKUP_NO, 'STATUS_MAYBE' => $available == hookup::HOOKUP_MAYBE, 'STATUS_UNSET' => $available == hookup::HOOKUP_UNSET, 'S_SELECT_NAME' => 'available[' . $hookup_date['date_id'] . ']', 'S_IS_ACTIVE' => $hookup_date['date_id'] == $this->hookup->hookup_active_date));
            }
        }
    }