fixed: compiling in the clang (new version of c++ std lib)

(added some header files)
added: three messsages in ticket plugin:
       // send by showtickets winix function when tickets are loaded (and sorted)
       // in p1 you have a pointer to the ticket tab: std::vector<Ticket::Ticket> (include "ticket.h")
       // in p2 you have a pointer to the sort tab:   std::vector<Item*>
       // those tables don't have to be equal in size (in the case when there is no some tickets in the database)
       #define WINIX_PL_TICKET_TICKETS_LOADED                 4106
       
       // a new ticket has been added
       // in p1 you have a pointer to the Ticket::Ticket structure (include "ticket.h")
       // in p2 you have a pointer to the Item structure
       #define WINIX_PL_TICKET_ADDED_NEW                              4107
       
       // a ticket has been changed
       // in p1 you have a pointer to the Ticket::Ticket structure (include "ticket.h")
       // in p2 you have a pointer to the Item structure
       #define WINIX_PL_TICKET_CHANGED                                        4108

added: two ezc functions for tickets:
       ticket_does_param_id_have_value()
       tickets_tab_does_param_id_have_value()
       (they take two integer arguments -- testing whether a specified param_id has the given value)
changed: some more minor additions in tickets templates




git-svn-id: svn://ttmath.org/publicrep/winix/trunk@932 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
Tomasz Sowa 2013-10-10 11:59:21 +00:00
parent b7f3f84080
commit a6b06f82e9
12 changed files with 250 additions and 79 deletions

View File

@ -2,11 +2,12 @@
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2011, Tomasz Sowa
* Copyright (c) 2008-2013, Tomasz Sowa
* All rights reserved.
*
*/
#include <cstdlib>
#include "acceptbaseparser.h"

View File

@ -2,7 +2,7 @@
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2012, Tomasz Sowa
* Copyright (c) 2012-2013, Tomasz Sowa
* All rights reserved.
*
*/
@ -10,6 +10,8 @@
#ifndef headerfile_winix_core_ipban
#define headerfile_winix_core_ipban
#include <ctime>
// telling if the IPBan record is active
// we have two records: active and non active

View File

@ -2,11 +2,13 @@
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2012, Tomasz Sowa
* Copyright (c) 2008-2013, Tomasz Sowa
* All rights reserved.
*
*/
#include <sys/types.h>
#include <unistd.h>
#include "postmultiparser.h"
#include "log.h"
#include "utf8/utf8.h"

View File

@ -2,7 +2,7 @@
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2011, Tomasz Sowa
* Copyright (c) 2011-2013, Tomasz Sowa
* All rights reserved.
*
*/
@ -12,6 +12,7 @@
#include <string>
#include <cstdio>
#include <unistd.h>
/*

View File

@ -2,11 +2,12 @@
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2010, Tomasz Sowa
* Copyright (c) 2010-2013, Tomasz Sowa
* All rights reserved.
*
*/
#include <unistd.h>
#include "dbconn.h"
#include "core/log.h"
#include "core/error.h"

View File

@ -70,6 +70,9 @@ void CreateTicket::AddTicket(Ticket & ticket, Item & item)
notify_msg.item_link += item.url;
system->notify.ItemChanged(notify_msg);
// sending a message
plugin.Call(WINIX_PL_TICKET_ADDED_NEW, &ticket, &item);
}
}

View File

@ -77,6 +77,9 @@ void EditTicket::ChangeTicket(Ticket & ticket, Item & item)
notify_msg.item_link += item.url;
system->notify.ItemChanged(notify_msg);
// sending a message
plugin.Call(WINIX_PL_TICKET_CHANGED, &ticket, &item);
}
}

View File

