added: to misc:

bool IsWhite(const wchar_t * str, bool treat_new_line_as_white)
       bool IsWhite(const std::wstring & str, bool treat_new_line_as_white)
       return true if the whole string is white (or an empty string)
added: global variable in admin environment for an user: "display_name"
       if defined it is used to display an user's name instead of its login
       it is used in: void print_user_name(Info & i, User & user);
       (tickets, threads, cat function etc)





git-svn-id: svn://ttmath.org/publicrep/winix/trunk@895 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2012-09-26 07:18:32 +00:00
parent 7f48d1eb2e
commit dfcf6b29c0
6 changed files with 78 additions and 6 deletions

View File

@@ -86,20 +86,34 @@ void print_date_nice(Info & i, const PT::Date & date)
}
void print_user_name(Info & i, const User * puser, const std::wstring & guest_name)
// cannot be a const reference at the moment (PT::Space is used)
void print_user_name(Info & i, User & user)
{
std::wstring * dname = user.aenv.GetValue(L"display_name");
if( dname && !IsWhite(*dname, true) )
i.out << *dname;
else
i.out << user.name;
}
void print_user_name(Info & i, User * puser, const std::wstring & guest_name)
{
if( puser )
{
i.out << puser->name;
print_user_name(i, *puser);
}
else
{
i.out << "~";
if( !guest_name.empty() )
if( !guest_name.empty() && !IsWhite(guest_name) )
i.out << guest_name;
else
i.out << "guest"; // !! dodac do konfiga
i.out << locale.Get(L"display_guest_name");
}
}

View File

@@ -39,7 +39,24 @@ void HtmlEscapeFormTxt(HtmlTextStream & out, const std::wstring & in);
void print_hour_min(Info & i, time_t time);
void print_date_nice(Info & i, const PT::Date & date);
void print_user_name(Info & i, const User * puser, const std::wstring & guest_name);
/*
print a user name -- it is trying to use 'display_name' from user's admin env
if it not find it or if the 'display_name' is all white (consists of all white characters)
then the login name is printed
*/
void print_user_name(Info & i, User & user);
/*
puser can be null -- in such a case guest_name is used
if guest_name is empty then 'display_guest_name' from locales is printed
*/
void print_user_name(Info & i, User * puser, const std::wstring & guest_name);
} // namespace TemplatesFunctions