Back to vBulletin 4.x Add-ons

PHPKD - Moderated Attachments Staff Notify
Mod Version: 4.0.100, by Omranic

vB Version: 4.0.x Rating: (3 votes - 5.00 average) Installs: 14
Released: 21 Mar 2010 Last Update: Never Downloads: 48
Not Supported DB Changes Uses Plugins Code Changes Additional Files Re-usable Code Translations  

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!.................. Brought to you by PHP KingDom (http://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:
  • http://go.phpkd.net/en/product/vbuam/


Helpful links:
  • http://forum.phpkd.net/project.php?do=issuelist&projectid=2&issuetypeid=bug
  • http://forum.phpkd.net/project.php?do=issuelist&projectid=2&issuetypeid=feature


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:
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 http://creativecommons.org/licenses/by-nc-sa/3.0/.
  • 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/by-nc-sa/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:
  • http://go.phpkd.net/en/product/vblvb/ New !
  • http://go.phpkd.net/en/product/vbaqr/ New !
  • http://go.phpkd.net/en/product/vbaqe/

Download

File Type: %1$s PHPKD_VBASN_4.0.100.zip (63.6 KB, 76 downloads)

Screenshots

Click image for larger version
Name:	phpkd_vbasn_admincp_settings.png
Views:	235
Size:	11.2 KB
ID:	114463   Click image for larger version
Name:	phpkd_vbasn_admincp_modperms.png
Views:	216
Size:	13.0 KB
ID:	114464   Click image for larger version
Name:	phpkd_vbasn_admincp_forum.png
Views:	191
Size:	9.0 KB
ID:	114465  

Similar Mods

Administrative and Maintenance Tools PHPKD - vB Link Verifier Bot vBulletin 3.8 Add-ons
Moderators Functions PHPKD - Moderated Attachments Staff Notify vBulletin 3.8 Add-ons
Moderators Functions PHPKD - Usergroup Attachment Moderation vBulletin 4.x Add-ons
Moderators Functions PHPKD - Moderated Attachments Staff Notify vBulletin 3.7 Add-ons
Moderators Functions PHPKD - Moderated Attachments Staff Notify vBulletin 3.6 Add-ons

vblts.ru supports vBulletin®, 2022-2024