本文整理汇总了PHP中ca_sets::setUsers方法的典型用法代码示例。如果您正苦于以下问题:PHP ca_sets::setUsers方法的具体用法?PHP ca_sets::setUsers怎么用?PHP ca_sets::setUsers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ca_sets
的用法示例。
在下文中一共展示了ca_sets::setUsers方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: shareSet
public function shareSet()
{
$pn_set_id = $this->request->getParameter('set_id', pInteger);
$t_set = new ca_sets();
if (!$t_set->haveAccessToSet($this->request->getUserID(), __CA_SET_EDIT_ACCESS__, $pn_set_id)) {
$this->notification->addNotification(_t("You cannot share this set"), "message");
} else {
$t_set->load($pn_set_id);
$vs_form_prefix = 'shareSetForm_';
$va_users_to_set = array();
foreach ($_REQUEST as $vs_key => $vs_val) {
if (preg_match("!^{$vs_form_prefix}id(.*)\$!", $vs_key, $va_matches)) {
$vn_user_id = (int) $this->request->getParameter($vs_form_prefix . 'id' . $va_matches[1], pInteger);
$vn_access = $this->request->getParameter($vs_form_prefix . 'access_' . $va_matches[1], pInteger);
if ($vn_access > 0) {
$va_users_to_set[$vn_user_id] = $vn_access;
}
}
}
$t_set->setUsers($va_users_to_set);
if ($t_set->numErrors()) {
$this->notification->addNotification(_t("There were errors while sharing: %1", join("; ", $t_set->getErrors())), "message");
} else {
$vn_c = sizeof($va_users_to_set);
$this->notification->addNotification($vn_c == 1 ? _t("Shared set with %1 user", $vn_c) : _t("Shared set with %1 users", $vn_c), "message");
}
}
$this->index();
}