vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.8 Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=235)
-   -   Moderators Functions - PHPKD - Moderated Attachments Staff Notify (https://vborg.vbsupport.ru/showthread.php?t=201741)

Omranic 01-13-2009 10:00 PM

PHPKD - Moderated Attachments Staff Notify
 
1 Attachment(s)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!.................. 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:

vithorius 01-20-2009 02:29 PM

Interesting hack...! :up:

MrD 02-22-2009 11:58 AM

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.

Omranic 04-13-2009 06:32 PM

Quote:

Originally Posted by vithorius (Post 1719024)
Interesting hack...! :up:

Thaks :up:.

Quote:

Originally Posted by MrD (Post 1751346)
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 :).

landrewolsen72 06-03-2009 02:11 PM

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

Omranic 07-22-2009 07:01 AM

Quote:

Originally Posted by landrewolsen72 (Post 1822780)
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

Redneck-Melly 11-29-2009 05:44 PM

is there a way to make this also notify when there is a post or thread in moderation?

Omranic 03-21-2010 01:15 AM

Quote:

Originally Posted by Redneck-Melly (Post 1922625)
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!

Xexiu 04-21-2013 09:50 PM

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

Code:

function email_moderators($fields)
Any ideas?


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

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.01948 seconds
  • Memory Usage 1,866KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_code_printable
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (9)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete