本文整理汇总了PHP中UserGroup::getView方法的典型用法代码示例。如果您正苦于以下问题:PHP UserGroup::getView方法的具体用法?PHP UserGroup::getView怎么用?PHP UserGroup::getView使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserGroup
的用法示例。
在下文中一共展示了UserGroup::getView方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: UserGroup
/**
* Return select list of groups
*
* @param string $selected Id group preselected
* @param string $htmlname Field name in form
* @param int $show_empty 0=liste sans valeur nulle, 1=ajoute valeur inconnue
* @param string $exclude Array list of groups id to exclude
* @param int $disabled If select list must be disabled
* @param string $include Array list of groups id to include
* @param int $enableonly Array list of groups id to be enabled. All other must be disabled
* @return void
*/
function select_dolgroups($selected = '', $htmlname = 'groupid', $show_empty = 0, $exclude = '', $disabled = 0, $include = '', $enableonly = '')
{
global $conf, $user, $langs;
$out = '';
$object = new UserGroup($db);
$result = $object->getView("list");
if (count($result->rows) && is_array($exclude)) {
foreach ($result->rows as $key => $obj) {
if (in_array($obj->value->name, $exclude, true)) {
unset($result->rows[$key]);
}
}
}
$i = 0;
if (count($result->rows)) {
$out .= '<select class="flat" name="' . $htmlname . '"' . ($disabled ? ' disabled="disabled"' : '') . '>';
if ($show_empty) {
$out .= '<option value="-1"' . ($selected == -1 ? ' selected="selected"' : '') . '> </option>' . "\n";
}
foreach ($result->rows as $obj) {
$disableline = 0;
if (is_array($enableonly) && count($enableonly) && !in_array($obj->value->name, $enableonly)) {
$disableline = 1;
}
$out .= '<option value="' . $obj->value->name . '"';
if ($disableline) {
$out .= ' disabled="disabled"';
}
if (is_object($selected) && $selected->id == $obj->value->name || !is_object($selected) && $selected == $obj->value->name) {
$out .= ' selected="selected"';
}
$out .= '>';
$out .= $obj->value->name;
$out .= '</option>';
$i++;
}
} else {
$out .= '<select class="flat" name="' . $htmlname . '" disabled="disabled">';
$out .= '<option value="">' . $langs->trans("None") . '</option>';
}
$out .= '</select>';
return $out;
}
示例2: UserGroup
$object = new UserGroup($db);
/*
* View
*/
if ($_GET['json'] == "list") {
$output = array(
"sEcho" => intval($_GET['sEcho']),
"iTotalRecords" => 0,
"iTotalDisplayRecords" => 0,
"aaData" => array()
);
try {
$result = $object->getView("list");
} catch (Exception $exc) {
print $exc->getMessage();
}
//print_r ($result);
$iTotal = count($result->rows);
$output["iTotalRecords"] = $iTotal;
$output["iTotalDisplayRecords"] = $iTotal;
foreach ($result->rows as $aRow) {
$output["aaData"][] = $aRow->value;
}
header('Content-type: application/json');