if StrBuf_ServGetln() is called in a loop, its return value has to be checked for...
[citadel.git] / webcit / useredit.c
index 05cf763affd83128ed51c0361ae9837cbf79a86f..c76188b4e1e0930bcb39fc44bd46b4040f14583b 100644 (file)
@@ -1,6 +1,3 @@
-/*
- * $Id$
- */
 
 #include "webcit.h"
 #include "webserver.h"
@@ -14,7 +11,7 @@
 void select_user_to_edit(const char *preselect)
 {
        output_headers(1, 0, 0, 0, 1, 0);
-       do_template("edituser_select", NULL);
+       do_template("aide_edituser_select", NULL);
         end_burst();
 }
 
@@ -255,7 +252,7 @@ HashList *iterate_load_userlist(StrBuf *Target, WCTemplputParams *TP)
 {
        int Done = 0;
        CompareFunc SortIt;
-       HashList *Hash;
+       HashList *Hash = NULL;
        StrBuf *Buf;
        UserListEntry* ul;
        char nnn[64];
@@ -272,8 +269,10 @@ HashList *iterate_load_userlist(StrBuf *Target, WCTemplputParams *TP)
 
                while (!Done) {
                        len = StrBuf_ServGetln(Buf);
-                       if ((len == 3) &&
-                           (strcmp(ChrPtr(Buf), "000")==0)) {
+                       if ((len <0) || 
+                           ((len == 3) &&
+                            strcmp(ChrPtr(Buf), "000")))
+                       {
                                Done = 1;
                                break;
                        }
@@ -290,10 +289,9 @@ HashList *iterate_load_userlist(StrBuf *Target, WCTemplputParams *TP)
                        SortByPayload(Hash, SortIt);
                else 
                        SortByPayload(Hash, CompareUID);
-               return Hash;
         }
        FreeStrBuf(&Buf);
-       return NULL;
+       return Hash;
 }
 
 
@@ -392,11 +390,16 @@ int ConditionalFlagINetEmail(StrBuf *Target, WCTemplputParams *TP)
 int ConditionalUserAccess(StrBuf *Target, WCTemplputParams *TP)
 {
        UserListEntry *ul = (UserListEntry*) CTX;
-
-       if (TP->Tokens->Params[3]->Type == TYPE_LONG)
-               return (TP->Tokens->Params[3]->lvalue == ul->AccessLevel);
-       else
+       
+       if (ul == NULL)
                return 0;
+
+       return GetTemplateTokenNumber(Target, 
+                                     TP, 
+                                     3, 
+                                     AxNewU)
+               ==
+               ul->AccessLevel;
 }
 
 /*
@@ -430,7 +433,7 @@ TRYAGAIN:
        Stat.highest_found = (-1);
        Done = 0;
        /* Search for the user's vCard */
-       if (load_msg_ptrs("MSGS ALL||||1", &Stat) > 0) {
+       if (load_msg_ptrs("MSGS ALL||||1", &Stat, NULL) > 0) {
                at = GetNewHashPos(WCC->summ, 0);
                while (GetNextHashPos(WCC->summ, at, &HKLen, &HashKey, &vMsg)) {
                        Msg = (message_summary*) vMsg;          
@@ -479,7 +482,7 @@ TRYAGAIN:
                        serv_puts("000");
                }
                else 
-                       lprintf(1, "Error while creating user vcard: %s\n", ChrPtr(Buf));
+                       syslog(1, "Error while creating user vcard: %s\n", ChrPtr(Buf));
                goto TRYAGAIN;
        }
        FreeStrBuf(&Buf);
@@ -584,7 +587,7 @@ void display_edituser(const char *supplied_username, int is_new) {
                        SubTP.Filter.ContextType = CTX_USERLIST;
                        SubTP.Context = UL;
                        output_headers(1, 0, 0, 0, 1, 0);
-                       DoTemplate(HKEY("userlist_detailview"), NULL, &SubTP);
+                       DoTemplate(HKEY("aide_edituser_detailview"), NULL, &SubTP);
                        end_burst();
                }
                DeleteUserListEntry(UL);
@@ -796,4 +799,12 @@ InitModule_USEREDIT
                         GroupchangenPosts,
                         CTX_USERLIST);
 
+       REGISTERTokenParamDefine(AxDeleted);
+       REGISTERTokenParamDefine(AxNewU);
+       REGISTERTokenParamDefine(AxProbU);
+       REGISTERTokenParamDefine(AxLocU);
+       REGISTERTokenParamDefine(AxNetU);
+       REGISTERTokenParamDefine(AxPrefU);
+       REGISTERTokenParamDefine(AxAideU);
 }
+