protected function fetchCanViewSocialgroupDiscussion($discussionid) { if (!$this->fetchCanUseGroups() or !($discussion = $this->content['socialgroup_discussion'][$discussionid])) { return false; } $group = $this->content['socialgroup'][$discussion['groupid']]; if (!$this->fetchCanViewGroupContent($group['groupid']) or $discussion['state'] == 'deleted') { return false; } if (!vB::$vbulletin->options['socnet_groups_msg_enabled'] or !($group['options'] & vB::$vbulletin->bf_misc_socialgroupoptions['enable_group_messages'])) { return false; } require_once DIR . '/includes/functions_socialgroup.php'; if ($discussion['state'] == 'moderation' and !fetch_socialgroup_modperm('canmoderategroupmessages', $group) and $discussion['postuserid'] != vB::$vbulletin->userinfo['userid']) { return false; } return true; }
$navbits = array('' => $vbphrase['delete_messages']); $navbits = construct_navbits($navbits); eval('$navbar = "' . fetch_template('navbar') . '";'); ($hook = vBulletinHook::fetch_hook('group_inlinemod_delete')) ? eval($hook) : false; eval('print_output("' . fetch_template('socialgroups_deletemessages') . '");'); } if ($_POST['do'] == 'doinlinedelete') { $vbulletin->input->clean_array_gpc('p', array('deletetype' => TYPE_UINT, 'deletereason' => TYPE_NOHTMLCOND)); $physicaldel = $vbulletin->GPC['deletetype'] == 2 ? true : false; // Validate Messages $messages = $db->query_read_slave("\n\t\tSELECT gm.gmid, gm.state, gm.groupid, gm.dateline, gm.postuserid, gm.postusername\n\t\tFROM " . TABLE_PREFIX . "groupmessage AS gm\n\t\tWHERE gmid IN (" . implode(',', $messageids) . ")\n\t"); while ($message = $db->fetch_array($messages)) { $group = fetch_socialgroupinfo($message['groupid']); $message['is_group_owner'] = $group['creatoruserid'] == $vbulletin->userinfo['userid']; $canmoderatemessages = fetch_socialgroup_modperm('canmoderategroupmessages', $group); $candeletemessages = (fetch_socialgroup_modperm('candeletegroupmessages', $group) or $message['state'] == 'visible' and $message['postuserid'] == $vbulletin->userinfo['userid'] and $vbulletin->userinfo['permissions']['socialgrouppermissions'] & $vbulletin->bf_ugp_socialgrouppermissions['canmanagemessages']); $canremovemessages = can_moderate(0, 'canremovegroupmessages'); if ($message['state'] == 'moderation' and !$canmoderatemessages) { standard_error(fetch_error('you_do_not_have_permission_to_manage_moderated_messages')); } else { if ($message['state'] == 'deleted' and !$candeletemessages) { standard_error(fetch_error('you_do_not_have_permission_to_manage_deleted_messages')); } else { if ($physicaldel and !$canremovemessages or !$physicaldel and !$candeletemessages) { standard_error(fetch_error('you_do_not_have_permission_to_delete_messages')); } } } $message['group_name'] = $group['name']; $messagearray["{$message['gmid']}"] = $message; $grouplist["{$message['groupid']}"] = true;
/** * */ public function has_modperm($perm, $user) { //$user is not currently used, fetch_socialgroup_modperm implicitly picks up //the current user information. We should fix that. return fetch_socialgroup_modperm($perm, $this->record); }
/** * Determines whether we can edit a specific group message * * @param array Message Information * @param array Group Information * * @return boolean */ function can_edit_group_message($messageinfo, $group) { global $vbulletin; if (!$vbulletin->userinfo['userid']) { return false; } switch ($messageinfo['state']) { case 'deleted': $canviewdeleted = (fetch_socialgroup_modperm('canundeletegroupmessages', $group) or $vbulletin->userinfo['userid'] == $messageinfo['postuserid'] and fetch_socialgroup_perm('canmanagemessages')); if (!$canviewdeleted) { return false; } return fetch_socialgroup_modperm('canundeletegroupmessages', $group) and can_moderate(0, 'caneditgroupmessages'); break; default: if ($messageinfo['postuserid'] == $vbulletin->userinfo['userid'] and fetch_socialgroup_perm('canmanagemessages')) { return true; } } return can_moderate(0, 'caneditgroupmessages'); }
break; case 'moderated': default: $collection->filter_show_deleted(false); } // Url for inlinemod form $url = SCRIPTPATH; // Show group name in messages $show['group'] = true; $show['discussion'] = true; // Always show inlinemod if ('new' == $type) { if ($do_discussions) { $show['inlinemod'] = (fetch_socialgroup_modperm('canundeletediscussions') or fetch_socialgroup_modperm('canmoderatediscussions')); } else { $show['inlinemod'] = (fetch_socialgroup_modperm('canundeletegroupmessages') or fetch_socialgroup_modperm('canmoderategroupmessages')); } } else { $show['inlinemod'] = true; } // Add moderation options show_group_inlinemoderation(false, $show, $do_discussions); $show['unapprove'] = $show['approve']; // Remove approval if we are viewing deleted if ($type == 'deleted') { $show['approve'] = false; } else { if ($type != 'new') { $show['undelete'] = false; $show['unapprove'] = false; }
if (!$group['is_owner'] and can_moderate(0, 'candeletesocialgroups')) { require_once DIR . '/includes/functions_log_error.php'; log_moderator_action($group, 'social_group_x_members_managed', array($group['name'])); } if ($group['members'] - sizeof($ids) <= 1 and $_REQUEST['do'] == 'kickmembers') { $vbulletin->url = 'group.php?' . $vbulletin->session->vars['sessionurl'] . 'groupid=' . $group['groupid']; } else { $vbulletin->url = 'group.php?' . $vbulletin->session->vars['sessionurl'] . 'do=manage' . ($_REQUEST['do'] == 'kickmembers' ? 'members' : '') . '&groupid=' . $group['groupid']; } ($hook = vBulletinHook::fetch_hook('group_kickmember_complete')) ? eval($hook) : false; $phrase = $_POST['do'] == 'cancelinvites' ? 'successfully_removed_invites' : 'successfully_kicked_members'; eval(print_standard_redirect($phrase)); } // ####################################################################### if ($_POST['do'] == 'pendingmembers') { if (!fetch_socialgroup_modperm('caninvitemoderatemembers', $group)) { print_no_permission(); } $vbulletin->input->clean_array_gpc('p', array('ids' => TYPE_ARRAY_KEYS_INT, 'action' => TYPE_STR)); $socialgroupmemberdm = datamanager_init('SocialGroupMember', $vbulletin); $vbulletin->GPC['ids'][] = 0; $ids = implode(', ', $vbulletin->GPC['ids']); $members = $vbulletin->db->query_read("\n\t\tSELECT * FROM " . TABLE_PREFIX . "socialgroupmember\n\t\tWHERE groupid = " . $group['groupid'] . " AND type = 'moderated' AND userid IN ({$ids})\n\t"); while ($member = $vbulletin->db->fetch_array($members)) { $socialgroupmemberdm->set_existing($member); ($hook = vBulletinHook::fetch_hook('group_pending_members')) ? eval($hook) : false; if ($vbulletin->GPC['action'] == 'deny') { $socialgroupmemberdm->delete(); } else { if ($vbulletin->GPC['action'] == 'accept') { $socialgroupmemberdm->set('type', 'member');
/** * Sets up different display variables for the Group Message * */ function process_display() { global $show; $show['moderation'] = $this->message['state'] == 'moderation'; $show['edit'] = can_edit_group_message($this->message, $this->group); $show['inlinemod'] = ($this->message['state'] != 'deleted' and (fetch_socialgroup_modperm('canmoderategroupmessages', $this->group) or fetch_socialgroup_modperm('candeletegroupmessages', $this->group)) or $this->message['state'] == 'deleted' and (fetch_socialgroup_modperm('candeletegroupmessages', $this->group) or fetch_socialgroup_modperm('canremovegroupmessages', $this->group))); }
require_once DIR . '/includes/functions_socialgroup.php'; require_once DIR . '/includes/class_socialgroup_search.php'; $socialgroupsearch = new vB_SGSearch($vbulletin); $socialgroupsearch->add('subscribed', $vbulletin->userinfo['userid']); $socialgroupsearch->set_sort('lastpost', 'ASC'); $socialgroupsearch->check_read($vbulletin->options['threadmarking']); ($hook = vBulletinHook::fetch_hook('group_list_filter')) ? eval($hook) : false; if ($numsocialgroups = $socialgroupsearch->execute(true)) { $groups = $socialgroupsearch->fetch_results(); $show['pictureinfo'] = $vbulletin->options['socnet_groups_pictures_enabled'] ? true : false; $lastpostalt = $show['pictureinfo'] ? 'alt2' : 'alt1'; if (is_array($groups)) { $grouplist = ''; foreach ($groups as $group) { $group = prepare_socialgroup($group); $show['pending_link'] = (fetch_socialgroup_modperm('caninvitemoderatemembers', $group) and $group['moderatedmembers'] > 0); $show['lastpostinfo'] = $group['lastpost']; ($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';
if ($_POST['do'] == 'inlineundelete') { // Validate Messages $messages = $inline_discussion ? verify_discussions($messageids, false, false, true) : verify_messages($messageids, false, false, true); require_once DIR . '/vb/search/indexcontroller/queue.php'; if ($messages) { while ($message = $db->fetch_array($messages)) { $discussion = fetch_socialdiscussioninfo($message['discussionid']); $group = fetch_socialgroupinfo($discussion['groupid']); $message['is_group_owner'] = $group['creatoruserid'] == $vbulletin->userinfo['userid']; if ($message['gmid'] == $discussion['firstpostid']) { if (!fetch_socialgroup_modperm('canundeletediscussions')) { standard_error(fetch_error('you_do_not_have_permission_to_manage_deleted_discussions')); } $message['firstpost'] = true; } else { if (!fetch_socialgroup_modperm('canundeletegroupmessages', $group)) { standard_error(fetch_error('you_do_not_have_permission_to_manage_deleted_messages')); } $message['firstpost'] = false; } $message['group_name'] = $group['name']; $message['discussion_name'] = $discussion['title']; $messagearray["{$message['gmid']}"] = $message; $discussionlist["{$discussion['discussionid']}"] = true; $grouplist["{$group['groupid']}"] = true; } } if (empty($messagearray)) { standard_error(fetch_error('you_did_not_select_any_valid_messages')); } require_once DIR . '/vb/search/indexcontroller/queue.php';
/** * pre_delete function - extend if the contenttype needs to do anything * * @param array list of deleted attachment ids to delete * @param boolean verify permission to delete * * @return boolean */ public function pre_delete($list, $checkperms = true) { @ignore_user_abort(true); // init lists $this->lists = array( 'grouplist' => array(), ); if ($checkperms) { // Verify that we have permission to view these attachmentids $attachmultiple = new vB_Attachment_Display_Multiple($this->registry); $attachments = $attachmultiple->fetch_results("a.attachmentid IN (" . implode(", ", $list) . ")"); if (count($list) != count($attachments)) { return false; } } $ids = $this->registry->db->query_read(" SELECT a.attachmentid, a.userid, IF(a.contentid = 0, 1, 0) AS inprogress, a.caption, sg.name, sg.groupid, IF(sg.creatoruserid = {$this->registry->userinfo['userid']}, 1, 0) AS is_owner, user.username FROM " . TABLE_PREFIX . "attachment AS a LEFT JOIN " . TABLE_PREFIX . "socialgroup AS sg ON (a.contentid = sg.groupid) LEFT JOIN " . TABLE_PREFIX . "user AS user ON (a.userid = user.userid) WHERE a.attachmentid IN (" . implode(", ", $list) . ") "); while ($id = $this->registry->db->fetch_array($ids)) { if ($checkperms AND !$id['inprogress'] AND $id['userid'] != $this->registry->userinfo['userid'] AND !fetch_socialgroup_modperm('canremovepicture', $id)) { return false; } if ($id['groupid']) { $this->lists['grouplist']["{$id['groupid']}"]["{$id['attachmentid']}"] = 1; if ($this->log) { if (!$id['is_owner'] AND $id['userid'] != $this->registry->userinfo['userid']) { // TODO : What does $picture want and fix modlog display in the admincp as it does not filter attachmentid properly on contenttype $picture = array(); require_once(DIR . '/includes/functions_log_error.php'); log_moderator_action($picture, 'social_group_picture_x_in_y_removed', array(fetch_trimmed_title($id['caption'], 50), $id['name'])); } } } } return true; }
/** * Sets up different display variables for the Group Message * * @access protected */ function process_display() { global $show, $vbphrase; $this->item['canview'] = ($this->item['state'] == 'visible' or $this->item['state'] == 'deleted' and fetch_socialgroup_modperm('canundeletediscussions', $this->group) or $this->item['state'] == 'moderation' and fetch_socialgroup_modperm('canmoderatediscussions', $this->group)); // Simplify moderation for templating if (fetch_socialgroup_modperm('canmoderategroupmessages', $this->group)) { $this->item['moderated_replies'] = ($this->item['moderation'] > 1 or $this->item['state'] != 'moderation' and $this->item['moderation'] == 1); } else { $this->item['moderated_replies'] = 0; } $this->item['moderated'] = $this->item['state'] == 'moderation'; // Show inline selection tools if ($this->show_moderation_tools and !$this->force_inline_selection) { $this->item['inlinemod'] = ($this->item['state'] != 'deleted' and fetch_socialgroup_modperm('canmoderatediscussions', $this->group) or fetch_socialgroup_modperm('canundeletediscussions', $this->group) or fetch_socialgroup_modperm('canremovediscussions', $this->group)); $show['inlinemod'] = ($show['inlinemod'] or $this->item['inlinemod']); } else { $show['inlinemod'] = $this->item['inlinemod'] = $this->force_inline_selection; } // Show edit links $this->item['edit'] = ($this->show_moderation_tools and can_edit_group_discussion($this->item, $this->group)); $show['edit'] = $this->item['edit']; if ($this->check_read) { if (!$this->item['is_read']) { if (!$this->item['readtime']) { $this->item['readtime'] = 0; // no database marking, check cookie if (!$this->registry->options['threadmarking'] or !$this->registry->userinfo['userid']) { $this->item['readtime'] = max(fetch_bbarray_cookie('discussion_marking', $this->item['discussionid']), $this->registry->userinfo['lastvisit']); } } // posts older than markinglimit days won't be highlighted as new $oldtime = TIMENOW - $this->registry->options['markinglimit'] * 24 * 60 * 60; $this->item['readtime'] = max($this->group['readtime'], $this->item['readtime'], $oldtime); $this->item['is_read'] = $this->item['readtime'] > $this->item['lastpost']; $this->item['goto_readtime'] = array('goto' => $this->item['readtime']); } } else { $this->item['is_read'] = true; } $this->item['readstate'] = $this->item['is_read'] ? 'old' : 'new'; $this->item['replies'] = max(0, $this->item['visible'] - 1); if ($this->show_subscription) { $this->item['showsubsinfo'] = $this->show_subscription; $this->item['notification'] = $this->item['emailupdate'] ? $vbphrase['instant'] : $vbphrase['none']; } else { $this->item['showsubsinfo'] = false; $this->item['notification'] = ""; } }