Beispiel #1
0
	/**
	 * Creates a new, empty content item to add to a node.
	 *
	 * @param vBCms_DM_Node $nodedm				- The DM of the node that the content is being created for
	 * @return int | false						- The id of the new content or false if not applicable
	 */
	public function createDefaultContent(vBCms_DM_Node $nodedm)
	{
		global $vbphrase;
		require_once DIR . '/includes/functions_databuild.php';
		fetch_phrase_group('cpcms');

		vB::$vbulletin->input->clean_array_gpc('r', array(
			'nodeid'        => vB_Input::TYPE_UINT,
			'parentnode'    => vB_Input::TYPE_UINT,
			'parentid'      => vB_Input::TYPE_UINT,
			'pagecontent'   => vB_Input::TYPE_STR,
			));

		//We should have a nodeid, but a parentnode is even better.
		($hook = vBulletinHook::fetch_hook($this->content_start_hook)) ? eval($hook) : false;

		if ($this->parent_node)
		{
			$parentnode = $this->parent_node;
		}
		else if (vB::$vbulletin->GPC_exists['parentnode'] AND intval(vB::$vbulletin->GPC['parentnode'] ))
		{
			$parentnode = vB::$vbulletin->GPC['parentnode'];
		}
		else if (vB::$vbulletin->GPC_exists['parentid'] AND intval(vB::$vbulletin->GPC['parentid'] ))
		{
			$parentnode = vB::$vbulletin->GPC['parentid'];
		}
		else if (vB::$vbulletin->GPC_exists['nodeid'] AND intval(vB::$vbulletin->GPC['nodeid'] )
			and $record = vB::$vbulletin->db->query_first("SELECT contenttypeid, nodeid, parentnode FROM " .
			TABLE_PREFIX . "cms_node where nodeid = " . vB::$vbulletin->GPC['nodeid'] ))
		{
			$parentnode = vB_Types::instance()->getContentTypeID("vBCms_Section") == $record['contenttypeid'] ?
				$record['nodeid'] : $record['parentnode'];
		}
		else
		{
			throw (new vB_Exception_Content('No valid parent node'));
		}
		$contenttypeid = vB_Types::instance()->getContentTypeID($this->package . '_'  . $this->class);

		//Verify Permissions
		if (!vBCMS_Permissions::canUseHtml($parentnode, $contenttypeid, vB::$vbulletin->userinfo['userid']))
		{
			throw (new vB_Exception_AccessDenied());
		}

		$this->config = array('pagetext' => $vbphrase['php_goes_here_desc'],
			'previewtext' => $vbphrase['php_preview_goes_here_desc']);
		$nodedm->set('config', $this->config);
		$nodedm->set('contenttypeid', $contenttypeid);
		$nodedm->set('parentnode', $parentnode);
		$nodedm->set('publicpreview', 1);
		$nodedm->set('comments_enabled', 1);
		$title = new vB_Phrase('vbcms', 'new_php_eval_page');
		$nodedm->set('description', $title);
		$nodedm->set('title', $title);

		if (!($contentid = $nodedm->save()))
		{
			throw (new vB_Exception_Content('Failed to create default content for contenttype ' . get_class($this)));
		}
		($hook = vBulletinHook::fetch_hook($this->content_end_hook)) ? eval($hook) : false;

		//at this point we have saved the data. We need to get the content id, which isn't easily available.
		if ($record = vB::$vbulletin->db->query_first("SELECT contentid FROM " . TABLE_PREFIX . "cms_node WHERE nodeid = $contentid"))
		{
			$nodedm->set('contentid', $record['contentid']);
		}

		return $contentid;
	}
Beispiel #2
0
	public function getConfigEditorView()
	{
		require_once DIR . '/includes/functions_databuild.php' ;
		fetch_phrase_group('posting');
		global $show;

		require_once DIR . '/includes/functions_editor.php' ;
		require_once(DIR . '/includes/functions_file.php');

		$config = $this->getConfig();


		$attachmentoption = '';
		$attachcount = 0;
		$posthash = 0;
		$poststarttime = 0;
		$postattach = 0;
		$contenttypeid = 0;
		$attachinfo = fetch_attachmentinfo($posthash, $poststarttime, $contenttypeid);

		$view->editorid = construct_edit_toolbar($pagetext, 0, 'blog_entry',1, 1, true,'fe', '', false);

		$templater = vB_Template::create('vbcms_comments_editor');
		$templater->register('attachmentoption', $attachmentoption);
		$templater->register('checked', $checked);
		$templater->register('disablesmiliesoption', $disablesmiliesoption);
		$templater->register('editorid', $view->editorid);
		$templater->register('messagearea', $messagearea);
		$tag_delimiters = addslashes_js(vB::$vbulletin->options['tagdelimiter']);
		$templater->register('tag_delimiters', $tag_delimiters);
		$content = $templater->render();

		return $GLOBALS['messagearea'];
	}
Beispiel #3
0
	{
		print_cp_redirect("misc.php?" . $vbulletin->session->vars['sessionurl'] . "do=removeorphanposts&pp=" . $vbulletin->GPC['perpage'] . "&startat=$finishat");
		echo "<p><a href=\"misc.php?" . $vbulletin->session->vars['sessionurl'] . "do=removeorphanposts&amp;pp=" . $vbulletin->GPC['perpage'] . "&amp;startat=$finishat\">" . $vbphrase['click_here_to_continue_processing'] . "</a></p>";
	}
	else
	{
		define('CP_REDIRECT', 'misc.php');
		print_stop_message('deleted_orphan_posts_successfully');
	}
}

