/* This file is part of Bolixo. Bolixo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Bolixo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Bolixo. If not, see . */ #include #include #include #include #include #include #include #include #define DEFINE_USERINFO #include "util.h" #include "../bolixo.h" #include "../bolixo.m" #include "webtabs.h" #include #include #include "document.h" #undef INSTRUMENT #include "../instrument.h" #include "../proto/bod_client.protoch" #include "../proto/bolixod_client.protodef" #include "../proto/bolixoapi.protoch" #include "w_var.h" #include #include "steps.h" #include void index_doc (DOCUMENT_POINTER &pt, DOC_ID &jump, bool index); void index_doc (DOCUMENT_POINTER &pt, DOC_ID &jump); static W_SSTRING w_upload2("upload2"); // Fields for config_search static W_SSTRING w_s_user("s_user"); static W_SSTRING w_s_name("s_name"); static W_SSTRING w_s_city("s_city"); static void index_field (_F_form *c, bool newline,unsigned colspan, const char *title, W_SSTRING &var, unsigned size) { if (newline) htmlout (""); htmlprintf ("%s\n",title,colspan); char tmp[100]; snprintf (tmp,sizeof(tmp),"size=%u",size); c->field_string (var,tmp); } static void index_field (_F_form *c, bool newline, const char *title, W_SSTRING &var) { index_field (c,newline,1,title,var,25); } /* Define a form field to edit the access of a group within a list */ static void index_field_access (_F_form *c, W_VAR &var) { c->field_list (var,""); c->field_list_item ("",MSG_U(I_INHERIT,"inherit")); c->field_list_item ("R",MSG_U(I_READONLY,"read-only")); c->field_list_item ("W",MSG_U(I_READWRITE,"read-write")); c->field_list_end(); } static void index_field_group (_F_form *c, W_VAR &var, const vector &groups) { c->field_list (var,""); c->field_list_item("",""); for (auto &s:groups) c->field_list_item (s.c_str(),s.c_str()); c->field_list_end(); } /* Update a group definition in a list */ static void index_set_group (CONNECT_INFO &con, const char *list, const char *group, const char *access, bool &fail) { glocal bool fail = false; glocal const char *groupname = group; (con,w_session.c_str(),list,glocal.groupname,access,""); if (!success){ htmlprintf (MSG_U(E_UPDGROUP,"Failure to update group %s: %s
\n"),glocal.groupname,msg); glocal.fail = true; }
if (glocal.fail) fail = true; }
static void index_set_group (CONNECT_INFO &con, const char *list, W_SSTRING &group, W_SSTRING &access, vector &groups, bool &fail) { const char *groupname = group.c_str(); if (groupname[0] != '\0'){ groups.push_back(groupname); index_set_group (con,list,groupname,access.c_str(),fail); } } static void index_delete_new_from_old(const vector &news, vector &old) { for (auto &n:news){ auto p = find(old.begin(),old.end(),n); if (p != old.end()){ old.erase(p); } } } static const char *adding = "__add__"; static bool profile_formactive (_F_webtabs &c, W_SSTRING &var) { const char *state = c.getstate(); if (w_add.isset()){ c.setstate(adding); }else if (var.isset()){ c.setstate(var.c_str()); }else if (state[0] != '\0'){ if (strcmp(state,adding)==0){ w_add.setinitval("1"); }else{ var.setinitval(state); } } return var.isset() || w_add.isset(); } static bool profile_formactive (_F_webtabs &c) { const char *state = c.getstate(); if (w_add.isset()){ c.setstate(adding); }else if (state[0] != '\0'){ if (strcmp(state,adding)==0){ w_add.setinitval("1"); } } return w_add.isset(); } /* Return the proper image to tell if this ID has a notification or not */ static const char *profile_notify_icon (const string &id) { string tmp = string("profile:")+id; return userinfo.notifies.count(tmp) > 0 ? "/new.png" : "/seen.png"; } /* Set the check boxes for the notitications dialog */ static void profile_set_notifies (_F_form &f, PARAM_STRING key) { /- f.field_checkbox(w_notify_ui,key,""); /- f.field_checkbox(w_notify_email,key,""); } /* Upload a file to the public folder */ static void profile_upload (CONNECT_INFO &con, W_SSTRING &var, const char *fname, bool &fail) { glocal con; const char *tempname = tlmpweb_getfilename(var); string filepath = string_f("/projects/%s/public/%s",userinfo.name.c_str(),fname); glocal bool file_exist = util_entrytype(con,filepath) == ENTRY_FILE; (filepath,tempname,fail); if (glocal.file_exist){ (glocal.con,w_session.c_str(),filepath,content,more,""); glocal.sendfile.sethandle(handle); glocal.sendfile.setresult(success,msg); }else{ (glocal.con,w_session.c_str(),filepath,content,more,""); glocal.sendfile.sethandle(handle); glocal.sendfile.setresult(success,msg); } (glocal.con,w_session.c_str(),handle,content,more); glocal.sendfile.setresult(success,msg); } static void config_form_title(const char *title) { htmlprintf ("\n",tlmpweb_ismobile() ? "1.3" : "1.5"); htmlout (title); /- } static void config_printmsg(const char *color, const string &msg) { if (msg.size() > 0){ htmlprintf (" %s\n",color,msg.c_str()); } } /* Create a small dialog to perform a search on bolixo.org. The result is presented in a table. When the user click on one record, it is added to the form for either interest or contact request. It is placed in userid and the caller uses it to place the value in its form. */ static void config_search(const char *id, string &userid) { glocal userid; glocal id; DIV c(TAB_SUBTABS); c.borderradius(5).border(1,"black").vmargins(2,5).paddings(2,2).vpaddings(2,2).print(); { DIV f; f.id(TAB_FORM).bg("#A0A0A0").borderradius(5).print(); (string_f("search:%s",glocal.id)); /- bool mobile = tlmpweb_ismobile(); if (mobile){ htmlprintf ("
%s%s\n",MSG_U(I_USERID,"User ID"),MSG_U(I_USERNAME,"Name")); }else{ htmlprintf ("
%s%s%s\n",MSG_R(I_USERID),MSG_R(I_USERNAME),MSG_U(I_CITY,"City")); } /-
field_string (w_s_user,"size=15"); /- field_string (w_s_name,"size=15"); if (!mobile){ /- field_string (w_s_city,"size=15"); } /-
button_submit(MSG_R(B_SEARCH)); /-
return true; keepediting = true;
} static WEBID id("tab:search"); (id,currents[id.c_str()],offsets[id.c_str()],20); glocal nbskip; glocal selected_row; if (w_s_user.size() > 0 || w_s_name.size() > 0 || w_s_city.size() > 0){ FILTER filter; CONNECT_HTTP_INFO hcon; hcon.init (util_getdirserver()); hcon.setpageapi ("bolixoapi"); if (util_getnonstrict()) hcon.setnonstrictmode(); filter.user = w_s_user.c_str(); filter.fullname = w_s_name.c_str(); filter.city = w_s_city.c_str(); (hcon,filter,nbskip,nblines); unsigned noline = glocal.nbskip; glocal.webtable.sethead("%s\t%s\t%s",MSG_R(I_USERID),MSG_R(I_USERNAME),MSG_R(I_CITY)); const char *dirserver = util_getdirserver(); unsigned mini_image_width = tlmpweb_ismobile() ? 60 : 40; for (auto &u:users){ if (noline == glocal.selected_row){ const char *nodename; if (is_start_any_ofnc(u.nodename,nodename,"https://","http://")){ glocal.userid = string_f("%s@%s",u.user,nodename); } } glocal.webtable.setclickopt (true,"",""); glocal.webtable.setrow("white",noline,"%s\t%s\t%s",u.user,u.fullname,u.city); string photo_url,mini_photo_url; if (u.photo_modified[0] != '\0'){ string tmp = util_flipspaces(u.photo_modified); photo_url = string_f ("\n" ,dirserver,u.user,u.nodename,tmp.c_str()); } if (u.mini_photo_modified[0] != '\0'){ string tmp = util_flipspaces(u.mini_photo_modified); mini_photo_url = string_f ("\n" ,mini_image_width,dirserver,u.user,u.nodename,tmp.c_str()); } if (photo_url.size() > 0 || mini_photo_url.size() > 0){ glocal.webtable.setrow("white",noline,"%s\t%s",mini_photo_url.c_str(),photo_url.c_str()); } noline++; } } }
struct GROUP_MEMBER{ string user; string access; string role; GROUP_MEMBER(PARAM_STRING _user, PARAM_STRING _access, PARAM_STRING _role) : user(_user.ptr), access(_access.ptr), role(_role.ptr) { } }; static void config_parsemembers(vector &members) { const char *pt = w_content.c_str(); while (*pt != '\0'){ string word; pt = str_copyword(word,pt); vector tb; int n = str_splitline(word.c_str(),':',tb); if (n > 0){ while (tb.size() < 3) tb.push_back(""); members.emplace_back (tb[0],tb[1],tb[2]); } } } void profile(CONNECT_INFO &con, CONNECT_INFO &con_sess, vector &docpointers) { glocal CONNECT_INFO con = con; glocal CONNECT_INFO *con_sess = &con_sess; glocal vector *docpointers = &docpointers; static unsigned size[5]={15,45,40,0,0}; ("profile",tabs,size); static WEBID id("tab:profiles"); (id,currents[id.c_str()]); sethead (MSG_U(H_PROFILE,"\tProfiles")); vector> t={ {"Account",MSG_U(T_ACCOUNT,"Account"),MSG_R(T_ACCOUNT)}, {"Notifications",MSG_U(T_NOTIFICATIONS,"Notifications"),MSG_R(T_NOTIFICATIONS)}, {"Interests",MSG_U(T_INTERESTS,"Interests"),MSG_R(T_INTERESTS)}, {"Contacts",MSG_U(T_CONTACTS,"Contacts"),MSG_U(T_CONTACTSTOYOU,"Contact requests to you")}, {"Contact-req",MSG_U(T_CONTACT_REQS,"Requests"),MSG_U(T_REQUESTSBYYOU,"Contact requests from you")}, {"Projects",MSG_U(T_PROJECTS,"Projects"),MSG_R(T_PROJECTS)}, {"Groups",MSG_U(T_GROUPS,"Groups"),MSG_R(T_GROUPS)} }; unsigned rownum=0; unsigned status_width = tlmpweb_ismobile() ? 60 : 20; for (auto s:t){ if (glocal.webtabs.selected(get<0>(s))) setcurrent(rownum); string add = string_f("webtab_add=1:%s~%s",get<0>(s).c_str(),get<1>(s).c_str()); setclickopt (true,"",add); setrow ("white",rownum,"\t%s",status_width,profile_notify_icon(get<0>(s)),get<2>(s).c_str()); rownum++; } if (strcmp(id,"helpgroups")==0){ index_doc((*glocal.docpointers)[SECTION_GROUPS],section_groups); }else if (strcmp(id,"helpprojects")==0){ index_doc((*glocal.docpointers)[SECTION_PROJECTS],section_projects); }else if (strcmp(id,"helpcontacts")==0){ index_doc((*glocal.docpointers)[SECTION_CONTACTS],section_contacts); }else if (strcmp(id,"helpcontact-req")==0){ index_doc((*glocal.docpointers)[SECTION_CONTACT_REQ],section_contact_req); }else if (strcmp(id,"helpaccount")==0){ index_doc((*glocal.docpointers)[SECTION_ACCOUNT],section_account); }else if (strcmp(id,"helpinterests")==0){ index_doc((*glocal.docpointers)[SECTION_INTERESTS],section_interests); }else if (strcmp(id,"helpnotifications")==0){ index_doc((*glocal.docpointers)[SECTION_NOTIFICATIONS],section_notifications); }else if (strcmp(id,"helpmain")==0){ index_doc((*glocal.docpointers)[SECTION_NONE],section_none); }else if (strncmp(id,"project:",8)==0){ glocal const char *prjname = id+8; glocal bool adding = glocal.prjname[0] == '\0'; (id); /-
if (!glocal.adding) htmlprintf ("
%s%s\n",MSG_U(T_PROJECT,"Project"),glocal.prjname); /-
(glocal.con,w_session.c_str(),""); for (auto &l:lists){ if (strcmp(l.name,glocal.prjname)==0){ w_desc = l.description; for (unsigned i=0; i glocal vector groups; // PATCH: Group contacts is not returned by list_groups // For the public group, it is necessary. Maybe other projects would // need access to special group contact... if (strcmp(glocal.prjname,"public")==0) glocal.groups.push_back("contacts"); (glocal.con,w_session.c_str(),"",true); for (auto &g:groups) glocal.groups.push_back(g.name); if (glocal.adding){ htmlprintf ("%s \n",MSG_U(I_PRJ_PROJECT,"Project")); field_string (w_list,"size=30"); } htmlprintf ("%s ",MSG_U(I_PRJ_DESCRIPTION,"Description")); field_string (w_desc,"style=width:100%"); /-   /-#I_PRJ_MEMBERS Members /-#I_PRJ_GROUP
GroupAccess /-
index_field_group (this,w_group1,glocal.groups); /- index_field_access (this,w_access1); /-
index_field_group (this,w_group2,glocal.groups); /- index_field_access (this,w_access2); /-
index_field_group (this,w_group3,glocal.groups); /- index_field_access (this,w_access3); /-
index_field_group (this,w_group4,glocal.groups); /- index_field_access (this,w_access4); /-
/- button_submit();
bool ret = true; if (strcmp(w_desc.c_str(),"a")==0){ ret = false; /- a is not allowed /-
} return ret;
glocal bool fail = false; if (glocal.adding){ glocal.prjname = w_list.c_str(); (glocal.con,w_session.c_str(),w_list.c_str(),""); if (!success){ glocal.fail = true; htmlprintf ("Can't create list: %s\n",msg); }else{ // The list has been added, the tab name will change. glocal.webtabs.setid(string_f("project:%s",glocal.prjname)); glocal.webtabs.settitle(string_f("%s %s",MSG_R(I_PROJECT),glocal.prjname)); } } if (!glocal.fail){ glocal vector oldgroups; (glocal.con,w_session.c_str(),""); for (auto &l:lists){ if (strcmp(l.name,glocal.prjname)==0){ for (auto g:l.groups) glocal.oldgroups.push_back(g); break; } } (glocal.con,w_session.c_str(),glocal.prjname,w_desc.c_str(),""); if (!success){ /- error glocal.fail = true; } vector newgroups; index_set_group (glocal.con,glocal.prjname,w_group1,w_access1,newgroups,glocal.fail); index_set_group (glocal.con,glocal.prjname,w_group2,w_access2,newgroups,glocal.fail); index_set_group (glocal.con,glocal.prjname,w_group3,w_access3,newgroups,glocal.fail); index_set_group (glocal.con,glocal.prjname,w_group4,w_access4,newgroups,glocal.fail); if (!glocal.fail){ // We have to remove the groups that are gone index_delete_new_from_old(newgroups,glocal.oldgroups); // what remains in oldgroups have to be deleted (setting access to - does this) for (auto &g:glocal.oldgroups) index_set_group (glocal.con,glocal.prjname,g.c_str(),"-",glocal.fail); } } fail = glocal.fail; if (!fail){ if (glocal.adding){ glocal.webtabs.redotab(); resetstate(); } keepediting = true; reload(); }
}else if (strncmp(id,"group:",6)==0){ glocal id; glocal const char *grpname = id+6; glocal bool adding = glocal.grpname[0] == '\0'; glocal string picked_userid; (); glocal string error; DIV f; f.id(TAB_FORM).print(); (glocal.id); /-
if (!glocal.adding) htmlprintf ("
%s%s\n",MSG_R(I_GROUP),glocal.grpname); /-
(glocal.con,w_session.c_str(),"",true); for (auto &g:groups){ if (strcmp(g.name,glocal.grpname)==0){ w_desc = g.description; w_content = ""; for (unsigned i=0; i if (glocal.picked_userid.size() > 0){ vector members; config_parsemembers(members); auto it = find_if(members.begin(),members.end() ,[this](auto &m){ return m.user == glocal.picked_userid; }); if (it!=members.end()){ glocal.error = string_f(MSG_U(E_ALREADYMEMBER,"%s is already in the list"),glocal.picked_userid.c_str()); }else{ string content = w_content.c_str(); if (content.size() > 0 && content[content.size()-1] != '\n') content += '\n'; content += glocal.picked_userid; content += ":W:"; tlmpweb_forcevar(w_content,content); } } if (glocal.adding){ htmlprintf ("%s ",MSG_U(I_GROUP,"Group")); field_string (w_group,"size=30"); } /-#I_DESCRIPTION Description  field_string (w_desc,"style=width:100%"); /-   /-#I_MEMBERS Members field_textarea (w_content,20,-100,""); /- button_submit(); config_printmsg ("red",glocal.error); bool ret = true; return ret; glocal bool fail = false; if (glocal.adding){ glocal.grpname = w_group.c_str(); (glocal.con,w_session.c_str(),glocal.grpname,""); if (!success){ glocal.fail = true; glocal.error = string_f(MSG_U(E_CANTCREATEGROUP,"Can't create group: %s"),msg); }else{ // The group has been added, the tab name will change. glocal.webtabs.setid(string_f("group:%s",glocal.grpname)); glocal.webtabs.settitle(string_f("%s %s",MSG_R(I_GROUP),glocal.grpname)); } } if (!glocal.fail){ glocal vector oldusers; (glocal.con,w_session.c_str(),"",true); for (auto &g:groups){ if (strcmp(g.name,glocal.grpname)==0){ for (auto u:g.users) glocal.oldusers.push_back(u); break; } } (glocal.con,w_session.c_str(),glocal.grpname,w_desc.c_str(),""); if (!success){ glocal.error = string_f (MSG_U(E_CANTSETGROUPDESC,"Can't set group description: %s"),msg); glocal.fail = true; } vector newmembers; config_parsemembers(newmembers); if (glocal.adding){ // Make sure the owner is there. By default, at group creation, the user is not a member of his own group // which is confusing. So we inject it here. auto it = find_if(newmembers.begin(),newmembers.end(),[](auto &m){ return m.user == userinfo.name;}); if (it == newmembers.end()) newmembers.emplace_back(userinfo.name,"W",""); } for (auto &member:newmembers){ glocal const char *user = member.user.c_str(); (glocal.con,w_session.c_str(),glocal.grpname ,glocal.user,member.access.c_str(),member.role.c_str(),""); if (!success){ glocal.fail = true; glocal.error = string_f (MSG_U(E_CANTSETMEMBER,"Can't set member %s: %s"),glocal.user,msg); } if (glocal.fail) break; } if (!glocal.fail){ // We have to remove the users that are gone vector newusers; for (auto &m:newmembers) newusers.push_back(m.user); index_delete_new_from_old(newusers,glocal.oldusers); // what remains in oldusers have to be deleted (setting access to - does this) for (auto &g:glocal.oldusers){ glocal const char *user = g.c_str(); (glocal.con,w_session.c_str(),glocal.grpname ,glocal.user,"-","",""); if (!success){ glocal.fail = true; glocal.error = string_f (MSG_U(E_CANTDELMEMBER,"Can't delete member %s: %s"),glocal.user,msg); } } } } fail = glocal.fail; if (!fail){ if (glocal.adding){ glocal.webtabs.redotab(); resetstate(); } keepediting = true; reload(); }
static string table ("group_contacts"); static WEBID id_contacts(table); DIV c(TAB_SUBTABS); c.borderradius(5).border(1,"black").vmargins(2,5).paddings(2,2).vpaddings(2,2).print(); (id_contacts,currents[table],offsets[table],5); glocal selected_row; (glocal.con,w_session.c_str(),""); unsigned rownum = 0; unsigned mini_image_width = tlmpweb_ismobile() ? 60 : 40; for (auto m:members){ if (rownum == glocal.selected_row){ glocal.picked_userid = m; } glocal.webtable.setclickopt (true,"",""); string dir = string_f("/projects/%s/public",m); string img = util_mini_img(step_image,mini_image_width,dir,"mini-photo.jpg",""); glocal.webtable.setrow("white",rownum,"%s\t%s",img.c_str(),m); rownum++; }
}else if (strcmp(id,"sendcontact")==0){ // CONF sendcontact glocal bool done = false; glocal id; glocal string picked_userid; (); glocal string error; glocal string confirm; DIV f; f.id(TAB_FORM).print(); (glocal.id); /-
/-
config_form_title(MSG_U(I_SENDCONTACT,"Send a contact request")); /-
htmlprintf ("%s\n",MSG_U(I_TOCONTACT,"Person to contact")); if (glocal.picked_userid.size() > 0){ tlmpweb_forcevar(w_recipients,glocal.picked_userid); } field_string (w_recipients,"style=width:100%"); htmlprintf ("%s\n",MSG_U(I_MESSAGE,"Message")); field_textarea (w_content,10,-100,""); /- button_send(); config_printmsg ("red",glocal.error); config_printmsg ("blue",glocal.confirm); bool ret = true; if (w_content.size() >= 200){ glocal.error = MSG_U(E_MSGTOOLONG,"Message limited to 200 characters"); ret = false; } return ret; glocal bool fail = false; if (w_recipients.size() > 0){ (glocal.con,w_session.c_str(),"",w_recipients.c_str(),w_content.c_str()); if (!success){ glocal.fail = true; glocal.error = string_f (MSG_U(E_CONTACTFAIL,"Contact request failed: %s"),msg); }else{ glocal.confirm = MSG_U(I_CONTACTSENT,"Contact request sent!"); } } fail = glocal.fail; if (!fail) keepediting = true;
config_search("sendcontact",glocal.picked_userid);
}else if (strncmp(id,"manage:",7)==0){ // CONF manage contact glocal bool done = false; glocal CONTACT_STATUS status = CONTACT_WAITING; glocal string user = id+7; (id); /-
/-
config_form_title(MSG_U(I_MANAGECONTACT,"Manage a contact")); /-
(glocal.con,w_session.c_str(),"",true,glocal.user,0,1); if (contacts.size() == 1){ auto &c = contacts[0]; w_content = c.message; } field_hidden(w_user); /- /-#I_REQUESTFROM Request from /- htmlout (glocal.user); /- htmlout (MSG_R(I_MESSAGE)); /- field_textarea(w_content,5,-100,"readonly"); /- /-#I_ACCEPTREQ Accept request /- field_radio(w_accept,"accept",true,""); /- /-#I_REFUSEREQ Refuse request /- field_radio(w_accept,"reject",false,""); /- button_submit(); return true; glocal bool fail = false; if (strcmp(w_accept.c_str(),"accept")==0){ glocal.status = CONTACT_ACCEPTED; }else if (strcmp(w_accept.c_str(),"reject")==0){ glocal.status = CONTACT_REJECTED; }else{ glocal.fail = true; /- Invalid input ??? } if (!glocal.fail){ (glocal.con,w_session.c_str(),"",glocal.user,glocal.status); if (!success){ glocal.fail = true; htmlprintf ("operation failed: %s
\n",msg); }else{ glocal.done = true; }
} fail = glocal.fail;
if (glocal.done){ /-
   
/-#I_CONTACTDONE Contact request processed! /-

if (glocal.status == CONTACT_ACCEPTED){ htmlprintf (MSG_U(I_FROMNOWON,"From now on, you can communicate with user %s
\n"),glocal.user.c_str()); htmlprintf (MSG_U(I_MAKEMEMBER,"You can make user %s member of your groups
\n"),glocal.user.c_str()); /-#I_HEMAKEMEMBER and he can make you member of his groups. } /-

glocal.webtabs.setstate(""); } }else if (strcmp(id,"interest")==0){ // CONF add interest glocal bool done = false; glocal id; glocal string picked_userid; (); glocal string error; DIV f; f.id(TAB_FORM).print(); (glocal.id); /- /-
config_form_title(MSG_U(I_ADDINTEREST,"Add interesting people")); /-
htmlprintf ("%s \n",MSG_U(I_PEOPLES,"Peoples")); if (glocal.picked_userid.size() > 0){ string content = w_content.c_str(); if (content.size() > 0) content += '\n'; content += glocal.picked_userid; tlmpweb_forcevar(w_content,content); } field_textarea (w_content,10,-100,""); /- button_submit(MSG_U(I_ADD,"Add")); config_printmsg ("red",glocal.error); return true; glocal bool fail = false; glocal vector users; glocal string already; // Users already in our interest list const char *pt = w_content.c_str(); while (*pt != '\0'){ pt = str_skip(pt); if (*pt > ' '){ const char *start = pt; while (*pt > ' ') pt++; glocal.users.push_back(string(start,pt-start)); } } // Check if some are already in the interest list (glocal.con,w_session.c_str(),""); for (auto u:users){ if (find(glocal.users.begin(),glocal.users.end(),u.name)!=glocal.users.end()){ glocal.already += string_f(" %s",u.name); glocal.fail = true; } } if (!glocal.fail){ for (auto u:glocal.users){ glocal const char *user = u.c_str(); (glocal.con,w_session.c_str(),u,""); if (!success){ glocal.error = string_f (MSG_U(E_INTERESTSET,"Can't add user %s in interest list: %s") ,glocal.user,msg); glocal.fail = true; } if (glocal.fail) break; } }else{ glocal.error = string_f ("%s: %s",MSG_U(E_INTERESTDUP,"These people are already in your interest list"),glocal.already.c_str()); } fail = glocal.fail; if (!fail){ glocal.webtabs.setstate(""); keepediting = true; w_content.setempty(); }
config_search("interest",glocal.picked_userid);
}
if (strcmp(id,"Projects")==0){ // CONF projects sethelp("helpprojects",MSG_U(I_HELPPROJECTS,"Projects")); { DIV t; t.id(TAB_FORM).print(); url_self (string_f("webtab_add=2:project:~%s",MSG_U(I_NEWPRJ,"New project")),MSG_U(I_CREATELIST,"Create a new project")); /-
 
} static WEBID id ("list:projects"); (id,currents[id.c_str()]); sethead (MSG_U(H_PROF_PROJECTS,"Project\tMembers\tAccess")); (glocal.con,w_session.c_str(),""); unsigned rownum=0; for (auto &l:lists){ if (l.name[0] != '#'){ string id = string_f("project:%s",l.name); string add = string_f("webtab_add=2:%s~%s %s",id.c_str(),MSG_R(I_PROJECT),l.name); glocal.webtable.setclickopt (true,"",add); if (glocal.webtabs.selected(id)) glocal.webtable.setcurrent(rownum); glocal.webtable.setrow ("sep",rownum,"%s\t%s\a",l.name,l.description); glocal.webtable.setclickopt (false,"",""); for (unsigned i=0; i }else if (strcmp(id,"Groups")==0){ // CONF groups sethelp("helpgroups",MSG_U(I_HELPGROUPS,"Groups")); { DIV t; t.id(TAB_FORM).print(); url_self (string_f("webtab_add=2:group:~%s",MSG_U(I_NEWGROUP,"New group")),MSG_U(I_CREATEGROUP,"Create a new group")); /-
 
} static WEBID id ("list:groups"); (id,currents[id.c_str()]); sethead (MSG_U(H_GROUPS,"Group\tMembers\tAccess\tRole")); (glocal.con,w_session.c_str(),"",true); unsigned rownum=0; for (auto &g:groups){ string id = string_f("group:%s",g.name); string add = string_f("webtab_add=2:%s~%s %s",id.c_str(),MSG_R(I_GROUP),g.name); glocal.webtable.setclickopt (true,"",add); if (glocal.webtabs.selected(id)) glocal.webtable.setcurrent(rownum); glocal.webtable.setrow ("sep",rownum,"%s\t%s\a\a",g.name,g.description); glocal.webtable.setclickopt (false,"",""); for (unsigned i=0; i }else if (strcmp(id,"Contacts")==0 || strcmp(id,"Contact-req")==0){ // CONF contacts glocal bool to_me = strcmp(id,"Contacts")==0; util_delnotify (*glocal.con_sess,"profile",id); if (glocal.to_me){ sethelp("helpcontacts",MSG_U(I_HELPCONTACTS,"Contacts")); }else{ sethelp("helpcontact-req",MSG_U(I_HELPCONTACT_REQ,"Requests")); } if (!glocal.to_me){ DIV f; f.id(TAB_FORM).print(); url_self (string_f("webtab_add=2:sendcontact~%s",MSG_U(I_CONTACTREQUEST,"Contact request")),MSG_U(I_NEWCONTACT,"Send a contact request")); /-
 
} static WEBID ID_CONTACT("list:contacts"); (ID_CONTACT,currents[ID_CONTACT.c_str()],offsets[ID_CONTACT.c_str()],10); sethead (MSG_U(H_CONTACTS,"User\tDate\tStatus")); (glocal.con,w_session.c_str(),"",glocal.to_me,"",nbskip,nblines); static const char *tbstatus[]={MSG_U(I_WAITING,"waiting"),MSG_U(I_ACCEPTED,"accepted"),MSG_U(I_REJECTED,"rejected")}; unsigned rownum = 0; for (auto &c:contacts){ if (glocal.to_me){ glocal.webtable.setclickopt (true,"",string_f("webtab_add=2:manage:%s~%s %s",c.user,MSG_U(I_MANAGE,"Request from"),c.user)); } glocal.webtable.setrow("white",rownum,"%s\t%s\t%s",c.user ,format_date(userinfo.dateformat,c.reqdate).c_str(),tbstatus[c.status]); rownum++; } }else if (strcmp(id,"Interests")==0){ // CONF interests sethelp("helpinterests",MSG_U(I_HELPINTERESTS,"Interests")); { DIV f; f.id(TAB_FORM).print(); url_self (string_f("webtab_add=2:interest~%s",MSG_R(I_NEWINTEREST)),MSG_U(I_NEWINTEREST,"Add interests")); /-
 
} static WEBID ID_INTERESTS("list:interests"); (ID_INTERESTS,currents[ID_INTERESTS.c_str()]); glocal unsigned dropmenu = dropmenu; glocal unsigned noline = noline; (glocal.con,w_session.c_str(),""); if (glocal.noline < users.size() && glocal.dropmenu == MENU_DELETE){ (glocal.con,w_session.c_str() ,users[glocal.noline].name,""); } glocal unsigned mini_image_width = tlmpweb_ismobile() ? 60 : 40; adddrop_opt (MENU_DELETE,MSG_R(M_DELETE)); sethead (MSG_U(H_INTEREST,"\tPerson\tSince")); (glocal.con,w_session.c_str(),""); unsigned rownum=0; for (auto &u:users){ glocal.webtable.setclickopt (true,"",string_f("user=%u:%s",rownum,u.name)); string since = format_date(userinfo.dateformat,u.since); const char *pt = strchr(u.name,'@'); if (pt!=nullptr){ // remote user string name(u.name,pt-u.name); const char *site = pt+1; string link = string_f("https://%s/public/%s",site,name.c_str()); string span = string_f("%s",link.c_str(),u.name); glocal.webtable.setrow("white",rownum,"\t%s\t%s" ,glocal.mini_image_width,site,name.c_str(),span.c_str(),since.c_str()); }else if (strcmp(u.name,"inbox")==0){ glocal.webtable.setrow("white",rownum,"\t%s\t%s" ,MSG_R(I_SHORTINBOX),since.c_str()); }else if (u.visible){ string link = string_f("/public/%s",u.name); string span = string_f("%s",link.c_str(),u.name); glocal.webtable.setrow("white",rownum,"\t%s\t%s" ,glocal.mini_image_width,u.name,span.c_str(),since.c_str()); }else{ glocal.webtable.setrow("white",rownum,"\t%s\t%s" ,u.name,since.c_str()); } rownum++; } }else if (strcmp(id,"Notifications")==0){ // CONF notifications glocal string status = " "; sethelp("helpnotifications",MSG_U(I_HELPNOTIF,"Notifications")); DIV d("webtable"); d.autoscroll().print(); glocal vector keys; glocal.keys.push_back(NOTIFY_PROFILE_CONTACTS); glocal.keys.push_back(NOTIFY_PROFILE_CONTACT_REQ); (glocal.con,w_session.c_str(),"",false); for (auto &g:groups){ glocal.keys.push_back(string_f("talks:%s:%s",g.owner,g.name)); } (id); /- htmlprintf ("
%s",glocal.status.c_str()); /-
for (auto &k:glocal.keys){ glocal const char *key = k.c_str(); (glocal.con,w_session.c_str(),"",k); // tlmp_warning ("notify load key=%s ui=%u email=%u\n",glocal.key,ui,email); w_notify_ui[glocal.key] = ui; w_notify_email[glocal.key] = email; } (glocal.con,w_session.c_str(),"",false); htmlprintf ("%s\n",MSG_R(H_MESSAGES)); htmlprintf ("%s%s%s  %s\n" ,MSG_U(I_OWNER,"Owner"),MSG_R(I_GROUP) ,MSG_U(I_PASSIVENOTIF,"Passive"),MSG_U(I_EMAILNOTIF,"Email")); htmlprintf ("%s",MSG_R(I_SHORTINBOX)); profile_set_notifies(glocal.form,string_f("talks:%s:inbox",userinfo.name.c_str())); for (auto &g:groups){ if (userinfo.name != g.owner || is_not_in(g.name,"inbox","anonymous")){ htmlprintf ("%s%s",g.owner,g.name); profile_set_notifies (glocal.form,string_f("talks:%s:%s",g.owner,g.name)); } } htmlprintf ("%s",MSG_R(I_ANONINBOX)); profile_set_notifies (glocal.form,string_f("talks:%s:anonymous",userinfo.name.c_str())); /-   htmlprintf ("%s%s  %s\n" ,MSG_U(H_CONTACTNOTIFS,"Contacts") ,MSG_R(I_PASSIVENOTIF),MSG_R(I_EMAILNOTIF)); htmlprintf ("%s",MSG_R(T_CONTACTSTOYOU)); profile_set_notifies (*this,NOTIFY_PROFILE_CONTACTS); htmlprintf ("%s",MSG_R(T_REQUESTSBYYOU)); profile_set_notifies (*this,NOTIFY_PROFILE_CONTACT_REQ); /- button_submit(); return true; for (auto &k:glocal.keys){ (glocal.con,w_session.c_str(),"",k,w_notify_ui[k],false,w_notify_email[k],false); } glocal.status = MSG_R(I_CONFIGUPDATED); keepediting = true;
}else if (strcmp(id,"Account")==0){ // CONF account glocal string status = " "; sethelp("helpaccount",MSG_U(I_HELPACCOUNT,"Account")); DIV d("webtable"); d.autoscroll().print(); (id); /- htmlprintf ("
%s",glocal.status.c_str()); /-
(glocal.con,w_session.c_str(),""); w_lang = config.lang; w_dateformat = string_f("%u",config.dateformat); w_public_view = config.public_view; w_public_dir = config.public_dir; w_anon_messages = config.anon_messages; w_timezone = config.timezone; (glocal.con,w_session.c_str(),""); w_publish = info.publish; w_bosite = info.bosite_visible; w_name = info.fullname; w_address1 = info.address1; w_address2 = info.address2; w_city = info.city; w_zipcode = info.zipcode; w_state = info.state; w_country = info.country; w_email = info.email; w_phone = info.phone; w_fax = info.fax; w_website = info.website; w_interest = info.interest; w_photo = info.photo; w_miniphoto = info.mini_photo; { DIV d; d.border(1,"gray").paddings(5,5).vpaddings(0,5).print(); /-
/-#T_PERSOPREF Personal preferences /-
/- /-#I_LANG
Language field_list (w_lang,""); field_list_item ("eng",MSG_U(I_ENGLISH,"English")); field_list_item ("fr",MSG_U(I_FRENCH,"French")); field_list_end(); /-#I_DATEFORMAT
Date format field_list(w_dateformat,""); field_list_item ("0",MSG_U(I_ENGDATE,"Month DD YYYY HH:MMam/pm")); field_list_item ("1",MSG_U(I_ISODATE,"YYYY/MM/DD HH:MM:SS")); field_list_end(); /-#I_TIMEZONE
Time zone field_list(w_timezone,""); ("/etc/timezones.lst",true); glocal.form.field_list_item(line); return 0; field_list_end(); /-#I_ENABLEPUB
Public view /-  field_checkbox (w_public_view,""); /-  /-#I_ENABLED enabled /-#I_PUBFOLDER
Public folder field_list (w_public_dir,""); field_list_item ("",MSG_U(I_NONE,"--none--")); field_list_item ("/",MSG_U(I_ROOTDIR,"root")); (glocal.con,w_session.c_str(),string_f("/projects/%s/public",userinfo.name.c_str()) ,"",false,0,100); for (auto &f:files){ if (bolixo_isdir(f.type)){ glocal.form.field_list_item (f.name,f.name); } } /-#I_ACCEPTANON
Anonymous messages /-  field_checkbox (w_anon_messages,""); /-  /-#I_ACCEPTEDANON accepted /-#MINI_PHOTO
Mini photo 40x40 string dir = string_f("/projects/%s/public",userinfo.name.c_str()); unsigned mini_image_width = tlmpweb_ismobile() ? 60 : 40; FILEINFO info; util_entrytype (glocal.con,string_f("%s/mini-photo.jpg",dir.c_str()),info); string img = util_mini_img(step_image,mini_image_width,dir,"mini-photo.jpg",info.modified); htmlout (img); /- field_file(w_upload); /-#PHOTO
Photo 100x100 util_entrytype (glocal.con,string_f("%s/photo.jpg",dir.c_str()),info); img = util_img(step_image,100,dir,"photo.jpg",info.modified); htmlout (img); /-  field_file(w_upload2); /-
} { DIV d; d.border(1,"gray").paddings(5,5).vpaddings(0,5).vmargins(5,0).print(); /-
/-#T_PUBLISH Public information /-
/-#F_PUBLISH Publish to bolixo.org directory /-    field_checkbox (w_publish,""); DIV dd; dd.border(1,"lightgray").print(); /- index_field (this,true,3,MSG_U(F_FULLNAME,"Name and surname"),w_name,40); index_field (this,true,3,MSG_U(F_ADDRESS1,"Address"),w_address1,40); index_field (this,true,3,MSG_U(F_ADDRESS2,"Address"),w_address2,40); index_field (this,true,MSG_U(F_CITY,"City"),w_city); index_field (this,false,MSG_U(F_STATE,"State"),w_state); index_field (this,true,MSG_U(F_COUNTRY,"Country"),w_country); index_field (this,false,MSG_U(F_ZIPCODE,"ZIP code"),w_zipcode); index_field (this,true,MSG_U(F_EMAIL,"Email"),w_email); index_field (this,true,MSG_U(F_PHONE,"Phone"),w_phone); index_field (this,false,MSG_U(F_FAX,"Fax"),w_fax); /-
/-#F_PUBLISHSOME Publish /- field_checkbox (w_bosite,""); /-#F_PUBBOLIXOSITE your Bolixo page /-   field_checkbox (w_photo,""); /-#F_YOURPHOTO Your photo /-   field_checkbox (w_miniphoto,""); /-#F_YOURMINIPHOTO Your mini photo index_field (this,true,MSG_U(F_WEBSITE,"Web site"),w_website); /-
/-#F_INTERESTS Interests /- field_textarea (w_interest,8,70,""); /-
} /-
button_submit();
bool ret = true; if (w_bosite.getval() != 0 && w_public_view.getval()==0){ ret = false; /- * /-#E_CANTPUBBOSITE You can't publish your Bolixo page unless you enable public view }else if (w_miniphoto.getval() != 0 && strcmp(w_upload.c_str(),"")==0 && util_entrytype(glocal.con,string_f("/projects/%s/public/mini-photo.jpg",userinfo.name.c_str()))!=ENTRY_FILE){ ret = false; /- * /-#E_CANTPUBMINIPHOTO You can't publish your mini-photo because you have not uploaded it yet }else if (w_photo.getval() != 0 && strcmp(w_upload2.c_str(),"")==0 && util_entrytype(glocal.con,string_f("/projects/%s/public/photo.jpg",userinfo.name.c_str()))!=ENTRY_FILE){ ret = false; /- * /-#E_CANTPUBPHOTO You can't publish your photo because you have not uploaded it yet } return ret; glocal bool fail = false; CONFIG config; config.lang = w_lang.c_str(); config.dateformat = atoi(w_dateformat.c_str()); config.public_view = w_public_view; config.public_dir = w_public_dir.c_str(); config.anon_messages = w_anon_messages; config.timezone = w_timezone.c_str(); (glocal.con,w_session.c_str(),"",config); if (!success){ glocal.fail = true; htmlprintf (MSG_U(E_CANTSAVECONFIG,"Can't save configuration: %s\n"),msg); }else{ translat_selectlang (w_lang.c_str()); glocal.status = MSG_U(I_CONFIGUPDATED,"Configuration updated"); } if (strcmp(w_upload.c_str(),"")!=0){ profile_upload (glocal.con,w_upload,"mini-photo.jpg",glocal.fail); } if (strcmp(w_upload2.c_str(),"")!=0){ profile_upload (glocal.con,w_upload2,"photo.jpg",glocal.fail); } USERPUBLICINFO info; info.publish = w_publish.getval(); info.bosite_visible = w_bosite.getval(); info.fullname = w_name.c_str(); info.address1 = w_address1.c_str(); info.address2 = w_address2.c_str(); info.city = w_city.c_str(); info.zipcode = w_zipcode.c_str(); info.state = w_state.c_str(); info.country = w_country.c_str(); info.email = w_email.c_str(); info.phone = w_phone.c_str(); info.fax = w_fax.c_str(); info.website = w_website.c_str(); info.interest = w_interest.c_str(); info.photo = w_photo.getval(); info.mini_photo = w_miniphoto.getval(); (glocal.con,w_session.c_str(),"",info); if (!success){ glocal.fail = true; htmlprintf (MSG_U(E_CANTSAVEPUBCONFIG,"Can't save public configurations: %s\n"),msg); } fail = glocal.fail; keepediting = true;
}
}