Go Back   vb.org Archive > vBulletin Modifications > vBulletin 3.8 Modifications > vBulletin 3.8 Add-ons
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
PHPKD - Moderated Attachments Staff Notify Details »»
PHPKD - Moderated Attachments Staff Notify
Version: 3.8.100, by Omranic Omranic is offline
Developer Last Online: Sep 2021 Show Printable Version Email this Page

Category: Moderators Functions - Version: 3.8.x Rating:
Released: 01-13-2009 Last Update: 03-20-2010 Installs: 18
DB Changes Uses Plugins
Re-useable Code Code Changes Additional Files Translations  
No support by the author.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!.................. Brought to you by PHP KingDom (www.phpkd.net) ..................!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~




Please remember to click Mark as Installed if you use this product.
Support requests from members who have not marked this as installed will be considered low priority.



Name: PHPKD - Moderated Attachments Staff Notify
Version: 4.0.100

Description: If attachments are moderated by default for any forum or any usergroup, then this product will auto notify staff members of these newly uploaded moderated attachments.


Compatible with: All 3.8.x/4.0.x vBulletin versions.


Requirements:
  • vBulletin version 3.8.x/4.0.x


Related Products:

Helpful links:

Features:
  • General Features:-
    • MD5 checked.
    • Fully Phrased.
    • Fully Supported.
    • Accurate Processing.
    • Professionally Coded.
    • Detailed Documentation.
    • Zero Additional Queries.
    • Requires only one manual edit.
    • Doing all default vBulletin checks & vBulletin Fully Compatible.
  • Specific Features:-
    • Ability to enable/disable notifications globally from product's settings.
    • Ability to set which staff members should be notified (Email Moderators/Email Moderators, Super Moderators, and Administrators).
    • Per staff member (moderator/super moderator/admin) permission to set whether he/she should be notified or not.
    • Per forum option to set which emails to be notified.


