Beispiel #1
0
         }
 }
 $sort = array($sortfield => 'selected="selected"');
 $hook_query_fields = $hook_query_joins = $hook_query_where = '';
 ($hook = vBulletinHook::fetch_hook('moderation_visitor_messages_query')) ? eval($hook) : false;
 if ($vbulletin->GPC['perpage'] == 0) {
     $perpage = $vbulletin->options['vm_perpage'];
 } else {
     if ($vbulletin->GPC['perpage'] > $vbulletin->options['vm_maxperpage']) {
         $perpage = $vbulletin->options['vm_maxperpage'];
     }
 }
 require_once DIR . '/includes/class_bbcode.php';
 require_once DIR . '/includes/class_visitormessage.php';
 $bbcode = new vB_BbCodeParser($vbulletin, fetch_tag_list());
 $factory = new vB_Visitor_MessageFactory($vbulletin, $bbcode, $userinfo);
 $messagebits = '';
 $counter = 0;
 do {
     if (!$pagenumber) {
         $pagenumber = 1;
     }
     $start = ($pagenumber - 1) * $perpage;
     $messagebits = '';
     $messages = $vbulletin->db->query_read("\r\n\t\t\tSELECT SQL_CALC_FOUND_ROWS\r\n\t\t\t\tvisitormessage.*, user1.*, visitormessage.ipaddress AS messageipaddress, visitormessage.userid AS profileuserid, user2.username AS profileusername\r\n\t\t\t\t{$postselect}\r\n\t\t\t\t" . ($vbulletin->options['avatarenabled'] ? ",avatar.avatarpath, NOT ISNULL(customavatar.userid) AS hascustomavatar, customavatar.dateline AS avatardateline,customavatar.width AS avwidth,customavatar.height AS avheight" : "") . "\r\n\t\t\t\t{$hook_query_fields}\r\n\t\t\t{$postfrom}\r\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "user AS user1 ON (visitormessage.postuserid = user1.userid)\r\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "user AS user2 ON (visitormessage.userid = user2.userid)\r\n\t\t\t" . ($vbulletin->options['avatarenabled'] ? "LEFT JOIN " . TABLE_PREFIX . "avatar AS avatar ON(avatar.avatarid = user1.avatarid) LEFT JOIN " . TABLE_PREFIX . "customavatar AS customavatar ON(customavatar.userid = user1.userid)" : "") . "\r\n\t\t\t{$deljoinsql}\r\n\t\t\t{$hook_query_joins}\r\n\t\t\tWHERE 1=1\r\n\t\t\t\t{$datecut}\r\n\t\t\t\t{$hook_query_where}\r\n\t\t\tORDER BY {$sqlsortfield} {$sqlsortorder}\r\n\t\t\tLIMIT {$start}, {$perpage}\r\n\t\t");
     list($messagetotal) = $vbulletin->db->query_first("SELECT FOUND_ROWS()", DBARRAY_NUM);
     if ($start >= $messagetotal) {
         $pagenumber = ceil($messagetotal / $perpage);
     }
 } while ($start >= $messagetotal and $messagetotal);
 $show['profile'] = true;
