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:
2010-01-25 04:52:17 +00:00
parent 356e93914b
commit 89daf6489d
48 changed files with 2856 additions and 874 deletions

View File

@@ -18,7 +18,7 @@
#include "data.h"
#include "plugin.h"
#include "misc.h"
#include "db.h"
Request::Request() : char_empty(0)
@@ -95,6 +95,11 @@ void Request::Clear()
is_thread = false;
thread.Clear();
thread_tab.clear();
is_ticket = false;
ticket.Clear();
ticket_tab.clear();
notify_code = 0;
browser_msie = false;
redirect_to.clear();
@@ -416,13 +421,13 @@ void Request::SendHeaders(bool compressing, Header header)
{
case h_404:
FCGX_PutS("Status: 404 Not Found\r\n", out);
FCGX_PutS("Content-Type: Text/Html\r\n", out);
FCGX_PutS("Content-Type: text/html\r\n", out);
log << log2 << "Request: response: 404 Not Found" << logend;
break;
case h_403:
FCGX_PutS("Status: 403 Forbidden\r\n", out);
FCGX_PutS("Content-Type: Text/Html\r\n", out);
FCGX_PutS("Content-Type: text/html\r\n", out);
log << log2 << "Request: response: 403 Forbidden" << logend;
break;
@@ -430,7 +435,7 @@ void Request::SendHeaders(bool compressing, Header header)
FCGX_PutS("Status: 200 OK\r\n", out);
if( role != authorizer )
FCGX_PutS("Content-Type: Text/Html\r\n", out);
FCGX_PutS("Content-Type: text/html\r\n", out);
}
}
@@ -683,31 +688,76 @@ bool Request::CanCreateThread(bool check_root)
if( !HasWriteAccess(*request.dir_table.back()) )
return false;
if( data.mounts.CurrentMountType() != Mount::thread )
if( !data.mounts.pmount || data.mounts.pmount->type != Mount::thread )
return false;
if( !check_root && session && session->puser && session->puser->super_user )
// super can create thread regardless of the restrictcreatethread option
return true;
if( !data.mounts.pmount->IsPar(Mount::par_createthread_on) )
return true;
// !! w przyszlosci mozna odczytywac wiecej parametrow od restrictcreatethread
// tymczasowo wykorzystujemy tylko pierwszy
int level;
if( data.mounts.CurrentMountIsParam(Mount::restrictcreatethread, &level) )
{
if( level == -1 )
return false;
if( data.mounts.pmount->IsArg(Mount::par_createthread_on, request.dir_table.size()) )
return true;
// we can only allow on a specific level
if( int(request.dir_table.size()) != level )
return false;
}
return false;
}
// returning true if we can create a ticket in the current directory
bool Request::CanCreateTicket(bool check_root)
{
if( request.dir_table.empty() )
return false;
if( request.is_item )
return false;
if( !HasWriteAccess(*request.dir_table.back()) )
return false;
if( !data.mounts.pmount || data.mounts.pmount->type != Mount::ticket )
return false;
// checking for par_createticket_on mount option
if( !check_root && session && session->puser && session->puser->super_user )
// super can create tickets regardless of the createticket_on option
return true;
if( !data.mounts.pmount->IsPar(Mount::par_createticket_on) )
return true;
if( data.mounts.pmount->IsArg(Mount::par_createticket_on, request.dir_table.size()) )
return true;
return false;
}
bool Request::CanEditTicket()
{
if( request.dir_table.empty() )
return false;
if( request.is_item || !request.is_ticket )
return false;
if( !HasWriteAccess(*request.dir_table.back()) )
return false;
if( !data.mounts.pmount || data.mounts.pmount->type != Mount::ticket )
return false;
return true;
}
bool Request::CanRemove(const Item & item)
{
if( item.parent_id == -1 )
@@ -729,8 +779,7 @@ bool Request::CanRemove(const Item & item)
return false;
}
if( data.mounts.CurrentMountIsParam(Mount::only_root_can_remove) )
// this can be deleted only be a root
if( data.mounts.pmount->IsPar(Mount::par_only_root_remove) )
if( !request.session->puser || !request.session->puser->super_user )
return false;
@@ -747,13 +796,13 @@ bool Request::CanUseEmacs(const Item & item, bool check_root)
if( !request.HasWriteAccess(item) )
return false;
int level;
if( data.mounts.CurrentMountIsParam(Mount::can_use_emacs_on, &level) )
if( level != int(request.dir_table.size()) )
return false;
if( !data.mounts.pmount->IsPar(Mount::par_emacs_on) )
return true;
if( data.mounts.pmount->IsArg(Mount::par_emacs_on, request.dir_table.size()) )
return true;
return true;
return false;
}
@@ -770,13 +819,13 @@ bool Request::CanUseMkdir(const Item & item, bool check_root)
if( !request.HasWriteAccess(item) )
return false;
int level;
if( data.mounts.CurrentMountIsParam(Mount::can_use_mkdir_on, &level) )
if( level != int(request.dir_table.size()) )
return false;
if( !data.mounts.pmount->IsPar(Mount::par_mkdir_on) )
return true;
if( data.mounts.pmount->IsArg(Mount::par_mkdir_on, request.dir_table.size()) )
return true;
return true;
return false;
}
@@ -839,20 +888,32 @@ return false;
bool Request::MakeDirsOnFS(std::string & path)
// !! dobrac lepsze nazwy dla tych dwoch metod
void Request::MakePath(std::string & path)
{
size_t i;
path = data.static_auth_dir;
// skipping the first - the first is root
for(i=1 ; i<dir_table.size() ; ++i)
{
path += '/';
path += dir_table[i]->url;
}
}
bool Request::MakeDirsOnFS()
{
size_t i;
std::string path = data.static_auth_dir;
// skipping the first - the first is root
for(i=1 ; i<dir_table.size() ; ++i)
{
path += '/';
path += dir_table[i]->url;
if( mkdir(path.c_str(), 0750) < 0 )
if( mkdir(path.c_str(), 0755) < 0 )
{
// oops
log << log1 << "Request: can't create the directory on fs: " << path << logend;