mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
add home field to groups table for using different startpages for groups
This commit is contained in:
parent
d35c4682c2
commit
768a9f2191
@ -3,6 +3,7 @@ CREATE TABLE `groups` (
|
||||
`alias` varchar(190) NOT NULL,
|
||||
`name` varchar(255) NOT NULL,
|
||||
`url` varchar(255) NOT NULL,
|
||||
`home` varchar(255) DEFAULT "/",
|
||||
`description` text,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `alias` (`alias`)
|
||||
|
||||
@ -13,9 +13,9 @@ namespace controller {
|
||||
|
||||
}
|
||||
|
||||
Poco::AutoPtr<Group> Group::create(const std::string& alias, const std::string& name, const std::string& url, const std::string& description)
|
||||
Poco::AutoPtr<Group> Group::create(const std::string& alias, const std::string& name, const std::string& url, const std::string& home, const std::string& description)
|
||||
{
|
||||
auto db = new model::table::Group(alias, name, url, description);
|
||||
auto db = new model::table::Group(alias, name, url, home, description);
|
||||
auto group = new Group(db);
|
||||
return Poco::AutoPtr<Group>(group);
|
||||
}
|
||||
@ -57,7 +57,7 @@ namespace controller {
|
||||
auto session = cm->getConnection(CONNECTION_MYSQL_LOGIN_SERVER);
|
||||
Poco::Data::Statement select(session);
|
||||
|
||||
select << "SELECT id, alias, name, url, description FROM " << db->getTableName()
|
||||
select << "SELECT id, alias, name, url, home, description FROM " << db->getTableName()
|
||||
, Poco::Data::Keywords::into(group_list);
|
||||
|
||||
size_t resultCount = 0;
|
||||
|
||||
@ -14,7 +14,7 @@ namespace controller {
|
||||
|
||||
~Group();
|
||||
|
||||
static Poco::AutoPtr<Group> create(const std::string& alias, const std::string& name, const std::string& url, const std::string& description);
|
||||
static Poco::AutoPtr<Group> create(const std::string& alias, const std::string& name, const std::string& url, const std::string& home, const std::string& description);
|
||||
|
||||
static std::vector<Poco::AutoPtr<Group>> load(const std::string& alias);
|
||||
static Poco::AutoPtr<Group> load(int id);
|
||||
|
||||
@ -8,15 +8,15 @@ namespace model {
|
||||
{
|
||||
}
|
||||
|
||||
Group::Group(const std::string& alias, const std::string& name, const std::string& url, const std::string& description)
|
||||
: mAlias(alias), mName(name), mUrl(url), mDescription(description)
|
||||
Group::Group(const std::string& alias, const std::string& name, const std::string& url, const std::string& home, const std::string& description)
|
||||
: mAlias(alias), mName(name), mUrl(url), mHome(home), mDescription(description)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Group::Group(GroupTuple tuple)
|
||||
: ModelBase(tuple.get<0>()),
|
||||
mAlias(tuple.get<1>()), mName(tuple.get<2>()), mUrl(tuple.get<3>()), mDescription(tuple.get<4>())
|
||||
mAlias(tuple.get<1>()), mName(tuple.get<2>()), mUrl(tuple.get<3>()), mHome(tuple.get<4>()), mDescription(tuple.get<5>())
|
||||
{
|
||||
|
||||
}
|
||||
@ -32,6 +32,7 @@ namespace model {
|
||||
ss << "Alias: " << mAlias << std::endl;
|
||||
ss << "Name: " << mName << std::endl;
|
||||
ss << "Url: " << mUrl << std::endl;
|
||||
ss << "Home: " << mHome << std::endl;
|
||||
ss << "Description:" << mDescription << std::endl;
|
||||
return ss.str();
|
||||
}
|
||||
@ -40,9 +41,9 @@ namespace model {
|
||||
{
|
||||
Poco::Data::Statement select(session);
|
||||
|
||||
select << "SELECT id, alias, name, url, description FROM " << getTableName()
|
||||
select << "SELECT id, alias, name, url, home, description FROM " << getTableName()
|
||||
<< " where " << fieldName << " = ?"
|
||||
, into(mID), into(mAlias), into(mName), into(mUrl), into(mDescription);
|
||||
, into(mID), into(mAlias), into(mName), into(mUrl), into(mHome), into(mDescription);
|
||||
|
||||
return select;
|
||||
}
|
||||
@ -51,7 +52,7 @@ namespace model {
|
||||
{
|
||||
Poco::Data::Statement select(session);
|
||||
|
||||
select << "SELECT id, alias, name, url, description FROM " << getTableName();
|
||||
select << "SELECT id, alias, name, url, home, description FROM " << getTableName();
|
||||
|
||||
return select;
|
||||
}
|
||||
@ -60,7 +61,7 @@ namespace model {
|
||||
{
|
||||
Poco::Data::Statement select(session);
|
||||
// typedef Poco::Tuple<std::string, std::string, std::string, Poco::Nullable<Poco::Data::BLOB>, int> UserTuple;
|
||||
select << "SELECT id, alias, name, url, description FROM " << getTableName()
|
||||
select << "SELECT id, alias, name, url, home, description FROM " << getTableName()
|
||||
<< " where " << fieldName << " LIKE ?";
|
||||
|
||||
return select;
|
||||
@ -81,7 +82,7 @@ namespace model {
|
||||
Poco::Data::Statement insert(session);
|
||||
lock();
|
||||
insert << "INSERT INTO " << getTableName()
|
||||
<< " (alias, name, url, description) VALUES(?,?,?,?)"
|
||||
<< " (alias, name, url, home, description) VALUES(?,?,?,?,?)"
|
||||
, use(mAlias), use(mName), use(mUrl), use(mDescription);
|
||||
unlock();
|
||||
return insert;
|
||||
|
||||
@ -7,13 +7,13 @@
|
||||
namespace model {
|
||||
namespace table {
|
||||
|
||||
typedef Poco::Tuple<int, std::string, std::string, std::string, std::string> GroupTuple;
|
||||
typedef Poco::Tuple<int, std::string, std::string, std::string, std::string, std::string> GroupTuple;
|
||||
|
||||
class Group : public ModelBase
|
||||
{
|
||||
public:
|
||||
Group();
|
||||
Group(const std::string& alias, const std::string& name, const std::string& url, const std::string& description);
|
||||
Group(const std::string& alias, const std::string& name, const std::string& url, const std::string& home, const std::string& description);
|
||||
Group(GroupTuple userTuple);
|
||||
~Group();
|
||||
|
||||
@ -25,10 +25,12 @@ namespace model {
|
||||
inline const std::string& getName() const { std::shared_lock<std::shared_mutex> _lock(mSharedMutex); return mName; }
|
||||
inline const std::string& getDescription() const { std::shared_lock<std::shared_mutex> _lock(mSharedMutex); return mDescription; }
|
||||
inline const std::string& getUrl() const { std::shared_lock<std::shared_mutex> _lock(mSharedMutex); return mUrl; }
|
||||
inline const std::string& getHome() const { SHARED_LOCK; return mHome; }
|
||||
|
||||
inline void setName(const std::string& name) { std::unique_lock<std::shared_mutex> _lock(mSharedMutex); mName = name; }
|
||||
inline void setDescription(const std::string& desc) { std::unique_lock<std::shared_mutex> _lock(mSharedMutex); mDescription = desc; }
|
||||
inline void setUrl(const std::string& url) { std::unique_lock<std::shared_mutex> _lock(mSharedMutex); mUrl = url; }
|
||||
inline void setHome(const std::string& home) { UNIQUE_LOCK; mHome = home; }
|
||||
|
||||
protected:
|
||||
Poco::Data::Statement _loadFromDB(Poco::Data::Session session, const std::string& fieldName);
|
||||
@ -40,6 +42,7 @@ namespace model {
|
||||
std::string mAlias;
|
||||
std::string mName;
|
||||
std::string mUrl;
|
||||
std::string mHome;
|
||||
std::string mDescription;
|
||||
|
||||
};
|
||||
|
||||
@ -23,6 +23,7 @@
|
||||
alias,
|
||||
form.get("group-name", ""),
|
||||
form.get("group-url", ""),
|
||||
form.get("group-home", ""),
|
||||
form.get("group-desc", "")
|
||||
);
|
||||
newGroup->getModel()->insertIntoDB(false);
|
||||
@ -47,6 +48,7 @@
|
||||
<div class="cell header-cell c2">Name</div>
|
||||
<div class="cell header-cell c2">Alias</div>
|
||||
<div class="cell header-cell c3">Url</div>
|
||||
<div class="cell header-cell c2">Home</div>
|
||||
<div class="cell header-cell c5"><%= gettext("Description") %></div>
|
||||
</div>
|
||||
<% for(auto it = groups.begin(); it != groups.end(); it++) {
|
||||
@ -56,6 +58,7 @@
|
||||
<div class="cell c2"><%= group_model->getName() %></div>
|
||||
<div class="cell c2"><%= group_model->getAlias() %></div>
|
||||
<div class="cell c3"><%= group_model->getUrl() %></div>
|
||||
<div class="cell c2"><%= group_model->getHome() %></div>
|
||||
<div class="cell c5"><%= group_model->getDescription()%></div>
|
||||
</div>
|
||||
<% } %>
|
||||
@ -72,6 +75,8 @@
|
||||
<input class="form-control" id="group-alias" type="text" name="group-alias"/>
|
||||
<label class="form-label" for="group-url">Url</label>
|
||||
<input class="form-control" id="group-url" type="text" name="group-url"/>
|
||||
<label class="form-label" for="group-home" title="Startpage link">Home</label>
|
||||
<input class="form-control" id="group-home" type="text" name="group-home"/>
|
||||
<label class="form-label" for="group-desc"><%= gettext("Description")%></label>
|
||||
<textarea class="form-control" name="group-desc" rows="3" maxlength="150" id="group-desc"></textarea>
|
||||
<input class="center-form-submit form-button" type="submit" name="submit" value="<%= gettext("Add Group") %>">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user