Implemented permission settings for Roles.
parent
09f6266123
commit
94fba56dab
@ -0,0 +1,38 @@
|
||||
#include "permissionservice.h"
|
||||
|
||||
PermissionService::PermissionService()
|
||||
{
|
||||
}
|
||||
|
||||
PermissionService::~PermissionService()
|
||||
{
|
||||
}
|
||||
|
||||
QList<QSharedPointer<Permission> > PermissionService::forPlugin(const QString &pluginId)
|
||||
{
|
||||
Transaction tr;
|
||||
odb::database *db = Context::instance().db();
|
||||
permQuery q(permQuery::pluginId == pluginId);
|
||||
permResult result = db->query<Permission>(q);
|
||||
|
||||
QList<QSharedPointer<Permission> > ret;
|
||||
for (permResult::iterator it = result.begin(); it != result.end(); it++)
|
||||
{
|
||||
ret.append(it.load());
|
||||
}
|
||||
|
||||
tr.commit();
|
||||
return ret;
|
||||
}
|
||||
|
||||
QSharedPointer<Permission> PermissionService::forNameAndPlugin(const QString &name, const QString &pluginId)
|
||||
{
|
||||
Transaction tr;
|
||||
odb::database *db = Context::instance().db();
|
||||
permQuery q(permQuery::pluginId == pluginId && permQuery::permissionName == name);
|
||||
QSharedPointer<Permission> p = db->query_one<Permission>(q);
|
||||
|
||||
tr.commit();
|
||||
return p;
|
||||
}
|
||||
|
@ -0,0 +1,30 @@
|
||||
#ifndef PERMISSIONSERVICE_H
|
||||
#define PERMISSIONSERVICE_H
|
||||
|
||||
#include "service.h"
|
||||
#include "permission.h"
|
||||
#include "core-odb.hxx"
|
||||
#include "core_global.h"
|
||||
#include <odb/core.hxx>
|
||||
#include <odb/database.hxx>
|
||||
#include <odb/query.hxx>
|
||||
#include <odb/result.hxx>
|
||||
|
||||
#include <QList>
|
||||
#include <QSharedPointer>
|
||||
#include <QString>
|
||||
|
||||
typedef odb::query<Permission> permQuery;
|
||||
typedef odb::result<Permission> permResult;
|
||||
|
||||
class CORESHARED_EXPORT PermissionService : public Service<Permission>
|
||||
{
|
||||
public:
|
||||
PermissionService();
|
||||
~PermissionService();
|
||||
|
||||
QList<QSharedPointer<Permission> > forPlugin(const QString &pluginId);
|
||||
QSharedPointer<Permission> forNameAndPlugin(const QString &name, const QString &pluginId);
|
||||
};
|
||||
|
||||
#endif // PERMISSIONSERVICE_H
|
Loading…
Reference in New Issue