@ -148,6 +148,7 @@ void ShowTicketsFromDir(PluginInfo & info)
// defined in templates.cpp
void AddEzcFunctions(PluginInfo & info);
@ -173,6 +174,7 @@ using namespace Ticket;
plugin.Assign(WINIX_END_REQUEST, EndRequest);
plugin.Assign(WINIX_PL_TICKET_LOAD_TICKETS, ShowTicketsFromDir);
tdb.SetConn(info.db->GetConn());
tdb.LogQueries(info.config->log_db_query);

View File

@ -2,7 +2,7 @@
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2011-2012, Tomasz Sowa
* Copyright (c) 2011-2013, Tomasz Sowa
* All rights reserved.
*
*/
@ -13,6 +13,9 @@
// values from 4100 - 4199 reserved for 'ticket' plugin
// showtickets winix function is about to sort pointers to tickets
// in p1 you have pointer to std::vector<Item*> struct
// you can sort it in your own (in such a case you have to return true)
#define WINIX_PL_TICKET_SORT_POINTERS 4100
@ -20,6 +23,8 @@
#define WINIX_PL_TICKET_CAN_MAKE_REDIRECT 4101
// calling ShowTicketsFromDir(long dir_id) method from ShowTickets object
// when tickets are read and sorted then WINIX_PL_TICKET_TICKETS_LOADED is called
// in l1 you shoud give the directory_id
// from the tickets have to be read
// and you can use only ezc functions to display the tickets
@ -43,6 +48,28 @@
// in p2 you have a pointer to the Ticket struct
#define WINIX_PL_TICKET_CLOSED 4105
// send by showtickets winix function when tickets are loaded (and sorted)
// in p1 you have a pointer to the ticket tab: std::vector<Ticket::Ticket> (include "ticket.h")
// in p2 you have a pointer to the sort tab: std::vector<Item*>
// those tables don't have to be equal in size (in the case when there is no some tickets in the database)
#define WINIX_PL_TICKET_TICKETS_LOADED 4106
// a new ticket has been added
// in p1 you have a pointer to the Ticket::Ticket structure (include "ticket.h")
// in p2 you have a pointer to the Item structure
#define WINIX_PL_TICKET_ADDED_NEW 4107
// a ticket has been changed
// in p1 you have a pointer to the Ticket::Ticket structure (include "ticket.h")
// in p2 you have a pointer to the Item structure
#define WINIX_PL_TICKET_CHANGED 4108
#endif

View File

@ -143,6 +143,8 @@ void ShowTickets::ShowTicketsFromDir(long dir_id)
SortPointers();
ReadTickets();
plugin.Call(WINIX_PL_TICKET_TICKETS_LOADED, &ticket_info->ticket_tab, &ticket_info->item_sort_tab);
// !! IMPROVE ME may a better name instead of WINIX_PL_THREAD_SET_SORTTAB?
plugin.Call(WINIX_PL_THREAD_SET_SORTTAB, &ticket_info->item_sort_tab);
plugin.Call(WINIX_PL_THREAD_READ_THREADS);

View File

