protected function fetchCanViewCmsArticle($nodeid) { // The process query handles the infernal CMS if (!($node = $this->content['cms_node'][$nodeid])) { return false; } if ($node['publishdate'] > TIMENOW or !$node['published']) { return false; } $canview = vBCMS_Permissions::canView($node['nodeid']); return $canview; }
/** Checks to see if the current user has at least read access to the CMS root node. * * @return boolean **/ function can_see_cms() { global $vbulletin; if (!$vbulletin->products['vbcms']) { return false; } if (class_exists('vBCMS_Permissions', false)) { return vBCMS_Permissions::canView(1); } global $vbulletin; $sql = "SELECT MAX(permissions & 1) AS perm FROM " . TABLE_PREFIX . "cms_permissions WHERE nodeid = 1 AND usergroupid in (" . $vbulletin->userinfo['usergroupid'] . ($vbulletin->userinfo['membergroupids'] != '' ? ', ' . $vbulletin->userinfo['membergroupids'] : '' ) . ")"; $perms = $vbulletin->db->query_first($sql ); return (intval($perms['perm']) > 0); }
/** * this will create an array of result objects from an array of ids() * * @param array of integer $ids * @return array of objects */ public function create_array($ids) { $contenttypeid = vB_Types::instance()->getContentTypeID( 'vBCms_StaticHtml'); if (! isset(vB::$vbulletin->userinfo['permissions']['cms'])) { vBCMS_Permissions::getUserPerms(); } if ($rst = vB::$vbulletin->db->query_read("SELECT n.nodeid as itemid, n.setpublish, u.username,n.nodeid, u.userid, i.html_title, n.permissionsfrom, n.hidden, n.url, nc1.value AS previewtext, nc.value AS pagetext, i.title, i.description, n.publishdate, n.parentnode, parent.title AS parenttitle, parent.html_title AS parent_html_title FROM " . TABLE_PREFIX . "cms_node AS n LEFT JOIN " . TABLE_PREFIX . "cms_nodeinfo i ON i.nodeid = n.nodeid LEFT JOIN " . TABLE_PREFIX . "cms_nodeinfo AS parent ON parent.nodeid = n.parentnode LEFT JOIN " . TABLE_PREFIX . "user u ON u.userid = n.userid LEFT JOIN " . TABLE_PREFIX . "cms_nodeconfig AS nc ON nc.nodeid = n.nodeid AND nc.name = 'pagetext' LEFT JOIN " . TABLE_PREFIX . "cms_nodeconfig AS nc1 ON nc1.nodeid = n.nodeid AND nc1.name = 'previewtext' WHERE n.nodeid IN (" . implode(', ', $ids) . ")")) { while ($search_result = vB::$vbulletin->db->fetch_array($rst)) { vBCMS_Permissions::setPermissionsfrom($search_result['nodeid'], $search_result['$permissionsfrom'], $search_result['hidden'], $search_result['setpublish'], $search_result['publishdate'] ); //check permissions if (!vBCMS_Permissions::canView($search_result['nodeid'])) { continue; } $item = new vBCms_Search_Result_StaticPage(); $item->itemid = $search_result['itemid']; $item->contenttypeid = $contenttypeid; if ($rst1 = vB::$vbulletin->db->query_read("SELECT cat.categoryid, cat.category FROM " . TABLE_PREFIX . "cms_nodecategory nc INNER JOIN " . TABLE_PREFIX . "cms_category cat ON nc.categoryid = cat.categoryid WHERE nc.nodeid = " . $search_result['nodeid'])) { while($record = vB::$vbulletin->db->fetch_array($rst1)) { $record['category_url'] = vB_Route::create('vBCms_Route_List', "category/" . $record['route_info'] . "/1")->getCurrentURL(); $categories[$record['categoryid']] = $record; } } // if ($rst1 = vB::$vbulletin->db->query_read("SELECT cat.categoryid, cat.category FROM " . // TABLE_PREFIX . "cms_nodecategory nc INNER JOIN " . TABLE_PREFIX . // "cms_category cat ON nc.categoryid = cat.categoryid WHERE nc.nodeid = " . // $search_result['nodeid'])) // { // while($record = vB::$vbulletin->db->fetch_array($rst1)) // { // $categories[$record['categoryid']] = $record; // } // } $search_result['categories'] = $categories; $item->record = $search_result; $items[$search_result['itemid']] = $item; } return $items; } return false; }
/** Checks to see if the current user has at least read access to the CMS root node. * * @return boolean **/ function can_see_cms() { global $vbulletin; if (!$vbulletin->products['vbcms']) { return false; } if (class_exists('vBCMS_Permissions', false)) { return vBCMS_Permissions::canView(1); } $ids = array(); $rawids = explode(',', $vbulletin->userinfo['usergroupid'] . ',' . $vbulletin->userinfo['membergroupids']); foreach ($rawids as $id) { if (($id = intval($id)) > 0) { $ids[] = $id; } } if (!empty($ids)) { $perms = $vbulletin->db->query_first("\n\t\t\tSELECT MAX(permissions & 1) AS perm\n\t\t\tFROM " . TABLE_PREFIX . "cms_permissions\n\t\t\tWHERE nodeid = 1 AND usergroupid IN (" . implode(',', $ids) . ")\n\t\t"); return intval($perms['perm']) > 0; } return false; }