Ejemplo n.º 1
0
	/**
	 * Main entry point for the controller.
	 *
	 * @return string							- The final page output
	 */
	public function actionPublishNode()
	{
		// Create AJAX view for html replacement
		$view = new vB_View_AJAXHTML('cms_publish_view');
		$view->title = new vB_Phrase('vbcms', 'publishing_page');

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

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

			$nodedm = new vBCms_DM_Node();
			$nodedm->setExisting($this->node);
			$nodedm->set('publishdate', vB::$vbulletin->GPC['publishdate']);

			if (!$nodedm->save())
			{
				$view->addErrors($nodedm->getErrors());
				return $this->saveError($view, 'Node DM save failed');
			}

			//We need to see if we have a content node to index.
			$contenttypeid = $this->node->getContenttypeId();
			$index_controller = vB_Search_Core::get_instance()->get_index_controller_by_id($contenttypeid);

			if (!($index_controller instanceof vb_Search_Indexcontroller_Null))
			{
				$classinfo = vB_Types::instance()->getContentClassFromId($contenttypeid);
				vB_Search_Indexcontroller_Queue::indexQueue($classinfo['package'], $classinfo['class'], 'index', $this->node->getId());
			}

			$published = ($publishdate AND ($publishdate <= TIMENOW));

			if ($published != $this->node->isPublished())
			{
				$finishurl = vBCms_Route_Content::getURL(array('node' => $this->node->getNodeId(), 'action' => vB_Router::getUserAction('vBCms_Controller_Content', 'View')));
				$view->setUrl(vB_View_AJAXHTML::URL_FINISHED, $finishurl);
			}

			$status_phrase = new vB_Phrase('vbcms', $published ? 'page_published' : 'page_unpublished');
			$view->setStatus(vB_View_AJAXHTML::STATUS_FINISHED, $status_phrase);
		}
		else
		{
			// get the delete view
			$publishview = new vB_View('vbcms_publish_form');

			// add datepicker for date
			$publishview->datepicker = new vB_View_DatePicker();
			$publishview->datepicker->setDate($this->node->getPublishDate());
			$publishview->datepicker->setLabel(new vB_Phrase('vbcms', 'publish_date'));
			$publishview->datepicker->setDateVar('publishdate');

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

			// add form to the html replacement output
			$view->setContent($publishview);

			// send the view
			// TODO: update overlay handler to accept an empty status
			$view->setStatus(vB_View_AJAXHTML::STATUS_VIEW, '&nbsp;');
		}

		return $view->render(true);
	}
Ejemplo n.º 2
0
	/**
	* Additional tasks to perform after a delete.
	*
	* @param mixed								- The result of execDelete()
	*/
	function postDelete($result)
	{
		$this->assertItem();

		$nodeid = intval($this->item->getNodeId());

		$nodedm = new vBCms_DM_Node();
		$nodedm->setExisting($nodeid);
		$nodedm->set('nodeid', $nodeid);
		$nodedm->removeRating(intval($this->item->getVote()));
		$nodedm->save();

		return $result;
	}