Go Back   vb.org Archive > vBulletin Modifications > vBulletin 4.x Modifications > vBulletin 4.x Add-ons
PHPKD - Moderated Attachments Staff Notify Details »»
PHPKD - Moderated Attachments Staff Notify
Version: 4.0.100, by Omranic Omranic is offline
Developer Last Online: Sep 2021 Show Printable Version Email this Page

Category: Moderators Functions - Version: 4.0.x Rating:
Released: 03-20-2010 Last Update: Never Installs: 14
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, 74 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 03-21-2010, 06:20 AM
Forum Lover Forum Lover is offline
 
Join Date: Jun 2007
Location: Sydney
Posts: 503
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Downloaded 1. and Installed 3 at this moment.
Reply With Quote
  #3  
Old 03-22-2010, 01:40 AM
Dr.osamA's Avatar
Dr.osamA Dr.osamA is offline
 
Join Date: Aug 2004
Location: Syrie
Posts: 979
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

installed

thanxx
Reply With Quote
  #4  
Old 04-07-2010, 03:00 AM
Omranic's Avatar
Omranic Omranic is offline
 
Join Date: Jan 2005
Location: Egypt
Posts: 536
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Forum Lover View Post
Downloaded 1. and Installed 3 at this moment.
And it's now downloaded: 24 & marked as installed: 8, it's not a measure. Some users may like to mark products as installed for future use or for just interesting in the upcoming updates of the product .


Quote:
Originally Posted by Dr.osamA View Post
installed

thanxx
You are welcome :up:
Reply With Quote
  #5  
Old 04-07-2010, 06:31 AM
NashChristian's Avatar
NashChristian NashChristian is offline
 
Join Date: Jul 2007
Location: Nashville, TN
Posts: 292
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hello,

I'm curious why there are only 3 stars in your mod's rating. If others have had problems installing this, or it's functionality is marginal, please let us know in the thread.

Anyhow, three questions:
  • Stock vB doesn't provide any notification for attachments currently?
  • This will email the admin whenever someone ads a photo album or an image to their photo album, independant of any other posts?
  • Will this add moderation to attachments not currently moderated by stock vB (the SAME as it would if your moderation mod was ALSO installed)?

This sounds like exactly what I need. I have no CLUE why this functionality would not be stock vB!

Thanks for sharing!
Jeff
Reply With Quote
  #6  
Old 04-20-2010, 07:28 AM
NashChristian's Avatar
NashChristian NashChristian is offline
 
Join Date: Jul 2007
Location: Nashville, TN
Posts: 292
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hello... is there ANYBODY out there?

I have a quick question, in regards to:
5. No more dependent on "PHPKD - Usergroup Attachment Moderation" product, it's standalone product now with auto integrate ability.
Does this mean that with this mod alone, attachment moderation will be added PER USER GROUP and the notification will also be implemented? A two-in-one deal?

Please let me know.

By the way, if I can get some answers, and I do in fact install your mod, I will gladly mark it installed. I just need to understand first if this is what I need.

Thanks!
Reply With Quote
  #7  
Old 04-20-2010, 06:04 PM
NashChristian's Avatar
NashChristian NashChristian is offline
 
Join Date: Jul 2007
Location: Nashville, TN
Posts: 292
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok... I'm trying to install this, but am so far unsucessful.

I'm getting hung up on this step:

Quote:
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)
I can't find that function, or any part of it, anywhere in my includes/class_upload.php file! I get no hits on "$fields", I get no hits on "moderators", the only term I get any hits on is "email", and below is the only reference to that term in the file:

PHP Code:
eval(fetch_email_phrases('attachfull'0));
vbmail($this->registry->options['webmasteremail'], $subject$message); 

I'm running 4.0.2. Has the code changed since 4.0.? when you coded this? Will this even work with 4.0.2? Please advise.

I'd like to use this, but so far don't see how I can implement it.

Any help would be appreciated.
Thanks!
Jeff
Reply With Quote
  #8  
Old 04-21-2010, 10:23 AM
NashChristian's Avatar
NashChristian NashChristian is offline
 
Join Date: Jul 2007
Location: Nashville, TN
Posts: 292
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Now I know why this has only 3 stars! vB should mark this UNSUPPORTED! The coder is logged into the site while I post, and still REFUSES to reply!

Uninstalled! Voted TERRIBLE! Thanks!
Reply With Quote
  #9  
Old 09-07-2012, 10:03 PM
kylek kylek is offline
 
Join Date: Oct 2003
Location: British Columbia, Canada
Posts: 798
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Works great in 4.2.0 except you have to change the dependency as its set for 4.0.9
Reply With Quote
Reply

Thread Tools

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 11:07 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.07693 seconds
  • Memory Usage 2,341KB
  • 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
  • (1)bbcode_php
  • (3)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