Begin removing the decimal point from our version number (901 instead of 9.01)
[citadel.git] / webcit / useredit.c
index a6041d7e6c58bd93266835578f56015023e5500e..e7ba2b2bbb5e7beca0c102288ccbf563154c1ca7 100644 (file)
@@ -451,6 +451,9 @@ void tmplput_USER_BIO(StrBuf *Target, WCTemplputParams *TP)
        long len;
 
        GetTemplateTokenString(Target, TP, 0, &who, &len);
+       if (len == 0) {
+               who = ChrPtr(WC->wc_fullname);
+       }
 
        Buf = NewStrBuf();
        serv_printf("RBIO %s", who);
@@ -472,29 +475,11 @@ void tmplput_USER_BIO(StrBuf *Target, WCTemplputParams *TP)
        FreeStrBuf(&Buf);
 }
 
+
 int Conditional_USER_HAS_PIC(StrBuf *Target, WCTemplputParams *TP)
 {
-       StrBuf *Buf;
-       const char *who;
-       long len;
-       int r = 0;
-
-       GetTemplateTokenString(Target, TP, 2, &who, &len);
-
-       Buf = NewStrBuf();
-       serv_printf("OIMG _userpic_|%s", who);
-       StrBuf_ServGetln(Buf);
-       if (GetServerStatus(Buf, NULL) != 2) {
-               r = 1;
-       }
-       else {
-               r = 0;
-       }
-       serv_puts("CLOS");
-       StrBuf_ServGetln(Buf);
-       GetServerStatus(Buf, NULL);
-       FreeStrBuf(&Buf);
-       return(r);
+       // ajc 2016apr10 this needs to be re-evaluated with the new protocol
+       return(0);
 }
 
 
@@ -527,7 +512,7 @@ TRYAGAIN:
        Stat.lowest_found = (-1);
        Stat.highest_found = (-1);
        /* Search for the user's vCard */
-       if (load_msg_ptrs("MSGS ALL||||1", NULL, &Stat, NULL) > 0) {
+       if (load_msg_ptrs("MSGS ALL||||1", NULL, NULL, &Stat, NULL, NULL, NULL, NULL, 0) > 0) {
                at = GetNewHashPos(WCC->summ, 0);
                while (GetNextHashPos(WCC->summ, at, &HKLen, &HashKey, &vMsg)) {
                        Msg = (message_summary*) vMsg;          
@@ -576,7 +561,7 @@ TRYAGAIN:
                        serv_puts("000");
                }
                else 
-                       syslog(1, "Error while creating user vcard: %s\n", ChrPtr(Buf));
+                       syslog(LOG_WARNING, "Error while creating user vcard: %s\n", ChrPtr(Buf));
                goto TRYAGAIN;
        }
        FreeStrBuf(&Buf);
@@ -793,6 +778,30 @@ void create_user(void) {
 }
 
 
+void display_userpic(void) {
+       off_t bytes;
+       StrBuf *Buf = NewStrBuf();
+       const char *username = bstr("user");
+       serv_printf("DLUI %s", username);
+       StrBuf_ServGetln(Buf);
+       if (GetServerStatus(Buf, NULL) == 6) {
+               StrBufCutLeft(Buf, 4);
+               bytes = StrBufExtract_long(Buf, 0, '|');
+               StrBuf *content_type = NewStrBuf();
+               StrBufExtract_token(content_type, Buf, 3, '|');
+               WC->WBuf = NewStrBuf();
+               StrBuf_ServGetBLOBBuffered(WC->WBuf, bytes);
+               http_transmit_thing(ChrPtr(content_type), 0);
+               FreeStrBuf(&content_type);
+       }
+       else {
+               output_error_pic("", "");
+       }
+       FreeStrBuf(&Buf);
+}
+
+
+
 void _select_user_to_edit(void) {
        select_user_to_edit(NULL);
 }
@@ -811,6 +820,7 @@ InitModule_USEREDIT
        WebcitAddUrlHandler(HKEY("display_edituser"), "", 0, _display_edituser, 0);
        WebcitAddUrlHandler(HKEY("edituser"), "", 0, edituser, 0);
        WebcitAddUrlHandler(HKEY("create_user"), "", 0, create_user, 0);
+       WebcitAddUrlHandler(HKEY("userpic"), "", 0, display_userpic, 0);
 
        RegisterNamespace("USERLIST:USERNAME",      0, 1, tmplput_USERLIST_UserName, NULL, CTX_USERLIST);
        RegisterNamespace("USERLIST:PASSWD",        0, 1, tmplput_USERLIST_Password, NULL, CTX_USERLIST);