Beispiel #1
0
String CommentableObjectViewer::getCreatePostLink(const EntityID &quoted_object)
{
	ordered_map<std::wstring, std::wstring> params;
	params.set(OS_URL_PARAM_ACTION, conversions::to_wstring<uint32>(actCreatePost));

	if(quoted_object.empty() == false)
		params.set(OS_URL_PARAM_QUOTE, quoted_object.toWide());

	return getPortal()->getViewObjectLink(getEntityID(), params);
}
Beispiel #2
0
void CommentableObjectViewer::onInit()
{
	ControlBase::onInit();

	EntityID target = static_cast<String>(getRequest()->getUrlParam(OS_URL_PARAM_TARGET)).to_ascii();
	if(target.validate(false))
	{
		String href = localizePost(target);
		if(href.empty() == false)
		{
			getSession()->redirect(href.to_ascii());
			return;
		}
	}
}
Beispiel #3
0
//bool EntitiesEntity::_loadObject(const shared_ptr<IPortalDatabase> &database, shared_ptr<ObjectsIRevisionable> object)
bool EntitiesEntity::load(const shared_ptr<IPortalDatabase> &database, const EntityID & id)
{
	OS_TIMER_PERFORMANCE(TP, _S("Entity::_loadObject"));
	OS_LOCK(m_cs);

#ifndef OS_TODOCIP
	shared_ptr<ObjectsIRevisionable> object = objects_revisionable_cast(database->getPortal()->getObject(database, id.toUTF16()));
	m_primary = object;
	//OS_ASSERT(getEntityID() == id);
#endif

	if(database->getPortal()->getSnapshotManager()->m_enableEnsureLoadingEntity)
		database->getPortal()->getSnapshotManager()->ensure(database, id);

	DataTable result;
	// TOCLEAN_SNAPSHOT_SCORE
	//String sql = String::format(_S("select current,visible,score,depth,parent,section,stability_date from os_snapshot_objects where reference='%S'").c_str(), m_primary->id->toUTF16().c_str());
	String sql = String::format(_S("select type,current,visible,depth,parent,section,stability_date from os_snapshot_objects where entity='%S'").c_str(), id.toUTF16().c_str());
	database->execute(sql, result);
	if(!result.hasRow(0))
	{
		clear();
		return false;
	}
	else
	{
		ObjectID currentID = static_cast<String>(result.get(0,_S("current"))).to_ascii();
		m_type = Convert::toObjectType(static_cast<uint32>(result.get(0,_S("type"))));
		m_visible = result.get(0,_S("visible"));
		//m_score = *result.get(0,_S("score")); // TOCLEAN_SNAPSHOT_SCORE
		m_depth = result.get(0,_S("depth"));
		m_parent = static_cast<String>(result.get(0,_S("parent"))).to_ascii();
		m_section = static_cast<String>(result.get(0,_S("section"))).to_ascii();
		m_stabilityDate = String(result.get(0,_S("stability_date")));

		if(id == ObjectsSystem::instance()->getRootID())
			//m_current = objects_revisionable_cast(database->getPortal()->getObject(database, ObjectsSystem::instance()->getRootID().toObjectID()));
			m_current = ObjectsSection::getRootSection();
		else
		{		
#ifdef OS_TODOCIP
			/*
			if(currentID.empty())
				return false;
			m_current = objects_revisionable_cast(database->getPortal()->getObject(database, currentID));
			if(m_current == nullptr)
				return false;				
			*/

			if(currentID.empty() == false)
				m_current = objects_revisionable_cast(database->getPortal()->getObject(database, currentID));
#else
			if(currentID.empty())
			{
				m_current.reset();
				// OS_ASSERT(m_parent == ObjectsSystem::instance()->getSkippedID());
				// No, dato che la getEntity non fa + l'ensure, può succedere che carica un oggetto non stabilizzato.
				m_visible = false;
			}
			else
				m_current = objects_revisionable_cast(database->getPortal()->getObject(database, currentID));
#endif
		}

		return true;
	}
}
Beispiel #4
0
String OMLQuote::quoteObject(const EntityID &id, const String &content)
{
	OS_ASSERT(id.empty() == false);
	return String::format(_S("[quote id=%S]%S[/quote]").c_str(), id.toUTF16().c_str(), content.c_str());
}
Beispiel #5
0
bool OsirisLink::isValid() const
{
	bool valid = true;
	
	if(getParam("type") == OS_OSIRISLINK_TYPE_PORTAL)
	{
		if(hasParam("portal") == false)
			return false;
		
		PortalID portal = static_cast<String>(getParam("portal")).to_ascii();
		if(portal.validate(false) == false)
			return false;

#ifdef OS_OSIRIS_VERSION_RAZOR
		if(hasParam("pov") == false)
			return false;

		PovID pov = static_cast<String>(getParam("pov")).to_ascii();
		if(pov.empty())
			return false;		
#endif
	}
	else if(getParam("type") == OS_OSIRISLINK_TYPE_ISIS)
	{
		if(hasParam("portal") == false)
			return false;
		
		PortalID portal = static_cast<String>(getParam("portal")).to_ascii();
		if(portal.validate(false) == false)
			return false;

#ifdef OS_OSIRIS_VERSION_RAZOR
		if(hasParam("pov") == false)
			return false;

		PovID pov = static_cast<String>(getParam("pov")).to_ascii();
		if(pov.empty())
			return false;		
#endif

		if(hasParam("name") == false)
			return false;		

		if(hasParam("url") == false)
			return false;

		// TODO: check if is a url.
	}
	else if(getParam("type") == OS_OSIRISLINK_TYPE_FILE)
	{
		if(hasParam("id") == false)
			return false;		

		EntityID id = static_cast<String>(getParam("id")).to_ascii();
		if(id.empty())
			return false;
				
		if(hasParam("portal"))
		{
			PortalID portal = static_cast<String>(getParam("portal")).to_ascii();
			if(portal.validate(false) == false)
				return false;
		}

#ifdef OS_OSIRIS_VERSION_RAZOR
		if(hasParam("pov"))
		{
			PovID pov = static_cast<String>(getParam("pov")).to_ascii();
			if(pov.empty())
				return false;		
		}
#endif	
	}
	else if(getParam("type") == OS_OSIRISLINK_TYPE_URL)
	{
		if(hasParam("url") == false)
			return false;		

		// TODO: check if is a url	
	}
	else if(getParam("type") == OS_OSIRISLINK_TYPE_RES)
	{
		if(hasParam("path") == false)
			return false;

		// We don't check if is a path.
	}
	else
		return false;

	return true;
}
Beispiel #6
0
 inline bool operator >(const EntityID & p_ID) const
 {
     return this->getValue() > p_ID.getValue();
 }
Beispiel #7
0
ObjectID ObjectsSystem::getVirtualObjectID(const EntityID & id) const
{
	return "03020002" + id.getString();
}