added: issues ticket system
added functions: ticket, createticket, editticket (there is no 'rm' function working for tickets yet) changed: mount parser and mount points now we have more parameters (arguments in parameters) some refactoring in functions 'emacs' and 'mkdir' git-svn-id: svn://ttmath.org/publicrep/cmslu/trunk@554 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
173
core/mount.cpp
173
core/mount.cpp
@@ -14,15 +14,17 @@
|
||||
|
||||
Mount::Mount()
|
||||
{
|
||||
type = cms;
|
||||
type = cms;
|
||||
dir_id = -1;
|
||||
|
||||
param.resize(par_none);
|
||||
}
|
||||
|
||||
|
||||
|
||||
const char * Mount::TypeToStr()
|
||||
{
|
||||
static char buffer[30];
|
||||
static char buffer[30];
|
||||
|
||||
switch( type )
|
||||
{
|
||||
@@ -34,8 +36,12 @@ const char * Mount::TypeToStr()
|
||||
sprintf(buffer, "thread");
|
||||
break;
|
||||
|
||||
case ticket:
|
||||
sprintf(buffer, "ticket");
|
||||
break;
|
||||
|
||||
default:
|
||||
sprintf(buffer, "the name is not set");
|
||||
sprintf(buffer, "unknown");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -43,82 +49,105 @@ return buffer;
|
||||
}
|
||||
|
||||
|
||||
bool Mount::ParseStrParam(const std::string & param, const std::vector<int> & args)
|
||||
|
||||
Mount::ParamCode Mount::ParseParam(const char * param_name)
|
||||
{
|
||||
Param p = none;
|
||||
|
||||
if( param == "asc" )
|
||||
p = asc;
|
||||
else
|
||||
if( param == "desc" )
|
||||
p = desc;
|
||||
else
|
||||
if( param == "withheader" )
|
||||
p = withheader;
|
||||
else
|
||||
if( param == "withinfo" )
|
||||
p = withinfo;
|
||||
else
|
||||
if( param == "thread_with_header" )
|
||||
p = thread_with_header;
|
||||
else
|
||||
if( param == "thread_with_info" )
|
||||
p = thread_with_info;
|
||||
else
|
||||
if( param == "restrictcreatethread" )
|
||||
p = restrictcreatethread;
|
||||
else
|
||||
if( param == "only_root_can_remove" )
|
||||
p = only_root_can_remove;
|
||||
else
|
||||
if( param == "can_use_emacs_on" )
|
||||
p = can_use_emacs_on;
|
||||
else
|
||||
if( param == "can_use_mkdir_on" )
|
||||
p = can_use_mkdir_on;
|
||||
else
|
||||
if( param == "none" )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
|
||||
param_table.insert( std::make_pair(p, args) );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Mount::IsParam(Param p)
|
||||
{
|
||||
ParamTable::iterator i = param_table.find(p);
|
||||
|
||||
if( i == param_table.end() )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Mount::IsParam(Param p, int * first_arg)
|
||||
{
|
||||
ParamTable::iterator i = param_table.find(p);
|
||||
|
||||
if( i == param_table.end() )
|
||||
struct ParName
|
||||
{
|
||||
*first_arg = -1;
|
||||
return false;
|
||||
ParamCode param_code;
|
||||
const char * name;
|
||||
};
|
||||
|
||||
static ParName par_name_tab[] = {
|
||||
{ par_page, "page" },
|
||||
{ par_thread, "thread" },
|
||||
{ par_ticket, "ticket" },
|
||||
{ par_ticket_type, "ticket_type" },
|
||||
{ par_ticket_type_default, "ticket_type_default" },
|
||||
{ par_ticket_status, "ticket_status" },
|
||||
{ par_ticket_status_default, "ticket_status_default" },
|
||||
{ par_ticket_priority, "ticket_priority" },
|
||||
{ par_ticket_priority_default, "ticket_priority_default" },
|
||||
{ par_ticket_category, "ticket_category" },
|
||||
{ par_ticket_category_default, "ticket_category_default" },
|
||||
{ par_ticket_expected, "ticket_expected" },
|
||||
{ par_ticket_expected_default, "ticket_expected_default" },
|
||||
{ par_createthread_on, "createthread_on" },
|
||||
{ par_createticket_on, "createticket_on" },
|
||||
{ par_only_root_remove, "only_root_remove" },
|
||||
{ par_emacs_on, "emacs_on" },
|
||||
{ par_mkdir_on, "mkdir_on" }
|
||||
};
|
||||
|
||||
size_t i, len = sizeof(par_name_tab) / sizeof(ParName);
|
||||
|
||||
for(i=0 ; i<len ; ++i)
|
||||
{
|
||||
if( strcmp(par_name_tab[i].name, param_name) == 0 )
|
||||
return par_name_tab[i].param_code;
|
||||
}
|
||||
|
||||
if( !i->second.empty() )
|
||||
*first_arg = i->second[0];
|
||||
else
|
||||
*first_arg = -1;
|
||||
|
||||
return true;
|
||||
return par_none;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Mount::ClearParams()
|
||||
{
|
||||
param_table.clear();
|
||||
size_t i;
|
||||
|
||||
for(i=0 ; i<param.size() ; ++i)
|
||||
param[i].Clear();
|
||||
}
|
||||
|
||||
|
||||
bool Mount::IsPar(Mount::ParamCode code)
|
||||
{
|
||||
if( !param[code].defined )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Mount::IsArg(Mount::ParamCode code, const char * arg)
|
||||
{
|
||||
ParamArg::iterator i;
|
||||
|
||||
if( !param[code].defined )
|
||||
return false;
|
||||
|
||||
for(i=param[code].arg.begin() ; i!=param[code].arg.end() ; ++i)
|
||||
{
|
||||
if( *i == arg )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool Mount::IsArg(Mount::ParamCode code, const std::string & arg)
|
||||
{
|
||||
return IsArg(code, arg.c_str());
|
||||
}
|
||||
|
||||
|
||||
bool Mount::IsArg(Mount::ParamCode code, int arg)
|
||||
{
|
||||
ParamArg::iterator i;
|
||||
|
||||
if( !param[code].defined )
|
||||
return false;
|
||||
|
||||
for(i=param[code].arg.begin() ; i!=param[code].arg.end() ; ++i)
|
||||
{
|
||||
if( atoi(i->c_str()) == arg )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user