void IdeMailBox::onRestoreMessage(IEvent *e) { HtmlEvent *htmlEvent = dynamic_cast<HtmlEvent *>(e); if(htmlEvent == nullptr) return; ObjectID id = htmlEvent->get(0).to_ascii(); if(id.empty() == false) { // Elimina il messaggio getPortal()->getMessenger()->moveMessageToInbox(getPage()->getDatabase(), getSessionAccount(), id); // Mostra la posta in arrivo _renderFolder(messageFolderInbox); } }
void IdeMailBox::onDeleteMessage(IEvent *e) { HtmlEvent *htmlEvent = dynamic_cast<HtmlEvent *>(e); if(htmlEvent == nullptr) return; ObjectID id = htmlEvent->get(0).to_ascii(); if(id.empty() == false) { // Elimina il messaggio getPortal()->getMessenger()->moveMessageToTrash(getPage()->getDatabase(), getSessionAccount(), id); // Mostra la directory di riferimento _renderFolder(m_folder); } }
//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; } }
bool CompatibilityManager::razorUpgrade(const String &folder) { try { if(FileSystem::instance()->directoryExists(folder)) { StringList portals; FileSystem::instance()->getDirectories(folder, portals, false); for(StringList::const_iterator i = portals.begin(); i != portals.end(); ++i) { // 000000018F94C9554C8B227CF000C6E30EB281AEAE1A77E7 String name = *i; if(name.length() == 48) { // Portal < Razor std::string oldID = name.to_ascii(); // Options String oldPath = utils::standardisePath(folder + oldID); shared_ptr<PortalOptions> options(OS_NEW PortalOptions()); // Carica le impostazioni del portale if(options->readFromPath(oldPath) == false) return false; shared_ptr<IDbDriver> driver = DatabasesSystem::instance()->getDriver("sqlite"); // Query Database shared_ptr<IDbConnection> connection = driver->createConnection(oldID, driver->createOptions()); connection->open(); String portalName = options->getName(); //String portalDescription = static_cast<String>(options->getOptionValue("description")); NotificationsManager::instance()->notify(_S("Migration of '") + portalName + _S("' to 1.0 series")); PlatformManager::instance()->sleep(500); //ObjectID userID = static_cast<String>(m_portalOptions.getOption(options::users_reference)).to_ascii(); ObjectID userID = static_cast<String>(options->getOptionValue("users.reference")).to_ascii(); //bool monarchic = (options->getPortalID().getPortalType() == portalTypeMonarchic); ID oldPortalID(oldID); uint8 portalType = OS_UINT8_LO(oldPortalID.getHeader().getFirst()); bool monarchic = (portalType == 1); // Calcolo UserID. // Se non lo posso dedurre, uso il primo che trovo loggato. if(userID.empty()) { if(monarchic) { //userID = options->getPortalID().getAdministratorID(); #ifdef OS_NOOBJECTID userID = oldPortalID.getHash(); #else userID = ObjectID::generate(portalObjectTypeUser, oldPortalID.getHash()); #endif } else { String sql = String::EMPTY; sql += _S(" select tp.profile, tu.reference "); sql += _S(" from "); sql += _S(" os_snapshot_profiles tp, "); sql += _S(" os_snapshot_users tu "); sql += _S(" where "); sql += _S(" tp.profile=tu.profile and "); sql += _S(" tu.score=1 and "); sql += _S(" tu.follow=1 and "); sql += _S(" tu.description='Auto valutation'"); shared_ptr<IDbResult> result = connection->query(sql); DataTable table; result->init(table); DataTableRow row = table.addRow(); while(result->end() == false) { result->bind(row); String objectID = static_cast<String>(*row[1]); userID = objectID.to_ascii(); result->moveNext(); break; } } } #ifdef OS_NOOBJECTID PovID povID = userID; #else PovID povID = userID.getHash(); #endif if(userID.empty() == false) { // Clean old snapshot connection->execute(_S("delete from os_snapshot_objects")); connection->execute(_S("delete from os_snapshot_users")); connection->execute(_S("delete from os_snapshot_profiles")); connection->execute(_S("delete from os_discussions_stats")); //connection->execute(_S("delete from os_forums_forum_stats")); //connection->execute(_S("delete from os_forums_section_stats")); connection->execute(_S("delete from os_polls_stats")); connection->execute(_S("delete from os_polls_options_stats")); connection->execute(_S("delete from os_users_stats")); // Old connection->execute(_S("drop table if exists os_forums_forum_stats")); connection->execute(_S("drop table if exists os_forums_section_stats")); // Reset acceptable connection->execute(_S("update os_entries set rank=-2")); // Clean signatures #ifdef OS_NEWSIGNATURE connection->execute(_S("update os_attributes set signature=x'00'")); connection->execute(_S("update os_avatars set signature=x'00'")); connection->execute(_S("update os_calendar_events set signature=x'00'")); connection->execute(_S("update os_files set signature=x'00'")); connection->execute(_S("update os_instances set signature=x'00'")); connection->execute(_S("update os_models set signature=x'00'")); connection->execute(_S("update os_polls set signature=x'00'")); connection->execute(_S("update os_polls_options set signature=x'00'")); connection->execute(_S("update os_polls_votes set signature=x'00'")); connection->execute(_S("update os_posts set signature=x'00'")); connection->execute(_S("update os_private_messages set signature=x'00'")); connection->execute(_S("update os_reputations set signature=x'00'")); connection->execute(_S("update os_sections set signature=x'00'")); connection->execute(_S("update os_tags set signature=x'00'")); connection->execute(_S("update os_texts set signature=x'00'")); connection->execute(_S("update os_users set signature=x'00'")); connection->execute(_S("update os_votes set signature=x'00'")); #endif // identificarli: // select * from os_users where signature=x'00' } connection->close(); if(userID.empty() == false) { String newPortalIDKey = oldID.substr(8); PortalID newPortalID = CryptManager:: instance()->SHA(newPortalIDKey.buffer(), newPortalIDKey.buffer_size()).toHex(); String newPovID = Portal::generatePovID(newPortalID, povID); String newPath = utils::standardisePath(folder + newPovID); options->setPortalID(newPortalID); options->setPovID(povID); options->setDatabaseName(newPovID); FileSystem::instance()->ensureDirectory(newPath); options->writeToPath(newPath); String sqlitePluginID = _S("532E9E0A68EB22E08240965CFA9366DFA6A26A62"); String databaseRootPath = utils::makeFolderPath(Options::instance()->getDataPath(), utils::makeFolderPath(OS_STORE_PATH, sqlitePluginID)); String oldDatabasePath = utils::makeFilePath(databaseRootPath,oldID) + _S(".db"); String newDatabasePath = utils::makeFilePath(databaseRootPath,newPovID) + _S(".db"); FileSystem::instance()->copyFile(oldDatabasePath, newDatabasePath); FileSystem::instance()->remove(oldDatabasePath); FileSystem::instance()->removeDirectory(oldPath); } else { OS_LOG_ERROR("Unable to migrate portal '" + portalName + "', ID:" + oldID + ". Contact our forum, thanks."); } } } } } catch(std::exception &e) { OS_LOG_ERROR(e.what()); return false; } catch(...) { OS_LOG_ERROR(_S("Unknown error during Razor upgrade.'")); return false; } return true; }