@ -37,15 +37,22 @@ extern EditTicket fun_edit_ticket;
struct TicketValue
{
bool is_param; // true if there is a paremeter (in config Space)
PT::Space * config_par; // current space param (from current config) if is_param is true
// when is_param is true then this pointer is never null
long param_id; // param id (the same as config_par->Long(L"id"))
bool is_value; // true if value for such a param was defined
bool is_in_ticket_par; // true if the value is defined in ticket.par_tab
// else the value is defined in meta
Ticket::TicketParam * ticket_par; // if is_in_ticket_par is true:
PT::Space * value_meta; // if is_in_ticket_par is false:
long param_id; // param id (the same as config_par->Long(L"id"))
bool is_value; // true if value for such a param was defined
// (either in ticket_par or in meta)
// *you have to check this variable first before using ticket_par or value_meta*
bool is_in_ticket_par; // true if the value is defined in ticket.par_tab
// else the value can be defined in meta (or not at all)
Ticket::TicketParam * ticket_par; // if is_in_ticket_par is true
PT::Space * value_meta; // if is_in_ticket_par is false and if there is such a value in meta
TicketValue()
{
@ -59,6 +66,7 @@ PT::Space * value_meta; // if is_in_ticket_par is false:
param_id = 0;
is_value = false;
is_in_ticket_par = false;
ticket_par = 0;
value_meta = 0;
}
};
@ -276,8 +284,7 @@ void ticket_meta_value(Info & i)
void ticket_is_closed(Info & i)
{
// !! CHECKME should it be cur->request->item?
PT::Space * ticket_space = cur->request->item.ameta.FindSpace(L"ticket");
PT::Space * ticket_space = ticket_info.item->ameta.FindSpace(L"ticket");
if( ticket_space )
i.res = ticket_space->Bool(L"closed", false);
@ -318,6 +325,53 @@ void ticket_param_value_for_param_id(Info & i)
}
// it takes two integer parameters (param id and value)
void ticket_does_param_id_have_value(Info & i)
{
value_for_param_id.Clear();
size_t conf_index = 0;
PT::Space & space = *ticket_info.cur_conf;
if( i.params.size() == 2 )
{
long id = Tol(i.params[0]);
long id2 = Tol(i.params[1]);
for( ; conf_index < space.spaces.size() ; ++conf_index)
{
if( space.spaces[conf_index]->name == L"param" &&
space.spaces[conf_index]->Int(L"id") == id )
{
value_for_param_id.Clear();
value_for_param_id.is_param = true;
value_for_param_id.config_par = space.spaces[conf_index];
value_for_param_id.param_id = value_for_param_id.config_par->Long(L"id");
if( ticket_info.ticket && ticket_info.item )
{
find_ticket_value(value_for_param_id, ticket_info.ticket->par_tab, ticket_info.item->meta);
if( value_for_param_id.is_value )
{
if( value_for_param_id.is_in_ticket_par )
{
i.res = value_for_param_id.ticket_par->intv == id2;
}
else
{
log << log1 << "Ticket: ticket_does_param_id_have_value cannot be used with meta values"
<< logend;
}
}
}
break;
}
}
}
}
namespace ns_tickets_tab
@ -331,7 +385,7 @@ struct TicketsTabValue
Ticket * ticket; // pointer to the ticket (if is_ticket is true)
/*
there can be two situations:
there can be three situations:
- is_item is false and is_ticket is false
- is_item is true and is_ticket is false
- is_item is true and is_ticket is true
@ -439,18 +493,17 @@ void tickets_tab(Info & i)
// !! IMPROVEME if there is no a ticket (find_ticket returns false)
// may we add en ampty ticket and tickets_value.ticket will be pointing to it?
// !! IMPROVE ME change the name of the message
// !! IMPROVEME change the name of the message
plugin.Call(WINIX_PL_TICKET_TICKETS_TAB_IS_NEXT, tickets_value.item);
if( find_ticket(file_id, ticket_info.ticket_tab, ticket_index) )
{
tickets_value.is_ticket = true;
tickets_value.ticket = &ticket_info.ticket_tab[ticket_index];
}
else
{
log << log1 << "Ticket: I cannot find a ticket for file_id: " << file_id << logend;
}
plugin.Call(WINIX_PL_THREAD_SET_SORTTAB_INDEX, item_sort_index);
@ -482,6 +535,7 @@ void tickets_tab_url(Info & i)
}
// !! IMPROVEME change name to tickets_tab_subject_is_empty
void tickets_tab_subject_empty(Info & i)
{
tickets_tab_check_reqid();
@ -555,7 +609,6 @@ void tickets_tab_param_value_for_param_id(Info & i)
value_for_param_id.config_par = space.spaces[param_index];
value_for_param_id.param_id = value_for_param_id.config_par->Long(L"id");
// !! CHECKME don't we have to test tickets_value.ticket and tickets_value.item?
find_ticket_value(value_for_param_id, tickets_value.ticket->par_tab, tickets_value.item->meta);
ticket_print_value(i, value_for_param_id);
@ -567,6 +620,50 @@ void tickets_tab_param_value_for_param_id(Info & i)
// it takes two integer parameters (param id and value)
void tickets_tab_does_param_id_have_value(Info & i)
{
tickets_tab_check_reqid();
if( tickets_value.is_ticket && i.params.size() == 2 )
{
size_t param_index = 0;
PT::Space & space = *ticket_info.cur_conf;
long id = Toi(i.params[0]);
long id2 = Toi(i.params[1]);
for( ; param_index < space.spaces.size() ; ++param_index)
{
if( space.spaces[param_index]->name == L"param" &&
space.spaces[param_index]->Int(L"id") == id )
{
value_for_param_id.Clear();
value_for_param_id.is_param = true;
value_for_param_id.config_par = space.spaces[param_index];
value_for_param_id.param_id = value_for_param_id.config_par->Long(L"id");
find_ticket_value(value_for_param_id, tickets_value.ticket->par_tab, tickets_value.item->meta);
if( value_for_param_id.is_value )
{
if( value_for_param_id.is_in_ticket_par )
{
i.res = value_for_param_id.ticket_par->intv == id2;
}
else
{
log << log1 << "Ticket: tickets_tab_does_param_id_have_value cannot be used with meta values"
<< logend;
}
}
break;
}
}
}
}
void tickets_tab_conf_tab(Info & i)
{
tickets_tab_check_reqid();
@ -601,6 +698,25 @@ void tickets_tab_conf_tab_has_value(Info & i)
}
void tickets_tab_conf_tab_param_id(Info & i)
{
tickets_tab_check_reqid();
if( value.is_param )
i.out << value.param_id;
}
// takes one parameter
void tickets_tab_conf_tab_param_id_is(Info & i)
{
tickets_tab_check_reqid();
if( value.is_param )
i.res = (value.param_id == Tol(i.par));
}
void tickets_tab_conf_tab_param_name(Info & i)
{
tickets_tab_check_reqid();
@ -794,6 +910,16 @@ void ticket_tab_param_id(Info & i)
}
// takes one parameter
void ticket_tab_param_id_is(Info & i)
{
ticket_tab_check_reqid();
if( value.is_param )
i.res = (value.param_id == Tol(i.par));
}
void ticket_tab_param_name(Info & i)
{
ticket_tab_check_reqid();
@ -1034,60 +1160,64 @@ using namespace ns_ticket_tab;
using TemplatesFunctions::EzcFun;
EzcFun * fun = reinterpret_cast<EzcFun*>(info.p1);
fun->Insert("ticket_can_create", ticket_can_create);
fun->Insert("ticket_can_edit", ticket_can_edit);
fun->Insert("ticket_is_creating_new", ticket_is_creating_new);
fun->Insert("ticket_meta_value", ticket_meta_value);
fun->Insert("ticket_is_closed", ticket_is_closed);
fun->Insert("ticket_can_create", ticket_can_create);
fun->Insert("ticket_can_edit", ticket_can_edit);
fun->Insert("ticket_is_creating_new", ticket_is_creating_new);
fun->Insert("ticket_meta_value", ticket_meta_value);
fun->Insert("ticket_is_closed", ticket_is_closed);
fun->Insert("ticket_param_value_for_param_id", ticket_param_value_for_param_id);
fun->Insert("ticket_param_value_for_param_id", ticket_param_value_for_param_id);
fun->Insert("ticket_does_param_id_have_value", ticket_does_param_id_have_value);
fun->Insert("tickets_tab", tickets_tab);
fun->Insert("tickets_tab_is_closed", tickets_tab_is_closed);
fun->Insert("tickets_tab_url", tickets_tab_url);
fun->Insert("tickets_tab_subject_empty", tickets_tab_subject_empty);
fun->Insert("tickets_tab_subject", tickets_tab_subject);
fun->Insert("tickets_tab_meta_value", tickets_tab_meta_value);
fun->Insert("tickets_tab_date_creation", tickets_tab_date_creation);
fun->Insert("tickets_tab_date_creation_nice", tickets_tab_date_creation_nice);
fun->Insert("tickets_tab_param_value_for_param_id", tickets_tab_param_value_for_param_id);
fun->Insert("tickets_tab_does_param_id_have_value", tickets_tab_does_param_id_have_value);
fun->Insert("tickets_tab_conf_tab", tickets_tab_conf_tab);
fun->Insert("tickets_tab_conf_tab_has_value", tickets_tab_conf_tab_has_value);
fun->Insert("tickets_tab_conf_tab_param_id", tickets_tab_conf_tab_param_id);
fun->Insert("tickets_tab_conf_tab_param_id_is", tickets_tab_conf_tab_param_id_is);
fun->Insert("tickets_tab_conf_tab_param_name", tickets_tab_conf_tab_param_name);
fun->Insert("tickets_tab_conf_tab_value", tickets_tab_conf_tab_value);
fun->Insert("tickets_tab_conf_tab_type_is", tickets_tab_conf_tab_type_is);
fun->Insert("tickets_tab_conf_tab_progress_image_number", tickets_tab_conf_tab_progress_image_number);
fun->Insert("tickets_tab_conf_tab_file_tab", tickets_tab_conf_tab_file_tab);
fun->Insert("tickets_tab_conf_tab_file_tab_index", tickets_tab_conf_tab_file_tab_index);
fun->Insert("tickets_tab_conf_tab_file_tab_path", tickets_tab_conf_tab_file_tab_path);
fun->Insert("tickets_tab_conf_tab_file_tab_itemid", tickets_tab_conf_tab_file_tab_itemid);
fun->Insert("tickets_tab_conf_tab_file_tab_meta", tickets_tab_conf_tab_file_tab_meta);
fun->Insert("tickets_tab", tickets_tab);
fun->Insert("tickets_tab_is_closed", tickets_tab_is_closed);
fun->Insert("tickets_tab_url", tickets_tab_url);
fun->Insert("tickets_tab_subject_empty", tickets_tab_subject_empty);
fun->Insert("tickets_tab_subject", tickets_tab_subject);
fun->Insert("tickets_tab_meta_value", tickets_tab_meta_value);
fun->Insert("tickets_tab_date_creation", tickets_tab_date_creation);
fun->Insert("tickets_tab_date_creation_nice", tickets_tab_date_creation_nice);
fun->Insert("ticket_tab", ticket_tab);
fun->Insert("ticket_tab_param_id", ticket_tab_param_id);
fun->Insert("ticket_tab_param_id_is", ticket_tab_param_id_is);
fun->Insert("ticket_tab_param_name", ticket_tab_param_name);
fun->Insert("ticket_tab_has_value", ticket_tab_has_value);
fun->Insert("ticket_tab_value", ticket_tab_value);
fun->Insert("ticket_tab_value_int", ticket_tab_value_int);
fun->Insert("ticket_tab_value_dec", ticket_tab_value_dec);
fun->Insert("ticket_tab_value_meta", ticket_tab_value_meta);
fun->Insert("ticket_tab_type_is", ticket_tab_type_is);
fun->Insert("tickets_tab_param_value_for_param_id", tickets_tab_param_value_for_param_id);
fun->Insert("ticket_tab_select_tab", ticket_tab_select_tab);
fun->Insert("ticket_tab_select_tab_is_selected", ticket_tab_select_tab_is_selected);
fun->Insert("ticket_tab_select_tab_name", ticket_tab_select_tab_name);
fun->Insert("ticket_tab_select_tab_id", ticket_tab_select_tab_id);
fun->Insert("ticket_tab_select_tab_meta", ticket_tab_select_tab_meta);
fun->Insert("tickets_tab_conf_tab", tickets_tab_conf_tab);
fun->Insert("tickets_tab_conf_tab_has_value", tickets_tab_conf_tab_has_value);
fun->Insert("tickets_tab_conf_tab_param_name", tickets_tab_conf_tab_param_name);
fun->Insert("tickets_tab_conf_tab_value", tickets_tab_conf_tab_value);
fun->Insert("tickets_tab_conf_tab_type_is", tickets_tab_conf_tab_type_is);
fun->Insert("tickets_tab_conf_tab_progress_image_number", tickets_tab_conf_tab_progress_image_number);
fun->Insert("tickets_tab_conf_tab_file_tab", tickets_tab_conf_tab_file_tab);
fun->Insert("tickets_tab_conf_tab_file_tab_index", tickets_tab_conf_tab_file_tab_index);
fun->Insert("tickets_tab_conf_tab_file_tab_path", tickets_tab_conf_tab_file_tab_path);
fun->Insert("tickets_tab_conf_tab_file_tab_itemid", tickets_tab_conf_tab_file_tab_itemid);
fun->Insert("tickets_tab_conf_tab_file_tab_meta", tickets_tab_conf_tab_file_tab_meta);
fun->Insert("ticket_tab", ticket_tab);
fun->Insert("ticket_tab_param_id", ticket_tab_param_id);
fun->Insert("ticket_tab_param_name", ticket_tab_param_name);
fun->Insert("ticket_tab_has_value", ticket_tab_has_value);
fun->Insert("ticket_tab_value", ticket_tab_value);
fun->Insert("ticket_tab_value_int", ticket_tab_value_int);
fun->Insert("ticket_tab_value_dec", ticket_tab_value_dec);
fun->Insert("ticket_tab_value_meta", ticket_tab_value_meta);
fun->Insert("ticket_tab_type_is", ticket_tab_type_is);
fun->Insert("ticket_tab_select_tab", ticket_tab_select_tab);
fun->Insert("ticket_tab_select_tab_is_selected", ticket_tab_select_tab_is_selected);
fun->Insert("ticket_tab_select_tab_name", ticket_tab_select_tab_name);
fun->Insert("ticket_tab_select_tab_id", ticket_tab_select_tab_id);
fun->Insert("ticket_tab_select_tab_meta", ticket_tab_select_tab_meta);
fun->Insert("ticket_tab_file_tab", ticket_tab_file_tab);
fun->Insert("ticket_tab_file_tab_index", ticket_tab_file_tab_index);
fun->Insert("ticket_tab_file_tab_path", ticket_tab_file_tab_path);
fun->Insert("ticket_tab_file_tab_itemid", ticket_tab_file_tab_itemid);
fun->Insert("ticket_tab_file_tab_meta", ticket_tab_file_tab_meta);
fun->Insert("ticket_tab_file_tab", ticket_tab_file_tab);
fun->Insert("ticket_tab_file_tab_index", ticket_tab_file_tab_index);
fun->Insert("ticket_tab_file_tab_path", ticket_tab_file_tab_path);
fun->Insert("ticket_tab_file_tab_itemid", ticket_tab_file_tab_itemid);
fun->Insert("ticket_tab_file_tab_meta", ticket_tab_file_tab_meta);
}

View File

@ -561,19 +561,16 @@ PostFileTab::iterator i2;
void TicketInfo::RemoveTicket(long file_id)
{
/*
* IMPROVEME
* we should also remove some files (images) for a ticket
* may when 'rm' function is displayed we should show some checkboxes
* 'remove static files etc.' and if they are checked then the files are removed?
*
*/
if( tdb->GetTicket(file_id, rm_ticket) == WINIX_ERR_OK )
{
// !! WTF?
/*
for(size_t i=0 ; i<rm_ticket.par_tab.size(); ++i)
{
long id = rm_ticket.par_tab[i].int_value;
functions->fun_rm.RemoveItemById(id);
}
*/
//
tdb->RemoveTicket(file_id);
}
}