protected static function _init_index_map() { // init index map $vb_types = vB_Types::instance(); self::$_sphinx_index_map = array($vb_types->getContentTypeId('vBForum_Post') => array('ThreadPostMain', 'ThreadPostDelta'), $vb_types->getContentTypeId('vBForum_SocialGroupMessage') => array('DiscussionMessageMain', 'DiscussionMessageDelta'), $vb_types->getContentTypeId('vBForum_SocialGroup') => array('SocialGroupMain', 'SocialGroupDelta'), $vb_types->getContentTypeId('vBBlog_BlogEntry') => array('BlogEntryMain', 'BlogEntryDelta'), $vb_types->getContentTypeId('vBBlog_BlogComment') => array('BlogCommentMain', 'BlogCommentDelta'), $vb_types->getContentTypeId('vBCms_Article') => array('CMSArticlesMain', 'CMSArticlesDelta'), $vb_types->getContentTypeId('vBForum_VisitorMessage') => array('VisitorMessageMain', 'VisitorMessageDelta')); return true; }
public function output() { global $vbulletin; if (!isset($vbulletin->userinfo['permissions']['cms'])) { vBCMS_Permissions::getUserPerms(); } $publishlist = implode(', ', vB::$vbulletin->userinfo['permissions']['cms']['canpublish']); $viewlist = implode(', ', vB::$vbulletin->userinfo['permissions']['cms']['allview']); $rst = vB::$vbulletin->db->query_read_slave("SELECT node.nodeid, node.parentnode, node.url, node.permissionsfrom,\n\t\t\tnode.setpublish, node.publishdate, node.noderight, info.title FROM " . TABLE_PREFIX . "cms_node AS node INNER JOIN " . TABLE_PREFIX . "cms_nodeinfo AS info ON info.nodeid = node.nodeid\n\t\t\t WHERE node.contenttypeid = " . vB_Types::instance()->getContentTypeID("vBCms_Section") . " AND\n\t\t((node.permissionsfrom IN ({$viewlist}) AND node.hidden = 0 ) OR (node.permissionsfrom IN ({$publishlist})))\n\t\t\t ORDER BY node.nodeleft"); $nodes = array(); $noderight = 0; while ($record = vB::$vbulletin->db->fetch_array($rst)) { if (!in_array($record['permissionsfrom'], vB::$vbulletin->userinfo['permissions']['cms']['canedit']) and !(in_array($record['permissionsfrom'], vB::$vbulletin->userinfo['permissions']['cms']['canview']) and $record['setpublish'] == '1' and $record['publishdate'] < TIMENOW) or $record['noderight'] < $noderight) { //We need to skip this record and all its children $noderight = $record['permissionsfrom']; continue; } $nodes[] = $record; } if (count($nodes)) { reset($nodes); $nodes = $this->setNavArray($nodes); return $nodes; } }
protected function getNewRouteInfo() { $arguments =& $this->arguments; $param =& $this->queryParameters; $keys = array_keys($param); $idkey = array('t', 'threadid'); if (empty($param['do'])) { $param['do'] = 'showsmilies'; } switch ($param['do']) { case 'bbcode': $this->anchor = 'bbcode_reference/bbcode_why'; return 'help'; case 'showrules': $this->anchor = 'community_overview/general_tos'; return 'help'; case 'showsmilies': $this->anchor = 'bbcode_reference/bbcode_smilies'; return 'help'; case 'whoposted': if ($set = array_intersect($keys, $idkey) and $pid = intval($param[reset($set)])) { $oldid = $pid; $oldcontenttypeid = vB_Types::instance()->getContentTypeID(array('package' => 'vBForum', 'class' => 'Thread')); $node = vB::getDbAssertor()->getRow('vBForum:node', array('oldid' => $oldid, 'oldcontenttypeid' => $oldcontenttypeid)); if (!empty($node)) { $arguments['nodeid'] = $node['nodeid']; return $node['routeid']; } } default: throw new vB_Exception_404('invalid_page'); } }
protected function fetchChannelNodes($parent, $page, $perpage, $depth = 3, $contentype = 0, $options = false) { $api = Api_InterfaceAbstract::instance(); $optionsArray = array(); if (!$contentype) { $contentype = vB_Types::instance()->getContentTypeID('vBForum_Channel'); } $params = array('parentid' => $parent, 'page' => $page, 'perpage' => $perpage, 'depth' => $depth, 'contenttypeid' => $contentype, 'options' => $options); return $api->callApi('node', 'listNodeFullContent', $params); }
public function output() { global $vbulletin, $db, $show, $VB_API_REQUESTS; if (!$VB_API_REQUESTS['api_c']) { // The client doesn't have an ID yet. So we need to generate a new one. $vbulletin->input->clean_array_gpc('r', array('clientname' => TYPE_STR, 'clientversion' => TYPE_STR, 'platformname' => TYPE_STR, 'platformversion' => TYPE_STR, 'uniqueid' => TYPE_STR)); // All params are required. // uniqueid is the best to be a permanent unique id such as hardware ID (CPU ID, // Harddisk ID or Mobile IMIE). Some client can not get a such a uniqueid, // so it needs to generate an unique ID and save it in its local storage. If it // requires the client ID and Secret again, pass the same unique ID. if (!$vbulletin->GPC['clientname'] or !$vbulletin->GPC['clientversion'] or !$vbulletin->GPC['platformname'] or !$vbulletin->GPC['platformversion'] or !$vbulletin->GPC['uniqueid']) { return $this->error('apiclientinfomissing', 'Miss required client information'); } // Gererate clienthash. $clienthash = md5($vbulletin->GPC['clientname'] . $vbulletin->GPC['platformname'] . $vbulletin->GPC['uniqueid']); // Generate a new secret $secret = fetch_random_password(32); // If the same clienthash exists, return secret back to the client. $client = $db->query_first_slave("SELECT *\n\t\t\t\tFROM " . TABLE_PREFIX . "apiclient\n\t\t\t\tWHERE clienthash = '" . $db->escape_string($clienthash) . "'\n\t\t\t\tLIMIT 1\n\t\t\t"); $apiclientid = $client['apiclientid']; if ($apiclientid) { // Update secret // Also remove userid so it will logout previous loggedin and remembered user. (VBM-553) $db->query_write("UPDATE " . TABLE_PREFIX . "apiclient SET\n\t\t\t\t\tsecret = '" . $db->escape_string($secret) . "',\n\t\t\t\t\tapiaccesstoken = '" . $db->escape_string($vbulletin->session->vars['apiaccesstoken']) . "',\n\t\t\t\t\tlastactivity = " . TIMENOW . ",\n\t\t\t\t\tclientversion = '" . $db->escape_string($vbulletin->GPC['clientversion']) . "',\n\t\t\t\t\tplatformversion = '" . $db->escape_string($vbulletin->GPC['platformversion']) . "',\n\t\t\t\t\tuserid = 0\n\t\t\t\t\tWHERE apiclientid = {$apiclientid}"); } else { // Create a new client $db->query_write("\n\t\t\t\t\tINSERT INTO " . TABLE_PREFIX . "apiclient (\n\t\t\t\t\t\tsecret, clienthash, clientname, clientversion, platformname,\n\t\t\t\t\t\tplatformversion, uniqueid, initialipaddress, apiaccesstoken,\n\t\t\t\t\t\tdateline, lastactivity\n\t\t\t\t\t)\n\t\t\t\t\tVALUES (\n\t\t\t\t\t\t'" . $db->escape_string($secret) . "', " . "'" . $db->escape_string($clienthash) . "', " . "'" . $db->escape_string($vbulletin->GPC['clientname']) . "', " . "'" . $db->escape_string($vbulletin->GPC['clientversion']) . "', " . "'" . $db->escape_string($vbulletin->GPC['platformname']) . "', " . "'" . $db->escape_string($vbulletin->GPC['platformversion']) . "', " . "'" . $db->escape_string($vbulletin->GPC['uniqueid']) . "', " . "'" . $db->escape_string($vbulletin->alt_ip) . "', " . "'" . $db->escape_string($vbulletin->session->vars['apiaccesstoken']) . "', " . TIMENOW . ", " . TIMENOW . "\n\t\t\t\t\t)\n\t\t\t\t"); $apiclientid = $db->insert_id(); } // Set session client ID $vbulletin->session->set('apiclientid', $apiclientid); } else { // api_c and api_sig are verified in init.php so we don't need to verify here again. $apiclientid = intval($VB_API_REQUESTS['api_c']); // Update lastactivity $db->query_write("UPDATE " . TABLE_PREFIX . "apiclient SET\n\t\t\t\tlastactivity = " . TIMENOW . "\n\t\t\t\tWHERE apiclientid = {$apiclientid}"); } $contenttypescache = vB_Types::instance()->getContentTypes(); foreach ($contenttypescache as $contenttype) { $contenttypes[$contenttype['class']] = $contenttype['id']; } // Check the status of CMS and Blog $blogenabled = $vbulletin->products['vbblog'] == '1'; $cmsenabled = $vbulletin->products['vbcms'] == '1'; $data = array('apiversion' => VB_API_VERSION, 'apiaccesstoken' => $vbulletin->session->vars['apiaccesstoken'], 'bbtitle' => $vbulletin->options['bbtitle'], 'bburl' => $vbulletin->options['bburl'], 'bbactive' => $vbulletin->options['bbactive'], 'forumhome' => $vbulletin->options['forumhome'], 'vbulletinversion' => $vbulletin->options['templateversion'], 'contenttypes' => $contenttypes, 'features' => array('blogenabled' => $blogenabled, 'cmsenabled' => $cmsenabled, 'pmsenabled' => (bool) $vbulletin->options['enablepms'], 'searchesenabled' => (bool) $vbulletin->options['enablesearches'], 'groupsenabled' => (bool) ($vbulletin->options['socnet'] & $vbulletin->bf_misc_socnet['enable_groups']), 'albumsenabled' => (bool) ($vbulletin->options['socnet'] & $vbulletin->bf_misc_socnet['enable_albums']), 'friendsenabled' => (bool) ($vbulletin->options['socnet'] & $vbulletin->bf_misc_socnet['enable_friends']), 'visitor_trackingenabled' => (bool) ($vbulletin->options['socnet'] & $vbulletin->bf_misc_socnet['enable_visitor_tracking']), 'visitor_messagingenabled' => (bool) ($vbulletin->options['socnet'] & $vbulletin->bf_misc_socnet['enable_visitor_messaging']), 'multitypesearch' => true, 'taggingenabled' => (bool) $vbulletin->options['threadtagging'], 'paidsubs' => $this->paidSubs()), 'permissions' => $vbulletin->userinfo['permissions'], 'show' => $show); if (!$vbulletin->options['bbactive']) { $data['bbclosedreason'] = $vbulletin->options['bbclosedreason']; } $data['apiclientid'] = $apiclientid; if (!$VB_API_REQUESTS['api_c']) { $data['secret'] = $secret; } return $data; }
public function populate() { $typeid = vB::$vbulletin->activitystream['socialgroup_photocomment']['typeid']; $this->delete($typeid); if (!vB::$vbulletin->activitystream['socialgroup_photocomment']['enabled']) { return; } $contenttypeid = vB_Types::instance()->getContentTypeID('vBForum_SocialGroup'); $timespan = TIMENOW - vB::$vbulletin->options['as_expire'] * 60 * 60 * 24; vB::$db->query_write("\n\t\t\tINSERT INTO " . TABLE_PREFIX . "activitystream\n\t\t\t\t(userid, dateline, contentid, typeid, action)\n\t\t\t\t(SELECT\n\t\t\t\t\tpostuserid, dateline, commentid, '{$typeid}', 'create'\n\t\t\t\tFROM " . TABLE_PREFIX . "picturecomment\n\t\t\t\tWHERE\n\t\t\t\t\tdateline >= {$timespan}\n\t\t\t\t\t\tAND\n\t\t\t\t\tsourcecontenttypeid = {$contenttypeid}\n\t\t\t\t)\n\t\t"); }
protected function getNewRouteInfo() { $oldid = $this->captureOldId(); $node = vB::getDbAssertor()->getRow('vBForum:fetchLegacyPostIds', array('oldids' => $oldid, 'postContentTypeId' => vB_Types::instance()->getContentTypeID('vBForum_Post'))); if (empty($node)) { throw new vB_Exception_404('invalid_page'); } $this->arguments['nodeid'] = $node['starter']; $this->arguments['innerPost'] = $node['nodeid']; return $node['routeid']; }
/** * Deletes all expired redirects * */ public function deleteExpiredRedirects() { $timenow = vB::getRequest()->getTimeNow(); $contenttypeid = vB_Types::instance()->getContentTypeId($this->contenttype); $assertor = vB::getDbAssertor(); $expiredRedirects = $assertor->getRows('vBForum:node', array(vB_dB_Query::CONDITIONS_KEY => array(array('field' => 'contenttypeid', 'value' => $contenttypeid, vB_Db_Query::OPERATOR_KEY => vB_Db_Query::OPERATOR_EQ), array('field' => 'unpublishdate', 'value' => $timenow, vB_Db_Query::OPERATOR_KEY => vB_Db_Query::OPERATOR_LTE)))); $redirectids = array(); foreach ($expiredRedirects as $redirect) { $redirectids[] = $redirect['nodeid']; } $assertor->delete('vBForum:redirect', array(array('field' => 'nodeid', 'value' => $redirectids, vB_Db_Query::OPERATOR_KEY => vB_Db_Query::OPERATOR_EQ))); $assertor->delete('vBForum:node', array(array('field' => 'nodeid', 'value' => $redirectids, vB_Db_Query::OPERATOR_KEY => vB_Db_Query::OPERATOR_EQ))); }
public function populate() { if (!vB::$vbulletin->products['vbcms']) { return; } $typeid = vB::$vbulletin->activitystream['cms_article']['typeid']; $this->delete($typeid); if (!vB::$vbulletin->activitystream['cms_article']['enabled']) { return; } $contenttypeid = vB_Types::instance()->getContentTypeID('vBCms_Article'); $timespan = TIMENOW - vB::$vbulletin->options['as_expire'] * 60 * 60 * 24; vB::$db->query_write("\n\t\t\tINSERT INTO " . TABLE_PREFIX . "activitystream\n\t\t\t\t(userid, dateline, contentid, typeid, action)\n\t\t\t\t(SELECT\n\t\t\t\t\tuserid, publishdate, nodeid, '{$typeid}', 'create'\n\t\t\t\tFROM " . TABLE_PREFIX . "cms_node AS cms_node\n\t\t\t\tWHERE\n\t\t\t\t\tpublishdate >= {$timespan}\n\t\t\t\t\t\tAND\n\t\t\t\t\tcontenttypeid = {$contenttypeid}\n\t\t\t\t)\n\t\t"); }
protected function getNewRouteInfo() { $param =& $this->queryParameters; if (isset($param['p']) and $oldid = intval($param['p']) or isset($param['postid']) and $oldid = intval($param['postid'])) { $node = vB::getDbAssertor()->getRow('vBForum:fetchLegacyPostIds', array('oldids' => $oldid, 'postContentTypeId' => vB_Types::instance()->getContentTypeID('vBForum_Post'))); if (empty($node)) { throw new vB_Exception_404('invalid_page'); } $this->arguments['nodeid'] = $node['starter']; $this->arguments['innerPost'] = $node['nodeid']; return $node['routeid']; } $this->oldcontenttypeid = vB_Types::instance()->getContentTypeID(array('package' => 'vBForum', 'class' => 'Thread')); return parent::getNewRouteInfo(); }
protected function validateAndCleanNotificationData($notificationData) { // Very similar to the vB_Notification_Content, but has to skip the "channel" check since // VM's go to their own channel. Instead, there's a isVisitorMessage() check. $newData = parent::validateAndCleanNotificationData($notificationData); unset($notificationData); if (!isset($newData['sentbynodeid'])) { throw new Exception("Missing Notification Data: sentbynodeid"); } $nodeid = $newData['sentbynodeid']; $node = vB_Library::instance('node')->getNode($nodeid, false, true); // we need to get the full content, to ensure 'channeltype' is there. if (!isset($node['nodeid'])) { throw new Exception("Invalid Notification Data: sentbynodeid"); } if (!isset($node['setfor'])) { throw new Exception("Invalid Node Data: setfor"); } // only explictly specified content types are allowed to send notifications $topLevelContentTypes = array('Gallery' => 1, 'Link' => 1, 'Poll' => 1, 'Text' => 1, 'Video' => 1); $contenttypeclass = vB_Types::instance()->getContentTypeClass($node['contenttypeid']); if (!isset($topLevelContentTypes[$contenttypeclass])) { throw new Exception("Cannot send this notification for the node's content type."); } // Only allow visitor messages. /* // node lib's fetchClosureParent() does not seem functional for the 2nd param that content lib's isVisitorMessage() // relies on, VBV-14367. Let's just check the closure table directly for now. $contentLib = vB_Library::instance('Content_' . vB_Types::instance()->getContentTypeClass($node['contenttypeid'])); if (!$contentLib->isVisitorMessage($nodeid)) { throw new Exception("Not a visitor message."); } */ $vmChannel = vB_Library::instance('node')->fetchVMChannel(); $closureCheck = vB::getDbAssertor()->getRows('vBForum:closure', array('child' => $nodeid, 'parent' => $vmChannel)); if (empty($closureCheck)) { throw new Exception("Not a visitor message."); } // We're good if we got to this point. $newData['sentbynodeid'] = (int) $node['nodeid']; if (!isset($node['userid'])) { throw new Exception("Invalid Notification Data: sentbynodeid"); } $newData['sender'] = (int) $node['userid']; return $newData; }
/** * Verify permissions of a single attachment * * @return bool */ public function verify_attachment() { if (!$this->verify_attachment_specific('vBCms_Article')) { return false; } //Now we need to get a content id. It could come from several places if (!isset($this->contentid)) { vB::$vbulletin->input->clean_array_gpc('r', array( 'f' => vB_Input::TYPE_UINT, 'attachmentid' => vB_Input::TYPE_UINT )); } if (vB::$vbulletin->GPC_exists['values'] and isset(vB::$vbulletin->GPC['values']['f'])) { $this->contentid = vB::$vbulletin->GPC['values']['f']; } else if (vB::$vbulletin->GPC_exists['attachmentid'] AND $this->vbulletininfo['contentid']) { $this->contentid = $this->vbulletininfo['contentid']; } else if (vB::$vbulletin->GPC_exists['attachmentid'] AND intval(vB::$vbulletin->GPC['attachmentid'])) { if ($record = vB::$db->query_first("SELECT contentid, contenttypeid FROM " . TABLE_PREFIX . "attachment where attachmentid = " . vB::$vbulletin->GPC['attachmentid'])) { if ($record['contenttypeid'] == vB_Types::instance()->getContentTypeID("vBCms_Article")) { $this->contentid = $record['contentid']; } } } //If we have a contentid, we can check the permissions if (isset($this->contentid)) { return vBCMS_Permissions::canDownload($this->contentid); } return false; }
protected function getNewRouteInfo() { // go to home page if path is exactly like prefix if (count($this->matches) == 1 and empty($this->queryParameters)) { $forumHomeChannel = vB_Library::instance('content_channel')->getForumHomeChannel(); return $forumHomeChannel['routeid']; } // capture old id $argument =& $this->arguments; $oldid = $argument['oldid']; // calculate old contenttypeid $oldtype = array('t' => 'Thread', 'f' => 'Forum'); $oldcontenttypeid = vB_Types::instance()->getContentTypeID(array('package' => 'vBForum', 'class' => $oldtype[$this->matches['nodetype']])); $node = vB::getDbAssertor()->getRow('vBForum:node', array('oldid' => $oldid, 'oldcontenttypeid' => $oldcontenttypeid)); if (empty($node)) { throw new vB_Exception_404('invalid_page'); } $argument['nodeid'] = $node['nodeid']; return $node['routeid']; }
protected function getNewRouteInfo() { $oldtype = array('cat' => 9988, 'groupid' => vB_Types::instance()->getContentTypeID('vBForum_SocialGroup'), 'discussionid' => vB_Types::instance()->getContentTypeID('vBForum_SocialGroupDiscussion')); $argument =& $this->arguments; $param =& $this->queryParameters; foreach ($oldtype as $key => $oldcontenttypeid) { if (!empty($param[$key]) and $oldid = intval($param[$key])) { $node = vB::getDbAssertor()->getRow('vBForum:node', array('oldid' => $oldid, 'oldcontenttypeid' => $oldcontenttypeid)); if (empty($node)) { throw new vB_Exception_404('invalid_page'); } $argument['nodeid'] = $node['nodeid']; return $node['routeid']; } } $sgChannelId = vB_Api::instance('socialgroup')->getSGChannel(); $sgChannel = vB::getDbAssertor()->getRow('vBForum:node', array('nodeid' => $sgChannelId)); $argument['nodeid'] = $sgChannel['nodeid']; return $sgChannel['routeid']; }
protected function getNewRouteInfo() { $param =& $this->queryParameters; $search = array(); // pull the parameter that still compatible with vb5 and discard others if (isset($param['userid'])) { $user = vB_User::fetchUserinfo($param['userid']); if ($user !== false) { $search['author'] = $user['username']; } } if (isset($param['starteronly'])) { $search['starter_only'] = $param['starteronly']; } if (isset($param['forumchoice'])) { $oldcontenttypeid = vB_Types::instance()->getContentTypeID(array('package' => 'vBForum', 'class' => 'Forum')); foreach ($param['forumchoice'] as $oldid) { $node = vB::getDbAssertor()->getRow('vBForum:node', array('oldid' => $oldid, 'oldcontenttypeid' => $oldcontenttypeid)); $search['channel'][] = $node['nodeid']; } } if (isset($param['do'])) { switch ($param['do']) { case 'finduser': if (!empty($search)) { $searchJSON = json_encode($search); } break; case 'getdaily': case 'getnew': $searchJSON = '{"date":"lastVisit","view":"topic","unread_only":1,"sort":{"lastcontent":"desc"},"exclude_type":["vBForum_PrivateMessage"]}'; break; default: } } $param = array(); if (!empty($searchJSON)) { $param['searchJSON'] = $searchJSON; } return 'search'; }
protected function getNewRouteInfo() { $argument =& $this->arguments; $param =& $this->queryParameters; $keys = array_keys($param); $tidkey = array('t', 'threadid'); $pidkey = array('p', 'postid'); if ($set = array_intersect($keys, $tidkey) and $pid = intval($param[reset($set)])) { $oldid = $pid; $node = vB::getDbAssertor()->getRow('vBForum:node', array('oldid' => $oldid, 'oldcontenttypeid' => vB_Types::instance()->getContentTypeID(array('package' => 'vBForum', 'class' => 'Thread')))); } else { if ($set = array_intersect($keys, $pidkey) and $pid = intval($param[reset($set)])) { $oldid = $pid; $node = vB::getDbAssertor()->getRow('vBForum:fetchLegacyPostIds', array('oldids' => $oldid, 'postContentTypeId' => vB_Types::instance()->getContentTypeID('vBForum_Post'))); } } if (empty($node)) { throw new vB_Exception_404('invalid_page'); } $this->arguments['nodeid'] = $node['starter']; return $node['routeid']; }
/** * Format the data for saving * * @param bool * * @return boolean Function result */ function pre_save($doquery = true) { if ($this->presave_called !== null) { return $this->presave_called; } if (!$this->fetch_field('contenttypeid')) { if ($this->info['contenttype']) { $this->set('contenttypeid', vB_Types::instance()->getContentTypeID($this->info['contenttype'])); } } if (!$this->fetch_field('dateline')) { $this->set('dateline', TIMENOW); } if (!$this->fetch_field('ipid')) { $this->set('ipid', 0); } $return_value = true; if (!$this->hook_presave) { ($hook = vBulletinHook::fetch_hook('contentread_presave')) ? eval($hook) : false; } $this->presave_called = $return_value; return $return_value; }
protected function getNewRouteInfo() { $argument =& $this->arguments; $param =& $this->queryParameters; if (!empty($param['u'])) { $argument['userid'] = intval($param['u']); $argument['tab'] = 'media'; return 'profile'; } else { if (!empty($param['albumid'])) { $oldid = intval($param['albumid']); $oldcontenttypeid = vB_Types::instance()->getContentTypeID('vBForum_Album'); $node = vB::getDbAssertor()->getRow('vBForum:node', array('oldid' => $oldid, 'oldcontenttypeid' => $oldcontenttypeid)); if (empty($node)) { throw new vB_Exception_404('invalid_page'); } $argument['nodeid'] = $node['nodeid']; return 'album'; } else { throw new vB_Exception_404('invalid_page'); } } }
protected function validateAndCleanNotificationData($notificationData) { $newData = parent::validateAndCleanNotificationData($notificationData); unset($notificationData); if (!isset($newData['sentbynodeid'])) { throw new Exception("Missing Notification Data: sentbynodeid"); } $nodeid = $newData['sentbynodeid']; $node = vB_Library::instance('node')->getNode($nodeid, false, true); // we need to get the full content, to ensure 'channeltype' is there. if (!isset($node['nodeid'])) { throw new Exception("Invalid Notification Data: sentbynodeid"); } // Don't send notification if it's not visible to a "regular" user. if (!($node['showpublished'] and $node['showapproved'])) { throw new Exception("Invalid Notification Data: showpublished or showapproved"); } // The sentbynodeid MUST BE A POLL TYPE $topLevelContentTypes = array('Poll' => 1); $contenttypeclass = vB_Types::instance()->getContentTypeClass($node['contenttypeid']); if (!isset($topLevelContentTypes[$contenttypeclass])) { throw new Exception("Cannot send this notification for the node's content type."); } // Let's restrict it to certain channel types, just in case we can create polls anywhere. // Keep this in sync with vB_Channel::$channelTypes $allowedChannelTypes = array('forum' => 1, 'blog' => 1, 'article' => 1, 'group' => 1); if (!isset($allowedChannelTypes[$node['channeltype']])) { throw new Exception("Cannot send this notification for the node's channel type."); } // We're good if we got to this point. $newData['sentbynodeid'] = (int) $node['nodeid']; // Sender must be specified when constructing this type. Set by parent::validateAndCleanNotificationData() if (!isset($newData['sender'])) { throw new Exception("Invalid Notification Data: sender"); } return $newData; }
/** * Validates the notification data, checks the context to see if we should send this * notification type, and throws exceptions if we should not or cannot send this notification * type. If all is okay, it may set additional notification data specific to this notification type. * * @param Array $notificationData * * @throws Exception() If for some reason this notification type cannot be sent given * the context data in $notificationData * * @access protected */ protected function validateAndCleanNotificationData($notificationData) { $newData = parent::validateAndCleanNotificationData($notificationData); unset($notificationData); if (!isset($newData['sentbynodeid'])) { throw new Exception("Missing Notification Data: sentbynodeid"); } $nodeid = $newData['sentbynodeid']; $node = vB_Library::instance('node')->getNode($nodeid, false, true); // we need to get the full content, to ensure 'channeltype' is there. if (!isset($node['nodeid'])) { throw new Exception("Invalid Notification Data: sentbynodeid"); } // Don't send notification if it's not visible to a "regular" user. if (!($node['showpublished'] and $node['showapproved'])) { throw new Exception("Invalid Notification Data: showpublished or showapproved"); } // only explictly specified content types are allowed to send notifications $topLevelContentTypes = array('Gallery' => 1, 'Link' => 1, 'Poll' => 1, 'Text' => 1, 'Video' => 1); $contenttypeclass = vB_Types::instance()->getContentTypeClass($node['contenttypeid']); if (!isset($topLevelContentTypes[$contenttypeclass])) { throw new Exception("Cannot send this notification for the node's content type."); } // Similar to above, but for channeltypes. Keep this in sync with vB_Channel::$channelTypes $allowedChannelTypes = array('forum' => 1, 'blog' => 1, 'article' => 1, 'group' => 1); if (!isset($allowedChannelTypes[$node['channeltype']])) { throw new Exception("Cannot send this notification for the node's channel type."); } // We're good if we got to this point. $newData['sentbynodeid'] = (int) $node['nodeid']; if (!isset($node['userid'])) { throw new Exception("Invalid Notification Data: sentbynodeid"); } $newData['sender'] = (int) $node['userid']; return $newData; }
/** standard constructor **/ public function __construct() { $self->contenttypeid = vB_Types::instance()->getContentTypeID('vBCms_StaticPage'); }
protected function fetchSubscribeUnionSql() { $sqlbits = array(); if (vB::$vbulletin->activitystream['forum_post']['enabled']) { $sqlbits[] = "\n\t\t\t\t### Threads ###\n\t\t\t\tSELECT stream.*, type.section, type.type\n\t\t\t\tFROM " . TABLE_PREFIX . "activitystream AS stream\n\t\t\t\tINNER JOIN " . TABLE_PREFIX . "activitystreamtype AS type ON (stream.typeid = type.typeid)\n\t\t\t\tINNER JOIN " . TABLE_PREFIX . "post AS p ON (p.postid = stream.contentid)\n\t\t\t\tINNER JOIN " . TABLE_PREFIX . "subscribethread AS st ON (\n\t\t\t\t\tp.threadid = st.threadid\n\t\t\t\t\t\tAND\n\t\t\t\t\tstream.typeid = " . intval(vB::$vbulletin->activitystream['forum_post']['typeid']) . "\n\t\t\t\t\t\tAND\n\t\t\t\t\tst.userid = " . vB::$vbulletin->userinfo['userid'] . "\n\t\t\t\t)\n\t\t\t\t" . ($this->wheresql ? "WHERE " . implode(" AND ", $this->wheresql) : "") . "\n\t\t\t"; } /* * Blog specific bits */ if (vB::$vbulletin->products['vbblog']) { if (vB::$vbulletin->activitystream['blog_comment']['enabled']) { $sqlbits[] = "\n\t\t\t\t\t### Blog Entries###\n\t\t\t\t\tSELECT stream.*, type.section, type.type\n\t\t\t\t\tFROM " . TABLE_PREFIX . "activitystream AS stream\n\t\t\t\t\tINNER JOIN " . TABLE_PREFIX . "activitystreamtype AS type ON (stream.typeid = type.typeid)\n\t\t\t\t\tINNER JOIN " . TABLE_PREFIX . "blog_text AS bt ON (bt.blogtextid = stream.contentid)\n\t\t\t\t\tINNER JOIN " . TABLE_PREFIX . "blog_subscribeentry AS se ON (\n\t\t\t\t\t\tbt.blogid = se.blogid\n\t\t\t\t\t\t\tAND\n\t\t\t\t\t\tstream.typeid = " . intval(vB::$vbulletin->activitystream['blog_comment']['typeid']) . "\n\t\t\t\t\t\t\tAND\n\t\t\t\t\t\tse.userid = " . vB::$vbulletin->userinfo['userid'] . "\n\t\t\t\t\t)\n\t\t\t\t\t" . ($this->wheresql ? "WHERE " . implode(" AND ", $this->wheresql) : "") . "\n\t\t\t\t"; } /* * The query below filters out any entries in the blog_subscribeentry table since they * will be populated in the above query */ if (vB::$vbulletin->activitystream['blog_entry']['enabled']) { $sqlbits[] = "\n\t\t\t\t\t### Blog User###\n\t\t\t\t\tSELECT stream.*, type.section, type.type\n\t\t\t\t\tFROM " . TABLE_PREFIX . "activitystream AS stream\n\t\t\t\t\tINNER JOIN " . TABLE_PREFIX . "activitystreamtype AS type ON (stream.typeid = type.typeid)\n\t\t\t\t\tINNER JOIN " . TABLE_PREFIX . "blog AS blog ON (blog.blogid = stream.contentid)\n\t\t\t\t\tINNER JOIN " . TABLE_PREFIX . "blog_subscribeuser AS su ON (\n\t\t\t\t\t\tblog.userid = su.bloguserid\n\t\t\t\t\t\t\tAND\n\t\t\t\t\t\tstream.typeid = " . intval(vB::$vbulletin->activitystream['blog_entry']['typeid']) . "\n\t\t\t\t\t\t\tAND\n\t\t\t\t\t\tsu.userid = " . vB::$vbulletin->userinfo['userid'] . "\n\t\t\t\t\t)\n\t\t\t\t\t" . ($this->wheresql ? "WHERE " . implode(" AND ", $this->wheresql) : "") . "\n\t\t\t\t"; } } /* * Social Group specific bits */ if (vB::$vbulletin->options['socnet'] & vB::$vbulletin->bf_misc_socnet['enable_groups'] and vB::$vbulletin->userinfo['permissions']['socialgrouppermissions'] & vB::$vbulletin->bf_ugp_socialgrouppermissions['canviewgroups']) { if (vB::$vbulletin->activitystream['socialgroup_groupmessage']['enabled']) { $sqlbits[] = "\n\t\t\t\t\t### Social Group Messages ###\n\t\t\t\t\tSELECT stream.*, type.section, type.type\n\t\t\t\t\tFROM " . TABLE_PREFIX . "activitystream AS stream\n\t\t\t\t\tINNER JOIN " . TABLE_PREFIX . "activitystreamtype AS type ON (stream.typeid = type.typeid)\n\t\t\t\t\tINNER JOIN " . TABLE_PREFIX . "groupmessage AS gm ON (gm.gmid = stream.contentid)\n\t\t\t\t\tINNER JOIN " . TABLE_PREFIX . "subscribediscussion AS sd ON (\n\t\t\t\t\t\tgm.discussionid = sd.discussionid\n\t\t\t\t\t\t\tAND\n\t\t\t\t\t\tstream.typeid = " . intval(vB::$vbulletin->activitystream['socialgroup_groupmessage']['typeid']) . "\n\t\t\t\t\t\t\tAND\n\t\t\t\t\t\tsd.userid = " . vB::$vbulletin->userinfo['userid'] . "\n\t\t\t\t\t)\n\t\t\t\t\t" . ($this->wheresql ? "WHERE " . implode(" AND ", $this->wheresql) : "") . "\n\t\t\t\t"; } if (vB::$vbulletin->activitystream['socialgroup_discussion']['enabled']) { $sqlbits[] = "\n\t\t\t\t\t### Social Group Discussions ###\n\t\t\t\t\tSELECT stream.*, type.section, type.type\n\t\t\t\t\tFROM " . TABLE_PREFIX . "activitystream AS stream\n\t\t\t\t\tINNER JOIN " . TABLE_PREFIX . "activitystreamtype AS type ON (stream.typeid = type.typeid)\n\t\t\t\t\tINNER JOIN " . TABLE_PREFIX . "discussion AS d ON (d.discussionid = stream.contentid)\n\t\t\t\t\tINNER JOIN " . TABLE_PREFIX . "subscribegroup AS sg ON (\n\t\t\t\t\t\td.groupid = sg.groupid\n\t\t\t\t\t\t\tAND\n\t\t\t\t\t\tstream.typeid = " . intval(vB::$vbulletin->activitystream['socialgroup_discussion']['typeid']) . "\n\t\t\t\t\t\t\tAND\n\t\t\t\t\t\tsg.userid = " . vB::$vbulletin->userinfo['userid'] . "\n\t\t\t\t\t)\n\t\t\t\t\t" . ($this->wheresql ? "WHERE " . implode(" AND ", $this->wheresql) : "") . "\n\t\t\t\t"; } if (vB::$vbulletin->activitystream['socialgroup_photo']['enabled']) { $contenttypeid = vB_Types::instance()->getContentTypeID('vBForum_SocialGroup'); $sqlbits[] = "\n\t\t\t\t\t### Social Group Photos ###\n\t\t\t\t\tSELECT stream.*, type.section, type.type\n\t\t\t\t\tFROM " . TABLE_PREFIX . "activitystream AS stream\n\t\t\t\t\tINNER JOIN " . TABLE_PREFIX . "activitystreamtype AS type ON (stream.typeid = type.typeid)\n\t\t\t\t\tINNER JOIN " . TABLE_PREFIX . "attachment AS a ON (a.attachmentid = stream.contentid AND a.contenttypeid = {$contenttypeid})\n\t\t\t\t\tINNER JOIN " . TABLE_PREFIX . "subscribegroup AS sg ON (\n\t\t\t\t\t\ta.contentid = sg.groupid\n\t\t\t\t\t\t\tAND\n\t\t\t\t\t\tstream.typeid = " . intval(vB::$vbulletin->activitystream['socialgroup_photo']['typeid']) . "\n\t\t\t\t\t\t\tAND\n\t\t\t\t\t\tsg.userid = " . vB::$vbulletin->userinfo['userid'] . "\n\t\t\t\t\t)\n\t\t\t\t\t" . ($this->wheresql ? "WHERE " . implode(" AND ", $this->wheresql) : "") . "\n\t\t\t\t"; } } ($hook = vBulletinHook::fetch_hook($this->hook_union)) ? eval($hook) : false; if (!$sqlbits) { $sqlbits[] = "\n\t\t\t\tSELECT stream.*\n\t\t\t\tFROM " . TABLE_PREFIX . "activitystream AS stream\n\t\t\t\tWHERE stream.activitystreamid = 0\n\t\t\t"; } return vB::$vbulletin->db->query_read_slave("\n\t\t\t(" . implode(") UNION ALL (", $sqlbits) . ")\n\t\t\tORDER BY dateline DESC\n\t\t\t{$this->limitsql}\n\t\t"); }
/** * post_delete function - extend if the contenttype needs to do anything * * @param $attachdm added for PHP 5.4 strict standards compliance * * @return void */ public function post_delete(&$attachdm = '') { // Update attach in the post table if (!empty($this->lists['postlist'])) { $types = vB_Types::instance(); $contenttypeid = intval($types->getContentTypeID('vBForum_Post')); // COALASCE() used here due to issue in 5.1.30 (at least) where mysql reports COLUMN CANNOT BE NULL error // when the subquery returns a null $this->registry->db->query_write("\n\t\t\t\tUPDATE " . TABLE_PREFIX . "post AS p\n\t\t\t\tSET p.attach = COALESCE((\n\t\t\t\t\tSELECT COUNT(*)\n\t\t\t\t\tFROM " . TABLE_PREFIX . "attachment AS a\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tp.postid = a.contentid\n\t\t\t\t\t\t\tAND\n\t\t\t\t\t\ta.contenttypeid = {$contenttypeid}\n\t\t\t\t\tGROUP BY a.contentid\n\t\t\t\t), 0)\n\t\t\t\tWHERE p.postid IN (" . implode(", ", array_keys($this->lists['postlist'])) . ")\n\t\t\t"); } // Update attach in the thread table if (!empty($this->lists['threadlist'])) { $this->registry->db->query_write("\n\t\t\t\tUPDATE " . TABLE_PREFIX . "thread AS t\n\t\t\t\tSET t.attach = (\n\t\t\t\t\tSELECT SUM(attach)\n\t\t\t\t\tFROM " . TABLE_PREFIX . "post AS p\n\t\t\t\t\tWHERE p.threadid = t.threadid\n\t\t\t\t\tGROUP BY p.threadid\n\t\t\t\t)\n\t\t\t\tWHERE t.threadid IN (" . implode(", ", array_keys($this->lists['threadlist'])) . ")\n\t\t\t"); } }
if ($foruminfo['options'] & $vbulletin->bf_misc_forumoptions['displaywrt']) { // Usergroup & Author Check if ($vbulletin->userinfo['permissions']['forumpermissions'] & $vbulletin->bf_ugp_forumpermissions['canwrtmembers'] or $vbulletin->options['wrtauthor'] and $threadinfo['postuserid'] == $vbulletin->userinfo['userid']) { $show['wrt'] = true; } } } if ($show['wrt']) { $cutoff = $threadinfo['dateline']; if ($vbulletin->options['wrtlimit']) { $cutoff = TIMENOW - 86400 * $vbulletin->options['wrtlimit']; } $wrt = array(); $wrtlist = array(); $wrt['threadid'] = $threadinfo['threadid']; $contenttypeid = vB_Types::instance()->getContentTypeID('vBForum_Thread'); ($hook = vBulletinHook::fetch_hook('showthread_whoread_prelist')) ? eval($hook) : false; if ($vbulletin->options['wrtreaders']) { /* IP data isnt used in the display atm but this is how you link to the new ip table */ $readlist = $vbulletin->db->query_read_slave("\n\t\t\tSELECT user.userid, user.options, user.username, user.usergroupid,\n\t\t\tuser.displaygroupid, whoread.dateline #, ipdata.ip AS ipaddress, ipdata.altip\n\t\t\tFROM " . TABLE_PREFIX . "contentread as whoread\n\t\t\tINNER JOIN " . TABLE_PREFIX . "user as user USING (userid)\n#\t\t\tLEFT JOIN " . TABLE_PREFIX . "ipdata as ipdata USING (ipid)\n\t\t\tWHERE whoread.readtype = 'view'\n\t\t\tAND whoread.contentid = {$threadid}\n\t\t\tAND whoread.contenttypeid = {$contenttypeid}\n\t\t\tAND whoread.dateline > {$cutoff}\n\t\t"); $count = 0; $wrt['trtotal'] = 0; while ($threadreader = $vbulletin->db->fetch_array($readlist)) { if (intval($threadreader['userid'])) { $wrt['trtotal'] += 1; $threadreader['markinv'] = ''; $threadreader[visible] = true; if ($threadreader['options'] & $vbulletin->bf_misc_useroptions['invisible']) { $threadreader['visible'] = false; if ($vbulletin->userinfo['permissions']['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['canseehidden'] or $threadreader['userid'] == $vbulletin->userinfo['userid']) {
} // ############################# REQUIRE ################################## require_once DIR . '/includes/functions.php'; require_once DIR . '/includes/functions_socialgroup.php'; require_once DIR . '/includes/functions_check_images.php'; require_once DIR . '/includes/blog_functions.php'; require_once DIR . '/includes/class_bootstrap_framework.php'; require_once DIR . '/vb/types.php'; if (!function_exists('ci_check_urls')) { exit; } // ######################################################################## // ######################### START MAIN SCRIPT ############################ // ######################################################################## vB_Bootstrap_Framework::init(); $ci_content_types = vB_Types::instance(); // first of all, purge all obsolete records $vbulletin->db->query_write("\n DELETE FROM " . TABLE_PREFIX . "rcd_imagequeue\n WHERE `nextcheck` < " . (TIMENOW - CI_MAX_RECORD_AGE * 24 * 3600) . "\n"); /* * get URLs that we need to check (status = PROCESSING and nextcheck < now) * * valid statuses are: * PROCESSING - http code not 200, will be checked later * SUCCESS - got http code 200, not be checked anymore * REPLACE - got http code 200, but it too big or it not a picture * FAILED - number of attempts exceeded, not be checked anymore */ $ci_query_resource = $vbulletin->db->query("\n SELECT imagequeueid, url, contentid, contenttypeid, attempts\n FROM " . TABLE_PREFIX . "rcd_imagequeue\n WHERE status = 'PROCESSING'\n AND nextcheck < " . TIMENOW . "\n"); // Queue URLs to check $ci_urls = array(); // Full URL data (to update message)
/** * vB_Search_Type::get_groupcontenttypeid() * Get the group content type id for this types group type * * This is only valid if can_group returns true * * @return the group content type id */ public function get_groupcontenttypeid() { return vB_Types::instance()->getContentTypeId($this->group_package . "_" . $this->group_class); }
/** * Additional tasks to perform before a delete. * * Return false to indicate that the entire delete process was not a success. * * @param mixed - The result of execDelete() */ protected function preDelete($result) { $this->assertItem(); require_once DIR . '/includes/class_taggablecontent.php'; $taggable = vB_Taggable_Content_Item::create(vB::$vbulletin, vB_Types::instance()->getContentTypeID("vBCms_Article"), intval($this->item->getId())); $taggable->delete_tag_attachments(); vB::$db->query_write(" DELETE FROM " . TABLE_PREFIX . "cms_nodecategory WHERE nodeid = " . intval($this->item->getNodeId()) ); vB::$db->query_write(" DELETE FROM " . TABLE_PREFIX . "cms_article WHERE contentid = " . intval($this->item->getId()) ); vB_Cache::instance()->event('categories_updated'); return parent::preDelete($result); }
function delete() { global $vbulletin; if ($blogid = $this->existing['blogid']) { $db =& $this->registry->db; require_once(DIR . '/includes/blog_functions_log_error.php'); if ($this->info['hard_delete']) { require_once(DIR . '/vb/search/indexcontroller/queue.php'); vb_Search_Indexcontroller_Queue::indexQueue('vBBlog', 'BlogEntry', 'delete', $blogid); vb_Search_Indexcontroller_Queue::indexQueue('vBBlog', 'BlogComment', 'delete_group', $blogid); /* NOTE: There queries are all used in the post delete function in class_dm_blog_user.php, if you add another please add it there too */ $db->query_write(" DELETE FROM " . TABLE_PREFIX . "blog_categoryuser WHERE blogid = $blogid "); $db->query_write(" DELETE FROM " . TABLE_PREFIX . "blog_deletionlog WHERE primaryid = $blogid AND type = 'blogid' "); $db->query_write(" DELETE FROM " . TABLE_PREFIX . "blog_moderation WHERE primaryid = $blogid AND type = 'blogid' "); $db->query_write(" DELETE FROM " . TABLE_PREFIX . "blog_pinghistory WHERE blogid = $blogid "); $db->query_write(" DELETE FROM " . TABLE_PREFIX . "blog_rate WHERE blogid = $blogid "); $db->query_write(" DELETE FROM " . TABLE_PREFIX . "blog_read WHERE blogid = $blogid "); $db->query_write(" DELETE FROM " . TABLE_PREFIX . "blog_subscribeentry WHERE blogid = $blogid "); $db->query_write(" DELETE FROM " . TABLE_PREFIX . "blog_tachyentry WHERE blogid = $blogid "); // 4.0 doesn't like aliases, 4.1 requires the alias be used :rolleyes:!!! $db->query_write(" DELETE " . TABLE_PREFIX . "blog_text, " . TABLE_PREFIX . "blog_textparsed, " . TABLE_PREFIX . "blog_editlog, " . TABLE_PREFIX . "blog_moderation, " . TABLE_PREFIX . "blog_deletionlog FROM " . TABLE_PREFIX . "blog_text LEFT JOIN " . TABLE_PREFIX . "blog_textparsed ON (" . TABLE_PREFIX . "blog_textparsed.blogtextid = " . TABLE_PREFIX . "blog_text.blogtextid) LEFT JOIN " . TABLE_PREFIX . "blog_editlog ON (" . TABLE_PREFIX . "blog_editlog.blogtextid = " . TABLE_PREFIX . "blog_text.blogtextid) LEFT JOIN " . TABLE_PREFIX . "blog_moderation ON (" . TABLE_PREFIX . "blog_moderation.primaryid = " . TABLE_PREFIX . "blog_text.blogtextid AND " . TABLE_PREFIX . "blog_moderation.type = 'blogtextid') LEFT JOIN " . TABLE_PREFIX . "blog_deletionlog ON (" . TABLE_PREFIX . "blog_deletionlog.primaryid = " . TABLE_PREFIX . "blog_text.blogtextid AND " . TABLE_PREFIX . "blog_deletionlog.type = 'blogtextid') WHERE " . TABLE_PREFIX . "blog_text.blogid = $blogid "); $db->query_write(" DELETE FROM " . TABLE_PREFIX . "blog_trackback WHERE blogid = $blogid "); $db->query_write(" DELETE FROM " . TABLE_PREFIX . "blog_views WHERE blogid = $blogid "); $db->query_write(" DELETE FROM " . TABLE_PREFIX . "blog_hash WHERE blogid = $blogid AND blogtextid = " . intval($this->fetch_field('firstblogtextid')) ); require_once(DIR . '/includes/class_taggablecontent.php'); $content = vB_Taggable_Content_Item::create($vbulletin, "vBBlog_BlogEntry", $blogid); $content->delete_tag_attachments(); require_once(DIR . '/includes/class_bootstrap_framework.php'); require_once(DIR . '/vb/types.php'); vB_Bootstrap_Framework::init(); $contenttypeid = vB_Types::instance()->getContentTypeID('vBBlog_BlogEntry'); $attachdata =& datamanager_init('Attachment', $this->registry, ERRTYPE_SILENT, 'attachment'); $attachdata->condition = "a.contentid = $blogid AND a.contenttypeid = " . intval($contenttypeid); $attachdata->delete(true, false); $db->query_write(" DELETE FROM " . TABLE_PREFIX . "blog WHERE blogid = $blogid "); if (!$this->info['skip_moderator_log']) { blog_moderator_action($this->existing, 'blogentry_removed'); $db->query_write(" UPDATE " . TABLE_PREFIX . "moderatorlog SET threadtitle = '". $db->escape_string($this->existing['title']) ."' WHERE id2 = $blogid "); } } else { $this->set('state', 'deleted'); $this->save(); if (!$this->info['skip_moderator_log']) { blog_moderator_action($this->existing, 'blogentry_softdeleted'); } // soft delete $db->query_write(" REPLACE INTO " . TABLE_PREFIX . "blog_deletionlog (primaryid, type, userid, username, reason, dateline) VALUES ($blogid, 'blogid', " . $this->registry->userinfo['userid'] . ", '" . $db->escape_string($this->registry->userinfo['username']) . "', '" . $db->escape_string($this->info['reason']) . "', " . TIMENOW . ") "); $db->query_write(" DELETE FROM " . TABLE_PREFIX . "blog_moderation WHERE primaryid = $blogid AND type = 'blogid' "); if (!$this->info['keep_attachments']) { require_once(DIR . '/includes/class_bootstrap_framework.php'); require_once(DIR . '/vb/types.php'); vB_Bootstrap_Framework::init(); $contenttypeid = vB_Types::instance()->getContentTypeID('vBBlog_BlogEntry'); $attachdata =& datamanager_init('Attachment', $this->registry, ERRTYPE_SILENT, 'attachment'); $attachdata->condition = "a.contentid = $blogid AND a.contenttypeid = " . intval($contenttypeid); $attachdata->delete(true, false); } } if (!$this->info['skip_build_blog_counters']) { build_blog_user_counters($this->fetch_field('userid')); build_blog_stats(); } ($hook = vBulletinHook::fetch_hook('blog_data_delete')) ? eval($hook) : false; return true; } return false; }
/** * updates a record * * @param int $nodeid * @param array $data -- The data for the node to be updated * @param boolean $convertWysiwygTextToBbcode * * @return boolean */ public function update($nodeid, $data, $convertWysiwygTextToBbcode = true) { // TODO: Permission check // $loginuser = &vB::getCurrentSession()->fetch_userinfo(); // $usercontext = &vB::getUserContext($loginuser['userid']); // if (!$usercontext->hasPermission('forumpermissions', 'canpostvideo')) // { // throw new Exception('no_permission'); // } $currentNode = vB_Library::instance('Node')->getNodeBare($nodeid); if ($currentNode['contenttypeid'] != vB_Types::instance()->getContentTypeID($this->contenttype)) { parent::changeContentType($nodeid, $currentNode['contenttypeid'], $this->contenttype); $data['contenttypeid'] = vB_Types::instance()->getContentTypeID($this->contenttype); } if (isset($data['videoitems'])) { $newvideoitems = $this->checkVideoData($data); unset($data['videoitems']); } $result = parent::update($nodeid, $data, $convertWysiwygTextToBbcode); // do not process videoitems if they are not provided if (!isset($data['videoitems'])) { return $result; } // Get a list of current video items $videoitems = $this->fetchVideoItems($nodeid); $oldvideoitemids = array(); $newvideoitemids = array(); foreach ($videoitems as $item) { $oldvideoitemids[$item['videoitemid']] = $item['videoitemid']; } foreach ($newvideoitems as $item) { $newvideoitemids[$item['videoitemid']] = $item['videoitemid']; $newvideoitemdata[$item['videoitemid']] = $item; } $itemstoremove = array_diff($oldvideoitemids, $newvideoitemids); $itemstoupdate = array_intersect($oldvideoitemids, $newvideoitemids); $itemstoinsert = array_diff($newvideoitemids, $oldvideoitemids); // Save video items foreach ($itemstoinsert as $itemid) { $this->assertor->assertQuery("videoitem", array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_INSERT, 'nodeid' => $nodeid, 'provider' => $newvideoitemdata[$itemid]['provider'], 'code' => $newvideoitemdata[$itemid]['code'], 'url' => $newvideoitemdata[$itemid]['url'])); } foreach ($itemstoupdate as $itemid) { $this->assertor->assertQuery("videoitem", array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_UPDATE, 'nodeid' => $nodeid, 'provider' => $newvideoitemdata[$itemid]['provider'], 'code' => $newvideoitemdata[$itemid]['code'], 'url' => $newvideoitemdata[$itemid]['url'], vB_dB_Query::CONDITIONS_KEY => array('videoitemid' => $itemid))); } foreach ($itemstoremove as $itemid) { $this->assertor->assertQuery("videoitem", array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_DELETE, 'videoitemid' => $itemid)); } // do the indexing after the options are added vB_Api::instance('Search')->index($nodeid); vB_Cache::instance(vB_Cache::CACHE_FAST)->event("nodeChg_{$nodeid}"); vB_Cache::instance()->event("nodeChg_{$nodeid}"); return $result; }
/** * Returns the contenttype id for the content. * * @return int */ public function getContentTypeID() { if (isset($this->contenttypeid)) { return $this->contenttypeid; } return $this->contenttypeid = vB_Types::instance()->getContentTypeID(array('package' => $this->package, 'class' => $this->class)); }