Beispiel #2
0
			// Messages left to this user's profile by $vbulletin->userinfo
			$sql1[] = "visitormessage.userid = $userinfo[userid]";
			$sql1[] = "visitormessage.postuserid = " . $vbulletin->userinfo['userid'];
			$sql1[] = "visitormessage.state IN ('" . implode("','", $state1) . "')";

			// Messages left to vbulletin->userinfo's profile by this user
			$sql2[] = "visitormessage.userid = " . $vbulletin->userinfo['userid'];
			$sql2[] = "visitormessage.postuserid = $userinfo[userid]";
			$sql2[] = "visitormessage.state IN ('" . implode("','", $state2) . "')";

			require_once(DIR . '/includes/class_bbcode.php');
			require_once(DIR . '/includes/class_visitormessage.php');

			$bbcode = new vB_BbCodeParser($vbulletin, fetch_tag_list());
			$factory = new vB_Visitor_MessageFactory($vbulletin, $bbcode, $userinfo);

			$hook_query_fields1 = $hook_query_fields2 = $hook_query_joins1 = $hook_query_joins2 = $hook_query_where1 = $hook_query_where2 = '';
			($hook = vBulletinHook::fetch_hook('visitor_message_form_query')) ? eval($hook) : false;

			// We will need to limit this to a certain amount
			$messages = $db->query_read_slave("
			(
				SELECT
					visitormessage.*, visitormessage.dateline AS pmdateline, user.*, visitormessage.ipaddress AS messageipaddress
					$delsql1
					" . ($vbulletin->options['avatarenabled'] ? ",avatar.avatarpath, NOT ISNULL(customavatar.userid) AS hascustomavatar, customavatar.dateline AS avatardateline,customavatar.width AS avwidth,customavatar.height AS avheight" : "") . "
					$hook_query_fields1
				FROM " . TABLE_PREFIX . "visitormessage AS visitormessage
				LEFT JOIN " . TABLE_PREFIX . "user AS user ON (visitormessage.postuserid = user.userid)
				" . ($vbulletin->options['avatarenabled'] ? "LEFT JOIN " . TABLE_PREFIX . "avatar AS avatar ON(avatar.avatarid = user.avatarid) LEFT JOIN " . TABLE_PREFIX . "customavatar AS customavatar ON(customavatar.userid = user.userid)" : "") . "
Beispiel #3
0
 /**
  * Prepare any data needed for the output
  *
  * @param	string	The id of the block
  * @param	array	Options specific to the block
  */
 function prepare_output($id = '', $options = array())
 {
     global $show, $vbphrase, $messagearea, $vBeditTemplate;
     require_once DIR . '/includes/functions_visitormessage.php';
     require_once DIR . '/includes/class_bbcode.php';
     require_once DIR . '/includes/class_visitormessage.php';
     if (is_array($options)) {
         $options = array_merge($this->option_defaults, $options);
     } else {
         $options = $this->option_defaults;
     }
     if ($options['vmid']) {
         $messageinfo = verify_visitormessage($options['vmid'], false);
     }
     $state = array('visible');
     if (fetch_visitor_message_perm('canmoderatevisitormessages', $this->profile->userinfo)) {
         $state[] = 'moderation';
     }
     if (can_moderate(0, 'canmoderatevisitormessages') or $this->registry->userinfo['userid'] == $this->profile->userinfo['userid'] and $this->registry->userinfo['permissions']['visitormessagepermissions'] & $this->registry->bf_ugp_visitormessagepermissions['canmanageownprofile']) {
         $state[] = 'deleted';
         $deljoinsql = "LEFT JOIN " . TABLE_PREFIX . "deletionlog AS deletionlog ON (visitormessage.vmid = deletionlog.primaryid AND deletionlog.type = 'visitormessage')";
     } else {
         $deljoinsql = '';
     }
     $state_or = array("visitormessage.state IN ('" . implode("','", $state) . "')");
     // Get the viewing user's moderated posts
     if ($this->registry->userinfo['userid'] and !fetch_visitor_message_perm('canmoderatevisitormessages', $this->profile->userinfo)) {
         $state_or[] = "(visitormessage.postuserid = " . $this->registry->userinfo['userid'] . " AND state = 'moderation')";
     }
     $perpage = (!$options['perpage'] or $options['perpage'] > $this->registry->options['vm_maxperpage']) ? $this->registry->options['vm_perpage'] : $options['perpage'];
     if ($messageinfo['vmid']) {
         $getpagenum = $this->registry->db->query_first("\n\t\t\t\tSELECT COUNT(*) AS comments\n\t\t\t\tFROM " . TABLE_PREFIX . "visitormessage AS visitormessage\n\t\t\t\tWHERE userid = " . $this->profile->userinfo['userid'] . "\n\t\t\t\t\tAND (" . implode(" OR ", $state_or) . ")\n\t\t\t\t\tAND dateline >= {$messageinfo['dateline']}\n\t\t\t");
         $options['pagenumber'] = ceil($getpagenum['comments'] / $perpage);
     }
     $pagenumber = $options['pagenumber'];
     do {
         if (!$pagenumber or $options['tab'] != $id and $options['tab'] != '') {
             $pagenumber = 1;
         }
         $start = ($pagenumber - 1) * $perpage;
         $hook_query_fields = $hook_query_joins = $hook_query_where = '';
         ($hook = vBulletinHook::fetch_hook('member_profileblock_visitormessage_query')) ? eval($hook) : false;
         if ($this->registry->options['globalignore'] != '') {
             if (!can_moderate(0, 'candeletevisitormessages') and !can_moderate(0, 'canremovevisitormessages')) {
                 require_once DIR . '/includes/functions_bigthree.php';
                 $coventry = fetch_coventry('string');
             }
         }
         $messagebits = '';
         $messages = $this->registry->db->query_read("\n\t\t\t\tSELECT " . (!isset($this->profile->prepared['vm_total']) ? "SQL_CALC_FOUND_ROWS" : "") . "\n\t\t\t\t\tvisitormessage.*, user.*, visitormessage.ipaddress AS messageipaddress\n\t\t\t\t\t" . ($this->registry->userinfo['userid'] ? ",IF(userlist.userid IS NOT NULL, 1, 0) AS bbuser_iscontact_of_user" : "") . "\n\t\t\t\t\t" . ($deljoinsql ? ",deletionlog.userid AS del_userid, deletionlog.username AS del_username, deletionlog.reason AS del_reason" : "") . "\n\t\t\t\t\t" . ($this->registry->options['avatarenabled'] ? ",avatar.avatarpath, NOT ISNULL(customavatar.userid) AS hascustomavatar, customavatar.dateline AS avatardateline,customavatar.width AS avwidth,customavatar.height AS avheight, customavatar.width_thumb AS avwidth_thumb, customavatar.height_thumb AS avheight_thumb, filedata_thumb, NOT ISNULL(customavatar.userid) AS hascustom" : "") . "\n\t\t\t\t\t{$hook_query_fields}\n\t\t\t\tFROM " . TABLE_PREFIX . "visitormessage AS visitormessage\n\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "user AS user ON (visitormessage.postuserid = user.userid)\n\t\t\t\t" . ($this->registry->userinfo['userid'] ? "LEFT JOIN " . TABLE_PREFIX . "userlist AS userlist ON (userlist.userid = user.userid AND userlist.type = 'buddy' AND userlist.relationid = " . $this->registry->userinfo['userid'] . ")" : "") . "\n\t\t\t\t" . ($this->registry->options['avatarenabled'] ? "LEFT JOIN " . TABLE_PREFIX . "avatar AS avatar ON(avatar.avatarid = user.avatarid) LEFT JOIN " . TABLE_PREFIX . "customavatar AS customavatar ON(customavatar.userid = user.userid)" : "") . "\n\t\t\t\t{$deljoinsql}\n\t\t\t\t{$hook_query_joins}\n\t\t\t\tWHERE visitormessage.userid = " . $this->profile->userinfo['userid'] . "\n\t\t\t\t\tAND (" . implode(" OR ", $state_or) . ")\n\t\t\t\t" . ($coventry ? "AND visitormessage.postuserid NOT IN (" . $coventry . ")" : '') . "\n\t\t\t\t\t{$hook_query_where}\n\t\t\t\tORDER BY visitormessage.dateline DESC\n\t\t\t\tLIMIT {$start}, {$perpage}\n\t\t\t");
         if (!isset($this->profile->prepared['vm_total'])) {
             list($messagetotal) = $this->registry->db->query_first("SELECT FOUND_ROWS()", DBARRAY_NUM);
         } else {
             $messagetotal = $this->profile->prepared['vm_total'];
         }
         if ($start >= $messagetotal) {
             $pagenumber = ceil($messagetotal / $perpage);
         }
     } while ($start >= $messagetotal and $messagetotal);
     $this->block_data['messagestart'] = $start + 1;
     $this->block_data['messageend'] = min($start + $perpage, $messagetotal);
     $bbcode = new vB_BbCodeParser($this->registry, fetch_tag_list());
     $factory = new vB_Visitor_MessageFactory($this->registry, $bbcode, $this->profile->userinfo);
     $messagebits = '';
     if ($this->registry->userinfo['userid'] and empty($options['showignored'])) {
         $ignorelist = preg_split('/( )+/', trim($this->registry->userinfo['ignorelist']), -1, PREG_SPLIT_NO_EMPTY);
     } else {
         $ignorelist = array();
     }
     $firstrecord = array();
     $read_ids = array();
     while ($message = $this->registry->db->fetch_array($messages)) {
         // Process user.options
         $message = array_merge($message, convert_bits_to_array($message['options'], $this->registry->bf_misc_useroptions));
         if (!$firstrecord) {
             $firstrecord = $message;
         }
         if ($ignorelist and in_array($message['postuserid'], $ignorelist)) {
             $message['ignored'] = true;
         }
         if (empty($options['showignored']) and in_coventry($message['postuserid'])) {
             $message['ignored'] = true;
         }
         $response_handler =& $factory->create($message);
         $response_handler->converse = true;
         if (!$message['vm_enable'] and (!can_moderate(0, 'canmoderatevisitormessages') or $this->registry->userinfo['userid'] == $message['postuserid']) or $message['vm_contactonly'] and !can_moderate(0, 'canmoderatevisitormessages') and $message['postuserid'] != $this->registry->userinfo['userid'] and !$message['bbuser_iscontact_of_user']) {
             $response_handler->converse = false;
         }
         $response_handler->cachable = false;
         $messagebits .= $response_handler->construct();
         if (!$message['messageread'] and $message['state'] == 'visible') {
             $read_ids[] = $message['vmid'];
         }
         $lastcomment = !$lastcomment ? $message['dateline'] : $lastcomment;
     }
     $readvms = 0;
     // If it's our profile and the visible or default tab then we hope they've read it
     // if ($this->profile->userinfo['userid'] == $this->registry->userinfo['userid'] AND ($options['tab'] == $id OR $options['tab'] == '') AND !empty($read_ids))
     if ($this->profile->userinfo['userid'] == $this->registry->userinfo['userid']) {
         if (!empty($read_ids)) {
             $readvms = sizeof($read_ids);
             $this->registry->db->query_write("UPDATE " . TABLE_PREFIX . "visitormessage SET messageread = 1 WHERE vmid IN (" . implode(',', $read_ids) . ")");
         }
         if ($this->profile->userinfo['vmunreadcount'] - $readvms > 0 and $this->registry->options['globalignore'] != '') {
             // We still have unread VMs somewhere, and Tachy is enabled
             build_visitor_message_counters($this->profile->userinfo['userid']);
         } else {
             if ($readvms) {
                 // This is more than likely on the second page
                 $this->registry->db->query_write("\n\t\t\t\t\tUPDATE " . TABLE_PREFIX . "user\n\t\t\t\t\tSET vmunreadcount = IF(vmunreadcount >= {$readvms}, vmunreadcount - {$readvms}, 0)\n\t\t\t\t\tWHERE userid = " . $this->registry->userinfo['userid']);
             }
         }
     }
     if ($pagenumber == 1 and (!isset($this->profile->prepared['vm_total']) or !isset($this->profile->prepared['lastvm_time']) or !isset($this->profile->prepared['lastvm_date']))) {
         $pminfo = array('dateline' => $firstrecord['dateline'], 'messages' => $messagetotal);
     } else {
         $pminfo = null;
     }
     $this->profile->prepare('vm_total', $pminfo);
     $this->block_data['messagebits'] = $messagebits;
     $this->block_data['lastcomment'] = $lastcomment;
     $show['delete'] = fetch_visitor_message_perm('candeletevisitormessages', $this->profile->userinfo);
     $show['undelete'] = fetch_visitor_message_perm('canundeletevisitormessages', $this->profile->userinfo);
     $show['approve'] = fetch_visitor_message_perm('canmoderatevisitormessages', $this->profile->userinfo);
     $show['inlinemod'] = ($show['delete'] or $show['undelete'] or $show['approve']);
     // Only allow AJAX QC on the first page
     $show['quickcomment'] = $show['post_visitor_message'];
     $show['allow_ajax_qc'] = ($pagenumber == 1 and $messagetotal) ? 1 : 0;
     $pageinfo = array('tab' => $id);
     if ($options['perpage'] != $this->registry->options['vm_perpage']) {
         $pageindo['pp'] = $options['perpage'];
     }
     if (!empty($options['showignored'])) {
         $pageinfo['showignored'] = 1;
     }
     $this->block_data['pagenav'] = construct_page_nav($pagenumber, $perpage, $messagetotal, '', '', $id, 'member', $this->profile->userinfo, $pageinfo);
     $this->block_data['messagetotal'] = $messagetotal;
     $show['view_conversation'] = (!$this->profile->prepared['myprofile'] and THIS_SCRIPT != 'converse' and $this->registry->userinfo['vm_enable']);
     if ($show['quickcomment']) {
         require_once DIR . '/includes/functions_editor.php';
         $this->block_data['editorid'] = construct_edit_toolbar('', false, 'visitormessage', $this->registry->options['allowsmilies'], true, false, 'qr_small', '', array(), 'content', 'vBForum_VisitorMessage', 0, $this->profile->userinfo['userid']);
         $this->block_data['messagearea'] = $messagearea;
         $this->block_data['clientscript'] = $vBeditTemplate['clientscript'];
     }
 }