fixed: ticket sets a default function only for directories

fixed: reading a new url and subject in Functions::ReadItem()
added: tickets are sorted now (by date)



git-svn-id: svn://ttmath.org/publicrep/winix/trunk@659 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2010-09-30 20:58:20 +00:00
parent d94a08b991
commit 7bc17a9202
12 changed files with 178 additions and 141 deletions

View File

@@ -77,33 +77,26 @@ return true;
void Emacs::PostFunEmacsModifyMountPoint(bool adding)
{
if( system->mounts.pmount->type == system->mounts.MountTypeThread() )
{
if( adding )
db->EditThreadAddItem(request->dir_tab.back()->id, request->item.id);
if( system->mounts.pmount->type == system->mounts.MountTypeThread() && adding )
db->EditThreadAddItem(request->dir_tab.back()->id, request->item.id);
system->RedirectToLastDir();
}
/* !! tticket
else
if( system->mounts.pmount->type == system->mounts.MountTypeTicket() )
{
system->RedirectToLastDir();
}
*/
else
{
// system->mounts.MountTypeCms()
if( system->mounts.pmount->type == system->mounts.MountTypeCms() )
system->RedirectTo(request->item);
}
else
system->RedirectToLastDir();
}
void Emacs::MakePost()
{
bool adding = !request->is_item;
bool edit_with_url = functions->ReadItem(request->item, Item::file);
bool adding = !request->is_item;
if( !adding )
old_url = request->item.url;
functions->ReadItem(request->item, Item::file);
if( adding )
functions->SetUser(request->item); // set user before checking the rebus
@@ -120,9 +113,7 @@ void Emacs::MakePost()
}
else
{
// !! moze dodac metode EditFile w klasie functions?
// i ona wywola system->EditFile i poniszego updatera
request->status = system->EditFile(request->item, edit_with_url);
request->status = system->EditFile(request->item, request->item.url != old_url);
if( request->status == WINIX_ERR_OK )
TemplatesFunctions::pattern_cacher.UpdatePattern(request->item);

View File

@@ -32,6 +32,7 @@ private:
bool PostEmacsCheckAbuse(bool adding);
void PostFunEmacsModifyMountPoint(bool adding);
std::string old_url;
};

View File

@@ -168,8 +168,6 @@ void Functions::Add(FunctionBase & fun)
void Functions::Create()
{
Add(fun_template);
Add(fun_adduser);
Add(fun_cat);
Add(fun_chmod);
@@ -192,6 +190,7 @@ void Functions::Create()
Add(fun_rm);
Add(fun_run);
Add(fun_subject);
Add(fun_template);
Add(fun_thread);
Add(fun_tinymce);
Add(fun_uname);
@@ -200,10 +199,6 @@ void Functions::Create()
Add(fun_who);
plugin.Call(WINIX_CREATE_FUNCTIONS);
// Add(fun_ticket);
// Add(fun_createticket);
// Add(fun_editticket);
}
@@ -366,31 +361,13 @@ void Functions::CheckGetPostTimes(time_t difference)
// returning true if the 'url' has to be changed
bool Functions::ReadItemUrlSubject(Item & item, Item::Type item_type)
void Functions::ReadItemUrlSubject(Item & item, Item::Type item_type)
{
bool with_url = false;
const std::string & new_url = request->PostVar("url");
const std::string & new_subject = request->PostVar("subject");
if( item_type == Item::file )
{
if( !request->is_item || new_url != item.url )
with_url = true;
}
else
{
// !! dla katalogow zawsze ma modyfikowac url?
with_url = true;
}
if( !new_url.empty() )
item.url = new_url;
if( !new_subject.empty() )
item.subject = new_subject;
std::string * new_subject = request->PostVarp("subject");
std::string * new_url = request->PostVarp("url");
if( new_subject )
item.subject = *new_subject;
if( item.subject.empty() )
{
@@ -399,10 +376,11 @@ bool Functions::ReadItemUrlSubject(Item & item, Item::Type item_type)
item.subject += ToStr(db->Size(request->dir_tab.back()->id, Item::file));
}
if( new_url )
item.url = *new_url;
// if item.url is empty then it will be set from item.subject
PrepareUrl(item);
return with_url;
}
@@ -483,20 +461,18 @@ void Functions::ReadItemContentWithType(Item & item)
// item_type - the type of an item you are expecting to read
// returns true if the url has to be changed
// at the moment this is only checked for Item::file - for Item::dir it returns always true
bool Functions::ReadItem(Item & item, Item::Type item_type)
void Functions::ReadItem(Item & item, Item::Type item_type)
{
if( item_type == Item::none )
return false;
return;
item.type = item_type;
item.parent_id = request->dir_tab.back()->id; // !! moze to dac jako parametr?
bool edit_with_url = ReadItemUrlSubject(item, item_type);
ReadItemUrlSubject(item, item_type);
if( item_type == Item::file )
ReadItemContentWithType(item);
return edit_with_url;
}

View File

@@ -114,7 +114,11 @@ public:
void ReadItemFilterHtml(Item & item);
void ReadItemContent(Item & item, const std::string & content_type);
void ReadItemContentWithType(Item & item);
bool ReadItem(Item & item, Item::Type item_type);
// if item.url is not empty and there is not a post variable "url"
// then the item.url will not be changed
// (the same is for item.subject and "subject" post variable)
void ReadItem(Item & item, Item::Type item_type);
void SetUser(Item & item);
@@ -138,7 +142,7 @@ private:
void SetDefaultFunctionForFile();
void SetDefaultFunctionForDir();
bool ReadItemUrlSubject(Item & item, Item::Type item_type);
void ReadItemUrlSubject(Item & item, Item::Type item_type);
Table table;