<?php
/***************************************************************************
- * Copyright (C) 2003-2011 Polytechnique.org *
+ * Copyright (C) 2003-2014 Polytechnique.org *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
const PERM_API_USER_READONLY = 'api_user_readonly';
const PERM_DIRECTORY_AX = 'directory_ax';
const PERM_DIRECTORY_PRIVATE = 'directory_private';
+ const PERM_DIRECTORY_HIDDEN = 'directory_hidden';
const PERM_EDIT_DIRECTORY = 'edit_directory';
const PERM_FORUMS = 'forums';
const PERM_GROUPS = 'groups';
IF(ef.email IS NULL, NULL, CONCAT(ef.email, \'@\', df.name)) AS forlife_alternate,
IF(eb.email IS NULL, NULL, CONCAT(eb.email, \'@\', mb.name)) AS bestalias,
(er.redirect IS NULL AND a.state = \'active\' AND FIND_IN_SET(\'mail\', at.perms)) AS lost,
- a.email, a.full_name, a.directory_name, a.display_name, a.sex = \'female\' AS gender,
+ a.email, a.full_name, a.directory_name, a.display_name, a.sort_name, a.sex = \'female\' AS gender,
IF(a.state = \'active\', CONCAT(at.perms, \',\', IF(a.user_perms IS NULL, \'\', a.user_perms)), \'\') AS perms,
a.user_perms, a.email_format, a.is_admin, a.state, a.type, at.description AS type_description, a.skin,
FIND_IN_SET(\'watch\', a.flags) AS watch, a.comment,
*
* Rules are:
* - Everyone can view 'public'
- * - directory_ax gives access to 'AX' level
+ * - directory_ax gives access to 'AX' level, ie. the printed directory
* - directory_private gives access to 'private' level
- * - admin gives access to 'hidden' level
+ * - admin and directory_hidden gives access to 'hidden' level
*/
public function readVisibility()
{
$level = Visibility::VIEW_NONE;
- if ($this->is_admin) {
+ if ($this->is_admin || $this->checkPerms('directory_hidden')) {
$level = Visibility::VIEW_ADMIN;
} elseif ($this->checkPerms('directory_private')) {
$level = Visibility::VIEW_PRIVATE;
return $this->profile()->directory_name;
}
+ public function sortName()
+ {
+ if (!$this->hasProfile()) {
+ return $this->sort_name;
+ }
+ return $this->profile()->sort_name;
+ }
+
static public function compareDirectoryName($a, $b)
{
return strcasecmp(replace_accent($a->directoryName()), replace_accent($b->directoryName()));
}
}
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8:
?>