Example #1
0
}
if ($_REQUEST['do'] == 'doadd') {
    $vbulletin->input->clean_array_gpc('p', array('suggestid' => TYPE_UINT, 'photoplog_category' => TYPE_ARRAY));
    $photoplog_suggestid = $vbulletin->GPC['suggestid'];
    $photoplog_category = $vbulletin->GPC['photoplog_category'];
    $photoplog_category_title = trim(strval($photoplog_category['title']));
    $photoplog_category_description = trim(strval($photoplog_category['description']));
    $photoplog_category_displayorder = intval(trim(strval($photoplog_category['displayorder'])));
    $photoplog_category_parentid = intval(trim(strval($photoplog_category['parentid'])));
    $photoplog_category_options = $photoplog_category['options'];
    foreach ($photoplog_category_options as $photoplog_key => $photoplog_val) {
        $photoplog_category_options["{$photoplog_key}"] = intval(trim(strval($photoplog_val)));
    }
    require_once DIR . '/includes/functions_misc.php';
    $photoplog_category_bitopts = convert_array_to_bits($photoplog_category_options, $photoplog_categoryoptions, 1);
    if (photoplog_insert_category($photoplog_category_title, $photoplog_category_description, $photoplog_category_displayorder, $photoplog_category_parentid, $photoplog_category_bitopts, $photoplog_ds_catopts, $photoplog_suggestid)) {
        if ($photoplog_suggestid) {
            if ($vbulletin->options['photoplog_user_email']) {
                $photoplog_moderate_cat = $db->query_first("SELECT userid, title\r\n\t\t\t\t\tFROM " . PHOTOPLOG_PREFIX . "photoplog_suggestedcats\r\n\t\t\t\t\tWHERE suggestid = " . intval($photoplog_suggestid) . "\r\n\t\t\t\t");
                if ($photoplog_moderate_cat) {
                    $photoplog_fetch_userinfo = $db->query_first("SELECT username,email\r\n\t\t\t\t\t\tFROM " . TABLE_PREFIX . "user\r\n\t\t\t\t\t\tWHERE userid = " . intval($photoplog_moderate_cat['userid']) . "\r\n\t\t\t\t\t\tAND (options & " . intval($vbulletin->bf_misc_useroptions['adminemail']) . ")\r\n\t\t\t\t\t");
                    if ($photoplog_fetch_userinfo) {
                        $photoplog_category = strval($photoplog_moderate_cat['title']);
                        $photoplog_username = unhtmlspecialchars($photoplog_fetch_userinfo['username']);
                        $photoplog_subject = $photoplog_message = '';
                        eval(fetch_email_phrases('photoplog_approved_category', -1, '', 'photoplog_'));
                        vbmail($photoplog_fetch_userinfo['email'], $photoplog_subject, $photoplog_message, true);
                    }
                    $db->free_result($photoplog_fetch_userinfo);
                }
            }
Example #2
0
function photoplog_massmove_make_subcats_as_necessary(&$fileids, &$destination_list_categories, &$parent_list_categories, &$source_list_categories, &$ds_catopts)
{
    global $vbulletin;
    $source_key_of_parent_list = photoplog_make_source_key_of_parent_list($source_list_categories, $parent_list_categories);
    $clone_category_list = array();
    $clone_category_list[] = false;
    foreach ($source_list_categories as $source_key => $source_cat) {
        if ($source_key != 0 && $fileids[$source_key] != '') {
            $clone_category_list[$source_key] = true;
            $parent_key = $source_key_of_parent_list[$source_key];
            while ($parent_key != 0) {
                $clone_category_list[$parent_key] = true;
                $parent_key = $source_key_of_parent_list[$parent_key];
            }
        } else {
            $clone_category_list[$source_key] = false;
        }
    }
    foreach ($clone_category_list as $clone_key => $clone_cat) {
        if ($clone_key != 0) {
            if ($clone_cat) {
                $clone_parent_key = $source_key_of_parent_list[$clone_key];
                $clone_parent_cat = $destination_list_categories[$clone_parent_key];
                $orig_child_cat = $source_list_categories[$clone_key];
                $child_info_query = '';
                $child_title = '';
                $child_description = '';
                $child_displayorder = 0;
                $child_options = '';
                $child_info_query = $vbulletin->db->query_first("SELECT title,\r\n\t\t\t\t\t\tdescription, displayorder, options\r\n\t\t\t\t\tFROM " . PHOTOPLOG_PREFIX . "photoplog_categories\r\n\t\t\t\t\tWHERE catid = " . intval($orig_child_cat));
                if ($child_info_query) {
                    $child_title = $child_info_query['title'];
                    $child_description = $child_info_query['description'];
                    $child_displayorder = $child_info_query['displayorder'];
                    $child_options = $child_info_query['options'];
                }
                $child_search_query = $vbulletin->db->query_first("SELECT catid\r\n\t\t\t\t\tFROM " . PHOTOPLOG_PREFIX . "photoplog_categories\r\n\t\t\t\t\tWHERE parentid = " . intval($clone_parent_cat) . "\r\n\t\t\t\t\tAND title = '" . $vbulletin->db->escape_string($child_title) . "'\r\n\t\t\t\t");
                if ($child_search_query) {
                    // child already exists
                    $destination_list_categories[$clone_key] = $child_search_query['catid'];
                } else {
                    // child does not exist, create clone
                    // attempt to grab options from parent category
                    $parent_query = $vbulletin->db->query_first("SELECT options\r\n\t\t\t\t\t\tFROM " . PHOTOPLOG_PREFIX . "photoplog_categories\r\n\t\t\t\t\t\tWHERE catid = " . intval($clone_parent_cat) . "\r\n\t\t\t\t\t");
                    if ($parent_query) {
                        $child_options = $parent_query['options'];
                    }
                    $destination_list_categories[$clone_key] = photoplog_insert_category($child_title, $child_description, $child_displayorder, $clone_parent_cat, $child_options, $ds_catopts);
                }
            } else {
                // really should be no files to move, but in case something just came in, don't move it.
                $destination_list_categories[$clone_key] = $source_list_categories[$clone_key];
            }
        }
    }
}