Installation Procedure:
  1. Upload required files to their appropriate places:
    • includes
      • xml
        • bitfield_phpkd_vbasn.xml
      • md5_sums_phpkd_vbasn.php
  2. Do the following small manual edit, open the file "includes/class_upload.php" (follow instructions relative to your vB version):
    Both 3.8.x & 4.0.x:
    Search for:
    Code:
    	function email_moderators($fields)
    Add above it directly the following code:
    Code:
    	// Begin:[ PHPKD - Moderated Attachments Staff Notify ]
    
    	/**
    	* Fetches the amount of moderated attachments associated with a posthash and user
    	*
    	* @param	string	Post hash
    	* @param	integer	User ID associated with post hash (-1 means current user)
    	*
    	* @return	integer	Number of attachments
    	*/
    	function phpkd_vbasn_fetch_mod_attachment_count($postid, $userid = -1)
    	{
    		if ($userid == -1)
    		{
    			$userid = $this->fetch_field('userid', 'post');
    		}
    		$userid = intval($userid);
    
    		$attachcount = $this->dbobject->query_first("
    			SELECT COUNT(*) AS count
    			FROM " . TABLE_PREFIX . "attachment
    			WHERE userid = $userid
    				AND " . ((substr(SIMPLE_VERSION, 0, 1) >= 4) ? 'state = \'moderation\'' : 'visible != 1') . "
    				AND " . ((substr(SIMPLE_VERSION, 0, 1) >= 4) ? 'contenttypeid = 1 AND contentid = ' . $postid : 'postid = ' . $postid)
    		);
    
    		return intval($attachcount['count']);
    	}
    
    
    	/**
    	* Fetches the moderated attachments associated with a posthash and user
    	*
    	* @param	string	Post hash
    	* @param	integer	User ID associated with post hash (-1 means current user)
    	*
    	* @return	array Moderated attachments IDs
    	*/
    	function phpkd_vbasn_fetch_mod_attachment($postid, $userid = -1)
    	{
    		if ($userid == -1)
    		{
    			$userid = $this->fetch_field('userid', 'post');
    		}
    		$userid = intval($userid);
    
    		$attachs = $this->dbobject->query_read_slave("
    			SELECT attachmentid, filename, dateline
    			FROM " . TABLE_PREFIX . "attachment
    			WHERE userid = $userid
    				AND " . ((substr(SIMPLE_VERSION, 0, 1) >= 4) ? 'state = \'moderation\'' : 'visible != 1') . "
    				AND " . ((substr(SIMPLE_VERSION, 0, 1) >= 4) ? 'contenttypeid = 1 AND contentid = ' . $postid : 'postid = ' . $postid)
    		);
    
    		$modattach = array();
    		while ($attach = $this->dbobject->fetch_array($attachs))
    		{
    			$modattach[$attach['attachmentid']] = array('attachmentid' => $attach['attachmentid'], 'filename' => $attach['filename'], 'postid' => $postid, 'dateline' => $attach['dateline']);
    		}
    
    		return $modattach;
    	}
    
    
    	/**
    	* Fetches the email addresses of moderators to email when there is a newly uploaded moderated attachments in a forum.
    	*
    	* @param	string|array	A string or array of dbfields to check for email addresses; also doubles as mod perm names
    	* @param	string|array	A string (comma-delimited) or array of forum IDs to check
    	* @param	array			(By reference) An array of languageids associated with specific email addresses returned
    	*
    	* @return	array			Array of emails to mail
    	*/
    	function phpkd_vbasn_fetch_moderator_modattach_emails($fields, $forums, &$language_info)
    	{
    		// Only proceed if email features are enabled
    		if (!$this->registry->options['enableemail'] OR !$this->registry->options['phpkd_vbasn_emailto'])
    		{
    			return;
    		}
    
    		$language_info = array();
    
    		if (!is_array($fields))
    		{
    			$fields = array($fields);
    		}
    
    		// figure out the fields to select and the permissions to check
    		$field_names = '';
    		$mod_perms = array();
    		foreach ($fields AS $field)
    		{
    			if ($permfield = intval($this->registry->bf_misc_phpkd_vbasn["$field"]))
    			{
    				$mod_perms[] = "(moderator.phpkd_vbasn & $permfield)";
    			}
    
    			$field_names .= "$field, ' ',";
    		}
    
    		if (sizeof($fields) > 1)
    		{
    			// kill trailing comma
    			$field_names = 'CONCAT(' . substr($field_names, 0, -1) . ')';
    		}
    		else
    		{
    			$field_names = reset($fields);
    		}
    
    		// figure out the forums worth checking
    		if (is_array($forums))
    		{
    			$forums = implode(',', $forums);
    		}
    		if (!$forums)
    		{
    			return array();
    		}
    
    		$phpkd_vbasn = '';
    
    		$moderators = $this->registry->db->query_read_slave("
    			SELECT $field_names AS phpkd_vbasn
    			FROM " . TABLE_PREFIX . "forum
    			WHERE forumid IN (" . $this->registry->db->escape_string($forums) . ")
    		");
    		while ($moderator = $this->registry->db->fetch_array($moderators))
    		{
    			$phpkd_vbasn .= ' ' . trim($moderator['phpkd_vbasn']);
    		}
    
    		if (empty($phpkd_vbasn) OR $this->registry->options['phpkd_vbasn_emailto'] == 2)
    		{
    			// get a list of super mod groups
    			$smod_groups = array();
    			foreach ($this->registry->usergroupcache AS $ugid => $groupinfo)
    			{
    				if ($groupinfo['adminpermissions'] & $this->registry->bf_ugp_adminpermissions['ismoderator'])
    				{
    					// super mod group
    					$smod_groups[] = $ugid;
    				}
    			}
    		}
    
    		if ($mod_perms)
    		{
    			$mods = $this->registry->db->query_read_slave("
    				SELECT DISTINCT user.email, user.languageid
    				FROM " . TABLE_PREFIX . "moderator AS moderator
    				LEFT JOIN " . TABLE_PREFIX . "user AS user USING(userid)
    				WHERE
    					(
    						(moderator.forumid IN (" . $this->registry->db->escape_string($forums) . ") AND moderator.forumid <> -1)
    						" . (!empty($smod_groups) ? "OR (user.usergroupid IN (" . implode(',', $smod_groups) . ") AND moderator.forumid = -1)" : '') . "
    					)
    					AND (" . implode(' OR ', $mod_perms) . ")
    			");
    			while ($mod = $this->registry->db->fetch_array($mods))
    			{
    				$language_info["$mod[email]"] = $mod['languageid'];
    				$phpkd_vbasn .= ' ' . $mod['email'];
    			}
    		}
    
    		$emails = preg_split('#\s+#', trim($phpkd_vbasn), -1, PREG_SPLIT_NO_EMPTY);
    		$emails = array_unique($emails);
    
    		return $emails;
    	}
    
    
    	/**
    	* Process notifications & email staff members upon newly uploaded moderated attachments
    	*
    	* @param	string|array	A string or array of dbfields to check for email addresses; also doubles as mod perm names
    	* @param	integer			Number of newly uploaded moderated attachments
    	* @param	array			Array of newly uploaded moderated attachments
    	*/
    	function phpkd_vbasn_email_moderators($fields, $attachcount, $attachs)
    	{
    		global $vbphrase;
    
    		if ($this->info['skip_moderator_email'] OR !$this->info['forum'] OR in_coventry($this->fetch_field('userid', 'post'), true))
    		{
    			return;
    		}
    
    		$mod_emails = $this->phpkd_vbasn_fetch_moderator_modattach_emails($fields, $this->info['forum']['parentlist'], $newpost_lang);
    
    		if (!empty($mod_emails))
    		{
    			$foruminfo = $this->info['forum'];
    			$foruminfo['title_clean'] = unhtmlspecialchars($foruminfo['title_clean']);
    
    			$threadinfo = fetch_threadinfo($this->fetch_field('threadid'));
    
    			$email = ($this->info['user']['email'] ? $this->info['user']['email'] : $this->registry->userinfo['email']);
    			$browsing_user = $this->registry->userinfo['username'];
    
    			// ugly hack -- should be fixed in the future
    			$this->registry->userinfo['username'] = unhtmlspecialchars($this->info['user']['username'] ? $this->info['user']['username'] : $this->registry->userinfo['username']);
    
    			$post = array_merge($this->existing, $this->post);
    			if (!$post['postid'])
    			{
    				$post['postid'] = $this->thread['firstpostid'];
    			}
    
    			require_once(DIR . '/includes/functions_misc.php');
    
    			foreach ($mod_emails AS $toemail)
    			{
    				if ($toemail != $email)
    				{
    					if ($threadinfo['prefixid'])
    					{
    						// need prefix in correct language
    						$threadinfo['prefix_plain'] = fetch_phrase(
    							"prefix_$threadinfo[prefixid]_title_plain",
    							'global',
    							'',
    							false,
    							true,
    							isset($newpost_lang["$toemail"]) ? $newpost_lang["$toemail"] : 0,
    							false
    						) . ' ';
    					}
    					else
    					{
    						$threadinfo['prefix_plain'] = '';
    					}
    
    					$attachdetails = "";
    					foreach ($attachs as $attach)
    					{
    						$attachdetails .= construct_phrase($vbphrase['phpkd_vbasn_modattachitem'], $attach['attachmentid'], $attach['filename']);
    					}
    
    					if (substr(SIMPLE_VERSION, 0, 1) >= 4)
    					{
    						$threadlink = fetch_seo_url('thread|nosession', $threadinfo);
    						eval(fetch_email_phrases('phpkd_vbasn_4x', iif(isset($newpost_lang["$toemail"]), $newpost_lang["$toemail"], 0)));
    					}
    					else
    					{
    						eval(fetch_email_phrases('phpkd_vbasn_3x', iif(isset($newpost_lang["$toemail"]), $newpost_lang["$toemail"], 0)));
    					}
    					vbmail($toemail, $subject, $message);
    				}
    			}
    
    			// back to normal
    			$this->registry->userinfo['username'] = htmlspecialchars_uni($browsing_user);
    		}
    	}
    
    	// End:[ PHPKD - Moderated Attachments Staff Notify ]
    Save the modified file "includes/class_upload.php" and upload it to it's place again (ALLOW OVERWRITE).
  3. Import the product's XML file "product-phpkd_vbasn.xml" from AdminCP.
  4. Configure forums' & moderators' options as preferred -See 'Controls' Section in product's details-.
  5. You're Done .


Upgrade Procedure:
  1. Same as "Installation Procedure", but "Allow Overwrite" for both file uploads & product import.


Controls:
  • Settings:
    vBulletin AdminCP ? Settings ? Options ? Message Attachment Options ? PHPKD - Moderated Attachments Staff Notify
  • Forum Options:
    vBulletin AdminCP ? Forums & Moderators ? Forum Manager ? Select Forum to edit ? PHPKD - Moderated Attachments Staff Notify ? Email Addresses to Notify When there is newly uploaded Moderated Attachments
  • Moderator Permissions:
    vBulletin AdminCP ? Forums & Moderators ? Options ? Show All Moderators ? Select Moderator to edit permissions ? Receive Email When there is newly uploaded Moderated Attachments


License:
Read Here: http://info.phpkd.net/en/license/free/
--------------- --------------- --------------- ---------------
Creative Commons - Attribution-Noncommercial-Share Alike 3.0
http://creativecommons.org/licenses/by-nc-sa/3.0/
--------------- --------------- --------------- ---------------
  • You are free:
    • To Share ? to copy, distribute and transmit the work
    • To Remix ? to adapt the work

  • Under the following conditions:
    • [Attribution]: You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work).
    • [Noncommercial]: You may not use this work for commercial purposes.
    • [Share Alike]: If you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar license to this one.

  • For any reuse or distribution, you must make clear to others the license terms of this work. The best way to do this is with a link to this web page.
  • Any of the above conditions can be waived if you get explicit permission from the copyright holder.
  • Nothing in this license impairs or restricts the author's moral rights.
--------------- --------------- --------------- ---------------
Your fair dealing and other rights are in no way affected by the above.
This is a human-readable summary of the Legal Code (the full license).
http://creativecommons.org/licenses/.../3.0/legalcode
--------------- --------------- --------------- ---------------


Help with:
  • Translations to benefit more users.
  • Suggestions & feature requests to develop this product.
  • Contributing any updates, upgrades and/or any new features.
  • Spreading this product. Yes, you're free to re-distribute this product as it is (See 'Free License' details).


Known Issues:
  • Nothing till now!


Future TO-DO-LIST:
  • Post your suggestions!


History:
  • v3.8.100 14/01/2009 02:00 PM UTC: First 3.8.x release (public)
  • v4.0.100 19/03/2010 08:00 AM UTC: First 4.0.x release (public)
    1. Recoded from scratch.
    2. Limited manual edits to just one manual edit.
    3. Fully compatible with both vB 3.8.x & vB 4.0.x.
    4. Supports vB4 seo links for threads (appears in sent email notifications).
    5. No more dependent on "PHPKD - Usergroup Attachment Moderation" product, it's standalone product now with auto integrate ability.
    6. Ability to turn the product On/Off from product's settings.
    7. Process both new threads & new replies.


Screen Shots:
  • Available down there.


Technical Notes:
  • New Plugins: 6
  • New Phrases: 16
  • New Templates: 0
  • Manual Template changes: 0
  • Auto Template changes: 0
  • New Files: 2
  • Manual File Changes: 1
  • New vBulletin Settings: 1
  • New Usergroup Permissions: 0
  • New Moderator Permissions: 1
  • New Administrator Permissions: 0
  • New Forum Options: 1
  • New DB Tables: 0
  • DB Alterations: 2
  • New Cronjobs: 0
    --------------------------------
  • Installation Level: V.Easy
  • Installation Time: ~15 seconds


Recent Products:

Download Now

File Type: zip PHPKD_VBASN_4.0.100.zip (63.6 KB, 36 views)

Screenshots

File Type: png phpkd_vbasn_admincp_settings.png (11.2 KB, 0 views)
File Type: png phpkd_vbasn_admincp_modperms.png (13.0 KB, 0 views)
File Type: png phpkd_vbasn_admincp_forum.png (9.0 KB, 0 views)

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #2  
Old 01-20-2009, 02:29 PM
vithorius's Avatar
vithorius vithorius is offline
 
Join Date: Feb 2008
Location: Portugal
Posts: 347
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Interesting hack...! :up:
Reply With Quote
  #3  
Old 02-22-2009, 11:58 AM
MrD's Avatar
MrD MrD is offline
 
Join Date: Aug 2003
Location: Germany/NRW
Posts: 419
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi,
is there a Option to displayed the notification at the Welcome Box?
i think it´s better then Email.
The Attachment can moderate faster.
Reply With Quote
  #4  
Old 04-13-2009, 07:32 PM
Omranic's Avatar
Omranic Omranic is offline
 
Join Date: Jan 2005
Location: Egypt
Posts: 536
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by vithorius View Post
Interesting hack...! :up:
Thaks :up:.

Quote:
Originally Posted by MrD View Post
Hi,
is there a Option to displayed the notification at the Welcome Box?
i think it?s better then Email.
The Attachment can moderate faster.
Currently no, I've already used the default vBulletin scenarios in notifying about the moderated items. May be implemented later, but I wish it's implemented by vBulletin itself since it should be a default feature in the software .
Reply With Quote
  #5  
Old 06-03-2009, 03:11 PM
landrewolsen72 landrewolsen72 is offline
 
Join Date: Apr 2009
Posts: 3
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi, I think I installed this product correctly by following the instructions you outline above but when I post attachments, the moderators listed for the forums do not receive emails. Can you point me in the right direction? When an attachment is posted, what hook fires first so I can walk the path and see where your code is being called.

Thanks!
-Andy
Reply With Quote
  #6  
Old 07-22-2009, 08:01 AM
Omranic's Avatar
Omranic Omranic is offline
 
Join Date: Jan 2005
Location: Egypt
Posts: 536
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by landrewolsen72 View Post
Hi, I think I installed this product correctly by following the instructions you outline above but when I post attachments, the moderators listed for the forums do not receive emails. Can you point me in the right direction? When an attachment is posted, what hook fires first so I can walk the path and see where your code is being called.

Thanks!
-Andy
Hello Andy,

Please make sure that you receive email notifications from your forum on moderated posts (Try to test these default features. if it works then this product should work since it uses the same routine).

Be sure you've already:
  1. Installed "Attachment Moderation - Follow Forum Moderation Rules Control".
  2. Configured the new per forum option "Moderated Attachments Staff Notify".
  3. Configured the new per usergroup option "Attachment Permissions - > Follow Forum Moderation Rules".
  4. Configured the new per moderator option "Moderator Permissions -> Receive Email When there is new Moderated Attachments".
If it's all ok, then you should receive emails per moderated attachment .

All the best.
SolidSnake@GTI
Reply With Quote
  #7  
Old 11-29-2009, 05:44 PM
Redneck-Melly Redneck-Melly is offline
 
Join Date: Mar 2008
Posts: 71
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

is there a way to make this also notify when there is a post or thread in moderation?
Reply With Quote
  #8  
Old 03-21-2010, 01:15 AM
Omranic's Avatar
Omranic Omranic is offline
 
Join Date: Jan 2005
Location: Egypt
Posts: 536
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Redneck-Melly View Post
is there a way to make this also notify when there is a post or thread in moderation?
Dear, notifications upon new threads/posts are built in features on vBulletin .


New Update ...
v4.0.100 19/03/2010 08:00 AM UTC: Fully compatible vB 3.8.x & vB 4.0.x release!
Reply With Quote
  #9  
Old 04-21-2013, 10:50 PM
Xexiu Xexiu is offline
 
Join Date: May 2008
Location: Barcelona
Posts: 54
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I edited with NotePad ++ includes/class_upload.php but doesn't find:

Code:
function email_moderators($fields)
Any ideas?
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:03 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04572 seconds
  • Memory Usage 2,344KB
  • Queries Executed 23 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (3)bbcode_code
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (8)postbit
  • (4)postbit_attachment
  • (9)postbit_onlinestatus
  • (9)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete