removed: hidden variable 'old_url' in emacs template
git-svn-id: svn://ttmath.org/publicrep/cmslu/trunk@527 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
parent
13b0204427
commit
848afac803
|
@ -53,7 +53,7 @@ emacs.o: ../core/group.h ../core/dircontainer.h ../core/ugcontainer.h
|
|||
emacs.o: ../core/data.h ../core/dirs.h ../core/users.h ../core/groups.h
|
||||
emacs.o: ../core/functions.h ../core/lastcontainer.h ../core/mounts.h
|
||||
emacs.o: ../core/mount.h ../core/notify.h
|
||||
emacs.o: ../templatesnotify/templatesnotify.h ../core/mount.h
|
||||
emacs.o: ../templatesnotify/templatesnotify.h ../core/mount.h ../core/misc.h
|
||||
last.o: content.h ../core/item.h ../templates/templates.h
|
||||
last.o: ../templates/patterncacher.h ../core/thread.h
|
||||
login.o: content.h ../core/item.h ../templates/templates.h
|
||||
|
|
|
@ -65,6 +65,7 @@ class Content
|
|||
void FunThread();
|
||||
void FunCreateThread();
|
||||
|
||||
bool PostFunSetUrlSubject();
|
||||
void PostFunLogin();
|
||||
void PostFunEmacsAdd();
|
||||
void PostFunEmacsEdit(bool with_url);
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
#include "../core/db.h"
|
||||
#include "../core/data.h"
|
||||
#include "../core/notify.h"
|
||||
#include "../core/misc.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -87,43 +89,61 @@ void Content::PostFunEmacsEdit(bool with_url)
|
|||
}
|
||||
|
||||
|
||||
// returning true if the 'url' has to be changed
|
||||
bool Content::PostFunSetUrlSubject()
|
||||
{
|
||||
bool with_url = false;
|
||||
|
||||
std::string * new_url = request.PostVar("url");
|
||||
std::string * new_subject = request.PostVar("subject");
|
||||
|
||||
if( request.is_item )
|
||||
{
|
||||
// editing an item
|
||||
if( new_url && *new_url != request.item.url )
|
||||
with_url = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// adding a new item
|
||||
with_url = true;
|
||||
}
|
||||
|
||||
if( new_url )
|
||||
request.item.url = *new_url;
|
||||
|
||||
if( new_subject )
|
||||
request.item.subject = *new_subject;
|
||||
|
||||
|
||||
if( request.item.subject.empty() )
|
||||
{
|
||||
request.item.subject = request.dir_table.back()->subject;
|
||||
request.item.subject += "_msg_";
|
||||
request.item.subject += ToStr(db.Size(request.dir_table.back()->id, Item::file));
|
||||
}
|
||||
|
||||
// if request.item.url is empty then it will be set from request.item.subject
|
||||
PrepareUrl(request.item);
|
||||
|
||||
return with_url;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Content::PostFunEmacs()
|
||||
{
|
||||
bool adding = true;
|
||||
|
||||
if( request.is_item )
|
||||
adding = false;
|
||||
bool adding = !request.is_item;
|
||||
|
||||
try
|
||||
{
|
||||
// these old values are ignored (if exists)
|
||||
|
||||
request.PostVar("url", request.item.url);
|
||||
request.PostVar("subject", request.item.subject);
|
||||
|
||||
if( request.item.subject.empty() )
|
||||
request.item.subject = request.dir_table.back()->subject;
|
||||
// !! dodac skladanie tytuly z ostatniego katalogu i liczby okreslajacej ile jest elementow w srodku
|
||||
// !! nie bedzie obciazany modul wyszukujacy bardzo
|
||||
////////
|
||||
|
||||
bool with_url = PostFunSetUrlSubject();
|
||||
request.PostVar("content", request.item.content);
|
||||
|
||||
bool with_url = false;
|
||||
std::string * old_url = request.PostVar("old_url");
|
||||
|
||||
if( !request.is_item || (old_url && *old_url!=request.item.url) )
|
||||
with_url = true;
|
||||
|
||||
PrepareUrl(request.item);
|
||||
|
||||
if( !CheckRebus() )
|
||||
{
|
||||
request.status = Error::rebus_bad_answer;
|
||||
SetUser(request.item);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
33
core/db.cpp
33
core/db.cpp
|
@ -821,6 +821,39 @@ void Db::GetItems(std::vector<Item> & item_table, long parent_id, Item::Type typ
|
|||
}
|
||||
|
||||
|
||||
// how many items there are in a 'parent_id' directory
|
||||
long Db::Size(long parent_id, Item::Type type)
|
||||
{
|
||||
PGresult * r = 0;
|
||||
int res = 0;
|
||||
|
||||
try
|
||||
{
|
||||
AssertConnection();
|
||||
|
||||
std::ostringstream query;
|
||||
query << "select count(id) from core.item where ";
|
||||
|
||||
if( type != Item::none )
|
||||
query << "type='" << (int)type << "' and ";
|
||||
|
||||
query << "parent_id='" << parent_id << "';";
|
||||
|
||||
r = AssertQuery( query.str() );
|
||||
AssertResultStatus(r, PGRES_TUPLES_OK);
|
||||
|
||||
res = atol(AssertValue(r, 0, 0));
|
||||
}
|
||||
catch(const Error &)
|
||||
{
|
||||
}
|
||||
|
||||
ClearResult(r);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
// !! ta chyba nie uzywana juz?
|
||||
void Db::GetItem(std::vector<Item> & item_table, long id)
|
||||
{
|
||||
|
|
|
@ -65,6 +65,8 @@ public:
|
|||
void GetGroups(UGContainer<Group> & group_table);
|
||||
|
||||
// !! nowy interfejs
|
||||
long Size(long parent_id, Item::Type type = Item::none);
|
||||
|
||||
Error GetItem(long parent_id, const std::string & url, Item & item);
|
||||
Error EditDefaultItem(long id, long new_default_item);
|
||||
|
||||
|
|
|
@ -308,6 +308,16 @@ return buffer;
|
|||
}
|
||||
|
||||
|
||||
const char * ToStr(int value)
|
||||
{
|
||||
static char buffer[100];
|
||||
|
||||
sprintf(buffer, "%d", value);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
bool IsWhite(int s)
|
||||
{
|
||||
if( s==' ' || s=='\t' || s==13 )
|
||||
|
|
|
@ -43,6 +43,8 @@ bool IsWhite(int s);
|
|||
void TrimWhite(std::string & s);
|
||||
void ToSmall(std::string & s);
|
||||
const char * SkipWhite(const char * s);
|
||||
const char * ToStr(int value);
|
||||
|
||||
|
||||
bool ValidateEmail(const std::string & email);
|
||||
|
||||
|
|
Loading…
Reference in New Issue