SUBST: add method to retrieve room preferences from a token
[citadel.git] / webcit / subst.c
index 52f50f4489d3a4e9f4827c0bcbe8101b91688b91..7443515e7bbaec272e78ab9e83995cc85667c42e 100644 (file)
@@ -448,6 +448,7 @@ int HaveTemplateTokenString(StrBuf *Target,
        case TYPE_STR:
        case TYPE_BSTR:
        case TYPE_PREFSTR:
+       case TYPE_ROOMPREFSTR:
        case TYPE_GETTEXT:
        case TYPE_SUBTEMPLATE:
                return 1;
@@ -509,6 +510,19 @@ void GetTemplateTokenString(StrBuf *Target,
                *Value = ChrPtr(Buf);
                *len = StrLength(Buf);
                break;
+       case TYPE_ROOMPREFSTR:
+               if (TP->Tokens->Params[N]->len == 0) {
+                       LogTemplateError(Target, 
+                                        "TokenParameter", N, TP, 
+                                        "Requesting parameter %d; of type PREFSTR, empty lookup string not admitted.", N);
+                       *len = 0;
+                       *Value = EmptyStr;
+                       break;
+               }
+               Buf = get_ROOM_PREFS(TKEY(N));
+               *Value = ChrPtr(Buf);
+               *len = StrLength(Buf);
+               break;
        case TYPE_LONG:
                LogTemplateError(Target, 
                                 "TokenParameter", N, TP, 
@@ -588,6 +602,19 @@ long GetTemplateTokenNumber(StrBuf *Target, WCTemplputParams *TP, int N, long df
                if (get_PREF_LONG(TKEY(N), &Ret, dflt))
                        return Ret;
                return 0;
+       case TYPE_ROOMPREFSTR:
+               LogTemplateError(Target, 
+                                "TokenParameter", N, TP, 
+                                "requesting a prefstring in param %d want a number", N);
+               if (TP->Tokens->Params[N]->len == 0) {
+                       LogTemplateError(Target, 
+                                        "TokenParameter", N, TP, 
+                                        "Requesting parameter %d; of type PREFSTR, empty lookup string not admitted.", N);
+                       return 0;
+               }
+               if (get_ROOM_PREFS_LONG(TKEY(N), &Ret, dflt))
+                       return Ret;
+               return 0;
        case TYPE_INTDEFINE:
        case TYPE_LONG:
                return TP->Tokens->Params[N]->lvalue;
@@ -730,6 +757,14 @@ int GetNextParameter(StrBuf *Buf,
                        ParamBrace = 1;
                }
        }
+       else if (*pch == '.') {
+               Parm->Type = TYPE_ROOMPREFSTR;
+               pch ++;
+               if (*pch == '(') {
+                       pch ++;
+                       ParamBrace = 1;
+               }
+       }
        else if (*pch == ';') {
                Parm->Type = TYPE_PREFINT;
                pch ++;