// ###################### Anonymous Survey Code #######################
if ($_REQUEST['do'] == 'survey')
{
	// first we'd like extra phrase groups from the cphome
	fetch_phrase_group('cphome');

	/*
	All the functions are prefixed with @ to supress errors, this allows us to get feedback from hosts which have almost everything
	useful disabled
	*/

	// What operating system is the webserver running
	$os = @php_uname('s');

	// Using 32bit or 64bit
	$architecture = @php_uname('m');//php_uname('r') . ' ' . php_uname('v') . ' ' . //;

	// Webserver Signature
	$web_server = $_SERVER['SERVER_SOFTWARE'];
Beispiel #4
0
function get_article_comments($article, $associated_thread_id, $userinfo, &$pageno, &$perpage, &$total)
{
    require_once DIR . '/includes/functions_misc.php';
    require_once DIR . '/includes/functions.php';
    require_once DIR . '/includes/functions_databuild.php';
    require_once DIR . '/includes/functions_bigthree.php';
    $posts_out = array();
    fetch_phrase_group('posting');
    $threadinfo = verify_id('thread', $associated_thread_id, 0, 1);
    $foruminfo = verify_id('forum', $threadinfo['forumid'], 0, 1);
    //First let's see if we have forum/thread view permissions. If not,
    // we're done
    if (!($permissions = can_view_thread($article->getNodeId(), $userinfo))) {
        return array();
    }
    $forumperms = fetch_permissions($threadinfo['forumid']);
    //Normally this thread will be wide open, so let's get the list first
    // without checking. We'll verify each post anyway.
    //get our results
    $results = get_comments($permissions, $associated_thread_id);
    $record_count = count($results);
    if (!$results or !count($results)) {
        return array();
    }
    //we accept the parameter "last" for pageno.
    if ($pageno == FR_LAST_POST) {
        $pageno = intval(($record_count + $perpage - 1) / $perpage);
        $first = ($pageno - 1) * $perpage;
    } else {
        $pageno = max(1, intval($pageno));
        $first = $perpage * ($pageno - 1);
    }
    //Let's trim off the results we need.
    //This also tells us if we should show the "next" button.
    $post_array = array_slice($results, $first, $perpage, true);
    if (!$post_array) {
        return array();
    }
    $firstpostid = false;
    $displayed_dateline = 0;
    if (vB::$vbulletin->options['threadmarking'] and vB::$vbulletin->userinfo['userid']) {
        $threadview = max($threadinfo['threadread'], $threadinfo['forumread'], TIMENOW - vB::$vbulletin->options['markinglimit'] * 86400);
    } else {
        $threadview = intval(fetch_bbarray_cookie('thread_lastview', $thread['threadid']));
        if (!$threadview) {
            $threadview = vB::$vbulletin->userinfo['lastvisit'];
        }
    }
    require_once DIR . '/includes/functions_user.php';
    $show['inlinemod'] = false;
    $postids = array();
    $postids = ' post.postid in (' . implode(', ', $post_array) . ')';
    $posts = vB::$vbulletin->db->query_read($sql = "\n\tSELECT\n\tpost.*, post.username AS postusername, post.ipaddress AS ip, IF(post.visible = 2, 1, 0) AS isdeleted,\n\t    user.*, userfield.*, usertextfield.*,\n\t    " . iif($forum['allowicons'], 'icon.title as icontitle, icon.iconpath,') . "\n\t    " . iif(vB::$vbulletin->options['avatarenabled'], 'avatar.avatarpath, NOT ISNULL(customavatar.userid) AS hascustomavatar, customavatar.dateline AS avatardateline,customavatar.width AS avwidth,customavatar.height AS avheight,') . "\n\t    " . ((can_moderate($thread['forumid'], 'canmoderateposts') or can_moderate($thread['forumid'], 'candeleteposts')) ? 'spamlog.postid AS spamlog_postid,' : '') . "\n\t    " . iif($deljoin, 'deletionlog.userid AS del_userid, deletionlog.username AS del_username, deletionlog.reason AS del_reason,') . "\n\t    editlog.userid AS edit_userid, editlog.username AS edit_username, editlog.dateline AS edit_dateline,\n\t    editlog.reason AS edit_reason, editlog.hashistory,\n\t    postparsed.pagetext_html, postparsed.hasimages,\n\t    sigparsed.signatureparsed, sigparsed.hasimages AS sighasimages,\n\t    sigpic.userid AS sigpic, sigpic.dateline AS sigpicdateline, sigpic.width AS sigpicwidth, sigpic.height AS sigpicheight,\n\t    IF(displaygroupid=0, user.usergroupid, displaygroupid) AS displaygroupid, infractiongroupid,\n\t    customprofilepic.userid AS profilepic, customprofilepic.dateline AS profilepicdateline, customprofilepic.width AS ppwidth, customprofilepic.height AS ppheight\n\t    " . iif(!($permissions['genericpermissions'] & vB::$vbulletin->bf_ugp_genericpermissions['canseehiddencustomfields']), vB::$vbulletin->profilefield['hidden']) . "\n\t    {$hook_query_fields}\n\t    FROM " . TABLE_PREFIX . "post AS post\n\t    LEFT JOIN " . TABLE_PREFIX . "user AS user ON(user.userid = post.userid)\n\t    LEFT JOIN " . TABLE_PREFIX . "userfield AS userfield ON(userfield.userid = user.userid)\n\t    LEFT JOIN " . TABLE_PREFIX . "usertextfield AS usertextfield ON(usertextfield.userid = user.userid)\n\t    " . iif($forum['allowicons'], "LEFT JOIN " . TABLE_PREFIX . "icon AS icon ON(icon.iconid = post.iconid)") . "\n\t    " . iif(vB::$vbulletin->options['avatarenabled'], "LEFT JOIN " . TABLE_PREFIX . "avatar AS avatar ON(avatar.avatarid = user.avatarid) LEFT JOIN " . TABLE_PREFIX . "customavatar AS customavatar ON(customavatar.userid = user.userid)") . "\n\t    " . ((can_moderate($thread['forumid'], 'canmoderateposts') or can_moderate($thread['forumid'], 'candeleteposts')) ? "LEFT JOIN " . TABLE_PREFIX . "spamlog AS spamlog ON(spamlog.postid = post.postid)" : '') . "\n\t    {$deljoin}\n\t    LEFT JOIN " . TABLE_PREFIX . "editlog AS editlog ON(editlog.postid = post.postid)\n\t    LEFT JOIN " . TABLE_PREFIX . "postparsed AS postparsed ON(postparsed.postid = post.postid AND postparsed.styleid = " . intval(STYLEID) . " AND postparsed.languageid = " . intval(LANGUAGEID) . ")\n\t    LEFT JOIN " . TABLE_PREFIX . "sigparsed AS sigparsed ON(sigparsed.userid = user.userid AND sigparsed.styleid = " . intval(STYLEID) . " AND sigparsed.languageid = " . intval(LANGUAGEID) . ")\n\t    LEFT JOIN " . TABLE_PREFIX . "sigpic AS sigpic ON(sigpic.userid = post.userid)\n\t    LEFT JOIN " . TABLE_PREFIX . "customprofilepic AS customprofilepic ON (user.userid = customprofilepic.userid)\n\t    {$hook_query_joins}\n\t    WHERE {$postids}\n\t    ORDER BY post.dateline\n\t    ");
    if (!($forumperms & vB::$vbulletin->bf_ugp_forumpermissions['canseethumbnails']) and !($forumperms & vB::$vbulletin->bf_ugp_forumpermissions['cangetattachment'])) {
        vB::$vbulletin->options['attachthumbs'] = 0;
    }
    if (!($forumperms & vB::$vbulletin->bf_ugp_forumpermissions['cangetattachment'])) {
        vB::$vbulletin->options['viewattachedimages'] = 0;
    }
    $postcount = count($postid_array);
    $counter = 0;
    $postbits = '';
    vB::$vbulletin->noheader = true;
    while ($post = vB::$vbulletin->db->fetch_array($posts)) {
        if (!$privileges['can_moderate_forums']) {
            if ($privileges['is_coventry'] or $post['visible'] == 2) {
                continue;
            }
        }
        // post/thread is deleted by moderator and we don't have permission to see it
        if (!($post['visible'] or $privileges['can_moderate_posts'])) {
            continue;
        }
        if (!intval($post['userid'])) {
            $post['avatarid'] = false;
        } else {
            if (!$post['hascustomavatar']) {
                if ($post['profilepic']) {
                    $post['hascustomavatar'] = 1;
                    $post['avatarid'] = true;
                    $post['avatarpath'] = "./image.php?u=" . $post['userid'] . "&amp;dateline=" . $post['profilepicdateline'] . "&amp;type=profile";
                    $post['avwidth'] = $post['ppwidth'];
                    $post['avheight'] = $post['ppheight'];
                } else {
                    $post['hascustomavatar'] = 1;
                    $post['avatarid'] = true;
                    // explicity setting avatarurl to allow guests comments to show unknown avatar
                    $post['avatarurl'] = $post['avatarpath'] = vB_Template_Runtime::fetchStyleVar('imgdir_misc') . '/unknown.gif';
                    $post['avwidth'] = 60;
                    $post['avheight'] = 60;
                }
            }
        }
        if ($tachyuser = in_coventry($post['userid']) and !can_moderate($thread['forumid'])) {
            continue;
        }
        if ($post['visible'] == 1 and !$tachyuser) {
            ++$counter;
            if ($postorder) {
                $post['postcount'] = --$postcount;
            } else {
                $post['postcount'] = ++$postcount;
            }
        }
        if ($tachyuser) {
            $fetchtype = 'post_global_ignore';
        } else {
            if ($ignore["{$post['userid']}"]) {
                $fetchtype = 'post_ignore';
            } else {
                if ($post['visible'] == 2) {
                    $fetchtype = 'post_deleted';
                } else {
                    $fetchtype = 'post';
                }
            }
        }
        if (vB::$vbulletin->GPC['viewfull'] and $post['postid'] == $postinfo['postid'] and $fetchtype != 'post' and (can_moderate($threadinfo['forumid']) or !$post['isdeleted'])) {
            $fetchtype = 'post';
        }
        if (!$firstpostid) {
            $firstpostid = $post['postid'];
        }
        $post['islastshown'] = $post['postid'] == $lastpostid;
        $post['isfirstshown'] = ($counter == 1 and $fetchtype == 'post' and $post['visible'] == 1);
        $post['islastshown'] = $post['postid'] == $lastpostid;
        $post['attachments'] = $postattach["{$post['postid']}"];
        $canedit = false;
        if (!$threadinfo['isdeleted'] and !$post['isdeleted'] and (can_moderate($threadinfo['forumid'], 'caneditposts') or $threadinfo['open'] and $post['userid'] == vB::$vbulletin->userinfo['userid'] and $forumperms & vB::$vbulletin->bf_ugp_forumpermissions['caneditpost'] and ($post['dateline'] >= TIMENOW - vB::$vbulletin->options['edittimelimit'] * 60 or vB::$vbulletin->options['edittimelimit'] == 0))) {
            $canedit = true;
        }
        // Get post date/time
        $postdate = vbdate(vB::$vbulletin->options['dateformat'], $post['dateline'], 1);
        $posttime = vbdate(vB::$vbulletin->options['timeformat'], $post['dateline']);
        $attachments = array();
        $fr_images = array();
        // Attachments (images).
        if (count($post['attachments']) > 0) {
            foreach ($post['attachments'] as $attachment) {
                $lfilename = strtolower($attachment['filename']);
                if (strpos($lfilename, '.jpe') !== false || strpos($lfilename, '.png') !== false || strpos($lfilename, '.gif') !== false || strpos($lfilename, '.jpg') !== false || strpos($lfilename, '.jpeg') !== false) {
                    $fr_images[] = array('img' => vB::$vbulletin->options['bburl'] . '/attachment.php?attachmentid=' . $attachment['attachmentid'], 'tmb' => vB::$vbulletin->options['bburl'] . '/attachment.php?attachmentid=' . $attachment['attachmentid'] . '&stc=1&thumb=1');
                }
            }
        }
        // Parse the post for quotes and inline images
        list($text, $nuked_quotes, $images) = parse_post($post['pagetext'], false);
        if (count($fr_images) > 0) {
            $text .= "<br/>";
            foreach ($fr_images as $attachment) {
                $text .= "<img src=\"{$attachment['img']}\"/>";
            }
        }
        foreach ($images as $image) {
            $fr_images[] = array('img' => $image);
        }
        $avatarurl = '';
        // Avatar work
        if (vB::$vbulletin->options['avatarenabled']) {
            require_once DIR . '/includes/functions_user.php';
            $userinfo = fetch_userinfo($post['userid'], FETCH_USERINFO_AVATAR);
            fetch_avatar_from_userinfo($userinfo);
            if ($userinfo['avatarurl']) {
                $avatarurl = process_avatarurl($userinfo['avatarurl']);
            }
        }
        $tmp = array('post_id' => $post['postid'], 'thread_id' => $post['threadid'], 'forum_id' => $foruminfo['forumid'], 'username' => prepare_utf8_string(strip_tags($post['username'])), 'joindate' => prepare_utf8_string($post['joindate']), 'usertitle' => prepare_utf8_string(strip_tags($post['usertitle'])), 'numposts' => $post['posts'], 'userid' => $post['userid'], 'title' => prepare_utf8_string($post['title']), 'post_timestamp' => prepare_utf8_string(date_trunc($postdate) . ' ' . $posttime), 'fr_images' => $fr_images, 'image_thumbs' => array());
        // Soft Deleted
        if ($post['visible'] == 2) {
            $tmp['deleted'] = true;
            $tmp['del_username'] = prepare_utf8_string($post['del_username']);
            if ($post['del_reason']) {
                $tmp['del_reason'] = prepare_utf8_string($post['del_reason']);
            }
        } else {
            $tmp['text'] = $text;
            $tmp['quotable'] = $nuked_quotes;
            if ($canedit) {
                $tmp['canedit'] = true;
                $tmp['edittext'] = prepare_utf8_string($post['pagetext']);
            }
        }
        if ($avatarurl != '') {
            $tmp['avatarurl'] = $avatarurl;
        }
        $posts_out[] = $tmp;
    }
    if ($LASTPOST['dateline'] > $displayed_dateline) {
        $displayed_dateline = $LASTPOST['dateline'];
        if ($displayed_dateline <= $threadview) {
            $updatethreadcookie = true;
        }
    }
    // Set thread last view
    if ($displayed_dateline and $displayed_dateline > $threadview) {
        mark_thread_read($threadinfo, $foruminfo, vB::$vbulletin->userinfo['userid'], $displayed_dateline);
    }
    vB::$vbulletin->db->free_result($posts);
    unset($post);
    $total = $record_count;
    return $posts_out;
}
Beispiel #5
0
	/**
	 * Returns the config view for the widget.
	 *
	 * @return vBCms_View_Widget				- The view result
	 */
	public function getConfigView()
	{
		$this->assertWidget();

		global $vbphrase;
		require_once DIR . '/includes/functions_databuild.php';
		fetch_phrase_group('vbcms');

		vB::$vbulletin->input->clean_array_gpc('r', array(
			'do'      => vB_Input::TYPE_STR,
			'days'    => vB_Input::TYPE_UINT,
			'item_id'    => vB_Input::TYPE_UINT,
			'count'    => vB_Input::TYPE_UINT,
			'rb_type'  => vB_Input::TYPE_UINT,
			'template_name'  => vB_Input::TYPE_STR,
			'contenttypeid'   => vB_Input::TYPE_ARRAY
		));

		$view = new vB_View_AJAXHTML('cms_widget_config');
		$view->title = new vB_Phrase('vbcms', 'configuring_widget_x', $this->widget->getTitle());

		$config = $this->widget->getConfig();

		if ((vB::$vbulletin->GPC['do'] == 'config') AND $this->verifyPostId())
		{
			if (vB::$vbulletin->GPC_exists['days'])
			{
				$config['days'] = vB::$vbulletin->GPC['days'];
			}

			if (vB::$vbulletin->GPC_exists['count'])
			{
				$config['count'] =  vB::$vbulletin->GPC['count'];
			}

			if (vB::$vbulletin->GPC_exists['template_name'])
			{
				$config['template_name'] =  vB::$vbulletin->GPC['template_name'];
			}

			if ( vB::$vbulletin->GPC_exists['rb_type'] AND intval(vB::$vbulletin->GPC['rb_type']))
			{
				$config['contenttypeid'] = vB::$vbulletin->GPC['rb_type'];
				vB::$vbulletin->input->clean_array_gpc('p', array(
					'template_' .  vB::$vbulletin->GPC['rb_type'] => vB_Input::TYPE_STR));

				$config['template'] =
				(vB::$vbulletin->GPC_exists['template_' . vB::$vbulletin->GPC['rb_type']] ?
				vB::$vbulletin->GPC['template_' . vB::$vbulletin->GPC['rb_type']] :
				'vbcms_searchresult_' . vB_Types::instance()->getPackageClass(vB::$vbulletin->GPC['rb_type']) );
			}
			else
			{
				$config['contenttypeid'] = vB_Types::instance()->getContentTypeID('vBForum_Post');
				$config[ 'template'] =	'vbcms_searchresult_post';
			}

			$widgetdm = $this->widget->getDM();
			$widgetdm->set('config', $config);

			if ($this->content)
			{
				$widgetdm->setConfigNode($this->content->getNodeId());
			}

			$widgetdm->save();

			//clear the cache
			vB_Cache::instance()->event('widget_config_' . $this->widget->getId());
			vB_Cache::instance()->cleanNow();

			if (!$widgetdm->hasErrors())
			{
				if ($this->content)
				{
					$segments = array('node' => $this->content->getNodeURLSegment(),
										'action' => vB_Router::getUserAction('vBCms_Controller_Content', 'EditPage'));
					$view->setUrl(vB_View_AJAXHTML::URL_FINISHED, vBCms_Route_Content::getURL($segments));
				}

				$view->setStatus(vB_View_AJAXHTML::STATUS_FINISHED, new vB_Phrase('vbcms', 'configuration_saved'));
			}
			else
			{
				if (vB::$vbulletin->debug)
				{
					$view->addErrors($widgetdm->getErrors());
				}

				// only send a message
				$view->setStatus(vB_View_AJAXHTML::STATUS_MESSAGE, new vB_Phrase('vbcms', 'configuration_failed'));
			}
		}
		else
		{
			// add the config content

			$configview = $this->createView('config');
			$contenttypes = array() ;
			require_once DIR . '/includes/functions_databuild.php';
			fetch_phrase_group('search');

			foreach (vB_Search_Core::get_instance()->get_indexed_types() as $type)
			{
				$contenttypes[$type['contenttypeid']] = array('name' => $type['class'],
					'contenttypeid' => $type['contenttypeid'],
					'template' => ((intval($type['contenttypeid']) == intval($config['contenttypeid'])) and
								isset($config['template'])) ?
							$config['template'] : 'vbcms_searchresult_' . strtolower($type['class']),
					'checked' => intval($type['contenttypeid']) == intval($config['contenttypeid']) ? 'checked="checked"' : '')  ;
			}

			$configview->contenttypes = $contenttypes;
			$show_checked = array();

			// Contenttype select
			$select_types = '';
			foreach (vB_Search_Core::get_instance()->get_indexed_types() as $type)
			{
				$contenttypes[$type['contenttypeid']] = array('name' => $type['class'],
					'contenttypeid' => $type['contenttypeid'],
					'template' => ((intval($type['contenttypeid']) == intval($config['contenttypeid'])) and
								isset($config['template'])) ?
							$config['template'] : 'vbcms_searchresult_' . strtolower($type['class']),
					'checked' => intval($type['contenttypeid']) == intval($config['contenttypeid']) ? 'checked="checked"' : '')  ;
			}
			$configview->contenttypes = $contenttypes;

			$configview->count = $config['count'];
			$configview->days = $config['days'];
			$configview->template_name = ($config['template_name'] ? $config['template_name'] : 'vbcms_widget_searchwidget_page');

			// add id to form
			$this->addPostId($configview);

			$view->setContent($configview);
			// send the view
			$view->setStatus(vB_View_AJAXHTML::STATUS_VIEW, new vB_Phrase('vbcms', 'configuring_widget'));
		}

		return $view;
	}
Beispiel #6
0
	public function getInlineEditBodyView()
	{
		global $vbphrase;
		require_once DIR . '/includes/functions_databuild.php';
		require_once DIR . '/includes/functions.php';
		fetch_phrase_group('cpcms');


		$this->editing = true;

		//confirm that the user has edit rights
		if (!$this->content->canEdit() AND !($this->getUserId() == vB::$vbulletin->userinfo['userid'])
			AND !$this->content->canPublish())
		{
			return $vb_phrase['no_edit_permissions'];
		}


		vB::$vbulletin->input->clean_array_gpc('r', array(
			'postid' => vB_Input::TYPE_UINT,
			'blogcommentid' => vB_Input::TYPE_UINT,
			'do' => vB_Input::TYPE_STR,
			'blogid' => TYPE_UINT
		));

		if ($_REQUEST['do'] == 'delete')
		{
			$dm = $this->content->getDM();
			$dm->delete();
			$this->cleanContentCache();
			return $vbphrase['article_deleted'];
		}

		if ($_REQUEST['do'] == 'apply' OR $_REQUEST['do'] == 'update')
		{
			$this->SaveData($view);
		}



		require_once DIR . '/packages/vbcms/contentmanager.php';
		// Load the content item
		if (!$this->loadContent($this->getViewInfoFlags(self::VIEW_PAGE)))
		{
			throw (new vB_Exception_404());
		}

		global $show;

		$show['img_bbcode'] = true;
		// Get smiliecache and bbcodecache
		vB::$vbulletin->datastore->fetch(array('smiliecache','bbcodecache'));

		// Create view
		$view = $this->createView('inline', self::VIEW_PAGE);

		// Add the content to the view
		$view = $this->populateViewContent($view, self::VIEW_PAGE, false);
		$pagetext = $this->content->getPageText();
		// Get postings phrasegroup
		// need posting group
		require_once DIR . '/includes/functions_databuild.php';
		fetch_phrase_group('posting');

		// Build editor
		global $messagearea;
		require_once DIR . '/includes/functions_file.php';
		require_once DIR . '/includes/functions_editor.php';
		require_once(DIR . '/packages/vbattach/attach.php');

		$view->formid = "cms_content_data";
		$view->can_edit = $this->content->canEdit();

		if ($this->content->canEdit())
		{
			$attach = new vB_Attach_Display_Content(vB::$vbulletin, 'vBCms_Article');
			//this will set a number of its parameters if they are not already set.
			$posthash = null;
			$poststarttime = null;
			$postattach = array();
			$attachcount = 0;

			$values = "values[f]=" . $this->content->getNodeId() ;

			$attachmentoption = $attach->fetch_edit_attachments($posthash, $poststarttime, $postattach, $this->content->getNodeId(), $values, '', $attachcount);

			$attachinfo = fetch_attachmentinfo($posthash, $poststarttime, $this->getContentTypeId(), array('f' => $this->content->getNodeId()));

			$view->editorid = construct_edit_toolbar(
				$pagetext,
				false,
				new vBCms_Editor_Override(vB::$vbulletin),
				true,
				true,
				true,
				'cms_article',
				'',
				$attachinfo
			);


			$templater = vB_Template::create('vbcms_article_editor');
			$templater->register('attachmentoption', $attachmentoption);
			$templater->register('attachmentoption', $attachmentoption);
			$templater->register('posthash', $posthash);
			$templater->register('poststarttime', $poststarttime);
			$templater->register('contenttypeid', $this->getContentTypeId());
			$templater->register('values', $values);
			$templater->register('contentid', $this->content->getNodeId());
			$templater->register('insertinline ', 1);
			$templater->register('checked', $checked);
			$templater->register('disablesmiliesoption', $disablesmiliesoption);
			$templater->register('editorid', $view->editorid);
			$templater->register('messagearea', $messagearea);
			$tag_delimiters = addslashes_js(vB::$vbulletin->options['tagdelimiter']);
			$templater->register('tag_delimiters', $tag_delimiters);
			$content = $templater->render();
			$view->editor = $content;
		}
		else
		{
			$view->previewtext = $this->content->getPreviewText();;
		}

		$view->url = $this->content->getUrl();
		$view->type = new vB_Phrase('vbcms', 'content');
		$view->adding = 	new vB_Phrase('cpcms', 'adding_x', $vbphrase['article']);
		$view->html_title = $this->content->getHtmlTitle();
		$view->title = $this->content->getTitle();
		$view->metadata = $this->content->getMetadataEditor();
		$segments = array('node' => $this->content->getUrlSegment(),
							'action' => vB_Router::getUserAction('vBCms_Controller_Content', 'View'));
		$view->view_url = vBCms_Route_Content::getURL($segments);
		// Add URL to submit to
		$segments = array('node' => $this->content->getUrlSegment(),
							'action' => vB_Router::getUserAction('vBCms_Controller_Content', 'EditPage'));
		$view->submit_url = vBCms_Route_Content::getURL($segments);
		$segments = array('node' => $this->content->getUrlSegment(),
							'action' => vB_Router::getUserAction('vBCms_Controller_Content', 'View'));
		$view->editbar = $this->content->getEditBar($view->submit_url, vBCms_Route_Content::getURL($segments), $view->formid);

		$view->publisher = $this->content->getPublishEditor($view->submit_url, $view->formid,
			true, true, $this->content->getPublicPreview(), $this->content->getComments_Enabled());
		$view->authorid = ($this->content->getUserId());
		$view->authorname = ($this->content->getUsername());
		$view->viewcount = ($this->content->getViewCount());
		$view->parentid = $this->content->getParentId();
		$view->post_started = ($this->content->getPostStarted());
		$view->post_posted = ($this->content->getPostPosted());

		$view->comment_count = ($this->content->getReplyCount());
		$view->contentid = $this->content->getContentId(true);

		$view->show_threaded = true;
		$view->per_page = 10;
		$view->indent_per_level = 5;
		$view->max_level = 4;
		// Add form check
		$this->addPostId($view);
		return $view;
	}
Beispiel #7
0
function getNodePanel($divId)
{
    global $vbulletin;
    global $vbphrase;
    global $phrasegroups;
    global $sect_js_varname;
    fetch_phrase_group('cpcms');
    $result = "\n<div id=\"{$divId}\" style=\"position: absolute;\n\tdisplay: none;\twidth:600px;height:380px;background-color:white; text-align:" . vB_Template_Runtime::fetchStyleVar('left') . ";\n\toverflow: auto;" . vB_Template_Runtime::fetchStyleVar('left') . ":100px;top:100px; border:1px solid #000;clear:both;padding:0px 0px 0px 0px;\">\n\t<div class=\"tcat\" style=\"border:0;height:12px;top:0px;" . vB_Template_Runtime::fetchStyleVar('left') . ":0px;width:580px;position:relative;\" >\n\t\t<span style=\"" . vB_Template_Runtime::fetchStyleVar('left') . ":0px;top:0px;position:relative;text-align:" . vB_Template_Runtime::fetchStyleVar('left') . ";font-size:120%;width:50%;float:" . vB_Template_Runtime::fetchStyleVar('left') . ";\"><strong>" . $vbphrase['section_navigator'] . "</strong>\n\t\t</span>\n\t\t<div style=\"" . vB_Template_Runtime::fetchStyleVar('left') . ":400px;border:0;top:-20px;text-align:" . vB_Template_Runtime::fetchStyleVar('right') . ";padding:0px 10px 0px 0px;\">\n\t\t\t<input type=\"button\" id=\"button_selectsection_close\" value=\"" . $vbphrase['close'] . "\"\n\t\t\tonclick=\"document.getElementById('{$divId}').style.display='none'\" />\n\t\t</div>\n\t</div>\n\t<div class=\"picker_overlay\" style=\"border:0;height:343px;width:100%;top:0px;padding:0;\n\t\toverflow:auto;position:relative;display:block;\">\n\t\t<div class=\"tcat\" style=\"border:0;position:relative;" . vB_Template_Runtime::fetchStyleVar('left') . ":0px;width:561px;padding:0;\n\t\t\tfont-size:14px;font-weight:bold;padding:2px;color:black;float:" . vB_Template_Runtime::fetchStyleVar('left') . ";padding:10px;\n\t\t\tborder-style:solid;border-width:1px 1px 0 1px;border-color:#000000;\">" . $vbphrase['choose_a_section'] . "\n\t\t</div>\n\t\t<div style=\"border:0;padding-" . vB_Template_Runtime::fetchStyleVar('left') . ":5px\">\n\t";
    $result .= getSectionList();
    $result .= "\n\t</div>\n\t</div>\n</div>\n";
    return $result;
}
Beispiel #8
0
	public static function getCalendar($year, $month)
	{
		require_once DIR . '/includes/functions_databuild.php';
		fetch_phrase_group('vbcms');
		global $vbphrase;
		// Create view
		$view = new vB_View('vbcms_widget_calendar_table');

		if (!$year OR !$month)
		{
			$today = getdate(TIMENOW);
			$year = $today['year'];
			$month = $today['mon'];
		}

		//Let's get the text representation of the month.
		$view->textmonth =  $vbphrase[strtolower(date('F', gmmktime(1, 1, 1, $month, 15, $year)))];
		$view->weeks = self::getPublished($year, $month);
		$view->year = $year;
		$view->month = $month;
		$prevyear = ($month == 1 ? $year - 1 : $year);
		$prevmonth = ($month == 1 ? 12 : $month - 1);
		$nextyear = ($month == 12 ? $year + 1 : $year);
		$nextmonth = ($month == 12 ? 1 : $month + 1);

		//Get the links to next and previous months
		$view->prev_month_link = vB::$vbulletin->options['bburl'] . "/ajax.php?do=calwidget&amp;month=$prevmonth&amp;year=$prevyear" ;
		$view->next_month_link = vB::$vbulletin->options['bburl'] . "/ajax.php?do=calwidget&amp;month=$nextmonth&amp;year=$nextyear";


		return $view;
	}
Beispiel #9
0
	/**
	 * Returns the config view for the widget.
	 *
	 * @return vBCms_View_Widget				- The view result
	 */
	public function getConfigView($widget = false)
	{
		global $vbphrase;
		$this->assertWidget();
		require_once DIR . '/includes/functions_databuild.php';
		fetch_phrase_group('cpcms');

		vB::$vbulletin->input->clean_array_gpc('r', array(
			'do'      => vB_Input::TYPE_STR,
			'template_name'    => vB_Input::TYPE_STR,
			'menu_type'    => vB_Input::TYPE_INT,
			'show_all_tree_elements_threshold' => vB_Input::TYPE_INT
		));

		$view = new vB_View_AJAXHTML('cms_widget_config');
		$view->title = new vB_Phrase('vbcms', 'configuring_widget_x', $this->widget->getTitle());
		$config = $this->widget->getConfig();
		$widgetdm = $this->widget->getDM();

		if ((vB::$vbulletin->GPC['do'] == 'config') AND $this->verifyPostId())
		{
			if (vB::$vbulletin->GPC_exists['template_name'])
			{
				$config['template_name'] = vB::$vbulletin->GPC['template_name'];
			}

			if (vB::$vbulletin->GPC_exists['menu_type'])
			{
				$config['menu_type'] = (vB::$vbulletin->GPC['menu_type'] == 2 ? 2 : 1);
			}

			if (vB::$vbulletin->GPC_exists['show_all_tree_elements_threshold'])
			{
				$config['show_all_tree_elements_threshold'] = vB::$vbulletin->GPC['show_all_tree_elements_threshold'];
			}

			if ($this->content)
			{
				$widgetdm->setConfigNode($this->content->getNodeId());
			}

			$widgetdm->set('config', $config);
			$widgetdm->save();

			if (!$widgetdm->hasErrors())
			{
				if ($this->content)
				{
					$segments = array('node' => $this->content->getNodeURLSegment(),
										'action' => vB_Router::getUserAction('vBCms_Controller_Content', 'EditPage'));
					$view->setUrl(vB_View_AJAXHTML::URL_FINISHED, vBCms_Route_Content::getURL($segments));
				}

				$view->setStatus(vB_View_AJAXHTML::STATUS_FINISHED, new vB_Phrase('vbcms', 'configuration_saved'));
			}
			else
			{
				if (vB::$vbulletin->debug)
				{
					$view->addErrors($widgetdm->getErrors());
				}

				// only send a message
				$view->setStatus(vB_View_AJAXHTML::STATUS_MESSAGE, new vB_Phrase('vbcms', 'configuration_failed'));
			}
		}
		if (!isset($config['template_name']) OR ($config['template_name'] == '') )
		{
			$config['template_name'] = 'vbcms_widget_sectionnavext_page';
		}
		// add the config content
		$configview = $this->createView('config');

		$configview->template_name = $config['template_name'];
		$configview->one_selected = (intval($config['menu_type']) != 2 ? 'selected="selected"' : '');
		$configview->two_selected = (intval($config['menu_type']) == 2 ? 'selected="selected"' : '');
		$configview->show_all_tree_elements_threshold = $config['show_all_tree_elements_threshold'];


		// item id to ensure form is submitted to us
		$this->addPostId($configview);

		$view->setContent($configview);

		// send the view
		$view->setStatus(vB_View_AJAXHTML::STATUS_VIEW, new vB_Phrase('vbcms', 'configuring_widget'));

		return $view;	}
Beispiel #10
0
	public static function listSections($page, $per_page = 10)
	{
		global $vbphrase;
		global $vbulletin;
		require_once DIR . '/includes/functions_databuild.php';
		fetch_phrase_group('cpcms');

		$sectionid = ( ($vbulletin->GPC_exists['sectionid'] AND intval($vbulletin->GPC['sectionid']))?
			$vbulletin->GPC['sectionid'] : false);

		$sections = self::getSection($sectionid);

		if ($record_count = count($sections))
		{
			$sections = array_slice($sections, ($page-1) * $per_page, $per_page, true);
			$parent = $vbulletin->db->query_first($sql = "SELECT info.title FROM " .
				TABLE_PREFIX . "cms_node AS node INNER JOIN " . TABLE_PREFIX .
				"cms_nodeinfo AS info ON info.nodeid = node.nodeid
				WHERE " .
				( $sectionid ?
					" node.nodeid = " . $sectionid : " node.nodeid IS NULL" ));
			$i = 1;

			$result = print_form_header('cms_content_admin', '', false, true, 'cms_data', '100%', '_self',
					true, 'post', 0, false);
			$result .= "<input type=\"hidden\" id=\"sectionid\" value=\"" .
				( $sectionid ? $sectionid :'') .	"\" name=\"sectionid\"/>
			<input type=\"hidden\" name=\"sentfrom\" id=\"section\" value=\"section\"/>
			<input type=\"hidden\" name=\"id\" id=\"id\" value=\"0\"/>";

			$result .= self::getSectionHeaders($sectionid) . "<br />\n";
			$result .= "<tr class=\"tcat\">
					<td class=\"feature_management_header\" style=\"padding:5px;float:" . vB_Template_Runtime::fetchStyleVar('left') . ";\"><div style=\"float:" . vB_Template_Runtime::fetchStyleVar('left') . "\">
					" . $vbphrase['you_are_managing'] . " " . $vbphrase['section'] . ": <span class=\"section_name\">" . $parent['title'] .
					($vbulletin->GPC_exists['sectionid'] ? '' : '(' . $vbphrase['all_sections'] .')') . "</span>
					<input type=\"button\" onclick=\"showNodeWindow('filter_section')\" value=\"" . $vbphrase['navigate_to_section'] ."\">
					"
					.  "
					</div>
					</td>
					</tr>";
			$result.= "<tr><td>\n";
			$result .= "<div style=\"overflow:auto;margin: auto;\">
			<table class=\"tborder\" cellpadding=\"4\" border=\"0\" width=\"100%\" align=\"center\">\n";
			$bgclass = fetch_row_bgclass();
			$result .= "<tr align=\"center\" class=\"thead\">\n";
			$result .= "<td class=\"thead\" width=\"20\">#</td>
				<td class=\"thead\" align=\"" . vB_Template_Runtime::fetchStyleVar('left') . "\" width=\"400\"><a href=\"cms_content_admin.php?do=sort&sentfrom=section&sortby=config4.value\" target=\"_self\">" . $vbphrase['title'] . "</a></td>
				<td class=\"thead\"><a href=\"cms_content_admin.php?do=sort&sentfrom=section&sortby=setpublish\">" . $vbphrase['published'] . "</a></td>
				<td class=\"thead\">" . $vbphrase['content_layout'] . "</td>
				<td class=\"thead\"><a href=\"cms_content_admin.php?do=sort&sentfrom=section&sortby=auto_displayorder\" target=\"_self\">" . $vbphrase['display_order'] . "</a></td>
				<td class=\"thead\" width=\"50\">" . $vbphrase['records_per_page'] . "</td>
				<td class=\"thead\">" . $vbphrase['subsections'] . "</td>
				<td class=\"thead\">" . $vbphrase['content'] . "</td>
				<td class=\"thead\">" . $vbphrase['viewcount'] . "</td>".
/*				<td class=\"thead\">" . $vbphrase['layout'] . "</td>
				<td class=\"thead\">" . $vbphrase['style'] . "</td> */
			" </tr>";
			$sequence = 0;

			foreach($sections as $key => $section)
			{
				$sequence++;
				$first_selected_parent_row_class = "";
				$change_display_order_buttons = "";
				$section_name_prefix = ((vB_Template_Runtime::fetchStyleVar('textdirection') == 'ltr') ?
						'&gt;' : '&gt;');

				if ($sequence == 1 AND $page == 1)
				{
					$first_selected_parent_row_class = " class=\"selected_parent_row\"";
					$section_name_prefix = "";
				}

				// for sub-sections, display up or down arrows to change the display order
				else
				{
					$change_display_order_buttons = "<div style=\"float:" . vB_Template_Runtime::fetchStyleVar('left') . "; width:32px;\">";
					// dont display up arrow if its already first section in list
					if ($sequence > 2 AND isset($sections[$key-1]))
					{
						$change_display_order_buttons .= "<a style=\"float:" . vB_Template_Runtime::fetchStyleVar('left') . ";\" href=\"javascript:swapSections(".$section['nodeid'].", ".$sections[$key-1]['nodeid'].")\"><img src=\"" . self::getImagePath('imgdir_cms') . "/arrow_up.png\" style=\"border-style:none\" /></a>";
					}
					// dont display down arrow is its already last section in list
					if ($sequence < count($sections) AND isset($sections[$key+1]))
					{
						$change_display_order_buttons .= "<a style=\"float:right;\" href=\"javascript:swapSections(".$section['nodeid'].", ".$sections[$key+1]['nodeid'].")\"><img src=\"" . self::getImagePath('imgdir_cms') . "/arrow_down.png\" style=\"border-style:none\" /></a>";
					}
					$change_display_order_buttons .= "</div>";
				}

				$bgclass = fetch_row_bgclass();
				$result .= "<tr" . $first_selected_parent_row_class . " align=\"center\">\n <input type=\"hidden\" name=\"ids[]\" value=\"" .
					$section['nodeid'] . "\" />\n";
				$result .= "  <td class=\"$bgclass\" style=\"font-size:80%;\">$sequence</td>\n";
				$result .= "  <td align=\"" . vB_Template_Runtime::fetchStyleVar('left') . "\" class=\"$bgclass\" style=\"font-size:80%;width:400px;\"><div class=\"sectionTitleWrapper\" style=\"width:400px;\">
					" . $change_display_order_buttons . $section_name_prefix . "<a href=\"./cms_content_admin.php?do=filter&sectionid=" . $section['nodeid'] . "&contenttypeid=" .
					vb_Types::instance()->getContentTypeID("vBCms_Section") .
						"\" target=\"_self\" >" . htmlspecialchars_uni($section['title']) . "</a>
						<div style=\"float:" . vB_Template_Runtime::fetchStyleVar('right') . "\">
						<a href=\"javascript:showSectionEdit('new_section'," . (intval($section['parentnode']) ? $section['parentnode'] : '0') .
						 ", " . $section['nodeid'] . ",'')\"><img src=\"" . self::getImagePath('imgdir_cms') . "/add_small.png\" style=\"border-style:none\"></a>
						<a href=\"javascript:showSectionEdit('save_section',". (intval($section['parentnode']) ? $section['parentnode'] : '0') . ', ' .
						 $section['nodeid'] . ", '"
					.  vB_Template_Runtime::escapeJS(htmlspecialchars_uni($section['title'])) . "')\")\"><img src=\"" . self::getImagePath('imgdir_cms') . "/edit_small.png\" style=\"border-style:none\"></a>"
				. ((intval($section['nodeid']) != 1 AND intval($section['section_count']) == 0 AND intval($section['item_count']) == 0) ?
					"<a href=\"javascript:confirmSectionDelete(" . $section['nodeid'] . ', \'' . vB_Template_Runtime::escapeJS($vbphrase['confirm_deletion']). "');\">
					<img src=\"" . self::getImagePath('imgdir_cms') . "/delete_small.png\" style=\"border-style:none\"></a>" : '')
				. "
				</div>
				</div></td>\n";
				$result .= "  <td class=\"$bgclass\" style=\"font-size:80%;\"><select name=\"state_" .
					$section['nodeid']. "\" id=\"state_" . $section['nodeid']. "\"
					onchange=\"setFormValue('do', 'saveonesectionstate');
					setFormValue('nodeid', " . $section['nodeid']. ");document.getElementById('cms_data').submit();\">" . self::getPublishedSelect(
						intval($section['setpublish']), $section['publishdate']) . "</select></td>\n";
				$result .= "  <td class=\"$bgclass\" style=\"font-size:80%;\"><select id=\"cl_" . $section['nodeid'] . "\" name=\"cl_" . $section['nodeid'] .
				"\" onchange=\"setFormValue('do','saveonecl');	setFormValue('nodeid'," . $section['nodeid'] . ");
					document.getElementById('cms_data').submit();\">" . self::getContentLayoutSelect($section['content_layoutid']) ;
				$result .= "  <td class=\"$bgclass\" style=\"font-size:80%;\"><select name=\"sect_pr_" . $section['nodeid'] .
					 "\" onchange=\"setFormValue('nodeid', " . $section['nodeid']. ");
					setFormValue('do', 'sectionpriority');document.getElementById('cms_data').submit();\">\n" .
					self::getSectionPrioritySelect($section['priority'], $section['nodeid']) . "</select></td>\n";
				$result .= "  <td class=\"$bgclass\" style=\"font-size:80%;\">" . self::getSectionPPEdit($section['per_page'], $section['nodeid']) . "</td>\n";
				$result .= "  <td class=\"$bgclass\" style=\"font-size:80%;\">" . $section['section_count'] . "</td>\n";
				$result .= "  <td class=\"$bgclass\" style=\"font-size:80%;\">" . $section['item_count'] . "</td>\n";
				$result .= "  <td class=\"$bgclass\" style=\"font-size:80%;\">" . $section['viewcount'] . "</td>\n";
				$result .= "</tr>\n";
			}

			print_hidden_fields();
			$result .= "</table>";
			$result .= "</div></td></tr>";
			$result .= "</table>\n";
			$result .= self::getNav($per_page, $record_count, $page, 'section', 100, 'page', true,
				('cms_content_admin.php' . ($sectionid ? "?sectionid=$sectionid" : '')));
			global $echoform;
			$echoform = false;
			$result .= "</form>";
			$result .= self::getSectionEditPanel();
			return $result;
		}
	}
Beispiel #11
0
	/**
	 * Returns the config view for the widget.
	 *
	 * @return vBCms_View_Widget				- The view result
	 */
	public function getConfigView()
	{
		global $vbphrase;
		$this->assertWidget();
		require_once DIR . '/includes/functions_databuild.php';
		fetch_phrase_group('contenttypes');

		vB::$vbulletin->input->clean_array_gpc('r', array(
			'do'      => vB_Input::TYPE_STR,
			'days' => vB_Input::TYPE_UINT,
			'count' => vB_Input::TYPE_UINT,
			'rb_type' => vB_Input::TYPE_UINT,
			'username' => vB_Input::TYPE_STR,
			'friends' => vB_Input::TYPE_BOOL,
			'childforums' => vB_Input::TYPE_BOOL,
			'keywords' => vB_Input::TYPE_STR,
			'template_name'  => vB_Input::TYPE_STR,
			'contenttypeid'   => vB_Input::TYPE_UINT,
			'group_text' =>  vB_Input::TYPE_STR,
			'forumchoice' =>  vB_Input::TYPE_ARRAY,
			'cat' =>  vB_Input::TYPE_ARRAY,
			'prefixchoice' =>  vB_Input::TYPE_ARRAY,
			'srch_tag_text' => vB_Input::TYPE_STR
			));

		$view = new vB_View_AJAXHTML('cms_widget_config');
		$view->title = new vB_Phrase('vbcms', 'configuring_widget_x', $this->widget->getTitle());

		$config = $this->widget->getConfig();

		if ((vB::$vbulletin->GPC['do'] == 'config') AND $this->verifyPostId())
		{
			if (vB::$vbulletin->GPC_exists['days'])
			{
				$config['days'] = vB::$vbulletin->GPC['days'];
			}

			if (vB::$vbulletin->GPC_exists['template_name'])
			{
				$config['template_name'] = vB::$vbulletin->GPC['template_name'];
			}

			if (vB::$vbulletin->GPC_exists['count'])
			{
				$config['count'] =  vB::$vbulletin->GPC['count'];
			}

			$config['username'] = vB::$vbulletin->GPC_exists['username']?
				convert_urlencoded_unicode(vB::$vbulletin->GPC['username']) : null;

			$config['friends'] =  vB::$vbulletin->GPC_exists['friends'];
			$config['childforums'] =  vB::$vbulletin->GPC_exists['childforums'];


			$config['keywords'] =  convert_urlencoded_unicode(vB::$vbulletin->GPC['keywords']);

			//the contenttype array gets special handling.
			$type_info = array() ;

			if ( vB::$vbulletin->GPC_exists['rb_type'] AND intval(vB::$vbulletin->GPC['rb_type']))
			{
				$config['contenttypeid'] = vB::$vbulletin->GPC['rb_type'];
				vB::$vbulletin->input->clean_array_gpc('p', array(
					'template_' .  vB::$vbulletin->GPC['rb_type'] => vB_Input::TYPE_STR));

				$config['template'] =
				(vB::$vbulletin->GPC_exists['template_' . vB::$vbulletin->GPC['rb_type']] ?
				vB::$vbulletin->GPC['template_' . vB::$vbulletin->GPC['rb_type']] :
				'vbcms_searchresult_' . vB_Types::instance()->getPackageClass(vB::$vbulletin->GPC['rb_type']) );
			}
			else
			{
				$config['contenttypeid'] = vB_Types::instance()->getContentTypeID('vBForum_Post');
				$config[ 'template'] =	'vbcms_searchresult_post';
			}

			$config['group'] = vB::$vbulletin->GPC_exists['group_text']?
				convert_urlencoded_unicode(vB::$vbulletin->GPC['group_text']) : null;

			$config['forumchoice'] = vB::$vbulletin->GPC_exists['forumchoice']?
				vB::$vbulletin->GPC['forumchoice'] : null;

			$config['cat'] = vB::$vbulletin->GPC_exists['cat']?
				vB::$vbulletin->GPC['cat'] : null;

			$config['prefixchoice'] = vB::$vbulletin->GPC_exists['prefixchoice']?
				vB::$vbulletin->GPC['prefixchoice'] : null;

			$config['tag'] = vB::$vbulletin->GPC_exists['srch_tag_text']?
				convert_urlencoded_unicode(vB::$vbulletin->GPC['srch_tag_text']) : null;

			$widgetdm = $this->widget->getDM();
			$widgetdm->set('config', $config);

			if ($this->content)
			{
				$widgetdm->setConfigNode($this->content->getNodeId());
			}

			$widgetdm->save();

			if (!$widgetdm->hasErrors())
			{
				if ($this->content)
				{
					$segments = array('node' => $this->content->getNodeURLSegment(),
										'action' => vB_Router::getUserAction('vBCms_Controller_Content', 'EditPage'));
					$view->setUrl(vB_View_AJAXHTML::URL_FINISHED, vBCms_Route_Content::getURL($segments));
				}

				$view->setStatus(vB_View_AJAXHTML::STATUS_FINISHED, new vB_Phrase('vbcms', 'configuration_saved'));
				vB_Cache::instance()->event($this->getCacheEvent());
			}
			else
			{
				if (vB::$vbulletin->debug)
				{
					$view->addErrors($widgetdm->getErrors());
				}

				// only send a message
				$view->setStatus(vB_View_AJAXHTML::STATUS_MESSAGE, new vB_Phrase('vbcms', 'configuration_failed'));
			}
		}
		else
		{
			$configview = $this->createView('config');

			// Contenttype multiselect
			$contenttypes = array() ;
			require_once DIR . '/includes/functions_databuild.php';
			fetch_phrase_group('search');

			foreach (vB_Search_Core::get_instance()->get_indexed_types() as $type)
			{
				$phrasekey = 'contenttype_' . strtolower($type['package']) . '_' . strtolower($type['class']);
				$contenttypes[$type['contenttypeid']] = array('name' => $vbphrase[$phrasekey] ,
					'contenttypeid' => $type['contenttypeid'],
					'template' => ((intval($type['contenttypeid']) == intval($config['contenttypeid'])) and
								isset($config['template'])) ?
							$config['template'] : 'vbcms_searchresult_' . strtolower($type['class']),
					'checked' => intval($type['contenttypeid']) == intval($config['contenttypeid']) ? 'checked="checked"' : '')  ;
			}

			$configview->contenttypes = $contenttypes;
			$configview->days = (isset($config['days']) ? $config['days'] : 14);
			$configview->count = $config['count'];
			$configview->username = $config['username'] ? $config['username'] : '';
			$configview->friendschecked = ($config['friends'] ? 'checked="checked"' : '');
			$configview->childforumschecked = ($config['childforums'] ? 'checked="checked"' : '');
			$configview->keywords = $config['keywords'];
			$configview->template_name = ($config['template_name'] ? $config['template_name'] : 'vbcms_widget_searchwidget_page');
			$configview->group = $config['group'];
			$configview->tag = $config['tag'];
			$configview->type_select = $select_types;
			$configview->cat_select = $this->getGroupCategories($config);
			$configview->prefixchoice_select = $this->getPrefixes($config) . '</select>';
			$configview->forumchoice_select = $this->getForums($config);

			// item id to ensure form is submitted to us
			$this->addPostId($configview);

			$view->setContent($configview);

			// send the view
			$view->setStatus(vB_View_AJAXHTML::STATUS_VIEW, new vB_Phrase('vbcms', 'configuring_widget'));
		}

		return $view;
	}
Beispiel #12
0
	private static function getNewBlogs($user)
	{
		global $vbulletin;
		global $vbphrase;
		if (! file_exists(DIR . '/packages/vbblog/search/searchcontroller/newblogentry.php')
			or ! (vB_Search_Core::get_instance()->get_cansearch('vBBlog', 'BlogEntry') ))
		{
			return;
		}
		include_once DIR . '/packages/vbblog/search/searchcontroller/newblogentry.php' ;
		require_once DIR . '/vb/search/core.php' ;
		require_once DIR . '/vb/search/criteria.php' ;
		require_once DIR . '/includes/functions_databuild.php' ;
		//We can use the existing new structures to create this feed. We don't
		// have to, we could do a direct sql query. But this structure is tested
		// and we know it handles permissions properly.
		//First we need a criteria object
		fetch_phrase_group('vbcms');
		$criteria = vB_Search_Core::get_instance()->create_criteria(vB_Search_Core::SEARCH_NEW);
		//Set the count, which may have been passed to us.
		$max_count = 10;

		if ($vbulletin->GPC_exists['count'] AND intval($vbulletin->GPC['count'])
			and intval($vbulletin->GPC['count']) < 21)
		{
			$max_count = intval($vbulletin->GPC['count']);
		}

		//Do we get a user? If so, limit the query.
		if ($vbulletin->GPC_exists['userid'] AND intval($vbulletin->GPC['userid']))
		{
			$criteria->add_userid_filter($vbulletin->GPC['userid'], true);
		}
		else if ($vbulletin->GPC_exists['searchuser'])
		{
			$criteria->add_user_filter($vbulletin->GPC['searchuser'], true);
		}

		//and set the date limit
		if ($vbulletin->GPC_exists['days'] AND intval($vbulletin->GPC['days'] ))
		{
			$datelimit = TIMENOW - ( intval($vbulletin->GPC['days']) * 86400);
		}
		else
		{
			$datelimit = TIMENOW - ( 3 * 86400);
		}
		$criteria->add_newitem_filter($datelimit, null, null);
		$search_controller = new vBBlog_Search_SearchController_NewBlogEntry;
		$results = vB_Search_Results::create_from_cache($user, $criteria, $search_controller);

		if (! $results = vB_Search_Results::create_from_cache($user, $criteria, $search_controller))
		{
			$results = vB_Search_Results::create_from_criteria($user, $criteria, $search_controller);
		}
		$page = $results->get_page(1, $max_count, 1);
		$headers = array(
			'title' => $vbulletin->options['hometitle'] ,
			'link' => $vbulletin->options['bburl'],
			'description' => construct_phrase($vbphrase['recent_blogs_from_x'], $vbulletin->options['hometitle']) ,
			'language' => 'en-us',
			'updated' => date('Y-m-d\TH:i:s', TIMENOW),
			'lastBuildDate' => date('Y-m-d\TH:i:s', TIMENOW)
		);
		$items= array();

		if (count($page))
		{
			$parser = new vBCms_BBCode_HTML(vB::$vbulletin, vBCms_BBCode_HTML::fetchCmsTags());
			foreach ($page as $result)
			{
				if ($blog = $result->get_record())
				{
					$items[] = array(
						'title' => $blog['title'],
						'summary' => $parser->get_preview($blog['pagetext'], 800),
						'link' => $vbulletin->options['bburl'] . '/blog.php?blogid='
							. $blog['blogid'],
						'author' => 'noreply@noreply.com-' . $blog['username']);
				}
			}
		}
		return self::makeXml($headers, null, $items);
	}
Beispiel #13
0
	/** Creates the publish editor across the top of the edit section
	 *
	 * @return mixed
	 *
	 ****/
	public function getEditBar($submit_url, $view_url, $formid, $action = 'edit', $candelete = true)
	{
		global $vbphrase;

		if ($this->canEdit() OR $this->canPublish())
		{
			require_once DIR . '/includes/functions_databuild.php';

			fetch_phrase_group('cpcms');
			fetch_phrase_group('contenttypes');

			$new_view = new vB_View('vbcms_content_edit_editbar');
			$new_view->submit_url = $submit_url;
			$new_view->view_url = $view_url;
			$new_view->formid = $formid;
			$new_view->header_phrase = $header_phrase;
			$new_view->adding = construct_phrase($vbphrase['addoredit_x'], $vbphrase[$action], $vbphrase[strtolower('contenttype_' . $this->package . '_' . $this->class)]);
			$new_view->confirm_message = $vbphrase['delete_page_confirmation_message'];
			$new_view->candelete = $candelete;
			$new_view->is_section = ($this->contenttypeid == vb_Types::instance()->getContentTypeID("vBCms_Section"));

			return $new_view;
		}
	}
Beispiel #14
0
	/**
	 * Returns the config view for the widget.
	 *
	 * @return vBCms_View_Widget				- The view result
	 */
	public function getConfigView()
	{
		$this->assertWidget();

		vB::$vbulletin->input->clean_array_gpc('r', array(
			'do'      => vB_Input::TYPE_STR,
			'days'    => vB_Input::TYPE_UINT,
			'ids'    => vB_Input::TYPE_STR,
			'count'    => vB_Input::TYPE_UINT,
			'forumchoice' => vB_Input::TYPE_ARRAY,
			'childforums' => vB_Input::TYPE_BOOL,
			'template_name'    => vB_Input::TYPE_STR,
			'detail_template' => vB_Input::TYPE_STR
		));

		$view = new vB_View_AJAXHTML('cms_widget_config');
		$view->title = new vB_Phrase('vbcms', 'configuring_widget_x', $this->widget->getTitle());
		$config = $this->widget->getConfig();

		if ((vB::$vbulletin->GPC['do'] == 'config') AND $this->verifyPostId())
		{
			if (vB::$vbulletin->GPC_exists['days'])
			{
				$config['days'] = vB::$vbulletin->GPC['days'];
			}

			if (vB::$vbulletin->GPC_exists['count'])
			{
				$config['count'] =  vB::$vbulletin->GPC['count'];
			}

			if (vB::$vbulletin->GPC_exists['template_name'])
			{
				$config['template_name'] = vB::$vbulletin->GPC['template_name'];
			}

			if (vB::$vbulletin->GPC_exists['detail_template'])
			{
				$config['detail_template'] = vB::$vbulletin->GPC['detail_template'];
			}

			if (vB::$vbulletin->GPC_exists['ids'])
			{
				$ids = array_unique(explode(',', vB::$vbulletin->GPC['ids']));
				$cleaned = array();

				foreach ($ids as $id)
				{
					if (intval($id) )
					{
						$cleaned[] = intval($id);
					}
				}
				$ids = implode(',', $cleaned);
				$config['ids'] = $ids ;
			}

			if (vB::$vbulletin->GPC_exists['forumchoice'])
			{
				$config['forumchoice'] =  vB::$vbulletin->GPC['forumchoice'];
			}

			$config['childforums'] =  vB::$vbulletin->GPC_exists['childforums'];


			$widgetdm = $this->widget->getDM();
			$widgetdm->set('config', $config);

			if ($this->content)
			{
				$widgetdm->setConfigNode($this->content->getNodeId());
			}

			$widgetdm->save();
			//clear the cache for this widget
			vB_Cache::instance()->event('poll_widget_' . $this->widget->getId());

			if (!$widgetdm->hasErrors())
			{
				if ($this->content)
				{
					$segments = array('node' => $this->content->getNodeURLSegment(),
										'action' => vB_Router::getUserAction('vBCms_Controller_Content', 'EditPage'));
					$view->setUrl(vB_View_AJAXHTML::URL_FINISHED, vBCms_Route_Content::getURL($segments));
				}

				$view->setStatus(vB_View_AJAXHTML::STATUS_FINISHED, new vB_Phrase('vbcms', 'configuration_saved'));
			}
			else
			{
				if (vB::$vbulletin->debug)
				{
					$view->addErrors($widgetdm->getErrors());
				}

				// only send a message
				$view->setStatus(vB_View_AJAXHTML::STATUS_MESSAGE, new vB_Phrase('vbcms', 'configuration_failed'));
			}
		}
		else
		{
			$configview = $this->createView('config');
			require_once DIR . '/includes/functions_databuild.php';
			fetch_phrase_group('search');

			if (!isset($config['template_name']) OR ($config['template_name'] == '') )
			{
				$config['template_name'] = 'vbcms_widget_poll_page';
			}

			if (!isset($config['detail_template']) OR ($config['detail_template'] == '') )
			{
				$config['detail_template'] = 'vbcms_widget_poll_resultdetail';
			}
			// add the config content
			$configview->template_name = $config['template_name'];
			$configview->detail_template = $config['detail_template'];
			$configview->forumchoice_select = $this->getForums($config);
			$configview->childforumschecked = ($config['childforums'] ? 'checked="checked"' : '');
			$configview->count = $config['count'];
			$configview->days = $config['days'];
			$configview->ids = $config['ids'];

			// item id to ensure form is submitted to us
			$this->addPostId($configview);

			$view->setContent($configview);

			// send the view
			$view->setStatus(vB_View_AJAXHTML::STATUS_VIEW, new vB_Phrase('vbcms', 'configuring_widget'));
		}

		return $view;
	}
Beispiel #15
0
	/**
	 * Fetches a rich page view of the specified content item.
	 * This method can accept parameters from the client code which are usually
	 * derived from user input.  Parameters are passed as an array in the order that
	 * they were received.  Parameters do not normally have assoc keys.
	 *
	 * Note: Parameters are always passed raw, so ensure that validation and
	 * escaping is performed where required.
	 *
	 * Skip permissions should allow content to be rendered regardless of the
	 * current user's permissions.
	 *
	 * Child classes will inevitably override this with wildly different
	 * implementations.
	 *
	 * @param array mixed $parameters			- Request parameters
	 * @param bool $skip_permissions			- Whether to skip can view permission checking
	 * @return vB_View | bool					- Returns a view or false
	 */
	public function getInlineEditBodyView($parameters = false)
	{
		global $vbphrase;
		require_once DIR . '/includes/functions.php';
		require_once DIR . '/includes/functions_databuild.php';
		fetch_phrase_group('cpcms');
		$this->editing = true;

		//confirm that the user has edit rights

		if (!$this->content->canPublish())
		{
			return new vB_Phrase('cpcms', 'no_edit_permissions');
		}

		if ($_REQUEST['do'] == 'apply' OR $_REQUEST['do'] == 'update' OR $_REQUEST['do'] == 'movenode')
		{
			$this->checkSaveData($view);
			unset($_REQUEST['do']);
		}

		$this->content->requireInfo(vBCms_Item_Content::INFO_BASIC  &
			vBCms_Item_Content::INFO_CONFIG & vBCms_Item_Content::INFO_NODE &
			vBCms_Item_Content::INFO_NAVIGATION & vBCms_Item_Content::INFO_PARENTS);
		$this->content->isValid();
		$config = $this->content->getConfig();

		//See if we're deleting
		if ($_REQUEST['do'] == 'delete')
		{

			//We can't delete if there is content below
			if ($record = vB::$vbulletin->db->query_first("SELECT nodeid FROM " . TABLE_PREFIX .
				"cms_node WHERE parentnode = " . $this->content->getNodeId() . " limit 1")
				and intval($record['nodeid']))
			{
				return new vB_Phrase('cpcms', 'cannot_delete_with_subnodes');
			}
			$dm = $this->content->getDM();
			$dm->delete();
			$events = $this->getCleanCacheEvents();
			vB_Cache::instance()->event($events);
			vB_Cache::instance()->cleanNow();
			return new vB_Phrase('cpcms', 'section_deleted');
		}
		vB::$vbulletin->input->clean_array_gpc('r', array(
		'sortby' => vB_Input::TYPE_STR,
		'dir' => vB_Input::TYPE_STR,
		'page' => vB_Input::TYPE_INT,
		'item_count' => vB_Input::TYPE_INT,
		'per_page' => TYPE_INT,
		'simple_paging' => TYPE_INT,
		'page' => TYPE_INT
			));

		// Load the content item
		if (!$this->loadContent($this->getViewInfoFlags(self::VIEW_PAGE)))
		{
			throw (new vB_Exception_404());
		}

		// Create view
		$view = $this->createView('inline', self::VIEW_PAGE);

		// Add the content to the view
		parent::populateViewContent($view, self::VIEW_PAGE);

		$this->config = $this->getConfig();

		$view->formid = 'cms_content_data';
		$view->title = $this->content->getTitle();
		$view->html_title = $this->content->getHtmlTitle();
		$view->url = $this->content->getUrl();
		$view->contentfrom = $this->config['contentfrom'];
		$view->editshowchildren = $this->content->getEditShowchildren() ? 1 : 0;
		$view->layout_select = vBCms_ContentManager::getLayoutSelect($this->content->getLayoutSetting(), $this->getParentId());
		$view->style_select = vBCms_ContentManager::getStyleSelect($this->content->getStyleSetting()) ;
		$view->display_order_select = vBCms_ContentManager::getSectionPrioritySelect($this->config['section_priority']) ;
		$view->content_layout_select = $tmp = vBCms_ContentManager::getContentLayoutSelect($this->config['content_layout']);
		$view->simple_paging = $this->config['simple_paging'];
		$view->per_page = $this->config['items_perhomepage'];
		$view->nodeid = $this->content->getNodeId();
		$view->dateformat = vB::$vbulletin->options['dateformat'] . " " . vB::$vbulletin->options['timeformat'];

		if (intval($this->content->getPublishDate))
		{
			$view->publishdate = $this->content->getPublishDate();
		}

		$aggregate = new vBCms_Collection_Content_Section();
		switch(vB::$vbulletin->GPC['sortby'])
		{
			case 'title' :
				$aggregate->setSortBy('ORDER BY title ' . vB::$vbulletin->GPC['dir']);
				break;
			case 'setpublish' :
				$aggregate->setSortBy('ORDER BY setpublish ' . vB::$vbulletin->GPC['dir']);
				break;
			case 'displayorder' :
				$aggregate->setSortBy('ORDER BY displayorder ' . vB::$vbulletin->GPC['dir']);
				break;
			case 'username' :
				$aggregate->setSortBy('ORDER BY username ' . vB::$vbulletin->GPC['dir']);
				break;
			case 'publishdate' :
				$aggregate->setSortBy('ORDER BY publishdate ' . vB::$vbulletin->GPC['dir']);
				break;
			case 'pageviews' :
				$aggregate->setSortBy('ORDER BY viewcount ' . vB::$vbulletin->GPC['dir']);
				break;
			case 'replycount':
				$aggregate->setSortBy('ORDER BY replycount ' . vB::$vbulletin->GPC['dir']);
				;
				break;
			case 'section':
				$aggregate->setSortBy('ORDER BY parenttitle ' . vB::$vbulletin->GPC['dir']);
				;
				break;
			default:
		$aggregate->setOrderBy(1);
			;
		} // switch

		//See if we need to hide the children
		$filter_node = $this->content->getEditShowchildren();
		if (!$filter_node)
		{
			$aggregate->setFilterNodeExact($this->content->getNodeId());
		}
		else
		{
			$aggregate->filterNode($this->content->getNodeId());
		}
		$nodes = array();
		$sequence = 0;
		$candelete = 1;


		if (vB::$vbulletin->GPC_exists['perpage'] AND intval(vB::$vbulletin->GPC['perpage']))
		{
			$perpage = vB::$vbulletin->GPC['perpage'];
		}
		else
		{
			$perpage = vBCms_ContentManager::getPerPage(new vB_Legacy_CurrentUser());
		}

		$current_page = (vB::$vbulletin->GPC_exists['page'] AND intval(vB::$vbulletin->GPC['page']) ) ?
			vB::$vbulletin->GPC['page'] : 1;
		$aggregate->paginate();
		$aggregate->paginateQuantity($perpage);
		$aggregate->paginatePage($current_page);

		foreach ($aggregate as $id => $content_node)
		{
			$candelete = 0;

			if ($content_node->getContentTypeid() != vb_Types::instance()->getContentTypeID("vBCms_Section") )
			{
				$sequence++;
				$nodes[] = array('sequence' => $sequence,
				'class' => $content_node->getClass(),
				'title' => $content_node->getTitle(),
				'html_title' => $content_node->getHtmlTitle(),
				'nodeid' => $content_node->getNodeid(),
				'prev_checked' =>	($content_node->getPublicPreview() ? " checked=\"checked\" " : ''),
				'publicpreview' => $content_node->publicpreview,
				'parenttitle' => $content_node->getParentTitle(),
				'published_select' => vBCms_ContentManager::getPublishedSelect($content_node->getSetPublish(), $content_node->getPublishDate()),
				'order_select' =>  vBCms_ContentManager::getOrderSelect($content_node->getDisplayOrder($this->content->getNodeId()),
					$this->content->getNodeId()),
				'author' => $content_node->getUsername(),
				'pub_date' =>  (intval($content_node->getPublishDate()) ? vbdate(vB::$vbulletin->options['dateformat'], $content_node->getPublishDate()) : '') ,
				'viewcount' => $content_node->getViewCount(),
				'view_url' => vBCms_Route_Content::getURL(array('node' => $content_node->getUrlSegment())),
				'replycount' => $content_node->getReplyCount());
			}
		}

		if (vB::$vbulletin->GPC_exists['item_count'])
		{
				$item_count = vB::$vbulletin->GPC['item_count'];
		}
		else
		{
			$aggregate->filterNoSections(1);
			$item_count = $aggregate->getCount();
		}

		$segments = array('node' => $this->content->getUrlSegment(),
							'action' => vB_Router::getUserAction('vBCms_Controller_Content', 'View'));
		$view->view_url = vBCms_Route_Content::getURL($segments);
		$segments = array('node' => $this->content->getUrlSegment(),
							'action' => vB_Router::getUserAction('vBCms_Controller_Content', 'EditPage'));
		$view->submit_url = vBCms_Route_Content::getURL($segments);
		$base_url = $view->submit_url;
		$base_url .=  strpos($base_url, '?') ? '&amp;' : '?';

		$view->record_count = count($aggregate);
		$view->item_count = $item_count;

		$pagination = construct_page_nav($current_page, $perpage, $item_count, $view->submit_url);
		$view->pagination = $pagination;

		$perpage_select .= '<select name="perpage" onchange="checkShouldSave(\'' .
			$view->formid . '\', \'perpage\', \'' . vB_Template_Runtime::escapeJS(new vB_Phrase('cpcms', 'confirm_save_section')) .
			 '\', \'' . vB_Template_Runtime::escapeJS($view->submit_url)  . '\');">' . "\n";
		foreach (array(5,10,15,20,25,50,75,100,200, 250, 500) as $this_perpage)
		{
			$perpage_select .= "<option value=\"$this_perpage\""
				. (intval($this_perpage) == intval($perpage) ? ' selected="selected" ' : '')
				. ">$this_perpage</option>\n" ;
		}
		$perpage_select	.= "</select>";
		$view->perpage_select = $perpage_select;

		$record = vB::$vbulletin->db->query_first("SELECT SUM(childinfo.viewcount) AS viewcount,
          SUM(CASE when child.contenttypeid <> " . vb_Types::instance()->getContentTypeID("vBCms_Section") ." THEN 1 ELSE 0 END) AS content,
          SUM(CASE when (child.parentnode = node.nodeid AND child.contenttypeid <> " . vb_Types::instance()->getContentTypeID("vBCms_Section") .") THEN 1 ELSE 0 END) AS children,
          SUM(CASE when child.contenttypeid =" . vb_Types::instance()->getContentTypeID("vBCms_Section") ." AND child.parentnode = node.nodeid THEN 1 ELSE 0 END) AS subsections
				FROM " . TABLE_PREFIX . "cms_node AS node
				LEFT JOIN " . TABLE_PREFIX . "cms_node AS child ON (child.nodeleft >= node.nodeleft AND child.nodeleft <= node.noderight AND child.nodeid <> node.nodeid AND child.new != 1)
				LEFT JOIN " . TABLE_PREFIX . "cms_nodeinfo AS childinfo ON childinfo.nodeid = child.nodeid AND child.contenttypeid <> " . vb_Types::instance()->getContentTypeID("vBCms_Section") ."
				WHERE node.nodeid = " . $this->content->getNodeId());
		$view->viewcount = $record['viewcount'];
		$view->content = $record['content'];
		$view->children = $record['children'];
		$view->subsections = $record['subsections'];

		$view->nodes = $nodes;

		$view->metadata = $this->content->getMetadataEditor();

		//Here we create some url's. This should allow to sort in reverse direction

		$view->sorttitle_url = $base_url . 'sortby=title&dir=' .
			((vB::$vbulletin->GPC_exists['sortby'] AND vB::$vbulletin->GPC['sortby'] == 'title'
				AND vB::$vbulletin->GPC['dir'] == 'asc') ? 'desc' : 'asc');
		$view->sortpub_url = $base_url . 'sortby=setpublish&dir=' .
			((vB::$vbulletin->GPC_exists['sortby'] AND vB::$vbulletin->GPC['sortby'] == 'setpublish'
				AND vB::$vbulletin->GPC['dir'] == 'asc') ? 'desc' : 'asc');
		$view->sortorder_url = $base_url . 'sortby=displayorder&dir=' .
			((vB::$vbulletin->GPC_exists['sortby'] AND vB::$vbulletin->GPC['sortby'] == 'displayorder'
				AND vB::$vbulletin->GPC['dir'] == 'asc') ? 'desc' : 'asc');
		$view->sortauthor_url = $base_url . 'sortby=username&dir=' .
			((vB::$vbulletin->GPC_exists['sortby'] AND vB::$vbulletin->GPC['sortby'] == 'username'
				AND vB::$vbulletin->GPC['dir'] == 'asc') ? 'desc' : 'asc');
		$view->sortdate_url = $base_url . 'sortby=publishdate&dir=' .
			((vB::$vbulletin->GPC_exists['sortby'] AND vB::$vbulletin->GPC['sortby'] == 'publishdate'
				AND vB::$vbulletin->GPC['dir'] == 'asc') ? 'desc' : 'asc');
		$view->sorthits_url = $base_url . 'sortby=pageviews&dir=' .
			((vB::$vbulletin->GPC_exists['sortby'] AND vB::$vbulletin->GPC['sortby'] == 'pageviews'
				AND vB::$vbulletin->GPC['dir'] == 'asc') ? 'desc' : 'asc');
		$view->sortreplycount_url = $base_url . 'sortby=replycount&dir=' .
			((vB::$vbulletin->GPC_exists['sortby'] AND vB::$vbulletin->GPC['sortby'] == 'replycount'
				AND vB::$vbulletin->GPC['dir'] == 'asc') ? 'desc' : 'asc');
		$view->sortsection_url = $base_url . 'sortby=section&dir=' .
			((vB::$vbulletin->GPC_exists['sortby'] AND vB::$vbulletin->GPC['sortby'] == 'section'
				AND vB::$vbulletin->GPC['dir'] == 'asc') ? 'desc' : 'asc');
		$view->editbar = $this->content->getEditBar($view->submit_url, $view->view_url, $view->formid,
				(intval($this->content->getNodeId()) ? 'edit' : 'add'), $candelete);
		$view->publisher = $this->content->getPublishEditor($view->submit_url, $view->formid, false,
			false, false, false, $this->config['pagination_links']);

		$view->contenttypeid = vB_Types::instance()->getContentTypeID("vBCms_Section");

		$this->addPostId($view);

		// Sub menu
		if (!$this->content->isRoot())
		{
			$view->inherit_section = $this->content->getNavigationParentTitle();
			$view->inherited = !$this->content->hasNavigation();
		}

		$navigation_nodes = $this->content->getNavigationNodes();

		$subnav_nodes = vBCms_ContentManager::getSections(false, true);


		// array for the navigation display order drop-down menu
		$displayorder_array = array(0 => '');
		$count = max(count($nodes), 40);
		for ($i=1; $i <= $count; $i++)
		{
			$displayorder_array[$i] = $i;
		}

		// populate sub-nav configuration menu with all cms sections
		$sections = array();

		$subnav = new vB_View('vbcms_content_section_subnavedit');
		$subnav->displayorder_array = $displayorder_array;
		foreach ($subnav_nodes AS $node)
		{
			$nodeid = $node['nodeid'];

			// check if the section has already been selected for the menu nav
			// if so, its position in the array (key+1) is its display order
			$displayorder = 0; //default display order is 0
			$selected = false;
			if (isset($navigation_nodes) AND is_array($navigation_nodes))
			{
				if ($selected = in_array($nodeid, $navigation_nodes))
				{
					$displayorder = array_search($nodeid, $navigation_nodes) + 1;
				}
			}

			$sections[] = array('id' => $nodeid, 'title' => $node['title'], 'depth' => $node['depth'], 'selected' => $selected, 'displayorder' => $displayorder);
		}
		$subnav->sections = $sections;
		$subnav_rendered = $subnav->render();
		$view->subnav = $subnav_rendered;
		unset($nodes, $subnav_nodes, $sections);
		return $view;
	}
Beispiel #16
0
	/**
	 * Returns the config view for the widget.
	 *
	 * @return vBCms_View_Widget				- The view result
	 */
	public function getConfigView()
	{
		global $vbphrase;
		require_once DIR . '/includes/functions_databuild.php';
		fetch_phrase_group('cpcms');

		$this->assertWidget();

		vB::$vbulletin->input->clean_array_gpc('r', array(
			'do'      => vB_Input::TYPE_STR,
			'days'    => vB_Input::TYPE_UINT,
			'recent_type'    => vB_Input::TYPE_STR,
			'count'    => vB_Input::TYPE_UINT,
			'forumchoice' => vB_Input::TYPE_ARRAY,
			'template_name' => vB_Input::TYPE_STR,
			'min_replies'   => vB_Input::TYPE_UINT,
			'main_template' => vB_Input::TYPE_STR,
			'childforums' => vB_Input::TYPE_BOOL
		));

		$view = new vB_View_AJAXHTML('cms_widget_config');
		$view->title = new vB_Phrase('vbcms', 'configuring_widget_x', $this->widget->getTitle());
		$config = $this->widget->getConfig();

		if ((vB::$vbulletin->GPC['do'] == 'config') AND $this->verifyPostId())
		{
			if (vB::$vbulletin->GPC_exists['days'])
			{
				$config['days'] = vB::$vbulletin->GPC['days'];
			}

			if (vB::$vbulletin->GPC_exists['min_replies'])
			{
				$config['min_replies'] =  vB::$vbulletin->GPC['min_replies'];
			}

			if (vB::$vbulletin->GPC_exists['count'])
			{
				$config['count'] =  vB::$vbulletin->GPC['count'];
			}

			if (vB::$vbulletin->GPC_exists['recent_type'])
			{
				$config['recent_type'] =  vB::$vbulletin->GPC['recent_type'];
			}

			if (vB::$vbulletin->GPC_exists['template_name'])
			{
				$config['template_name'] =  vB::$vbulletin->GPC['template_name'];
			}

			if (vB::$vbulletin->GPC_exists['main_template'])
			{
				$config['main_template'] =  vB::$vbulletin->GPC['main_template'];
			}

			if (vB::$vbulletin->GPC_exists['forumchoice'])
			{
				$config['forumchoice'] =  vB::$vbulletin->GPC['forumchoice'];
			}

			$config['childforums'] =  vB::$vbulletin->GPC_exists['childforums'];

			$widgetdm = $this->widget->getDM();
			$widgetdm->set('config', $config);

			if ($this->content)
			{
				$widgetdm->setConfigNode($this->content->getNodeId());
			}

			$widgetdm->save();


			if (!$widgetdm->hasErrors())
			{
				if ($this->content)
				{
					$segments = array('node' => $this->content->getNodeURLSegment(),
										'action' => vB_Router::getUserAction('vBCms_Controller_Content', 'EditPage'));
					$view->setUrl(vB_View_AJAXHTML::URL_FINISHED, vBCms_Route_Content::getURL($segments));
				}

				$view->setStatus(vB_View_AJAXHTML::STATUS_FINISHED, new vB_Phrase('vbcms', 'configuration_saved'));
				vB_Cache::instance()->event($this->getCacheEvent());
			}
			else
			{
				if (vB::$vbulletin->debug)
				{
					$view->addErrors($widgetdm->getErrors());
				}

				// only send a message
				$view->setStatus(vB_View_AJAXHTML::STATUS_MESSAGE, new vB_Phrase('vbcms', 'configuration_failed'));
			}
		}
		else
		{
			$configview = $this->createView('config');
			require_once DIR . '/includes/functions_databuild.php';
			fetch_phrase_group('search');

			$configview->forumchoice_select = $this->getForums($config);
			$configview->childforumschecked = ($config['childforums'] ? 'checked="checked"' : '');
			$configview->count = $config['count'];
			$configview->template_name = (isset($config['template_name']) ? $config['template_name'] : 'vbcms_searchresult_thread');
			$configview->main_template = (isset($config['main_template']) ? $config['main_template'] : 'vbcms_widget_recent_page');
			$configview->min_replies = $config['min_replies'];
			$configview->days = $config['days'];
			$typeselected = array();
			$recent_typeselected[0]= ($config['recent_type'] == 'active' ? 'checked="checked"' : '');
			$recent_typeselected[1]= ($config['recent_type'] == 'recent' ? 'checked="checked"' : '');
			$recent_typeselected[2]= ($config['recent_type'] == 'viewed' ? 'checked="checked"' : '');
			$recent_typeselected[3]= ($config['recent_type'] == 'mostrated' ? 'checked="checked"' : '');
			$recent_typeselected[4]= ($config['recent_type'] == 'bestrated' ? 'checked="checked"' : '');
			$configview->recent_typeselected = $recent_typeselected;

			// item id to ensure form is submitted to us
			$this->addPostId($configview);

			$view->setContent($configview);

			// send the view
			$view->setStatus(vB_View_AJAXHTML::STATUS_VIEW, new vB_Phrase('vbcms', 'configuring_widget'));
		}

		return $view;
	}
Beispiel #17
0
	public function getInlineEditBodyView()
	{
		global $vbphrase;
		require_once DIR . '/includes/functions_databuild.php';
		require_once DIR . '/includes/functions.php';
		fetch_phrase_group('cpcms');

		$this->config = $this->content->getConfig();
		$this->editing = true;

		//confirm that the user has edit rights
		if ( (!$this->content->canEdit()
			AND !$this->content->canUseHtml(vB::$vbulletin->userinfo['userid'])
			) OR !$this->content->canPublish() )
		{
			return $vb_phrase['no_edit_permissions'];
		}

		vB::$vbulletin->input->clean_array_gpc('r', array(
			'do' => vB_Input::TYPE_STR,
		));

		if ($_REQUEST['do'] == 'delete')
		{
			$dm = $this->content->getDM();
			$dm->delete();
			$this->cleanContentCache();
			return $vbphrase['article_deleted'];
		}

		$view = new vB_View('vbcms_content_' . strtolower($this->class). '_inline');
		if ($_REQUEST['do'] == 'apply' OR $_REQUEST['do'] == 'update')
		{
			$this->saveData($view);
		}

		$this->config = $this->content->getConfig();

		require_once DIR . '/packages/vbcms/contentmanager.php';
		// Load the content item
		if (!$this->loadContent($this->getViewInfoFlags(self::VIEW_PAGE)))
		{
			throw (new vB_Exception_404());
		}

		global $show;

		$show['img_bbcode'] = true;
		// Create view

		//make sure we have template names.
		if (empty($this->config['previewtemplate']))
		{
			$this->config['previewtemplate'] = $this->default_previewtemplate;
		}

		if (empty($this->config['template']))
		{
			$this->config['template'] = $this->default_template;
		}
		// Add the content to the view
		$view = $this->populateViewContent($view, self::VIEW_PAGE, false);
		//the configuration settings
		foreach ($this->config as $key => $value)
		{
			if (($key == 'preview_image') OR ($key == 'title'))
			{
				$view->$key = htmlspecialchars_uni($value);
			}
			else
			{
				$view->$key = $value;
			}
		}

		$view->formid = "cms_content_data";
		$view->can_edit = $this->content->canEdit() AND $this->content->canUseHtml(vB::$vbulletin->userinfo['userid']);

		$view->url = $this->content->getUrl();
		$view->type = new vB_Phrase('vbcms', 'content');
		$view->adding = 	new vB_Phrase('cpcms', 'adding_x', $vbphrase['article']);
		$view->html_title = $this->content->getHtmlTitle();
		$view->title = $this->content->getTitle();
		$view->metadata = $this->content->getMetadataEditor();
		$segments = array('node' => $this->content->getUrlSegment(),
							'action' => vB_Router::getUserAction('vBCms_Controller_Content', 'View'));
		$view->view_url = vBCms_Route_Content::getURL($segments);
		// Add URL to submit to
		$segments = array('node' => $this->content->getUrlSegment(),
							'action' => vB_Router::getUserAction('vBCms_Controller_Content', 'EditPage'));
		$view->submit_url = vBCms_Route_Content::getURL($segments);
		$segments = array('node' => $this->content->getUrlSegment(),
							'action' => vB_Router::getUserAction('vBCms_Controller_Content', 'View'));
		$view->editbar = $this->content->getEditBar($view->submit_url, vBCms_Route_Content::getURL($segments), $view->formid);

		$view->publisher = $this->content->getPublishEditor($view->submit_url, $view->formid,
			true, true, $this->content->getPublicPreview(), $this->content->getComments_Enabled());
		$view->authorid = ($this->content->getUserId());
		$view->authorname = ($this->content->getUsername());
		$view->viewcount = ($this->content->getViewCount());
		$view->parentid = $this->content->getParentId();

		$view->comment_count = ($this->content->getReplyCount());
		$view->contentid = $this->content->getContentId(true);

		$view->show_threaded = true;
		$view->per_page = 10;
		$view->indent_per_level = 5;
		$view->max_level = 4;
		// Add form check
		$this->addPostId($view);
		return $view;
	}
Beispiel #18
0
	/**
	 * Returns the config view for the widget.
	 *
	 * @return vBCms_View_Widget				- The view result
	 */
	public function getConfigView()
	{
		global $vbphrase;
		require_once DIR . '/includes/functions_databuild.php';
		fetch_phrase_group('cpcms');

		$this->assertWidget();

		vB::$vbulletin->input->clean_array_gpc('r', array(
			'do'    => vB_Input::TYPE_STR,
			'days'    => vB_Input::TYPE_UINT,
			'count' => vB_Input::TYPE_UINT,
			'template' => vB_Input::TYPE_STR,
			'inner_template' => vB_Input::TYPE_STR,
			'cache_ttl' => vB_Input::TYPE_UINT,
		));

		$view = new vB_View_AJAXHTML('cms_widget_config');
		$view->title = new vB_Phrase('vbcms', 'configuring_widget_x', $this->widget->getTitle());
		$config = $this->widget->getConfig();

		if ((vB::$vbulletin->GPC['do'] == 'config') AND $this->verifyPostId())
		{
			if (vB::$vbulletin->GPC_exists['days'])
			{
				$config['days'] = vB::$vbulletin->GPC['days'];
			}

			if (vB::$vbulletin->GPC_exists['count'])
			{
				$config['count'] =  vB::$vbulletin->GPC['count'];
			}

			if (vB::$vbulletin->GPC_exists['template'])
			{
				$config['template'] =  vB::$vbulletin->GPC['template'];
			}

			if (vB::$vbulletin->GPC_exists['inner_template'])
			{
				$config['inner_template'] =  vB::$vbulletin->GPC['inner_template'];
			}

			if (vB::$vbulletin->GPC_exists['cache_ttl'])
			{
				$config['cache_ttl'] =  vB::$vbulletin->GPC['cache_ttl'];
			}

			$widgetdm = $this->widget->getDM();
			$widgetdm->set('config', $config);

			if ($this->content)
			{
				$widgetdm->setConfigNode($this->content->getNodeId());
			}

			$widgetdm->save();


			if (!$widgetdm->hasErrors())
			{
				if ($this->content)
				{
					$segments = array('node' => $this->content->getNodeURLSegment(),
										'action' => vB_Router::getUserAction('vBCms_Controller_Content', 'EditPage'));
					$view->setUrl(vB_View_AJAXHTML::URL_FINISHED, vBCms_Route_Content::getURL($segments));
				}

				$view->setStatus(vB_View_AJAXHTML::STATUS_FINISHED, new vB_Phrase('vbcms', 'configuration_saved'));
			}
			else
			{
				if (vB::$vbulletin->debug)
				{
					$view->addErrors($widgetdm->getErrors());
				}

				// only send a message
				$view->setStatus(vB_View_AJAXHTML::STATUS_MESSAGE, new vB_Phrase('vbcms', 'configuration_failed'));
			}
		}
		else
		{
			$configview = $this->createView('config');
			$configview->days = $config['days'];
			$configview->count = $config['count'];
			$configview->cache_ttl = $config['cache_ttl'];
			if (!isset($config['template']) OR ($config['template'] == '') )
			{
				$config['template'] = 'vbcms_widget_recentcmscomments_page';
			}

			if (!isset($config['inner_template']) OR ($config['inner_template'] == '') )
			{
				$config['inner_template'] = 'vbcms_searchresult_newcomment';
			}

			$configview->template = $config['template'];
			$configview->inner_template = $config['inner_template'];

			// item id to ensure form is submitted to us
			$this->addPostId($configview);

			$view->setContent($configview);

			// send the view
			$view->setStatus(vB_View_AJAXHTML::STATUS_VIEW, new vB_Phrase('vbcms', 'configuring_widget'));
		}

		return $view;
	}
Beispiel #19
0
	/**
	 * Returns the config view for the widget.
	 *
	 * @param	vB_Widget	$widget
	 * @return vBCms_View_Widget				- The view result
	 */
	public function getConfigView($widget = false)
	{
		$this->assertWidget();
		require_once DIR . '/includes/functions_databuild.php';
		fetch_phrase_group('cpcms');
		fetch_phrase_group('vbblock');
		fetch_phrase_group('vbblocksettings');

		vB::$vbulletin->input->clean_array_gpc('r', array(
			'do'     => vB_Input::TYPE_STR,
			'template_name' => vB_Input::TYPE_STR,
			'cache_ttl' => vB_Input::TYPE_INT,
			'commentusernames' => vB_Input::TYPE_STR,
			'postusernames' => vB_Input::TYPE_STR,
			'taglist' => vB_Input::TYPE_STR,
			'blogid' => vB_Input::TYPE_STR,
			'cat_case_sensitive' => vB_Input::TYPE_INT,
			'messagemaxchars' => vB_Input::TYPE_INT,
			'categories' => vB_Input::TYPE_STR,
			'days' => vB_Input::TYPE_INT,
			'count'    => vB_Input::TYPE_INT
		));


		$view = new vB_View_AJAXHTML('cms_widget_config');
		$view->title = new vB_Phrase('vbcms', 'configuring_widget_x', $this->widget->getTitle());

		$config = $this->widget->getConfig();

		if ((vB::$vbulletin->GPC['do'] == 'config') AND $this->verifyPostId())
		{

			$widgetdm = new vBCms_DM_Widget($this->widget);

			if (vB::$vbulletin->GPC_exists['template_name'])
			{
				$config['template_name'] = vB::$vbulletin->GPC['template_name'];
			}

			if (vB::$vbulletin->GPC_exists['days'])
			{
				$config['days'] = vB::$vbulletin->GPC['days'];
			}

			if (vB::$vbulletin->GPC_exists['count'])
			{
				$config['count'] = vB::$vbulletin->GPC['count'];
			}

			if (vB::$vbulletin->GPC_exists['cache_ttl'])
			{
				$config['cache_ttl'] = vB::$vbulletin->GPC['cache_ttl'];
			}

			if (vB::$vbulletin->GPC_exists['messagemaxchars'])
			{
				$config['messagemaxchars'] = vB::$vbulletin->GPC['messagemaxchars'];
			}

			if (vB::$vbulletin->GPC_exists['commentusernames'])
			{
				//We could be passed an empty string. If so, clear the existing value
				if (empty(vB::$vbulletin->GPC['commentusernames']))
				{
					$config['commentuserid'] = '';
				}
				else
				{
					//We are passed names. We need to turn those into user id's
					$usernames = explode(',', vB::$vbulletin->GPC['commentusernames']);

					foreach ($usernames as $key => $username)
					{
						$usernames[$key] = "'" . vB::$db->escape_string(trim($username)) . "'";
					}
					$sql = "SELECT username, userid FROM " . TABLE_PREFIX . "user
					WHERE username IN (" . implode(',', $usernames) . ") ORDER BY lower(username)";

					if ($rst = vB::$db->query_read($sql))
					{
						$userids = array();
						while($record = vB::$db->fetch_array($rst))
						{
							$userids[$record['userid']] = $record['username'];
						}
					}
					$config['commentuserid'] = $userids;
				}
			}

			if (vB::$vbulletin->GPC_exists['postusernames'])
			{
				//We could be passed an empty string. If so, clear the existing value
				if (empty(vB::$vbulletin->GPC['postusernames']))
				{
					$config['postuserid'] = '';
				}
				else
				{
					//We are passed names. We need to turn those into user id's
					$usernames = explode(',', vB::$vbulletin->GPC['postusernames']);

					foreach ($usernames as $key => $username)
					{
						$usernames[$key] = "'" . vB::$db->escape_string(trim($username)) . "'";
					}
					$sql = "SELECT username, userid FROM " . TABLE_PREFIX . "user
					WHERE username IN (" . implode(',', $usernames) . ") ORDER BY lower(username)";

					if ($rst = vB::$db->query_read($sql))
					{
						$userids = array();
						while($record = vB::$db->fetch_array($rst))
						{
							$userids[$record['userid']] = $record['username'];
						}
					}
					$config['postuserid'] = $userids;
				}
			}

			if (vB::$vbulletin->GPC_exists['taglist'])
			{
				//We could be passed an empty string. If so, clear the existing value
				if (empty(vB::$vbulletin->GPC['taglist']))
				{
					$config['taglist'] = '';
				}
				else
				{
					//We need to confirm these are valid tags
					$tags = explode(',', vB::$vbulletin->GPC['taglist']);

					foreach ($tags as $key => $tag)
					{
						$tags[$key] = "'" . vB::$db->escape_string(trim($tag)) . "'";
					}
					$sql = "SELECT tagid, tagtext FROM " . TABLE_PREFIX . "tag
					WHERE tagtext IN (" . implode(',', $tags) . ")
					ORDER BY tagtext";

					if ($rst = vB::$db->query_read($sql))
					{
						$tagids = array();
						while($record = vB::$db->fetch_array($rst))
						{
							$tagids[$record['tagid']] = $record['tagtext'];
						}
					}
					$config['taglist'] = $tagids;
				}
			}


			if (vB::$vbulletin->GPC_exists['blogid'])
			{
				//We could be passed an empty string. If so, clear the existing value
				if (empty(vB::$vbulletin->GPC['blogid']))
				{
					$config['blogid'] = '';
				}
				else
				{
					//We need to confirm these are valid ids
					$blogids = explode(',', vB::$vbulletin->GPC['blogid']);
					$blogid_checked = array();

					foreach ($blogids as $key => $blogid)
					{
						if (intval(intval($blogid)))
						{

						}
						$blogid_checked[] = intval($blogid);
					}

					$sql = "SELECT blogid FROM " . TABLE_PREFIX . "blog
					WHERE blogid IN (" . implode(',', $blogid_checked) . ")";

					if ($rst = vB::$db->query_read($sql))
					{
						$blogids = array();
						while($record = vB::$db->fetch_array($rst))
						{
							$blogids[] = $record['blogid'];
						}
					}
					$config['blogid'] = implode(',', $blogids);
				}
			}
			if (vB::$vbulletin->GPC_exists['categories'])
			{
				//We could be passed an empty string. If so, clear the existing value
				if (vB::$vbulletin->GPC['categories'] == '')
				{
					$config['categories'] = '';
				}
				else
				{
					$categories = explode(',', vB::$vbulletin->GPC['categories']);

					foreach ($categories as $key => $category)
					{
						$categories[$key] = "'" . vB::$db->escape_string(trim($category)) . "'";
					}

					$sql = "SELECT title, blogcategoryid FROM " . TABLE_PREFIX . "blog_category
					WHERE title IN (" . implode(',', $categories) . ")";

					if ($rst = vB::$db->query_read($sql))
					{
						$categories = array();
						while($record = vB::$db->fetch_array($rst))
						{
							$categories[$record['blogcategoryid']] = $record['title'];
						}
					}
					$config['categories'] = $categories;
				}
			}

			$widgetdm->set('config', $config);

			$widgetdm->save();

			if (!$widgetdm->hasErrors())
			{
				if ($this->content)
				{
					$segments = array('node' => $this->content->getNodeURLSegment(),
										'action' => vB_Router::getUserAction('vBCms_Controller_Content', 'EditPage'));
					$view->setUrl(vB_View_AJAXHTML::URL_FINISHED, vBCms_Route_Content::getURL($segments));
				}

				$view->setStatus(vB_View_AJAXHTML::STATUS_FINISHED, new vB_Phrase('vbcms', 'configuration_saved'));
			}
			else
			{
				if (vB::$vbulletin->debug)
				{
					$view->addErrors($widgetdm->getErrors());
				}

				// only send a message
				$view->setStatus(vB_View_AJAXHTML::STATUS_MESSAGE, new vB_Phrase('vbcms', 'configuration_failed'));
			}
		}
		else
		{
			// add the config content
			$configview = $this->createView('config');

			if (!isset($config['template_name']) OR ($config['template_name'] == '') )
			{
				$config['template_name'] = 'vbcms_widget_recentblog_page';
			}
			// add the config content
			$configview->template_name = $config['template_name'];
			$configview->days = $config['days'];
			$configview->count = $config['count'];
			$configview->messagemaxchars = $config['messagemaxchars'];
			$configview->blogid = $config['blogid'];

			if (!empty($config['postuserid']))
			{
				$configview->postusernames = implode(',', $config['postuserid']);
			}

			if (!empty($config['commentuserid']))
			{
				$configview->commentusernames = implode(',', $config['commentuserid']);
			}

			if (!empty($config['taglist']))
			{
				$configview->taglist = implode(',', $config['taglist']);
			}

			//Case sensitivity is an interesting issue. We will do the
			// search based on the db collation, which defaults to case
			// insensitive. But let's display in the stored value case
			$categories = array();

			if (!empty($config['categories']))
			{
				$lcase_categories = array();
				foreach($config['categories'] as $category)
				{
					if (!in_array(strtolower($category), $lcase_categories))
					{
						$categories[] = $category;
						$lcase_categories[] = strtolower($category);
					}
				}
				$configview->categories = implode(',', $config['categories']);
			}
			$configview->categories = implode(',', $categories);
			$configview->cache_ttl = $config['cache_ttl'];

			$this->addPostId($configview);

			$view->setContent($configview);

			// send the view
			$view->setStatus(vB_View_AJAXHTML::STATUS_VIEW, new vB_Phrase('vbcms', 'configuring_widget'));
		}

		return $view;
	}
Beispiel #20
0
	/**
	 * Builds the toolbar view for managing the page.
	 *
	 * @param bool $edit_mode					- Whether the user is currently in edit mode
	 * @return vB_View
	 */
	protected function getToolbarView($edit_mode = false)
	{
		global $vbulletin;
		global $vbphrase;

		if (!$this->content->canCreate() AND !$this->content->canEdit() AND !$this->content->canPublish())
		{
			return;
		}

		require_once DIR . '/includes/functions_databuild.php';

		fetch_phrase_group('cpcms');
		// Create view
		$view = new vB_View('vbcms_toolbar');
		$view->edit_mode = $edit_mode;
		$view->page_url = vB_Router::getURL();
		$view->access = ($this->content->publicCanView() ?
			$vbphrase['public'] : $vbphrase['public']);

		// Setup a new route to get URLs
		$route = new vBCms_Route_Content();
		$route->node = $this->node->getURLSegment();

		$view->view_url = $route->getCurrentURL(array('action' => vB_Router::getUserAction('vBCms_Controller_Content', 'View')));

		$view->edit_url = $route->getCurrentURL(array('action' => vB_Router::getUserAction('vBCms_Controller_Content', 'EditPage')));
		$view->edit_label = new vB_Phrase('vbcms', 'edit_this_page');

		// New content options
		$view->add_url = $route->getCurrentURL(array('action' => vB_Router::getUserAction('vBCms_Controller_Content', 'AddNode')));
		$view->add_label = new vB_Phrase('vbcms', 'create_new');

		// Get placable contenttypes.  TODO: This should be a method of vB_Types for reuse

		if (!($view->contenttypes = vB_Cache::instance()->read('vbcms_controller_content.place_nonaggs', true, true)))
		{

			$contenttype_collection = new vB_Collection_ContentType();
			$contenttype_collection->filterPlaceable(true);
			$contenttype_collection->filterNonAggregators(true);

			$contenttypes = array();
			$permissionsfrom = $this->content->getPermissionsFrom();
			foreach ($contenttype_collection AS $contenttype)
			{
				$this_type = vBCms_Content::create($contenttype->getPackageClass(), $contenttype->getClass(), 0);

				if ($this_type->canCreateHere($permissionsfrom))
				{
					$title = (string)$contenttype->getTitle();
					$contenttypes[$title] = array('id' => $contenttype->getId(),
																 'title' => $title);
				};
				unset($this_type);
			}
			ksort($contenttypes);
			$view->contenttypes = $contenttypes;
			unset($contenttype_collection, $contenttypes);

			vB_Cache::instance()->write('vbcms_controller_content.place_nonaggs', $view->contenttypes, false, vB_Types::instance()->getContentTypeCacheEvents());
		}



		// Set the publish state description
		if ($this->node->isPublished())
		{
			$view->publish_status = new vB_Phrase('vbcms', 'page_is_published');
		}
		else if ($this->node->getPendingParentId())
		{
			$pending_title = $this->node->getPendingParentTitle();
			$pending_route = vB_Route::create('vBCms_Route_Content')->getCurrentURL(array('node' => $this->node->getPendingParentId()));

			$view->publish_status = new vB_Phrase('vbcms', 'section_x_not_published', $pending_route, $pending_title);
		}
		else if ($date = $this->node->getPublishDate())
		{
			$date = vbdate(vB::$vbulletin->options['dateformat'], $date, true);
			$view->publish_status = new vB_Phrase('vbcms', 'page_will_be_published_x', $date);
		}
		else
		{
			$view->publish_status = new vB_Phrase('vbcms', 'page_not_published');
		}

		$view->can_publish = $this->content->canPublish();
		$view->can_edit = $this->content->canEdit();
		$view->can_create = $this->content->canCreate();

		// Add postid
		$this->addPostId($view);

		return $view;
	}
Beispiel #21
0
function undelete_post($postid, $countposts, $postinfo = NULL, $threadinfo = NULL, $counterupdate = true)
{
	global $vbulletin, $vbphrase;

	// Valid postinfo array will contain: postid, threadid, visible, userid, username, title
	// Invalid post or post is not deleted
	if (!$postinfo AND !$postinfo = fetch_postinfo($postid))
	{
		return;
	}

	// Valid threadinfo array will contain: threadid, forumid, visible, firstpostid
	if (!$threadinfo AND !$threadinfo = fetch_threadinfo($postinfo['threadid']))
	{
		return;
	}

	if ($threadinfo['firstpostid'] == $postid)
	{
		// undelete thread
		undelete_thread($threadinfo['threadid'], $countposts, $threadinfo);
		return;
	}

	// Post is not deleted
	if ($postinfo['visible'] != 2)
	{
		return;
	}

	// Only increment post for a visible thread in a counting forum
	if ($countposts AND $postinfo['userid'] AND $threadinfo['visible'] == 1)
	{
		$userdata =& datamanager_init('User', $vbulletin, ERRTYPE_SILENT);
		$userdata->set_existing($postinfo);
		$userdata->set('posts', 'posts + 1', false);
		$userdata->set_ladder_usertitle_relative(1);
		$userdata->save();
		unset($userdata);
	}

	$deletiondata =& datamanager_init('Deletionlog_ThreadPost', $vbulletin, ERRTYPE_SILENT, 'deletionlog');
	$deletioninfo = array('type' => 'post', 'primaryid' => $postid);
	$deletiondata->set_existing($deletioninfo);
	$deletiondata->delete();
	unset($deletiondata, $deletioninfo);

	$postman =& datamanager_init('Post', $vbulletin, ERRTYPE_SILENT, 'threadpost');
	$postman->set_existing($postinfo);
	$postman->set('visible', 1);
	$postman->save();

	if ($counterupdate)
	{
		build_thread_counters($postinfo['threadid']);
		build_forum_counters($threadinfo['forumid']);
	}

	fetch_phrase_group('threadmanage');
	$postinfo['forumid'] = $threadinfo['forumid'];

	require_once(DIR . '/includes/functions_log_error.php');
	log_moderator_action($postinfo, 'post_y_by_x_undeleted', array($postinfo['title'], $postinfo['username']));
}
Beispiel #22
0
 public function render($current_user, $criteria, $template_name = '')
 {
     global $vbulletin, $vbphrase, $show;
     require_once DIR . '/includes/functions_forumdisplay.php';
     require_once DIR . '/includes/functions_misc.php';
     require_once DIR . '/includes/functions_user.php';
     fetch_phrase_group('search');
     if (!strlen($template_name)) {
         $template_name = 'search_results_postbit';
     }
     /*
     	Post is not a good name for this array, however its what it used to be called
     	(when it wasn't such a bad name) and changing it makes it certain that a lot of
     	hooks are going to break.
     */
     $post = array();
     $thread = $this->post->get_thread();
     $forum = $thread->get_forum();
     $this->set_replydata($this->post->get_field('threadid'), $this->post->get_field('postid'), $current_user);
     if ($this->replydata['mylastpost'] > 0) {
         $post_statusicon[] = 'dot';
     }
     if (!$thread->get_field('open')) {
         $post_statusicon[] = 'lock';
     }
     if ($this->replydata['lastread'] < $thread->get_field('lastpost')) {
         $post_statusicon[] = 'new';
     }
     if (!count($post_statusicon)) {
         $post_statusicon[] = 'old';
     }
     $post_statusicon = implode('_', $post_statusicon);
     $post['postid'] = $this->post->get_field('postid');
     $post['postdateline'] = $this->post->get_field('dateline');
     $post['posttitle'] = vB_Search_Searchtools::stripHtmlTags(htmlspecialchars_decode($this->post->get_display_title()));
     if (empty($post['posttitle'])) {
         $post['posttitle'] = $vbphrase['view_post'];
     }
     $post['visible'] = $this->post->get_field('visible');
     $post['attach'] = $this->post->get_field('attach');
     $post['highlight'] = $criteria->get_highlights();
     $post['userid'] = $this->post->get_field('userid');
     $post['username'] = $this->post->get_field('username');
     $post['threadid'] = $thread->get_field('threadid');
     $post['threadtitle'] = $thread->get_field('title');
     $post['threadiconid'] = $thread->get_field('iconid');
     $post['replycount'] = $thread->get_field('replycount');
     $post['views'] = $thread->get_field('views') > 0 ? $thread->get_field('views') : $thread->get_field('replycount') + 1;
     $post['firstpostid'] = $thread->get_field('firstpostid');
     $post['prefixid'] = $thread->get_field('prefixid');
     $post['taglist'] = $thread->get_field('taglist');
     $post['pollid'] = $thread->get_field('pollid');
     $post['sticky'] = $thread->get_field('sticky');
     $post['open'] = $thread->get_field('open');
     $post['lastpost'] = $thread->get_field('lastpost');
     $post['forumid'] = $thread->get_field('forumid');
     $post['thread_visible'] = $thread->get_field('visible');
     $post['forumtitle'] = $forum->get_field('title');
     $post['posticonid'] = $this->post->get_field('iconid');
     $post['allowicons'] = $forum->allow_icons();
     $post['posticonpath'] = $this->post->get_icon_path();
     $post['posticontitle'] = $this->post->get_icon_title();
     $post['posticon'] = $post['allowicons'] and $post['posticonpath'];
     $lastread = $forum->get_last_read_by_current_user($current_user);
     if ($current_user->hasForumPermission($forum->get_field('forumid'), 'canviewthreads')) {
         if (defined('VB_API') and VB_API === true) {
             $post['pagetext'] = $this->post->get_field('pagetext');
             $post['message_plain'] = build_message_plain($post['pagetext']);
         } else {
             $post['pagetext'] = nl2br($this->post->get_summary(200));
         }
     }
     $show['deleted'] = false;
     if ($current_user->isModerator()) {
         $log = $this->post->get_deletion_log_array();
         if ($log['userid']) {
             $post['del_phrase'] = $vbphrase['message_deleted_by_x'];
         } else {
             $log = $thread->get_deletion_log_array();
             if (!$log['userid']) {
                 $post['del_phrase'] = $vbphrase['thread_deleted_by_x'];
                 $log = false;
             }
         }
         if ($log) {
             $post['del_username'] = $log['username'];
             $post['del_userid'] = $log['userid'];
             $post['del_reason'] = $log['reason'];
             $show['deleted'] = true;
         }
     }
     $post['prefixid'] = $thread->get_field('prefixid');
     if ($post['prefixid']) {
         $post['prefix_plain_html'] = htmlspecialchars_uni($vbphrase["prefix_{$post['prefixid']}_title_plain"]);
         $post['prefix_rich'] = $vbphrase["prefix_{$post['prefixid']}_title_rich"];
     } else {
         $post['prefix_plain_html'] = '';
         $post['prefix_rich'] = '';
     }
     $show['disabled'] = !$this->can_inline_mod($current_user);
     $postuser = $this->post->get_record();
     $post = process_thread_array($post, $lastread, $post['allowicons']);
     ($hook = vBulletinHook::fetch_hook('search_results_postbit')) ? eval($hook) : false;
     $template = vB_Template::create($template_name);
     $template->register('post', $post);
     $template->register('userinfo', $postuser);
     $template->register('threadinfo', $thread->get_record());
     $template->register('dateline', $this->post->get_field('dateline'));
     if ($vbulletin->options['avatarenabled']) {
         $template->register('avatar', fetch_avatar_from_record($this->post->get_record(), true));
     }
     $pageinfo_thread = array();
     $pageinfo_post = array('p' => $post['postid']);
     if (!empty($post['highlight'])) {
         $pageinfo_post['highlight'] = urlencode(implode(' ', $post['highlight']));
         $pageinfo_thread['highlight'] = urlencode(implode(' ', $post['highlight']));
     }
     $template->register('pageinfo_post', $pageinfo_post);
     $template->register('pageinfo_thread', $pageinfo_thread);
     $template->register('post_statusicon', $post_statusicon);
     return $template->render();
 }
Beispiel #23
0
	public function getConfigEditorView()
	{
		require_once DIR . '/includes/functions_databuild.php';
		fetch_phrase_group('posting');

		$config = $this->widget->getConfig();

		require_once DIR . '/includes/functions_editor.php';
		construct_edit_toolbar($config['html'], false, new vBCms_Editor_Override(vB::$vbulletin), true, true, false, 'cms_article');

		return $GLOBALS['messagearea'];
	}
Beispiel #24
0
 private function showCategoryOptions($selected)
 {
     global $vbphrase;
     require_once DIR . '/includes/functions_databuild.php';
     fetch_phrase_group('search');
     $categories = fetch_socialgroup_category_options(false);
     if (!is_array($selected)) {
         $selected = array($selected);
     }
     if (count($categories) > 0) {
         $select = render_option_template($vbphrase['any_category'], '', !count($selected) ? 'selected="selected"' : '');
         foreach ($categories as $categoryid => $category) {
             $select .= render_option_template(htmlspecialchars_uni($category['title']), $categoryid, in_array($categoryid, $selected) ? 'selected="selected"' : '');
         }
         return $select;
     } else {
         return false;
     }
 }
Beispiel #25
0
	/**
	 * Produces the configuration overlay for table tags.
	 *
	 * @return string
	 */
	public function actionTableOverlay()
	{
		$view = new vB_View_AJAXHTML('vbcms_editor_table_overlay');
		$properties = array(
			'type' => vB::$vbulletin->input->clean_gpc('p', 'type', vB_Input::TYPE_STR)
		);

		$formview = new vB_View('vbcms_editor_table_overlay');
		$formview->addArray($properties);
		$view->setContent($formview);

		// need posting group
		require_once DIR . '/includes/functions_databuild.php' ;
		fetch_phrase_group('posting');

		return $view->render(true);
	}
Beispiel #26
0
	/**
	 * Returns the config view for the widget.
	 *
	 * @return vBCms_View_Widget				- The view result
	 */
	public function getConfigView($widget = false)
	{
		require_once DIR . '/includes/functions_databuild.php';
		fetch_phrase_group('cpcms');
		fetch_phrase_group('search');

		$this->assertWidget();

		vB::$vbulletin->input->clean_array_gpc('r', array(
			'do'      => vB_Input::TYPE_STR,
			'forumchoice' => vB_Input::TYPE_ARRAY,
			'template_name' => vB_Input::TYPE_STR,
			'cache_ttl' => vB_Input::TYPE_INT,
			'days' => vB_Input::TYPE_INT,
			'allow_html' => vB_Input::TYPE_INT,
			'count'    => vB_Input::TYPE_INT
		));

		$view = new vB_View_AJAXHTML('cms_widget_config');
		$view->title = new vB_Phrase('vbcms', 'configuring_widget_x', $this->widget->getTitle());

		$config = $this->widget->getConfig();

		if ((vB::$vbulletin->GPC['do'] == 'config') AND $this->verifyPostId())
		{
			$widgetdm = new vBCms_DM_Widget($this->widget);

			if (vB::$vbulletin->GPC_exists['template_name'])
			{
				$config['template_name'] = vB::$vbulletin->GPC['template_name'];
			}

			//make sure we have actual values for forumchoice
			if (vB::$vbulletin->GPC_exists['forumchoice'])
			{
				$config['forumchoice'] = vB::$vbulletin->GPC['forumchoice'];
			}

			if (vB::$vbulletin->GPC_exists['count'])
			{
				$config['count'] = vB::$vbulletin->GPC['count'];
			}

			if (vB::$vbulletin->GPC_exists['days'])
			{
				$config['days'] = vB::$vbulletin->GPC['days'];
			}

			if (vB::$vbulletin->GPC_exists['cache_ttl'])
			{
				$config['cache_ttl'] = vB::$vbulletin->GPC['cache_ttl'];
			}

			if (vB::$vbulletin->GPC_exists['template_name'])
			{
				$config['template_name'] = vB::$vbulletin->GPC['template_name'];
			}

			$config['allow_html'] = vB::$vbulletin->GPC_exists['allow_html'] ? 1 : 0;
			$widgetdm->set('config', $config);

			if ($this->content)
			{
				$widgetdm->setConfigNode($this->content->getNodeId());
			}

			$widgetdm->save();

			if (!$widgetdm->hasErrors())
			{
				if ($this->content)
				{
					$segments = array('node' => $this->content->getNodeURLSegment(),
										'action' => vB_Router::getUserAction('vBCms_Controller_Content', 'EditPage'));
					$view->setUrl(vB_View_AJAXHTML::URL_FINISHED, vBCms_Route_Content::getURL($segments));
				}

				$view->setStatus(vB_View_AJAXHTML::STATUS_FINISHED, new vB_Phrase('vbcms', 'configuration_saved'));
			}
			else
			{
				if (vB::$vbulletin->debug)
				{
					$view->addErrors($widgetdm->getErrors());
				}

				// only send a message
				$view->setStatus(vB_View_AJAXHTML::STATUS_MESSAGE, new vB_Phrase('vbcms', 'configuration_failed'));
			}
		}
		else
		{
			// add the config content
			$configview = $this->createView('config');

			if (!isset($config['template_name']) OR ($config['template_name'] == '') )
			{
				$config['template_name'] = 'vbcms_widget_staticbb_page';
			}
			// add the config content
			$configview->template_name = $config['template_name'];
			$configview->forumchoice_select = $this->getForums($config);
			$configview->days = $config['days'];
			$configview->count = $config['count'];
			$this->addPostId($configview);
			$configview->cache_ttl = $config['cache_ttl'];
			$configview->allow_html = $config['allow_html'];

			$view->setContent($configview);

			// send the view
			$view->setStatus(vB_View_AJAXHTML::STATUS_VIEW, new vB_Phrase('vbcms', 'configuring_widget'));
		}

		return $view;
	}
Beispiel #27
0
	/**
	 * Fetches a rich page view of the specified content item.
	 * This method can accept parameters from the client code which are usually
	 * derived from user input.  Parameters are passed as an array in the order that
	 * they were received.  Parameters do not normally have assoc keys.
	 *
	 * Note: Parameters are always passed raw, so ensure that validation and
	 * escaping is performed where required.
	 *
	 * Skip permissions should allow content to be rendered regardless of the
	 * current user's permissions.
	 *
	 * Child classes will inevitably override this with wildly different
	 * implementations.
	 *
	 * @param array mixed $parameters			- Request parameters
	 * @param bool $skip_permissions			- Whether to skip can view permission checking
	 * @return vB_View | bool					- Returns a view or false
	 */
	public function getInlineEditBodyView($parameters = false)
	{
		global $vbphrase;
		require_once DIR . '/includes/functions_databuild.php' ;
		fetch_phrase_group('cpcms');

		//confirm that the user has edit rights
		if (!$this->content->canEdit())
		{
			return $vb_phrase['no_edit_permissions'];
		}

		if ($_REQUEST['do'] == 'delete')
		{
			$dm = $this->content->getDM();
			$dm->delete();
			$this->cleanContentCache();
			return $vbphrase['item_deleted'];
		}

		// Load the content item
		if (!$this->loadContent($this->getViewInfoFlags(self::VIEW_PAGE )))
		{
			throw (new vB_Exception_404());
		}
		if ($_REQUEST['do'] == 'apply' OR $_REQUEST['do'] == 'update' OR $_REQUEST['do'] == 'movenode')
		{
			$this->SaveData();
		}

		// Create view
		$view = $this->createView('inline', self::VIEW_PAGE);

		// Add the content to the view
		$this->populateViewContent($view, self::VIEW_PAGE, false);

		// Check if inline form was submitted
		// postback content

		// TODO: Don't need to escape this with new template syntax
		$view->formid = 'cms_statichtml_data';

		$view->type = new vB_Phrase('vbcms', 'statichtml');
		$view->adding = 	new vB_Phrase('cpcms', 'adding_x', $vbphrase['article']);
		$view->typetitle = $this->content->getTypeTitle();
		$view->metadata = $this->content->getMetadataEditor();
		$view->comments_enabled = ($this->content->getComments_Enabled());
		$segments = array('node' => $this->content->getUrlSegment(),
							'action' => vB_Router::getUserAction('vBCms_Controller_Content', 'View'));
		$view->view_url = vBCms_Route_Content::getURL($segments);
		// Add URL to submit to
		$segments = array('node' => $this->content->getUrlSegment(),
							'action' => vB_Router::getUserAction('vBCms_Controller_Content', 'EditPage'));
		$view->submit_url = vBCms_Route_Content::getURL($segments);
		$segments = array('node' => $this->content->getUrlSegment(),
							'action' => vB_Router::getUserAction('vBCms_Controller_Content', 'View'));
		$view->editbar = $this->content->getEditBar($view->submit_url, vBCms_Route_Content::getURL($segments), $view->formid);
		$view->publisher = $this->content->getPublishEditor($view->submit_url, $view->formid);
		$view->show_threaded = true;
		$view->per_page = 10;

		$this->addPostId($view);

		return $view;
	}
Beispiel #28
0
	/**
	 * Initialisation.
	 * Initialises the view, templaters and all other necessary objects for
	 * successfully creating the response.
	 */
	protected function initialize()
	{
		// Setup the templater.  Even XML output needs this for the html response
		//First we need a node from which we can get a style.

		//We need to set sectionid, style, and layout
		global $vbphrase;
		require_once DIR . '/includes/functions_databuild.php';
		fetch_phrase_group('vbcms');

		//we are going to use simple paging, so let' limit the number of records return.

		if (count($this->segments) < 2)
		{
			$value = 1;
		}
		else
		{
			$value = max(1, intval($this->segments['value']));
			}
			switch($this->segments['type'])
		{
			case 'author':
				//if we were passed a parameter for fromsection, we use that.
				//or it could be the fourth parameter.
				vB::$vbulletin->input->clean_array_gpc('r', array(
					'fromsection' => TYPE_INT,
					'sectionid' => TYPE_INT,
					));


				$this->query_filter = " AND node.userid = " . intval($value);

				if (vB::$vbulletin->GPC_exists['fromsection'] AND intval(vB::$vbulletin->GPC['fromsection']))
				{
					$displaysectionid = intval(vB::$vbulletin->GPC['fromsection']);
				}
				//we haven't got a section.
				else $displaysectionid = "SELECT MIN(nodeid) AS nodeid FROM " . TABLE_PREFIX . "cms_node WHERE
					parentnode IS NULL";
				;
				if ($record = vB::$vbulletin->db->query_first("SELECT username FROM " .TABLE_PREFIX .
					"user WHERE userid = $value" ))
				{
					$this->title = $record['username'];
					$this->urlstring = $this->title;
				}
				$this->result_type = $vbphrase['author'];
				break;
			case 'section':

				$this->query_filter = " AND node.parentnode = " . $value;
				$displaysectionid = $value;


				if ($record = vB::$vbulletin->db->query_first("SELECT title FROM " .TABLE_PREFIX .
					"cms_nodeinfo WHERE nodeid = $value" ))
				{
					$this->title = $record['title'];
					$this->urlstring = urlencode($this->title);
				}

				$this->result_type = $vbphrase['section'];
				break;

			case 'category':

				$record = vB::$vbulletin->db->query_first("SELECT category, parentnode FROM " .TABLE_PREFIX .
				"cms_category WHERE categoryid = $value") ;
				if (!$record)
				{
					$record = vB::$vbulletin->db->query_first("SELECT category, parentnode, categoryid FROM " .TABLE_PREFIX .
					"cms_category LIMIT 1") ;
					if ($record)
					{
						$this->segments['value'] = $value = $record['categoryid'];
					}

				}
				if (!$record)
				{
					throw (new vB_Exception_User(new vB_Phrase('error', 'no_categories_defined')));
				}
				$this->joins = " INNER JOIN " . TABLE_PREFIX . "cms_nodecategory AS nodecat ON nodecat.nodeid = node.nodeid
						 AND nodecat.categoryid = $value" ;

				$this->title = $record['category'];
				$this->urlstring = urlencode($record['category']);
				$displaysectionid = $record['parentnode'];

				$this->result_type = $vbphrase['category'];
				break;

			case 'day':
				//Here we displaying for a specific day. We need to get the date range for the
				//where clause. We have nothing to set the $displaysectionid, so set it to false
				$displaysectionid = false;

				//default date to today
				if (! (intval($value) > 1000000))
				{
					$value = TIMENOW;
				}

				$this->query_filter = " AND node.setpublish > 0 AND (node.publishdate BETWEEN $value  AND " .
					 ($value + 86399) . ") " ;
				$this->title = vbdate( vB::$vbulletin->options['dateformat'], $value);
				$this->urlstring = urlencode($value);

				$displaysectionid = "SELECT MIN(nodeid) AS nodeid FROM " . TABLE_PREFIX . "cms_node WHERE
					parentnode IS NULL";
				$this->result_type = $vbphrase['date'];
				break;

			default:
				//we haven't got a section.
				$displaysectionid = "SELECT MIN(nodeid) AS nodeid FROM " . TABLE_PREFIX . "cms_node WHERE
					parentnode IS NULL";
				;
				if ($record = vB::$vbulletin->db->query_first("SELECT title FROM " .TABLE_PREFIX .
					"cms_nodeinfo WHERE nodeid = ($displaysectionid)"))
				{
					$this->title = $record['title'];
					$this->result_type = $vbphrase['section'];
					$this->urlstring = urlencode($this->title );
				}
				$this->result_type = $vbphrase['section'];
			;
		} // switch

		if (! is_numeric($displaysectionid) )
		{

			$record = vB::$vbulletin->db->query_first($displaysectionid);
			$displaysectionid = $record['nodeid'];
		}

		$rst = vB::$vbulletin->db->query_read("SELECT parent.nodeid, parent.styleid, parent.layoutid from " .
			TABLE_PREFIX . "cms_node AS node	INNER JOIN " . TABLE_PREFIX .
			"cms_node AS parent ON (node.nodeleft >= parent.nodeleft AND node.nodeleft <= parent.noderight)
			   WHERE node.nodeid = " . $displaysectionid . "
			 ORDER BY parent.nodeleft DESC ;");

		$record = vB::$vbulletin->db->fetch_array($rst);

		$this->sectionid = $record['nodeid'];

		$node = vBCms_Item_Content::create('vBCms', 'Section', $displaysectionid);

		if (! $node->canView())
		{
			throw (new vB_Exception_AccessDenied());
		}
		$node->requireInfo(vBCms_Item_Content::INFO_NODE);
		vBCms_NavBar::prepareNavBar($node);

		while($record)
		{
			if (intval($record['layoutid']) AND !intval($this->layoutid))
			{
				$this->layoutid = $record['layoutid'];
			}
			if (intval($record['styleid']) AND !intval($this->styleid))
			{
				$this->styleid = $record['styleid'];
			}

			if (intval($this->layoutid))
			{
				$this->displaysectionid = $displaysectionid;
				return;
			}

			$record = vB::$vbulletin->db->fetch_array($rst);
		}

		if (!intval($this->styleid))
		{
			$this->styleid = vB::$vbulletin->options['styleid'];
		}

		if (!intval($this->layoutid))
		{
			$this->layoutid = 1;
		}

	}
Beispiel #29
0
	/**
	 * Returns the config view for the widget.
	 *
	 * @return vBCms_View_Widget				- The view result
	 */
	public function getConfigView()
	{
		require_once DIR . '/includes/functions_databuild.php';
		fetch_phrase_group('cpcms');
		$this->assertWidget();

		vB::$vbulletin->input->clean_array_gpc('r', array(
			'do'            => vB_Input::TYPE_STR,
			'url'           => vB_Input::TYPE_STR,
			'template_name' => vB_Input::TYPE_STR,
			'use_rss_title' => vB_Input::TYPE_BOOL,
			'max_items'		 => vB_Input::TYPE_INT,
		));

		$view = new vB_View_AJAXHTML('cms_widget_config');
		$view->title = new vB_Phrase('vbcms', 'configuring_widget_x', $this->widget->getTitle());
		$config = $this->widget->getConfig();

		if ((vB::$vbulletin->GPC['do'] == 'config') AND $this->verifyPostId())
		{
			$config['url'] = convert_urlencoded_unicode(vB::$vbulletin->GPC['url']);
			$config['use_rss_title'] = vB::$vbulletin->GPC['use_rss_title'];

			if (vB::$vbulletin->GPC_exists['template_name'])
			{
				$config['template_name'] = vB::$vbulletin->GPC['template_name'];
			}

			if (vB::$vbulletin->GPC_exists['max_items'])
			{
				$config['max_items'] = vB::$vbulletin->GPC['max_items'];
			}
			$widgetdm = $this->widget->getDM();
			$widgetdm->set('config', $config);

			if ($this->content)
			{
				$widgetdm->setConfigNode($this->content->getNodeId());
			}

			$widgetdm->save();

			if (!$widgetdm->hasErrors())
			{
				if ($this->content)
				{
					$segments = array('node' => $this->content->getNodeURLSegment(),
										'action' => vB_Router::getUserAction('vBCms_Controller_Content', 'EditPage'));
					$view->setUrl(vB_View_AJAXHTML::URL_FINISHED, vBCms_Route_Content::getURL($segments));
				}

				$view->setStatus(vB_View_AJAXHTML::STATUS_FINISHED, new vB_Phrase('vbcms', 'configuration_saved'));
			}
			else
			{
				if (vB::$vbulletin->debug)
				{
					$view->addErrors($widgetdm->getErrors());
				}

				// only send a message
				$view->setStatus(vB_View_AJAXHTML::STATUS_MESSAGE, new vB_Phrase('vbcms', 'configuration_failed'));
			}
		}
		else
		{
			// add the config content
			$configview = $this->createView('config');

			if (!isset($config['template_name']) OR ($config['template_name'] == '') )
			{
				$config['template_name'] = 'vbcms_widget_rss_page';
			}
			// add the config content
			$configview->use_rss_title = $config['use_rss_title'];
			$configview->template_name = $config['template_name'];
			$configview->max_items = $config['max_items'];
			$configview->url = $config['url'] ? htmlspecialchars_uni($config['url']) : $config['url'];

			// item id to ensure form is submitted to us
			$this->addPostId($configview);

			$view->setContent($configview);

			// send the view
			$view->setStatus(vB_View_AJAXHTML::STATUS_VIEW, new vB_Phrase('vbcms', 'configuring_widget'));
		}

		return $view;
	}
Beispiel #30
0
	/**
	 * function to return the rendered html for this result
	 *
	 * @param object legacy user object
	 * @param object criteria object
	 * @param string override default template name
	 *
	 * @return string html of the rendered template
	 */
	public function render($current_user, $criteria, $template_name = '')
	{
		global $vbulletin, $vbphrase, $show;

		fetch_phrase_group('search');

		// grab data
		$post = $this->get_post()->get_record();
		$article = $this->article->get_record();

		// create template
		if (!strlen($template_name)) {
			$template_name = 'search_results_cmscomment';
		}
		$template = vB_Template::create($template_name);

		// main comment article info block
		$article_url = vB_Route::create('vBCms_Route_Content', $article['nodeid'].'-'.$article['url'])->getCurrentURL();
		$join_char = strpos($article_url,'?') ? '&amp;' : '?';
		$comment_url = $article_url . $join_char . "commentid=" . $post['postid'] . "#post" . $post['postid'];

		$template->register('article_url', $article_url);
		$template->register('comment_url', $comment_url);
		$template->register('article_title', $article['title']);
		$template->register('pagetext', nl2br($this->get_post()->get_summary(40)));

		// comment post info
		$template->register('userinfo', $current_user->get_record());
		$template->register('username', $post['username']);
		$template->register('postid', $post['postid']);
		$template->register('postdate', vbdate($vbulletin->options['dateformat'], $post['dateline'], true));
		$template->register('postdatetime', vbdate($vbulletin->options['timeformat'], $post['dateline']));


		// get deleted moderation data
		$show['deleted'] = false;
		if ($current_user->isModerator())
		{
			$del_array = array();
			$log = $this->get_post()->get_deletion_log_array();
			if ($log['userid'])
			{
				$del_array['del_phrase'] = $vbphrase['message_deleted_by_x'];
			}
			else
			{
				$log = $this->get_post()->get_thread()->get_deletion_log_array();
				if (!$log['userid'])
				{
					$del_array['del_phrase'] = $vbphrase['thread_deleted_by_x'];
					$log = false;
				}
			}

			if ($log)
			{
				$del_array['del_username'] = $log['username'];
				$del_array['del_userid'] = $log['userid'];
				$del_array['del_reason'] = $log['reason'];
				$template->register('del_array', $del_array);
				$show['deleted'] = true;
			}
		}

		// stats
		$template->register('viewcount', $article['viewcount']);
		$template->register('replycount', $article['replycount']);

		// last comment post info
		$lastpost_userinfo = array(
			'lastposterid' => $article['lastposterid'],
			'lastposter' => $article['lastposter']
		);
		$template->register('lastpost_userinfo', $lastpost_userinfo);
		$template->register('lastpostdate', vbdate($vbulletin->options['dateformat'], $article['lastpost'], true));
		$template->register('lastpostdatetime', vbdate($vbulletin->options['timeformat'], $article['lastpost']));

		return $template->render();
	}