예제 #1
0
/*
shared_ptr<Portal> PortalsSystem::createPortal(shared_ptr<PortalOptions> options) // TOCLEAN
{
	options->setPortalID(PortalID::generate());

	
	Buffer public_key;
	Buffer private_key;

	// Genera la coppia di chiavi dell'amministratore
	if(CryptManager::instance()->rsaGenerateKeys(rsaType2048, private_key, public_key) == false)
		return false;
	

	//PortalAccess access = options->getPassword().empty() ? portalAccessPublic : portalAccessPrivate;
	//options->setPortalID(PortalID::generateAnarchic(access));
	

	
	if(options->getPortalID().empty())
		options->setPortalID(PortalID::generateAnarchic(access));
	
	if(options->getUserID().empty())
	{
		// Create account
		shared_ptr<IdeAccount> account = IdeAccountsManager::instance()->createAccount(OS_DEFAULT_ADMIN_USERNAME, OS_DEFAULT_ADMIN_PASSWORD, true);
		if(account == nullptr)
		{
			OS_LOG_ERROR("Cannot create account");
			return false;
		}

		Buffer publicKey;
		account->getAccount()->decodePublicKey(OS_DEFAULT_ADMIN_PASSWORD, publicKey);
		options->setUserID(DataAccount::getReferenceUser(publicKey));
	}
	
			
	shared_ptr<Portal> portal = subscribePortal(options);
	if(portal == nullptr)
	{
		OS_LOG_ERROR("Cannot create portal");
		return nullptr;
	}

	return portal;
}
*/
shared_ptr<Portal> PortalsSystem::subscribePortal(shared_ptr<PortalOptions> options)
{
	OS_LOCK(m_cs);

	if(options == nullptr)
	{
		OS_ASSERTFALSE();
		return nullptr;
	}

	PortalID id = options->getPortalID();
	if(id.empty())
	{
		id = PortalID::generate();		
		options->setPortalID(id);
	}

	PovID pov = options->getPovID();
	if(pov.empty())
		return nullptr;
	
	//if(id.getType() != ID::idPortal || id.validate(false) == false)
	//	return nullptr;

	String fullPov = Portal::generatePovID(id, pov);

	if(getPortal(id, pov) != nullptr)
		return nullptr;

	if(options->getDatabaseName().empty())
		options->setDatabaseName(fullPov);

	if(options->validate() == false)
		return nullptr;

	String folder = utils::standardisePath(getPath() + fullPov);

	if(FileSystem::instance()->exists(folder))
	{
		OS_LOG_ERROR(String::format(_S("Folder '%S' already exists").c_str(), folder.c_str()));
		return nullptr;
	}

	// Assicura che la root dei portali esista
	FileSystem::instance()->createDirectory(getPath());
	// Crea la root del portale
	if(FileSystem::instance()->createDirectory(folder) == false)
	{
		OS_LOG_ERROR(String::format(_S("Cannot create folder '%S'").c_str(), folder.c_str()));
		return nullptr;
	}

	// Crea il portale
	if(_setupPortal(options, folder) == false)
	{
		FileSystem::instance()->removeDirectory(folder);
		return nullptr;
	}

	return _loadPortal(folder, false, true);
}
예제 #2
0
bool CompatibilityManager::razorPortalDatabaseUpgrade(const shared_ptr<IPortalDatabase> &database)
{
	PovID povID = database->getPortal()->getPovID();
#ifdef OS_NOOBJECTID
	ObjectID userID = povID;
#else
	ObjectID userID = ObjectID::generate(portalObjectTypeUser, povID.getString());
#endif

	migrateAccounts(database);

	
	String portalName = database->getPortal()->getOptions()->getName();
	String portalDescription = static_cast<String>(database->getPortal()->getOptions()->getOptionValue("description"));

	// Clean old snapshot
	database->execute(_S("delete from os_snapshot_objects"));
	database->execute(_S("delete from os_snapshot_users"));
	//database->execute(_S("delete from os_snapshot_profiles"));
	database->execute(_S("delete from os_discussions_stats"));
	//database->execute(_S("delete from os_forums_forum_stats"));
	//database->execute(_S("delete from os_forums_section_stats"));
	database->execute(_S("delete from os_polls_stats"));
	database->execute(_S("delete from os_polls_options_stats"));
	database->execute(_S("delete from os_users_stats"));

	// Old
	database->execute(_S("drop table if exists os_forums_forum_stats"));
	database->execute(_S("drop table if exists os_forums_section_stats"));

	// Reset acceptable
	database->execute(_S("update os_entries set rank=-2"));

	// Clean signatures
	database->execute(_S("update os_attributes set signature=x'00'"));
	database->execute(_S("update os_avatars set signature=x'00'"));
	database->execute(_S("update os_calendar_events set signature=x'00'"));
	database->execute(_S("update os_files set signature=x'00'"));
	database->execute(_S("update os_instances set signature=x'00'"));
	database->execute(_S("update os_models set signature=x'00'"));
	database->execute(_S("update os_polls set signature=x'00'"));
	database->execute(_S("update os_polls_options set signature=x'00'"));
	database->execute(_S("update os_polls_votes set signature=x'00'"));
	database->execute(_S("update os_posts set signature=x'00'"));
	database->execute(_S("update os_private_messages set signature=x'00'"));
	database->execute(_S("update os_reputations set signature=x'00'"));
	database->execute(_S("update os_sections set signature=x'00'"));
	database->execute(_S("update os_tags set signature=x'00'"));
	database->execute(_S("update os_texts set signature=x'00'"));
	database->execute(_S("update os_users set signature=x'00'"));
	database->execute(_S("update os_votes set signature=x'00'"));

	// Other conversions
	database->execute(_S("update os_entries set entity=null where entity='';\r\n"));
	database->execute(_S("update os_calendar_events set entity=null where entity='';\r\n"));
	database->execute(_S("update os_files set entity=null where entity='';\r\n"));
	database->execute(_S("update os_instances set entity=null where entity='';\r\n"));
	database->execute(_S("update os_models set entity=null where entity='';\r\n"));
	database->execute(_S("update os_polls set entity=null where entity='';\r\n"));
	database->execute(_S("update os_polls_options set entity=null where entity='';\r\n"));
	database->execute(_S("update os_posts set entity=null where entity='';\r\n"));
	database->execute(_S("update os_sections set entity=null where entity='';\r\n"));
	database->execute(_S("update os_tags set entity=null where entity='';\r\n"));
	database->execute(_S("update os_texts set entity=null where entity='';\r\n"));
		
	database->execute(_S("update os_attributes set pov='") + povID.toUTF16() + _S("';\r\n"));
	database->execute(_S("update os_avatars set pov='") + povID.toUTF16() + _S("';\r\n"));
	database->execute(_S("update os_calendar_events set pov='") + povID.toUTF16() + _S("';\r\n"));
	database->execute(_S("update os_files set pov='") + povID.toUTF16() + _S("';\r\n"));
	database->execute(_S("update os_instances set pov='") + povID.toUTF16() + _S("';\r\n"));
	database->execute(_S("update os_models set pov='") + povID.toUTF16() + _S("';\r\n"));
	database->execute(_S("update os_polls set pov='") + povID.toUTF16() + _S("';\r\n"));
	database->execute(_S("update os_polls_options set pov='") + povID.toUTF16() + _S("';\r\n"));
	database->execute(_S("update os_polls_votes set pov='") + povID.toUTF16() + _S("';\r\n"));
	database->execute(_S("update os_posts set pov='") + povID.toUTF16() + _S("';\r\n"));
	database->execute(_S("update os_private_messages set pov='") + povID.toUTF16() + _S("';\r\n"));
	database->execute(_S("update os_reputations set pov='") + povID.toUTF16() + _S("';\r\n"));
	database->execute(_S("update os_sections set pov='") + povID.toUTF16() + _S("';\r\n"));
	database->execute(_S("update os_tags set pov='") + povID.toUTF16() + _S("';\r\n"));
	database->execute(_S("update os_texts set pov='") + povID.toUTF16() + _S("';\r\n"));
	database->execute(_S("update os_users set pov='") + povID.toUTF16() + _S("';\r\n"));
	database->execute(_S("update os_votes set pov='") + povID.toUTF16() + _S("';\r\n"));

	database->execute(_S("update os_entries set entity=ifnull(entity,id);\r\n"));

	database->execute(_S("update os_calendar_events set entity=ifnull(entity,id);\r\n"));
	database->execute(_S("update os_files set entity=ifnull(entity,id);\r\n"));
	database->execute(_S("update os_instances set entity=ifnull(entity,id);\r\n"));
	database->execute(_S("update os_models set entity=ifnull(entity,id);\r\n"));
	database->execute(_S("update os_polls set entity=ifnull(entity,id);\r\n"));
	database->execute(_S("update os_polls_options set entity=ifnull(entity,id);\r\n"));
	database->execute(_S("update os_posts set entity=ifnull(entity,id);\r\n"));
	database->execute(_S("update os_sections set entity=ifnull(entity,id);\r\n"));
	database->execute(_S("update os_tags set entity=ifnull(entity,id);\r\n"));
	database->execute(_S("update os_texts set entity=ifnull(entity,id);\r\n"));
				
	database->execute(_S("update os_calendar_events set entity_author=(select author from os_entries where os_entries.id = os_calendar_events.entity);\r\n"));
	database->execute(_S("update os_files set entity_author=(select author from os_entries where os_entries.id = os_files.entity);\r\n"));
	database->execute(_S("update os_instances set entity_author=(select author from os_entries where os_entries.id = os_instances.entity);\r\n"));
	database->execute(_S("update os_models set entity_author=(select author from os_entries where os_entries.id = os_models.entity);\r\n"));
	database->execute(_S("update os_polls set entity_author=(select author from os_entries where os_entries.id = os_polls.entity);\r\n"));
	database->execute(_S("update os_polls_options set entity_author=(select author from os_entries where os_entries.id = os_polls_options.entity);\r\n"));
	database->execute(_S("update os_posts set entity_author=(select author from os_entries where os_entries.id = os_posts.entity);\r\n"));
	database->execute(_S("update os_sections set entity_author=(select author from os_entries where os_entries.id = os_sections.entity);\r\n"));
	database->execute(_S("update os_tags set entity_author=(select author from os_entries where os_entries.id = os_tags.entity);\r\n"));
	database->execute(_S("update os_texts set entity_author=(select author from os_entries where os_entries.id = os_texts.entity);\r\n"));

	database->execute(_S("update os_calendar_events set entity_date=(select submit_date from os_entries where os_entries.id = os_calendar_events.entity);\r\n"));
	database->execute(_S("update os_files set entity_date=(select submit_date from os_entries where os_entries.id = os_files.entity);\r\n"));
	database->execute(_S("update os_instances set entity_date=(select submit_date from os_entries where os_entries.id = os_instances.entity);\r\n"));
	database->execute(_S("update os_models set entity_date=(select submit_date from os_entries where os_entries.id = os_models.entity);\r\n"));
	database->execute(_S("update os_polls set entity_date=(select submit_date from os_entries where os_entries.id = os_polls.entity);\r\n"));
	database->execute(_S("update os_polls_options set entity_date=(select submit_date from os_entries where os_entries.id = os_polls_options.entity);\r\n"));
	database->execute(_S("update os_posts set entity_date=(select submit_date from os_entries where os_entries.id = os_posts.entity);\r\n"));
	database->execute(_S("update os_sections set entity_date=(select submit_date from os_entries where os_entries.id = os_sections.entity);\r\n"));
	database->execute(_S("update os_tags set entity_date=(select submit_date from os_entries where os_entries.id = os_tags.entity);\r\n"));
	database->execute(_S("update os_texts set entity_date=(select submit_date from os_entries where os_entries.id = os_texts.entity);\r\n"));

	database->execute(_S("update os_calendar_events set entity_parent=(select parent from os_entries where os_entries.id = os_calendar_events.entity);\r\n"));
	database->execute(_S("update os_files set entity_parent=(select parent from os_entries where os_entries.id = os_files.entity);\r\n"));
	database->execute(_S("update os_instances set entity_parent=(select parent from os_entries where os_entries.id = os_instances.entity);\r\n"));
	database->execute(_S("update os_models set entity_parent=(select parent from os_entries where os_entries.id = os_models.entity);\r\n"));
	database->execute(_S("update os_polls set entity_parent=(select parent from os_entries where os_entries.id = os_polls.entity);\r\n"));
	database->execute(_S("update os_polls_options set entity_parent=(select parent from os_entries where os_entries.id = os_polls_options.entity);\r\n"));
	database->execute(_S("update os_posts set entity_parent=(select parent from os_entries where os_entries.id = os_posts.entity);\r\n"));
	database->execute(_S("update os_sections set entity_parent=(select parent from os_entries where os_entries.id = os_sections.entity);\r\n"));
	database->execute(_S("update os_tags set entity_parent=(select parent from os_entries where os_entries.id = os_tags.entity);\r\n"));
	database->execute(_S("update os_texts set entity_parent=(select parent from os_entries where os_entries.id = os_texts.entity);\r\n"));

	database->execute(_S("CREATE INDEX os_files_index_entity_temp on os_files (entity asc);\r\n"));
	database->execute(_S("CREATE INDEX os_texts_index_entity_temp on os_texts (entity asc);\r\n"));
	database->execute(_S("CREATE INDEX os_posts_index_entity_temp on os_posts (entity asc);\r\n"));

	database->execute(_S("update os_entries set entity_author=(select entity_author from os_calendar_events where os_entries.entity = os_calendar_events.entity) where type=16;\r\n"));
	database->execute(_S("update os_entries set entity_author=(select entity_author from os_files where os_entries.entity = os_files.entity) where type=8;\r\n"));
	database->execute(_S("update os_entries set entity_author=(select entity_author from os_instances where os_entries.entity = os_instances.entity) where type=4;\r\n"));
	database->execute(_S("update os_entries set entity_author=(select entity_author from os_models where os_entries.entity = os_models.entity) where type=15;\r\n"));
	database->execute(_S("update os_entries set entity_author=(select entity_author from os_polls where os_entries.entity = os_polls.entity) where type=12;\r\n"));
	database->execute(_S("update os_entries set entity_author=(select entity_author from os_polls_options where os_entries.entity = os_polls_options.entity) where type=13;\r\n"));
	database->execute(_S("update os_entries set entity_author=(select entity_author from os_posts where os_entries.entity = os_posts.entity) where type=6;\r\n"));
	database->execute(_S("update os_entries set entity_author=(select entity_author from os_sections where os_entries.entity = os_sections.entity) where type=3;\r\n"));
	database->execute(_S("update os_entries set entity_author=(select entity_author from os_tags where os_entries.entity = os_tags.entity) where type=9;\r\n"));
	database->execute(_S("update os_entries set entity_author=(select entity_author from os_texts where os_entries.entity = os_texts.entity) where type=5;\r\n"));

	database->execute(_S("update os_entries set entity_date=(select entity_date from os_calendar_events where os_entries.entity = os_calendar_events.entity) where type=16;\r\n"));
	database->execute(_S("update os_entries set entity_date=(select entity_date from os_files where os_entries.entity = os_files.entity) where type=8;\r\n"));
	database->execute(_S("update os_entries set entity_date=(select entity_date from os_instances where os_entries.entity = os_instances.entity) where type=4;\r\n"));
	database->execute(_S("update os_entries set entity_date=(select entity_date from os_models where os_entries.entity = os_models.entity) where type=15;\r\n"));
	database->execute(_S("update os_entries set entity_date=(select entity_date from os_polls where os_entries.entity = os_polls.entity) where type=12;\r\n"));
	database->execute(_S("update os_entries set entity_date=(select entity_date from os_polls_options where os_entries.entity = os_polls_options.entity) where type=13;\r\n"));
	database->execute(_S("update os_entries set entity_date=(select entity_date from os_posts where os_entries.entity = os_posts.entity) where type=6;\r\n"));
	database->execute(_S("update os_entries set entity_date=(select entity_date from os_sections where os_entries.entity = os_sections.entity) where type=3;\r\n"));
	database->execute(_S("update os_entries set entity_date=(select entity_date from os_tags where os_entries.entity = os_tags.entity) where type=9;\r\n"));
	database->execute(_S("update os_entries set entity_date=(select entity_date from os_texts where os_entries.entity = os_texts.entity) where type=5;\r\n"));

	database->execute(_S("update os_entries set entity=null,entity_author=null,entity_date=null where type not in (16,8,4,15,12,13,6,3,9,5);\r\n"));

	database->execute(_S("drop index os_files_index_entity_temp;\r\n"));
	database->execute(_S("drop index os_texts_index_entity_temp;\r\n"));
	database->execute(_S("drop index os_posts_index_entity_temp;\r\n"));

	// Object header cleaning - Entity
	database->execute(_S("update os_entries set entity=substr(entity,9);\r\n"));
	database->execute(_S("update os_calendar_events set entity=substr(entity,9);\r\n"));
	database->execute(_S("update os_files set entity=substr(entity,9);\r\n"));
	database->execute(_S("update os_instances set entity=substr(entity,9);\r\n"));
	database->execute(_S("update os_models set entity=substr(entity,9);\r\n"));
	database->execute(_S("update os_polls set entity=substr(entity,9);\r\n"));
	database->execute(_S("update os_polls_options set entity=substr(entity,9);\r\n"));
	database->execute(_S("update os_posts set entity=substr(entity,9);\r\n"));
	database->execute(_S("update os_sections set entity=substr(entity,9);\r\n"));
	database->execute(_S("update os_tags set entity=substr(entity,9);\r\n"));
	database->execute(_S("update os_texts set entity=substr(entity,9);\r\n"));

	database->execute(_S("update os_entries set parent=substr(parent,9);\r\n"));
	database->execute(_S("update os_calendar_events set parent=substr(parent,9);\r\n"));
	database->execute(_S("update os_files set parent=substr(parent,9);\r\n"));
	database->execute(_S("update os_instances set parent=substr(parent,9);\r\n"));
	database->execute(_S("update os_models set parent=substr(parent,9);\r\n"));
	database->execute(_S("update os_polls set parent=substr(parent,9);\r\n"));
	database->execute(_S("update os_polls_options set parent=substr(parent,9);\r\n"));
	database->execute(_S("update os_posts set parent=substr(parent,9);\r\n"));
	database->execute(_S("update os_sections set parent=substr(parent,9);\r\n"));
	database->execute(_S("update os_tags set parent=substr(parent,9);\r\n"));
	database->execute(_S("update os_texts set parent=substr(parent,9);\r\n"));

	database->execute(_S("update os_calendar_events set entity_parent=substr(entity_parent,9);\r\n"));
	database->execute(_S("update os_files set entity_parent=substr(entity_parent,9);\r\n"));
	database->execute(_S("update os_instances set entity_parent=substr(entity_parent,9);\r\n"));
	database->execute(_S("update os_models set entity_parent=substr(entity_parent,9);\r\n"));
	database->execute(_S("update os_polls set entity_parent=substr(entity_parent,9);\r\n"));
	database->execute(_S("update os_polls_options set entity_parent=substr(entity_parent,9);\r\n"));
	database->execute(_S("update os_posts set entity_parent=substr(entity_parent,9);\r\n"));
	database->execute(_S("update os_sections set entity_parent=substr(entity_parent,9);\r\n"));
	database->execute(_S("update os_tags set entity_parent=substr(entity_parent,9);\r\n"));
	database->execute(_S("update os_texts set entity_parent=substr(entity_parent,9);\r\n"));

	// Object header cleaning - ObjectID
	database->execute(_S("update os_entries set id=substr(id,9) where length(id)=48;\r\n"));
	database->execute(_S("update os_entries set author=substr(author,9) where length(author)=48;\r\n"));
	database->execute(_S("update os_entries set entity_author=substr(entity_author,9) where length(entity_author)=48;\r\n"));

	database->execute(_S("update os_attributes set id=substr(id,9) where length(id)=48;\r\n"));
	database->execute(_S("update os_attributes set author=substr(author,9) where length(author)=48;\r\n"));

	database->execute(_S("update os_avatars set id=substr(id,9) where length(id)=48;\r\n"));
	database->execute(_S("update os_avatars set author=substr(author,9) where length(author)=48;\r\n"));

	database->execute(_S("update os_local_messages set id=substr(id,9) where length(id)=48;\r\n"));
	database->execute(_S("update os_local_messages set author=substr(author,9) where length(author)=48;\r\n"));

	database->execute(_S("update os_polls_votes set id=substr(id,9) where length(id)=48;\r\n"));
	database->execute(_S("update os_polls_votes set author=substr(author,9) where length(author)=48;\r\n"));
	database->execute(_S("update os_polls_votes set reference=substr(reference,9) where length(reference)=48;\r\n"));

	database->execute(_S("update os_votes set id=substr(id,9) where length(id)=48;\r\n"));
	database->execute(_S("update os_votes set author=substr(author,9) where length(author)=48;\r\n"));
	database->execute(_S("update os_votes set reference=substr(reference,9) where length(reference)=48;\r\n"));

	database->execute(_S("update os_private_messages set id=substr(id,9) where length(id)=48;\r\n"));
	database->execute(_S("update os_private_messages set author=substr(author,9) where length(author)=48;\r\n"));
	database->execute(_S("update os_private_messages set adressee=substr(adressee,9) where length(adressee)=48;\r\n"));

	database->execute(_S("update os_reputations set id=substr(id,9) where length(id)=48;\r\n"));
	database->execute(_S("update os_reputations set author=substr(author,9) where length(author)=48;\r\n"));
	database->execute(_S("update os_reputations set reference=substr(reference,9) where length(reference)=48;\r\n"));

	database->execute(_S("update os_users set id=substr(id,9) where length(id)=48;\r\n"));

	database->execute(_S("update os_calendar_events set id=substr(id,9) where length(id)=48;\r\n"));
	database->execute(_S("update os_calendar_events set author=substr(author,9) where length(author)=48;\r\n"));
	database->execute(_S("update os_calendar_events set entity_author=substr(entity_author,9) where length(entity_author)=48;\r\n"));
	database->execute(_S("update os_files set id=substr(id,9) where length(id)=48;\r\n"));
	database->execute(_S("update os_files set author=substr(author,9) where length(author)=48;\r\n"));
	database->execute(_S("update os_files set entity_author=substr(entity_author,9) where length(entity_author)=48;\r\n"));
	database->execute(_S("update os_instances set id=substr(id,9) where length(id)=48;\r\n"));
	database->execute(_S("update os_instances set author=substr(author,9) where length(author)=48;\r\n"));
	database->execute(_S("update os_instances set entity_author=substr(entity_author,9) where length(entity_author)=48;\r\n"));
	database->execute(_S("update os_models set id=substr(id,9) where length(id)=48;\r\n"));
	database->execute(_S("update os_models set author=substr(author,9) where length(author)=48;\r\n"));
	database->execute(_S("update os_models set entity_author=substr(entity_author,9) where length(entity_author)=48;\r\n"));
	database->execute(_S("update os_polls set id=substr(id,9) where length(id)=48;\r\n"));
	database->execute(_S("update os_polls set author=substr(author,9) where length(author)=48;\r\n"));
	database->execute(_S("update os_polls set entity_author=substr(entity_author,9) where length(entity_author)=48;\r\n"));
	database->execute(_S("update os_polls_options set id=substr(id,9) where length(id)=48;\r\n"));
	database->execute(_S("update os_polls_options set author=substr(author,9) where length(author)=48;\r\n"));
	database->execute(_S("update os_polls_options set entity_author=substr(entity_author,9) where length(entity_author)=48;\r\n"));
	database->execute(_S("update os_posts set id=substr(id,9) where length(id)=48;\r\n"));
	database->execute(_S("update os_posts set author=substr(author,9) where length(author)=48;\r\n"));
	database->execute(_S("update os_posts set entity_author=substr(entity_author,9) where length(entity_author)=48;\r\n"));
	database->execute(_S("update os_sections set id=substr(id,9) where length(id)=48;\r\n"));
	database->execute(_S("update os_sections set author=substr(author,9) where length(author)=48;\r\n"));
	database->execute(_S("update os_sections set entity_author=substr(entity_author,9) where length(entity_author)=48;\r\n"));
	database->execute(_S("update os_tags set id=substr(id,9) where length(id)=48;\r\n"));
	database->execute(_S("update os_tags set author=substr(author,9) where length(author)=48;\r\n"));
	database->execute(_S("update os_tags set entity_author=substr(entity_author,9) where length(entity_author)=48;\r\n"));
	database->execute(_S("update os_texts set id=substr(id,9) where length(id)=48;\r\n"));
	database->execute(_S("update os_texts set author=substr(author,9) where length(author)=48;\r\n"));
	database->execute(_S("update os_texts set entity_author=substr(entity_author,9) where length(entity_author)=48;\r\n"));
	
	// Special for Osiris Official
	database->execute(_S("update os_entries set author='3CCB3260950B80505CBB062C0B9B65E7028BD53F' where author='EFA5BEDD264F19D35BA92F05E503AD477D432E9F' and type=3;\r\n"));
	database->execute(_S("update os_entries set author='3CCB3260950B80505CBB062C0B9B65E7028BD53F' where author='EFA5BEDD264F19D35BA92F05E503AD477D432E9F' and type=8;\r\n"));
	database->execute(_S("update os_files set author='3CCB3260950B80505CBB062C0B9B65E7028BD53F',entity_author='3CCB3260950B80505CBB062C0B9B65E7028BD53F' where author='EFA5BEDD264F19D35BA92F05E503AD477D432E9F';\r\n"));
	database->execute(_S("update os_sections set author='3CCB3260950B80505CBB062C0B9B65E7028BD53F',entity_author='3CCB3260950B80505CBB062C0B9B65E7028BD53F' where author='EFA5BEDD264F19D35BA92F05E503AD477D432E9F';\r\n"));

	// Cleaning... issue found in some old portals.
	database->execute(_S("delete from os_models where id not in (select id from os_entries);\r\n"));
	database->execute(_S("drop table if exists os_commentables_stats;\r\n"));

	//if(database->execute(patch) == false)
	//	return false;

	// Default POV Options
	{
		String povOptions;
		povOptions += _S("<options>");
		povOptions += _S("<option name=\"acp.objects.allow_unsigned\" value=\"true\"/>");
		povOptions += _S("<option name=\"acp.portal.name\" value=\"") + HtmlParser::instance()->encode(portalName) + _S("\"/>");
		povOptions += _S("<option name=\"acp.portal.description\" value=\"") + HtmlParser::instance()->encode(portalDescription) + _S("\"/>");						
		povOptions += _S("</options>");

		String sql = _S("update os_users set options=") + Convert::toSQL(povOptions) + _S(" where id=") + Convert::toSQL(userID.toUTF16()) + _S(";");
		database->execute(sql);
	}

	// Rename changed ID
	renameIDS(database);

	// Update contents	
	{
		if(upgradeContentOML(database, _S("os_calendar_events"), _S("content"), false) == false)
			return false;
		if(upgradeContentOML(database, _S("os_files"), _S("content"), false) == false)
			return false;
		if(upgradeContentOML(database, _S("os_models"), _S("content"), false) == false)
			return false;
		if(upgradeContentOML(database, _S("os_polls"), _S("content"), false) == false)
			return false;
		if(upgradeContentOML(database, _S("os_posts"), _S("content"), false) == false)
			return false;
		if(upgradeContentOML(database, _S("os_texts"), _S("content"), false) == false)
			return false;
		if(upgradeContentOML(database, _S("os_users"), _S("mark"), false) == false)
			return false;
		if(upgradeContentOML(database, _S("os_instances"), _S("data"), true) == false)
			return false;
		if(upgradeContentOML(database, _S("os_sections"), _S("data"), true) == false)
			return false;
		if(upgradeContentOML(database, _S("os_sections"), _S("component"), false) == false)
			return false;
		if(upgradeContentOML(database, _S("os_instances"), _S("module"), false) == false)
			return false;
	}	

	String filename = utils::makeFilePath(Options::instance()->getLogPath(), _S("migration_") + database->getPortal()->getPortalID().toWide() + _S(".log"));

	shared_ptr<File> file(OS_NEW File());
	if(file->open(filename, File::ofWrite) == false)
		return false;

	std::string debugAscii = m_DebugLog.to_ascii();
	file->write(debugAscii.data(), static_cast<uint32>(debugAscii.size()));

	file->close();

	return true;
}
예제 #3
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;
}