1 /***************************************************************************
2 * Copyright (C) 2007 by David Cuadrado *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
27 #include "dashserver/users/user.h"
28 #include "dashserver/xdbms/manager.h"
32 namespace DashServer
{
35 struct Member::Private
37 QHash
<QString
, Users::Permission
*> permissions
;
40 Member::Member() : d(new Private
)
51 void Member::setUser(const QString
&login
)
56 Users::User
Member::user() const
63 XDBMS::Manager::self()->load("users", &user
);
68 void Member::setJob(const QString
&job
)
73 QString
Member::job() const
78 void Member::addPermission(int part
, Users::Permission::Opts opts
)
80 QString m
= Project::partName(part
);
82 addPermission(m
, opts
);
85 void Member::addPermission(const QString
&part
, Users::Permission::Opts opts
)
87 addPermission(new Users::Permission(part
, opts
));
90 void Member::addPermission(Users::Permission
*perm
)
92 QString module
= perm
->module();
94 if( !d
->permissions
.contains(module
) )
96 d
->permissions
[module
] = perm
;
106 QHash
<QString
, Users::Permission
*> Member::permissions()
108 return d
->permissions
;
111 bool Member::canReadOn(int part
) const
113 QString m
= Project::partName(part
);
115 if( d
->permissions
.contains(m
) )
117 return d
->permissions
[m
]->read();
123 bool Member::canWriteOn(int part
) const
125 QString m
= Project::partName(part
);
127 if( d
->permissions
.contains(m
) )
129 return d
->permissions
[m
]->write();