diff --git a/.hgeol b/.hgeol index e13b08ced..c7a59fec5 100644 --- a/.hgeol +++ b/.hgeol @@ -1,6 +1,9 @@ [patterns] **.h = native **.cpp = native + +**/database.xml = BIN +**/msg.xml = BIN **.txt = native **.xml = native diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index 1ae01610f..0cd9afd54 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -111,9 +111,11 @@ FIND_PACKAGE(LibXml2 REQUIRED) FIND_PACKAGE(PNG REQUIRED) FIND_PACKAGE(Jpeg) +IF(WITH_STATIC_LIBXML2) + SET(LIBXML2_DEFINITIONS ${LIBXML2_DEFINITIONS} -DLIBXML_STATIC) +ENDIF(WITH_STATIC_LIBXML2) IF(WITH_STATIC) # libxml2 could need winsock2 library - SET(LIBXML2_DEFINITIONS ${LIBXML2_DEFINITIONS} -DLIBXML_STATIC) SET(LIBXML2_LIBRARIES ${LIBXML2_LIBRARIES} ${WINSOCK2_LIB}) # on Mac OS X libxml2 requires iconv and liblzma diff --git a/code/CMakeModules/PCHSupport.cmake b/code/CMakeModules/PCHSupport.cmake index d444bfa3d..042f6b0cc 100644 --- a/code/CMakeModules/PCHSupport.cmake +++ b/code/CMakeModules/PCHSupport.cmake @@ -33,9 +33,9 @@ ENDIF(MSVC) # Set PCH_FLAGS for common flags, PCH_ARCH_XXX_FLAGS for specific archs flags and PCH_ARCHS for archs MACRO(PCH_SET_COMPILE_FLAGS _target) SET(PCH_FLAGS) - SET(PCH_ARCHS) - - SET(FLAGS) + SET(PCH_ARCHS) + SET(_FLAGS) + LIST(APPEND _FLAGS ${CMAKE_CXX_FLAGS}) STRING(TOUPPER "${CMAKE_BUILD_TYPE}" _UPPER_BUILD) @@ -81,10 +81,15 @@ MACRO(PCH_SET_COMPILE_FLAGS _target) LIST(APPEND _FLAGS " ${_directory_flags}") LIST(APPEND _FLAGS " ${_directory_definitions}") - STRING(REGEX REPLACE " +" " " _FLAGS ${_FLAGS}) - # Format definitions - SEPARATE_ARGUMENTS(_FLAGS) + IF(MSVC) + # Fix path with space + SEPARATE_ARGUMENTS(_FLAGS UNIX_COMMAND "${_FLAGS}") + ELSE(MSVC) + STRING(REGEX REPLACE " +" " " _FLAGS ${_FLAGS}) + SEPARATE_ARGUMENTS(_FLAGS) + ENDIF(MSVC) + IF(CLANG) # Determining all architectures and get common flags diff --git a/code/CMakeModules/nel.cmake b/code/CMakeModules/nel.cmake index 72e2d07e4..834a5da5b 100644 --- a/code/CMakeModules/nel.cmake +++ b/code/CMakeModules/nel.cmake @@ -123,7 +123,7 @@ MACRO(NL_DEFAULT_PROPS name label) VERSION ${NL_VERSION} SOVERSION ${NL_VERSION_MAJOR} COMPILE_FLAGS "/GA" - LINK_FLAGS "/VERSION:${NL_VERSION}") + LINK_FLAGS "/VERSION:${NL_VERSION_MAJOR}.${NL_VERSION_MINOR}") ENDIF(${type} STREQUAL EXECUTABLE AND WIN32) IF(WITH_STLPORT AND WIN32) @@ -247,6 +247,11 @@ MACRO(NL_SETUP_DEFAULT_OPTIONS) ELSE(WIN32) OPTION(WITH_STATIC "With static libraries." OFF) ENDIF(WIN32) + IF (WITH_STATIC) + OPTION(WITH_STATIC_LIBXML2 "With static libxml2" ON ) + ELSE(WITH_STATIC) + OPTION(WITH_STATIC_LIBXML2 "With static libxml2" OFF) + ENDIF(WITH_STATIC) OPTION(WITH_STATIC_DRIVERS "With static drivers." OFF) IF(WIN32) OPTION(WITH_EXTERNAL "With provided external." ON ) diff --git a/code/nel/CMakeLists.txt b/code/nel/CMakeLists.txt index 745278cd7..1929135b4 100644 --- a/code/nel/CMakeLists.txt +++ b/code/nel/CMakeLists.txt @@ -68,7 +68,11 @@ IF(WITH_NEL_SAMPLES) ADD_SUBDIRECTORY(samples) ENDIF(WITH_NEL_SAMPLES) -IF(WITH_NEL_TOOLS) - FIND_PACKAGE(Squish) +# Allow to compile only max plugins without other tools. +IF(WITH_NEL_TOOLS OR WITH_NEL_MAXPLUGIN) + IF(WITH_NEL_TOOLS) + FIND_PACKAGE(Squish) + ENDIF(WITH_NEL_TOOLS) ADD_SUBDIRECTORY(tools) -ENDIF(WITH_NEL_TOOLS) +ENDIF(WITH_NEL_TOOLS OR WITH_NEL_MAXPLUGIN) + diff --git a/code/nel/include/nel/gui/interface_link.h b/code/nel/include/nel/gui/interface_link.h index ffa6ac0c7..42fb2bbcf 100644 --- a/code/nel/include/nel/gui/interface_link.h +++ b/code/nel/include/nel/gui/interface_link.h @@ -66,6 +66,11 @@ namespace NLGUI */ bool affect(const CInterfaceExprValue &value); }; + struct CCDBTargetInfo + { + NLMISC::CRefPtr Leaf; + std::string LeafName; + }; /// Updates triggered interface links when triggered by the observed branch @@ -85,7 +90,7 @@ namespace NLGUI * If there are no target element, the link is permanent (removed at exit) * NB : The target is not updated during this call. */ - bool init(const std::vector &targets, const std::string &expr, const std::string &actionHandler, const std::string &ahParams, const std::string &ahCond, CInterfaceGroup *parent); + bool init(const std::vector &targets, const std::vector &cdbTargets, const std::string &expr, const std::string &actionHandler, const std::string &ahParams, const std::string &ahCond, CInterfaceGroup *parent); // force all the links that have been created to update their targets. This can be called when the interface has been loaded, and when the databse entries have been retrieved. static void updateAllLinks(); // force all trigered links to be updated @@ -119,6 +124,7 @@ namespace NLGUI * \return true if all targets are valid */ static bool splitLinkTargets(const std::string &targets, CInterfaceGroup *parentGroup, std::vector &targetsVect); + static bool splitLinkTargetsExt(const std::string &targets, CInterfaceGroup *parentGroup, std::vector &targetsVect, std::vector &cdbTargetsVect); //////////////////////////////////////////////////////////////////////////////////////////////////////// private: friend struct CRemoveTargetPred; @@ -135,12 +141,14 @@ namespace NLGUI typedef std::vector TNodeVect; private: std::vector _Targets; + std::vector _CDBTargets; TNodeVect _ObservedNodes; std::string _Expr; CInterfaceExprNode *_ParseTree; std::string _ActionHandler; std::string _AHParams; std::string _AHCond; + CInterfaceExprNode *_AHCondParsed; CInterfaceGroup *_AHParent; static TLinkList _LinkList; TLinkList::iterator _ListEntry; diff --git a/code/nel/include/nel/gui/lua_helper.h b/code/nel/include/nel/gui/lua_helper.h index 10b78daa8..69639fc04 100644 --- a/code/nel/include/nel/gui/lua_helper.h +++ b/code/nel/include/nel/gui/lua_helper.h @@ -217,6 +217,7 @@ namespace NLGUI void clear() { setTop(0); } int getTop(); bool empty() { return getTop() == 0; } + void pushGlobalTable(); void pushValue(int index); // copie nth element of stack to the top of the stack void remove(int index); // remove nth element of stack void insert(int index); // insert last element of the stack before the given position @@ -301,7 +302,8 @@ namespace NLGUI /** Helper : Execute a function by name. Lookup for the function is done in the table at the index 'funcTableIndex' * the behaviour is the same than with call of pcall. */ - int pcallByName(const char *functionName, int nargs, int nresults, int funcTableIndex = LUA_GLOBALSINDEX, int errfunc = 0); + int pcallByNameGlobal(const char *functionName, int nargs, int nresults, int errfunc = 0); + int pcallByName(const char *functionName, int nargs, int nresults, int funcTableIndex, int errfunc = 0); // push a C closure (pop n element from the stack and associate with the function) void pushCClosure(lua_CFunction function, int n); @@ -367,6 +369,7 @@ namespace NLGUI CLuaState &operator=(const CLuaState &/* other */) { nlassert(0); return *this; } void executeScriptInternal(const std::string &code, const std::string &dbgSrc, int numRet = 0); + int pcallByNameInternal(const char *functionName, int nargs, int nresults, int errfunc, int initialStackSize); }; diff --git a/code/nel/include/nel/gui/lua_helper_inline.h b/code/nel/include/nel/gui/lua_helper_inline.h index 0b9113ce1..01afd142f 100644 --- a/code/nel/include/nel/gui/lua_helper_inline.h +++ b/code/nel/include/nel/gui/lua_helper_inline.h @@ -42,10 +42,16 @@ inline void CLuaState::checkIndex(int index) //H_AUTO(Lua_CLuaState_checkIndex) // NB : more restrictive test that in the documentation there, because // we don't expose the check stack function +#if LUA_VERSION_NUM >= 502 + nlassert( (index!=0 && abs(index) <= getTop()) + || index == LUA_REGISTRYINDEX + ); +#else nlassert( (index!=0 && abs(index) <= getTop()) || index == LUA_REGISTRYINDEX || index == LUA_GLOBALSINDEX ); +#endif } //================================================================================ @@ -75,6 +81,18 @@ inline void CLuaState::setTop(int index) lua_settop(_State, index); } +//================================================================================ +inline void CLuaState::pushGlobalTable() +{ + //H_AUTO(Lua_CLuaState_pushGlobalTable) +#if LUA_VERSION_NUM >= 502 + lua_pushglobaltable(_State); +#else + checkIndex(LUA_GLOBALSINDEX); + lua_pushvalue(_State, LUA_GLOBALSINDEX); +#endif +} + //================================================================================ inline void CLuaState::pushValue(int index) { @@ -243,7 +261,11 @@ inline size_t CLuaState::strlen(int index) { //H_AUTO(Lua_CLuaState_strlen) checkIndex(index); +#if LUA_VERSION_NUM >= 502 + return lua_rawlen(_State, index); +#else return lua_strlen(_State, index); +#endif } //================================================================================ @@ -342,7 +364,11 @@ inline bool CLuaState::equal(int index1, int index2) //H_AUTO(Lua_CLuaState_equal) checkIndex(index1); checkIndex(index2); +#if LUA_VERSION_NUM >= 502 + return lua_compare(_State, index1, index2, LUA_OPEQ) != 0; +#else return lua_equal(_State, index1, index2) != 0; +#endif } //================================================================================ @@ -376,7 +402,11 @@ inline bool CLuaState::lessThan(int index1, int index2) //H_AUTO(Lua_CLuaState_lessThan) checkIndex(index1); checkIndex(index2); +#if LUA_VERSION_NUM >= 502 + return lua_compare(_State, index1, index2, LUA_OPLT) != 0; +#else return lua_lessthan(_State, index1, index2) != 0; +#endif } diff --git a/code/nel/include/nel/gui/widget_manager.h b/code/nel/include/nel/gui/widget_manager.h index 7fedc6240..00723faea 100644 --- a/code/nel/include/nel/gui/widget_manager.h +++ b/code/nel/include/nel/gui/widget_manager.h @@ -444,7 +444,7 @@ namespace NLGUI } float getAlphaRolloverSpeed(); - void resetAlphaRolloverSpeed(); + void resetAlphaRolloverSpeedProps(); void setContainerAlpha( uint8 alpha ); uint8 getContainerAlpha() const { return _ContainerAlpha; } @@ -454,6 +454,7 @@ namespace NLGUI uint8 getGlobalRolloverFactorContainer() const { return _GlobalRolloverFactorContainer; } void updateGlobalAlphas(); + void resetGlobalAlphasProps(); const SInterfaceTimes& getInterfaceTimes() const{ return interfaceTimes; } void updateInterfaceTimes( const SInterfaceTimes × ){ interfaceTimes = times; } @@ -527,6 +528,11 @@ namespace NLGUI NLMISC::CCDBNodeLeaf *_BProp; NLMISC::CCDBNodeLeaf *_AProp; NLMISC::CCDBNodeLeaf *_AlphaRolloverSpeedDB; + + NLMISC::CCDBNodeLeaf *_GlobalContentAlphaDB; + NLMISC::CCDBNodeLeaf *_GlobalContainerAlphaDB; + NLMISC::CCDBNodeLeaf *_GlobalContentRolloverFactorDB; + NLMISC::CCDBNodeLeaf *_GlobalContainerRolloverFactorDB; uint8 _ContainerAlpha; uint8 _GlobalContentAlpha; diff --git a/code/nel/include/nel/misc/types_nl.h b/code/nel/include/nel/misc/types_nl.h index 6485960f7..ce9d88bae 100644 --- a/code/nel/include/nel/misc/types_nl.h +++ b/code/nel/include/nel/misc/types_nl.h @@ -104,6 +104,8 @@ // Windows 64bits platform SDK compilers doesn't support inline assembler # define NL_NO_ASM # endif +# undef _WIN32_WINNT +# define _WIN32_WINNT 0x0600 // force VISTA minimal version in 64 bits # endif // define NOMINMAX to be sure that windows includes will not define min max macros, but instead, use the stl template # define NOMINMAX diff --git a/code/nel/src/3d/driver/opengl/driver_opengl.cpp b/code/nel/src/3d/driver/opengl/driver_opengl.cpp index 29e14a1a0..08b883e12 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl.cpp @@ -1488,7 +1488,10 @@ void CDriverGL::enableUsedTextureMemorySum (bool enable) H_AUTO_OGL(CDriverGL_enableUsedTextureMemorySum ) if (enable) + { nlinfo ("3D: PERFORMANCE INFO: enableUsedTextureMemorySum has been set to true in CDriverGL"); + _TextureUsed.reserve(512); + } _SumTextureMemoryUsed=enable; } @@ -1502,7 +1505,7 @@ uint32 CDriverGL::getUsedTextureMemory() const uint32 memory=0; // For each texture used - set::const_iterator ite=_TextureUsed.begin(); + std::vector::const_iterator ite = _TextureUsed.begin(); while (ite!=_TextureUsed.end()) { // Get the gl texture @@ -1510,7 +1513,8 @@ uint32 CDriverGL::getUsedTextureMemory() const gltext= (*ite); // Sum the memory used by this texture - memory+=gltext->TextureMemory; + if (gltext) + memory+=gltext->TextureMemory; // Next texture ite++; diff --git a/code/nel/src/3d/driver/opengl/driver_opengl.h b/code/nel/src/3d/driver/opengl/driver_opengl.h index bfe73492d..ee6431dc4 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl.h +++ b/code/nel/src/3d/driver/opengl/driver_opengl.h @@ -196,6 +196,8 @@ public: bool initFrameBufferObject(ITexture * tex); bool activeFrameBufferObject(ITexture * tex); + + std::vector::size_type TextureUsedIdx; }; @@ -1273,7 +1275,7 @@ private: uint32 _NbSetupMaterialCall; uint32 _NbSetupModelMatrixCall; bool _SumTextureMemoryUsed; - std::set _TextureUsed; + std::vector _TextureUsed; uint computeMipMapMemoryUsage(uint w, uint h, GLint glfmt) const; // VBHard Lock Profiling diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_texture.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_texture.cpp index 77954a8e3..055f8d99d 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_texture.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_texture.cpp @@ -79,6 +79,8 @@ CTextureDrvInfosGL::CTextureDrvInfosGL(IDriver *drv, ItTexDrvInfoPtrMap it, CDri InitFBO = false; AttachDepthStencil = true; UsePackedDepthStencil = drvGl->supportPackedDepthStencil(); + + TextureUsedIdx = 0; } // *************************************************************************** CTextureDrvInfosGL::~CTextureDrvInfosGL() @@ -91,7 +93,10 @@ CTextureDrvInfosGL::~CTextureDrvInfosGL() _Driver->_AllocatedTextureMemory-= TextureMemory; // release in TextureUsed. - _Driver->_TextureUsed.erase (this); + if (TextureUsedIdx < _Driver->_TextureUsed.size() && _Driver->_TextureUsed[TextureUsedIdx] == this) + { + _Driver->_TextureUsed[TextureUsedIdx] = NULL; + } if(InitFBO) { @@ -1492,7 +1497,11 @@ bool CDriverGL::activateTexture(uint stage, ITexture *tex) if (_SumTextureMemoryUsed) { // Insert the pointer of this texture - _TextureUsed.insert (gltext); + if (gltext->TextureUsedIdx >= _TextureUsed.size() || _TextureUsed[gltext->TextureUsedIdx] != gltext) + { + gltext->TextureUsedIdx = _TextureUsed.size(); + _TextureUsed.push_back(gltext); + } } if(tex->isTextureCube()) diff --git a/code/nel/src/3d/zone_lighter.cpp b/code/nel/src/3d/zone_lighter.cpp index 112df54e0..0fe7e9b48 100644 --- a/code/nel/src/3d/zone_lighter.cpp +++ b/code/nel/src/3d/zone_lighter.cpp @@ -1170,8 +1170,7 @@ void CZoneLighter::light (CLandscape &landscape, CZone& output, uint zoneToLight { // Last patch uint lastPatch=firstPatch+patchCountByThread; - if (lastPatch>patchCount) - lastPatch=patchCount; + lastPatch %= patchCount; // Last patch computed _LastPatchComputed[process] = firstPatch; @@ -3772,6 +3771,8 @@ uint CZoneLighter::getAPatch (uint process) uint index = _LastPatchComputed[process]; uint firstIndex = index; + nlassert(index < _PatchInfo.size()); + if (access.value().size() == 0) // no more patches return 0xffffffff; diff --git a/code/nel/src/gui/dbgroup_combo_box.cpp b/code/nel/src/gui/dbgroup_combo_box.cpp index 83baa93b3..61b8ec3e6 100644 --- a/code/nel/src/gui/dbgroup_combo_box.cpp +++ b/code/nel/src/gui/dbgroup_combo_box.cpp @@ -28,10 +28,12 @@ using namespace std; using namespace NLMISC; -NLMISC_REGISTER_OBJECT(CViewBase, CDBGroupComboBox, std::string, "combo_box"); - namespace NLGUI { + NLMISC_REGISTER_OBJECT(CViewBase, CDBGroupComboBox, std::string, "combo_box"); + + void force_link_dbgroup_combo_box_cpp() { } + // Compare strings static inline bool lt_text(const std::pair &s1, const std::pair &s2) { diff --git a/code/nel/src/gui/dbgroup_select_number.cpp b/code/nel/src/gui/dbgroup_select_number.cpp index 409bf838f..b3dc2e8f1 100644 --- a/code/nel/src/gui/dbgroup_select_number.cpp +++ b/code/nel/src/gui/dbgroup_select_number.cpp @@ -31,6 +31,8 @@ namespace NLGUI { NLMISC_REGISTER_OBJECT(CViewBase, CDBGroupSelectNumber, std::string, "select_number"); + void force_link_dbgroup_select_number_cpp() { } + // *************************************************************************** CDBGroupSelectNumber::CDBGroupSelectNumber(const TCtorParam ¶m) : CInterfaceGroup(param) diff --git a/code/nel/src/gui/interface_group.cpp b/code/nel/src/gui/interface_group.cpp index f981814ba..4e8919e5c 100644 --- a/code/nel/src/gui/interface_group.cpp +++ b/code/nel/src/gui/interface_group.cpp @@ -2325,7 +2325,8 @@ namespace NLGUI _LUAOnDbChange[dbList]= newLink; // Init and attach to list of untargeted links std::vector noTargets; - newLink->init(noTargets, NLMISC::toString("depends(%s)", dbList.c_str()), "lua", script, "", this); + std::vector noCdbTargets; + newLink->init(noTargets, noCdbTargets, NLMISC::toString("depends(%s)", dbList.c_str()), "lua", script, "", this); } // ------------------------------------------------------------------------------------------------ diff --git a/code/nel/src/gui/interface_link.cpp b/code/nel/src/gui/interface_link.cpp index d672e9402..282199ee7 100644 --- a/code/nel/src/gui/interface_link.cpp +++ b/code/nel/src/gui/interface_link.cpp @@ -165,6 +165,7 @@ namespace NLGUI _NextTriggeredLink[0] = _NextTriggeredLink[1] = NULL; _Triggered[0] = _Triggered[1] = false; _ParseTree = NULL; + _AHCondParsed = NULL; } //=========================================================== @@ -187,10 +188,13 @@ namespace NLGUI _LinkList.erase(_ListEntry); delete _ParseTree; + _ParseTree = NULL; + delete _AHCondParsed; + _AHCondParsed = NULL; } //=========================================================== - bool CInterfaceLink::init(const std::vector &targets, const std::string &expr, const std::string &actionHandler, const std::string &ahParams, const std::string &ahCond, CInterfaceGroup *parentGroup) + bool CInterfaceLink::init(const std::vector &targets, const std::vector &cdbTargets, const std::string &expr, const std::string &actionHandler, const std::string &ahParams, const std::string &ahCond, CInterfaceGroup *parentGroup) { CInterfaceExprValue result; // Build the parse tree @@ -236,6 +240,7 @@ namespace NLGUI // There are no target for this link, so, put in a dedicated list to ensure that the link will be destroyed at exit _LinksWithNoTarget.push_back(TLinkSmartPtr(this)); } + _CDBTargets = cdbTargets; // create observers createObservers(_ObservedNodes); @@ -243,7 +248,12 @@ namespace NLGUI // _ActionHandler = actionHandler; _AHParams = ahParams; + nlassert(!_AHCondParsed); _AHCond = ahCond; + if (!ahCond.empty()) + { + _AHCondParsed = CInterfaceExpr::buildExprTree(ahCond); + } _AHParent = parentGroup; return true; } @@ -356,19 +366,47 @@ namespace NLGUI } } } + if (_CDBTargets.size()) + { + CInterfaceExprValue resultCopy = result; + if (resultCopy.toInteger()) + { + sint64 resultValue = resultCopy.getInteger(); + for (uint k = 0; k < _CDBTargets.size(); ++k) + { + NLMISC::CCDBNodeLeaf *node = _CDBTargets[k].Leaf; + if (!node) + { + node = _CDBTargets[k].Leaf = NLGUI::CDBManager::getInstance()->getDbProp(_CDBTargets[k].LeafName, false); + } + if (node) + { + // assuming setvalue64 always works + node->setValue64(resultValue); + } + else + { + nlwarning("CInterfaceLink::update: Node does not exist: '%s'", _CDBTargets[k].LeafName.c_str()); + } + } + } + else + { + nlwarning("CInterfaceLink::update: Result conversion to db target failed"); + } + } // if there's an action handler, execute it if (!_ActionHandler.empty()) { // If there is a condition, test it. - bool launch= true; - if(!_AHCond.empty()) + bool launch = _AHCond.empty(); + if (_AHCondParsed) // todo: maybe makes more sense to make condition also cover target { - launch= false; - CInterfaceExprValue result; - if(CInterfaceExpr::eval(_AHCond, result)) - launch= result.getBool(); + CInterfaceExprValue result; + _AHCondParsed->eval(result); + launch = result.getBool(); } - if(launch) + if (launch) { CAHManager::getInstance()->runActionHandler(_ActionHandler, _AHParent, _AHParams); // do not add any code after this line because this can be deleted !!!! @@ -517,6 +555,11 @@ namespace NLGUI continue; } std::string::size_type lastPos = targetNames[k].find_last_not_of(" "); + if (startPos >= lastPos) + { + nlwarning(" empty target encountered"); + continue; + } if (!splitLinkTarget(targetNames[k].substr(startPos, lastPos - startPos+1), parentGroup, ti.PropertyName, ti.Elem)) { @@ -531,6 +574,70 @@ namespace NLGUI } + // *************************************************************************** + bool CInterfaceLink::splitLinkTargetsExt(const std::string &targets, CInterfaceGroup *parentGroup,std::vector &targetsVect, std::vector &cdbTargetsVect) + { + std::vector targetNames; + NLMISC::splitString(targets, ",", targetNames); + targetsVect.clear(); + targetsVect.reserve(targetNames.size()); + cdbTargetsVect.clear(); // no reserve because less used + bool everythingOk = true; + for (uint k = 0; k < targetNames.size(); ++k) + { + std::string::size_type startPos = targetNames[k].find_first_not_of(" "); + if(startPos == std::string::npos) + { + // todo hulud interface syntax error + nlwarning(" empty target encountered"); + continue; + } + std::string::size_type lastPos = targetNames[k].find_last_not_of(" "); + if (startPos >= (lastPos+1)) + { + nlwarning(" empty target encountered"); + continue; + } + + if (targetNames[k][startPos] == '@') + { + CInterfaceLink::CCDBTargetInfo ti; + ti.LeafName = targetNames[k].substr((startPos+1), (lastPos+1) - (startPos+1)); + // Do not allow Write on SERVER: or LOCAL: + static const std::string dbServer= "SERVER:"; + static const std::string dbLocal= "LOCAL:"; + static const std::string dbLocalR2= "LOCAL:R2"; + if( (0==ti.LeafName.compare(0, dbServer.size(), dbServer)) || + (0==ti.LeafName.compare(0, dbLocal.size(), dbLocal)) + ) + { + if (0!=ti.LeafName.compare(0, dbLocalR2.size(), dbLocalR2)) + { + //nlwarning("You are not allowed to write on 'SERVER:...' or 'LOCAL:...' database"); + nlstop; + return false; + } + } + ti.Leaf = NLGUI::CDBManager::getInstance()->getDbProp(ti.LeafName, false); + cdbTargetsVect.push_back(ti); + } + else + { + CInterfaceLink::CTargetInfo ti; + if (!splitLinkTarget(targetNames[k].substr(startPos, lastPos - startPos+1), parentGroup, ti.PropertyName, ti.Elem)) + { + // todo hulud interface syntax error + nlwarning(" Can't get link target"); + everythingOk = false; + continue; + } + targetsVect.push_back(ti); + } + } + return everythingOk; + } + + //=========================================================== void CInterfaceLink::checkNbRefs() { diff --git a/code/nel/src/gui/interface_parser.cpp b/code/nel/src/gui/interface_parser.cpp index 76f5df1ed..da8bd1e52 100644 --- a/code/nel/src/gui/interface_parser.cpp +++ b/code/nel/src/gui/interface_parser.cpp @@ -997,6 +997,7 @@ namespace NLGUI std::vector targets; + std::vector cdbTargets; ptr = (char*) xmlGetProp (cur, (xmlChar*)"target"); std::string target; @@ -1004,7 +1005,7 @@ namespace NLGUI { target = std::string( (const char*)ptr ); if( !editorMode ) - CInterfaceLink::splitLinkTargets(std::string((const char*)ptr), parentGroup, targets); + CInterfaceLink::splitLinkTargetsExt(std::string((const char*)ptr), parentGroup, targets, cdbTargets); } // optional action handler @@ -1022,7 +1023,7 @@ namespace NLGUI if( !editorMode ) { CInterfaceLink *il = new CInterfaceLink; - il->init(targets, expr, action, params, cond, parentGroup); // init will add 'il' in the list of link present in 'elm' + il->init(targets, cdbTargets, expr, action, params, cond, parentGroup); // init will add 'il' in the list of link present in 'elm' } else { diff --git a/code/nel/src/gui/link_hack.cpp b/code/nel/src/gui/link_hack.cpp index 7bc058891..1492012e1 100644 --- a/code/nel/src/gui/link_hack.cpp +++ b/code/nel/src/gui/link_hack.cpp @@ -24,6 +24,8 @@ namespace NLGUI { void ifexprufct_forcelink(); + void force_link_dbgroup_select_number_cpp(); + void force_link_dbgroup_combo_box_cpp(); /// Necessary so the linker doesn't drop the code of these classes from the library void LinkHack() @@ -33,5 +35,7 @@ namespace NLGUI CDBViewQuantity::forceLink(); CViewPointer::forceLink(); ifexprufct_forcelink(); + force_link_dbgroup_select_number_cpp(); + force_link_dbgroup_combo_box_cpp(); } } \ No newline at end of file diff --git a/code/nel/src/gui/lua_helper.cpp b/code/nel/src/gui/lua_helper.cpp index bc800725b..fb9466b36 100644 --- a/code/nel/src/gui/lua_helper.cpp +++ b/code/nel/src/gui/lua_helper.cpp @@ -197,6 +197,8 @@ namespace NLGUI { #ifdef LUA_NEVRAX_VERSION _State = lua_open(l_realloc_func, l_free_func); + #elif defined(LUA_VERSION_NUM) && LUA_VERSION_NUM >= 501 + _State = luaL_newstate(); #else _State = lua_open(); #endif @@ -361,7 +363,11 @@ namespace NLGUI rd.Str = &code; rd.Done = false; - int result = lua_load(_State, CHelper::luaChunkReaderFromString, (void *) &rd, dbgSrc.c_str()); + int result = lua_load(_State, CHelper::luaChunkReaderFromString, (void *) &rd, dbgSrc.c_str() +#if LUA_VERSION_NUM >= 502 + , NULL +#endif + ); if (result !=0) { // pop the error code @@ -569,9 +575,17 @@ namespace NLGUI //H_AUTO(Lua_CLuaState_registerFunc) nlassert(function); CLuaStackChecker lsc(this); +#if LUA_VERSION_NUM >= 502 + pushGlobalTable(); +#endif push(name); push(function); +#if LUA_VERSION_NUM >= 502 + setTable(-3); // -3 is the pushGlobalTable + pop(1); // pop the pushGlobalTable value (setTable popped the 2 pushes) +#else setTable(LUA_GLOBALSINDEX); +#endif } @@ -643,13 +657,31 @@ namespace NLGUI } // *************************************************************************** - int CLuaState::pcallByName(const char *functionName, int nargs, int nresults, int funcTableIndex /*=LUA_GLOBALSINDEX*/, int errfunc /*= 0*/) + int CLuaState::pcallByNameGlobal(const char *functionName, int nargs, int nresults, int errfunc /*= 0*/) + { + int initialStackSize = getTop(); + nlassert(functionName); +#if LUA_VERSION_NUM >= 502 + pushGlobalTable(); +#else + nlassert(isTable(LUA_GLOBALSINDEX)); + pushValue(LUA_GLOBALSINDEX); +#endif + return pcallByNameInternal(functionName, nargs, nresults, errfunc, initialStackSize); + } + + int CLuaState::pcallByName(const char *functionName, int nargs, int nresults, int funcTableIndex, int errfunc /*= 0*/) { - //H_AUTO(Lua_CLuaState_pcallByName) int initialStackSize = getTop(); nlassert(functionName); nlassert(isTable(funcTableIndex)); pushValue(funcTableIndex); + return pcallByNameInternal(functionName, nargs, nresults, errfunc, initialStackSize); + } + + int CLuaState::pcallByNameInternal(const char *functionName, int nargs, int nresults, int errfunc /*= 0*/, int initialStackSize) + { + //H_AUTO(Lua_CLuaState_pcallByName) push(functionName); getTable(-2); remove(-2); // get rid of the table @@ -782,7 +814,12 @@ namespace NLGUI int CLuaState::getGCCount() { //H_AUTO(Lua_CLuaState_getGCCount) +#if LUA_VERSION_NUM >= 502 + // deprecated + return 0; +#else return lua_getgccount(_State); +#endif } //================================================================================ diff --git a/code/nel/src/gui/lua_object.cpp b/code/nel/src/gui/lua_object.cpp index a7bbbb7f8..3f8924517 100644 --- a/code/nel/src/gui/lua_object.cpp +++ b/code/nel/src/gui/lua_object.cpp @@ -474,7 +474,11 @@ namespace NLGUI CLuaState *luaState = table.getLuaState(); CLuaStackChecker lsc(luaState); // get pointer to the 'next' function +#if LUA_VERSION_NUM >= 502 + luaState->pushGlobalTable(); +#else luaState->pushValue(LUA_GLOBALSINDEX); +#endif _NextFunction = CLuaObject(*luaState)["next"]; // nlassert(luaState); diff --git a/code/nel/src/gui/widget_manager.cpp b/code/nel/src/gui/widget_manager.cpp index 22839a8cf..4d7ada23d 100644 --- a/code/nel/src/gui/widget_manager.cpp +++ b/code/nel/src/gui/widget_manager.cpp @@ -1035,8 +1035,8 @@ namespace NLGUI setCapturePointerRight(NULL); resetColorProps(); - - _AlphaRolloverSpeedDB = NULL; + resetAlphaRolloverSpeedProps(); + resetGlobalAlphasProps(); activeAnims.clear(); } @@ -1967,10 +1967,18 @@ namespace NLGUI } // Update global color from database - setGlobalColor( NLMISC::CRGBA ( (uint8)CDBManager::getInstance()->getDbProp("UI:SAVE:COLOR:R")->getValue32(), - (uint8)CDBManager::getInstance()->getDbProp("UI:SAVE:COLOR:G")->getValue32(), - (uint8)CDBManager::getInstance()->getDbProp("UI:SAVE:COLOR:B")->getValue32(), - (uint8)CDBManager::getInstance()->getDbProp("UI:SAVE:COLOR:A")->getValue32() ) ); + if (!_RProp) + { + _RProp = CDBManager::getInstance()->getDbProp("UI:SAVE:COLOR:R"); + _GProp = CDBManager::getInstance()->getDbProp("UI:SAVE:COLOR:G"); + _BProp = CDBManager::getInstance()->getDbProp("UI:SAVE:COLOR:B"); + _AProp = CDBManager::getInstance()->getDbProp("UI:SAVE:COLOR:A"); + } + setGlobalColor(NLMISC::CRGBA( + (uint8)_RProp->getValue32(), + (uint8)_GProp->getValue32(), + (uint8)_BProp->getValue32(), + (uint8)_AProp->getValue32())); NLMISC::CRGBA c = getGlobalColorForContent(); NLMISC::CRGBA gc = getGlobalColor(); @@ -2965,7 +2973,7 @@ namespace NLGUI return fTmp*fTmp*fTmp; } - void CWidgetManager::resetAlphaRolloverSpeed() + void CWidgetManager::resetAlphaRolloverSpeedProps() { _AlphaRolloverSpeedDB = NULL; } @@ -2981,10 +2989,29 @@ namespace NLGUI void CWidgetManager::updateGlobalAlphas() { - _GlobalContentAlpha = (uint8)CDBManager::getInstance()->getDbProp("UI:SAVE:CONTENT_ALPHA")->getValue32(); - _GlobalContainerAlpha = (uint8)CDBManager::getInstance()->getDbProp("UI:SAVE:CONTAINER_ALPHA")->getValue32(); - _GlobalRolloverFactorContent = (uint8)CDBManager::getInstance()->getDbProp("UI:SAVE:CONTENT_ROLLOVER_FACTOR")->getValue32(); - _GlobalRolloverFactorContainer = (uint8)CDBManager::getInstance()->getDbProp("UI:SAVE:CONTAINER_ROLLOVER_FACTOR")->getValue32(); + if (!_GlobalContentAlphaDB) + { + _GlobalContentAlphaDB = CDBManager::getInstance()->getDbProp("UI:SAVE:CONTENT_ALPHA"); + nlassert(_GlobalContentAlphaDB); + _GlobalContainerAlphaDB = CDBManager::getInstance()->getDbProp("UI:SAVE:CONTAINER_ALPHA"); + nlassert(_GlobalContainerAlphaDB); + _GlobalContentRolloverFactorDB = CDBManager::getInstance()->getDbProp("UI:SAVE:CONTENT_ROLLOVER_FACTOR"); + nlassert(_GlobalContentRolloverFactorDB); + _GlobalContainerRolloverFactorDB = CDBManager::getInstance()->getDbProp("UI:SAVE:CONTAINER_ROLLOVER_FACTOR"); + nlassert(_GlobalContainerRolloverFactorDB); + } + _GlobalContentAlpha = (uint8)_GlobalContentAlphaDB->getValue32(); + _GlobalContainerAlpha = (uint8)_GlobalContainerAlphaDB->getValue32(); + _GlobalRolloverFactorContent = (uint8)_GlobalContentRolloverFactorDB->getValue32(); + _GlobalRolloverFactorContainer = (uint8)_GlobalContainerRolloverFactorDB->getValue32(); + } + + void CWidgetManager::resetGlobalAlphasProps() + { + _GlobalContentAlphaDB = NULL; + _GlobalContainerAlphaDB = NULL; + _GlobalContentRolloverFactorDB = NULL; + _GlobalContainerRolloverFactorDB = NULL; } void CWidgetManager::registerNewScreenSizeHandler( INewScreenSizeHandler *handler ) @@ -3156,6 +3183,7 @@ namespace NLGUI CWidgetManager::CWidgetManager() { + LinkHack(); CStringShared::createStringMapper(); CReflectableRegister::registerClasses(); @@ -3171,6 +3199,8 @@ namespace NLGUI _LastYContextHelp= -10000; resetColorProps(); + resetAlphaRolloverSpeedProps(); + resetGlobalAlphasProps(); _GlobalColor = NLMISC::CRGBA(255,255,255,255); _GlobalColorForContent = _GlobalColor; diff --git a/code/nel/tools/3d/CMakeLists.txt b/code/nel/tools/3d/CMakeLists.txt index 58360aec0..441a83800 100644 --- a/code/nel/tools/3d/CMakeLists.txt +++ b/code/nel/tools/3d/CMakeLists.txt @@ -1,61 +1,75 @@ -SUBDIRS( - build_coarse_mesh - build_far_bank - build_smallbank - ig_lighter - zone_dependencies - zone_ig_lighter - zone_lighter - zone_welder - animation_set_builder - anim_builder - build_clod_bank - build_clodtex - build_interface - build_shadow_skin - cluster_viewer - file_info - get_neighbors - ig_add - ig_info - shapes_exporter - tga_cut - tga_resize - zone_check_bind - zone_dump - zviewer) -IF(WIN32) - ADD_SUBDIRECTORY(ig_elevation) - ADD_SUBDIRECTORY(lightmap_optimizer) +IF(WITH_NEL_TOOLS) + SUBDIRS( + build_coarse_mesh + build_far_bank + build_smallbank + ig_lighter + zone_dependencies + zone_ig_lighter + zone_lighter + zone_welder + animation_set_builder + anim_builder + build_clod_bank + build_clodtex + build_interface + build_shadow_skin + cluster_viewer + file_info + get_neighbors + ig_add + ig_info + shapes_exporter + tga_cut + tga_resize + shape2obj + zone_check_bind + zone_dump + zviewer) + +ENDIF(WITH_NEL_TOOLS) + +# For tools selection of only max plugins +IF(WIN32) IF(MFC_FOUND) ADD_SUBDIRECTORY(object_viewer) - ADD_SUBDIRECTORY(object_viewer_exe) - ADD_SUBDIRECTORY(tile_edit) + IF(WITH_NEL_MAXPLUGIN) + IF(MAXSDK_FOUND) + ADD_SUBDIRECTORY(plugin_max) + ADD_SUBDIRECTORY(ligo) + ENDIF(MAXSDK_FOUND) + ENDIF(WITH_NEL_MAXPLUGIN) ENDIF(MFC_FOUND) - - IF(WITH_NEL_MAXPLUGIN) - IF(MAXSDK_FOUND) - ADD_SUBDIRECTORY(plugin_max) - ADD_SUBDIRECTORY(ligo) - ENDIF(MAXSDK_FOUND) - ENDIF(WITH_NEL_MAXPLUGIN) - ENDIF(WIN32) -IF(WITH_QT) - ADD_SUBDIRECTORY(tile_edit_qt) - ADD_SUBDIRECTORY(object_viewer_qt) - ADD_SUBDIRECTORY(object_viewer_widget) -ENDIF(WITH_QT) +IF(WITH_NEL_TOOLS) -IF(SQUISH_FOUND) + IF(WIN32) + ADD_SUBDIRECTORY(ig_elevation) + ADD_SUBDIRECTORY(lightmap_optimizer) + IF(MFC_FOUND) + ADD_SUBDIRECTORY(object_viewer_exe) + ADD_SUBDIRECTORY(tile_edit) + ENDIF(MFC_FOUND) + ENDIF(WIN32) + + IF(WITH_QT) + ADD_SUBDIRECTORY(tile_edit_qt) + ADD_SUBDIRECTORY(object_viewer_qt) + ADD_SUBDIRECTORY(object_viewer_widget) + ENDIF(WITH_QT) + + IF(SQUISH_FOUND) ADD_SUBDIRECTORY(s3tc_compressor_lib) - ADD_SUBDIRECTORY(panoply_maker) - ADD_SUBDIRECTORY(tga_2_dds) - ADD_SUBDIRECTORY(hls_bank_maker) -ENDIF(SQUISH_FOUND) + ADD_SUBDIRECTORY(panoply_maker) + ADD_SUBDIRECTORY(tga_2_dds) + ADD_SUBDIRECTORY(hls_bank_maker) + ENDIF(SQUISH_FOUND) + + #crash_log_analyser + #shapes_exporter + +ENDIF(WITH_NEL_TOOLS) -#crash_log_analyser -#shapes_exporter diff --git a/code/nel/tools/3d/object_viewer/object_viewer.cpp b/code/nel/tools/3d/object_viewer/object_viewer.cpp index 19490309b..bc9949079 100644 --- a/code/nel/tools/3d/object_viewer/object_viewer.cpp +++ b/code/nel/tools/3d/object_viewer/object_viewer.cpp @@ -1271,7 +1271,8 @@ void CObjectViewer::go () // Calc FPS static sint64 lastTime=NLMISC::CTime::getPerformanceTime (); sint64 newTime=NLMISC::CTime::getPerformanceTime (); - float fps = (float)(1.0 / NLMISC::CTime::ticksToSecond (newTime-lastTime)); + sint64 timeDiff = newTime - lastTime; + float fps = timeDiff > 0 ? (float)(1.0 / NLMISC::CTime::ticksToSecond (newTime-lastTime)) : 1000.0f; lastTime=newTime; char msgBar[1024]; uint nbPlayingSources, nbSources; diff --git a/code/nel/tools/3d/object_viewer_qt/src/images/nel_ide_load.png b/code/nel/tools/3d/object_viewer_qt/src/images/nel_ide_load.png index 217259d04..1ec9d823f 100644 Binary files a/code/nel/tools/3d/object_viewer_qt/src/images/nel_ide_load.png and b/code/nel/tools/3d/object_viewer_qt/src/images/nel_ide_load.png differ diff --git a/code/nel/tools/3d/plugin_max/scripts/startup/nel_material.ms b/code/nel/tools/3d/plugin_max/scripts/startup/nel_material.ms index 02f07dfe6..06021c45f 100644 --- a/code/nel/tools/3d/plugin_max/scripts/startup/nel_material.ms +++ b/code/nel/tools/3d/plugin_max/scripts/startup/nel_material.ms @@ -574,36 +574,6 @@ plugin material NelMaterial CheckBox cbUseSelfIllumColor "Use Color" checked:false align:#right ) - on cbTwoSided changed bval do - updateUI false - - on cpAmbient changed cval do - updateUI false - - on cpDiffuse changed cval do - updateUI false - - on spOpacity changed pval do - updateUI false - - on cpSpecular changed cval do - updateUI false - - on spSpecularLevel changed pval do - updateUI false - - on spGlossiness changed pval do - updateUI false - - on cpSelfIllumColor changed cval do - updateUI false - - on spSelfIllumAmount changed bval do - updateUI false - - on cbUseSelfIllumColor changed bval do - updateUI false - Fn updateUI update = ( if (version >= 14) then @@ -655,6 +625,36 @@ plugin material NelMaterial ) ) + on cbTwoSided changed bval do + updateUI false + + on cpAmbient changed cval do + updateUI false + + on cpDiffuse changed cval do + updateUI false + + on spOpacity changed pval do + updateUI false + + on cpSpecular changed cval do + updateUI false + + on spSpecularLevel changed pval do + updateUI false + + on spGlossiness changed pval do + updateUI false + + on cpSelfIllumColor changed cval do + updateUI false + + on spSelfIllumAmount changed bval do + updateUI false + + on cbUseSelfIllumColor changed bval do + updateUI false + on nelBasicParameters open do ( updateUI true diff --git a/code/nel/tools/3d/shape2obj/CMakeLists.txt b/code/nel/tools/3d/shape2obj/CMakeLists.txt new file mode 100644 index 000000000..c6fb25ec7 --- /dev/null +++ b/code/nel/tools/3d/shape2obj/CMakeLists.txt @@ -0,0 +1,9 @@ +FILE(GLOB SRC *.cpp) + +ADD_EXECUTABLE(shape2obj ${SRC}) + +TARGET_LINK_LIBRARIES(shape2obj nelmisc nel3d) +NL_DEFAULT_PROPS(shape2obj "NeL, Tools, 3D: shape2obj") +NL_ADD_RUNTIME_FLAGS(shape2obj) + +INSTALL(TARGETS shape2obj RUNTIME DESTINATION ${NL_BIN_PREFIX} COMPONENT tools3d) diff --git a/code/nel/tools/3d/shape2obj/main.cpp b/code/nel/tools/3d/shape2obj/main.cpp index 91945bdb6..66d9dd6c4 100644 --- a/code/nel/tools/3d/shape2obj/main.cpp +++ b/code/nel/tools/3d/shape2obj/main.cpp @@ -66,7 +66,7 @@ const CIndexBuffer *getRdrPassPrimitiveBlock(const CMeshMRMSkinnedGeom *mesh, ui bool ProcessMeshMRMSkinned(const std::string &filename, IShape *shapeMesh); bool ProcessMeshMRM(const std::string &filename, IShape *shapeMesh); -bool ProcessMesh(const std::string &filename, IShape *shapeMesh); +//bool ProcessMesh(const std::string &filename, IShape *shapeMesh); int main(int argc, char* argv[]) { @@ -110,7 +110,7 @@ int main(int argc, char* argv[]) if (ProcessMeshMRMSkinned(filename, shapeMesh)) return 0; if (ProcessMeshMRM(filename, shapeMesh)) return 0; - if (ProcessMesh(filename, shapeMesh)) return 0; +// if (ProcessMesh(filename, shapeMesh)) return 0; return 0; } @@ -519,6 +519,10 @@ bool ProcessMeshMRM(const std::string &filename, IShape *shapeMesh) return true; } +/* + +TODO: implement this + bool ProcessMesh(const std::string &filename, IShape *shapeMesh) { CMesh *mesh = dynamic_cast(shapeMesh); @@ -666,3 +670,5 @@ bool ProcessMesh(const std::string &filename, IShape *shapeMesh) return true; } + +*/ \ No newline at end of file diff --git a/code/nel/tools/CMakeLists.txt b/code/nel/tools/CMakeLists.txt index 49a8abef4..abc5dff02 100644 --- a/code/nel/tools/CMakeLists.txt +++ b/code/nel/tools/CMakeLists.txt @@ -1,28 +1,34 @@ -ADD_SUBDIRECTORY(misc) -ADD_SUBDIRECTORY(memory) +# Don't add other subdirectories if only max plugins are selected. +IF(WITH_NEL_TOOLS) + ADD_SUBDIRECTORY(misc) + ADD_SUBDIRECTORY(memory) +ENDIF(WITH_NEL_TOOLS) + +# Max plugins are under the 3d directory as well. IF(WITH_3D) ADD_SUBDIRECTORY(3d) ENDIF(WITH_3D) -IF(WITH_PACS) - ADD_SUBDIRECTORY(pacs) -ENDIF(WITH_PACS) - -IF(WITH_LOGIC) - ADD_SUBDIRECTORY(logic) -ENDIF(WITH_LOGIC) - -IF(WITH_GEORGES) - ADD_SUBDIRECTORY(georges) -ENDIF(WITH_GEORGES) - -IF(WITH_SOUND) - ADD_SUBDIRECTORY(sound) -ENDIF(WITH_SOUND) - -IF(WITH_NEL_TESTS) - ADD_SUBDIRECTORY(nel_unit_test) -ENDIF(WITH_NEL_TESTS) - -#build_gamedata +# Don't add other subdirectories if only max plugins are selected. +IF(WITH_NEL_TOOLS) + IF(WITH_PACS) + ADD_SUBDIRECTORY(pacs) + ENDIF(WITH_PACS) + + IF(WITH_LOGIC) + ADD_SUBDIRECTORY(logic) + ENDIF(WITH_LOGIC) + + IF(WITH_GEORGES) + ADD_SUBDIRECTORY(georges) + ENDIF(WITH_GEORGES) + + IF(WITH_SOUND) + ADD_SUBDIRECTORY(sound) + ENDIF(WITH_SOUND) + + IF(WITH_NEL_TESTS) + ADD_SUBDIRECTORY(nel_unit_test) + ENDIF(WITH_NEL_TESTS) +ENDIF(WITH_NEL_TOOLS) diff --git a/code/nel/tools/build_gamedata/generators/generate_simple_max_exporters.py b/code/nel/tools/build_gamedata/generators/generate_simple_max_exporters.py index f034c5d19..cd8a9039f 100644 --- a/code/nel/tools/build_gamedata/generators/generate_simple_max_exporters.py +++ b/code/nel/tools/build_gamedata/generators/generate_simple_max_exporters.py @@ -88,8 +88,6 @@ def generateSimpleMaxExporter(processName, fileExtension, sourceDirectoriesVaria -generateSimpleMaxExporter("pacs_prim", "pacs_prim", "PacsPrimSourceDirectories", "PacsPrimExportDirectory", "PacsPrimInstallDirectory") - generateSimpleMaxExporter("skel", "skel", "SkelSourceDirectories", "SkelExportDirectory", "SkelInstallDirectory") generateSimpleMaxExporter("swt", "swt", "SwtSourceDirectories", "SwtExportDirectory", "SwtInstallDirectory") diff --git a/code/nel/tools/build_gamedata/generators/generate_tagged_max_exporters.py b/code/nel/tools/build_gamedata/generators/generate_tagged_max_exporters.py index e10a23cea..89a65d3fb 100644 --- a/code/nel/tools/build_gamedata/generators/generate_tagged_max_exporters.py +++ b/code/nel/tools/build_gamedata/generators/generate_tagged_max_exporters.py @@ -100,6 +100,8 @@ def generateTaggedMaxExporter(processName, fileExtension, sourceDirectoriesVaria +generateTaggedMaxExporter("pacs_prim", "pacs_prim", "PacsPrimSourceDirectories", "PacsPrimExportDirectory", "PacsPrimTagExportDirectory", "PacsPrimInstallDirectory") + generateTaggedMaxExporter("clodbank", "clod", "ClodSourceDirectories", "ClodExportDirectory", "ClodTagExportDirectory", "ClodInstallDirectory") generateTaggedMaxScript("ig", "ig") diff --git a/code/nel/tools/build_gamedata/processes/pacs_prim/1_export.py b/code/nel/tools/build_gamedata/processes/pacs_prim/1_export.py index b793fe0f8..f551228c0 100644 --- a/code/nel/tools/build_gamedata/processes/pacs_prim/1_export.py +++ b/code/nel/tools/build_gamedata/processes/pacs_prim/1_export.py @@ -6,7 +6,7 @@ # # \file 1_export.py # \brief Export pacs_prim -# \date 2011-09-28-07-42-GMT +# \date 2013-07-24-14-21-GMT # \author Jan Boon (Kaetemi) # Python port of game data build pipeline. # Export pacs_prim @@ -33,7 +33,9 @@ sys.path.append("../../configuration") if os.path.isfile("log.log"): os.remove("log.log") -log = open("log.log", "w") +if os.path.isfile("temp_log.log"): + os.remove("temp_log.log") +log = open("temp_log.log", "w") from scripts import * from buildsite import * from process import * @@ -47,6 +49,7 @@ printLog(log, "-------") printLog(log, time.strftime("%Y-%m-%d %H:%MGMT", time.gmtime(time.time()))) printLog(log, "") + # Find tools # ... @@ -58,15 +61,18 @@ if MaxAvailable: printLog(log, ">>> Export pacs_prim 3dsmax <<<") mkPath(log, ExportBuildDirectory + "/" + PacsPrimExportDirectory) + mkPath(log, ExportBuildDirectory + "/" + PacsPrimTagExportDirectory) for dir in PacsPrimSourceDirectories: mkPath(log, DatabaseDirectory + "/" + dir) - if (needUpdateDirByTagLog(log, DatabaseDirectory + "/" + dir, ".max", ExportBuildDirectory + "/" + PacsPrimExportDirectory, ".pacs_prim")): + if (needUpdateDirByTagLog(log, DatabaseDirectory + "/" + dir, ".max", ExportBuildDirectory + "/" + PacsPrimTagExportDirectory, ".max.tag")): scriptSrc = "maxscript/pacs_prim_export.ms" scriptDst = MaxUserDirectory + "/scripts/pacs_prim_export.ms" outputLogfile = ScriptDirectory + "/processes/pacs_prim/log.log" outputDirectory = ExportBuildDirectory + "/" + PacsPrimExportDirectory + tagDirectory = ExportBuildDirectory + "/" + PacsPrimTagExportDirectory maxSourceDir = DatabaseDirectory + "/" + dir - tagList = findFiles(log, outputDirectory, "", ".pacs_prim") + maxRunningTagFile = tagDirectory + "/max_running.tag" + tagList = findFiles(log, tagDirectory, "", ".max.tag") tagLen = len(tagList) if os.path.isfile(scriptDst): os.remove(scriptDst) @@ -77,18 +83,50 @@ if MaxAvailable: newline = line.replace("%OutputLogfile%", outputLogfile) newline = newline.replace("%MaxSourceDirectory%", maxSourceDir) newline = newline.replace("%OutputDirectory%", outputDirectory) + newline = newline.replace("%TagDirectory%", tagDirectory) sDst.write(newline) sSrc.close() sDst.close() + zeroRetryLimit = 3 while tagDiff > 0: + mrt = open(maxRunningTagFile, "w") + mrt.write("moe-moe-kyun") + mrt.close() printLog(log, "MAXSCRIPT " + scriptDst) subprocess.call([ Max, "-U", "MAXScript", "pacs_prim_export.ms", "-q", "-mi", "-vn" ]) - tagList = findFiles(log, outputDirectory, "", ".pacs_prim") + if os.path.exists(outputLogfile): + try: + lSrc = open(outputLogfile, "r") + for line in lSrc: + lineStrip = line.strip() + if (len(lineStrip) > 0): + printLog(log, lineStrip) + lSrc.close() + os.remove(outputLogfile) + except Exception: + printLog(log, "ERROR Failed to read 3dsmax log") + else: + printLog(log, "WARNING No 3dsmax log") + tagList = findFiles(log, tagDirectory, "", ".max.tag") newTagLen = len(tagList) tagDiff = newTagLen - tagLen tagLen = newTagLen - printLog(log, "Exported " + str(tagDiff) + " .pacs_prim files!") + addTagDiff = 0 + if os.path.exists(maxRunningTagFile): + printLog(log, "FAIL 3ds Max crashed and/or file export failed!") + if tagDiff == 0: + if zeroRetryLimit > 0: + zeroRetryLimit = zeroRetryLimit - 1 + addTagDiff = 1 + else: + printLog(log, "FAIL Retry limit reached!") + else: + addTagDiff = 1 + os.remove(maxRunningTagFile) + printLog(log, "Exported " + str(tagDiff) + " .max files!") + tagDiff += addTagDiff os.remove(scriptDst) + printLog(log, "") @@ -99,8 +137,10 @@ if os.path.isfile(listPath): -printLog(log, "") log.close() +if os.path.isfile("log.log"): + os.remove("log.log") +shutil.move("temp_log.log", "log.log") # end of file diff --git a/code/nel/tools/build_gamedata/processes/pacs_prim/maxscript/pacs_prim_export.ms b/code/nel/tools/build_gamedata/processes/pacs_prim/maxscript/pacs_prim_export.ms index 21bdcdd4c..ddfc0014a 100644 --- a/code/nel/tools/build_gamedata/processes/pacs_prim/maxscript/pacs_prim_export.ms +++ b/code/nel/tools/build_gamedata/processes/pacs_prim/maxscript/pacs_prim_export.ms @@ -8,6 +8,9 @@ -- Allocate 20 Me for the script heapSize += 15000000 +-- In case of error just abort the app and don't show nel report window +NelForceQuitOnMsgDisplayer() + nlErrorFilename = "%OutputLogfile%" nlErrorStream = openFile nlErrorFilename mode:"a" if nlErrorStream == undefined then @@ -110,75 +113,128 @@ fn runNelMaxExport inputMaxFile = +removeRunningTag = true + try ( - -- Get files in the %MaxSourceDirectory% directory - files = getFiles "%MaxSourceDirectory%/*.max" - gc() - - -- Sort files - sort files - gc() - - -- No file ? - if files.count != 0 then + undo off ( - -- For each files - for i = 1 to files.count do + -- Get files in the %MaxSourceDirectory% directory + files = getFiles "%MaxSourceDirectory%/*.max" + gc() + + -- Sort files + sort files + gc() + + -- No file ? + if files.count != 0 then ( - inputMaxFile = files[i] - outputNelFile = ("%OutputDirectory%/" + (getFilenameFile inputMaxFile) + ".pacs_prim") - - try + -- For each files + for i = 1 to files.count do ( - -- Compare file date - if (NeLTestFileDate outputNelFile inputMaxFile) == true then - ( - -- Free memory and file handles - gc() - heapfree - - -- Reset 3dsmax - resetMAXFile #noprompt - - -- Open the max project - nlerror("Scanning file " + inputMaxFile + " ...") - if (loadMaxFile inputMaxFile quiet:true) == true then + inputMaxFile = files[i] + outputTagFile = ("%TagDirectory%/" + (getFilenameFile inputMaxFile) + (getFilenameType inputMaxFile) + ".tag") + + --try + --( + -- Compare file date + if (NeLTestFileDate outputTagFile inputMaxFile) == true then ( - runNelMaxExport(inputMaxFile) + -- Free memory and file handles + gc() + heapfree + + -- Reset 3dsmax + resetMAXFile #noprompt + + -- Open the max project + nlerror("Scanning file " + inputMaxFile + " ...") + if (loadMaxFile inputMaxFile quiet:true) == true then + ( + tagThisFile = runNelMaxExport(inputMaxFile) + + -- Write a tag file + if tagThisFile == true then + ( + tagFile = createFile outputTagFile + if tagFile == undefined then + ( + nlerror("WARNING can't create tag file " + outputTagFile) + removeRunningTag = false + ) + else + ( + print "mukyu" to: tagFile + close tagFile + ) + ) + else + ( + removeRunningTag = false + ) + ) + else + ( + -- Error + nlerror("ERROR exporting 'pacs_prim': can't open the file " + inputMaxFile) + removeRunningTag = false + ) ) else ( - -- Error - nlerror("ERROR exporting 'pacs_prim': can't open the file " + inputMaxFile) + nlerror("SKIPPED BY TAG " + inputMaxFile) ) - ) - else - ( - nlerror("SKIPPED " + inputMaxFile) - ) - ) - catch - ( - -- Error - nlerror("ERROR error exporting 'pacs_prim' in files " + inputMaxFile) + --) + --catch + --( + -- -- Error + -- nlerror("ERROR error exporting 'pacs_prim' in file " + inputMaxFile) + -- removeRunningTag = false + --) ) ) - ) - else - ( - nlerror("WARNING no *.max file in folder %MaxSourceDirectory%") + else + ( + nlerror("WARNING no *.max file in folder %MaxSourceDirectory%") + ) ) ) catch ( -- Error - nlerror("ERROR fatal error exporting 'pacs_prim' in folder %MaxSourceDirectory%") + nlerror("ERROR Fatal error exporting 'pacs_prim' in folder %MaxSourceDirectory%") + nlerror("FAIL Fatal error occured") + NelForceQuitRightNow() + removeRunningTag = false +) + +try +( + if (removeRunningTag) then + ( + resetMAXFile #noPrompt + ) +) +catch +( + nlerror("FAIL Last reset fails") + removeRunningTag = false +) + +if (removeRunningTag) then +( + nlerror("SUCCESS All .max files have been successfully exported") + deleteFile("%TagDirectory%/max_running.tag") +) +else +( + nlerror("FAIL One or more issues occured") + NelForceQuitRightNow() ) -- Bye - -resetMAXFile #noprompt +nlerror("BYE") quitMAX #noPrompt quitMAX() #noPrompt diff --git a/code/ryzom/CMakeLists.txt b/code/ryzom/CMakeLists.txt index 991437159..95ed56c46 100644 --- a/code/ryzom/CMakeLists.txt +++ b/code/ryzom/CMakeLists.txt @@ -46,6 +46,12 @@ IF(WITH_RYZOM_CLIENT) ENDIF(CURL_STATIC) ADD_SUBDIRECTORY(client) + +ELSEIF(WITH_RYZOM_TOOLS) + + # Need clientsheets lib for sheets packer tool + ADD_SUBDIRECTORY(client) + ENDIF(WITH_RYZOM_CLIENT) IF(WITH_RYZOM_TOOLS) @@ -53,6 +59,14 @@ IF(WITH_RYZOM_TOOLS) ENDIF(WITH_RYZOM_TOOLS) IF(WITH_RYZOM_SERVER) + FIND_PACKAGE(MySQL REQUIRED) ADD_SUBDIRECTORY(server) + +ELSEIF(WITH_RYZOM_TOOLS) + + # Need servershare for build packed collision tool + # Need aishare for build wmap tool + ADD_SUBDIRECTORY(server) + ENDIF(WITH_RYZOM_SERVER) diff --git a/code/ryzom/client/CMakeLists.txt b/code/ryzom/client/CMakeLists.txt index 36090be7b..78cbbbd04 100644 --- a/code/ryzom/client/CMakeLists.txt +++ b/code/ryzom/client/CMakeLists.txt @@ -1,4 +1,9 @@ + +# Need clientsheets lib for sheets packer tool ADD_SUBDIRECTORY(src) + +IF(WITH_RYZOM_CLIENT) + #ADD_SUBDIRECTORY(data) #ADD_SUBDIRECTORY(patcher) @@ -12,3 +17,5 @@ IF(RYZOM_ETC_PREFIX) ELSE(RYZOM_ETC_PREFIX) INSTALL(FILES client_default.cfg DESTINATION etc/ryzom) ENDIF(RYZOM_ETC_PREFIX) + +ENDIF(WITH_RYZOM_CLIENT) diff --git a/code/ryzom/client/client_default.cfg b/code/ryzom/client/client_default.cfg index f95a5c2b6..05c0db137 100644 --- a/code/ryzom/client/client_default.cfg +++ b/code/ryzom/client/client_default.cfg @@ -126,24 +126,24 @@ AutoEquipTool = 1; // *** LANDSCAPE -LandscapeTileNear = 150.000000; -LandscapeTileNear_min = 20.000000; -LandscapeTileNear_max = 250.000000; -LandscapeTileNear_step = 10.0; -LandscapeTileNear_ps0 = 20.0; -LandscapeTileNear_ps1 = 100.0; -LandscapeTileNear_ps2 = 150.0; -LandscapeTileNear_ps3 = 200.0; +LandscapeTileNear = 50.000000; +LandscapeTileNear_min = 20.000000; +LandscapeTileNear_max = 100.000000; +LandscapeTileNear_step = 10.0; +LandscapeTileNear_ps0 = 20.0; +LandscapeTileNear_ps1 = 40.0; +LandscapeTileNear_ps2 = 50.0; +LandscapeTileNear_ps3 = 80.0; // NB: threshold is inverted ULandscape::setThreshold(), to be more intelligible -LandscapeThreshold = 2000.0; -LandscapeThreshold_min = 100.0; // Low quality => 0.01 threshold -LandscapeThreshold_max = 4000.0; // High quality => 0.0005 threshold -LandscapeThreshold_step = 100.0; -LandscapeThreshold_ps0 = 100.0; -LandscapeThreshold_ps1 = 1000.0; -LandscapeThreshold_ps2 = 2000.0; -LandscapeThreshold_ps3 = 3000.0; +LandscapeThreshold = 1000.0; +LandscapeThreshold_min = 100.0; // Low quality => 0.01 threshold +LandscapeThreshold_max = 2000.0; // High quality => 0.0005 threshold +LandscapeThreshold_step = 100.0; +LandscapeThreshold_ps0 = 100.0; +LandscapeThreshold_ps1 = 500.0; +LandscapeThreshold_ps2 = 1000.0; +LandscapeThreshold_ps3 = 2000.0; Vision = 500.000000; Vision_min = 200.000000; diff --git a/code/ryzom/client/client_default.cfg.in b/code/ryzom/client/client_default.cfg.in index 41c3dd1de..030a4a2b2 100644 --- a/code/ryzom/client/client_default.cfg.in +++ b/code/ryzom/client/client_default.cfg.in @@ -126,24 +126,24 @@ AutoEquipTool = 1; // *** LANDSCAPE -LandscapeTileNear = 150.000000; -LandscapeTileNear_min = 20.000000; -LandscapeTileNear_max = 250.000000; -LandscapeTileNear_step = 10.0; -LandscapeTileNear_ps0 = 20.0; -LandscapeTileNear_ps1 = 100.0; -LandscapeTileNear_ps2 = 150.0; -LandscapeTileNear_ps3 = 200.0; +LandscapeTileNear = 50.000000; +LandscapeTileNear_min = 20.000000; +LandscapeTileNear_max = 100.000000; +LandscapeTileNear_step = 10.0; +LandscapeTileNear_ps0 = 20.0; +LandscapeTileNear_ps1 = 40.0; +LandscapeTileNear_ps2 = 50.0; +LandscapeTileNear_ps3 = 80.0; // NB: threshold is inverted ULandscape::setThreshold(), to be more intelligible -LandscapeThreshold = 2000.0; -LandscapeThreshold_min = 100.0; // Low quality => 0.01 threshold -LandscapeThreshold_max = 4000.0; // High quality => 0.0005 threshold -LandscapeThreshold_step = 100.0; -LandscapeThreshold_ps0 = 100.0; -LandscapeThreshold_ps1 = 1000.0; -LandscapeThreshold_ps2 = 2000.0; -LandscapeThreshold_ps3 = 3000.0; +LandscapeThreshold = 1000.0; +LandscapeThreshold_min = 100.0; // Low quality => 0.01 threshold +LandscapeThreshold_max = 2000.0; // High quality => 0.0005 threshold +LandscapeThreshold_step = 100.0; +LandscapeThreshold_ps0 = 100.0; +LandscapeThreshold_ps1 = 500.0; +LandscapeThreshold_ps2 = 1000.0; +LandscapeThreshold_ps3 = 2000.0; Vision = 500.000000; Vision_min = 200.000000; diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/bg_downloader.lua b/code/ryzom/client/data/gamedev/interfaces_v3/bg_downloader.lua index 686e21b6c..c2569b301 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/bg_downloader.lua +++ b/code/ryzom/client/data/gamedev/interfaces_v3/bg_downloader.lua @@ -84,7 +84,7 @@ function bgdownloader:setPatchProgress(progress) self:getPrioCB().active = true local progressPercentText = string.format("%d%%", 100 * progress) - local progressPostfix = math.mod(os.time(), 3) + local progressPostfix = math.fmod(os.time(), 3) local progressDate = nltime.getLocalTime() / 500 local colValue = math.floor(230 + 24 * math.sin(progressDate)) local color = string.format("%d %d %d %d", colValue, colValue, colValue, 255) diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/config.xml b/code/ryzom/client/data/gamedev/interfaces_v3/config.xml index 630ecd4c6..4114143e5 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/config.xml +++ b/code/ryzom/client/data/gamedev/interfaces_v3/config.xml @@ -2882,15 +2882,12 @@ This MUST follow the Enum MISSION_DESC::TIconId type="bool" value="true" /> - - - + + + diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/game_r2_loading.lua b/code/ryzom/client/data/gamedev/interfaces_v3/game_r2_loading.lua index dd3af3c88..33a3810d3 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/game_r2_loading.lua +++ b/code/ryzom/client/data/gamedev/interfaces_v3/game_r2_loading.lua @@ -521,7 +521,7 @@ function GameR2Loading:validateLoading() local filename = GameR2Loading.CurrentFile - if string.find(filename, '\.r2', -3) == nil then + if string.find(filename, '.r2', -3) == nil then messageBox(i18n.get("uiR2EDLoadScenario_InvalidFileName")) return end diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/help.xml b/code/ryzom/client/data/gamedev/interfaces_v3/help.xml index 39cfb1af4..c774edd47 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/help.xml +++ b/code/ryzom/client/data/gamedev/interfaces_v3/help.xml @@ -863,8 +863,10 @@ + + value="http://localhost:40917/www/html/index.php" /> + + + + + + - - - - - - - - diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/interaction.lua b/code/ryzom/client/data/gamedev/interfaces_v3/interaction.lua index 07d081874..d36486e99 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/interaction.lua +++ b/code/ryzom/client/data/gamedev/interfaces_v3/interaction.lua @@ -131,7 +131,7 @@ local function levelToForceRegion(level) end local function levelToLevelForce(level) - return math.floor(math.mod(level, 50) * 5 / 50) + 1 + return math.floor(math.fmod(level, 50) * 5 / 50) + 1 end diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/login_main.xml b/code/ryzom/client/data/gamedev/interfaces_v3/login_main.xml index f6dab0c1e..648cbbb6a 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/login_main.xml +++ b/code/ryzom/client/data/gamedev/interfaces_v3/login_main.xml @@ -45,7 +45,7 @@ text_ref="BM BM" text_y="-2" reset_focus_on_hide="false" max_historic="0" onenter="set_keyboard_focus" params="target=ui:login:checkpass:content:submit_gr:eb_password:eb|select_all=false" - prompt="" enter_loose_focus="true" multi_line="false" max_num_chars="20" color="135 243 28 255" /> + prompt="" enter_loose_focus="true" multi_line="false" max_num_chars="12" color="135 243 28 255" /> + prompt="" enter_loose_focus="true" multi_line="false" max_num_chars="20" color="135 243 28 255" /> @@ -669,7 +669,7 @@ on_enter="leave_modal" options="no_bordure" mouse_pos="false" exit_key_pushed="t text_ref="BM BM" text_y="-2" on_focus="create_account_rules" on_focus_params="rules_password_conf" reset_focus_on_hide="false" max_historic="0" entry_type="password" onenter="set_keyboard_focus" params="target=ui:login:create_account:content:submit_gr:eb_email:eb|select_all=false" - prompt="" enter_loose_focus="true" multi_line="false" max_num_chars="8" color="135 243 28 255" /> + prompt="" enter_loose_focus="true" multi_line="false" max_num_chars="20" color="135 243 28 255" /> @@ -678,7 +678,7 @@ on_enter="leave_modal" options="no_bordure" mouse_pos="false" exit_key_pushed="t text_ref="BM BM" text_y="-2" on_focus="create_account_rules" on_focus_params="rules_email" reset_focus_on_hide="false" max_historic="0" onenter="" params="" - prompt="" enter_loose_focus="true" multi_line="false" max_num_chars="255" color="135 243 28 255" /> + prompt="" enter_loose_focus="true" multi_line="false" max_num_chars="254" color="135 243 28 255" /> - + + - + diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/player.lua b/code/ryzom/client/data/gamedev/interfaces_v3/player.lua index c1abe7b22..062f09690 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/player.lua +++ b/code/ryzom/client/data/gamedev/interfaces_v3/player.lua @@ -803,8 +803,8 @@ end function game:timeInSecondsToReadableTime(regenTime) - local seconds = math.mod(regenTime, 60) - local minutes = math.mod(math.floor(regenTime / 60), 60) + local seconds = math.fmod(regenTime, 60) + local minutes = math.fmod(math.floor(regenTime / 60), 60) local hours = math.floor(regenTime / 3600) local result = "" if seconds > 0 then result = concatUCString(tostring(seconds), i18n.get("uittSecondsShort")) end diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/ring_access_point.lua b/code/ryzom/client/data/gamedev/interfaces_v3/ring_access_point.lua index d07f5abee..ca04561f1 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/ring_access_point.lua +++ b/code/ryzom/client/data/gamedev/interfaces_v3/ring_access_point.lua @@ -904,7 +904,7 @@ function RingAccessPoint:onDraw() self.LastRefreshTime = nltime.getLocalTime() / 1000 --self:getWindow():find("refreshText").active = false else - local waitText = i18n.get("uiRAP_WaitMsg" .. math.mod(os.time(), 3)) + local waitText = i18n.get("uiRAP_WaitMsg" .. math.fmod(os.time(), 3)) self:setInfoMessage(waitText) --local refreshText = self:getWindow():find("refreshText") --if not self.ListReceived then diff --git a/code/ryzom/client/src/CMakeLists.txt b/code/ryzom/client/src/CMakeLists.txt index 93b141c95..6a08a5e76 100644 --- a/code/ryzom/client/src/CMakeLists.txt +++ b/code/ryzom/client/src/CMakeLists.txt @@ -1,10 +1,15 @@ + +# Need clientsheets lib for sheets packer tool +ADD_SUBDIRECTORY(client_sheets) + +IF(WITH_RYZOM_CLIENT) + # These are Windows/MFC apps IF(WIN32) # ADD_SUBDIRECTORY(bug_report) SET(SEVENZIP_LIBRARY "ryzom_sevenzip") ENDIF(WIN32) -ADD_SUBDIRECTORY(client_sheets) ADD_SUBDIRECTORY(seven_zip) FILE(GLOB CFG ../*.cfg ../*.cfg.in) @@ -124,3 +129,5 @@ IF(WITH_PCH) ENDIF(WITH_PCH) INSTALL(TARGETS ryzom_client RUNTIME DESTINATION ${RYZOM_GAMES_PREFIX} COMPONENT client BUNDLE DESTINATION /Applications) + +ENDIF(WITH_RYZOM_CLIENT) diff --git a/code/ryzom/client/src/cdb_synchronised.cpp b/code/ryzom/client/src/cdb_synchronised.cpp index 08189fdd4..45c57dd55 100644 --- a/code/ryzom/client/src/cdb_synchronised.cpp +++ b/code/ryzom/client/src/cdb_synchronised.cpp @@ -318,7 +318,11 @@ void CCDBSynchronised::writeInitInProgressIntoUIDB() { CInterfaceManager *pIM = CInterfaceManager::getInstance(); if (pIM) - NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:CDB_INIT_IN_PROGRESS")->setValueBool(_InitInProgress); + { + NLMISC::CCDBNodeLeaf *node = m_CDBInitInProgressDB ? (&*m_CDBInitInProgressDB) + : &*(m_CDBInitInProgressDB = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:CDB_INIT_IN_PROGRESS")); + node->setValueBool(_InitInProgress); + } else nlwarning("InterfaceManager not created"); } diff --git a/code/ryzom/client/src/cdb_synchronised.h b/code/ryzom/client/src/cdb_synchronised.h index 7f8f1fb5e..e5c2f4876 100644 --- a/code/ryzom/client/src/cdb_synchronised.h +++ b/code/ryzom/client/src/cdb_synchronised.h @@ -151,6 +151,8 @@ private: bool allInitPacketReceived() const { return _InitDeltaReceived == 2; } // Classic database + inventory void writeInitInProgressIntoUIDB(); + + NLMISC::CRefPtr m_CDBInitInProgressDB; }; diff --git a/code/ryzom/client/src/commands.cpp b/code/ryzom/client/src/commands.cpp index 406d554e3..3805122f2 100644 --- a/code/ryzom/client/src/commands.cpp +++ b/code/ryzom/client/src/commands.cpp @@ -5164,7 +5164,7 @@ NLMISC_COMMAND(luaObject, "Dump the content of a lua object", " [max CLuaIHMRyzom::debugInfo(e.what()); return false; } - luaState->pushValue(LUA_GLOBALSINDEX); + luaState->pushGlobalTable(); CLuaObject env; env.pop(*luaState); uint maxDepth; diff --git a/code/ryzom/client/src/cursor_functions.cpp b/code/ryzom/client/src/cursor_functions.cpp index a51877be1..8c3bc3a32 100644 --- a/code/ryzom/client/src/cursor_functions.cpp +++ b/code/ryzom/client/src/cursor_functions.cpp @@ -58,6 +58,7 @@ uint32 MissionRingId = 0; UInstance selectedInstance; const UInstance noSelectedInstance; string selectedInstanceURL; +static NLMISC::CRefPtr s_UserCharFade; /////////////// @@ -273,7 +274,8 @@ void checkUnderCursor() entity= EntitiesMngr.getEntityUnderPos(cursX, cursY, ClientCfg.SelectionDist, isPlayerUnderCursor); // If the mouse is over the player make the player transparent - CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:USER_CHAR_FADE", false); + CCDBNodeLeaf *pNL = s_UserCharFade ? &*s_UserCharFade + : &*(s_UserCharFade = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:USER_CHAR_FADE", false)); if ((pNL != NULL) && (pNL->getValue32() == 1) && UserEntity->selectable()) { // If the nearest entity is the player, hide! diff --git a/code/ryzom/client/src/entities.cpp b/code/ryzom/client/src/entities.cpp index eec5a6b5a..7bc478ce7 100644 --- a/code/ryzom/client/src/entities.cpp +++ b/code/ryzom/client/src/entities.cpp @@ -435,28 +435,47 @@ void CEntityManager::initialize(uint nbMaxEntity) for (i=0; igetDB()->addObserver(&MissionTargetObserver, textId ); + _MissionTargetTitleDB[i][j] = NLGUI::CDBManager::getInstance()->getDbProp(text, false); + nlassert(_MissionTargetTitleDB[i][j]); } // Add an Observer to the Team database for (i=0; igetDB()->addObserver(&TeamUIDObserver, textId ); + _GroupMemberUidDB[i] = NLGUI::CDBManager::getInstance()->getDbProp(text, false); + nlassert(_GroupMemberUidDB[i]); - textId = ICDBNode::CTextId( toString(TEAM_DB_PATH ":%d:NAME", i) ); + text = toString(TEAM_DB_PATH ":%d:NAME", i); + textId = ICDBNode::CTextId(text); NLGUI::CDBManager::getInstance()->getDB()->addObserver(&TeamPresentObserver, textId ); + _GroupMemberNameDB[i] = NLGUI::CDBManager::getInstance()->getDbProp(text, false); + nlassert(_GroupMemberNameDB[i]); } // Add an Observer to the Animal database for (i=0; igetDB()->addObserver(&AnimalUIDObserver, textId ); + std::string text = toString("SERVER:PACK_ANIMAL:BEAST%d:UID", i); + textId = ICDBNode::CTextId(text); + NLGUI::CDBManager::getInstance()->getDB()->addObserver(&AnimalUIDObserver, textId); + _BeastUidDB[i] = NLGUI::CDBManager::getInstance()->getDbProp(text, false); + nlassert(_BeastUidDB[i]); - textId = ICDBNode::CTextId( toString("SERVER:PACK_ANIMAL:BEAST%d:STATUS",i) ); - NLGUI::CDBManager::getInstance()->getDB()->addObserver(&AnimalStatusObserver, textId ); + text = toString("SERVER:PACK_ANIMAL:BEAST%d:STATUS", i); + textId = ICDBNode::CTextId(text); + NLGUI::CDBManager::getInstance()->getDB()->addObserver(&AnimalStatusObserver, textId); + _BeastStatusDB[i] = NLGUI::CDBManager::getInstance()->getDbProp(text, false); + nlassert(_BeastStatusDB[i]); + + text = toString("SERVER:PACK_ANIMAL:BEAST%d:TYPE", i); + _BeastTypeDB[i] = NLGUI::CDBManager::getInstance()->getDbProp(text, false); + nlassert(_BeastTypeDB[i]); } }// initialize // diff --git a/code/ryzom/client/src/entities.h b/code/ryzom/client/src/entities.h index 27551141a..f71240b63 100644 --- a/code/ryzom/client/src/entities.h +++ b/code/ryzom/client/src/entities.h @@ -29,6 +29,9 @@ #include "ground_fx_manager.h" #include "projectile_manager.h" #include "user_entity.h" +// Some constants +#include "game_share/mission_desc.h" +#include "game_share/inventories.h" // Misc. #include "nel/misc/types_nl.h" #include "nel/misc/stream.h" @@ -36,6 +39,7 @@ #include "nel/misc/vector.h" #include "nel/misc/file.h" #include "nel/misc/aabbox.h" +#include "nel/misc/cdb_leaf.h" // 3D #include "nel/3d/u_instance.h" // Std. @@ -149,6 +153,14 @@ private: NL3D::UInstance _LastInstanceUnderPos; + // DB node pointers used to update some entity flags + NLMISC::CRefPtr _MissionTargetTitleDB[MAX_NUM_MISSIONS][MAX_NUM_MISSION_TARGETS]; + NLMISC::CRefPtr _GroupMemberUidDB[8]; // MaxNumPeopleInTeam in people_interaction.h + NLMISC::CRefPtr _GroupMemberNameDB[8]; // MaxNumPeopleInTeam in people_interaction.h + NLMISC::CRefPtr _BeastUidDB[MAX_INVENTORY_ANIMAL]; + NLMISC::CRefPtr _BeastStatusDB[MAX_INVENTORY_ANIMAL]; + NLMISC::CRefPtr _BeastTypeDB[MAX_INVENTORY_ANIMAL]; + ////////////// //// DEBUG /// uint _NbUser; @@ -344,6 +356,13 @@ public: */ void refreshInsceneInterfaceOfFriendNPC(uint slot); + inline NLMISC::CCDBNodeLeaf *getMissionTargetTitleDB(int mission, int target) { return _MissionTargetTitleDB[mission][target]; } + inline NLMISC::CCDBNodeLeaf *getGroupMemberUidDB(int member) { return _GroupMemberUidDB[member]; } + inline NLMISC::CCDBNodeLeaf *getGroupMemberNameDB(int member) { return _GroupMemberNameDB[member]; } + inline NLMISC::CCDBNodeLeaf *getBeastUidDB(int beast) { return _BeastUidDB[beast]; } + inline NLMISC::CCDBNodeLeaf *getBeastStatusDB(int beast) { return _BeastStatusDB[beast]; } + inline NLMISC::CCDBNodeLeaf *getBeastTypeDB(int beast) { return _BeastTypeDB[beast]; } + private: // NB: don't return unselectable entities diff --git a/code/ryzom/client/src/entity_cl.cpp b/code/ryzom/client/src/entity_cl.cpp index 9aef8b1c8..0063c93f4 100644 --- a/code/ryzom/client/src/entity_cl.cpp +++ b/code/ryzom/client/src/entity_cl.cpp @@ -120,6 +120,7 @@ NLMISC::CRGBA CEntityCL::_PvpAllyColor; NLMISC::CRGBA CEntityCL::_GMTitleColor[CHARACTER_TITLE::EndGmTitle - CHARACTER_TITLE::BeginGmTitle + 1]; uint8 CEntityCL::_InvalidGMTitleCode = 0xFF; NLMISC::CRefPtr CEntityCL::_OpacityMinNodeLeaf; +NLMISC::CRefPtr CEntityCL::_ShowReticleLeaf; // Context help @@ -2646,7 +2647,7 @@ void CEntityCL::updateMissionTarget() for (j=0; jgetDbProp("SERVER:MISSIONS:"+toString(i)+":TARGET"+toString(j)+":TITLE", false); + CCDBNodeLeaf *prop = EntitiesMngr.getMissionTargetTitleDB(i, j); // NLGUI::CDBManager::getInstance()->getDbProp("SERVER:MISSIONS:"+toString(i)+":TARGET"+toString(j)+":TITLE", false); if (prop) { _MissionTarget = _NameId == (uint32)prop->getValue32(); @@ -2846,8 +2847,8 @@ void CEntityCL::updateIsInTeam () for (uint i=0; igetDbProp(toString(TEAM_DB_PATH ":%d:UID", i), false); - CCDBNodeLeaf *presentProp = NLGUI::CDBManager::getInstance()->getDbProp(toString(TEAM_DB_PATH ":%d:NAME", i), false); + CCDBNodeLeaf *uidProp = EntitiesMngr.getGroupMemberUidDB(i); + CCDBNodeLeaf *presentProp = EntitiesMngr.getGroupMemberNameDB(i); // If same Entity uid than the one in the Database, ok the entity is in the Player TEAM!! if (uidProp && uidProp->getValue32() == (sint32)dataSetId() && presentProp && presentProp->getValueBool() ) @@ -2876,9 +2877,9 @@ void CEntityCL::updateIsUserAnimal () for (uint i=0; igetDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d:UID", i), false); - CCDBNodeLeaf *statusProp = NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d:STATUS", i), false); - CCDBNodeLeaf *typeProp = NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d:TYPE", i), false); + CCDBNodeLeaf *uidProp = EntitiesMngr.getBeastUidDB(i); + CCDBNodeLeaf *statusProp = EntitiesMngr.getBeastStatusDB(i); + CCDBNodeLeaf *typeProp = EntitiesMngr.getBeastTypeDB(i); // I must have the same Id, and the animal entry must be ok. if(uidProp && statusProp && typeProp && uidProp->getValue32() == (sint32)dataSetId() && ANIMAL_STATUS::isSpawned((ANIMAL_STATUS::EAnimalStatus)(statusProp->getValue32()) )) @@ -3041,7 +3042,9 @@ void CEntityCL::updateVisiblePostPos(const NLMISC::TTime &/* currentTimeInMs */, bool bShowReticle = true; - CCDBNodeLeaf* node = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:SHOW_RETICLE"); + CCDBNodeLeaf *node = (CCDBNodeLeaf *)_ShowReticleLeaf ? &*_ShowReticleLeaf + : &*(_ShowReticleLeaf = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:SHOW_RETICLE", false)); + if (node) { bShowReticle = node->getValueBool(); diff --git a/code/ryzom/client/src/entity_cl.h b/code/ryzom/client/src/entity_cl.h index 696efc61d..f7a26e03f 100644 --- a/code/ryzom/client/src/entity_cl.h +++ b/code/ryzom/client/src/entity_cl.h @@ -1111,7 +1111,8 @@ protected: // for localSelectBox() computing sint64 _LastLocalSelectBoxComputeTime; - static NLMISC::CRefPtr _OpacityMinNodeLeaf; + static NLMISC::CRefPtr _OpacityMinNodeLeaf; + static NLMISC::CRefPtr _ShowReticleLeaf; protected: /** diff --git a/code/ryzom/client/src/interface_v3/action_handler_misc.cpp b/code/ryzom/client/src/interface_v3/action_handler_misc.cpp index 6a21858f5..54c8b6fac 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_misc.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_misc.cpp @@ -425,14 +425,15 @@ class CActionHandlerAddLink : public IActionHandler } std::vector targetsVect; - bool result = CInterfaceLink::splitLinkTargets(targets, parentGroup, targetsVect); + std::vector cdbTargetsVect; + bool result = CInterfaceLink::splitLinkTargetsExt(targets, parentGroup, targetsVect, cdbTargetsVect); if (!result) { nlwarning(" Couldn't parse all links"); } // add the link CInterfaceLink *il = new CInterfaceLink; - il->init(targetsVect, expr, ah, ahparam, ahcond, parentGroup); + il->init(targetsVect, cdbTargetsVect, expr, ah, ahparam, ahcond, parentGroup); CInterfaceManager *im = CInterfaceManager::getInstance(); CWidgetManager::getInstance()->getParser()->addLink(il, id); il->update(); diff --git a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp index 088bcc571..ae06d0997 100644 --- a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp +++ b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp @@ -108,7 +108,7 @@ ucstring CControlSheetTooltipInfoWaiter::infoValidated(CDBCtrlSheet* ctrlSheet, CLuaStackRestorer lsr(ls, 0); CLuaIHM::pushReflectableOnStack(*ls, (CReflectableRefPtrTarget *)ctrlSheet); - ls->pushValue(LUA_GLOBALSINDEX); + ls->pushGlobalTable(); CLuaObject game(*ls); game = game["game"]; game.callMethodByNameNoThrow(luaMethodName.c_str(), 1, 1); @@ -3170,7 +3170,7 @@ void CDBCtrlSheet::getContextHelp(ucstring &help) const _PhraseAdapter = new CSPhraseComAdpater; _PhraseAdapter->Phrase = pPM->getPhrase(phraseId); CLuaIHM::pushReflectableOnStack(*ls, _PhraseAdapter); - ls->pushValue(LUA_GLOBALSINDEX); + ls->pushGlobalTable(); CLuaObject game(*ls); game = game["game"]; game.callMethodByNameNoThrow("updatePhraseTooltip", 1, 1); diff --git a/code/ryzom/client/src/interface_v3/group_in_scene_user_info.cpp b/code/ryzom/client/src/interface_v3/group_in_scene_user_info.cpp index e313c7ae4..76d97c519 100644 --- a/code/ryzom/client/src/interface_v3/group_in_scene_user_info.cpp +++ b/code/ryzom/client/src/interface_v3/group_in_scene_user_info.cpp @@ -41,16 +41,77 @@ uint CGroupInSceneUserInfo::_BatLength = 0; CCDBNodeLeaf *CGroupInSceneUserInfo::_Value = NULL; CCDBNodeLeaf *CGroupInSceneUserInfo::_ValueBegin = NULL; CCDBNodeLeaf *CGroupInSceneUserInfo::_ValueEnd = NULL; +NLMISC::CRefPtr CGroupInSceneUserInfo::_GuildIconLeaf[256]; // *************************************************************************** NLMISC_REGISTER_OBJECT(CViewBase, CGroupInSceneUserInfo, std::string, "in_scene_user_info"); REGISTER_UI_CLASS(CGroupInSceneUserInfo) +namespace { + +// Has more entries than actually in config, as not all types have all entries. +class CConfigSaveInsceneDB +{ +public: + void setPrefix(const std::string &prefix) { _DBPrefix = prefix; } + inline NLMISC::CCDBNodeLeaf *getGuildSymbol() { return _GuildSymbol ? (&*_GuildSymbol) : &*(_GuildSymbol = NLGUI::CDBManager::getInstance()->getDbProp(_DBPrefix + "GUILD_SYMBOL")); } + inline NLMISC::CCDBNodeLeaf *getName() { return _Name ? (&*_Name) : &*(_Name = NLGUI::CDBManager::getInstance()->getDbProp(_DBPrefix + "NAME")); } + inline NLMISC::CCDBNodeLeaf *getTitle() { return _Title ? (&*_Title) : &*(_Title = NLGUI::CDBManager::getInstance()->getDbProp(_DBPrefix + "TITLE")); } + inline NLMISC::CCDBNodeLeaf *getRPTags() { return _RPTags ? (&*_RPTags) : &*(_RPTags = NLGUI::CDBManager::getInstance()->getDbProp(_DBPrefix + "RPTAGS")); } + inline NLMISC::CCDBNodeLeaf *getGuildName() { return _GuildName ? (&*_GuildName) : &*(_GuildName = NLGUI::CDBManager::getInstance()->getDbProp(_DBPrefix + "GUILD_NAME")); } + inline NLMISC::CCDBNodeLeaf *getHP() { return _HP ? (&*_HP) : &*(_HP = NLGUI::CDBManager::getInstance()->getDbProp(_DBPrefix + "HP")); } + inline NLMISC::CCDBNodeLeaf *getSta() { return _Sta ? (&*_Sta) : &*(_Sta = NLGUI::CDBManager::getInstance()->getDbProp(_DBPrefix + "STA")); } + inline NLMISC::CCDBNodeLeaf *getSap() { return _Sap ? (&*_Sap) : &*(_Sap = NLGUI::CDBManager::getInstance()->getDbProp(_DBPrefix + "SAP")); } + inline NLMISC::CCDBNodeLeaf *getFocus() { return _Focus ? (&*_Focus) : &*(_Focus = NLGUI::CDBManager::getInstance()->getDbProp(_DBPrefix + "FOCUS")); } + inline NLMISC::CCDBNodeLeaf *getAction() { return _Action ? (&*_Action) : &*(_Action = NLGUI::CDBManager::getInstance()->getDbProp(_DBPrefix + "ACTION")); } + inline NLMISC::CCDBNodeLeaf *getMessages() { return _Messages ? (&*_Messages) : &*(_Messages = NLGUI::CDBManager::getInstance()->getDbProp(_DBPrefix + "MESSAGES")); } + inline NLMISC::CCDBNodeLeaf *getPvPLogo() { return _PvPLogo ? (&*_PvPLogo) : &*(_PvPLogo = NLGUI::CDBManager::getInstance()->getDbProp(_DBPrefix + "PVP_LOGO")); } + inline NLMISC::CCDBNodeLeaf *getNPCName() { return _NPCName ? (&*_NPCName) : &*(_NPCName = NLGUI::CDBManager::getInstance()->getDbProp(_DBPrefix + "NPCNAME")); } + inline NLMISC::CCDBNodeLeaf *getNPCTitle() { return _NPCTitle ? (&*_NPCTitle) : &*(_NPCTitle = NLGUI::CDBManager::getInstance()->getDbProp(_DBPrefix + "NPCTITLE")); } + inline NLMISC::CCDBNodeLeaf *getMissionIcon() { return _MissionIcon ? (&*_MissionIcon) : &*(_MissionIcon = NLGUI::CDBManager::getInstance()->getDbProp(_DBPrefix + "MISSION_ICON")); } + inline NLMISC::CCDBNodeLeaf *getMiniMissionIcon() { return _MiniMissionIcon ? (&*_MiniMissionIcon) : &*(_MiniMissionIcon = NLGUI::CDBManager::getInstance()->getDbProp(_DBPrefix + "MINI_MISSION_ICON")); } +private: + std::string _DBPrefix; + NLMISC::CRefPtr _GuildSymbol; + NLMISC::CRefPtr _Name; + NLMISC::CRefPtr _Title; + NLMISC::CRefPtr _RPTags; + NLMISC::CRefPtr _GuildName; + NLMISC::CRefPtr _HP; + NLMISC::CRefPtr _Sta; + NLMISC::CRefPtr _Sap; + NLMISC::CRefPtr _Focus; + NLMISC::CRefPtr _Action; + NLMISC::CRefPtr _Messages; + NLMISC::CRefPtr _PvPLogo; + NLMISC::CRefPtr _NPCName; + NLMISC::CRefPtr _NPCTitle; + NLMISC::CRefPtr _MissionIcon; + NLMISC::CRefPtr _MiniMissionIcon; +}; + +CConfigSaveInsceneDB _ConfigSaveInsceneDB[4]; // USER/FRIEND/ENEMY/SOURCE +bool _ConfigSaveInsceneDBInit = false; + +#define SAVE_USER 0 +#define SAVE_FRIEND 1 +#define SAVE_ENEMY 2 +#define SAVE_SOURCE 3 + +} CGroupInSceneUserInfo::CGroupInSceneUserInfo(const TCtorParam ¶m) : CGroupInScene(param) { + if (!_ConfigSaveInsceneDBInit) + { + _ConfigSaveInsceneDB[0].setPrefix("UI:SAVE:INSCENE:USER:"); + _ConfigSaveInsceneDB[1].setPrefix("UI:SAVE:INSCENE:FRIEND:"); + _ConfigSaveInsceneDB[2].setPrefix("UI:SAVE:INSCENE:ENEMY:"); + _ConfigSaveInsceneDB[3].setPrefix("UI:SAVE:INSCENE:SOURCE:"); + _ConfigSaveInsceneDBInit = true; + } _Name = NULL; _Title = NULL; _GuildName = NULL; @@ -130,7 +191,7 @@ CGroupInSceneUserInfo *CGroupInSceneUserInfo::build (CEntityCL *entity) bool needPvPLogo= false; bool permanentContent = false; bool rpTags = false; - bool displayMissionIcons = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:INSCENE:FRIEND:MISSION_ICON")->getValueBool(); + bool displayMissionIcons = _ConfigSaveInsceneDB[SAVE_FRIEND].getMissionIcon()->getValueBool(); // Names const char *templateName; @@ -156,7 +217,6 @@ CGroupInSceneUserInfo *CGroupInSceneUserInfo::build (CEntityCL *entity) // Active fields and bars if ( isForageSource ) { - string dbEntry = "UI:SAVE:INSCENE:SOURCE:"; CForageSourceCL *forageSource = static_cast(entity); name = !entityName.empty() /*&& NLGUI::CDBManager::getInstance()->getDbProp(dbEntry+"NAME")->getValueBool()*/; @@ -175,32 +235,32 @@ CGroupInSceneUserInfo *CGroupInSceneUserInfo::build (CEntityCL *entity) } else if(npcFriendAndNeutral) { - string dbEntry; + int dbEntry; getBarSettings( pIM, user, entity->isPlayer(), _friend, dbEntry, bars ); // For RoleMasters, merchants etc... must display name and function, and nothing else for(uint i=0;igetDbProp(dbEntry+"NPCNAME")->getValueBool(); + name= !entityName.empty() && _ConfigSaveInsceneDB[dbEntry].getNPCName()->getValueBool(); symbol= false; - title= !entityTitle.empty() && CDBManager::getInstance()->getDbProp(dbEntry+"NPCTITLE")->getValueBool(); + title= !entityTitle.empty() && _ConfigSaveInsceneDB[dbEntry].getNPCTitle()->getValueBool(); guildName= false; templateName = "in_scene_user_info"; - rpTags = (!entityTag1.empty() || !entityTag2.empty() || !entityTag3.empty() || !entityTag4.empty() ) && NLGUI::CDBManager::getInstance()->getDbProp(dbEntry+"RPTAGS")->getValueBool(); + rpTags = (!entityTag1.empty() || !entityTag2.empty() || !entityTag3.empty() || !entityTag4.empty() ) && _ConfigSaveInsceneDB[dbEntry].getRPTags()->getValueBool(); } else { // Base entry in database - string dbEntry; + int dbEntry; getBarSettings( pIM, user, entity->isPlayer(), _friend, dbEntry, bars ); - name = !entityName.empty() && NLGUI::CDBManager::getInstance()->getDbProp(dbEntry+"NAME")->getValueBool(); - title = !entityTitle.empty() && NLGUI::CDBManager::getInstance()->getDbProp(dbEntry+"TITLE")->getValueBool(); - rpTags = (!entityTag1.empty() || !entityTag2.empty() || !entityTag3.empty() || !entityTag4.empty() ) && NLGUI::CDBManager::getInstance()->getDbProp(dbEntry+"RPTAGS")->getValueBool(); + name = !entityName.empty() && _ConfigSaveInsceneDB[dbEntry].getName()->getValueBool(); + title = !entityTitle.empty() && _ConfigSaveInsceneDB[dbEntry].getTitle()->getValueBool(); + rpTags = (!entityTag1.empty() || !entityTag2.empty() || !entityTag3.empty() || !entityTag4.empty() ) && _ConfigSaveInsceneDB[dbEntry].getRPTags()->getValueBool(); // if name is empty but not title, title is displayed as name - if (!title && entityName.empty() && !entityTitle.empty() && NLGUI::CDBManager::getInstance()->getDbProp(dbEntry+"NAME")->getValueBool()) + if (!title && entityName.empty() && !entityTitle.empty() && _ConfigSaveInsceneDB[dbEntry].getName()->getValueBool()) title = true; templateName = "in_scene_user_info"; // special guild - if(NLGUI::CDBManager::getInstance()->getDbProp(dbEntry+"GUILD_SYMBOL")->getValueBool()) + if(_ConfigSaveInsceneDB[dbEntry].getGuildSymbol()->getValueBool()) { // if symbol not still available, wait for one when VP received symbol = (entity->getGuildSymbol() != 0); @@ -211,7 +271,7 @@ CGroupInSceneUserInfo *CGroupInSceneUserInfo::build (CEntityCL *entity) symbol= false; needGuildSymbolId = false; } - if(NLGUI::CDBManager::getInstance()->getDbProp(dbEntry+"GUILD_NAME")->getValueBool()) + if(_ConfigSaveInsceneDB[dbEntry].getGuildName()->getValueBool()) { // if guild name not still available, wait for one when VP received guildName = (entity->getGuildNameID() != 0); @@ -222,7 +282,7 @@ CGroupInSceneUserInfo *CGroupInSceneUserInfo::build (CEntityCL *entity) guildName= false; needGuildNameId= false; } - needPvPLogo = NLGUI::CDBManager::getInstance()->getDbProp(dbEntry+"PVP_LOGO")->getValueBool(); + needPvPLogo = _ConfigSaveInsceneDB[dbEntry].getPvPLogo()->getValueBool(); eventFaction = (entity->getEventFactionID() != 0); } @@ -799,9 +859,9 @@ REGISTER_ACTION_HANDLER( CHandlerResetCharacterInScene, "reset_character_in_scen // *************************************************************************** -void CGroupInSceneUserInfo::getBarSettings( CInterfaceManager* pIM, bool isUser, bool isPlayer, bool isFriend, std::string& dbEntry, bool *bars ) +void CGroupInSceneUserInfo::getBarSettings( CInterfaceManager* pIM, bool isUser, bool isPlayer, bool isFriend, int &dbEntry, bool *bars ) { - dbEntry = isUser?"UI:SAVE:INSCENE:USER:":isFriend?"UI:SAVE:INSCENE:FRIEND:":"UI:SAVE:INSCENE:ENEMY:"; + dbEntry = isUser?SAVE_USER:isFriend?SAVE_FRIEND:SAVE_ENEMY; // if currently is edition mode, then bars are not displayed if (ClientCfg.R2EDEnabled && R2::isEditionCurrent()) { @@ -813,11 +873,11 @@ void CGroupInSceneUserInfo::getBarSettings( CInterfaceManager* pIM, bool isUser, } else { - bars[HP] = NLGUI::CDBManager::getInstance()->getDbProp(dbEntry+"HP")->getValueBool(); - bars[SAP] = (isUser || isFriend) && (isUser || isPlayer) && NLGUI::CDBManager::getInstance()->getDbProp(dbEntry+"SAP")->getValueBool(); - bars[STA] = (isUser || isFriend) && (isUser || isPlayer) && NLGUI::CDBManager::getInstance()->getDbProp(dbEntry+"STA")->getValueBool(); - bars[Focus] = (isUser || isFriend) && (isUser || isPlayer) && NLGUI::CDBManager::getInstance()->getDbProp(dbEntry+"FOCUS")->getValueBool(); - bars[Action] = (isUser) && NLGUI::CDBManager::getInstance()->getDbProp(dbEntry+"ACTION")->getValueBool(); + bars[HP] = _ConfigSaveInsceneDB[dbEntry].getHP()->getValueBool(); + bars[SAP] = (isUser || isFriend) && (isUser || isPlayer) && _ConfigSaveInsceneDB[dbEntry].getSap()->getValueBool(); + bars[STA] = (isUser || isFriend) && (isUser || isPlayer) && _ConfigSaveInsceneDB[dbEntry].getSta()->getValueBool(); + bars[Focus] = (isUser || isFriend) && (isUser || isPlayer) && _ConfigSaveInsceneDB[dbEntry].getFocus()->getValueBool(); + bars[Action] = (isUser) && _ConfigSaveInsceneDB[dbEntry].getAction()->getValueBool(); } } @@ -831,7 +891,7 @@ void CGroupInSceneUserInfo::setLeftGroupActive( bool active ) if ( _Entity->isUser() || _Entity->isForageSource() ) return; - string dbEntry; + int dbEntry; bool barSettings [NumBars]; getBarSettings( CInterfaceManager::getInstance(), _Entity->isUser(), _Entity->isPlayer(), _Entity->isViewedAsFriend(), dbEntry, barSettings ); @@ -943,8 +1003,13 @@ void CGroupInSceneUserInfo::updateDynamicData () if (_Entity->getGuildSymbol() != 0) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - string dbLeaf = "UI:ENTITY:GUILD:"+toString (_Entity->slot())+":ICON"; - NLGUI::CDBManager::getInstance()->getDbProp(dbLeaf)->setValue64(_Entity->getGuildSymbol()); + if (!_GuildIconLeaf[_Entity->slot()]) + { + string dbLeaf = "UI:ENTITY:GUILD:"+toString (_Entity->slot())+":ICON"; + _GuildIconLeaf[_Entity->slot()] = NLGUI::CDBManager::getInstance()->getDbProp(dbLeaf); + } + nlassert(&*_GuildIconLeaf[_Entity->slot()]); + (&*_GuildIconLeaf[_Entity->slot()])->setValue64(_Entity->getGuildSymbol()); } // Set the event faction diff --git a/code/ryzom/client/src/interface_v3/group_in_scene_user_info.h b/code/ryzom/client/src/interface_v3/group_in_scene_user_info.h index 4a9dd6ddd..3869a74b1 100644 --- a/code/ryzom/client/src/interface_v3/group_in_scene_user_info.h +++ b/code/ryzom/client/src/interface_v3/group_in_scene_user_info.h @@ -72,7 +72,7 @@ protected: }; /// Fill NumBars elements into bars and set dbEntry - static void getBarSettings( CInterfaceManager* pIM, bool isUser, bool isPlayer, bool isFriend, std::string& dbEntry, bool *bars ); + static void getBarSettings( CInterfaceManager* pIM, bool isUser, bool isPlayer, bool isFriend, int &dbEntry, bool *bars ); // The entity (character or forage source) CEntityCL *_Entity; @@ -97,6 +97,9 @@ protected: static NLMISC::CCDBNodeLeaf *_ValueBegin; static NLMISC::CCDBNodeLeaf *_ValueEnd; + // Guild icon leafs + static NLMISC::CRefPtr _GuildIconLeaf[256]; + // Special guild bool _NeedGuildNameId; bool _NeedGuildSymbolId; diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index d352aff91..9d1cb364a 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -511,6 +511,8 @@ CInterfaceManager::CInterfaceManager() _LogState = false; _KeysLoaded = false; CWidgetManager::getInstance()->resetColorProps(); + CWidgetManager::getInstance()->resetAlphaRolloverSpeedProps(); + CWidgetManager::getInstance()->resetGlobalAlphasProps(); _NeutralColor = NULL; _WarningColor = NULL; _ErrorColor = NULL; @@ -1420,8 +1422,9 @@ void CInterfaceManager::uninitInGame1 () _NeutralColor = NULL; _WarningColor = NULL; _ErrorColor = NULL; - CWidgetManager::getInstance()->resetAlphaRolloverSpeed(); CWidgetManager::getInstance()->resetColorProps(); + CWidgetManager::getInstance()->resetAlphaRolloverSpeedProps(); + CWidgetManager::getInstance()->resetGlobalAlphasProps(); #ifdef AJM_DEBUG_TRACK_INTERFACE_GROUPS CInterfaceManager::getInstance()->DebugTrackGroupsDump(); @@ -1978,7 +1981,11 @@ void CInterfaceManager::drawViews(NL3D::UCamera camera) // Update Player characteristics (for Item carac requirement Redifying) nlctassert(CHARACTERISTICS::NUM_CHARACTERISTICS==8); for (uint i=0; igetDbValue32(toString("SERVER:CHARACTER_INFO:CHARACTERISTICS%d:VALUE", i)); + { + NLMISC::CCDBNodeLeaf *node = _CurrentPlayerCharacLeaf[i] ? &*_CurrentPlayerCharacLeaf[i] + : &*(_CurrentPlayerCharacLeaf[i] = NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:CHARACTER_INFO:CHARACTERISTICS%d:VALUE", i), false)); + _CurrentPlayerCharac[i] = node ? node->getValue32() : 0; + } CWidgetManager::getInstance()->drawViews( camera ); diff --git a/code/ryzom/client/src/interface_v3/interface_manager.h b/code/ryzom/client/src/interface_v3/interface_manager.h index 567c07a7b..36bd909e3 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.h +++ b/code/ryzom/client/src/interface_v3/interface_manager.h @@ -633,7 +633,8 @@ private: std::vector _EmoteCmds; // Item Carac requirement - sint32 _CurrentPlayerCharac[CHARACTERISTICS::NUM_CHARACTERISTICS]; + sint32 _CurrentPlayerCharac[CHARACTERISTICS::NUM_CHARACTERISTICS]; + NLMISC::CRefPtr _CurrentPlayerCharacLeaf[CHARACTERISTICS::NUM_CHARACTERISTICS]; // observers for copying database branch changes CServerToLocalAutoCopy ServerToLocalAutoCopyInventory; diff --git a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp index 06b0b8557..fe4c6a716 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp +++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp @@ -187,9 +187,11 @@ static DECLARE_INTERFACE_USER_FCT(lua) // *** clear return value const std::string retId= "__ui_internal_ret_"; CLuaStackChecker lsc(&ls); + ls.pushGlobalTable(); ls.push(retId); ls.pushNil(); - ls.setTable(LUA_GLOBALSINDEX); + ls.setTable(-3); //pop pop + ls.pop(); // *** execute script @@ -201,8 +203,10 @@ static DECLARE_INTERFACE_USER_FCT(lua) // *** retrieve and convert return value + ls.pushGlobalTable(); ls.push(retId); - ls.getTable(LUA_GLOBALSINDEX); + ls.getTable(-2); + ls.remove(-2); bool ok= false; sint type= ls.type(); if (type==LUA_TBOOLEAN) @@ -370,7 +374,7 @@ void CLuaIHMRyzom::RegisterRyzomFunctions( NLGUI::CLuaState &ls ) ls.registerFunc("SNode", CUICtor::SNode); // *** Register the metatable for access to client.cfg (nb nico this may be more general later -> access to any config file ...) - ls.pushValue(LUA_GLOBALSINDEX); + ls.pushGlobalTable(); CLuaObject globals(ls); CLuaObject clientCfg = globals.newTable("config"); CLuaObject mt = globals.newTable("__cfmt"); diff --git a/code/ryzom/client/src/interface_v3/people_interraction.cpp b/code/ryzom/client/src/interface_v3/people_interraction.cpp index b0a050f29..95b091c22 100644 --- a/code/ryzom/client/src/interface_v3/people_interraction.cpp +++ b/code/ryzom/client/src/interface_v3/people_interraction.cpp @@ -558,7 +558,8 @@ void CPeopleInterraction::createTeamList() { CInterfaceLink *il = new CInterfaceLink; vector targets; - il->init(targets, sExpr, sAction, sParams, sCond, TeamChat->getContainer()); + vector cdbTargets; + il->init(targets, cdbTargets, sExpr, sAction, sParams, sCond, TeamChat->getContainer()); } } diff --git a/code/ryzom/client/src/interface_v3/sphrase_manager.cpp b/code/ryzom/client/src/interface_v3/sphrase_manager.cpp index 8abb66c8c..3d6155d23 100644 --- a/code/ryzom/client/src/interface_v3/sphrase_manager.cpp +++ b/code/ryzom/client/src/interface_v3/sphrase_manager.cpp @@ -941,6 +941,8 @@ void CSPhraseManager::reset() CSkillManager *pSM= CSkillManager::getInstance(); pBM->removeBrickLearnedCallback(&_ProgressionUpdate); pSM->removeSkillChangeCallback(&_ProgressionUpdate); + + _TotalMalusEquipLeaf = NULL; } // *************************************************************************** @@ -1122,7 +1124,9 @@ void CSPhraseManager::buildPhraseDesc(ucstring &text, const CSPhraseCom &phrase, // **** Compute Phrase Elements from phrase // get the current action malus (0-100) uint32 totalActionMalus= 0; - CCDBNodeLeaf *actMalus= NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:TOTAL_MALUS_EQUIP", false); + CCDBNodeLeaf *actMalus = _TotalMalusEquipLeaf ? &*_TotalMalusEquipLeaf + : &*(_TotalMalusEquipLeaf = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:TOTAL_MALUS_EQUIP", false)); + // root brick must not be Power or aura, because Action malus don't apply to them // (ie leave 0 ActionMalus for Aura or Powers if(actMalus && !rootBrick->isSpecialPower()) @@ -1652,7 +1656,8 @@ float CSPhraseManager::getPhraseSumBrickProp(const CSPhraseCom &phrase, uint else if(propId==CSBrickManager::getInstance()->StaPropId && brick->Properties[j].PropId==CSBrickManager::getInstance()->StaWeightFactorId) { CInterfaceManager *im = CInterfaceManager::getInstance(); - uint32 weight = (uint32) NLGUI::CDBManager::getInstance()->getDbProp("SERVER:USER:DEFAULT_WEIGHT_HANDS")->getValue32() / 10; // weight must be in dg here + if (!_ServerUserDefaultWeightHandsLeaf) _ServerUserDefaultWeightHandsLeaf = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:USER:DEFAULT_WEIGHT_HANDS"); + uint32 weight = (uint32)(&*_ServerUserDefaultWeightHandsLeaf)->getValue32() / 10; // weight must be in dg here CDBCtrlSheet *ctrlSheet = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:gestionsets:hands:handr")); if (ctrlSheet) { @@ -4501,7 +4506,8 @@ uint32 CSPhraseManager::getTotalActionMalus(const CSPhraseCom &phrase) const CInterfaceManager *pIM = CInterfaceManager::getInstance(); CSBrickManager *pBM= CSBrickManager::getInstance(); uint32 totalActionMalus= 0; - CCDBNodeLeaf *actMalus= NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:TOTAL_MALUS_EQUIP", false); + CCDBNodeLeaf *actMalus = _TotalMalusEquipLeaf ? &*_TotalMalusEquipLeaf + : &*(_TotalMalusEquipLeaf = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:TOTAL_MALUS_EQUIP", false)); // root brick must not be Power or aura, because Action malus don't apply to them // (ie leave 0 ActionMalus for Aura or Powers if (!phrase.Bricks.empty()) diff --git a/code/ryzom/client/src/interface_v3/sphrase_manager.h b/code/ryzom/client/src/interface_v3/sphrase_manager.h index b28ff39ed..c14b584ab 100644 --- a/code/ryzom/client/src/interface_v3/sphrase_manager.h +++ b/code/ryzom/client/src/interface_v3/sphrase_manager.h @@ -651,6 +651,10 @@ private: void computePhraseProgression(); void insertProgressionSkillRecurs(SKILLS::ESkills skill, uint32 value, sint *skillReqLevel, std::vector &skillsToInsert); + mutable NLMISC::CRefPtr _TotalMalusEquipLeaf; + + NLMISC::CRefPtr _ServerUserDefaultWeightHandsLeaf; + // @} /// return the skill of the root diff --git a/code/ryzom/client/src/main_loop.cpp b/code/ryzom/client/src/main_loop.cpp index 45c6b5b3a..59519fc69 100644 --- a/code/ryzom/client/src/main_loop.cpp +++ b/code/ryzom/client/src/main_loop.cpp @@ -382,6 +382,9 @@ CGameContextMenu GameContextMenu; NLMISC::CValueSmoother smoothFPS; NLMISC::CValueSmoother moreSmoothFPS(64); +static CRefPtr s_FpsLeaf; +static CRefPtr s_UiDirectionLeaf; + // Profile /* @@ -2296,7 +2299,8 @@ bool mainLoop() deltaTime = smoothFPS.getSmoothValue (); if (deltaTime > 0.0) { - CCDBNodeLeaf*pNL = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:FPS"); + CCDBNodeLeaf *pNL = s_FpsLeaf ? &*s_FpsLeaf + : &*(s_FpsLeaf = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:FPS")); pNL->setValue64((sint64)(1.f/deltaTime)); } } @@ -2801,8 +2805,10 @@ bool mainLoop() H_AUTO_USE ( RZ_Client_Main_Loop_Net ) // Put here things you have to send to the server only once per tick like user position. // UPDATE COMPASS + NLMISC::CCDBNodeLeaf *node = s_UiDirectionLeaf ? (&*s_UiDirectionLeaf) + : &*(s_UiDirectionLeaf = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:DIRECTION")); CInterfaceProperty prop; - prop.readDouble("UI:VARIABLES:DIRECTION"," "); + prop.setNodePtr(node); if(CompassMode == 1) { double camDir = atan2(View.view().y, View.view().x); @@ -3235,7 +3241,7 @@ class CHandlerDebugUiDumpElementUnderMouse : public IActionHandler if (!lua) return; CLuaStackRestorer lsr(lua, 0); CLuaIHM::pushUIOnStack(*lua, HighlightedDebugUI); - lua->pushValue(LUA_GLOBALSINDEX); + lua->pushGlobalTable(); CLuaObject env(*lua); env["inspect"].callNoThrow(1, 0); } diff --git a/code/ryzom/client/src/motion/user_controls.cpp b/code/ryzom/client/src/motion/user_controls.cpp index b780927e2..527bfb5d4 100644 --- a/code/ryzom/client/src/motion/user_controls.cpp +++ b/code/ryzom/client/src/motion/user_controls.cpp @@ -294,7 +294,9 @@ void CUserControls::update() // update camera collision once per frame View.updateCameraCollision(); - NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:MK_MOVE")->setValue32(autowalkState()); + NLMISC::CCDBNodeLeaf *node = _UiVarMkMoveDB ? &*_UiVarMkMoveDB + : &*(_UiVarMkMoveDB = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:MK_MOVE")); + node->setValue32(autowalkState()); }// update // diff --git a/code/ryzom/client/src/motion/user_controls.h b/code/ryzom/client/src/motion/user_controls.h index be1cbaf99..eb4de2020 100644 --- a/code/ryzom/client/src/motion/user_controls.h +++ b/code/ryzom/client/src/motion/user_controls.h @@ -31,6 +31,9 @@ // Std. #include +namespace NLMISC { + class CCDBNodeLeaf; +} /////////// // CLASS // @@ -305,6 +308,8 @@ private: /// when true the next forward action will cancel any moveto bool _NextForwardCancelMoveTo; + + NLMISC::CRefPtr _UiVarMkMoveDB; }; /// User Controls (mouse, keyboard, interfaces, ...) diff --git a/code/ryzom/client/src/net_manager.cpp b/code/ryzom/client/src/net_manager.cpp index f9a5628ca..1eedc16c5 100644 --- a/code/ryzom/client/src/net_manager.cpp +++ b/code/ryzom/client/src/net_manager.cpp @@ -3861,22 +3861,28 @@ bool CNetManager::update() CInterfaceManager *im = CInterfaceManager::getInstance(); if (im) { - CCDBNodeLeaf *node = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:PING", false); + CCDBNodeLeaf *node = m_PingLeaf ? &*m_PingLeaf + : &*(m_PingLeaf = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:PING", false)); if (node) node->setValue32(getPing()); - node = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:UPLOAD", false); + node = m_UploadLeaf ? &*m_UploadLeaf + : &*(m_UploadLeaf = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:UPLOAD", false)); if (node) node->setValue32((sint32)(getMeanUpload()*1024.f/8.f)); - node = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:DOWNLOAD", false); + node = m_DownloadLeaf ? &*m_DownloadLeaf + : &*(m_DownloadLeaf = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:DOWNLOAD", false)); if (node) node->setValue32((sint32)(getMeanDownload()*1024.f/8.f)); - node = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:PACKETLOST", false); + node = m_PacketLostLeaf ? &* m_PacketLostLeaf + : &*(m_PacketLostLeaf = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:PACKETLOST", false)); if (node) node->setValue32((sint32)getMeanPacketLoss()); - node = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:SERVERSTATE", false); + node = m_ServerStateLeaf ? &*m_ServerStateLeaf + : &*(m_ServerStateLeaf = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:SERVERSTATE", false)); if (node) node->setValue32((sint32)getConnectionState()); - node = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:CONNECTION_QUALITY", false); + node = m_ConnectionQualityLeaf ? &*m_ConnectionQualityLeaf + : &*(m_ConnectionQualityLeaf = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:CONNECTION_QUALITY", false)); if (node) node->setValue32((sint32)getConnectionQuality()); } diff --git a/code/ryzom/client/src/net_manager.h b/code/ryzom/client/src/net_manager.h index 9fef4bc1d..06d6a7621 100644 --- a/code/ryzom/client/src/net_manager.h +++ b/code/ryzom/client/src/net_manager.h @@ -43,6 +43,7 @@ void initializeNetwork(); namespace NLMISC { class CBitMemStream; + class CCDBNodeLeaf; }; @@ -126,6 +127,13 @@ public: protected: bool _IsReplayStarting; #endif + + NLMISC::CRefPtr m_PingLeaf; + NLMISC::CRefPtr m_UploadLeaf; + NLMISC::CRefPtr m_DownloadLeaf; + NLMISC::CRefPtr m_PacketLostLeaf; + NLMISC::CRefPtr m_ServerStateLeaf; + NLMISC::CRefPtr m_ConnectionQualityLeaf; }; diff --git a/code/ryzom/client/src/r2/dmc/com_lua_module.cpp b/code/ryzom/client/src/r2/dmc/com_lua_module.cpp index 80275d280..b91aca95c 100644 --- a/code/ryzom/client/src/r2/dmc/com_lua_module.cpp +++ b/code/ryzom/client/src/r2/dmc/com_lua_module.cpp @@ -77,7 +77,7 @@ CComLuaModule::CComLuaModule(CDynamicMapClient* client, lua_State *luaState /*= #ifdef LUA_NEVRAX_VERSION _LuaState = lua_open(NULL, NULL); #else - _LuaState = lua_open(); + _LuaState = luaL_newstate(); #endif _LuaOwnerShip = false; luaopen_base(_LuaState); @@ -105,7 +105,7 @@ CComLuaModule::CComLuaModule(CDynamicMapClient* client, lua_State *luaState /*= void CComLuaModule::initLuaLib() { //H_AUTO(R2_CComLuaModule_initLuaLib) - const luaL_reg methods[] = + const luaL_Reg methods[] = { {"updateScenario", CComLuaModule::luaUpdateScenario}, {"requestUpdateRtScenario", CComLuaModule::luaRequestUpdateRtScenario}, @@ -237,7 +237,12 @@ void CComLuaModule::initLuaLib() }; int initialStackSize = lua_gettop(_LuaState); +#if LUA_VERSION_NUM >= 502 + luaL_newlib(_LuaState, methods); + lua_setglobal(_LuaState, R2_LUA_PATH); +#else luaL_openlib(_LuaState, R2_LUA_PATH, methods, 0); +#endif lua_settop(_LuaState, initialStackSize); } @@ -1046,7 +1051,11 @@ void CComLuaModule::setObjectToLua(lua_State* state, CObject* object) { int initialStackSize = lua_gettop(state); +#if LUA_VERSION_NUM >= 502 + lua_pushglobaltable(state); // _G +#else lua_pushvalue(state, LUA_GLOBALSINDEX); // _G +#endif lua_pushstring(state, "r2"); // _G, "r2" lua_gettable(state, -2); // G, r2 @@ -1106,6 +1115,8 @@ void CComLuaModule::setObjectToLua(lua_State* state, CObject* object) } } +#if 0 + // okay! if (0) { @@ -1128,6 +1139,7 @@ void CComLuaModule::setObjectToLua(lua_State* state, CObject* object) } } } +#endif } else { @@ -1147,8 +1159,11 @@ CObject* CComLuaModule::getObjectFromLua(lua_State* state, sint idx) { if (lua_getmetatable(state, -1)) { - +#if LUA_VERSION_NUM >= 502 + lua_pushglobaltable(state); // obj, mt, _G +#else lua_pushvalue(state, LUA_GLOBALSINDEX); // obj, mt, _G +#endif lua_pushstring(state, "r2"); // obj, mt, _G, "r2" diff --git a/code/ryzom/client/src/r2/editor.cpp b/code/ryzom/client/src/r2/editor.cpp index bee527bbd..c27001140 100644 --- a/code/ryzom/client/src/r2/editor.cpp +++ b/code/ryzom/client/src/r2/editor.cpp @@ -2613,7 +2613,7 @@ void CEditor::init(TMode initialMode, TAccessMode accessMode) } // CLuaStackChecker lsc(&getLua()); - getLua().pushValue(LUA_GLOBALSINDEX); + getLua().pushGlobalTable(); _Globals.pop(getLua()); getLua().pushValue(LUA_REGISTRYINDEX); _Registry.pop(getLua()); @@ -3956,9 +3956,11 @@ void CEditor::release() // clear the environment if (CLuaManager::getInstance().getLuaState()) { + getLua().pushGlobalTable(); getLua().push(R2_LUA_PATH); getLua().pushNil(); - getLua().setTable(LUA_GLOBALSINDEX); + getLua().setTable(-3); // pop pop + getLua().pop(); _Globals.release(); _Registry.release(); _ObjectProjectionMetatable.release(); // AJM diff --git a/code/ryzom/client/src/r2/tool.cpp b/code/ryzom/client/src/r2/tool.cpp index ddc97fb95..995394b94 100644 --- a/code/ryzom/client/src/r2/tool.cpp +++ b/code/ryzom/client/src/r2/tool.cpp @@ -55,6 +55,7 @@ const uint32 DEFAULT_ENTITY_MIN_OPACITY = 128; bool CTool::_MouseCaptured = false; +NLMISC::CRefPtr CTool::_UserCharFade; static const CVector cardinals[] = { @@ -551,7 +552,8 @@ void CTool::handleMouseOverPlayer(bool over) { //H_AUTO(R2_CTool_handleMouseOverPlayer) // If the mouse is over the player make the player transparent - CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:USER_CHAR_FADE", false); + CCDBNodeLeaf *pNL = _UserCharFade ? &*_UserCharFade + : &*(_UserCharFade = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:USER_CHAR_FADE", false)); if ((pNL != NULL) && (pNL->getValue32() == 1) && UserEntity->selectable()) { // If the nearest entity is the player, hide! diff --git a/code/ryzom/client/src/r2/tool.h b/code/ryzom/client/src/r2/tool.h index f7262efc4..d36c514c1 100644 --- a/code/ryzom/client/src/r2/tool.h +++ b/code/ryzom/client/src/r2/tool.h @@ -284,6 +284,7 @@ private: sint64 _AutoPanDelay; sint64 _NumPans; static bool _MouseCaptured; + static NLMISC::CRefPtr _UserCharFade; private: /** compute the nearest valid surface at a given position from the island heightmap * (heightmap must not be empty or an assertion is raised) diff --git a/code/ryzom/client/src/session_browser_impl.cpp b/code/ryzom/client/src/session_browser_impl.cpp index 5cdd69291..1802aefbf 100644 --- a/code/ryzom/client/src/session_browser_impl.cpp +++ b/code/ryzom/client/src/session_browser_impl.cpp @@ -51,7 +51,7 @@ void CSessionBrowserImpl::init(CLuaState *ls) { nlassert(ls); _Lua = ls; - _Lua->pushValue(LUA_GLOBALSINDEX); + _Lua->pushGlobalTable(); CLuaObject game(*_Lua); game = game["game"]; game.setValue("getRingSessionList", luaGetRingSessionList); @@ -759,7 +759,7 @@ void CSessionBrowserImpl::callRingAccessPointMethod(const char *name, int numArg nlassert(name); { CLuaStackRestorer lsr(_Lua, _Lua->getTop() + numResult); - _Lua->pushValue(LUA_GLOBALSINDEX); + _Lua->pushGlobalTable(); CLuaObject rap(*_Lua); rap = rap["RingAccessPoint"]; rap.callMethodByNameNoThrow(name, numArg, numResult); @@ -774,7 +774,7 @@ void CSessionBrowserImpl::callRingCharTrackingMethod(const char *name, int numAr nlassert(name); { CLuaStackRestorer lsr(_Lua, _Lua->getTop() + numResult); - _Lua->pushValue(LUA_GLOBALSINDEX); + _Lua->pushGlobalTable(); CLuaObject rap(*_Lua); rap = rap["CharTracking"]; rap.callMethodByNameNoThrow(name, numArg, numResult); @@ -789,7 +789,7 @@ void CSessionBrowserImpl::callRingPlayerInfoMethod(const char *name, int numArg, nlassert(name); { CLuaStackRestorer lsr(_Lua, _Lua->getTop() + numResult); - _Lua->pushValue(LUA_GLOBALSINDEX); + _Lua->pushGlobalTable(); CLuaObject rap(*_Lua); rap = rap["RingPlayerInfo"]; rap.callMethodByNameNoThrow(name, numArg, numResult); @@ -804,7 +804,7 @@ void CSessionBrowserImpl::callScenarioScoresMethod(const char *name, int numArg, nlassert(name); { CLuaStackRestorer lsr(_Lua, _Lua->getTop() + numResult); - _Lua->pushValue(LUA_GLOBALSINDEX); + _Lua->pushGlobalTable(); CLuaObject rap(*_Lua); rap = rap["ScenarioScores"]; rap.callMethodByNameNoThrow(name, numArg, numResult); diff --git a/code/ryzom/client/src/weather.cpp b/code/ryzom/client/src/weather.cpp index 1f5f0f822..91fad6f7c 100644 --- a/code/ryzom/client/src/weather.cpp +++ b/code/ryzom/client/src/weather.cpp @@ -194,10 +194,13 @@ bool ServerDrivenWeather = false; const float WEATHER_BLEND_SPEED = 1.f / 8.f; // number of seconds to blend betwen weather states +static NLMISC::CRefPtr s_ServerWeatherValueDB; + // *************************************************************************** static uint16 getServerWeather() { - CCDBNodeLeaf *node = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:WEATHER:VALUE"); + CCDBNodeLeaf *node = s_ServerWeatherValueDB ? &*s_ServerWeatherValueDB + : &*(s_ServerWeatherValueDB = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:WEATHER:VALUE")); if (!node) return 0; return (uint16) node->getValue16(); } diff --git a/code/ryzom/common/data_common/database.xml b/code/ryzom/common/data_common/database.xml index fc0d1d209..6157693c6 100644 --- a/code/ryzom/common/data_common/database.xml +++ b/code/ryzom/common/data_common/database.xml @@ -1,1665 +1,1665 @@ - - - - - - - inline void _setProp(CCDBSynchronised &db, - ICDBStructNode *node, TCharConnectionState value, bool - forceSending = false) { db.x_setProp(node, uint64(value), - forceSending); } inline void _getProp(const CCDBSynchronised - &db, ICDBStructNode *node, TCharConnectionState - &value) { value = - (TCharConnectionState)db.x_getProp(node); } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + inline void _setProp(CCDBSynchronised &db, + ICDBStructNode *node, TCharConnectionState value, bool + forceSending = false) { db.x_setProp(node, uint64(value), + forceSending); } inline void _getProp(const CCDBSynchronised + &db, ICDBStructNode *node, TCharConnectionState + &value) { value = + (TCharConnectionState)db.x_getProp(node); } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/code/ryzom/common/data_common/msg.xml b/code/ryzom/common/data_common/msg.xml index 3fa75650e..df2011edf 100644 --- a/code/ryzom/common/data_common/msg.xml +++ b/code/ryzom/common/data_common/msg.xml @@ -1,1165 +1,1165 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/code/ryzom/common/src/game_share/crypt.cpp b/code/ryzom/common/src/game_share/crypt.cpp index fa0f1252f..0da908817 100644 --- a/code/ryzom/common/src/game_share/crypt.cpp +++ b/code/ryzom/common/src/game_share/crypt.cpp @@ -79,6 +79,10 @@ static char rz_sccsid[] = "@(#)crypt.c 8.1 (Berkeley) 6/4/93"; #include #define RZ__PASSWORD_EFMT1 '-' +#if DEBUG_CRYPT +void prtab(char *s, unsigned char *t, int num_rows); +#endif + /* * UNIX password, and DES, encryption. * By Tom Truscott, trt@rti.rti.org, @@ -785,7 +789,7 @@ int rz_des_cipher(const char *in, char *out, long salt, int num_iter) { } perm[i] = (unsigned char) k; } -#ifdef DEBUG +#ifdef DEBUG_CRYPT prtab("pc1tab", perm, 8); #endif rz_init_perm(PC1ROT, perm, 8, 8); @@ -809,7 +813,7 @@ int rz_des_cipher(const char *in, char *out, long salt, int num_iter) { if ((k%28) <= j) k -= 28; perm[i] = pc2inv[k]; } -#ifdef DEBUG +#ifdef DEBUG_CRYPT prtab("pc2tab", perm, 8); #endif rz_init_perm(PC2ROT[j], perm, 8, 8); @@ -833,7 +837,7 @@ int rz_des_cipher(const char *in, char *out, long salt, int num_iter) { perm[i*8+j] = (unsigned char) k; } } -#ifdef DEBUG +#ifdef DEBUG_CRYPT prtab("ietab", perm, 8); #endif rz_init_perm(IE3264, perm, 4, 8); @@ -850,7 +854,7 @@ int rz_des_cipher(const char *in, char *out, long salt, int num_iter) { } perm[k-1] = i+1; } -#ifdef DEBUG +#ifdef DEBUG_CRYPT prtab("cftab", perm, 8); #endif rz_init_perm(CF6464, perm, 8, 8); @@ -959,12 +963,8 @@ int rz_encrypt(register char *block, int flag) { return (0); } -#ifdef DEBUG -STATIC -prtab(s, t, num_rows) - char *s; - unsigned char *t; - int num_rows; +#ifdef DEBUG_CRYPT +void prtab(char *s, unsigned char *t, int num_rows) { register int i, j; diff --git a/code/ryzom/server/src/CMakeLists.txt b/code/ryzom/server/src/CMakeLists.txt index 13cee545a..29c11be09 100644 --- a/code/ryzom/server/src/CMakeLists.txt +++ b/code/ryzom/server/src/CMakeLists.txt @@ -1,7 +1,14 @@ + # Supporting modules and libraries. -ADD_SUBDIRECTORY(admin_modules) +# Need servershare for build packed collision tool +# Need aishare for build wmap tool ADD_SUBDIRECTORY(server_share) ADD_SUBDIRECTORY(ai_share) + +IF(WITH_RYZOM_SERVER) + +# Supporting modules and libraries. +ADD_SUBDIRECTORY(admin_modules) ADD_SUBDIRECTORY(gameplay_module_lib) ADD_SUBDIRECTORY(pd_lib) @@ -40,3 +47,5 @@ ADD_SUBDIRECTORY(general_utilities_service) #sabrina #simulation_service #testing_tool_service + +ENDIF(WITH_RYZOM_SERVER) diff --git a/code/ryzom/tools/CMakeLists.txt b/code/ryzom/tools/CMakeLists.txt index 247e75415..456336254 100644 --- a/code/ryzom/tools/CMakeLists.txt +++ b/code/ryzom/tools/CMakeLists.txt @@ -9,15 +9,13 @@ ADD_SUBDIRECTORY(leveldesign) ADD_SUBDIRECTORY(patch_gen) ADD_SUBDIRECTORY(pdr_util) ADD_SUBDIRECTORY(stats_scan) +ADD_SUBDIRECTORY(sheets_packer) IF(WITH_RYZOM_CLIENT) - ADD_SUBDIRECTORY(sheets_packer) ADD_SUBDIRECTORY(client) ENDIF(WITH_RYZOM_CLIENT) -IF(WITH_RYZOM_SERVER) - ADD_SUBDIRECTORY(server) -ENDIF(WITH_RYZOM_SERVER) +ADD_SUBDIRECTORY(server) # Old stuff that doesn't compile anymore. #ADD_SUBDIRECTORY(occ2huff) diff --git a/code/ryzom/tools/build_gamedata/workspace/ecosystems/desert/directories.py b/code/ryzom/tools/build_gamedata/workspace/ecosystems/desert/directories.py index e15b856f2..0a0534f1c 100644 --- a/code/ryzom/tools/build_gamedata/workspace/ecosystems/desert/directories.py +++ b/code/ryzom/tools/build_gamedata/workspace/ecosystems/desert/directories.py @@ -206,6 +206,7 @@ ZoneExportDirectory = CommonPath + "/zone" # PACS primitives directories PacsPrimExportDirectory = CommonPath + "/pacs_prim" +PacsPrimTagExportDirectory = CommonPath + "/pacs_prim_tag" # *** BUILD DIRECTORIES FOR THE BUILD PIPELINE *** diff --git a/code/ryzom/tools/build_gamedata/workspace/ecosystems/jungle/directories.py b/code/ryzom/tools/build_gamedata/workspace/ecosystems/jungle/directories.py index 1ceface1c..716afc247 100644 --- a/code/ryzom/tools/build_gamedata/workspace/ecosystems/jungle/directories.py +++ b/code/ryzom/tools/build_gamedata/workspace/ecosystems/jungle/directories.py @@ -210,6 +210,7 @@ ZoneExportDirectory = CommonPath + "/zone" # PACS primitives directories PacsPrimExportDirectory = CommonPath + "/pacs_prim" +PacsPrimTagExportDirectory = CommonPath + "/pacs_prim_tag" # *** BUILD DIRECTORIES FOR THE BUILD PIPELINE *** diff --git a/code/ryzom/tools/build_gamedata/workspace/ecosystems/lacustre/directories.py b/code/ryzom/tools/build_gamedata/workspace/ecosystems/lacustre/directories.py index af2e15e29..37e35b51e 100644 --- a/code/ryzom/tools/build_gamedata/workspace/ecosystems/lacustre/directories.py +++ b/code/ryzom/tools/build_gamedata/workspace/ecosystems/lacustre/directories.py @@ -218,6 +218,7 @@ ZoneExportDirectory = CommonPath + "/zone" # PACS primitives directories PacsPrimExportDirectory = CommonPath + "/pacs_prim" +PacsPrimTagExportDirectory = CommonPath + "/pacs_prim_tag" # *** BUILD DIRECTORIES FOR THE BUILD PIPELINE *** diff --git a/code/ryzom/tools/build_gamedata/workspace/ecosystems/primes_racines/directories.py b/code/ryzom/tools/build_gamedata/workspace/ecosystems/primes_racines/directories.py index d49e8d06b..c718e90ec 100644 --- a/code/ryzom/tools/build_gamedata/workspace/ecosystems/primes_racines/directories.py +++ b/code/ryzom/tools/build_gamedata/workspace/ecosystems/primes_racines/directories.py @@ -203,6 +203,7 @@ ZoneExportDirectory = CommonPath + "/zone" # PACS primitives directories PacsPrimExportDirectory = CommonPath + "/pacs_prim" +PacsPrimTagExportDirectory = CommonPath + "/pacs_prim_tag" # *** BUILD DIRECTORIES FOR THE BUILD PIPELINE *** diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/assigned.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/assigned.php new file mode 100644 index 000000000..6d2a558c3 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/assigned.php @@ -0,0 +1,120 @@ +set(array('User' => $user_id, 'Ticket' => $ticket_id)); + $assignation->create(); + return "SUCCESS_ASSIGNED"; + }else{ + return "ALREADY_ASSIGNED"; + } + + } + + //Unsign a ticket to a user or returns error message + public static function unAssignTicket( $user_id, $ticket_id) { + $dbl = new DBLayer("lib"); + //check if ticket is really assigned to that user + if( Assigned::isAssigned($ticket_id, $user_id)){ + $assignation = new Assigned(); + $assignation->set(array('User' => $user_id, 'Ticket' => $ticket_id)); + $assignation->delete(); + return "SUCCESS_UNASSIGNED"; + }else{ + return "NOT_ASSIGNED"; + } + + } + + // Get the id of the user assigned to a ticket + public static function getUserAssignedToTicket($ticket_id) { + $dbl = new DBLayer("lib"); + $statement = $dbl->execute("SELECT ticket_user.ExternId FROM `assigned` JOIN `ticket_user` ON assigned.User = ticket_user.TUserId WHERE `Ticket` = :ticket_id", Array('ticket_id' => $ticket_id)); + $user_id = $statement->fetch(); + return $user_id['ExternId']; + + + + } + + public static function isAssigned( $ticket_id, $user_id = 0) { + $dbl = new DBLayer("lib"); + //check if ticket is already assigned + + if($user_id == 0 && $dbl->execute(" SELECT * FROM `assigned` WHERE `Ticket` = :ticket_id", array('ticket_id' => $ticket_id) )->rowCount() ){ + return true; + }else if( $dbl->execute(" SELECT * FROM `assigned` WHERE `Ticket` = :ticket_id and `User` = :user_id", array('ticket_id' => $ticket_id, 'user_id' => $user_id) )->rowCount()){ + return true; + }else{ + return false; + } + } + + ////////////////////////////////////////////Methods//////////////////////////////////////////////////// + + public function __construct() { + } + + //set values + public function set($values) { + $this->setUser($values['User']); + $this->setTicket($values['Ticket']); + } + + public function create() { + $dbl = new DBLayer("lib"); + $query = "INSERT INTO `assigned` (`User`,`Ticket`) VALUES (:user, :ticket)"; + $values = Array('user' => $this->getUser(), 'ticket' => $this->getTicket()); + $dbl->execute($query, $values); + } + + //delete entry + public function delete() { + $dbl = new DBLayer("lib"); + $query = "DELETE FROM `assigned` WHERE `User` = :user_id and `Ticket` = :ticket_id"; + $values = array('user_id' => $this->getUser() ,'ticket_id' => $this->getTicket()); + $dbl->execute($query, $values); + } + + //Load with sGroupId + public function load( $user_id, $user_id) { + $dbl = new DBLayer("lib"); + $statement = $dbl->execute("SELECT * FROM `assigned` WHERE `Ticket` = :ticket_id AND `User` = :user_id", Array('ticket_id' => $ticket_id, 'user_id' => $user_id)); + $row = $statement->fetch(); + $this->set($row); + } + + + ////////////////////////////////////////////Getters//////////////////////////////////////////////////// + + public function getUser(){ + return $this->user; + } + + public function getTicket(){ + return $this->ticket; + } + + ////////////////////////////////////////////Setters//////////////////////////////////////////////////// + + public function setUser($u){ + $this->user = $u; + } + + public function setTicket($g){ + $this->ticket = $g; + } + + +} \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/dblayer.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/dblayer.php index a96fd98ea..c5b7375c3 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/dblayer.php +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/dblayer.php @@ -5,53 +5,39 @@ class DBLayer{ function __construct($db) { - try{ - $dsn = "mysql:"; - $dsn .= "host=". $db['host'].";"; - $dsn .= "dbname=". $db['name'].";"; - $dsn .= "port=". $db['port'].";"; - - $opt = array( - PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, - PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC - ); - $this->PDO = new PDO($dsn,$db['user'],$db['pass'], $opt); - }catch (PDOException $e) { - throw $e; - } + global $cfg; + $dsn = "mysql:"; + $dsn .= "host=". $cfg['db'][$db]['host'].";"; + $dsn .= "dbname=". $cfg['db'][$db]['name'].";"; + $dsn .= "port=". $cfg['db'][$db]['port'].";"; + + $opt = array( + PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, + PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC + ); + $this->PDO = new PDO($dsn,$cfg['db'][$db]['user'],$cfg['db'][$db]['pass'], $opt); + } public function executeWithoutParams($query){ - try{ - $statement = $this->PDO->prepare($query); - $statement->execute(); - return $statement; - }catch (PDOException $e) { - throw $e; - } + $statement = $this->PDO->prepare($query); + $statement->execute(); + return $statement; } public function execute($query,$params){ - try{ - $statement = $this->PDO->prepare($query); - $statement->execute($params); - return $statement; - }catch (PDOException $e) { - throw $e; - } + $statement = $this->PDO->prepare($query); + $statement->execute($params); + return $statement; } public function executeReturnId($query,$params){ - try{ - $statement = $this->PDO->prepare($query); - $this->PDO->beginTransaction(); - $statement->execute($params); - $lastId =$this->PDO->lastInsertId(); - $this->PDO->commit(); - return $lastId; - }catch (PDOException $e) { - throw $e; - } + $statement = $this->PDO->prepare($query); + $this->PDO->beginTransaction(); + $statement->execute($params); + $lastId =$this->PDO->lastInsertId(); + $this->PDO->commit(); + return $lastId; } } \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/forwarded.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/forwarded.php new file mode 100644 index 000000000..003811fe9 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/forwarded.php @@ -0,0 +1,98 @@ +load($ticket_id); + $forw->delete(); + } + $forward = new Forwarded(); + $forward->set(array('Group' => $group_id, 'Ticket' => $ticket_id)); + $forward->create(); + return "SUCCESS_FORWARDED"; + + } + + public static function getSGroupOfTicket($ticket_id) { + $forw = new self(); + $forw->load($ticket_id); + return $forw->getGroup(); + } + + + public static function isForwarded( $ticket_id) { + $dbl = new DBLayer("lib"); + if( $dbl->execute(" SELECT * FROM `forwarded` WHERE `Ticket` = :ticket_id", array('ticket_id' => $ticket_id))->rowCount()){ + return true; + }else{ + return false; + } + + } + + ////////////////////////////////////////////Methods//////////////////////////////////////////////////// + + public function __construct() { + } + + //set values + public function set($values) { + $this->setGroup($values['Group']); + $this->setTicket($values['Ticket']); + } + + public function create() { + $dbl = new DBLayer("lib"); + $query = "INSERT INTO `forwarded` (`Group`,`Ticket`) VALUES (:group, :ticket)"; + $values = Array('group' => $this->getGroup(), 'ticket' => $this->getTicket()); + $dbl->execute($query, $values); + } + + //delete entry + public function delete() { + $dbl = new DBLayer("lib"); + $query = "DELETE FROM `forwarded` WHERE `Group` = :group_id and `Ticket` = :ticket_id"; + $values = array('group_id' => $this->getGroup() ,'ticket_id' => $this->getTicket()); + $dbl->execute($query, $values); + } + + //Load with sGroupId + public function load( $ticket_id) { + $dbl = new DBLayer("lib"); + $statement = $dbl->execute("SELECT * FROM `forwarded` WHERE `Ticket` = :ticket_id", Array('ticket_id' => $ticket_id)); + $row = $statement->fetch(); + $this->set($row); + } + + + ////////////////////////////////////////////Getters//////////////////////////////////////////////////// + + public function getGroup(){ + return $this->group; + } + + public function getTicket(){ + return $this->ticket; + } + + ////////////////////////////////////////////Setters//////////////////////////////////////////////////// + + public function setGroup($g){ + $this->group = $g; + } + + public function setTicket($t){ + $this->ticket = $t; + } + + +} \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/gui_elements.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/gui_elements.php new file mode 100644 index 000000000..cb932afe5 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/gui_elements.php @@ -0,0 +1,79 @@ +', $function); + $intermediate_result = NULL; + foreach($fnames as $fname) { + if(substr($fname, -2) == "()") { + $fname = substr($fname, 0, strlen($fname)-2); + if($intermediate_result == NULL) { + $intermediate_result = $element->$fname(); + } else { + $intermediate_result = $intermediate_result->$fname(); + } + } else { + if($intermediate_result == NULL) { + $intermediate_result = $element->$fname(); + } else { + $intermediate_result = $intermediate_result->$fname(); + } + } + } + $result[$i][$fieldArray[$j]] = $intermediate_result; + $j++; + } + $i++; + } + return $result; + } + + + public static function make_table_with_key_is_id( $inputList, $funcArray, $idFunction){ + $result = Array(); + foreach($inputList as $element){ + foreach($funcArray as $function){ + $result[$element->$idFunction()] = $element->$function(); + } + } + return $result; + } + + + public static function time_elapsed_string($ptime){ + global $TIME_FORMAT; + $ptime = DateTime::createFromFormat($TIME_FORMAT, $ptime)->getTimestamp(); + + $etime = time() - $ptime; + + if ($etime < 1) + { + return '0 seconds'; + } + + $a = array( 12 * 30 * 24 * 60 * 60 => 'year', + 30 * 24 * 60 * 60 => 'month', + 24 * 60 * 60 => 'day', + 60 * 60 => 'hour', + 60 => 'minute', + 1 => 'second' + ); + + foreach ($a as $secs => $str) + { + $d = $etime / $secs; + if ($d >= 1) + { + $r = round($d); + return $r . ' ' . $str . ($r > 1 ? 's' : '') . ' ago'; + } + } + } + +} \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/helpers.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/helpers.php index 0bc4197b3..233f44510 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/helpers.php +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/helpers.php @@ -6,6 +6,7 @@ class Helpers{ global $AMS_LIB; global $SITEBASE; global $AMS_TRANS; + global $INGAME_LAYOUT; require_once $AMS_LIB . '/smarty/libs/Smarty.class.php'; $smarty = new Smarty; @@ -17,55 +18,39 @@ class Helpers{ helpers :: create_folders (); - if ( helpers :: check_if_game_client () or $forcelibrender = false ){ + if ( helpers::check_if_game_client() or $forcelibrender = false ){ $smarty -> template_dir = $AMS_LIB . '/ingame_templates/'; $smarty -> setConfigDir( $AMS_LIB . '/configs' ); - }else{ + $variables = parse_ini_file( $AMS_LIB . '/configs/ingame_layout.ini', true ); + foreach ( $variables[$INGAME_LAYOUT] as $key => $value ){ + $smarty -> assign( $key, $value ); + } + }else{ $smarty -> template_dir = $SITEBASE . '/templates/'; $smarty -> setConfigDir( $SITEBASE . '/configs' ); - } + } foreach ( $vars as $key => $value ){ $smarty -> assign( $key, $value ); } - global $DEFAULT_LANGUAGE; - //if language get param is given = set cookie - //else if no get param is given and a cookie is set, use that language, else use default. - if ( isset( $_GET['language'] ) ) { - //check if the language is supported - if ( file_exists( $AMS_TRANS . '/' . $_GET['language'] . '.ini' ) ){ - //if it's supported, set cookie! - setcookie( 'language',$_GET['language'], time() + 60*60*24*30 ); - $language = $_GET['language']; - }else{ - //the language is not supported, use the default. - $language = $DEFAULT_LANGUAGE; - } - }else{ - //if no get param is given, check if a cookie value for language is set - if ( isset( $_COOKIE['language'] ) ) { - $language = $_COOKIE['language']; - } - //else use the default - else{ - $language = $DEFAULT_LANGUAGE; - } - } - - $variables = parse_ini_file( $AMS_TRANS . '/' . $language . '.ini', true ); + + $variables = Helpers::handle_language(); foreach ( $variables[$template] as $key => $value ){ $smarty -> assign( $key, $value ); } - if( isset($vars['permission']) && $vars['permission'] == 2 ){ + + if( isset($vars['permission']) && $vars['permission'] == 3 ){ $inherited = "extends:layout_admin.tpl|"; + }else if( isset($vars['permission']) && $vars['permission'] == 2){ + $inherited = "extends:layout_mod.tpl|"; }else if( isset($vars['permission']) && $vars['permission'] == 1){ $inherited = "extends:layout_user.tpl|"; }else{ $inherited =""; } - // extends:' . $inherited .'|register.tpl - $smarty -> display( $inherited . $template . '.tpl' ); + // extends:' . $inherited .'|register.tpl + $smarty -> display( $inherited . $template . '.tpl' ); } static public function create_folders(){ @@ -91,11 +76,68 @@ class Helpers{ static public function check_if_game_client() { // if HTTP_USER_AGENT is not set then its ryzom core - if ( !isset( $_SERVER['HTTP_USER_AGENT'] ) ){ + if ( strpos($_SERVER['HTTP_USER_AGENT'],"Ryzom") === 0){ return true; - }else{ + }else{ return false; } - } } - + + static public function handle_language(){ + global $DEFAULT_LANGUAGE; + global $AMS_TRANS; + + //if language get param is given = set cookie + //else if no get param is given and a cookie is set, use that language, else use default. + if ( isset( $_GET['language'] ) ) { + //check if the language is supported + if ( file_exists( $AMS_TRANS . '/' . $_GET['language'] . '.ini' ) ){ + //if it's supported, set cookie! + setcookie( 'language',$_GET['language'], time() + 60*60*24*30 ); + $language = $_GET['language']; + }else{ + //the language is not supported, use the default. + $language = $DEFAULT_LANGUAGE; + } + }else{ + //if no get param is given, check if a cookie value for language is set + if ( isset( $_COOKIE['language'] ) ) { + $language = $_COOKIE['language']; + } + //else use the default + else{ + $language = $DEFAULT_LANGUAGE; + } + } + + return parse_ini_file( $AMS_TRANS . '/' . $language . '.ini', true ); + } + + + //Time output function for handling the time display function. + static public function outputTime($time){ + global $TIME_FORMAT; + return date($TIME_FORMAT,strtotime($time)); + } + + static public function check_login_ingame(){ + if ( helpers :: check_if_game_client () or $forcelibrender = false ){ + $dbr = new DBLayer("ring"); + if (isset($_GET['UserId']) && isset($_COOKIE['ryzomId'])){ + $id = $_GET['UserId']; + $statement = $dbr->execute("SELECT * FROM ring_users WHERE user_id=:id AND cookie =:cookie", array('id' => $id, 'cookie' => $_COOKIE['ryzomId'])); + if ($statement->rowCount() ){ + $entry = $statement->fetch(); + //print_r($entry); + return array('id' => $entry['user_id'], 'name' => $entry['user_name']); + }else{ + return "FALSE"; + } + }else{ + return "FALSE"; + } + }else{ + return "FALSE"; + } + } +} diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/in_support_group.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/in_support_group.php new file mode 100644 index 000000000..b01517db2 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/in_support_group.php @@ -0,0 +1,77 @@ +execute(" SELECT * FROM `in_support_group` WHERE `User` = :user_id and `Group` = :group_id ", array('user_id' => $user_id, 'group_id' => $group_id) )->rowCount() ){ + return true; + }else{ + return false; + } + } + + ////////////////////////////////////////////Methods//////////////////////////////////////////////////// + + public function __construct() { + } + + //set values + public function set($values) { + $this->setUser($values['User']); + $this->setGroup($values['Group']); + } + + public function create() { + $dbl = new DBLayer("lib"); + $query = "INSERT INTO `in_support_group` (`User`,`Group`) VALUES (:user, :group)"; + $values = Array('user' => $this->user, 'group' => $this->group); + $dbl->execute($query, $values); + } + + //delete entry + public function delete() { + $dbl = new DBLayer("lib"); + $query = "DELETE FROM `in_support_group` WHERE `User` = :user_id and `Group` = :group_id"; + $values = array('user_id' => $this->getUser() ,'group_id' => $this->getGroup()); + $dbl->execute($query, $values); + } + + //Load with sGroupId + public function load( $user_id, $group_id) { + $dbl = new DBLayer("lib"); + $statement = $dbl->execute("SELECT * FROM `in_support_group` WHERE `Group` = :group_id", Array('group_id' => $group_id)); + $row = $statement->fetch(); + $this->set($row); + } + + + ////////////////////////////////////////////Getters//////////////////////////////////////////////////// + + public function getUser(){ + return $this->user; + } + + public function getGroup(){ + return $this->group; + } + + ////////////////////////////////////////////Setters//////////////////////////////////////////////////// + + public function setUser($u){ + $this->user = $u; + } + + public function setGroup($g){ + $this->group = $g; + } + + +} \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/mail_handler.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/mail_handler.php new file mode 100644 index 000000000..4c5e14caf --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/mail_handler.php @@ -0,0 +1,378 @@ + getTId() . " ----------\n You received a new reply on your ticket: " . $ticketObj->getTitle() . + "\n --------------------\n\n"; + $subject = "New reply on [Ticket #" . $ticketObj->getTId() ."]"; + $endTxt = "\n\n----------\nYou can reply on this message to answer directly on the ticket!"; + $txt = $txt . $content . $endTxt; + self::send_mail($ticketObj->getAuthor(),$subject,$txt, $ticketObj->getTId(),$author); + }else if($type == "NEW"){ + $txt = "---------- Ticket #". $ticketObj->getTId() . " ----------\n Your ticket: " . $ticketObj->getTitle() . " is newly created"; + if($ticketObj->getAuthor() != $author){ + $txt = $txt . " by " . Ticket_User::get_username_from_id($author); + }else{ + $author = $ticketObj->getAuthor(); + } + $txt = $txt . "\n --------------------\n\n"; + $subject = "New ticket created [Ticket #" . $ticketObj->getTId() ."]"; + $endTxt = "\n\n----------\nYou can reply on this message to answer directly on the ticket!"; + $txt = $txt . $content . $endTxt; + self::send_mail($ticketObj->getAuthor(),$subject,$txt, $ticketObj->getTId()); + } + + } + } + + + public static function send_mail($recipient, $subject, $body, $ticket_id = 0, $from = 1) { + if(is_numeric($recipient)) { + $id_user = $recipient; + $recipient = NULL; + } + $query = "INSERT INTO email (Recipient,Subject,Body,Status,Attempts,Sender,UserId,MessageId,TicketId) VALUES (:recipient, :subject, :body, :status, :attempts, :sender, :id_user, :messageId, :ticketId)"; + $values = array('recipient' => $recipient, 'subject' => $subject, 'body' => $body, 'status' => 'NEW', 'attempts'=> 0, 'sender' => $from,'id_user' => $id_user, 'messageId' => 0, 'ticketId'=> $ticket_id); + $db = new DBLayer("lib"); + $db->execute($query, $values); + + } + + + //the main function + function cron() { + global $cfg; + $inbox_username = $cfg['mail']['username']; + $inbox_password = $cfg['mail']['password']; + $inbox_host = $cfg['mail']['host']; + $oms_reply_to = "Ryzom Ticketing Support "; + global $MAIL_DIR; + + // Deliver new mail + echo("mail cron\n"); + + //creates child process + $pid = self::mail_fork(); + $pidfile = '/tmp/ams_cron_email_pid'; + + //INFO: if $pid = + //-1: "Could not fork!\n"; + // 0: "In child!\n"; + //>0: "In parent!\n"; + + if($pid) { + + // We're the parent process, do nothing! + + } else { + //make db connection here because the children have to make the connection. + $this->db = new DBLayer("lib"); + + //if $pidfile doesn't exist yet, then start sending the mails that are in the db. + if(!file_exists($pidfile)) { + //create the file and write the child processes id in it! + $pid = getmypid(); + $file = fopen($pidfile, 'w'); + fwrite($file, $pid); + fclose($file); + + //select all new & failed emails & try to send them + //$emails = db_query("select * from email where status = 'NEW' or status = 'FAILED'"); + $statement = $this->db->executeWithoutParams("select * from email where Status = 'NEW' or Status = 'FAILED'"); + $emails = $statement->fetchAll(); + + foreach($emails as $email) { + $message_id = self::new_message_id($email['TicketId']); + + //if recipient isn't given, then use the email of the id_user instead! + echo("Emailing {$email['Recipient']}\n"); + if(!$email['Recipient']) { + $email['Recipient'] = Ticket_User::get_email_by_user_id($email['UserId']); + } + + //create sending email adres based on the $sender id + if($email['Sender'] != 0) { + $username = Ticket_User::get_username_from_id($email['Sender']); + $from = "$username <$username@$inbox_host>"; + } else { + $from = $oms_reply_to; + } + $headers = "From: $from\r\n" . "Message-ID: " . $message_id ; + print("recip: " . $email['Recipient']); + print("subj: " .$email['Subject']); + print("body: " . $email['Body']); + print("headers: " . $headers); + if(mail($email['Recipient'], $email['Subject'], $email['Body'], $headers)) { + $status = "DELIVERED"; + echo("Emailed {$email['Recipient']}\n"); + } else { + $status = "FAILED"; + echo("Email to {$email['Recipient']} failed\n"); + } + //change the status of the emails. + $this->db->execute('update email set Status = ?, MessageId = ?, Attempts = Attempts + 1 where MailId = ?', array($status, $message_id, $email['MailId'])); + //db_exec('update email set status = ?, message_id = ?, attempts = attempts + 1 where id_email = ?', array($status, $message_id, $email['id_email'])); + } + unlink($pidfile); + } + // Check mail + + //$mailbox = imap_open("{localhost:110/pop3/novalidate-cert}INBOX", $inbox_username, $inbox_password); + $mbox = imap_open($cfg['mail']['server'], $inbox_username, $inbox_password) or die('Cannot connect to mail server: ' . imap_last_error()); + $message_count = imap_num_msg($mbox); + + for ($i = 1; $i <= $message_count; ++$i) { + + //return task ID + self::incoming_mail_handler($mbox, $i); + $tid = 1; //self::ams_create_email($from, $subject, $txt, $html, $to, $from); + + if($tid) { + //TODO: base file on Ticket + reply id + /* $file = fopen($MAIL_DIR."/mail/".$tid, 'w'); + fwrite($file, $entire_email); + fclose($file); */ + } + //mark message $i of $mbox for deletion! + imap_delete($mbox, $i); + } + //delete marked messages + imap_expunge($mbox); + imap_close($mbox); + + } + + } + + + + function new_message_id($ticketId) { + $time = time(); + $pid = getmypid(); + global $cfg; + global $ams_mail_count; + $ams_mail_count = ($ams_mail_count == '') ? 1 : $ams_mail_count + 1; + return ""; + + } + + function get_ticket_id_from_subject($subject){ + $startpos = strpos($subject, "[Ticket #"); + $tempString = substr($subject, $startpos+9); + $endpos = strpos($tempString, "]"); + $ticket_id = substr($tempString, 0, $endpos); + return $ticket_id; + } + + + function incoming_mail_handler($mbox,$i){ + + $header = imap_header($mbox, $i); + $subject = self::decode_utf8($header->subject); + + print_r($header); + + //get ticket_id out of the message-id or else out of the subject line + $ticket_id = 0; + if(isset($header->references)){ + $pieces = explode(".", $header->references); + if($pieces[0] == "subject); + $to = $header->to[0]->mailbox; + $from = $header->from[0]->mailbox . '@' . $header->from[0]->host; + $txt = self::get_part($mbox, $i, "TEXT/PLAIN"); + //$html = self::get_part($mbox, $i, "TEXT/HTML"); + + //use the line ---------- Ticket # to make a distincton between the old message and the reply + $endpos = strpos($txt, ">---------- Ticket #"); + if($endpos){ + $txt = substr($txt, 0, $endpos); + }else{ + $endpos = strpos($txt, "---------- Ticket #"); + if($endpos){ + $txt = substr($txt, 0, $endpos); + } + } + + + //get the id out of the email address of the person sending the email. + if($from !== NULL && !is_numeric($from)) $from = Ticket_User::get_id_from_email($from); + + $user = new Ticket_User(); + $user->load_With_TUserId($from); + $ticket = new Ticket(); + $ticket->load_With_TId($ticket_id); + + //if user has access to it! + if((Ticket_User::isMod($user) or ($ticket->getAuthor() == $user->getTUserId())) and $txt != ""){ + Ticket::createReply($txt, $user->getTUserId(), $ticket->getTId(), 0); + } + + } + + } + + /*function ams_create_email($from, $subject, $body, $html, $recipient = 0, $sender = NULL) { + + //TODO: + if($recipient == 0 && !is_string($recipient)) { + global $user; + $recipient = $user->uid; + } + + if($sender !== NULL && !is_numeric($sender)) $sender = self::get_id_from_username($sender); + if(!is_numeric($recipient)) $recipient = self::get_id_from_username($recipient); + + $message = array( + 'creator' => $sender, + 'owner' => $recipient, + 'type' => 'email', + 'summary' => $subject, + 'data' => array ( + 'subject' => $subject, + 'body' => $body, + 'html' => $html, + 'sender' => oms_get_username_from_id($sender), + 'from' => $from, + 'recipient' => oms_get_username_from_id($recipient), + 'time' => time(), + ), + ); + + //TO ASK: + oms_task_create($message); + oms_task_index($message, array('subject', 'body', 'sender', 'recipient')); + //--------------------------- + return $message['id_task']; + }*/ + + + + /*function oms_get_email($id) { + + $message = oms_task_load($id); + if($message) { + oms_prepare_email($message); + return $message; + } else { + return FALSE; + } + + }*/ + + + + /*function oms_prepare_email(&$message) { + + $data = $message['data']; + $data['id_message'] = $message['id_task']; + $data['read'] = ($message['status'] != 'NEW' && $message['status'] != 'UNREAD'); + $message = $data; + + }*/ + + + + /*function oms_email_mark_read($mid) { + + db_exec("update task set status = 'READ' where id_task = ? and type = 'email' and module = 'email'", array($mid)); + + }*/ + + + + function decode_utf8($str) { + + preg_match_all("/=\?UTF-8\?B\?([^\?]+)\?=/i",$str, $arr); + for ($i=0;$isubtype) { + return $primary_mime_type[(int) $structure->type] . '/' .$structure->subtype; + } + return "TEXT/PLAIN"; + + } + + + + function get_part($stream, $msg_number, $mime_type, $structure = false, $part_number = false) { + + if(!$structure) { + $structure = imap_fetchstructure($stream, $msg_number); + } + + if($structure) { + if($mime_type == self::get_mime_type($structure)) { + if(!$part_number) { + $part_number = "1"; + } + $text = imap_fetchbody($stream, $msg_number, $part_number); + if($structure->encoding == 3) { + return imap_base64($text); + } else if($structure->encoding == 4) { + return imap_qprint($text); + } else { + return $text; + } + } + + if($structure->type == 1) /* multipart */ { + while(list($index, $sub_structure) = each($structure->parts)) { + if($part_number) { + $prefix = $part_number . '.'; + } else { + $prefix = ''; + } + $data = self::get_part($stream, $msg_number, $mime_type, $sub_structure,$prefix . ($index + 1)); + if($data) { + return $data; + } + } // END OF WHILE + } // END OF MULTIPART + } // END OF STRUTURE + return false; + + } // END OF FUNCTION + +} \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/pagination.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/pagination.php new file mode 100644 index 000000000..3c4473170 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/pagination.php @@ -0,0 +1,97 @@ +current= 1; + }else{ + $this->current= $_GET['pagenum']; + } + + //Here we count the number of results + $db = new DBLayer($db); + $rows = $db->execute($query, $params)->rowCount(); + $this->amountOfRows = $rows; + //the array hat will contain all users + + if($rows > 0){ + //This is the number of results displayed per page + $page_rows = $nrDisplayed; + + //This tells us the page number of our last page + $this->last = ceil($rows/$page_rows); + + //this makes sure the page number isn't below one, or more than our maximum pages + if ($this->current< 1) + { + $this->current= 1; + }else if ($this->current> $this->last) { + $this->current= $this->last; + } + + //This sets the range to display in our query + $max = 'limit ' .($this->current- 1) * $page_rows .',' .$page_rows; + + //This is your query again, the same one... the only difference is we add $max into it + $data = $db->execute($query . " " . $max, $params); + + $this->element_array = Array(); + //This is where we put the results in a resultArray to be sent to smarty + while($row = $data->fetch(PDO::FETCH_ASSOC)){ + $element = new $resultClass(); + $element->set($row); + $this->element_array[] = $element; + } + } + } + + + public function getLast(){ + return $this->last; + } + + public function getCurrent(){ + return $this->current; + } + + public function getElements(){ + return $this->element_array; + } + + public function getAmountOfRows(){ + return $this->amountOfRows; + } + + public function getLinks($nrOfLinks){ + $pageLinks = Array(); + //if amount of showable links is greater than the amount of pages: show all! + if ($this->last <= $nrOfLinks){ + for($var = 1; $var <= $this->last; $var++){ + $pageLinks[] = $var; + } + }else{ + $offset = ($nrOfLinks-1)/2 ; + $startpoint = $this->current - $offset; + $endpoint = $this->current + $offset; + + if($startpoint < 1){ + $startpoint = 1; + $endpoint = $startpoint + $nrOfLinks - 1; + }else if($endpoint > $this->last){ + $endpoint = $this->last; + $startpoint = $endpoint - ($nrOfLinks -1); + } + + for($var = $startpoint; $var <= $endpoint; $var++){ + $pageLinks[] = $var; + } + } + return $pageLinks; + } +} \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/querycache.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/querycache.php new file mode 100644 index 000000000..9ca6c627d --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/querycache.php @@ -0,0 +1,83 @@ +setSID($values['SID']); + $this->setType($values['type']); + $this->setQuery($values['query']); + $this->setDb($values['db']); + } + + + //return constructed element based on SID + public function load_With_SID( $id) { + $dbl = new DBLayer("lib"); + $statement = $dbl->execute("SELECT * FROM ams_querycache WHERE SID=:id", array('id' => $id)); + $row = $statement->fetch(); + $this->set($row); + } + + + //update private data to DB. + public function update(){ + $dbl = new DBLayer("lib"); + $query = "UPDATE ams_querycache SET type= :t, query = :q, db = :d WHERE SID=:id"; + $values = Array('id' => $this->getSID(), 't' => $this->getType(), 'q' => $this->getQuery(), 'd' => $this->getDb()); + $statement = $dbl->execute($query, $values); + } + + ////////////////////////////////////////////Getters//////////////////////////////////////////////////// + + public function getSID(){ + return $this->SID; + } + + + public function getType(){ + return $this->type; + } + + + public function getQuery(){ + return $this->query; + } + + public function getDb(){ + return $this->db; + } + + ////////////////////////////////////////////Setters//////////////////////////////////////////////////// + + public function setSID($s){ + $this->SID = $s; + } + + + public function setType($t){ + $this->type = $t; + } + + public function setQuery($q){ + $this->query= $q; + } + + public function setDb($d){ + $this->db= $d; + } + +} \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/sql.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/sql.php deleted file mode 100644 index 609ed8740..000000000 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/sql.php +++ /dev/null @@ -1,10 +0,0 @@ -execute("SELECT * FROM support_group WHERE SGroupId = :id", array('id' => $id)); + $row = $statement->fetch(); + $instanceGroup = new self(); + $instanceGroup->set($row); + return $instanceGroup; + + } + + //return all groups + public static function getGroups() { + $dbl = new DBLayer("lib"); + $statement = $dbl->executeWithoutParams("SELECT * FROM support_group ORDER BY Name ASC"); + $rows = $statement->fetchAll(); + $result = Array(); + foreach($rows as $group){ + + $instanceGroup = new self(); + $instanceGroup->set($group); + $result[] = $instanceGroup; + } + return $result; + } + + //wrapper for creating a support group + public static function createSupportGroup( $name, $tag) { + + if(strlen($name) < 21 && strlen($name) > 4 &&strlen($tag) < 8 && strlen($tag) > 1 ){ + $notExists = self::supportGroup_EntryNotExists($name, $tag); + if ( $notExists == "SUCCESS" ){ + $sGroup = new self(); + $sGroup->setName($name); + $sGroup->setTag($tag); + $sGroup->create(); + return "SUCCESS"; + }else{ + //return NAME_TAKEN or TAG_TAKEN + return $notExists; + } + }else{ + //RETURN ERROR that indicates SIZE + return "SIZE_ERROR"; + } + } + + //check if group exists + public static function supportGroup_EntryNotExists( $name, $tag) { + $dbl = new DBLayer("lib"); + //check if name is already used + if( $dbl->execute("SELECT * FROM support_group WHERE Name = :name",array('name' => $name))->rowCount() ){ + return "NAME_TAKEN"; + } + else if( $dbl->execute("SELECT * FROM support_group WHERE Tag = :tag",array('tag' => $tag))->rowCount() ){ + return "TAG_TAKEN"; + }else{ + return "SUCCESS"; + } + } + + + //check if group exists + public static function supportGroup_Exists( $id) { + $dbl = new DBLayer("lib"); + //check if supportgroup id exist + if( $dbl->execute("SELECT * FROM support_group WHERE SGroupId = :id",array('id' => $id ))->rowCount() ){ + return true; + }else{ + return false; + } + } + + + //return constructed element based on SGroupId + public static function constr_SGroupId( $id) { + $instance = new self(); + $instance->setSGroup($id); + return $instance; + } + + //returns list of all users that are enlisted to a support group + public static function getAllUsersOfSupportGroup($group_id) { + $dbl = new DBLayer("lib"); + $statement = $dbl->execute("SELECT * FROM `in_support_group` INNER JOIN `ticket_user` ON ticket_user.TUserId = in_support_group.User WHERE in_support_group.Group=:id", array('id' => $group_id)); + $rows = $statement->fetchAll(); + $result = Array(); + foreach($rows as $row){ + $userInstance = new Ticket_User(); + $userInstance->setTUserId($row['TUserId']); + $userInstance->setPermission($row['Permission']); + $userInstance->setExternId($row['ExternId']); + $result[] = $userInstance; + } + return $result; + } + + //wrapper for adding user to a support group + public static function deleteSupportGroup($group_id) { + + //check if group id exists + if (self::supportGroup_Exists($group_id)){ + $sGroup = new self(); + $sGroup->setSGroupId($group_id); + $sGroup->delete(); + }else{ + //return that group doesn't exist + return "GROUP_NOT_EXISTING"; + } + + } + + //wrapper for adding user to a support group + public static function deleteUserOfSupportGroup( $user_id, $group_id) { + + //check if group id exists + if (self::supportGroup_Exists($group_id)){ + + //check if user is in supportgroup + //if so, delete entry and return SUCCESS + if(In_Support_Group::userExistsInSGroup($user_id, $group_id) ){ + //delete entry + $inSGroup = new In_Support_Group(); + $inSGroup->setUser($user_id); + $inSGroup->setGroup($group_id); + $inSGroup->delete(); + return "SUCCESS"; + } + else{ + //else return USER_NOT_IN_GROUP + return "USER_NOT_IN_GROUP"; + } + + + }else{ + //return that group doesn't exist + return "GROUP_NOT_EXISTING"; + } + + } + + //wrapper for adding user to a support group + public static function addUserToSupportGroup( $user_id, $group_id) { + //check if group id exists + if (self::supportGroup_Exists($group_id)){ + //check if user isn't in supportgroup yet + //if not, create entry and return SUCCESS + if(! In_Support_Group::userExistsInSGroup($user_id, $group_id) ){ + //create entry + $inSGroup = new In_Support_Group(); + $inSGroup->setUser($user_id); + $inSGroup->setGroup($group_id); + $inSGroup->create(); + return "SUCCESS"; + } + else{ + //else return ALREADY_ADDED + return "ALREADY_ADDED"; + } + + + }else{ + //return that group doesn't exist + return "GROUP_NOT_EXISTING"; + } + + } + + //returns list of all category objects + public static function getAllSupportGroups() { + $dbl = new DBLayer("lib"); + $statement = $dbl->executeWithoutParams("SELECT * FROM `support_group`"); + $row = $statement->fetchAll(); + $result = Array(); + foreach($row as $group){ + $instance = new self(); + $instance->set($group); + $result[] = $instance; + } + return $result; + } + ////////////////////////////////////////////Methods//////////////////////////////////////////////////// + + public function __construct() { + } + + //set values + public function set($values) { + $this->setSGroupId($values['SGroupId']); + $this->setName($values['Name']); + $this->setTag($values['Tag']); + } + + public function create() { + $dbl = new DBLayer("lib"); + $query = "INSERT INTO support_group (Name, Tag) VALUES (:name, :tag)"; + $values = Array('name' => $this->name, 'tag' => $this->tag); + $dbl->execute($query, $values); + } + + //Load with sGroupId + public function load_With_SGroupId( $id) { + $dbl = new DBLayer("lib"); + $statement = $dbl->execute("SELECT * FROM `support_group` WHERE `SGroupId` = :id", array('id' => $id)); + $row = $statement->fetch(); + $this->set($row); + } + + + //update private data to DB. + public function update(){ + $dbl = new DBLayer("lib"); + $query = "UPDATE `support_group` SET `Name` = :name, `Tag` = :tag WHERE `SGroupId` = :id"; + $values = Array('id' => $this->getSGroupId(), 'name' => $this->getName(), 'tag' => $this->getTag() ); + $statement = $dbl->execute($query, $values); + } + + //delete entry + public function delete(){ + $dbl = new DBLayer("lib"); + $query = "DELETE FROM `support_group` WHERE `SGroupId` = :id"; + $values = Array('id' => $this->getSGroupId()); + $statement = $dbl->execute($query, $values); + } + + ////////////////////////////////////////////Getters//////////////////////////////////////////////////// + + public function getSGroupId(){ + return $this->sGroupId; + } + + public function getName(){ + return $this->name; + } + + public function getTag(){ + return $this->tag; + } + + ////////////////////////////////////////////Setters//////////////////////////////////////////////////// + + public function setSGroupId($id){ + $this->sGroupId = $id; + } + + public function setName($n){ + $this->name = $n; + } + + public function setTag($t){ + $this->tag = $t; + } + + +} \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/sync.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/sync.php index 1c68b822b..12376d9b4 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/sync.php +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/sync.php @@ -14,39 +14,35 @@ class Sync{ */ static public function syncdata () { - global $cfg; - try { - $dbl = new DBLayer($cfg['db']['lib']); + $dbl = new DBLayer("lib"); $statement = $dbl->executeWithoutParams("SELECT * FROM ams_querycache"); - $rows = $statement->fetchAll(); - $dbs = new DBLayer($cfg['db']['shard']); + $rows = $statement->fetchAll(); foreach ($rows as $record) { - + + $db = new DBLayer($record['db']); switch($record['type']) { case 'createPermissions': case 'change_pass': $decode = json_decode($record['query']); $values = array('user' => $decode[0], 'pass' => $decode[1]); //make connection with and put into shard db & delete from the lib - $dbs->execute("SET Password = :pass WHERE Login = :user",$values); - $dbl->execute("DELETE FROM ams_querycache WHERE SID=:SID",array('SID' => $record['SID'])); + $db->execute("UPDATE user SET Password = :pass WHERE Login = :user",$values); break; case 'change_mail': $decode = json_decode($record['query']); $values = array('user' => $decode[0], 'mail' => $decode[1]); //make connection with and put into shard db & delete from the lib - $dbs->execute("SET Email = :mail WHERE Login = :user",$values); - $dbl->execute("DELETE FROM ams_querycache WHERE SID=:SID",array('SID' => $record['SID'])); + $db->execute("UPDATE user SET Email = :mail WHERE Login = :user",$values); break; case 'createUser': $decode = json_decode($record['query']); $values = array('login' => $decode[0], 'pass' => $decode[1], 'mail' => $decode[2] ); //make connection with and put into shard db & delete from the lib - $dbs->execute("INSERT INTO user (Login, Password, Email) VALUES (:login, :pass, :mail)",$values); - $dbl->execute("DELETE FROM ams_querycache WHERE SID=:SID",array('SID' => $record['SID'])); + $db->execute("INSERT INTO user (Login, Password, Email) VALUES (:login, :pass, :mail)",$values); break; } + $dbl->execute("DELETE FROM ams_querycache WHERE SID=:SID",array('SID' => $record['SID'])); } print('Syncing completed'); } diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket.php index f8f9f10e3..a9bceacd3 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket.php +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket.php @@ -8,21 +8,65 @@ class Ticket{ private $queue; private $ticket_category; private $author; - private $db; + private $priority; ////////////////////////////////////////////Functions//////////////////////////////////////////////////// - /*FUNCTION: getTicketTitlesOf() + /*FUNCTION: ticketExists + * returns true if ticket exists + * + */ + public static function ticketExists($id) { + $dbl = new DBLayer("lib"); + //check if ticket is already assigned + if( $dbl->execute(" SELECT * FROM `ticket` WHERE `TId` = :ticket_id", array('ticket_id' => $id) )->rowCount() ){ + return true; + }else{ + return false; + } + } + + /*FUNCTION: getStatusArray + * returns all possible statusses + * + */ + public static function getStatusArray() { + return Array("Waiting on user reply","Waiting on support","Waiting on Dev reply","Closed"); + } + + /*FUNCTION: getPriorityArray + * returns all possible statusses + * + */ + public static function getPriorityArray() { + return Array("Low","Normal","High","Super Dupa High"); + } + + + /*FUNCTION: getEntireTicket + * return all ticket of the given author's id. + * + */ + public static function getEntireTicket($id,$view_as_admin) { + $ticket = new Ticket(); + $ticket->load_With_TId($id); + $reply_array = Ticket_Reply::getRepliesOfTicket($id, $view_as_admin); + return Array('ticket_obj' => $ticket,'reply_array' => $reply_array); + } + + + /*FUNCTION: getTicketTitlesOf * return all ticket of the given author's id. * */ - public static function getTicketsOf($author, $db_data) { - $dbl = new DBLayer($db_data); + public static function getTicketsOf($author) { + $dbl = new DBLayer("lib"); $statement = $dbl->execute("SELECT * FROM ticket INNER JOIN ticket_user ON ticket.Author = ticket_user.TUserId and ticket_user.ExternId=:id", array('id' => $author)); $row = $statement->fetchAll(); $result = Array(); foreach($row as $ticket){ - $instance = new self($db_data); + $instance = new self(); + $instance->setTId($ticket['TId']); $instance->setTimestamp($ticket['Timestamp']); $instance->setTitle($ticket['Title']); $instance->setStatus($ticket['Status']); @@ -39,52 +83,168 @@ class Ticket{ * creates a ticket + first initial reply and fills in the content of it! * */ - public static function create_Ticket( $title, $content, $category, $author, $db_data) { + public static function create_Ticket( $title, $content, $category, $author, $real_author) { - $ticket = new Ticket($db_data); - $ticket->set($title,0,0,$category,$author); + $ticket = new Ticket(); + $values = array("Title" => $title, "Status"=> 1, "Queue"=> 0, "Ticket_Category" => $category, "Author" => $author, "Priority" => 0); + $ticket->set($values); $ticket->create(); $ticket_id = $ticket->getTId(); - - $ticket_content = new Ticket_Content($db_data); - $ticket_content->setContent($content); - $ticket_content->create(); - $content_id = $ticket_content->getTContentId(); - + if ( $author == $real_author){ + Ticket_Log::createLogEntry( $ticket_id, $author, 1); + }else{ + Ticket_Log::createLogEntry( $ticket_id, $real_author, 2, $author); + } + Ticket_Reply::createReply($content, $author, $ticket_id, 0, $author); + Mail_Handler::send_ticketing_mail($ticket, $content, "NEW", $real_author); + return $ticket_id; - $ticket_reply = new Ticket_Reply($db_data); - $ticket_reply->set($ticket_id, $content_id, $author); - $ticket_reply->create(); + } + + /*FUNCTION: updateTicketStatus() + * + * + */ + public static function updateTicketStatus( $ticket_id, $newStatus, $author) { + + $ticket = new Ticket(); + $ticket->load_With_TId($ticket_id); + if ($ticket->getStatus() != $newStatus){ + $ticket->setStatus($newStatus); + Ticket_Log::createLogEntry( $ticket_id, $author, 5, $newStatus); + } + $ticket->update(); } + + /*FUNCTION: updateTicketStatusAndPriority() + * creates a ticket + first initial reply and fills in the content of it! + * + */ + public static function updateTicketStatusAndPriority( $ticket_id, $newStatus, $newPriority, $author) { + + $ticket = new Ticket(); + $ticket->load_With_TId($ticket_id); + if ($ticket->getStatus() != $newStatus){ + $ticket->setStatus($newStatus); + Ticket_Log::createLogEntry( $ticket_id, $author, 5, $newStatus); + } + if ($ticket->getPriority() != $newPriority){ + $ticket->setPriority($newPriority); + Ticket_Log::createLogEntry( $ticket_id, $author, 6, $newPriority); + } + $ticket->update(); + + } + + //return the latest reply. + public static function getLatestReply( $ticket_id) { + $dbl = new DBLayer("lib"); + $statement = $dbl->execute("SELECT * FROM ticket_reply WHERE Ticket =:id ORDER BY TReplyId DESC LIMIT 1 ", array('id' => $ticket_id)); + $reply = new Ticket_Reply(); + $reply->set($statement->fetch()); + return $reply; + } + + public static function createReply($content, $author, $ticket_id, $hidden){ + //if not empty + if(! ( Trim ( $content ) === '' )){ + $content = filter_var($content, FILTER_SANITIZE_STRING); + $ticket = new Ticket(); + $ticket->load_With_TId($ticket_id); + //if status is not closed + if($ticket->getStatus() != 3){ + Ticket_Reply::createReply($content, $author, $ticket_id, $hidden, $ticket->getAuthor()); + + //notify ticket author that a new reply is added! + if($ticket->getAuthor() != $author){ + Mail_Handler::send_ticketing_mail($ticket, $content, "REPLY", $author); + } + + + }else{ + //TODO: Show error message that ticket is closed + } + }else{ + //TODO: Show error content is empty + } + } + + //returns SUCCESS_ASSIGNED, TICKET_NOT_EXISTING or ALREADY_ASSIGNED + public static function assignTicket($user_id, $ticket_id){ + if(self::ticketExists($ticket_id)){ + $returnvalue = Assigned::assignTicket($user_id, $ticket_id); + Ticket_Log::createLogEntry( $ticket_id, $user_id, 7); + return $returnvalue; + }else{ + return "TICKET_NOT_EXISTING"; + } + } + + //returns SUCCESS_UNASSIGNED, TICKET_NOT_EXISTING or NOT_ASSIGNED + public static function unAssignTicket($user_id, $ticket_id){ + if(self::ticketExists($ticket_id)){ + $returnvalue = Assigned::unAssignTicket($user_id, $ticket_id); + Ticket_Log::createLogEntry( $ticket_id, $user_id, 9); + return $returnvalue; + }else{ + return "TICKET_NOT_EXISTING"; + } + } + + public static function forwardTicket($user_id, $ticket_id, $group_id){ + if(self::ticketExists($ticket_id)){ + if(isset($group_id) && $group_id != ""){ + //unassign the ticket incase the ticket is assined to yourself + self::unAssignTicket($user_id, $ticket_id); + //forward the ticket + $returnvalue = Forwarded::forwardTicket($group_id, $ticket_id); + //make a log entry of this action + Ticket_Log::createLogEntry( $ticket_id, $user_id, 8, $group_id); + return $returnvalue; + }else{ + return "INVALID_SGROUP"; + } + }else{ + return "TICKET_NOT_EXISTING"; + } + } + + + + ////////////////////////////////////////////Methods//////////////////////////////////////////////////// - public function __construct($db_data) { - $this->db = $db_data; + public function __construct() { + } //Set ticket object - public function set($t,$s,$q,$t_c,$a){ - $this->title = $t; - $this->status = $s; - $this->queue = $q; - $this->ticket_category = $t_c; - $this->author = $a; + public function set($values){ + if(isset($values['TId'])){ + $this->tId = $values['TId']; + } + $this->title = $values['Title']; + $this->status = $values['Status']; + $this->queue = $values['Queue']; + $this->ticket_category = $values['Ticket_Category']; + $this->author = $values['Author']; + $this->priority = $values['Priority']; } //create ticket by writing private data to DB. public function create(){ - $dbl = new DBLayer($this->db); - $query = "INSERT INTO ticket (Timestamp, Title, Status, Queue, Ticket_Category, Author) VALUES (now(), :title, :status, :queue, :tcat, :author)"; - $values = Array('title' => $this->title, 'status' => $this->status, 'queue' => $this->queue, 'tcat' => $this->ticket_category, 'author' => $this->author); + $dbl = new DBLayer("lib"); + $query = "INSERT INTO ticket (Timestamp, Title, Status, Queue, Ticket_Category, Author, Priority) VALUES (now(), :title, :status, :queue, :tcat, :author, :priority)"; + $values = Array('title' => $this->title, 'status' => $this->status, 'queue' => $this->queue, 'tcat' => $this->ticket_category, 'author' => $this->author, 'priority' => $this->priority); $this->tId = $dbl->executeReturnId($query, $values); ; } //return constructed element based on TId public function load_With_TId( $id) { - $dbl = new DBLayer($this->db); + $dbl = new DBLayer("lib"); $statement = $dbl->execute("SELECT * FROM ticket WHERE TId=:id", array('id' => $id)); $row = $statement->fetch(); $this->tId = $row['TId']; @@ -94,18 +254,24 @@ class Ticket{ $this->queue = $row['Queue']; $this->ticket_category = $row['Ticket_Category']; $this->author = $row['Author']; + $this->priority = $row['Priority']; } - //update private data to DB. public function update(){ - $dbl = new DBLayer($this->db); - $query = "UPDATE ticket SET Timestamp = :timestamp, Title = :title, Status = :status, Queue = :queue, Ticket_Category = :tcat, Author = :author WHERE TId=:id"; - $values = Array('id' => $this->tId, 'timestamp' => $this->timestamp, 'title' => $this->title, 'status' => $this->status, 'queue' => $this->queue, 'tcat' => $this->ticket_category, 'author' => $this->author); + $dbl = new DBLayer("lib"); + $query = "UPDATE ticket SET Timestamp = :timestamp, Title = :title, Status = :status, Queue = :queue, Ticket_Category = :tcat, Author = :author, Priority = :priority WHERE TId=:id"; + $values = Array('id' => $this->tId, 'timestamp' => $this->timestamp, 'title' => $this->title, 'status' => $this->status, 'queue' => $this->queue, 'tcat' => $this->ticket_category, 'author' => $this->author, 'priority' => $this->priority); $statement = $dbl->execute($query, $values); } - + /*FUNCTION: postreply + * returns all possible statusses + * + * + public function postReply() { + return Array("Waiting on user reply","Waiting on support","Waiting on Dev reply","Closed"); + }*/ ////////////////////////////////////////////Getters//////////////////////////////////////////////////// public function getTId(){ @@ -113,7 +279,7 @@ class Ticket{ } public function getTimestamp(){ - return $this->timestamp; + return Helpers::outputTime($this->timestamp); } public function getTitle(){ @@ -124,6 +290,16 @@ class Ticket{ return $this->status; } + public function getStatusText(){ + $statusArray = Ticket::getStatusArray(); + return $statusArray[$this->getStatus()]; + } + + public function getCategoryName(){ + $category = Ticket_Category::constr_TCategoryId($this->getTicket_Category()); + return $category->getName(); + } + public function getQueue(){ return $this->queue; } @@ -136,6 +312,41 @@ class Ticket{ return $this->author; } + public function getPriority(){ + return $this->priority; + } + + public function getPriorityText(){ + $priorityArray = Ticket::getPriorityArray(); + return $priorityArray[$this->getPriority()]; + } + + public function getAssigned(){ + $user_id = Assigned::getUserAssignedToTicket($this->getTId()); + if ($user_id == ""){ + return 0; + }else{ + return $user_id; + } + } + + public function getForwardedGroupName(){ + $group_id = Forwarded::getSGroupOfTicket($this->getTId()); + if ($group_id == ""){ + return 0; + }else{ + return Support_Group::getGroup($group_id)->getName(); + } + } + + public function getForwardedGroupId(){ + $group_id = Forwarded::getSGroupOfTicket($this->getTId()); + if ($group_id == ""){ + return 0; + }else{ + return $group_id; + } + } ////////////////////////////////////////////Setters//////////////////////////////////////////////////// public function setTId($id){ @@ -166,4 +377,8 @@ class Ticket{ $this->author = $a; } + public function setPriority($p){ + $this->priority = $p; + } + } \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_category.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_category.php index 1fe7227b7..c2fd6a5d4 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_category.php +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_category.php @@ -9,8 +9,8 @@ class Ticket_Category{ //Creates a ticket_Catergory in the DB - public static function createTicketCategory( $name ,$db ) { - $dbl = new DBLayer($db); + public static function createTicketCategory( $name) { + $dbl = new DBLayer("lib"); $query = "INSERT INTO ticket_category (Name) VALUES (:name)"; $values = Array('name' => $name); $dbl->execute($query, $values); @@ -19,20 +19,20 @@ class Ticket_Category{ //return constructed element based on TCategoryId - public static function constr_TCategoryId( $id, $db_data) { - $instance = new self($db_data); + public static function constr_TCategoryId( $id) { + $instance = new self(); $instance->setTCategoryId($id); return $instance; } //returns list of all category objects - public static function getAllCategories($db_data) { - $dbl = new DBLayer($db_data); + public static function getAllCategories() { + $dbl = new DBLayer("lib"); $statement = $dbl->executeWithoutParams("SELECT * FROM ticket_category"); $row = $statement->fetchAll(); $result = Array(); foreach($row as $category){ - $instance = new self($db_data); + $instance = new self(); $instance->tCategoryId = $category['TCategoryId']; $instance->name = $category['Name']; $result[] = $instance; @@ -43,13 +43,12 @@ class Ticket_Category{ ////////////////////////////////////////////Methods//////////////////////////////////////////////////// - public function __construct($db_data) { - $this->db = $db_data; + public function __construct() { } //return constructed element based on TCategoryId public function load_With_TCategoryId( $id) { - $dbl = new DBLayer($this->db); + $dbl = new DBLayer("lib"); $statement = $dbl->execute("SELECT * FROM ticket_category WHERE TCategoryId=:id", array('id' => $id)); $row = $statement->fetch(); $this->tCategoryId = $row['TCategoryId']; @@ -59,7 +58,7 @@ class Ticket_Category{ //update private data to DB. public function update(){ - $dbl = new DBLayer($this->db); + $dbl = new DBLayer("lib"); $query = "UPDATE ticket_category SET Name = :name WHERE TCategoryId=:id"; $values = Array('id' => $this->tCategoryId, 'name' => $this->name); $statement = $dbl->execute($query, $values); diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_content.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_content.php index 62130d1d9..bc9ca8398 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_content.php +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_content.php @@ -9,8 +9,8 @@ class Ticket_Content{ ////////////////////////////////////////////Functions//////////////////////////////////////////////////// //return constructed element based on TCategoryId - public static function constr_TContentId( $id, $db_data) { - $instance = new self($db_data); + public static function constr_TContentId( $id) { + $instance = new self(); $instance->setTContentId($id); return $instance; } @@ -18,13 +18,12 @@ class Ticket_Content{ ////////////////////////////////////////////Methods//////////////////////////////////////////////////// - public function __construct($db_data) { - $this->db = $db_data; + public function __construct() { } //Creates a ticket_content entry in the DB public function create() { - $dbl = new DBLayer($this->db); + $dbl = new DBLayer("lib"); $query = "INSERT INTO ticket_content (Content) VALUES (:content)"; $values = Array('content' => $this->content); $this->tContentId = $dbl->executeReturnId($query, $values); ; @@ -32,7 +31,7 @@ class Ticket_Content{ //return constructed element based on TContentId public function load_With_TContentId( $id) { - $dbl = new DBLayer($this->db); + $dbl = new DBLayer("lib"); $statement = $dbl->execute("SELECT * FROM ticket_content WHERE TContentId=:id", array('id' => $id)); $row = $statement->fetch(); $this->tContentId = $row['TContentId']; @@ -41,7 +40,7 @@ class Ticket_Content{ //update private data to DB. public function update(){ - $dbl = new DBLayer($this->db); + $dbl = new DBLayer("lib"); $query = "UPDATE ticket_content SET Content = :content WHERE TContentId=:id"; $values = Array('id' => $this->tContentId, 'content' => $this->content); $statement = $dbl->execute($query, $values); diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_log.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_log.php new file mode 100644 index 000000000..d011049d7 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_log.php @@ -0,0 +1,180 @@ +execute("SELECT * FROM ticket_log INNER JOIN ticket_user ON ticket_log.Author = ticket_user.TUserId and ticket_log.Ticket=:id ORDER BY ticket_log.TLogId ASC", array('id' => $ticket_id)); + $row = $statement->fetchAll(); + $result = Array(); + foreach($row as $log){ + $instanceAuthor = Ticket_User::constr_TUserId($log['Author']); + $instanceAuthor->setExternId($log['ExternId']); + $instanceAuthor->setPermission($log['Permission']); + + $instanceLog = new self(); + $instanceLog->setTLogId($log['TLogId']); + $instanceLog->setTimestamp($log['Timestamp']); + $instanceLog->setAuthor($instanceAuthor); + $instanceLog->setTicket($ticket_id); + $instanceLog->setQuery($log['Query']); + + $result[] = $instanceLog; + } + return $result; + } + + //Creates a log entry + public static function createLogEntry( $ticket_id, $author_id, $action, $arg = -1) { + global $TICKET_LOGGING; + if($TICKET_LOGGING){ + $dbl = new DBLayer("lib"); + $query = "INSERT INTO ticket_log (Timestamp, Query, Ticket, Author) VALUES (now(), :query, :ticket, :author )"; + $values = Array('ticket' => $ticket_id, 'author' => $author_id, 'query' => json_encode(array($action,$arg))); + $dbl->execute($query, $values); + } + } + + + //return constructed element based on TLogId + public static function constr_TLogId( $id) { + $instance = new self(); + $instance->setTLogId($id); + return $instance; + } + + //returns list of all logs of a ticket + public static function getAllLogs($ticket_id) { + $dbl = new DBLayer("lib"); + $statement = $dbl->execute("SELECT * FROM ticket_log INNER JOIN ticket_user ON ticket_log.Author = ticket_user.TUserId and ticket_log.Ticket=:id", array('id' => $ticket_id)); + $row = $statement->fetchAll(); + $result = Array(); + foreach($row as $log){ + $instance = new self(); + $instance->set($log); + $result[] = $instance; + } + return $result; + } + + + ////////////////////////////////////////////Methods//////////////////////////////////////////////////// + + public function __construct() { + } + + //set values + public function set($values) { + $this->setTLogId($values['TLogId']); + $this->setTimestamp($values['Timestamp']); + $this->setQuery($values['Query']); + $this->setTicket($values['Ticket']); + $this->setAuthor($values['Author']); + } + + //Load with tlogId + public function load_With_TLogId( $id) { + $dbl = new DBLayer("lib"); + $statement = $dbl->execute("SELECT * FROM ticket_log WHERE TLogId=:id", array('id' => $id)); + $row = $statement->fetch(); + $this->set($row); + } + + + //update private data to DB. + public function update(){ + $dbl = new DBLayer("lib"); + $query = "UPDATE ticket_log SET Timestamp = :timestamp, Query = :query, Author = :author, Ticket = :ticket WHERE TLogId=:id"; + $values = Array('id' => $this->getTLogId(), 'timestamp' => $this->getTimestamp(), 'query' => $this->getQuery(), 'author' => $this->getAuthor(), 'ticket' => $this->getTicket() ); + $statement = $dbl->execute($query, $values); + } + + ////////////////////////////////////////////Getters//////////////////////////////////////////////////// + + public function getTLogId(){ + return $this->tLogId; + } + + public function getTimestamp(){ + return Helpers::outputTime($this->timestamp); + } + + public function getQuery(){ + return $this->query; + } + + public function getAuthor(){ + return $this->author; + } + + public function getTicket(){ + return $this->ticket; + } + + public function getAction(){ + $decodedQuery = json_decode($this->query); + return $decodedQuery[0]; + } + + public function getArgument(){ + $decodedQuery = json_decode($this->query); + return $decodedQuery[1]; + } + + public function getActionTextArray(){ + $variables = Helpers::handle_language(); + $result = array(); + foreach ( $variables['ticket_log'] as $key => $value ){ + $result[$key] = $value; + } + return $result; + } + + ////////////////////////////////////////////Setters//////////////////////////////////////////////////// + + public function setTLogId($id){ + $this->tLogId = $id; + } + + public function setTimestamp($t){ + $this->timestamp = $t; + } + + public function setQuery($q){ + $this->query = $q; + } + + public function setAuthor($a){ + $this->author = $a; + } + + public function setTicket($t){ + $this->ticket = $t; + } + + +} \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_queue.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_queue.php new file mode 100644 index 000000000..8751efbaa --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_queue.php @@ -0,0 +1,89 @@ +query = "SELECT ticket . * FROM ticket LEFT JOIN assigned ON ticket.TId = assigned.Ticket WHERE assigned.Ticket IS NULL"; + $this->params = array(); + } + + public function loadAllTickets(){ + $this->query = "SELECT * FROM `ticket`"; + $this->params = array(); + } + + public function loadAllOpenTickets(){ + $this->query = "SELECT * FROM ticket INNER JOIN ticket_user ON ticket.Author = ticket_user.TUserId and ticket.Status!=3"; + $this->params = array(); + } + + public function loadAllClosedTickets(){ + $this->query = "SELECT * FROM ticket INNER JOIN ticket_user ON ticket.Author = ticket_user.TUserId and ticket.Status=3"; + $this->params = array(); + } + + public function loadToDoTickets($user_id){ + + //first: find the tickets assigned to the user with status = waiting on support + //second find all not assigned tickets that aren't forwarded yet. + //find all tickets assigned to someone else witht status waiting on support, with timestamp of last reply > 1 day + //find all non-assigned tickets forwarded to the support groups to which that user belongs + $this->query = "SELECT * FROM `ticket` t LEFT JOIN `assigned` a ON t.TId = a.Ticket LEFT JOIN `ticket_user` tu ON tu.TUserId = a.User LEFT JOIN `forwarded` f ON t.TId = f.Ticket + WHERE (tu.ExternId = :user_id AND t.Status = 1) + OR (a.Ticket IS NULL AND f.Group IS NULL) + OR (tu.ExternId != :user_id AND t.Status = 1 AND (SELECT ticket_reply.Timestamp FROM `ticket_reply` WHERE Ticket =t.TId ORDER BY TReplyId DESC LIMIT 1) < NOW() - INTERVAL 1 DAY ) + OR (a.Ticket IS NULL AND EXISTS (SELECT * FROM `in_support_group` isg JOIN `ticket_user` tu2 ON isg.User = tu2.TUserId WHERE isg.Group = f.Group)) + "; + $this->params = array('user_id' => $user_id); + } + + public function createQueue($userid, $groupid, $what, $how, $who){ + + if($who == "user"){ + $selectfrom = "SELECT * FROM `ticket` t LEFT JOIN `assigned` a ON t.TId = a.Ticket LEFT JOIN `ticket_user` tu ON tu.TUserId = a.User"; + if ($how == "assigned"){ + $assign = "tu.TUserId = :id" ; + }else if ($how == "not_assigned"){ + $assign = "(tu.TUserId != :id OR a.Ticket IS NULL)"; + } + }else if ($who == "support_group"){ + $selectfrom = "SELECT * FROM `ticket` t LEFT JOIN `assigned` a ON t.TId = a.Ticket LEFT JOIN `ticket_user` tu ON tu.TUserId = a.User LEFT JOIN `forwarded` f ON t.TId = f.Ticket"; + if ($how == "assigned"){ + $assign = "f.Group = :id"; + }else if ($how == "not_assigned"){ + $assign = "(f.Group != :id OR f.Ticket IS NULL)" ; + } + + } + + if ($what == "waiting_for_support"){ + $status = "t.Status = 1"; + }else if ($what == "waiting_for_user"){ + $status = "t.Status = 0"; + }else if ($what == "closed"){ + $status = "t.Status = 3"; + } + + $query = $selectfrom ." WHERE " . $assign; + if(isset($status)){ + $query = $query . " AND " . $status; + } + if($who == "user"){ + $params = array('id' => $userid); + }else if ($who == "support_group"){ + $params = array('id' => $groupid); + } + $this->query = $query; + $this->params = $params; + } + + public function getQuery(){ + return $this->query; + } + + public function getParams(){ + return $this->params; + } +} \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_queue_handler.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_queue_handler.php new file mode 100644 index 000000000..8930a0651 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_queue_handler.php @@ -0,0 +1,58 @@ +queue = new Ticket_Queue(); + } + + public function getTickets($input, $user_id){ + + switch ($input){ + case "all": + $this->queue->loadAllTickets(); + break; + case "all_open": + $this->queue->loadAllOpenTickets(); + break; + case "archive": + $this->queue->loadAllClosedTickets(); + break; + case "not_assigned": + $this->queue->loadAllNotAssignedTickets(); + break; + case "todo": + $this->queue->loadToDoTickets($user_id); + break; + case "create": + //set these with the createQueue function proceding the getTickets function + break; + default: + return "ERROR"; + } + $this->pagination = new Pagination($this->queue->getQuery(),"lib",10,"Ticket",$this->queue->getParams()); + foreach( $this->pagination->getElements() as $element ){ + $catInstance = new Ticket_Category(); + $catInstance->load_With_TCategoryId($element->getTicket_Category()); + $element->setTicket_Category($catInstance); + + $userInstance = new Ticket_User(); + $userInstance->load_With_TUserId($element->getAuthor()); + $element->setAuthor($userInstance); + } + return $this->pagination->getElements(); + + } + + public function getPagination(){ + return $this->pagination; + } + + public function createQueue($userid, $groupid, $what, $how, $who){ + $this->queue->createQueue($userid, $groupid, $what, $how, $who); + } + +} \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_reply.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_reply.php index 8f14a9f5f..dafbdf74b 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_reply.php +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_reply.php @@ -6,56 +6,110 @@ class Ticket_Reply{ private $content; private $author; private $timestamp; - private $db; + private $hidden; ////////////////////////////////////////////Functions//////////////////////////////////////////////////// //return constructed element based on TCategoryId - public static function constr_TReplyId( $id, $db_data) { - $instance = new self($db_data); + public static function constr_TReplyId( $id) { + $instance = new self(); $instance->setTReplyId($id); return $instance; } + + //return constructed element based on TCategoryId + public static function getRepliesOfTicket( $ticket_id, $view_as_admin) { + $dbl = new DBLayer("lib"); + $statement = $dbl->execute("SELECT * FROM ticket_reply INNER JOIN ticket_content INNER JOIN ticket_user ON ticket_reply.Content = ticket_content.TContentId and ticket_reply.Ticket=:id and ticket_user.TUserId = ticket_reply.Author ORDER BY ticket_reply.TReplyId ASC", array('id' => $ticket_id)); + $row = $statement->fetchAll(); + $result = Array(); + foreach($row as $tReply){ + if(! $tReply['Hidden'] || $view_as_admin){ + $instanceAuthor = Ticket_User::constr_TUserId($tReply['Author']); + $instanceAuthor->setExternId($tReply['ExternId']); + $instanceAuthor->setPermission($tReply['Permission']); + + $instanceContent = new Ticket_Content(); + $instanceContent->setTContentId($tReply['TContentId']); + $instanceContent->setContent($tReply['Content']); + + $instanceReply = new self(); + $instanceReply->setTReplyId($tReply['TReplyId']); + $instanceReply->setTimestamp($tReply['Timestamp']); + $instanceReply->setAuthor($instanceAuthor); + $instanceReply->setTicket($ticket_id); + $instanceReply->setContent($instanceContent); + $instanceReply->setHidden($tReply['Hidden']); + $result[] = $instanceReply; + } + } + return $result; + } + + public static function createReply($content, $author, $ticket_id , $hidden, $ticket_creator){ + $ticket_content = new Ticket_Content(); + $ticket_content->setContent($content); + $ticket_content->create(); + $content_id = $ticket_content->getTContentId(); + + $ticket_reply = new Ticket_Reply(); + $ticket_reply->set(Array('Ticket' => $ticket_id,'Content' => $content_id,'Author' => $author, 'Hidden' => $hidden)); + $ticket_reply->create(); + $reply_id = $ticket_reply->getTReplyId(); + + if($ticket_creator == $author){ + Ticket::updateTicketStatus( $ticket_id, 1, $author); + } + + Ticket_Log::createLogEntry( $ticket_id, $author, 4, $reply_id); + } + ////////////////////////////////////////////Methods//////////////////////////////////////////////////// - public function __construct($db_data) { - $this->db = $db_data; + public function __construct() { } //Set ticket_reply object - public function set($t,$c,$a){ - $this->ticket = $t; - $this->content = $c; - $this->author = $a; + public function set($values){ + $this->setTicket($values['Ticket']); + $this->setContent($values['Content']); + $this->setAuthor($values['Author']); + if(isset($values['Timestamp'])){ + $this->setTimestamp($values['Timestamp']); + } + if(isset($values['Hidden'])){ + $this->setHidden($values['Hidden']); + } } //create ticket by writing private data to DB. public function create(){ - $dbl = new DBLayer($this->db); - $query = "INSERT INTO ticket_reply (Ticket, Content, Author, Timestamp) VALUES (:ticket, :content, :author, now())"; - $values = Array('ticket' => $this->ticket, 'content' => $this->content, 'author' => $this->author); - $dbl->execute($query, $values); + $dbl = new DBLayer("lib"); + $query = "INSERT INTO ticket_reply (Ticket, Content, Author, Timestamp, Hidden) VALUES (:ticket, :content, :author, now(), :hidden)"; + $values = Array('ticket' => $this->ticket, 'content' => $this->content, 'author' => $this->author, 'hidden' => $this->hidden); + $this->tReplyId = $dbl->executeReturnId($query, $values); } //return constructed element based on TId public function load_With_TReplyId( $id) { - $dbl = new DBLayer($this->db); + $dbl = new DBLayer("lib"); $statement = $dbl->execute("SELECT * FROM ticket_reply WHERE TReplyId=:id", array('id' => $id)); $row = $statement->fetch(); $this->tReplyId = $row['TReplyId']; $this->ticket = $row['Ticket']; $this->content = $row['Content']; $this->author = $row['Author']; - $this->timestamp = $row['Timestamp']; + $this->timestamp = $row['Timestamp']; + $this->hidden = $row['Hidden']; } //update private data to DB. public function update(){ - $dbl = new DBLayer($this->db); - $query = "UPDATE ticket SET Ticket = :ticket, Content = :content, Author = :author, Timestamp = :timestamp WHERE TReplyId=:id"; - $values = Array('id' => $this->tReplyId, 'timestamp' => $this->timestamp, 'ticket' => $this->ticket, 'content' => $this->content, 'author' => $this->author); + $dbl = new DBLayer("lib"); + $query = "UPDATE ticket SET Ticket = :ticket, Content = :content, Author = :author, Timestamp = :timestamp, Hidden = :hidden WHERE TReplyId=:id"; + $values = Array('id' => $this->tReplyId, 'timestamp' => $this->timestamp, 'ticket' => $this->ticket, 'content' => $this->content, 'author' => $this->author, 'hidden' => $this->hidden); $statement = $dbl->execute($query, $values); } @@ -75,14 +129,17 @@ class Ticket_Reply{ } public function getTimestamp(){ - return $this->timestamp; + return Helpers::outputTime($this->timestamp); } public function getTReplyId(){ return $this->tReplyId; } - + + public function getHidden(){ + return $this->hidden; + } ////////////////////////////////////////////Setters//////////////////////////////////////////////////// @@ -107,4 +164,8 @@ class Ticket_Reply{ public function setTReplyId($i){ $this->tReplyId = $i; } + + public function setHidden($h){ + $this->hidden = $h; + } } \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_user.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_user.php index b61c99f68..fe3529925 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_user.php +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_user.php @@ -4,32 +4,58 @@ class Ticket_User{ private $tUserId; private $permission; private $externId; - private $db; ////////////////////////////////////////////Functions//////////////////////////////////////////////////// //Creates a ticket_user in the DB - public static function createTicketUser( $extern_id, $permission,$db ) { - $dbl = new DBLayer($db); + public static function createTicketUser( $extern_id, $permission) { + $dbl = new DBLayer("lib"); $query = "INSERT INTO ticket_user (Permission, ExternId) VALUES (:perm, :ext_id)"; $values = Array('perm' => $permission, 'ext_id' => $extern_id); $dbl->execute($query, $values); } - - + + public static function isMod($user){ + if(isset($user) && $user->getPermission() > 1){ + return true; + } + return false; + } + + public static function isAdmin($user){ + if(isset($user) && $user->getPermission() == 3){ + return true; + } + return false; + } + //return constructed element based on TUserId - public static function constr_TUserId( $id, $db_data) { - $instance = new self($db_data); + public static function constr_TUserId( $id) { + $instance = new self(); $instance->setTUserId($id); return $instance; } + //return all mods/admins + public static function getModsAndAdmins() { + $dbl = new DBLayer("lib"); + $statement = $dbl->executeWithoutParams("SELECT * FROM `ticket_user` WHERE `Permission` > 1"); + $rows = $statement->fetchAll(); + $result = Array(); + foreach($rows as $user){ + $instanceUser = new self(); + $instanceUser->set($user); + $result[] = $instanceUser; + } + return $result; + } + //return constructed element based on ExternId - public static function constr_ExternId( $id, $db_data ) { - $instance = new self($db_data); - $dbl = new DBLayer($instance->db); + public static function constr_ExternId( $id) { + $instance = new self(); + $dbl = new DBLayer("lib"); $statement = $dbl->execute("SELECT * FROM ticket_user WHERE ExternId=:id", array('id' => $id)); $row = $statement->fetch(); $instance->tUserId = $row['TUserId']; @@ -39,26 +65,69 @@ class Ticket_User{ } + public static function change_permission($user_id, $perm){ + $user = new Ticket_User(); + $user->load_With_TUserId($user_id); + $user->setPermission($perm); + $user->update(); + } + + + public static function get_email_by_user_id($id){ + $user = new Ticket_User(); + $user->load_With_TUserId($id); + $webUser = new WebUsers($user->getExternId()); + return $webUser->getEmail(); + } + + + public static function get_username_from_id($id){ + $user = new Ticket_User(); + $user->load_With_TUserId($id); + $webUser = new WebUsers($user->getExternId()); + return $webUser->getUsername(); + } + + + public static function get_id_from_username($username){ + $externId = WebUsers::getId($username); + $user = Ticket_User::constr_ExternId($externId); + return $user->getTUserId(); + } + + + public static function get_id_from_email($email){ + $webUserId = WebUsers::getIdFromEmail($email); + $user = Ticket_User::constr_ExternId($webUserId); + return $user->getTUserId(); + } + ////////////////////////////////////////////Methods//////////////////////////////////////////////////// - public function __construct($db_data) { - $this->db = $db_data; + public function __construct() { } + //set values + public function set($values) { + $this->setTUserId($values['TUserId']); + $this->setPermission($values['Permission']); + $this->setExternId($values['ExternId']); + } + + //return constructed element based on TUserId public function load_With_TUserId( $id) { - $dbl = new DBLayer($this->db); + $dbl = new DBLayer("lib"); $statement = $dbl->execute("SELECT * FROM ticket_user WHERE TUserId=:id", array('id' => $id)); $row = $statement->fetch(); - $instance->tUserId = $row['TUserId']; - $instance->permission = $row['Permission']; - $instance->externId = $row['ExternId']; - return $instance; + $this->tUserId = $row['TUserId']; + $this->permission = $row['Permission']; + $this->externId = $row['ExternId']; } //update private data to DB. public function update(){ - $dbl = new DBLayer($this->db); + $dbl = new DBLayer("lib"); $query = "UPDATE ticket_user SET Permission = :perm, ExternId = :ext_id WHERE TUserId=:id"; $values = Array('id' => $this->tUserId, 'perm' => $this->permission, 'ext_id' => $this->externId); $statement = $dbl->execute($query, $values); @@ -67,17 +136,11 @@ class Ticket_User{ ////////////////////////////////////////////Getters//////////////////////////////////////////////////// public function getPermission(){ - if ($this->permission == ""){ - $this->load_With_TUserId($this->tUserId); - } return $this->permission; } public function getExternId(){ - if ($this->ExternId == ""){ - $this->load_With_TUserId($this->tUserId); - } return $this->externId; } @@ -98,4 +161,9 @@ class Ticket_User{ $this->externId = $id; } + public function setTUserId($id){ + $this->tUserId= $id; + } + + } \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/users.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/users.php index 9ce16aa37..d5ba0963a 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/users.php +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/users.php @@ -243,7 +243,7 @@ class Users{ * @takes $length, which is by default 2 * @return a random salt of 2 chars */ - public function generateSALT( $length = 2 ) + public static function generateSALT( $length = 2 ) { // start with a blank salt $salt = ""; @@ -284,22 +284,21 @@ class Users{ * @takes $array with name,pass and mail * @return ok if it's get correctly added to the shard, else return lib offline and put in libDB, if libDB is also offline return liboffline. */ - public function createUser($values, $user_id){ + public static function createUser($values, $user_id){ try { //make connection with and put into shard db - global $cfg; - $dbs = new DBLayer($cfg['db']['shard']); + $dbs = new DBLayer("shard"); $dbs->execute("INSERT INTO user (Login, Password, Email) VALUES (:name, :pass, :mail)",$values); - ticket_user::createTicketUser( $user_id , 1, $cfg['db']['lib'] ); + ticket_user::createTicketUser( $user_id, 1); return "ok"; } catch (PDOException $e) { //oh noooz, the shard is offline! Put in query queue at ams_lib db! try { - $dbl = new DBLayer($cfg['db']['lib']); - $dbl->execute("INSERT INTO ams_querycache (type, query) VALUES (:type, :query)",array("type" => "createUser", - "query" => json_encode(array($values["name"],$values["pass"],$values["mail"])))); - ticket_user::createTicketUser( $user_id , 1, $cfg['db']['lib'] ); + $dbl = new DBLayer("lib"); + $dbl->execute("INSERT INTO ams_querycache (type, query, db) VALUES (:type, :query, :db)",array("type" => "createUser", + "query" => json_encode(array($values["name"],$values["pass"],$values["mail"])), "db" => "shard")); + ticket_user::createTicketUser( $user_id , 1 ); return "shardoffline"; }catch (PDOException $e) { print_r($e); @@ -369,21 +368,20 @@ class Users{ protected function setAmsPassword($user, $pass){ - global $cfg; $values = Array('user' => $user, 'pass' => $pass); try { //make connection with and put into shard db - $dbs = new DBLayer($cfg['db']['shard']); + $dbs = new DBLayer("shard"); $dbs->execute("UPDATE user SET Password = :pass WHERE Login = :user ",$values); return "ok"; } catch (PDOException $e) { //oh noooz, the shard is offline! Put in query queue at ams_lib db! try { - $dbl = new DBLayer($cfg['db']['lib']); - $dbl->execute("INSERT INTO ams_querycache (type, query) VALUES (:type, :query)",array("type" => "change_pass", - "query" => json_encode(array($values["user"],$values["pass"])))); + $dbl = new DBLayer("lib"); + $dbl->execute("INSERT INTO ams_querycache (type, query, db) VALUES (:type, :query, :db)",array("type" => "change_pass", + "query" => json_encode(array($values["user"],$values["pass"])), "db" => "shard")); return "shardoffline"; }catch (PDOException $e) { return "liboffline"; @@ -393,21 +391,20 @@ class Users{ protected function setAmsEmail($user, $mail){ - global $cfg; $values = Array('user' => $user, 'mail' => $mail); try { //make connection with and put into shard db - $dbs = new DBLayer($cfg['db']['shard']); + $dbs = new DBLayer("shard"); $dbs->execute("UPDATE user SET Email = :mail WHERE Login = :user ",$values); return "ok"; } catch (PDOException $e) { //oh noooz, the shard is offline! Put in query queue at ams_lib db! try { - $dbl = new DBLayer($cfg['db']['lib']); - $dbl->execute("INSERT INTO ams_querycache (type, query) VALUES (:type, :query)",array("type" => "change_mail", - "query" => json_encode(array($values["user"],$values["mail"])))); + $dbl = new DBLayer("lib"); + $dbl->execute("INSERT INTO ams_querycache (type, query, db) VALUES (:type, :query, :db)",array("type" => "change_mail", + "query" => json_encode(array($values["user"],$values["mail"])), "db" => "shard")); return "shardoffline"; }catch (PDOException $e) { return "liboffline"; diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/configs/ingame_layout.ini b/code/ryzom/tools/server/ryzom_ams/ams_lib/configs/ingame_layout.ini new file mode 100644 index 000000000..e76cf2acf --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/configs/ingame_layout.ini @@ -0,0 +1,44 @@ +; This is the ingame layout config file +; Here you can easily change colors of specific elements in the ingame templates. + +;------------------------------------------------------------------------------- + +[basic] + +;second menu bar bg color +second_menu_bg_color = "#00000040" + +;title bg color +title_bg_color = "#303030" + +;default info text color +info_color = "#00CED1" + +;Account (user/admin/mod) name color +team_color = "red" +user_color = "green" +mod_color = "orange" +admin_color = "red" + +;main table bg color +main_tbl_color = "#00000030" + +;normal table bg color +normal_tbl_color = "#00000060" + +;table bg color for team replies +team_reply_tbl_color = "#F8C8C140" + +;table bg color for hidden replies +hidden_reply_tbl_color = "#CFFEFF40" + +;table bg color for closed reply +closed_tbl_color = "#FFE69960" + +;table header tr bg color +table_header_tr_color = "#00000090" + +;pagination current page bg +pagination_current_page_bg = "#00CED190" + +;------------------------------------------------------------------------------- \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/cron/mail_cron.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/cron/mail_cron.php new file mode 100644 index 000000000..9d669e866 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/cron/mail_cron.php @@ -0,0 +1,7 @@ +cron(); \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/createticket.tpl b/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/createticket.tpl new file mode 100644 index 000000000..dd19fd291 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/createticket.tpl @@ -0,0 +1,80 @@ +{block name=content} + + + + +{/block} + + diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/home.tpl b/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/home.tpl new file mode 100644 index 000000000..81ba9d934 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/home.tpl @@ -0,0 +1,55 @@ +{block name=content} + + + + + + + + + + +{/block} + diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/layout.tpl b/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/layout.tpl new file mode 100644 index 000000000..c98768e52 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/layout.tpl @@ -0,0 +1,34 @@ + + + + + Ryzom Account Management System + + + + + + +
+ + + + + + + + + +

Create a new ticket

+
+ + + + + + + + + + +
+ + +
+
+ + +
+ + +
+ + +
+
+ + + + + + + + + + + + + + + + +
Title: + +
Category: + +
Description:
+ + + +
+
+
+
+
+
+ +
+ + + + + + + + + +

{$home_title}

+
+ + + + + + + + + + +
+ + +
+
+ + +
+ + +
+ + +
+

{$home_info}

+
+
+
+
+ +
+ + {block name=content}{/block} + + + +
+ + + + + {block name=menu}{/block} + + + +
+
+ + + + + + diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/layout_admin.tpl b/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/layout_admin.tpl new file mode 100644 index 000000000..b3ce83d86 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/layout_admin.tpl @@ -0,0 +1,19 @@ +{extends file="layout.tpl"} +{block name=menu} +
Dashboard
+ +
Profile
+ +
Settings
+ + | + +
Users
+ +
Queues
+ +
Support Groups
+ + +{/block} + diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/layout_mod.tpl b/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/layout_mod.tpl new file mode 100644 index 000000000..34911226f --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/layout_mod.tpl @@ -0,0 +1,18 @@ +{extends file="layout.tpl"} +{block name=menu} +
Dashboard
+ +
Profile
+ +
Settings
+ + | + +
Users
+ +
Queues
+ +
Support Groups
+ +{/block} + diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/layout_user.tpl b/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/layout_user.tpl new file mode 100644 index 000000000..b876fa1c5 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/layout_user.tpl @@ -0,0 +1,24 @@ +{extends file="layout.tpl"} +{block name=menu} + +
  • Dashboard
  • +
  • Profile
  • +
  • Settings
  • + +
  • Create New Ticket
  • +
  • Logout
  • + + +
    Dashboard
    + +
    Profile
    + +
    Settings
    + + | + +
    Create New Ticket
    + + +{/block} + diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/login.tpl b/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/login.tpl new file mode 100644 index 000000000..ad6f48e0d --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/login.tpl @@ -0,0 +1,40 @@ +

     

    + +
    +
    +

    {$login_info}

    +
    +
    +
    +

    + Username: + +

    + + +

    + Password: + +

    + +

    + Remember me: +

    Remember me +

    + +

    + + +

    + +
    + + {if isset($login_error) and $login_error eq "TRUE"} +

    + {$login_error_message} +

    + {/if} +

    + {$login_register_message} {$login_register_message_here}! +

    +
    diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/register.tpl b/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/register.tpl index 17100d13d..03cb7c9d3 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/register.tpl +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/register.tpl @@ -6,7 +6,7 @@
    {$welcome_message}
    - +click hereeeee
    @@ -112,4 +112,4 @@ {$email_message} -
    \ No newline at end of file +
    diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/settings.tpl b/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/settings.tpl new file mode 100644 index 000000000..c8f67140c --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/settings.tpl @@ -0,0 +1,217 @@ +{block name=content} + + + + + + + + +
    + + + + +
    + + + + + {if isset($isAdmin) and $isAdmin eq 'TRUE' and $target_id neq 1} + {if $userPermission eq 1} + + + {else if $userPermission eq 2 } + + + {else if $userPermission eq 3 } + + + {/if} + {/if} + +
    Browse UserSend TicketMake ModeratorMake AdminDemote to UserMake AdminDemote to UserDemote to Moderator
    +
    +
    + + + + + + + + + + + + +

    Change Settings

    + + + + + + + + + + + + +
    + + +
    +
    + + + + +
    + + +
    + + +
    + +

    Change Password

    + + + + {if !isset($changesOther) or $changesOther eq "FALSE"} + + + +

    + + {/if} + + + +
    + Current Password: + + + {if isset($MATCH_ERROR) and $MATCH_ERROR eq "TRUE"}The password is incorrect{/if} +
    + New Password: + + + {if isset($NEWPASSWORD_ERROR) and $NEWPASSWORD_ERROR eq "TRUE"}{$newpass_error_message}{/if} +
    + Confirm New Password: + + + {if isset($CNEWPASSWORD_ERROR) and $CNEWPASSWORD_ERROR eq "TRUE"}{$confirmnewpass_error_message}{/if} +
    + {if isset($SUCCESS_PASS) and $SUCCESS_PASS eq "OK"} +

    + The password has been changed! +

    + {/if} + + + + + +

    + + + +
    +
    +
    + + +
    + + +
    +

    Change Email

    + +
    + + +
    + New Email: + + + {if isset($EMAIL_ERROR) and $EMAIL_ERROR eq "TRUE"}{$EMAIL}{/if} +
    + {if isset($SUCCESS_MAIL) and $SUCCESS_MAIL eq "OK"} +

    + The email has been changed! +

    + {/if} + + + +

    + +

    + +
    +
    +
    + + +
    + + +
    +

    Change Info

    +
    + + + + + + + + + + + + + + + + + + + + +
    Firstname:
    Lastname:
    Country:
    Gender +
    + {if isset($info_updated) and $info_updated eq "OK"} +

    + The Info has been updated! +

    + {/if} + + + + +

    + +

    +
    + +
    +
    +
    +
    + + + +{/block} + diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/sgroup_list.tpl b/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/sgroup_list.tpl new file mode 100644 index 000000000..6279d8fe4 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/sgroup_list.tpl @@ -0,0 +1,114 @@ +{block name=content} + + + + + + + + + + + +

    Support Groups

    + + + + + + + + + + + + +
    + + +
    +
    + + {if isset($isAdmin) && $isAdmin eq 'TRUE'} + + {/if} + +
    + + +
    + + +
    +

    Add a Support group

    + +
    + + + + + + + + + + +
    Group name:
    Group Tag:
    + +

    + + + {if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "SUCCESS"} +

    + {$group_success} +

    + {else if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "NAME_TAKEN"} +

    + {$group_name_taken} +

    + {else if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "TAG_TAKEN"} +

    + {$group_tag_taken} +

    + {else if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "SIZE_ERROR"} +

    + {$group_size_error} +

    + {/if} +
    +
    +
    +
    + + +
    + + +
    +

    All groups

    + + + + + + {if isset($isAdmin) && $isAdmin eq 'TRUE'}{/if} + + + {foreach from=$grouplist item=group} + + + + + {if isset($isAdmin) && $isAdmin eq 'TRUE'}{/if} + + {/foreach} +
    IDNameTagAction
    {$group.sGroupId}{$group.name}{$group.tag}Delete
    +
    +
    +
    +
    + + + +{/block} + diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/show_queue.tpl b/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/show_queue.tpl new file mode 100644 index 000000000..eeda5813e --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/show_queue.tpl @@ -0,0 +1,222 @@ +{block name=content} + + + + + + + + +
    + + + + +
    + + + + + + + + +
    Todo ticketsAll ticketsAll open ticketsTicket ArchiveNot Assigned Tickets
    +
    +
    + + + + + + + + + + + + +

    Ticket Queue: {$queue_view}

    + + + + + + + + + + + + +{/block} + diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/show_reply.tpl b/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/show_reply.tpl new file mode 100644 index 000000000..b6aa90cb2 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/show_reply.tpl @@ -0,0 +1,88 @@ +{block name=content} + + + + +{/block} + + diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/show_sgroup.tpl b/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/show_sgroup.tpl new file mode 100644 index 000000000..388cf8e32 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/show_sgroup.tpl @@ -0,0 +1,113 @@ +{block name=content} + + + + +{/block} + diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/show_ticket.tpl b/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/show_ticket.tpl new file mode 100644 index 000000000..5058a5776 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/show_ticket.tpl @@ -0,0 +1,284 @@ +{block name=content} + + + + + +{/block} + diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/show_ticket_log.tpl b/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/show_ticket_log.tpl new file mode 100644 index 000000000..57dff23b6 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/show_ticket_log.tpl @@ -0,0 +1,88 @@ +{block name=content} + + + + +{/block} + \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/show_user.tpl b/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/show_user.tpl new file mode 100644 index 000000000..93110b895 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/show_user.tpl @@ -0,0 +1,163 @@ +{block name=content} + + + + + +{/block} + diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/userlist.tpl b/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/userlist.tpl new file mode 100644 index 000000000..4e5f2a4ae --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/userlist.tpl @@ -0,0 +1,96 @@ +{block name=content} + + + +{/block} + diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/libinclude.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/libinclude.php index 0d8606488..e5deb6030 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/libinclude.php +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/libinclude.php @@ -3,6 +3,10 @@ // Base include file for library functions for AMS // *********************************************** function __autoload( $className ){ - require_once 'autoload/' . strtolower ( $className ) . '.php'; + if(file_exists( '/home/daan/ryzom/ryzomcore/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/' . strtolower ( $className ) . '.php')){ + require_once 'autoload/' . strtolower ( $className ) . '.php'; + } + if($className == "WebUsers") + require_once '/home/daan/ryzom/ryzomcore/code/ryzom/tools/server/ryzom_ams/www/html/autoload/' . strtolower ( $className ) . '.php'; } diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/en.ini b/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/en.ini index 858c3020f..90619bcfc 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/en.ini +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/en.ini @@ -7,10 +7,10 @@ home_info = "Welcome to the Ryzom Core - Account Management System" [settings] -[libuserlist] -libuserlist_title = "LibDB-Query List" -libuserlist_info = "Here you can see the entire list of elements in the LibDB-Query table. You can easily remove elements and by pressing 'Synchronize' you can start the syncing process manually!" -libuserlist_sync = "Synchronize" +[syncing] +syncing_title = "LibDB-Query List" +syncing_info = "Here you can see the entire list of elements in the LibDB-Query table. You can easily remove elements and by pressing 'Synchronize' you can start the syncing process manually!" +syncing_sync = "Synchronize" shard_online = "The shard seems to be online, manually syncing is possible: " shard_offline = "The shard seems to be offline, manually syncing is not possible!" members = "Members" @@ -20,10 +20,63 @@ name = "Name" email = "Email" action = "Action" +[show_ticket] +t_title = "Ticket" +title = "Title" +t_reply = "Reply on ticket" +t_fill = "Fill in your reply" +t_send = "Send reply" +invalid_sgroup = "Invalid support group!" +ticket_not_existing = "That's an invalid ticket" +success_forwarded = "The ticket was forwarded successfully!" +public_sgroup = "Public" +not_assigned = "None" +success_assigned = "The ticket was successfully assigned!" +success_unassigned = "The ticket was successfully unassigned!" +ticket_not_existing = "That ticket doesn't exist!" +ticket_already_assigned = "That ticket is already assigned to someone!" + [show_user] +[show_queue] +not_assigned = "Open" +success_assigned = "The ticket was successfully assigned!" +success_unassigned = "The ticket was successfully unassigned!" +ticket_not_existing = "That ticket doesn't exist!" +ticket_already_assigned = "That ticket is already assigned to someone!" +ticket_not_assigned = "That ticket isn't assigned to you!" +public_sgroup = "Public" + +[show_sgroup] +add_to_group_success = "The user has been added to the group!" +user_already_added = "The user is already part of the group!" +group_not_existing = "The group doesn't exist!" +user_not_existing = "The user doesn't seem to exist" +not_mod_or_admin = "You can only add Moderators or Admins!" + +[sgroup_list] +group_success = "The group has been created!" +group_name_taken = "The groupname was already used!" +group_tag_taken = "The tag was already used!" +group_size_error = "The name has to be between 4-20 chars and the tag between 2-4!" + [createticket] +[show_ticket_log] + +[show_reply] + +[ticket_log] +1 = "created the ticket" +2 = "created the ticket for" +3 = "read the ticket" +4 = "added reply" +5 = "changed the status to" +6 = "changed the priority to" +7 = "assigned to the ticket" +8 = "forwarded the ticket to the support group: " +9 = "unassigned from the ticket" + [error] title404 = "Not
    Found!" title403 = "Forbidden!" diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/fr.ini b/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/fr.ini index 150a62c6b..9127fd0a3 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/fr.ini +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/fr.ini @@ -7,10 +7,10 @@ home_info = "Bienvenue sur le Ryzom Core - Account Management System" [settings] -[libuserlist] -libuserlist_title = "LibDB-Query Liste" -libuserlist_info = "Ici vous pouvez voir la liste complete des elements dans le tableau libdb-Query. Vous pouvez facilement supprimer des elements et appuyant sur 'Synchroniser', vous pouvez commencer le processus de synchronisation manuellement!" -libuserlist_sync = "Synchroniser" +[syncing] +syncing_title = "LibDB-Query Liste" +syncing_info = "Ici vous pouvez voir la liste complete des elements dans le tableau libdb-Query. Vous pouvez facilement supprimer des elements et appuyant sur 'Synchroniser', vous pouvez commencer le processus de synchronisation manuellement!" +syncing_sync = "Synchroniser" shard_online = "Le shard semble etre ligne , la synchronisation manuellement est possible: " shard_offline = "Le shard semble etre deconnecte , la synchronisation manuellement n' est pas possible!" members = "Membres" @@ -20,10 +20,59 @@ name = "Nom" email = "Email" action = "Action" -[createticket] +[show_ticket] +t_title = "Billet" +title = "Titre" +t_reply = "Repondre a billet" +t_fill = "Remplissez votre reponse" +t_send = "Envoyer la reponse" +invalid_sgroup = "Invalide support group!" +ticket_not_existing = "c'est un billet invalide" +success_forwarded = "ce billet est renvoyee bien!" +public_sgroup = "Publique" +not_assigned = "Ne rien" [show_user] +[show_queue] +not_assigned = "Libre" +success_assigned = "Ce billet est succesfull assignee!" +success_unassigned = "Ce billet est succesful unassignee!" +ticket_not_existing = "ce billet n'existe pas!" +ticket_already_assigned = "Ce billet est deja assigne a quelqu'un autre" +ticket_not_assigned = "Ce billet n'est assigne pas" +public_sgroup = "Publique" + +[show_sgroup] +add_to_group_success = "ce user est ajoute sur la groupe!" +user_already_added = "cet user est deja membre de la groupe!" +group_not_existing = "cet Groupe n' existe pas!" +user_not_existing = "cet user n'existe pas" +not_mod_or_admin = "C'est possible d'ajoute seulement des mods et admins!" + +[sgroup_list] +group_success = "le group est cree!" +group_name_taken = "le nom pour le group est deja utilise!" +group_tag_taken = "le tag pour le group est deja utilise!" +group_size_error = "le nom doit etre 4-20 chars et le tag 2-4!" + +[createticket] + +[show_reply] + +[show_ticket_log] + +[ticket_log] +1 = "a cree le billet" +2 = "a cree le billet pour" +3 = "a lire le billet" +4 = "a ajoute le reponse" +5 = "change le status a" +6 = "change le priorite a" +7 = "assigne ce billet a ce meme" +8 = "a eenvoyee ce ticket a la groupe de support:" + + [error] title404 = "Pas
    trouvez!" title403 = "Interdit!" diff --git a/code/ryzom/tools/server/ryzom_ams/assets/android_app/Ryzom_Core_AMS.7z b/code/ryzom/tools/server/ryzom_ams/assets/android_app/Ryzom_Core_AMS.7z new file mode 100644 index 000000000..ed9366564 Binary files /dev/null and b/code/ryzom/tools/server/ryzom_ams/assets/android_app/Ryzom_Core_AMS.7z differ diff --git a/code/ryzom/tools/server/ryzom_ams/assets/android_app/info.txt b/code/ryzom/tools/server/ryzom_ams/assets/android_app/info.txt new file mode 100644 index 000000000..ef44bdf75 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/assets/android_app/info.txt @@ -0,0 +1 @@ +Info: Android Application Made by Matthew Lagoe for browsing the AMS on your android device! diff --git a/code/ryzom/tools/server/ryzom_ams/www/config.php b/code/ryzom/tools/server/ryzom_ams/www/config.php index d68ac18de..82c010e58 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/config.php +++ b/code/ryzom/tools/server/ryzom_ams/www/config.php @@ -10,13 +10,13 @@ $cfg['db']['web']['host'] = 'localhost'; $cfg['db']['web']['port'] = '3306'; $cfg['db']['web']['name'] = 'ryzom_ams'; -$cfg['db']['web']['user'] = 'root'; +$cfg['db']['web']['user'] = 'shard'; $cfg['db']['web']['pass'] = ''; $cfg['db']['lib']['host'] = 'localhost'; $cfg['db']['lib']['port'] = '3306'; $cfg['db']['lib']['name'] = 'ryzom_ams_lib'; -$cfg['db']['lib']['user'] = 'root'; +$cfg['db']['lib']['user'] = 'shard'; $cfg['db']['lib']['pass'] = ''; $cfg['db']['shard']['host'] = 'localhost'; @@ -25,6 +25,27 @@ $cfg['db']['shard']['name'] = 'nel'; $cfg['db']['shard']['user'] = 'shard'; $cfg['db']['shard']['pass'] = ''; +$cfg['db']['ring']['host'] = 'localhost'; +$cfg['db']['ring']['port'] = '3306'; +$cfg['db']['ring']['name'] = 'ring_open'; +$cfg['db']['ring']['user'] = 'shard'; +$cfg['db']['ring']['pass'] = ''; + +$cfg['mail']['username'] = 'amsryzom@gmail.com'; +$cfg['mail']['password'] = 'lol123bol'; +$cfg['mail']['host'] = 'ryzomcore.com'; + +// To connect to an IMAP server running on port 143 on the local machine, +// do the following: $mbox = imap_open("{localhost:143}INBOX", "user_id", "password"); +// POP3 server on port 110: $mbox = imap_open ("{localhost:110/pop3}INBOX", "user_id", "password"); +// SSL IMAP or POP3 server, add /ssl after the protocol: $mbox = imap_open ("{localhost:993/imap/ssl}INBOX", "user_id", "password"); +// To connect to an SSL IMAP or POP3 server with a self-signed certificate, +// add /ssl/novalidate-cert after the protocol specification: +// $mbox = imap_open ("{localhost:995/pop3/ssl/novalidate-cert}", "user_id", "password"); +// NNTP server on port 119 use: $nntp = imap_open ("{localhost:119/nntp}comp.test", "", ""); +// To connect to a remote server replace "localhost" with the name or the IP address of the server you want to connect to. +//$cfg['mail']['server'] = '{localhost:110/pop3/novalidate-cert}INBOX'; +$cfg['mail']['server']= '{imap.gmail.com:993/imap/ssl}INBOX'; //----------------------------------------------------------------------------------------- // If true= the server will add automatically unknown user in the database // (in nel.user= nel.permission= ring.ring_user and ring.characters @@ -40,3 +61,9 @@ $AMS_CACHEDIR = $AMS_LIB . '/cache'; $DEFAULT_LANGUAGE = 'en'; $SITEBASE = dirname( __FILE__ ) . '/html/' ; + +$TICKET_LOGGING = true; +$TICKET_MAILING_SUPPORT = true; +$TIME_FORMAT = "m-d-Y H:i:s"; +$INGAME_LAYOUT = "basic"; +$MAIL_DIR = "/tmp"; diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/autoload/webusers.php b/code/ryzom/tools/server/ryzom_ams/www/html/autoload/webusers.php index 6c22c57f8..014864e2a 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/autoload/webusers.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/autoload/webusers.php @@ -1,6 +1,28 @@ uId = $UId; + } + + public function set($values){ + $this->uId = $values['UId']; + $this->login = $values['Login']; + $this->email = $values['Email']; + $this->firstname = $values['FirstName']; + $this->lastname = $values['LastName']; + $this->gender = $values['Gender']; + $this->country = $values['Country']; + } /** * Function checkUserNameExists @@ -9,8 +31,7 @@ class WebUsers extends Users{ * @return string Info: Returns true or false if the user is in the web db. */ protected function checkUserNameExists($username){ - global $cfg; - $dbw = new DBLayer($cfg['db']['web']); + $dbw = new DBLayer("web"); return $dbw->execute("SELECT * FROM ams_user WHERE Login = :name",array('name' => $username))->rowCount(); } @@ -22,8 +43,7 @@ class WebUsers extends Users{ * @return string Info: Returns true or false if the user is in the www db. */ protected function checkEmailExists($email){ - global $cfg; - $dbw = new DBLayer($cfg['db']['web']); + $dbw = new DBLayer("web"); return $dbw->execute("SELECT * FROM ams_user WHERE Email = :email",array('email' => $email))->rowCount(); } @@ -35,9 +55,7 @@ class WebUsers extends Users{ * @return string Info: Returns true or false if a login match is found in the web db */ public function checkLoginMatch($username,$password){ - global $cfg; - - $dbw = new DBLayer($cfg['db']['web']); + $dbw = new DBLayer("web"); $statement = $dbw->execute("SELECT * FROM ams_user WHERE Login=:user", array('user' => $username)); $row = $statement->fetch(); @@ -49,42 +67,57 @@ class WebUsers extends Users{ return "fail"; } } - - public function getId($username){ - global $cfg; - - $dbw = new DBLayer($cfg['db']['web']); - $statement = $dbw->execute("SELECT * FROM ams_user WHERE Login=:username", array('username' => $username)); - $row = $statement->fetch(); - return $row['UId']; + + //returns te id for a given username + public static function getId($username){ + $dbw = new DBLayer("web"); + $statement = $dbw->execute("SELECT * FROM ams_user WHERE Login=:username", array('username' => $username)); + $row = $statement->fetch(); + return $row['UId']; + } + + //returns te id for a given username + public static function getIdFromEmail($email){ + $dbw = new DBLayer("web"); + $statement = $dbw->execute("SELECT * FROM ams_user WHERE Email=:email", array('email' => $email)); + $row = $statement->fetch(); + return $row['UId']; + } + + public function getUId(){ + return $this->uId; + } + + public function getUsername(){ + $dbw = new DBLayer("web"); + if(! isset($this->login) || $this->login == ""){ + $statement = $dbw->execute("SELECT * FROM ams_user WHERE UId=:id", array('id' => $this->uId)); + $row = $statement->fetch(); + $this->set($row); + } + return $this->login; } - public function getUsername($id){ - global $cfg; - - $dbw = new DBLayer($cfg['db']['web']); - $statement = $dbw->execute("SELECT * FROM ams_user WHERE UId=:id", array('id' => $id)); - $row = $statement->fetch(); - return $row['Login']; + public function getEmail(){ + $dbw = new DBLayer("web"); + if(! isset($this->email) || $this->email == ""){ + $statement = $dbw->execute("SELECT * FROM ams_user WHERE UId=:id", array('id' => $this->uId)); + $row = $statement->fetch(); + $this->set($row); + } + return $this->email; } - public function getEmail($id){ - global $cfg; - - $dbw = new DBLayer($cfg['db']['web']); - $statement = $dbw->execute("SELECT * FROM ams_user WHERE UId=:id", array('id' => $id)); - $row = $statement->fetch(); - return $row['Email']; - } - - public function getInfo($id){ - global $cfg; - - $dbw = new DBLayer($cfg['db']['web']); - $statement = $dbw->execute("SELECT * FROM ams_user WHERE UId=:id", array('id' => $id)); - $row = $statement->fetch(); - $result = Array('FirstName' => $row['FirstName'], 'LastName' => $row['LastName'], 'Gender' => $row['Gender'], 'Country' => $row['Country']); - return $result; + public function getInfo(){ + $dbw = new DBLayer("web"); + if(! (isset($this->firstname) && isset($this->lastname) && isset($this->gender) && isset($this->country) ) || + $this->firstname == "" || $this->lastname == "" || $this->gender == "" || $this->country == ""){ + $statement = $dbw->execute("SELECT * FROM ams_user WHERE UId=:id", array('id' => $this->uId)); + $row = $statement->fetch(); + $this->set($row); + } + $result = Array('FirstName' => $this->firstname, 'LastName' => $this->lastname, 'Gender' => $this->gender, 'Country' => $this->country); + return $result; } public function isLoggedIn(){ @@ -94,20 +127,12 @@ class WebUsers extends Users{ return false; } - public function isAdmin(){ - if(isset($_SESSION['permission']) && $_SESSION['permission'] == 2){ - return true; - } - return false; - } - public function setPassword($user, $pass){ - global $cfg; $reply = WebUsers::setAmsPassword($user, $pass); $values = Array('user' => $user, 'pass' => $pass); try { //make connection with and put into shard db - $dbw = new DBLayer($cfg['db']['web']); + $dbw = new DBLayer("web"); $dbw->execute("UPDATE ams_user SET Password = :pass WHERE Login = :user ",$values); } catch (PDOException $e) { @@ -117,12 +142,11 @@ class WebUsers extends Users{ } public function setEmail($user, $mail){ - global $cfg; $reply = WebUsers::setAmsEmail($user, $mail); $values = Array('user' => $user, 'mail' => $mail); try { //make connection with and put into shard db - $dbw = new DBLayer($cfg['db']['web']); + $dbw = new DBLayer("web"); $dbw->execute("UPDATE ams_user SET Email = :mail WHERE Login = :user ",$values); } catch (PDOException $e) { @@ -132,9 +156,13 @@ class WebUsers extends Users{ } public function getUsers(){ - global $cfg; - $dbl = new DBLayer($cfg['db']['web']); + $dbl = new DBLayer("web"); $data = $dbl->executeWithoutParams("SELECT * FROM ams_user"); return $data; } + + public static function getAllUsersQuery(){ + return "SELECT * FROM ams_user"; + } + } \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/func/add_sgroup.php b/code/ryzom/tools/server/ryzom_ams/www/html/func/add_sgroup.php new file mode 100644 index 000000000..9fc59d917 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/www/html/func/add_sgroup.php @@ -0,0 +1,34 @@ +getPermission(); + $result['no_visible_elements'] = 'FALSE'; + $result['username'] = $_SESSION['user']; + global $SITEBASE; + require_once($SITEBASE . 'inc/sgroup_list.php'); + $result= array_merge($result, sgroup_list()); + helpers :: loadtemplate( 'sgroup_list', $result); + exit; + + }else{ + //ERROR: No access! + $_SESSION['error_code'] = "403"; + header("Location: index.php?page=error"); + exit; + } + }else{ + //ERROR: not logged in! + header("Location: index.php"); + exit; + } + +} \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/func/add_user.php b/code/ryzom/tools/server/ryzom_ams/www/html/func/add_user.php index e21e32d6a..7e81b2751 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/func/add_user.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/func/add_user.php @@ -3,7 +3,7 @@ function add_user(){ $params = Array('Username' => $_POST["Username"], 'Password' => $_POST["Password"], 'ConfirmPass' => $_POST["ConfirmPass"], 'Email' => $_POST["Email"]); - $webUser = new WebUsers; + $webUser = new WebUsers(); $result = $webUser->check_Register($params); // if all are good then create user @@ -47,9 +47,8 @@ function write_user($newUser){ ); try{ - global $cfg; //make connection with web db and put it in there - $dbw = new DBLayer($cfg['db']['web']); + $dbw = new DBLayer("web"); $user_id = $dbw->executeReturnId("INSERT INTO ams_user (Login, Password, Email) VALUES (:name, :pass, :mail)",$params); //Create the user on the shard + in case shard is offline put copy of query in query db diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/func/add_user_to_sgroup.php b/code/ryzom/tools/server/ryzom_ams/www/html/func/add_user_to_sgroup.php new file mode 100644 index 000000000..3eb79b928 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/www/html/func/add_user_to_sgroup.php @@ -0,0 +1,42 @@ +getPermission()>1){ + $result['RESULT_OF_ADDING'] = Support_Group::addUserToSupportGroup($user_id, $id); + }else{ + $result['RESULT_OF_ADDING'] = "NOT_MOD_OR_ADMIN"; + } + + }else{ + $result['RESULT_OF_ADDING'] = "USER_NOT_EXISTING"; + } + $result['permission'] = $_SESSION['ticket_user']->getPermission(); + $result['no_visible_elements'] = 'FALSE'; + $result['username'] = $_SESSION['user']; + global $SITEBASE; + require_once($SITEBASE . 'inc/show_sgroup.php'); + $result= array_merge($result, show_sgroup()); + helpers :: loadtemplate( 'show_sgroup', $result); + exit; + + }else{ + //ERROR: No access! + $_SESSION['error_code'] = "403"; + header("Location: index.php?page=error"); + exit; + } + }else{ + //ERROR: not logged in! + header("Location: index.php"); + exit; + } + +} \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/func/change_info.php b/code/ryzom/tools/server/ryzom_ams/www/html/func/change_info.php index baf28afc2..311935e9c 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/func/change_info.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/func/change_info.php @@ -9,16 +9,17 @@ function change_info(){ if(isset($_POST['target_id'])){ - if( ($_POST['target_id'] == $_SESSION['id']) || WebUsers::isAdmin() ){ + if( ($_POST['target_id'] == $_SESSION['id']) || Ticket_User::isMod($_SESSION['ticket_user'] ) ){ if($_POST['target_id'] == $_SESSION['id']){ $target_username = $_SESSION['user']; }else{ - $target_username = WebUsers::getUsername($_POST['target_id']); + $webUser = new WebUsers($_POST['target_id']); + $target_username = $webUser->getUsername(); } - $webUser = new WebUsers(); + $webUser = new WebUsers($_POST['target_id']); //use current info to check for changes - $current_info = $webUser->getInfo($_POST['target_id']); + $current_info = $webUser->getInfo(); $current_info['FirstName'] = filter_var($current_info['FirstName'], FILTER_SANITIZE_STRING); @@ -70,9 +71,8 @@ function change_info(){ //if some field is update then: if($updated){ - global $cfg; //execute the query in the web DB. - $dbw = new DBLayer($cfg['db']['web']); + $dbw = new DBLayer("web"); $dbw->execute($query,$values); } @@ -82,7 +82,7 @@ function change_info(){ if($updated){ $result['info_updated'] = "OK"; } - $result['permission'] = $_SESSION['permission']; + $result['permission'] = $_SESSION['ticket_user']->getPermission(); $result['username'] = $_SESSION['user']; $result['no_visible_elements'] = 'FALSE'; $result['target_id'] = $_POST['target_id']; diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/func/change_mail.php b/code/ryzom/tools/server/ryzom_ams/www/html/func/change_mail.php index 6905febae..ac24fa5b0 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/func/change_mail.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/func/change_mail.php @@ -9,14 +9,15 @@ function change_mail(){ if(isset($_POST['target_id'])){ - if( ($_POST['target_id'] == $_SESSION['id']) || WebUsers::isAdmin() ){ + if( ($_POST['target_id'] == $_SESSION['id']) || Ticket_User::isMod($_SESSION['ticket_user']) ){ if($_POST['target_id'] == $_SESSION['id']){ $target_username = $_SESSION['user']; }else{ - $target_username = WebUsers::getUsername($_POST['target_id']); + $webUser = new WebUsers($_POST['target_id']); + $target_username = $webUser->getUsername(); } - $webUser = new WebUsers(); + $webUser = new WebUsers($_POST['target_id']); $reply = $webUser->checkEmail($_POST['NewEmail']); global $SITEBASE; @@ -37,13 +38,13 @@ function change_mail(){ }else if($status == 'shardoffline'){ $result['SUCCESS_MAIL'] = "SHARDOFF"; } - $result['permission'] = $_SESSION['permission']; + $result['permission'] = $_SESSION['ticket_user']->getPermission(); $result['no_visible_elements'] = 'FALSE'; $result['username'] = $_SESSION['user']; $result['target_id'] = $_POST['target_id']; if(isset($_GET['id'])){ - if(WebUsers::isAdmin() && ($_POST['target_id'] != $_SESSION['id'])){ - $result['isAdmin'] = "TRUE"; + if(Ticket_User::isMod($_SESSION['ticket_user']) && ($_POST['target_id'] != $_SESSION['id'])){ + $result['isMod'] = "TRUE"; } } helpers :: loadtemplate( 'settings', $result); @@ -51,13 +52,13 @@ function change_mail(){ }else{ $result['EMAIL'] = $reply; - $result['permission'] = $_SESSION['permission']; + $result['permission'] = $_SESSION['ticket_user']->getPermission(); $result['no_visible_elements'] = 'FALSE'; $result['username'] = $_SESSION['user']; $result['target_id'] = $_POST['target_id']; if(isset($_GET['id'])){ - if(WebUsers::isAdmin() && ($_POST['target_id'] != $_SESSION['id'])){ - $result['isAdmin'] = "TRUE"; + if(Ticket_User::isMod($_SESSION['ticket_user']) && ($_POST['target_id'] != $_SESSION['id'])){ + $result['isMod'] = "TRUE"; } } helpers :: loadtemplate( 'settings', $result); diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/func/change_password.php b/code/ryzom/tools/server/ryzom_ams/www/html/func/change_password.php index 57e675123..b3971202d 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/func/change_password.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/func/change_password.php @@ -9,17 +9,18 @@ function change_password(){ if(isset($_POST['target_id'])){ $adminChangesOther = false; //if target_id is the same as session id or is admin - if( ($_POST['target_id'] == $_SESSION['id']) || WebUsers::isAdmin() ){ + if( ($_POST['target_id'] == $_SESSION['id']) || Ticket_User::isMod($_SESSION['ticket_user']) ){ if($_POST['target_id'] == $_SESSION['id']){ $target_username = $_SESSION['user']; }else{ - $target_username = WebUsers::getUsername($_POST['target_id']); + $webUser = new WebUsers($_POST['target_id']); + $target_username = $webUser->getUsername(); //isAdmin is true when it's the admin, but the target_id != own id $adminChangesOther = true; $_POST["CurrentPass"] = "dummypass"; } - $webUser = new WebUsers(); + $webUser = new WebUsers($_POST['target_id']); $params = Array( 'user' => $target_username, 'CurrentPass' => $_POST["CurrentPass"], 'NewPass' => $_POST["NewPass"], 'ConfirmNewPass' => $_POST["ConfirmNewPass"], 'adminChangesOther' => $adminChangesOther); $result = $webUser->check_change_password($params); if ($result == "success"){ @@ -34,7 +35,7 @@ function change_password(){ }else if($status == 'shardoffline'){ $succresult['SUCCESS_PASS'] = "SHARDOFF"; } - $succresult['permission'] = $_SESSION['permission']; + $succresult['permission'] = $_SESSION['ticket_user']->getPermission(); $succresult['no_visible_elements'] = 'FALSE'; $succresult['username'] = $_SESSION['user']; $succresult['target_id'] = $_POST['target_id']; @@ -46,7 +47,7 @@ function change_password(){ $result['prevCurrentPass'] = filter_var($_POST["CurrentPass"], FILTER_SANITIZE_STRING); $result['prevNewPass'] = filter_var($_POST["NewPass"], FILTER_SANITIZE_STRING); $result['prevConfirmNewPass'] = filter_var($_POST["ConfirmNewPass"], FILTER_SANITIZE_STRING); - $result['permission'] = $_SESSION['permission']; + $result['permission'] = $_SESSION['ticket_user']->getPermission(); $result['no_visible_elements'] = 'FALSE'; $result['username'] = $_SESSION['user']; $result['target_id'] = $_POST['target_id']; diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/func/create_ticket.php b/code/ryzom/tools/server/ryzom_ams/www/html/func/create_ticket.php index 8f8010889..af51c6969 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/func/create_ticket.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/func/create_ticket.php @@ -7,9 +7,8 @@ function create_ticket(){ if(isset($_POST['target_id'])){ //if target_id is the same as session id or is admin - if( ($_POST['target_id'] == $_SESSION['id']) || WebUsers::isAdmin() ){ + if( ($_POST['target_id'] == $_SESSION['id']) || Ticket_User::isMod($_SESSION['ticket_user']) ){ - global $cfg; $category = filter_var($_POST['Category'], FILTER_SANITIZE_NUMBER_INT); $title = filter_var($_POST['Title'], FILTER_SANITIZE_STRING); $content = filter_var($_POST['Content'], FILTER_SANITIZE_STRING); @@ -17,11 +16,16 @@ function create_ticket(){ if($_POST['target_id'] == $_SESSION['id']){ $author = $_SESSION['ticket_user']->getTUserId(); }else{ - $author= Ticket_User::constr_ExternId($_POST['target_id'], $cfg['db']['lib'])->getTUserId(); + $author= Ticket_User::constr_ExternId($_POST['target_id'])->getTUserId(); } - Ticket::create_Ticket($title, $content, $category, $author, $cfg['db']['lib'] ); + $ticket_id = Ticket::create_Ticket($title, $content, $category, $author, $_SESSION['ticket_user']->getTUserId()); + header("Location: index.php?page=show_ticket&id=".$ticket_id); + exit; + }catch (PDOException $e) { //ERROR: LIB DB is not online! + print_r($e); + exit; header("Location: index.php"); exit; } @@ -35,7 +39,7 @@ function create_ticket(){ }else{ //ERROR: The form was not filled in correclty - header("Location: index.php?page=settings"); + header("Location: index.php?page=create_ticket"); exit; } }else{ diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/func/login.php b/code/ryzom/tools/server/ryzom_ams/www/html/func/login.php index eb9be221f..49ef2a435 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/func/login.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/func/login.php @@ -2,16 +2,15 @@ function login(){ - global $cfg; - try{ - $result = WebUsers::checkLoginMatch($_POST["Username"],$_POST["Password"]); + $username = filter_var($_POST['Username'],FILTER_SANITIZE_STRING); + $password = filter_var($_POST['Password'],FILTER_SANITIZE_STRING); + $result = WebUsers::checkLoginMatch($username, $password); if( $result != "fail"){ //handle successful login - $_SESSION['user'] = $_POST["Username"]; - $_SESSION['permission'] = $result['Permission']; + $_SESSION['user'] = $username; $_SESSION['id'] = $result['UId']; - $_SESSION['ticket_user'] = Ticket_User::constr_ExternId($result['UId'],$cfg['db']['lib']); + $_SESSION['ticket_user'] = Ticket_User::constr_ExternId($result['UId']); //go back to the index page. header( 'Location: index.php' ); diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/func/reply_on_ticket.php b/code/ryzom/tools/server/ryzom_ams/www/html/func/reply_on_ticket.php new file mode 100644 index 000000000..76f8ee71e --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/www/html/func/reply_on_ticket.php @@ -0,0 +1,51 @@ +load_With_TId($ticket_id); + + if(($target_ticket->getAuthor() == $_SESSION['ticket_user']->getTUserId()) || Ticket_User::isMod($_SESSION['ticket_user']) ){ + + try{ + $author = $_SESSION['ticket_user']->getTUserId(); + + $content = $_POST['Content']; + $hidden = 0; + if(isset($_POST['hidden']) && Ticket_User::isMod($_SESSION['ticket_user'])){ + $hidden = 1; + } + Ticket::createReply($content, $author, $ticket_id, $hidden); + + if(isset($_POST['ChangeStatus']) && isset($_POST['ChangePriority']) && Ticket_User::isMod($_SESSION['ticket_user'])){ + $newStatus = filter_var($_POST['ChangeStatus'], FILTER_SANITIZE_NUMBER_INT); + $newPriority = filter_var($_POST['ChangePriority'], FILTER_SANITIZE_NUMBER_INT); + Ticket::updateTicketStatusAndPriority($ticket_id,$newStatus, $newPriority, $author); + } + header("Location: index.php?page=show_ticket&id=".$ticket_id); + exit; + + }catch (PDOException $e) { + //ERROR: LIB DB is not online! + print_r($e); + //header("Location: index.php"); + exit; + } + + }else{ + //ERROR: No access! + $_SESSION['error_code'] = "403"; + header("Location: index.php?page=error"); + exit; + } + }else{ + //ERROR: not logged in! + header("Location: index.php"); + exit; + } + +} \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/img/ryzomcore_166_62.png b/code/ryzom/tools/server/ryzom_ams/www/html/img/ryzomcore_166_62.png new file mode 100644 index 000000000..d210203d9 Binary files /dev/null and b/code/ryzom/tools/server/ryzom_ams/www/html/img/ryzomcore_166_62.png differ diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/inc/change_permission.php b/code/ryzom/tools/server/ryzom_ams/www/html/inc/change_permission.php new file mode 100644 index 000000000..084aa3923 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/www/html/inc/change_permission.php @@ -0,0 +1,40 @@ +getTUserId(), $value); + header("Location: index.php?page=show_user&id=".$user_id); + exit; + + + }else{ + //ERROR: GET PARAMS not given or trying to change admin + header("Location: index.php?page=show_user&id=".$user_id); + exit; + } + + }else{ + //ERROR: No access! + $_SESSION['error_code'] = "403"; + header("Location: index.php?page=error"); + exit; + + } + + }else{ + //ERROR: not logged in! + header("Location: index.php"); + exit; + } + + +} \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/inc/createticket.php b/code/ryzom/tools/server/ryzom_ams/www/html/inc/createticket.php index 4647bbfaf..4c3dce7b8 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/inc/createticket.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/inc/createticket.php @@ -7,7 +7,7 @@ function createticket(){ //in case user_id-GET param set it's value as target_id, if no user_id-param is given, use the session id. if(isset($_GET['user_id'])){ - if(($_GET['user_id'] != $_SESSION['id']) && (!WebUsers::isAdmin()) ){ + if(($_GET['user_id'] != $_SESSION['id']) && ( ! ticket_user::isMod($_SESSION['ticket_user'])) ){ //ERROR: No access! $_SESSION['error_code'] = "403"; @@ -27,13 +27,8 @@ function createticket(){ } //create array of category id & names - global $cfg; - $catArray = Ticket_Category::getAllCategories($cfg['db']['lib']); - $result['category'] = Array(); - foreach($catArray as $catObj){ - $result['category'][$catObj->getTCategoryId()] = $catObj->getName(); - } - + $catArray = Ticket_Category::getAllCategories(); + $result['category'] = Gui_Elements::make_table_with_key_is_id($catArray, Array("getName"), "getTCategoryId" ); return $result; }else{ diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/inc/libuserlist.php b/code/ryzom/tools/server/ryzom_ams/www/html/inc/libuserlist.php deleted file mode 100644 index f7351e4d5..000000000 --- a/code/ryzom/tools/server/ryzom_ams/www/html/inc/libuserlist.php +++ /dev/null @@ -1,68 +0,0 @@ -executeWithoutParams("SELECT * FROM ams_querycache")->rowCount(); - - //the array hat will contain all users - $pageResult['liblist'] = Array(); - if($rows > 0){ - //This is the number of results displayed per page - $page_rows = 2; - - //This tells us the page number of our last page - $last = ceil($rows/$page_rows); - - //this makes sure the page number isn't below one, or more than our maximum pages - if ($pagenum < 1) - { - $pagenum = 1; - }else if ($pagenum > $last) { - $pagenum = $last; - } - - //This sets the range to display in our query - $max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows; - - //This is your query again, the same one... the only difference is we add $max into it - $data = $dbl->executeWithoutParams("SELECT * FROM ams_querycache $max"); - - //This is where we put the results in a resultArray to be sent to smarty - - $i = 0; - while($row = $data->fetch(PDO::FETCH_ASSOC)){ - $decode = json_decode($row['query']); - $pageResult['liblist'][$i]['id'] = $row['SID']; - $pageResult['liblist'][$i]['type'] = $row['type']; - //$pageResult['liblist'][$i]['name'] = $decode[0]; - //$pageResult['liblist'][$i]['mail'] = $decode[2]; - $i++; - } - } - - //check if shard is online - try{ - $dbs = new DBLayer($cfg['db']['shard']); - $pageResult['shard'] = "online"; - }catch(PDOException $e) { - $pageResult['shard'] = "offline"; - } - return $pageResult; - }else{ - //ERROR: No access! - $_SESSION['error_code'] = "403"; - header("Location: index.php?page=error"); - exit; - } -} \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/inc/login.php b/code/ryzom/tools/server/ryzom_ams/www/html/inc/login.php new file mode 100644 index 000000000..38a9ab5d8 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/www/html/inc/login.php @@ -0,0 +1,16 @@ +getInfo(); + if(Ticket_User::isMod($_SESSION['ticket_user']) && ($_GET['id']!= $_SESSION['id'])){ + $result['changesOther'] = "TRUE"; } $result['target_id'] = $_GET['id']; - $result['current_mail'] = WebUsers::getEmail($_GET['id']); + $result['current_mail'] = $webUser->getEmail(); } }else{ - $result = WebUsers::getInfo($_SESSION['id']); + $webUser = new Webusers($_SESSION['id']); + $result = $webUser->getInfo(); $result['target_id'] = $_SESSION['id']; - $result['current_mail'] = WebUsers::getEmail($_SESSION['id']); + $result['current_mail'] = $webUser->getEmail(); //Sanitize Data $result['current_mail'] = filter_var($result['current_mail'], FILTER_SANITIZE_EMAIL); diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/inc/sgroup_list.php b/code/ryzom/tools/server/ryzom_ams/www/html/inc/sgroup_list.php new file mode 100644 index 000000000..3d380c2d2 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/www/html/inc/sgroup_list.php @@ -0,0 +1,31 @@ +getTUserId(); + $queueArray = array(); + $queue_handler = new Ticket_Queue_handler(); + + //Pagination Base Links + $result['pagination_base_link'] = "index.php?page=show_queue&get=".$result['queue_view'] ; + + if(isset($_GET['get']) && ($_GET['get'] == "create") && isset($_GET['userid']) && isset($_GET['groupid']) && isset($_GET['what']) && isset($_GET['how']) && isset($_GET['who'])){ + $userid = filter_var($_GET['userid'], FILTER_SANITIZE_NUMBER_INT); + $groupid = filter_var($_GET['groupid'], FILTER_SANITIZE_NUMBER_INT); + $what = filter_var($_GET['what'], FILTER_SANITIZE_STRING); + $how = filter_var($_GET['how'], FILTER_SANITIZE_STRING); + $who = filter_var($_GET['who'], FILTER_SANITIZE_STRING); + $queue_handler->CreateQueue($userid, $groupid, $what, $how, $who); + $result['pagination_base_link'] = "index.php?page=show_queue&get=create&userid=".$userid."&groupid=".$groupid."&what=".$what."&how=".$how."&who=".$who; + $result['prev_created_userid'] = $userid; + $result['prev_created_groupid'] = $groupid; + $result['prev_created_what'] = $what; + $result['prev_created_how'] = $how; + $result['prev_created_who'] = $who; + } + + //if an action is set + if(isset($_POST['action'])){ + switch($_POST['action']){ + case "assignTicket": + $ticket_id = filter_var($_POST['ticket_id'], FILTER_SANITIZE_NUMBER_INT); + $result['ACTION_RESULT'] = Ticket::assignTicket($user_id, $ticket_id); + break; + + case "unAssignTicket": + $ticket_id = filter_var($_POST['ticket_id'], FILTER_SANITIZE_NUMBER_INT); + $result['ACTION_RESULT'] = Ticket::unAssignTicket($user_id, $ticket_id); + break; + + case "create_queue": + $userid = filter_var($_POST['userid'], FILTER_SANITIZE_NUMBER_INT); + $groupid = filter_var($_POST['groupid'], FILTER_SANITIZE_NUMBER_INT); + $what = filter_var($_POST['what'], FILTER_SANITIZE_STRING); + $how = filter_var($_POST['how'], FILTER_SANITIZE_STRING); + $who = filter_var($_POST['who'], FILTER_SANITIZE_STRING); + $queue_handler->CreateQueue($userid, $groupid, $what, $how, $who); + $result['pagination_base_link'] = "index.php?page=show_queue&get=create&userid=".$userid."&groupid=".$groupid."&what=".$what."&how=".$how."&who=".$who; + $result['prev_created_userid'] = $userid; + $result['prev_created_groupid'] = $groupid; + $result['prev_created_what'] = $what; + $result['prev_created_how'] = $how; + $result['prev_created_who'] = $who; + + + + + break; + + } + } + + $queueArray = $queue_handler->getTickets($result['queue_view'], $user_id); + + //pagination + $result['links'] = $queue_handler->getPagination()->getLinks(5); + $result['lastPage'] = $queue_handler->getPagination()->getLast(); + $result['currentPage'] = $queue_handler->getPagination()->getCurrent(); + + + //if queue_view is a valid parameter value + if ($queueArray != "ERROR"){ + + $result['tickets'] = Gui_Elements::make_table($queueArray, Array("getTId","getTitle","getTimestamp","getAuthor()->getExternId","getTicket_Category()->getName","getStatus","getStatusText","getAssigned","getForwardedGroupName","getForwardedGroupId"), Array("tId","title","timestamp","authorExtern","category","status","statusText","assigned","forwardedGroupName","forwardedGroupId")); + $i = 0; + foreach( $result['tickets'] as $ticket){ + $web_author = new WebUsers($ticket['authorExtern']); + $result['tickets'][$i]['author'] = $web_author->getUsername(); + $web_assigned = new WebUsers($ticket['assigned']); + $result['tickets'][$i]['assignedText'] = $web_assigned->getUsername(); + $result['tickets'][$i]['timestamp_elapsed'] = Gui_Elements::time_elapsed_string($ticket['timestamp']); + $i++; + } + $result['user_id'] = $_SESSION['ticket_user']->getTUserId(); + + //Queue creator field info + $result['grouplist'] = Gui_Elements::make_table(Support_Group::getGroups(), Array("getSGroupId","getName"), Array("sGroupId","name")); + $result['teamlist'] = Gui_Elements::make_table(Ticket_User::getModsAndAdmins(), Array("getTUserId","getExternId"), Array("tUserId","externId")); + $i = 0; + foreach( $result['teamlist'] as $member){ + $web_teammember = new Webusers($member['externId']); + $result['teamlist'][$i]['name'] = $web_teammember->getUsername(); + $i++; + } + return $result; + + }else{ + + //ERROR: Doesn't exist! + $_SESSION['error_code'] = "404"; + header("Location: index.php?page=error"); + exit; + } + + }else{ + //ERROR: No access! + $_SESSION['error_code'] = "403"; + header("Location: index.php?page=error"); + exit; + } + }else{ + //ERROR: not logged in! + header("Location: index.php"); + exit; + } + +} \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/inc/show_reply.php b/code/ryzom/tools/server/ryzom_ams/www/html/inc/show_reply.php new file mode 100644 index 000000000..1640c5938 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/www/html/inc/show_reply.php @@ -0,0 +1,46 @@ +load_With_TReplyId($result['reply_id']); + + + $ticket = new Ticket(); + $ticket->load_With_TId($reply->getTicket()); + + if(( $ticket->getAuthor() == $_SESSION['ticket_user']->getTUserId() && ! $reply->getHidden()) || Ticket_User::isMod($_SESSION['ticket_user'] )){ + $content = new Ticket_Content(); + $content->load_With_TContentId($reply->getContent()); + + $author = new Ticket_User(); + $author->load_With_TUserId($reply->getAuthor()); + + $result['hidden'] = $reply->getHidden(); + $result['ticket_id'] = $reply->getTicket(); + $result['reply_timestamp'] = $reply->getTimestamp(); + $result['author_permission'] = $author->getPermission(); + $result['reply_content'] = $content->getContent(); + $result['author'] = $author->getExternId(); + $webUser = new WebUsers($author->getExternId()); + $result['authorName'] = $webUser->getUsername(); + if(Ticket_User::isMod($_SESSION['ticket_user'])){ + $result['isMod'] = "TRUE"; + } + return $result; + + }else{ + //ERROR: No access! + $_SESSION['error_code'] = "403"; + header("Location: index.php?page=error"); + exit; + } + }else{ + //ERROR: not logged in! + header("Location: index.php"); + exit; + } +} \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/inc/show_sgroup.php b/code/ryzom/tools/server/ryzom_ams/www/html/inc/show_sgroup.php new file mode 100644 index 000000000..f4f5edd64 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/www/html/inc/show_sgroup.php @@ -0,0 +1,56 @@ +getName(); + $result['userlist'] = Gui_Elements::make_table(Support_Group::getAllUsersOfSupportGroup($result['target_id']), Array("getTUserId","getPermission","getExternId"), Array("tUserId","permission","externId")); + $i = 0; + foreach( $result['userlist'] as $user){ + $webuser = new Webusers($user['externId']); + $result['userlist'][$i]['name'] = $webuser->getUsername(); + $i++; + } + return $result; + + + }else{ + + //ERROR: No page specified! + $_SESSION['error_code'] = "404"; + header("Location: index.php?page=error"); + exit; + } + + }else{ + //ERROR: No access! + $_SESSION['error_code'] = "403"; + header("Location: index.php?page=error"); + exit; + } + }else{ + //ERROR: not logged in! + header("Location: index.php"); + exit; + } + +} \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/inc/show_ticket.php b/code/ryzom/tools/server/ryzom_ams/www/html/inc/show_ticket.php new file mode 100644 index 000000000..3179a0e25 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/www/html/inc/show_ticket.php @@ -0,0 +1,82 @@ +getTUserId(); + $result['ticket_id'] = filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT); + $target_ticket = new Ticket(); + $target_ticket->load_With_TId($result['ticket_id']); + + if(Ticket_User::isMod($_SESSION['ticket_user'] )){ + if(isset($_POST['action'])){ + switch($_POST['action']){ + case "forward": + $ticket_id = filter_var($_POST['ticket_id'], FILTER_SANITIZE_NUMBER_INT); + $group_id = filter_var($_POST['group'], FILTER_SANITIZE_NUMBER_INT); + $result['ACTION_RESULT'] = Ticket::forwardTicket($result['user_id'], $ticket_id, $group_id); + break; + case "assignTicket": + $ticket_id = filter_var($_POST['ticket_id'], FILTER_SANITIZE_NUMBER_INT); + $result['ACTION_RESULT'] = Ticket::assignTicket($result['user_id'] , $ticket_id); + break; + case "unAssignTicket": + $ticket_id = filter_var($_POST['ticket_id'], FILTER_SANITIZE_NUMBER_INT); + $result['ACTION_RESULT'] = Ticket::unAssignTicket($result['user_id'], $ticket_id); + break; + + } + } + } + + if(($target_ticket->getAuthor() == $_SESSION['ticket_user']->getTUserId()) || Ticket_User::isMod($_SESSION['ticket_user'] )){ + + $show_as_admin = false; + if(Ticket_User::isMod($_SESSION['ticket_user'])){ + $show_as_admin = true; + } + $entire_ticket = Ticket::getEntireTicket( $result['ticket_id'],$show_as_admin); + Ticket_Log::createLogEntry($result['ticket_id'],$_SESSION['ticket_user']->getTUserId(), 3); + $result['ticket_tId'] = $entire_ticket['ticket_obj']->getTId(); + $result['ticket_forwardedGroupName'] = $entire_ticket['ticket_obj']->getForwardedGroupName(); + $result['ticket_forwardedGroupId'] = $entire_ticket['ticket_obj']->getForwardedGroupId(); + $result['ticket_title'] = $entire_ticket['ticket_obj']->getTitle(); + $result['ticket_timestamp'] = $entire_ticket['ticket_obj']->getTimestamp(); + $result['ticket_status'] = $entire_ticket['ticket_obj']->getStatus(); + $result['ticket_author'] = $entire_ticket['ticket_obj']->getAuthor(); + $result['ticket_prioritytext'] = $entire_ticket['ticket_obj']->getPriorityText(); + $result['ticket_priorities'] = Ticket::getPriorityArray(); + $result['ticket_priority'] = $entire_ticket['ticket_obj']->getPriority(); + $result['ticket_statustext'] = $entire_ticket['ticket_obj']->getStatusText(); + $result['ticket_lastupdate'] = Gui_Elements::time_elapsed_string(Ticket::getLatestReply($result['ticket_id'])->getTimestamp()); + $result['ticket_category'] = $entire_ticket['ticket_obj']->getCategoryName(); + $webUser = new WebUsers(Assigned::getUserAssignedToTicket($result['ticket_tId'])); + $result['ticket_assignedToText'] = $webUser->getUsername(); + $result['ticket_assignedTo'] = Assigned::getUserAssignedToTicket($result['ticket_tId']); + $result['ticket_replies'] = Gui_Elements::make_table($entire_ticket['reply_array'], Array("getTReplyId","getContent()->getContent","getTimestamp","getAuthor()->getExternId","getAuthor()->getPermission","getHidden"), Array("tReplyId","replyContent","timestamp","authorExtern","permission","hidden")); + $i = 0; + foreach( $result['ticket_replies'] as $reply){ + $webReplyUser = new WebUsers($reply['authorExtern']); + $result['ticket_replies'][$i]['author'] = $webReplyUser->getUsername(); + $i++; + } + if(Ticket_User::isMod($_SESSION['ticket_user'])){ + $result['isMod'] = "TRUE"; + $result['statusList'] = Ticket::getStatusArray(); + $result['sGroups'] = Gui_Elements::make_table_with_key_is_id(Support_Group::getAllSupportGroups(), Array("getName"), "getSGroupId" ); + } + return $result; + + }else{ + //ERROR: No access! + $_SESSION['error_code'] = "403"; + header("Location: index.php?page=error"); + exit; + } + }else{ + //ERROR: not logged in! + header("Location: index.php"); + exit; + } +} \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/inc/show_ticket_log.php b/code/ryzom/tools/server/ryzom_ams/www/html/inc/show_ticket_log.php new file mode 100644 index 000000000..5d4cbb76b --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/www/html/inc/show_ticket_log.php @@ -0,0 +1,56 @@ +load_With_TId($result['ticket_id']); + $result['ticket_title'] = $target_ticket->getTitle(); + $ticket_logs = Ticket_Log::getLogsOfTicket( $result['ticket_id']); + $log_action_array = Ticket_Log::getActionTextArray(); + $result['ticket_logs'] = Gui_Elements::make_table($ticket_logs, Array("getTLogId","getTimestamp","getAuthor()->getExternId","getAction","getArgument()"), Array("tLogId","timestamp","authorExtern","action","argument")); + $i = 0; + foreach( $result['ticket_logs'] as $log){ + $webUser = new WebUsers($log['authorExtern']); + $author = $webUser->getUsername(); + $result['ticket_logs'][$i]['author'] = $author; + $query_backpart = ""; + if($log['action'] == 2){ + $webUser2 = new WebUsers($log['argument']); + $query_backpart = $webUser2->getUsername(); + }else if($log['action'] == 4){ + $query_backpart = "ID#" . $log['argument'] . ""; + }else if($log['action'] == 5){ + $statusArray = Ticket::getStatusArray(); + $query_backpart = $statusArray[$log['argument'] ]; + }else if($log['action'] == 6){ + $priorityArray = Ticket::getPriorityArray(); + $query_backpart = $priorityArray[$log['argument'] ]; + }else if($log['action'] == 8){ + $query_backpart = "" . Support_Group::getGroup($log['argument'])->getName() . ""; + } + $result['ticket_logs'][$i]['query'] = $author . " " . $log_action_array[$log['action']] . " " . $query_backpart; + $result['ticket_logs'][$i]['timestamp_elapsed'] = Gui_Elements::time_elapsed_string($log['timestamp']); + $i++; + } + if(Ticket_User::isMod($_SESSION['ticket_user'])){ + $result['isMod'] = "TRUE"; + } + return $result; + + }else{ + //ERROR: No access! + $_SESSION['error_code'] = "403"; + header("Location: index.php?page=error"); + exit; + } + }else{ + //ERROR: not logged in! + header("Location: index.php"); + exit; + } +} \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/inc/show_user.php b/code/ryzom/tools/server/ryzom_ams/www/html/inc/show_user.php index a0d9c9132..a8774ba83 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/inc/show_user.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/inc/show_user.php @@ -4,49 +4,30 @@ function show_user(){ //if logged in if(WebUsers::isLoggedIn()){ - if( !isset($_GET['id']) || WebUsers::isAdmin() || $_GET['id'] == $_SESSION['id'] ){ + if( !isset($_GET['id']) || Ticket_User::isMod($_SESSION['ticket_user']) || $_GET['id'] == $_SESSION['id'] ){ if(isset($_GET['id'])){ $result['target_id'] = filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT); }else{ $result['target_id'] = $_SESSION['id']; } - $result['target_name'] = WebUsers::getUsername( $result['target_id']); - $result['mail'] = WebUsers::getEmail( $result['target_id']); - $info = WebUsers::getInfo($result['target_id']); + $webUser = new WebUsers($result['target_id']); + $result['target_name'] = $webUser->getUsername(); + $result['mail'] = $webUser->getEmail(); + $info = $webUser->getInfo(); $result['firstName'] = $info['FirstName']; $result['lastName'] = $info['LastName']; $result['country'] = $info['Country']; $result['gender'] = $info['Gender']; - global $cfg; - $ticket_user = Ticket_User::constr_ExternId($result['target_id'],$cfg['db']['lib']); - $ticketlist = Ticket::getTicketsOf($ticket_user->getTUserId(),$cfg['db']['lib']); - $i = 0; - $result['ticketlist'] = Array(); - foreach($ticketlist as $ticket){ - $result['ticketlist'][$i]['tId'] = $ticket->getTId(); - $result['ticketlist'][$i]['timestamp'] = $ticket->getTimestamp(); - $result['ticketlist'][$i]['title'] = $ticket->getTitle(); - - //get the status - $statusId = $ticket->getStatus(); - if ($statusId == 0){ - $status = "Waiting on support.."; - }else if($statusId == 1){ - $status = "Being handled.."; - }else if($statusId == 2){ - $status = "Closed"; - } - - $result['ticketlist'][$i]['statusText'] = $status; - $result['ticketlist'][$i]['status'] = $statusId; - //get the category - $category = Ticket_Category::constr_TCategoryId($ticket->getTicket_Category(), $cfg['db']['lib']); - $result['ticketlist'][$i]['category'] = $category->getName(); - $i++; + $ticket_user = Ticket_User::constr_ExternId($result['target_id']); + $result['userPermission'] = $ticket_user->getPermission(); + if(Ticket_User::isAdmin($_SESSION['ticket_user'])){ + $result['isAdmin'] = "TRUE"; } + $ticketlist = Ticket::getTicketsOf($ticket_user->getTUserId()); + $result['ticketlist'] = Gui_Elements::make_table($ticketlist, Array("getTId","getTimestamp","getTitle","getStatus","getStatusText","getStatusText","getCategoryName"), Array("tId","timestamp","title","status","statustext","statusText","category")); return $result; }else{ diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/inc/syncing.php b/code/ryzom/tools/server/ryzom_ams/www/html/inc/syncing.php new file mode 100644 index 000000000..bca38bd74 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/www/html/inc/syncing.php @@ -0,0 +1,28 @@ +getElements() , Array("getSID","getType"), Array("id","type")); + $pageResult['links'] = $pagination->getLinks(5); + $pageResult['lastPage'] = $pagination->getLast(); + $pageResult['currentPage'] = $pagination->getCurrent(); + + + //check if shard is online + try{ + $dbs = new DBLayer("shard"); + $pageResult['shard'] = "online"; + }catch(PDOException $e) { + $pageResult['shard'] = "offline"; + } + return $pageResult; + }else{ + //ERROR: No access! + $_SESSION['error_code'] = "403"; + header("Location: index.php?page=error"); + exit; + } +} \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/inc/userlist.php b/code/ryzom/tools/server/ryzom_ams/www/html/inc/userlist.php index e2c2cbfcb..9e4c8a079 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/inc/userlist.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/inc/userlist.php @@ -1,17 +1,23 @@ getElements() , Array("getUId","getUsername","getEmail"), Array("id","username","email")); + $pageResult['links'] = $pagination->getLinks(5); + $pageResult['lastPage'] = $pagination->getLast(); + $pageResult['currentPage'] = $pagination->getCurrent(); + $i = 0; - $pageResult['userlist'] = Array(); - while($row = $users->fetch(PDO::FETCH_ASSOC)){ - $pageResult['userlist'][$i]['id'] = $row['UId']; - $pageResult['userlist'][$i]['username'] = $row['Login']; - $pageResult['userlist'][$i]['permission'] = $row['Permission']; - $pageResult['userlist'][$i]['email'] = $row['Email']; + foreach( $pageResult['userlist'] as $user ){ + $pageResult['userlist'][$i]['permission'] = Ticket_User::constr_ExternId($pageResult['userlist'][$i]['id'])->getPermission(); $i++; } + + if (Ticket_User::isAdmin($_SESSION['ticket_user'])){ + $pageResult['isAdmin'] = "TRUE"; + } return $pageResult; }else{ //ERROR: No access! diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/index.php b/code/ryzom/tools/server/ryzom_ams/www/html/index.php index 040989bbb..b14cbb40c 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/index.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/index.php @@ -6,11 +6,15 @@ require( '../../ams_lib/libinclude.php' ); session_start(); //Decide what page to load -if(isset($_SESSION['user'])){ - $page = 'home'; +if ( ! isset( $_GET["page"]) ){ + if(isset($_SESSION['user'])){ + $page = 'home'; + }else{ + //default page + $page = 'login'; + } }else{ - //default page - $page = 'login'; + $page = $_GET["page"]; } //perform an action in case one is specified @@ -18,13 +22,12 @@ if(isset($_SESSION['user'])){ if ( isset( $_POST["function"] ) ){ require( "func/" . $_POST["function"] . ".php" ); $return = $_POST["function"](); -}else if ( isset( $_GET["page"] ) ){ - $filename = 'inc/' . $_GET["page"] . '.php'; +}else{ + $filename = 'inc/' . $page . '.php'; if(is_file($filename)){ require_once($filename); - $return = $_GET["page"](); + $return = $page(); } - $page = $_GET["page"]; } //add username to the return array in case logged in. @@ -36,8 +39,8 @@ if(isset($_SESSION['user'])){ //Set permission -if(isset($_SESSION['permission'])){ - $return['permission'] = $_SESSION['permission']; +if(isset($_SESSION['ticket_user'])){ + $return['permission'] = $_SESSION['ticket_user']->getPermission(); }else{ //default permission $return['permission'] = 0; diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/sql/DBScheme.png b/code/ryzom/tools/server/ryzom_ams/www/html/sql/DBScheme.png index 340e67c5c..16bced7cc 100644 Binary files a/code/ryzom/tools/server/ryzom_ams/www/html/sql/DBScheme.png and b/code/ryzom/tools/server/ryzom_ams/www/html/sql/DBScheme.png differ diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/sql/install.php b/code/ryzom/tools/server/ryzom_ams/www/html/sql/install.php index 2101f80da..cf8a514e4 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/sql/install.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/sql/install.php @@ -9,7 +9,7 @@ try{ //SETUP THE WWW DB - $dbw = new DBLayer($cfg['db']['web']); + $dbw = new DBLayer("web"); $sql = " CREATE DATABASE IF NOT EXISTS `" . $cfg['db']['web']['name'] ."`; USE `". $cfg['db']['web']['name'] . "`; @@ -33,7 +33,7 @@ $dbw->executeWithoutParams($sql); //SETUP THE AMS_LIB DB - $dbl = new DBLayer($cfg['db']['lib']); + $dbl = new DBLayer("lib"); $sql = " CREATE DATABASE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`; USE `" . $cfg['db']['lib']['name'] ."`; @@ -42,208 +42,339 @@ CREATE TABLE ams_querycache ( `SID` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , `type` VARCHAR( 64 ) NOT NULL , - `query` VARCHAR( 512 ) NOT NULL + `query` VARCHAR( 512 ) NOT NULL, + `db` VARCHAR( 80 ) NOT NULL ); - -- ----------------------------------------------------- - -- Table `" . $cfg['db']['lib']['name'] ."`.`ticket_category` - -- ----------------------------------------------------- - DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_category` ; + + -- ----------------------------------------------------- + -- Table `" . $cfg['db']['lib']['name'] ."`.`ticket_category` + -- ----------------------------------------------------- + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_category` ; + + CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_category` ( + `TCategoryId` INT UNSIGNED NOT NULL AUTO_INCREMENT , + `Name` VARCHAR(45) NOT NULL , + PRIMARY KEY (`TCategoryId`) , + UNIQUE INDEX `Name_UNIQUE` (`Name` ASC) ) + ENGINE = InnoDB; + + + -- ----------------------------------------------------- + -- Table `" . $cfg['db']['lib']['name'] ."`.`ticket_user` + -- ----------------------------------------------------- + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_user` ; + + CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_user` ( + `TUserId` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT , + `Permission` INT(3) NOT NULL DEFAULT 1 , + `ExternId` INT(10) UNSIGNED NOT NULL , + PRIMARY KEY (`TUserId`) ) + ENGINE = InnoDB; + + + -- ----------------------------------------------------- + -- Table `" . $cfg['db']['lib']['name'] ."`.`ticket` + -- ----------------------------------------------------- + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket` ; + + CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket` ( + `TId` INT UNSIGNED NOT NULL AUTO_INCREMENT , + `Timestamp` TIMESTAMP NOT NULL , + `Title` VARCHAR(120) NOT NULL , + `Status` INT NULL DEFAULT 0 , + `Queue` INT NULL DEFAULT 0 , + `Ticket_Category` INT UNSIGNED NOT NULL , + `Author` INT UNSIGNED NOT NULL , + `Priority` INT(3) NULL DEFAULT 0 , + PRIMARY KEY (`TId`) , + INDEX `fk_ticket_ticket_category_idx` (`Ticket_Category` ASC) , + INDEX `fk_ticket_ams_user_idx` (`Author` ASC) , + CONSTRAINT `fk_ticket_ticket_category` + FOREIGN KEY (`Ticket_Category` ) + REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket_category` (`TCategoryId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT `fk_ticket_ams_user` + FOREIGN KEY (`Author` ) + REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket_user` (`TUserId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION) + ENGINE = InnoDB; + + + -- ----------------------------------------------------- + -- Table `" . $cfg['db']['lib']['name'] ."`.`assigned` + -- ----------------------------------------------------- + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`assigned` ; + + CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`assigned` ( + `Ticket` INT UNSIGNED NOT NULL , + `User` INT UNSIGNED NOT NULL , + INDEX `fk_assigned_ticket_idx` (`Ticket` ASC) , + PRIMARY KEY (`Ticket`, `User`) , + INDEX `fk_assigned_ams_user_idx` (`User` ASC) , + CONSTRAINT `fk_assigned_ticket` + FOREIGN KEY (`Ticket` ) + REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket` (`TId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT `fk_assigned_ams_user` + FOREIGN KEY (`User` ) + REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket_user` (`TUserId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION) + ENGINE = InnoDB; + + + -- ----------------------------------------------------- + -- Table `" . $cfg['db']['lib']['name'] ."`.`tag` + -- ----------------------------------------------------- + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`tag` ; + + CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`tag` ( + `TagId` INT UNSIGNED NOT NULL AUTO_INCREMENT , + `Value` VARCHAR(60) NOT NULL , + PRIMARY KEY (`TagId`) , + UNIQUE INDEX `Value_UNIQUE` (`Value` ASC) ) + ENGINE = InnoDB; + + + -- ----------------------------------------------------- + -- Table `" . $cfg['db']['lib']['name'] ."`.`tagged` + -- ----------------------------------------------------- + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`tagged` ; + + CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`tagged` ( + `Ticket` INT UNSIGNED NOT NULL , + `Tag` INT UNSIGNED NOT NULL , + PRIMARY KEY (`Ticket`, `Tag`) , + INDEX `fk_tagged_tag_idx` (`Tag` ASC) , + CONSTRAINT `fk_tagged_ticket` + FOREIGN KEY (`Ticket` ) + REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket` (`TId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT `fk_tagged_tag` + FOREIGN KEY (`Tag` ) + REFERENCES `" . $cfg['db']['lib']['name'] ."`.`tag` (`TagId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION) + ENGINE = InnoDB; + + + -- ----------------------------------------------------- + -- Table `" . $cfg['db']['lib']['name'] ."`.`ticket_content` + -- ----------------------------------------------------- + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_content` ; + + CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_content` ( + `TContentId` INT UNSIGNED NOT NULL AUTO_INCREMENT , + `Content` TEXT NULL , + PRIMARY KEY (`TContentId`) ) + ENGINE = InnoDB + DEFAULT CHARACTER SET = utf8; + + + -- ----------------------------------------------------- + -- Table `" . $cfg['db']['lib']['name'] ."`.`ticket_reply` + -- ----------------------------------------------------- + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_reply` ; + + CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_reply` ( + `TReplyId` INT UNSIGNED NOT NULL AUTO_INCREMENT , + `Ticket` INT UNSIGNED NOT NULL , + `Author` INT UNSIGNED NOT NULL , + `Content` INT UNSIGNED NOT NULL , + `Timestamp` TIMESTAMP NULL , + `Hidden` TINYINT(1) NULL DEFAULT 0 , + PRIMARY KEY (`TReplyId`) , + INDEX `fk_ticket_reply_ticket_idx` (`Ticket` ASC) , + INDEX `fk_ticket_reply_ams_user_idx` (`Author` ASC) , + INDEX `fk_ticket_reply_content_idx` (`Content` ASC) , + CONSTRAINT `fk_ticket_reply_ticket` + FOREIGN KEY (`Ticket` ) + REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket` (`TId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT `fk_ticket_reply_ams_user` + FOREIGN KEY (`Author` ) + REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket_user` (`TUserId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT `fk_ticket_reply_ticket_content` + FOREIGN KEY (`Content` ) + REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket_content` (`TContentId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION) + ENGINE = InnoDB; + + + -- ----------------------------------------------------- + -- Table `" . $cfg['db']['lib']['name'] ."`.`ticket_group` + -- ----------------------------------------------------- + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_group` ; + + CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_group` ( + `TGroupId` INT UNSIGNED NOT NULL AUTO_INCREMENT , + `Title` VARCHAR(80) NOT NULL , + PRIMARY KEY (`TGroupId`) , + UNIQUE INDEX `Title_UNIQUE` (`Title` ASC) ) + ENGINE = InnoDB; + + + -- ----------------------------------------------------- + -- Table `" . $cfg['db']['lib']['name'] ."`.`in_group` + -- ----------------------------------------------------- + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`in_group` ; + + CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`in_group` ( + `Ticket_Group` INT UNSIGNED NOT NULL , + `Ticket` INT UNSIGNED NOT NULL , + PRIMARY KEY (`Ticket_Group`, `Ticket`) , + INDEX `fk_in_group_ticket_group_idx` (`Ticket_Group` ASC) , + INDEX `fk_in_group_ticket_idx` (`Ticket` ASC) , + CONSTRAINT `fk_in_group_ticket_group` + FOREIGN KEY (`Ticket_Group` ) + REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket_group` (`TGroupId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT `fk_in_group_ticket` + FOREIGN KEY (`Ticket` ) + REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket` (`TId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION) + ENGINE = InnoDB; + + + -- ----------------------------------------------------- + -- Table `" . $cfg['db']['lib']['name'] ."`.`ticket_log` + -- ----------------------------------------------------- + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_log` ; + + CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_log` ( + `TLogId` INT UNSIGNED NOT NULL AUTO_INCREMENT , + `Timestamp` TIMESTAMP NOT NULL , + `Query` VARCHAR(255) NOT NULL , + `Ticket` INT UNSIGNED NOT NULL , + `Author` INT(10) UNSIGNED NULL , + PRIMARY KEY (`TLogId`) , + INDEX `fk_ticket_log_ticket1` (`Ticket` ASC) , + INDEX `fk_ticket_log_ticket_user1` (`Author` ASC) , + CONSTRAINT `fk_ticket_log_ticket1` + FOREIGN KEY (`Ticket` ) + REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket` (`TId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT `fk_ticket_log_ticket_user1` + FOREIGN KEY (`Author` ) + REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket_user` (`TUserId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION) + ENGINE = InnoDB; - CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_category` ( - `TCategoryId` INT NOT NULL AUTO_INCREMENT , - `Name` VARCHAR(45) NOT NULL , - PRIMARY KEY (`TCategoryId`) , - UNIQUE INDEX `Name_UNIQUE` (`Name` ASC) ) - ENGINE = InnoDB; - - INSERT IGNORE INTO `" . $cfg['db']['lib']['name'] ."`.`ticket_category` (`Name`) VALUES ('Hacking'),('Ingame-Bug'),('Website-Bug'),('Installation'); + INSERT IGNORE INTO `" . $cfg['db']['lib']['name'] ."`.`ticket_category` (`Name`) VALUES ('Hacking'),('Ingame-Bug'),('Website-Bug'),('Installation'); + + + + -- ----------------------------------------------------- + -- Table `" . $cfg['db']['lib']['name'] ."`.`support_group` + -- ----------------------------------------------------- + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`support_group` ; + + CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`support_group` ( + `SGroupId` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT , + `Name` VARCHAR(22) NOT NULL , + `Tag` VARCHAR(7) NOT NULL , + PRIMARY KEY (`SGroupId`) , + UNIQUE INDEX `Name_UNIQUE` (`Name` ASC) , + UNIQUE INDEX `Tag_UNIQUE` (`Tag` ASC) ) + ENGINE = InnoDB; + + + -- ----------------------------------------------------- + -- Table `" . $cfg['db']['lib']['name'] ."`.`in_support_group` + -- ----------------------------------------------------- + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`in_support_group` ; + + CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`in_support_group` ( + `User` INT(10) UNSIGNED NOT NULL , + `Group` INT(10) UNSIGNED NOT NULL , + INDEX `fk_in_support_group_ticket_user1` (`User` ASC) , + INDEX `fk_in_support_group_support_group1` (`Group` ASC) , + CONSTRAINT `fk_in_support_group_ticket_user1` + FOREIGN KEY (`User` ) + REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket_user` (`TUserId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT `fk_in_support_group_support_group1` + FOREIGN KEY (`Group` ) + REFERENCES `" . $cfg['db']['lib']['name'] ."`.`support_group` (`SGroupId` ) + ON DELETE CASCADE + ON UPDATE NO ACTION) + ENGINE = InnoDB; + + -- ----------------------------------------------------- + -- Table `" . $cfg['db']['lib']['name'] ."`.`forwarded` + -- ----------------------------------------------------- + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`forwarded` ; + + CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`forwarded` ( + `Group` INT(10) UNSIGNED NOT NULL , + `Ticket` INT UNSIGNED NOT NULL , + INDEX `fk_forwarded_support_group1` (`Group` ASC) , + INDEX `fk_forwarded_ticket1` (`Ticket` ASC) , + CONSTRAINT `fk_forwarded_support_group1` + FOREIGN KEY (`Group` ) + REFERENCES `" . $cfg['db']['lib']['name'] ."`.`support_group` (`SGroupId` ) + ON DELETE CASCADE + ON UPDATE NO ACTION, + CONSTRAINT `fk_forwarded_ticket1` + FOREIGN KEY (`Ticket` ) + REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket` (`TId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION) + ENGINE = InnoDB; + + + -- ----------------------------------------------------- + -- Table `" . $cfg['db']['lib']['name'] ."`.`email` + -- ----------------------------------------------------- + DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`email` ; + + CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`email` ( + `MailId` INT NOT NULL AUTO_INCREMENT , + `Recipient` VARCHAR(50) NULL , + `Subject` VARCHAR(60) NULL , + `Body` VARCHAR(400) NULL , + `Status` VARCHAR(45) NULL , + `Attempts` VARCHAR(45) NULL DEFAULT 0 , + `Sender` INT(10) UNSIGNED NOT NULL , + `UserId` INT(10) UNSIGNED NOT NULL , + `MessageId` VARCHAR(45) NOT NULL , + `TicketId` INT UNSIGNED NOT NULL , + PRIMARY KEY (`MailId`) , + INDEX `fk_email_ticket_user1` (`Sender` ASC) , + INDEX `fk_email_ticket_user2` (`UserId` ASC) , + INDEX `fk_email_ticket1` (`TicketId` ASC) , + CONSTRAINT `fk_email_ticket_user1` + FOREIGN KEY (`Sender` ) + REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket_user` (`TUserId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT `fk_email_ticket_user2` + FOREIGN KEY (`UserId` ) + REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket_user` (`TUserId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT `fk_email_ticket1` + FOREIGN KEY (`TicketId` ) + REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket` (`TId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION) + ENGINE = InnoDB; + - -- ----------------------------------------------------- - -- Table `" . $cfg['db']['lib']['name'] ."`.`ticket_user` - -- ----------------------------------------------------- - DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_user` ; - - CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_user` ( - `TUserId` INT(10) NOT NULL AUTO_INCREMENT , - `Permission` INT(3) NOT NULL DEFAULT 1 , - `ExternId` INT(10) NOT NULL , - PRIMARY KEY (`TUserId`) ) - ENGINE = InnoDB; - - - -- ----------------------------------------------------- - -- Table `" . $cfg['db']['lib']['name'] ."`.`ticket` - -- ----------------------------------------------------- - DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket` ; - - CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket` ( - `TId` INT NOT NULL AUTO_INCREMENT , - `Timestamp` TIMESTAMP NOT NULL , - `Title` VARCHAR(120) NOT NULL , - `Status` INT NULL DEFAULT 0 , - `Queue` INT NULL DEFAULT 0 , - `Ticket_Category` INT NOT NULL , - `Author` INT NOT NULL , - PRIMARY KEY (`TId`) , - INDEX `fk_ticket_ticket_category_idx` (`Ticket_Category` ASC) , - INDEX `fk_ticket_ams_user_idx` (`Author` ASC) , - CONSTRAINT `fk_ticket_ticket_category` - FOREIGN KEY (`Ticket_Category` ) - REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket_category` (`TCategoryId` ) - ON DELETE NO ACTION - ON UPDATE NO ACTION, - CONSTRAINT `fk_ticket_ams_user` - FOREIGN KEY (`Author` ) - REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket_user` (`TUserId` ) - ON DELETE NO ACTION - ON UPDATE NO ACTION) - ENGINE = InnoDB; - - - -- ----------------------------------------------------- - -- Table `" . $cfg['db']['lib']['name'] ."`.`assigned` - -- ----------------------------------------------------- - DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`assigned` ; - - CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`assigned` ( - `Ticket` INT NOT NULL , - `User` INT NOT NULL , - INDEX `fk_assigned_ticket_idx` (`Ticket` ASC) , - PRIMARY KEY (`Ticket`, `User`) , - INDEX `fk_assigned_ams_user_idx` (`User` ASC) , - CONSTRAINT `fk_assigned_ticket` - FOREIGN KEY (`Ticket` ) - REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket` (`TId` ) - ON DELETE NO ACTION - ON UPDATE NO ACTION, - CONSTRAINT `fk_assigned_ams_user` - FOREIGN KEY (`User` ) - REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket_user` (`TUserId` ) - ON DELETE NO ACTION - ON UPDATE NO ACTION) - ENGINE = InnoDB; - - - -- ----------------------------------------------------- - -- Table `" . $cfg['db']['lib']['name'] ."`.`tag` - -- ----------------------------------------------------- - DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`tag` ; - - CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`tag` ( - `TagId` INT NOT NULL AUTO_INCREMENT , - `Value` VARCHAR(60) NOT NULL , - PRIMARY KEY (`TagId`) , - UNIQUE INDEX `Value_UNIQUE` (`Value` ASC) ) - ENGINE = InnoDB; - - - -- ----------------------------------------------------- - -- Table `" . $cfg['db']['lib']['name'] ."`.`tagged` - -- ----------------------------------------------------- - DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`tagged` ; - - CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`tagged` ( - `Ticket` INT NOT NULL , - `Tag` INT NOT NULL , - PRIMARY KEY (`Ticket`, `Tag`) , - INDEX `fk_tagged_tag_idx` (`Tag` ASC) , - CONSTRAINT `fk_tagged_ticket` - FOREIGN KEY (`Ticket` ) - REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket` (`TId` ) - ON DELETE NO ACTION - ON UPDATE NO ACTION, - CONSTRAINT `fk_tagged_tag` - FOREIGN KEY (`Tag` ) - REFERENCES `" . $cfg['db']['lib']['name'] ."`.`tag` (`TagId` ) - ON DELETE NO ACTION - ON UPDATE NO ACTION) - ENGINE = InnoDB; - - - -- ----------------------------------------------------- - -- Table `" . $cfg['db']['lib']['name'] ."`.`ticket_content` - -- ----------------------------------------------------- - DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_content` ; - - CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_content` ( - `TContentId` INT NOT NULL AUTO_INCREMENT , - `Content` TEXT NULL , - PRIMARY KEY (`TContentId`) ) - ENGINE = InnoDB - DEFAULT CHARACTER SET = utf8; - - - -- ----------------------------------------------------- - -- Table `" . $cfg['db']['lib']['name'] ."`.`ticket_reply` - -- ----------------------------------------------------- - DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_reply` ; - - CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_reply` ( - `TReplyId` INT NOT NULL AUTO_INCREMENT , - `Ticket` INT NOT NULL , - `Author` INT NOT NULL , - `Content` INT NOT NULL , - `Timestamp` TIMESTAMP NULL , - PRIMARY KEY (`TReplyId`) , - INDEX `fk_ticket_reply_ticket_idx` (`Ticket` ASC) , - INDEX `fk_ticket_reply_ams_user_idx` (`Author` ASC) , - INDEX `fk_ticket_reply_content_idx` (`Content` ASC) , - CONSTRAINT `fk_ticket_reply_ticket` - FOREIGN KEY (`Ticket` ) - REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket` (`TId` ) - ON DELETE NO ACTION - ON UPDATE NO ACTION, - CONSTRAINT `fk_ticket_reply_ams_user` - FOREIGN KEY (`Author` ) - REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket_user` (`TUserId` ) - ON DELETE NO ACTION - ON UPDATE NO ACTION, - CONSTRAINT `fk_ticket_reply_ticket_content` - FOREIGN KEY (`Content` ) - REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket_content` (`TContentId` ) - ON DELETE NO ACTION - ON UPDATE NO ACTION) - ENGINE = InnoDB; - - - -- ----------------------------------------------------- - -- Table `" . $cfg['db']['lib']['name'] ."`.`ticket_group` - -- ----------------------------------------------------- - DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_group` ; - - CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`ticket_group` ( - `TGroupId` INT NOT NULL AUTO_INCREMENT , - `Title` VARCHAR(80) NOT NULL , - PRIMARY KEY (`TGroupId`) , - UNIQUE INDEX `Title_UNIQUE` (`Title` ASC) ) - ENGINE = InnoDB; - - - -- ----------------------------------------------------- - -- Table `" . $cfg['db']['lib']['name'] ."`.`in_group` - -- ----------------------------------------------------- - DROP TABLE IF EXISTS `" . $cfg['db']['lib']['name'] ."`.`in_group` ; - - CREATE TABLE IF NOT EXISTS `" . $cfg['db']['lib']['name'] ."`.`in_group` ( - `Ticket_Group` INT NOT NULL , - `Ticket` INT NOT NULL , - PRIMARY KEY (`Ticket_Group`, `Ticket`) , - INDEX `fk_in_group_ticket_group_idx` (`Ticket_Group` ASC) , - INDEX `fk_in_group_ticket_idx` (`Ticket` ASC) , - CONSTRAINT `fk_in_group_ticket_group` - FOREIGN KEY (`Ticket_Group` ) - REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket_group` (`TGroupId` ) - ON DELETE NO ACTION - ON UPDATE NO ACTION, - CONSTRAINT `fk_in_group_ticket` - FOREIGN KEY (`Ticket` ) - REFERENCES `" . $cfg['db']['lib']['name'] ."`.`ticket` (`TId` ) - ON DELETE NO ACTION - ON UPDATE NO ACTION) - ENGINE = InnoDB; - - "; $dbl->executeWithoutParams($sql); @@ -255,12 +386,14 @@ 'name' => "admin", 'pass' => $hashpass, 'mail' => "admin@admin.com", + 'permission' => 3 ); - Users::createUser($params, 1); try{ - $params['permission'] = 2; - $dbw = new DBLayer($cfg['db']['web']); - $dbw->execute("INSERT INTO ams_user (Login, Password, Email, Permission) VALUES (:name, :pass, :mail, :permission)",$params); + $dbw = new DBLayer("web"); + $user_id = $dbw->executeReturnId("INSERT INTO ams_user (Login, Password, Email, Permission) VALUES (:name, :pass, :mail, :permission)",$params); + Users::createUser($params, $user_id); + $dbl = new DBLayer("lib"); + $dbl->execute("UPDATE ticket_user SET Permission = 3 WHERE TUserId = :user_id",array('user_id' => $user_id)); print "The admin account is created, you can login with id: admin, pass: admin!"; }catch (PDOException $e){ print "There was an error while creating the admin account! "; @@ -277,4 +410,4 @@ print_r($e); } - \ No newline at end of file + diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/sql/ticketsql.sql b/code/ryzom/tools/server/ryzom_ams/www/html/sql/ticketsql.sql index 0f22a9741..e7864e628 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/sql/ticketsql.sql +++ b/code/ryzom/tools/server/ryzom_ams/www/html/sql/ticketsql.sql @@ -11,7 +11,7 @@ USE `mydb` ; DROP TABLE IF EXISTS `mydb`.`ticket_category` ; CREATE TABLE IF NOT EXISTS `mydb`.`ticket_category` ( - `TCategoryId` INT NOT NULL AUTO_INCREMENT , + `TCategoryId` INT UNSIGNED NOT NULL AUTO_INCREMENT , `Name` VARCHAR(45) NOT NULL , PRIMARY KEY (`TCategoryId`) , UNIQUE INDEX `Name_UNIQUE` (`Name` ASC) ) @@ -24,9 +24,9 @@ ENGINE = InnoDB; DROP TABLE IF EXISTS `mydb`.`ticket_user` ; CREATE TABLE IF NOT EXISTS `mydb`.`ticket_user` ( - `TUserId` INT(10) NOT NULL AUTO_INCREMENT , + `TUserId` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT , `Permission` INT(3) NOT NULL DEFAULT 1 , - `ExternId` INT(10) NOT NULL , + `ExternId` INT(10) UNSIGNED NOT NULL , PRIMARY KEY (`TUserId`) ) ENGINE = InnoDB; @@ -37,13 +37,14 @@ ENGINE = InnoDB; DROP TABLE IF EXISTS `mydb`.`ticket` ; CREATE TABLE IF NOT EXISTS `mydb`.`ticket` ( - `TId` INT NOT NULL AUTO_INCREMENT , + `TId` INT UNSIGNED NOT NULL AUTO_INCREMENT , `Timestamp` TIMESTAMP NOT NULL , `Title` VARCHAR(120) NOT NULL , `Status` INT NULL DEFAULT 0 , `Queue` INT NULL DEFAULT 0 , - `Ticket_Category` INT NOT NULL , - `Author` INT NOT NULL , + `Ticket_Category` INT UNSIGNED NOT NULL , + `Author` INT UNSIGNED NOT NULL , + `Priority` INT(3) NULL DEFAULT 0 , PRIMARY KEY (`TId`) , INDEX `fk_ticket_ticket_category_idx` (`Ticket_Category` ASC) , INDEX `fk_ticket_ams_user_idx` (`Author` ASC) , @@ -66,8 +67,8 @@ ENGINE = InnoDB; DROP TABLE IF EXISTS `mydb`.`assigned` ; CREATE TABLE IF NOT EXISTS `mydb`.`assigned` ( - `Ticket` INT NOT NULL , - `User` INT NOT NULL , + `Ticket` INT UNSIGNED NOT NULL , + `User` INT UNSIGNED NOT NULL , INDEX `fk_assigned_ticket_idx` (`Ticket` ASC) , PRIMARY KEY (`Ticket`, `User`) , INDEX `fk_assigned_ams_user_idx` (`User` ASC) , @@ -90,7 +91,7 @@ ENGINE = InnoDB; DROP TABLE IF EXISTS `mydb`.`tag` ; CREATE TABLE IF NOT EXISTS `mydb`.`tag` ( - `TagId` INT NOT NULL AUTO_INCREMENT , + `TagId` INT UNSIGNED NOT NULL AUTO_INCREMENT , `Value` VARCHAR(60) NOT NULL , PRIMARY KEY (`TagId`) , UNIQUE INDEX `Value_UNIQUE` (`Value` ASC) ) @@ -103,8 +104,8 @@ ENGINE = InnoDB; DROP TABLE IF EXISTS `mydb`.`tagged` ; CREATE TABLE IF NOT EXISTS `mydb`.`tagged` ( - `Ticket` INT NOT NULL , - `Tag` INT NOT NULL , + `Ticket` INT UNSIGNED NOT NULL , + `Tag` INT UNSIGNED NOT NULL , PRIMARY KEY (`Ticket`, `Tag`) , INDEX `fk_tagged_tag_idx` (`Tag` ASC) , CONSTRAINT `fk_tagged_ticket` @@ -126,7 +127,7 @@ ENGINE = InnoDB; DROP TABLE IF EXISTS `mydb`.`ticket_content` ; CREATE TABLE IF NOT EXISTS `mydb`.`ticket_content` ( - `TContentId` INT NOT NULL AUTO_INCREMENT , + `TContentId` INT UNSIGNED NOT NULL AUTO_INCREMENT , `Content` TEXT NULL , PRIMARY KEY (`TContentId`) ) ENGINE = InnoDB @@ -139,11 +140,12 @@ DEFAULT CHARACTER SET = utf8; DROP TABLE IF EXISTS `mydb`.`ticket_reply` ; CREATE TABLE IF NOT EXISTS `mydb`.`ticket_reply` ( - `TReplyId` INT NOT NULL AUTO_INCREMENT , - `Ticket` INT NOT NULL , - `Author` INT NOT NULL , - `Content` INT NOT NULL , + `TReplyId` INT UNSIGNED NOT NULL AUTO_INCREMENT , + `Ticket` INT UNSIGNED NOT NULL , + `Author` INT UNSIGNED NOT NULL , + `Content` INT UNSIGNED NOT NULL , `Timestamp` TIMESTAMP NULL , + `Hidden` TINYINT(1) NULL DEFAULT 0 , PRIMARY KEY (`TReplyId`) , INDEX `fk_ticket_reply_ticket_idx` (`Ticket` ASC) , INDEX `fk_ticket_reply_ams_user_idx` (`Author` ASC) , @@ -172,7 +174,7 @@ ENGINE = InnoDB; DROP TABLE IF EXISTS `mydb`.`ticket_group` ; CREATE TABLE IF NOT EXISTS `mydb`.`ticket_group` ( - `TGroupId` INT NOT NULL AUTO_INCREMENT , + `TGroupId` INT UNSIGNED NOT NULL AUTO_INCREMENT , `Title` VARCHAR(80) NOT NULL , PRIMARY KEY (`TGroupId`) , UNIQUE INDEX `Title_UNIQUE` (`Title` ASC) ) @@ -185,8 +187,8 @@ ENGINE = InnoDB; DROP TABLE IF EXISTS `mydb`.`in_group` ; CREATE TABLE IF NOT EXISTS `mydb`.`in_group` ( - `Ticket_Group` INT NOT NULL , - `Ticket` INT NOT NULL , + `Ticket_Group` INT UNSIGNED NOT NULL , + `Ticket` INT UNSIGNED NOT NULL , PRIMARY KEY (`Ticket_Group`, `Ticket`) , INDEX `fk_in_group_ticket_group_idx` (`Ticket_Group` ASC) , INDEX `fk_in_group_ticket_idx` (`Ticket` ASC) , @@ -203,6 +205,132 @@ CREATE TABLE IF NOT EXISTS `mydb`.`in_group` ( ENGINE = InnoDB; +-- ----------------------------------------------------- +-- Table `mydb`.`ticket_log` +-- ----------------------------------------------------- +DROP TABLE IF EXISTS `mydb`.`ticket_log` ; + +CREATE TABLE IF NOT EXISTS `mydb`.`ticket_log` ( + `TLogId` INT UNSIGNED NOT NULL AUTO_INCREMENT , + `Timestamp` TIMESTAMP NOT NULL , + `Query` VARCHAR(255) NOT NULL , + `Ticket` INT UNSIGNED NOT NULL , + `Author` INT(10) UNSIGNED NULL , + PRIMARY KEY (`TLogId`) , + INDEX `fk_ticket_log_ticket1` (`Ticket` ASC) , + INDEX `fk_ticket_log_ticket_user1` (`Author` ASC) , + CONSTRAINT `fk_ticket_log_ticket1` + FOREIGN KEY (`Ticket` ) + REFERENCES `mydb`.`ticket` (`TId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT `fk_ticket_log_ticket_user1` + FOREIGN KEY (`Author` ) + REFERENCES `mydb`.`ticket_user` (`TUserId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION) +ENGINE = InnoDB; + + +-- ----------------------------------------------------- +-- Table `mydb`.`support_group` +-- ----------------------------------------------------- +DROP TABLE IF EXISTS `mydb`.`support_group` ; + +CREATE TABLE IF NOT EXISTS `mydb`.`support_group` ( + `SGroupId` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT , + `Name` VARCHAR(22) NOT NULL , + `Tag` VARCHAR(7) NOT NULL , + PRIMARY KEY (`SGroupId`) , + UNIQUE INDEX `Name_UNIQUE` (`Name` ASC) , + UNIQUE INDEX `Tag_UNIQUE` (`Tag` ASC) ) +ENGINE = InnoDB; + + +-- ----------------------------------------------------- +-- Table `mydb`.`in_support_group` +-- ----------------------------------------------------- +DROP TABLE IF EXISTS `mydb`.`in_support_group` ; + +CREATE TABLE IF NOT EXISTS `mydb`.`in_support_group` ( + `User` INT(10) UNSIGNED NOT NULL , + `Group` INT(10) UNSIGNED NOT NULL , + INDEX `fk_in_support_group_ticket_user1` (`User` ASC) , + INDEX `fk_in_support_group_support_group1` (`Group` ASC) , + CONSTRAINT `fk_in_support_group_ticket_user1` + FOREIGN KEY (`User` ) + REFERENCES `mydb`.`ticket_user` (`TUserId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT `fk_in_support_group_support_group1` + FOREIGN KEY (`Group` ) + REFERENCES `mydb`.`support_group` (`SGroupId` ) + ON DELETE CASCADE + ON UPDATE NO ACTION) +ENGINE = InnoDB; + + +-- ----------------------------------------------------- +-- Table `mydb`.`forwarded` +-- ----------------------------------------------------- +DROP TABLE IF EXISTS `mydb`.`forwarded` ; + +CREATE TABLE IF NOT EXISTS `mydb`.`forwarded` ( + `Group` INT(10) UNSIGNED NOT NULL , + `Ticket` INT UNSIGNED NOT NULL , + INDEX `fk_forwarded_support_group1` (`Group` ASC) , + INDEX `fk_forwarded_ticket1` (`Ticket` ASC) , + CONSTRAINT `fk_forwarded_support_group1` + FOREIGN KEY (`Group` ) + REFERENCES `mydb`.`support_group` (`SGroupId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT `fk_forwarded_ticket1` + FOREIGN KEY (`Ticket` ) + REFERENCES `mydb`.`ticket` (`TId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION) +ENGINE = InnoDB; + + +-- ----------------------------------------------------- +-- Table `mydb`.`email` +-- ----------------------------------------------------- +DROP TABLE IF EXISTS `mydb`.`email` ; + +CREATE TABLE IF NOT EXISTS `mydb`.`email` ( + `MailId` INT NOT NULL AUTO_INCREMENT , + `Recipient` VARCHAR(50) NULL , + `Subject` VARCHAR(60) NULL , + `Body` VARCHAR(400) NULL , + `Status` VARCHAR(45) NULL , + `Attempts` VARCHAR(45) NULL DEFAULT 0 , + `Sender` INT(10) UNSIGNED NOT NULL , + `UserId` INT(10) UNSIGNED NOT NULL , + `MessageId` VARCHAR(45) NOT NULL , + `TicketId` INT UNSIGNED NOT NULL , + PRIMARY KEY (`MailId`) , + INDEX `fk_email_ticket_user1` (`Sender` ASC) , + INDEX `fk_email_ticket_user2` (`UserId` ASC) , + INDEX `fk_email_ticket1` (`TicketId` ASC) , + CONSTRAINT `fk_email_ticket_user1` + FOREIGN KEY (`Sender` ) + REFERENCES `mydb`.`ticket_user` (`TUserId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT `fk_email_ticket_user2` + FOREIGN KEY (`UserId` ) + REFERENCES `mydb`.`ticket_user` (`TUserId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT `fk_email_ticket1` + FOREIGN KEY (`TicketId` ) + REFERENCES `mydb`.`ticket` (`TId` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION) +ENGINE = InnoDB; + + SET SQL_MODE=@OLD_SQL_MODE; SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/sql/ticketsystemmodel.mwb b/code/ryzom/tools/server/ryzom_ams/www/html/sql/ticketsystemmodel.mwb index 53f58f037..baf11d335 100644 Binary files a/code/ryzom/tools/server/ryzom_ams/www/html/sql/ticketsystemmodel.mwb and b/code/ryzom/tools/server/ryzom_ams/www/html/sql/ticketsystemmodel.mwb differ diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/table.php b/code/ryzom/tools/server/ryzom_ams/www/html/table.php index d0eb7d815..0a023296c 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/table.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/table.php @@ -210,6 +210,710 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/createticket.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/createticket.tpl index 0b2ad2813..bd0564932 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/templates/createticket.tpl +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/createticket.tpl @@ -37,7 +37,7 @@
    - +
    diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout.tpl index 32088c7b8..f8fb5078c 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout.tpl +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout.tpl @@ -67,7 +67,7 @@ - Ryzom Core Logo + Ryzom Core Logo
    diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout_admin.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout_admin.tpl index cd7bc60ad..c50c1c20d 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout_admin.tpl +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout_admin.tpl @@ -5,10 +5,11 @@
  • Profile
  • Settings
  • -
  • Liblist
  • -
  • UserList
  • +
  • Users
  • +
  • Queues
  • +
  • Support Groups
  • +
  • Syncing
  • Logout
  • - {/block} diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout_mod.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout_mod.tpl new file mode 100644 index 000000000..e0a77d99a --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout_mod.tpl @@ -0,0 +1,14 @@ +{extends file="layout.tpl"} +{block name=menu} + +
  • Dashboard
  • +
  • Profile
  • +
  • Settings
  • + +
  • Users
  • +
  • Queues
  • +
  • Support Groups
  • + +
  • Logout
  • +{/block} + diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/register.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/register.tpl index c97323520..bcf4de48b 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/templates/register.tpl +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/register.tpl @@ -105,7 +105,7 @@
    {/if} - +
    @@ -115,7 +115,7 @@ - +
    diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/settings.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/settings.tpl index f9ad610d9..0a7aa263c 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/templates/settings.tpl +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/settings.tpl @@ -13,7 +13,7 @@
    Change Password - {if !isset($isAdmin) or $isAdmin eq "FALSE"} + {if !isset($changesOther) or $changesOther eq "FALSE"}
    diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/sgroup_list.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/sgroup_list.tpl new file mode 100644 index 000000000..57ab6e01f --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/sgroup_list.tpl @@ -0,0 +1,108 @@ +{block name=content} + + +
    +
    +
    +

    List

    +
    + + +
    +
    +
    +
    + All support groups +
    + + +
    +
    + + + +
    + + + {if isset($ACTION_RESULT)} + +
    + + + +
    +

    Tickets

    +

    +

    + + + + + + + + + + + + + + + + +
    Show + + tickets + + to + + : + + or + + + + +
    +
    +

    +

    + + + + + + + + + + + + {foreach from=$tickets item=ticket} + + + + + + + + + + + {/foreach} +
    IDTitleAssignedTimestampCategoryStatusSupportGroupActions
    {$ticket.tId}{$ticket.title}{if $ticket.assignedText neq ""} {$ticket.assignedText}{else} {$not_assigned} {/if}{$ticket.timestamp}{$ticket.category}{if $ticket.status eq 0}{else if $ticket.status eq 1}{else if $ticket.status eq 2}{/if}{$ticket.statusText} + + {if $ticket.forwardedGroupName eq "0"} + {$public_sgroup} + {else} + {$ticket.forwardedGroupName} + {/if} + + + {if $ticket.assigned eq 0} +
    + + + +
    + {else if $ticket.assigned eq $user_id} +
    + + + +
    + {/if} +
    +

    +
    + + + + {foreach from=$links item=link} + + {/foreach} + + +
    «{$link}»
    +
    +
    + + + + + + +
    + {if isset($ACTION_RESULT) and $ACTION_RESULT eq "SUCCESS_ASSIGNED"} +

    + {$success_assigned} +

    + {else if isset($ACTION_RESULT) and $ACTION_RESULT eq "SUCCESS_UNASSIGNED"} +

    + {$success_unassigned} +

    + {else if isset($ACTION_RESULT) and $ACTION_RESULT eq "TICKET_NOT_EXISTING"} +

    + {$ticket_not_existing} +

    + {else if isset($ACTION_RESULT) and $ACTION_RESULT eq "ALREADY_ASSIGNED"} +

    + {$ticket_already_assigned} +

    + {else if isset($ACTION_RESULT) and $ACTION_RESULT eq "NOT_ASSIGNED"} +

    + {$ticket_not_assigned} +

    + {/if} +
    + + {/if} +
    +
    +
    + +
    + + + + + + + +
    + + + + +
    + + + + + +
    Show TicketShow Ticket Log
    +
    +
    +
    + + + + + + + + + +

    Reply ID#{$reply_id} of Ticket #{$ticket_id}

    +
    + + + + + + + + + + +
    + + +
    +
    + + +
    + + +
    + + +
    +

    Reply:

    +

    + + + + +
    +

    + {$reply_timestamp} + {if $author_permission eq '1'} + {if isset($isMod) and $isMod eq "TRUE"} {$authorName}{else} {$authorName} {/if} + {else if $reply.permission gt '1'} + {if isset($isMod) and $isMod eq "TRUE"} {$authorName}{else} {$authorName} {/if} + {/if}

    +

    {$reply_content}

    +
    +

    +
    +
    +
    +
    + +
    + + + + + + + + + +

    Support Group: {$groupsname}

    +
    + + + + + + + + + + +
    + + +
    +
    + + + +
    + + +
    + + +
    +

    Add user to the list

    + {if isset($isAdmin) && $isAdmin eq 'TRUE'} +
    + + + + + +
    Username:
    + + + +

    + +

    + + {if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "SUCCESS"} +

    + {$add_to_group_success} +

    + {else if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "ALREADY_ADDED"} +

    + {$user_already_added} +

    + {else if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "GROUP_NOT_EXISTING"} +

    + {$group_not_existing} +

    + {else if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "USER_NOT_EXISTING"} +

    + {$user_not_existing} +

    + {else if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "NOT_MOD_OR_ADMIN"} +

    + {$not_mod_or_admin} +

    + {/if} +
    + {/if} +
    +
    +
    + + +
    + + +
    +

    All members

    + + + + + {if isset($isAdmin) && $isAdmin eq 'TRUE'}{/if} + + + {foreach from=$userlist item=user} + + + + {if isset($isAdmin) && $isAdmin eq 'TRUE'}{/if} + + {/foreach} +
    IDNameAction
    {$user.tUserId}{$user.name}Delete
    +
    +
    +
    +
    + +
    + + + + + + + +
    + + + + +
    + + + {if isset($isMod) and $isMod eq "TRUE"}{/if} + + +
    Show Ticket LogSend Other Ticket
    +
    +
    +
    + + + + + + + + + +

    [{$t_title}-#{$ticket_tId}] {$ticket_title}

    +
    + + + + + + + + + + +
    + + +
    +
    + + +
    + + +
    + + +
    + + + + + {if isset($isMod) and $isMod eq "TRUE"} + +
    + + +
    + + + + + + + + + + + + + + + + +
    Submitted: {$ticket_timestamp}Last Updated: {$ticket_lastupdate}Status: {if $ticket_status neq 3}Open{/if} {if $ticket_status eq 3} {$ticket_statustext}{else}{$ticket_statustext} {/if}
    Category: {$ticket_category}Priority {$ticket_prioritytext}Support Group: + + {if $ticket_forwardedGroupName eq "0"} + {$public_sgroup} + {else} + {$ticket_forwardedGroupName} + {/if} + +
    Assigned To: {if $ticket_assignedTo neq ""} {$ticket_assignedToText}{else} {$not_assigned} {/if}
    +
    +
    + + {foreach from=$ticket_replies item=reply} + + + + {/foreach} + + {if $ticket_status eq 3} + + + + {/if} + + + + +
    + + +
    +

    + {$reply.timestamp} + {if $reply.permission eq '1'} + {if isset($isMod) and $isMod eq "TRUE"} {$reply.author}{else} {$reply.author} {/if} + {else if $reply.permission gt '1'} + {if isset($isMod) and $isMod eq "TRUE"} {$reply.author}{else} {$reply.author} {/if} + {/if} +

    +

    {$reply.replyContent}

    +
    +
    + + +
    +

    [Ticket is closed]

    +
    +
    + +
    + + + + + + {if $ticket_status neq 3} + + + + {if isset($isMod) and $isMod eq "TRUE"} + + + + {/if} + {/if} + + + + + + +
    +

    {$t_reply}:

    +
    Hide reply for user.
    + {if isset($isMod) and $isMod eq "TRUE"} + + + + + +
    + Change status to + + + Change priority to + +
    + {/if} +
    + + + +
    +
    +
    +
    + + +
    + + + + + +
    +

    + Ticket Assigning: + {if $ticket_assignedTo eq 0} +

    + + + +
    + {else if $ticket_assignedTo eq $user_id} +
    + + + +
    + {/if} +

    + {if isset($ACTION_RESULT) and $ACTION_RESULT eq "SUCCESS_ASSIGNED"} +

    + {$success_assigned} +

    + {else if isset($ACTION_RESULT) and $ACTION_RESULT eq "SUCCESS_UNASSIGNED"} +

    + {$success_unassigned} +

    + {else if isset($ACTION_RESULT) and $ACTION_RESULT eq "TICKET_NOT_EXISTING"} +

    + {$ticket_not_existing} +

    + {else if isset($ACTION_RESULT) and $ACTION_RESULT eq "ALREADY_ASSIGNED"} +

    + {$ticket_already_assigned} +

    + {else if isset($ACTION_RESULT) and $ACTION_RESULT eq "NOT_ASSIGNED"} +

    + {$ticket_not_assigned} +

    + {/if} + + +
    +

    + Forward to Group: +

    + + + + + +
    +

    + {if isset($ACTION_RESULT) and $ACTION_RESULT eq "INVALID_SGROUP"} +

    + {$invalid_sgroup} +

    + {else if isset($ACTION_RESULT) and $ACTION_RESULT eq "TICKET_NOT_EXISTING"} +

    + {$ticket_not_existing} +

    + {else if isset($ACTION_RESULT) and $ACTION_RESULT eq "SUCCESS_FORWARDED"} +

    + {$success_forwarded} +

    + {/if} +
    +
    +
    + {/if} + +
    +
    +
    +
    +
    + +
    + + + + + + + +
    + + + + +
    + + + + +
    Show Ticket
    +
    +
    +
    + + + + + + + + + +

    Log of Ticket #{$ticket_id}

    +
    + + + + + + + + + + +
    + + +
    +
    + + +
    + + +
    + + +
    +

    Title: {$ticket_title}

    +

    + + + + + + + + {foreach from=$ticket_logs item=log} + + + + + + {/foreach} + +
    IDTimestampQuery
    {$log.tLogId}{$log.timestamp}{$log.query}
    +

    +
    +
    +
    +
    + +
    + + + + + + + +
    + + + + +
    + + + + + {if isset($isAdmin) and $isAdmin eq 'TRUE' and $target_id neq 1} + {if $userPermission eq 1} + + + {else if $userPermission eq 2 } + + + {else if $userPermission eq 3 } + + + {/if} + {/if} + +
    Edit UserSend TicketMake ModeratorMake AdminDemote to UserMake AdminDemote to UserDemote to Moderator
    +
    +
    +
    + + + + + + + + + +

    Profile of {$target_name}

    +
    + + + + + + + + + + +
    + + +
    +
    + + + +
    + + +
    + + +
    + +

    Info

    + + + + + + + + + + + + {if $firstName neq ""} + + + + + {/if} + {if $lastName neq ""} + + + + + {/if} + {if $country neq ""} + + + + + {/if} + {if $gender neq 0} + + + {if $gender eq 1} + + {else if $gender eq 2} + + {/if} + + {/if} + +
    Email:{$mail}
    Role: + {if $userPermission eq 1}User{/if} + {if $userPermission eq 2}Moderator{/if} + {if $userPermission eq 3}Admin{/if} +
    Firstname:{$firstName}
    LastName:{$lastName}
    Country:{$country}
    Gender:♂♀
    +
    +
    +
    + + +
    + + +
    +

    Tickets

    + + + + + + + + + + + {foreach from=$ticketlist item=ticket} + + + + + + + + + {/foreach} + +
    IDTitleTimestampCategoryStatus
    {$ticket.tId}{$ticket.title}{$ticket.timestamp}{$ticket.category}{if $ticket.status eq 0} {/if} {$ticket.statusText}
    +
    +
    +
    +
    + +
    + + + + + + + + + +

    Members

    +
    + + + + + + + + + + +
    + + +
    +
    + + +
    + + +
    + + + +
    +

    All Acounts

    + + + + + + + + + + {foreach from=$userlist item=element} + + + + + {if $element.permission eq 1}{/if} + {if $element.permission eq 2}{/if} + {if $element.permission eq 3}{/if} + + + + {/foreach} +
    IdUsernameEmailPermissionAction
    {$element.id}{$element.username}{$element.email}UserModeratorAdmin + Show User + Edit User + {if isset($isAdmin) and $isAdmin eq 'TRUE' and $element.id neq 1} + {if $element.permission eq 1} + Make Moderator + Make Admin + {else if $element.permission eq 2 } + Demote to User + Make Admin + {else if $element.permission eq 3 } + Demote to User + Demote to Moderator + {/if} + {/if} +
    +
    + + + + {foreach from=$links item=link} + + {/foreach} + + +
    «{$link}»
    +
    +
    +
    +
    + +
    David R2012/01/01Member + Active + + + + View + + + + Edit + + + + Delete + +
    Chris Jack2012/01/01Member + Active + + + + View + + + + Edit + + + + Delete + +
    Jack Chris2012/01/01Member + Active + + + + View + + + + Edit + + + + Delete + +
    Muhammad Usman2012/01/01Member + Active + + + + View + + + + Edit + + + + Delete + +
    Sheikh Heera2012/02/01Staff + Banned + + + + View + + + + Edit + + + + Delete + +
    Helen Garner2012/02/01Staff + Banned + + + + View + + + + Edit + + + + Delete + +
    Saruar Ahmed2012/03/01Member + Pending + + + + View + + + + Edit + + + + Delete + +
    Ahemd Saruar2012/03/01Member + Pending + + + + View + + + + Edit + + + + Delete + +
    David R2012/01/01Member + Active + + + + View + + + + Edit + + + + Delete + +
    Chris Jack2012/01/01Member + Active + + + + View + + + + Edit + + + + Delete + +
    Jack Chris2012/01/01Member + Active + + + + View + + + + Edit + + + + Delete + +
    Muhammad Usman2012/01/01Member + Active + + + + View + + + + Edit + + + + Delete + +
    Sheikh Heera2012/02/01Staff + Banned + + + + View + + + + Edit + + + + Delete + +
    Helen Garner2012/02/01Staff + Banned + + + + View + + + + Edit + + + + Delete + +
    Saruar Ahmed2012/03/01Member + Pending + + + + View + + + + Edit + + + + Delete + +
    Ahemd Saruar2012/03/01Member + Pending + + + + View + + + + Edit + + + + Delete + +
    David R2012/01/01Member + Active + + + + View + + + + Edit + + + + Delete + +
    Chris Jack2012/01/01Member + Active + + + + View + + + + Edit + + + + Delete + +
    Jack Chris2012/01/01Member + Active + + + + View + + + + Edit + + + + Delete + +
    Muhammad Usman2012/01/01Member + Active + + + + View + + + + Edit + + + + Delete + +
    Sheikh Heera2012/02/01Staff + Banned + + + + View + + + + Edit + + + + Delete + +
    Helen Garner2012/02/01Staff + Banned + + + + View + + + + Edit + + + + Delete + +
    Saruar Ahmed2012/03/01Member + Pending + + + + View + + + + Edit + + + + Delete + +
    Ahemd Saruar2012/03/01Member + Pending + + + + View + + + + Edit + + + + Delete + +
    David R2012/01/01Member + Active + + + + View + + + + Edit + + + + Delete + +
    Chris Jack2012/01/01Member + Active + + + + View + + + + Edit + + + + Delete + +
    Jack Chris2012/01/01Member + Active + + + + View + + + + Edit + + + + Delete + +
    Muhammad Usman2012/01/01Member + Active + + + + View + + + + Edit + + + + Delete + +
    Sheikh Heera2012/02/01Staff + Banned + + + + View + + + + Edit + + + + Delete + +
    Helen Garner2012/02/01Staff + Banned + + + + View + + + + Edit + + + + Delete + +
    Saruar Ahmed2012/03/01Member + Pending + + + + View + + + + Edit + + + + Delete + +
    Ahemd Saruar2012/03/01Member + Pending + + + + View + + + + Edit + + + + Delete + +
    Habib Rizwan 2012/01/21
    + + + + + + {if isset($isAdmin) && $isAdmin eq 'TRUE'}{/if} + + + + {foreach from=$grouplist item=group} + + + + + {if isset($isAdmin) && $isAdmin eq 'TRUE'}{/if} + + {/foreach} + + +
    IDNameTagAction
    {$group.sGroupId}{$group.name}{$group.tag} Delete
    + + + + {if isset($isAdmin) && $isAdmin eq 'TRUE'} +
    +
    +

    Add

    +
    + + +
    +
    +
    +
    + + + + Add a support group + +
    + +
    +
    + +
    +
    +
    + +
    + +
    +
    + +
    +
    +
    + + + +
    + +
    + +
    +
    + + {if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "SUCCESS"} +
    + {$group_success} +
    + {else if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "NAME_TAKEN"} +
    + {$group_name_taken} +
    + {else if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "TAG_TAKEN"} +
    + {$group_tag_taken} +
    + {else if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "SIZE_ERROR"} +
    + {$group_size_error} +
    + {/if} + + +
    +
    +
    + {/if} + +{/block} + diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/show_queue.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/show_queue.tpl new file mode 100644 index 000000000..179767589 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/show_queue.tpl @@ -0,0 +1,197 @@ +{block name=content} +
    +
    +
    +

    Ticket Queue {$queue_view}

    +
    + + +
    +
    +
    +
    + Tickets + +
    +
    + Show + + tickets + + to + + + + + + + + + +
    + + +
    + + + {if isset($ACTION_RESULT) and $ACTION_RESULT eq "SUCCESS_ASSIGNED"} +
    + {$success_assigned} +
    + {else if isset($ACTION_RESULT) and $ACTION_RESULT eq "SUCCESS_UNASSIGNED"} +
    + {$success_unassigned} +
    + {else if isset($ACTION_RESULT) and $ACTION_RESULT eq "TICKET_NOT_EXISTING"} +
    + {$ticket_not_existing} +
    + {else if isset($ACTION_RESULT) and $ACTION_RESULT eq "ALREADY_ASSIGNED"} +
    + {$ticket_already_assigned} +
    + {else if isset($ACTION_RESULT) and $ACTION_RESULT eq "NOT_ASSIGNED"} +
    + {$ticket_not_assigned} +
    + {/if} + + + + + + + + + + + + + + + + {foreach from=$tickets item=ticket} + + + + + + + + + + + {/foreach} + + +
    IDTitleAssignedTimestampCategoryStatusSupportGroupActions
    {$ticket.tId}{$ticket.title}{if $ticket.assignedText neq ""} {$ticket.assignedText} {else} {$not_assigned} {/if}{$ticket.timestamp}{$ticket.category}{if $ticket.status eq 0} {/if} {$ticket.statusText} + + {if $ticket.forwardedGroupName eq "0"} + {$public_sgroup} + {else} + {$ticket.forwardedGroupName} + {/if} + + + {if $ticket.assigned eq 0} +
    + + + +
    + {else if $ticket.assigned eq $user_id} +
    + + + +
    + {/if} +
    + +
    +
      +
    • «
    • + {foreach from=$links item=link} +
    • {$link}
    • + {/foreach} +
    • »
    • +
    +
    +
    +
    +
    + +
    +
    +

    Actions

    +
    + + +
    +
    + +
    +
    + + + + + + +{/block} + diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/show_reply.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/show_reply.tpl new file mode 100644 index 000000000..65f3f679b --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/show_reply.tpl @@ -0,0 +1,33 @@ +{block name=content} +
    +
    +
    +

    Show Reply

    +
    + + +
    +
    +
    +
    + Reply ID#{$reply_id} of Ticket #{$ticket_id} + + + + +
    +

    {$reply_timestamp} + {if $author_permission eq '1'} + {if isset($isMod) and $isMod eq "TRUE"} {$authorName}{else} {$authorName} {/if}

    + {else if $author_permission gt '1'} + {if isset($isMod) and $isMod eq "TRUE"} {$authorName}{else} {$authorName} {/if}

    + {/if} +

    {if $hidden eq 1}{/if}{$reply_content}{if $hidden eq 1}{/if}

    + +
    +
    +
    +
    +
    +{/block} + diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/show_sgroup.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/show_sgroup.tpl new file mode 100644 index 000000000..15c1d7b80 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/show_sgroup.tpl @@ -0,0 +1,103 @@ +{block name=content} +
    +
    +
    +

    {$groupsname} List

    +
    + + +
    +
    +
    +
    + All members of the {$groupsname} Support Group + + + + + + {if isset($isAdmin) && $isAdmin eq 'TRUE'}{/if} + + + + + {foreach from=$userlist item=user} + + + + {if isset($isAdmin) && $isAdmin eq 'TRUE'}{/if} + + {/foreach} + + +
    IDNameAction
    {$user.tUserId}{$user.name} Delete
    +
    +
    +
    + + {if isset($isAdmin) && $isAdmin eq 'TRUE'} +
    +
    +

    Add User

    +
    + + +
    +
    +
    +
    + +
    + + Add a user to the group '{$groupsname}' + +
    + +
    +
    + +
    +
    +
    + + + + +
    + +
    + +
    +
    + + {if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "SUCCESS"} +
    + {$add_to_group_success} +
    + {else if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "ALREADY_ADDED"} +
    + {$user_already_added} +
    + {else if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "GROUP_NOT_EXISTING"} +
    + {$group_not_existing} +
    + {else if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "USER_NOT_EXISTING"} +
    + {$user_not_existing} +
    + {else if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "NOT_MOD_OR_ADMIN"} +
    + {$not_mod_or_admin} +
    + {/if} +
    + +
    +
    +
    + {/if} +
    + +{/block} + diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/show_ticket.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/show_ticket.tpl new file mode 100644 index 000000000..aae1bf9f9 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/show_ticket.tpl @@ -0,0 +1,235 @@ +{block name=content} +
    +
    +
    +

    {$t_title} #{$ticket_tId}

    +
    + + +
    +
    +
    +
    + {$title}: {$ticket_title} + + +
    + + + + + + + + + + + + + + + + +
    Original Submitted: {$ticket_timestamp}Last Updated: {$ticket_lastupdate}Status: {if $ticket_status neq 3}Open{/if} {$ticket_statustext}
    Category: {$ticket_category}Priority: {$ticket_prioritytext}Support Group: + + {if $ticket_forwardedGroupName eq "0"} + {$public_sgroup} + {else} + {$ticket_forwardedGroupName} + {/if} + +
    Assigned To: {if $ticket_assignedTo neq ""} {$ticket_assignedToText} {else} {$not_assigned} {/if}
    + + + + + {foreach from=$ticket_replies item=reply} + + + + {/foreach} + + {if $ticket_status eq 3} + + + + {/if} + + + + + +
    +

    + {$reply.timestamp} + {if $reply.permission eq '1'} + {if isset($isMod) and $isMod eq "TRUE"} {$reply.author}{else} {$reply.author} {/if} + {else if $reply.permission gt '1'} + {if isset($isMod) and $isMod eq "TRUE"} {$reply.author}{else} {$reply.author} {/if} + {/if} +

    +

    {if $reply.hidden eq 1}{/if}{$reply.replyContent}{if $reply.hidden eq 1}{/if}

    +
    +

    Ticket is closed.

    +
    + + {if $ticket_status neq 3} + {$t_reply}: +
    + +
    +
    + +
    +
    +
    + {if isset($isMod) and $isMod eq "TRUE"} +
    + +
    +
    + Hide reply for user. +
    +
    +
    + {/if} + {/if} + {if isset($isMod) and $isMod eq "TRUE"} +
    + +
    + +
    +
    +
    + +
    + +
    +
    + {/if} + + +
    + +
    + +
    +
    + +
    +
    +
    +
    + + + +
    +
    +

    Actions

    +
    + + +
    +
    +
    +
    + + {if isset($isMod) and $isMod eq "TRUE"} + + Ticket Assigning + {if $ticket_assignedTo eq 0} +
    + + + +
    + {else if $ticket_assignedTo eq $user_id} +
    + + + +
    + {/if} + + {if isset($ACTION_RESULT) and $ACTION_RESULT eq "SUCCESS_ASSIGNED"} +
    + {$success_assigned} +
    + {else if isset($ACTION_RESULT) and $ACTION_RESULT eq "SUCCESS_UNASSIGNED"} +
    + {$success_unassigned} +
    + {else if isset($ACTION_RESULT) and $ACTION_RESULT eq "TICKET_NOT_EXISTING"} +
    + {$ticket_not_existing} +
    + {else if isset($ACTION_RESULT) and $ACTION_RESULT eq "ALREADY_ASSIGNED"} +
    + {$ticket_already_assigned} +
    + {else if isset($ACTION_RESULT) and $ACTION_RESULT eq "NOT_ASSIGNED"} +
    + {$ticket_not_assigned} +
    + {/if} + + Forward to Group +
    + +
    +
    + +
    +
    + + +
    +
    + +
    +
    +
    + {if isset($ACTION_RESULT) and $ACTION_RESULT eq "INVALID_SGROUP"} +
    + {$invalid_sgroup} +
    + {else if isset($ACTION_RESULT) and $ACTION_RESULT eq "TICKET_NOT_EXISTING"} +
    + {$ticket_not_existing} +
    + {else if isset($ACTION_RESULT) and $ACTION_RESULT eq "SUCCESS_FORWARDED"} +
    + {$success_forwarded} +
    + {/if} + {/if} + Other actions +
    + + +
    +
    +
    +
    +
    +{/block} + diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/show_ticket_log.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/show_ticket_log.tpl new file mode 100644 index 000000000..f7d065306 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/show_ticket_log.tpl @@ -0,0 +1,38 @@ +{block name=content} +
    +
    +
    +

    Log of Ticket #{$ticket_id}

    +
    + + +
    +
    +
    +
    + Title: {$ticket_title} + + + + + + + + + + {foreach from=$ticket_logs item=log} + + + + + + {/foreach} + + +
    IDTimestampQuery
    {$log.tLogId}{$log.timestamp}{$log.query}
    +
    +
    +
    +
    +{/block} + \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/show_user.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/show_user.tpl index 0b2a57c2b..91bdc683f 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/templates/show_user.tpl +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/show_user.tpl @@ -17,6 +17,15 @@ Email: {$mail} + + + Role: + + {if $userPermission eq 1}User{/if} + {if $userPermission eq 2}Moderator{/if} + {if $userPermission eq 3}Admin{/if} + + {if $firstName neq ""} Firstname: @@ -68,6 +77,20 @@
  • Edit User
  • Send Ticket
  • + {if isset($isAdmin) and $isAdmin eq 'TRUE' and $target_id neq 1} + {if $userPermission eq 1} +
  • Make Moderator
  • +
  • Make Admin
  • + {else if $userPermission eq 2 } +
  • Demote to User
  • +
  • Make Admin
  • + {else if $userPermission eq 3 } +
  • Demote to User
  • +
  • Demote to Moderator
  • + {/if} +
  • + {/if} + @@ -90,6 +113,7 @@ + @@ -99,11 +123,12 @@ {foreach from=$ticketlist item=ticket} - + + - + {/foreach} diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/libuserlist.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/syncing.tpl similarity index 75% rename from code/ryzom/tools/server/ryzom_ams/www/html/templates/libuserlist.tpl rename to code/ryzom/tools/server/ryzom_ams/www/html/templates/syncing.tpl index 645de53f2..56bd0cca3 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/templates/libuserlist.tpl +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/syncing.tpl @@ -3,7 +3,7 @@
    -

    {$libuserlist_title}

    +

    {$syncing_title}

    @@ -13,10 +13,10 @@
    -

    {$libuserlist_info}

    +

    {$syncing_info}

    {if $shard eq "online"}
    - {$shard_online}{$libuserlist_sync} + {$shard_online}{$syncing_sync}
    ID Title Timestamp Category
    {$ticket.title}{$ticket.tId}{$ticket.title} {$ticket.timestamp} {$ticket.category}{$ticket.statusText}{if $ticket.status eq 0} {/if} {$ticket.statusText}