13 include_once (
"FDL/Lib.Dir.php");
50 private $returnType = self::returnAccount;
51 private $roleFilters = array();
52 private $groupFilters = array();
53 private $searchResult = array();
55 private $filters = array();
56 private $order =
'login';
57 private $slice =
'ALL';
59 private $familyFilter = null;
61 private $returnUser =
true;
62 private $returnGroup =
true;
63 private $returnRole =
true;
64 private $viewControl =
false;
78 $roles = explode(
' ', $role);
79 foreach ($roles as $aRole) {
80 $aRole = trim($aRole);
82 $sql = sprintf(
"select id from users where accounttype='R' and login='%s'", pg_escape_string(mb_strtolower($aRole)));
87 $this->roleFilters[] = $result;
99 $groups = explode(
' ', $group);
100 foreach ($groups as $aGroup) {
101 $aGroup = trim($aGroup);
103 $sql = sprintf(
"select id from users where accounttype='G' and login='%s'", pg_escape_string(mb_strtolower($aGroup)));
108 $this->groupFilters[] = $result;
123 $this->returnUser = (
$type & self::userType) == self::userType;
124 $this->returnGroup = (
$type & self::groupType) == self::groupType;
125 $this->returnRole = (
$type & self::roleType) == self::roleType;
139 $args = func_get_args();
140 if (count(
$args) > 1) {
142 for ($i = 1; $i < count(
$args); $i++) {
143 $fs[] = pg_escape_string(
$args[$i]);
145 $filter = call_user_func_array(
"sprintf", $fs);
158 $this->order = $order;
168 if (((!is_numeric($slice)) && (strtolower($slice) !=
'all')) || ($slice < 0)) {
171 if (is_numeric($slice)) $this->
slice = intval($slice);
172 else $this->
slice = $slice;
182 if ((!is_numeric($start)) || ($start < 0)) {
185 $this->
start = intval($start);
209 $this->viewControl = !$override;
223 if (
$type != self::returnAccount &&
$type != self::returnDocument) {
226 $this->returnType =
$type;
238 if (
$type != self::returnAccount &&
$type != self::returnDocument) {
241 $this->returnType =
$type;
257 return self::getLoginFromDocName($name);
270 $sql = sprintf(
"select login from docname, users where docname.id = users.fid and docname.name='%s'", pg_escape_string($name));
281 if (!is_numeric($family)) {
284 $this->familyFilter =
$famId;
286 $this->familyFilter = $family;
297 if ($this->returnType == self::returnAccount) {
302 foreach ($this->searchResult as
$account) {
303 if ($account[
"fid"]) $ids[] = $account[
"fid"];
307 $dl->addDocumentIdentifiers($ids);
315 private function getgroupRoleFilter()
317 $rids = array_merge($this->roleFilters, $this->groupFilters);
319 $filter = sprintf(
"memberof && '{%s}'", implode(
',', $rids));
332 $groupRoleFilter = $this->getgroupRoleFilter();
335 if ($this->viewControl && $u->id != 1) {
337 if ($this->familyFilter) {
338 $table =
"doc" . $this->familyFilter;
339 $sql = sprintf(
"select users.* from users, $table where users.fid = $table.id and $table.views && '%s' and %s ", $viewVector, $groupRoleFilter);
341 $sql = sprintf(
"select users.* from users, docread where users.fid = docread.id and docread.views && '%s' and %s ", $viewVector, $groupRoleFilter);
344 if ($this->familyFilter) {
345 $table =
"doc" . $this->familyFilter;
346 $sql = sprintf(
"select users.* from users, $table where users.fid = $table.id and %s ", $groupRoleFilter);
348 $sql = sprintf(
"select * from users where %s ", $groupRoleFilter);
351 foreach ($this->filters as $aFilter) {
352 $sql.= sprintf(
" and (%s) ", $aFilter);
355 if ((!$this->returnUser) || (!$this->returnGroup) || (!$this->returnRole)) {
357 if ($this->returnUser) $fa[] =
"accounttype='U'";
358 if ($this->returnGroup) $fa[] =
"accounttype='G'";
359 if ($this->returnRole) $fa[] =
"accounttype='R'";
360 if ($fa)
$sql.= sprintf(
" and (%s)", implode(
' or ', $fa));
363 if ($this->order)
$sql.= sprintf(
" order by %s", pg_escape_string($this->order));
364 $sql.= sprintf(
" offset %d limit %s", $this->
start, pg_escape_string($this->
slice));
static docName2login($name)
if(substr($wsh, 0, 1)!= '/') $args
addFilter($filter, $arg=null)
static getError($code, $args=null)
useViewControl($control=true)
overrideViewControl($override=true)
getFamIdFromName($dbaccess, $name)
deprecatedFunction($msg= '')
static getUserViewVector($uid)
static getLoginFromDocName($name)
simpleQuery($dbaccess, $query, &$result=array(), $singlecolumn=false, $singleresult=false, $useStrict=null)