private function construct_category($userinfo, $type = 'global') { global $vbulletin; require_once DIR . '/includes/blog_functions_category.php'; if (!$userinfo['permissions']) { cache_permissions($userinfo, false); } if (!isset($vbulletin->vbblog['categorycache']["{$userinfo['userid']}"])) { fetch_ordered_categories($userinfo['userid']); } if (empty($vbulletin->vbblog['categorycache']["{$userinfo['userid']}"])) { return; } if ($userinfo['userid'] != $vbulletin->userinfo['userid']) { $cantusecats = array_unique(array_merge($userinfo['blogcategorypermissions']['cantpost'], $vbulletin->userinfo['blogcategorypermissions']['cantpost'], $userinfo['blogcategorypermissions']['cantview'], $vbulletin->userinfo['blogcategorypermissions']['cantview'])); } else { $cantusecats = array_unique(array_merge($userinfo['blogcategorypermissions']['cantpost'], $userinfo['blogcategorypermissions']['cantview'])); } $result = array(); foreach ($vbulletin->vbblog['categorycache']["{$userinfo['userid']}"] as $blogcategoryid => $category) { if (!($userinfo['permissions']['vbblog_general_permissions'] & $vbulletin->bf_ugp_vbblog_general_permissions['blog_cancreatecategory']) and $category['userid']) { continue; } else { if (in_array($blogcategoryid, $cantusecats)) { continue; } else { if ($type == 'global' and $category['userid'] != 0 or $type == 'local' and $category['userid'] == 0) { continue; } } } $result[] = array('blogcategoryid' => $category['blogcategoryid'], 'category' => array('title' => $category['title'])); } return $result; }
function pre_save($doquery = true) { if ($this->presave_called !== null) { return $this->presave_called; } if (!$this->pre_save_blogtext($doquery)) { $this->presave_called = false; return false; } if ($this->fetch_field('dateline') > TIMENOW) { $this->set('pending', 1); } else { $this->set('pending', 0); } if (!$this->condition) { if (!$this->fetch_field('dateline')) { $this->set('dateline', TIMENOW); } else if (($this->fetch_field('pending') AND $this->registry->options['vbblog_pending']) OR ($this->fetch_field('state') == 'draft' AND $this->registry->options['vbblog_draft']) AND $this->fetch_field('userid')) { if (defined('VBBLOG_PERMS') AND $this->registry->userinfo['userid'] == $this->fetch_field('userid')) { $userinfo =& $this->registry->userinfo; } else { if (!defined('VBBLOG_PERMS')) { // Tell the fetch_userinfo plugin that we need the blog fields in case this class is being called by a non blog script define('VBBLOG_PERMS', true); } $userinfo = fetch_userinfo($this->fetch_field('userid'), 1); } if ($this->fetch_field('pending') AND $userinfo['blog_pending'] >= $this->registry->options['vbblog_pending']) { $this->error('maximum_pending_entries', $this->registry->options['vbblog_pending']); return false; } else if ($this->fetch_field('state') == 'draft' AND $userinfo['blog_draft'] >= $this->registry->options['vbblog_draft']) { $this->error('maximum_draft_entries', $this->registry->options['vbblog_draft']); return false; } } $this->set('lastcomment', $this->fetch_field('dateline')); $this->set('lastcommenter', $this->fetch_field('username', 'blog_text')); $this->set('comments_visible', 0); $this->set('comments_moderation', 0); $this->set('comments_deleted', 0); $this->set('trackback_visible', 0); $this->set('trackback_moderation', 0); } else { if (!$this->fetch_field('firstblogtextid')) { $getfirstpost = $this->dbobject->query_first("SELECT blogtextid FROM " . TABLE_PREFIX . "blog WHERE blogid = " . $this->fetch_field('blogid') . " ORDER BY dateline, blogtextid LIMIT 1"); $this->set('firstblogtextid', $getfirstpost['blogtextid']); } if ($this->fetch_field('state') == 'draft' AND $this->existing['state'] != 'draft') { $this->error('existing_entries_can_not_be_draft'); return false; } if ($this->fetch_field('pending') AND $this->existing['pending'] != 1 AND $this->existing['state'] != 'draft') { $this->error('published_entries_can_not_be_set_to_the_future'); return false; } } // Check flood time if ($this->fetch_field('pending') AND $this->registry->options['floodchecktime'] > 0 AND empty($this->info['skip_floodcheck']) AND !can_moderate_blog() AND $this->fetch_field('userid')) { if (!$this->condition OR ($this->existing['dateline'] != $this->fetch_field('dateline'))) { // Want this to hit the master to lessen potential delays that would allow higher flood oppurtunity $lotime = $this->fetch_field('dateline') - $this->registry->options['floodchecktime']; $hitime = $this->fetch_field('dateline') + $this->registry->options['floodchecktime']; $wheresql = array(); $wheresql[] = "dateline < $hitime"; $wheresql[] = "dateline > $lotime"; $wherssql[] = "userid = " . $this->fetch_field('userid'); $wheresql[] = "pending = 1"; if ($this->condition) { $wheresql[] = "blogid <> " . $this->fetch_field('blogid'); } if ($this->dbobject->query_first(" SELECT blogid FROM " . TABLE_PREFIX . "blog WHERE " . implode(" AND ", $wheresql) . " ")) { $this->error('allow_x_seconds_between_entries', $this->registry->options['floodchecktime']); return false; } } } if (is_array($this->info['categories'])) { $userid = $this->fetch_field('userid'); require_once(DIR . '/includes/blog_functions_category.php'); fetch_ordered_categories($userid); foreach ($this->info['categories'] AS $categoryid) { if (empty($this->registry->vbblog['categorycache']["$userid"]["$categoryid"])) { $this->error('invalid_blog_category'); return false; } } if (sizeof($this->info['categories']) > $this->registry->options['blog_catpostlimit']) { $this->error('blog_category_entry_limit', $this->registry->options['blog_catpostlimit']); return false; } } $return_value = true; ($hook = vBulletinHook::fetch_hook('blog_fpdata_presave')) ? eval($hook) : false; $this->presave_called = $return_value; return $return_value; }
OR !($userinfo['permissions']['vbblog_general_permissions'] & $vbulletin->bf_ugp_vbblog_general_permissions['blog_cancreatecategory']) ) { print_no_permission(); } $show['blogcp'] = true; } require_once(DIR . '/includes/blog_functions_category.php'); if (!$vbulletin->GPC['blogcategoryid']) { // make sure they have less than the limit if (!isset($vbulletin->vbblog['categorycache'][$userinfo['userid']])) { fetch_ordered_categories($userinfo['userid']); } $count = 0; foreach($vbulletin->vbblog['categorycache'][$userinfo['userid']] AS $categorycheck) { if ($categorycheck['userid'] == $userinfo['userid']) { $count++; } } if ($count >= $vbulletin->options['blog_catusertotal']) { standard_error(fetch_error('blog_category_limit', $vbulletin->options['blog_catusertotal'])); } }
public static function construct_cat_chooser_options($topname = null) { global $vbulletin, $vbphrase; $selectoptions = array(); if ($topname) { $selectoptions['-2'] = $topname; } require_once DIR . '/includes/blog_functions_category.php'; require_once DIR . '/includes/functions_misc.php'; fetch_ordered_categories(0); $selectoptions['-1'] = fetch_phrase('uncategorized', 'vbblogglobal'); if (!empty($vbulletin->vbblog['categorycache']["0"])) { foreach ($vbulletin->vbblog['categorycache']["0"] as $categoryid => $category) { $depthmark = str_pad('', 4 * $category['depth'], '- - ', STR_PAD_LEFT); $selectoptions[$categoryid] = $depthmark . fetch_phrase('category' . $category['blogcategoryid'] . '_title', 'vbblogcat'); } } return $selectoptions; }
} } // ###################### Start list permissions ####################### if ($_REQUEST['do'] == 'listcp') { print_form_header('', ''); print_table_header($vbphrase['blog_category_permissions']); print_description_row(' <div class="darkbg" style="border: 2px inset"> <ul class="darkbg"> <li><b>' . $vbphrase['color_key'] . '</b></li> <li class="col-g">' . $vbphrase['standard_using_default_usergroup_permissions'] . '</li> <li class="col-c">' . $vbphrase['customized_using_custom_permissions_for_this_usergroup'] . '</li> <li class="col-i">' . $vbphrase['inherited_using_custom_permissions_inherited_from_a_parent_category'] . '</li> </ul></div> '); print_table_footer(); fetch_ordered_categories(0); // query category permissions $categorypermissions = $db->query_read("\r\n\t\tSELECT bcp.usergroupid, bc.blogcategoryid, bcp.categorypermissions, bcp.categorypermissionid,\r\n\t\tNOT (ISNULL(bcp.blogcategoryid)) AS hasdata, bcp.blogcategoryid\r\n\t\tFROM " . TABLE_PREFIX . "blog_category AS bc\r\n\t\tLEFT JOIN " . TABLE_PREFIX . "blog_categorypermission AS bcp ON (bcp.blogcategoryid = bc.blogcategoryid)\r\n\t"); $permscache = array(); while ($cperm = $db->fetch_array($categorypermissions)) { if ($cperm['hasdata']) { $temp = array(); $temp['categorypermissionid'] = $cperm['categorypermissionid']; $temp['categorypermissions'] = $cperm['categorypermissions']; $permscache["{$cperm['blogcategoryid']}"]["{$cperm['usergroupid']}"] = $temp; } } // get usergroup default permissions $permissions = array(); foreach ($vbulletin->usergroupcache as $usergroupid => $usergroup) { $permissions["{$usergroupid}"] = $usergroup['vbblog_general_permissions'];
/** * Function to output select bits * * @param integer Userid * * @return void */ function build_category_genealogy($userid) { global $vbulletin; fetch_ordered_categories($userid, true); // build parent/child lists foreach ($vbulletin->vbblog['categorycache']["$userid"] AS $blogcategoryid => $category) { // parent list $i = 0; $curid = $blogcategoryid; $vbulletin->vbblog['categorycache']["$userid"]["$blogcategoryid"]['parentlist'] = ''; while ($curid != 0 AND $i++ < 1000) { if ($curid) { $vbulletin->vbblog['categorycache']["$userid"]["$blogcategoryid"]['parentlist'] .= (!empty($vbulletin->vbblog['categorycache']["$userid"]["$blogcategoryid"]['parentlist']) ? ',' : '') . $curid; $curid = $vbulletin->vbblog['categorycache']["$userid"]["$curid"]['parentid']; } else { global $vbphrase; if (!isset($vbphrase['invalid_category_parenting'])) { $vbphrase['invalid_category_parenting'] = 'Invalid category parenting setup. Contact vBulletin support.'; } trigger_error($vbphrase['invalid_category_parenting'], E_USER_ERROR); } } // child list $vbulletin->vbblog['categorycache']["$userid"]["$blogcategoryid"]['childlist'] = $blogcategoryid; fetch_category_child_list($blogcategoryid, $blogcategoryid, $userid); } $parentsql = ''; $childsql = ''; foreach ($vbulletin->vbblog['categorycache']["$userid"] AS $blogcategoryid => $category) { $parentsql .= " WHEN $blogcategoryid THEN '$category[parentlist]' "; $childsql .= " WHEN $blogcategoryid THEN '$category[childlist]' "; } if (!empty($vbulletin->vbblog['categorycache']["$userid"])) { $vbulletin->db->query_write(" UPDATE " . TABLE_PREFIX . "blog_category SET parentlist = CASE blogcategoryid $parentsql ELSE parentlist END, childlist = CASE blogcategoryid $childsql ELSE childlist END WHERE userid = $userid "); } }
function build_category_permissions() { global $vbulletin; require_once(DIR . '/includes/blog_functions_category.php'); fetch_ordered_categories(0); // query category permissions $categorypermissions = $vbulletin->db->query_read(" SELECT * FROM " . TABLE_PREFIX . "blog_categorypermission "); $permcache = array(); while ($cperm = $vbulletin->db->fetch_array($categorypermissions)) { $permcache["$cperm[blogcategoryid]"]["$cperm[usergroupid]"] = intval($cperm['categorypermissions']); } $grouppermissions = array(); $usergroups = $vbulletin->db->query_read("SELECT vbblog_general_permissions, usergroupid FROM " . TABLE_PREFIX . "usergroup ORDER BY usergroupid"); while ($usergroup = $vbulletin->db->fetch_array($usergroups)) { $grouppermissions["$usergroup[usergroupid]"] = $usergroup['vbblog_general_permissions']; } $category = $vbulletin->vbblog['categorycache']["0"]; cache_category_permissions($category, $grouppermissions, $permcache); build_datastore('blogcategorycache', serialize($category), 1); // Update blog stats since category permission affects the latest entry build_blog_stats(); }