Exemple #1
0
     } else {
         $messagephrase = $do_discussions ? $vbphrase['moderated_social_group_discussions'] : $vbphrase['moderated_social_group_messages'];
         if ($do_discussions and !fetch_socialgroup_modperm('canmoderatediscussions') or !$do_discussions and !fetch_socialgroup_modperm('canmoderategroupmessages')) {
             print_no_permission();
         }
     }
 }
 // Items to display per page
 if ($do_discussions) {
     $perpage = (!$vbulletin->GPC['perpage'] or $vbulletin->GPC['perpage'] > $vbulletin->options['sgd_maxperpage']) ? $vbulletin->options['sgd_perpage'] : $vbulletin->GPC['perpage'];
 } else {
     $perpage = (!$vbulletin->GPC['perpage'] or $vbulletin->GPC['perpage'] > $vbulletin->options['gm_maxperpage']) ? $vbulletin->options['gm_perpage'] : $vbulletin->GPC['perpage'];
 }
 // Create message collection
 $itemtype = $do_discussions ? 'discussion' : 'message';
 $collection_factory = new vB_Group_Collection_Factory($vbulletin);
 $collection = $collection_factory->create($itemtype, false, $vbulletin->GPC['pagenumber'], $perpage, $descending);
 // Set filters
 $collection->set_ignore_marking(false);
 $collection->filter_show_discussions($do_discussions);
 $collection->filter_show_visible(false);
 $collection->filter_days_prune($daysprune);
 $collection->filter_sort_field($sortfield);
 switch ($type) {
     case 'deleted':
         $collection->filter_show_moderated(false);
         break;
     case 'new':
         $collection->filter_show_visible(true);
         break;
     case 'moderated':
/**
 * Marks a discussion or group as read.
 *
 * @param string $type						- 'group' or 'discussion'
 * @param int $userid						- The id of the user
 * @param int $itemid						- The id of the item to mark
 */
function exec_sg_mark_as_read($type, $itemid)
{
	global $vbulletin;

	if ($vbulletin->userinfo['userid'])
	{
		if ($vbulletin->options['threadmarking'])
		{
			$table = TABLE_PREFIX . (($type == 'group') ? 'groupread' : 'discussionread');
			$idcol = ($type == 'group') ? 'groupid' : 'discussionid';

			$vbulletin->db->query_write("REPLACE INTO $table (userid,$idcol,readtime)
										VALUES (" . intval($vbulletin->userinfo['userid']) . ", " . intval($itemid) . ", " . TIMENOW . ")");

			if ('discussion' == $type AND 2 == $vbulletin->options['threadmarking'])
			{
				// quite expensive check to see if there are any unread discussions
				if ($discussion = fetch_socialdiscussioninfo($itemid))
				{
					require_once(DIR . '/includes/class_groupmessage.php');

					// Create discussion collection
					$collection_factory = new vB_Group_Collection_Factory($vbulletin);
					$collection = $collection_factory->create('discussion', $discussion['groupid'], 0, 1, false, true);
					$collection->filter_show_read(false);

					if (!$collection->fetch_count())
					{
						exec_sg_mark_as_read('group', $discussion['groupid']);
					}
					unset($collection, $collection_factory);
				}
			}
		}
		else
		{
			// set read in cookie
			set_bbarray_cookie($type . '_marking', $itemid, TIMENOW);
		}
	}
	else
	{
		vbsetcookie('lastvisit', TIMENOW);
	}
}
Exemple #3
0
                ($hook = vBulletinHook::fetch_hook('group_list_groupbit')) ? eval($hook) : false;
                $templater = vB_Template::create('socialgroups_groupmodlist_bit');
                $templater->register('group', $group);
                $grouplist .= $templater->render();
            }
        }
        $show['socialgroups'] = true;
    }
    unset($socialgroupsearch);
}
// ############################ start new subscribed to discussions ##############################
$show['discussions'] = false;
if ($vbulletin->options['socnet'] & $vbulletin->bf_misc_socnet['enable_groups'] and $vbulletin->userinfo['permissions']['socialgrouppermissions'] & $vbulletin->bf_ugp_socialgrouppermissions['canviewgroups'] and $vbulletin->options['socnet_groups_msg_enabled']) {
    require_once DIR . '/includes/class_groupmessage.php';
    // Create message collection
    $collection_factory = new vB_Group_Collection_Factory($vbulletin);
    $collection = $collection_factory->create('discussion', false, $vbulletin->GPC['pagenumber'], false, false, true);
    $collection->set_ignore_marking(false);
    $collection->filter_show_unsubscribed(false);
    // Check if the user is subscribed to any discussions
    if ($collection->fetch_count()) {
        if (!$vbulletin->input->clean_gpc('r', 'viewalldiscussions', TYPE_BOOL)) {
            // only show unread
            $collection->filter_show_read(false);
        }
        $numdiscussions = $collection->fetch_count();
        // Show group name in messages
        $show['group'] = true;
        // Create bit factory
        $bit_factory = new vB_Group_Bit_Factory($vbulletin, $itemtype);
        // Build message bits for all items
Exemple #4
0
 } else {
     $gmid = $dataman->save();
     if ($messageinfo) {
         $gmid = $messageinfo['gmid'];
     }
     if ($messageinfo and !$group['is_owner'] and can_moderate(0, 'caneditgroupmessages')) {
         require_once DIR . '/includes/functions_log_error.php';
         log_moderator_action($messageinfo, 'gm_by_x_in_y_for_z_edited', array($messageinfo['postusername'], $discussion['title'], $group['name']));
     }
     if ($vbulletin->GPC['ajax'] and (!$edit_discussion or $messageinfo['gmid'])) {
         require_once DIR . '/includes/class_xml.php';
         $xml = new vB_AJAX_XML_Builder($vbulletin, 'text/xml');
         $xml->add_group('commentbits');
         require_once DIR . '/includes/class_groupmessage.php';
         // create message collection
         $collection_factory = new vB_Group_Collection_Factory($vbulletin, $group);
         $collection = $collection_factory->create($messageinfo['gmid'] ? 'message' : 'recentmessage', $discussion['discussionid'], false, false, false, true);
         if ($messageinfo['gmid']) {
             $collection->filter_id($messageinfo['gmid']);
         } else {
             $collection->set_dateline($vbulletin->GPC['lastcomment'], $gmid);
         }
         // add hook for manipulating query
         $collection->set_query_hook('group_message_post_ajax');
         // create bit factory for rendering messages
         $bitfactory = new vB_Group_Bit_Factory($vbulletin, 'message');
         // build response for each message
         while ($message = $collection->fetch_item()) {
             $bit = $bitfactory->create($message, $group);
             if ($vbulletin->GPC['hideinlinemod']) {
                 $bit->show_moderation_tools(false);