本文整理汇总了C++中user::Ptr::GetGroups方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::GetGroups方法的具体用法?C++ Ptr::GetGroups怎么用?C++ Ptr::GetGroups使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类user::Ptr
的用法示例。
在下文中一共展示了Ptr::GetGroups方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CalculateConfigHash
String UserDbObject::CalculateConfigHash(const Dictionary::Ptr& configFields) const
{
String hashData = DbObject::CalculateConfigHash(configFields);
User::Ptr user = static_pointer_cast<User>(GetObject());
Array::Ptr groups = user->GetGroups();
if (groups)
hashData += DbObject::HashValue(groups);
return SHA256(hashData);
}
示例2: EvaluateObjectRule
bool UserGroup::EvaluateObjectRule(const User::Ptr& user, const ConfigItem::Ptr& group)
{
String group_name = group->GetName();
CONTEXT("Evaluating rule for group '" + group_name + "'");
ScriptFrame frame;
if (group->GetScope())
group->GetScope()->CopyTo(frame.Locals);
frame.Locals->Set("user", user);
if (!group->GetFilter()->Evaluate(frame).GetValue().ToBool())
return false;
Log(LogDebug, "UserGroup")
<< "Assigning membership for group '" << group_name << "' to user '" << user->GetName() << "'";
Array::Ptr groups = user->GetGroups();
groups->Add(group_name);
return true;
}
示例3: OnConfigUpdateHeavy
void UserDbObject::OnConfigUpdateHeavy(void)
{
User::Ptr user = static_pointer_cast<User>(GetObject());
/* groups */
Array::Ptr groups = user->GetGroups();
std::vector<DbQuery> queries;
DbQuery query1;
query1.Table = DbType::GetByName("UserGroup")->GetTable() + "_members";
query1.Type = DbQueryDelete;
query1.Category = DbCatConfig;
query1.WhereCriteria = new Dictionary();
query1.WhereCriteria->Set("contact_object_id", user);
queries.push_back(query1);
if (groups) {
ObjectLock olock(groups);
for (const String& groupName : groups) {
UserGroup::Ptr group = UserGroup::GetByName(groupName);
DbQuery query2;
query2.Table = DbType::GetByName("UserGroup")->GetTable() + "_members";
query2.Type = DbQueryInsert | DbQueryUpdate;
query2.Category = DbCatConfig;
query2.Fields = new Dictionary();
query2.Fields->Set("instance_id", 0); /* DbConnection class fills in real ID */
query2.Fields->Set("contactgroup_id", DbValue::FromObjectInsertID(group));
query2.Fields->Set("contact_object_id", user);
query2.WhereCriteria = new Dictionary();
query2.WhereCriteria->Set("instance_id", 0); /* DbConnection class fills in real ID */
query2.WhereCriteria->Set("contactgroup_id", DbValue::FromObjectInsertID(group));
query2.WhereCriteria->Set("contact_object_id", user);
queries.push_back(query2);
}
}
DbObject::OnMultipleQueries(queries);
queries.clear();
DbQuery query2;
query2.Table = "contact_addresses";
query2.Type = DbQueryDelete;
query2.Category = DbCatConfig;
query2.WhereCriteria = new Dictionary();
query2.WhereCriteria->Set("contact_id", DbValue::FromObjectInsertID(user));
queries.push_back(query2);
Dictionary::Ptr vars = user->GetVars();
if (vars) { /* This is sparta. */
for (int i = 1; i <= 6; i++) {
Dictionary::Ptr fields = new Dictionary();
String key = "address" + Convert::ToString(i);
if (!vars->Contains(key))
continue;
String val = vars->Get(key);
fields->Set("contact_id", DbValue::FromObjectInsertID(user));
fields->Set("address_number", i);
fields->Set("address", val);
fields->Set("instance_id", 0); /* DbConnection class fills in real ID */
DbQuery query;
query.Type = DbQueryInsert;
query.Table = "contact_addresses";
query.Category = DbCatConfig;
query.Fields = fields;
queries.push_back(query);
}
}
DbObject::OnMultipleQueries(queries);
}