$first = 0;
}
}
+ }
+
+ /** The school identifier consists of 6 digits. The first 3 represent the
+ * promotion entry year. The last 3 indicate the student's rank.
+ *
+ * Our identifier consists of 8 digits and both half have the same role.
+ * This enables us to deal with bigger promotions and with a wider range
+ * of promotions.
+ *
+ * getSchoolId returns a school identifier given one of ours.
+ * getXorgId returns a X.org identifier given a school identifier.
+ */
+ public static function getSchoolId($xorgId)
+ {
+ if (!preg_match('/^[0-9]{8}$/', $xorgId)) {
+ return null;
+ }
+
+ $year = intval(substr($xorgId, 0, 4));
+ $rank = intval(substr($xorgId, 5, 3));
+ if ($year < 1996) {
+ return null;
+ } elseif ($year < 2000) {
+ $year = intval(substr(1900 - $year, 1, 3));
+ return sprintf('%02u0%03u', $year, $rank);
+ } else {
+ $year = intval(substr(1900 - $year, 1, 3));
+ return sprintf('%03u%03u', $year, $rank);
+ }
+ }
+ public static function getXorgId($schoolId)
+ {
+ $year = intval(substr($schoolId, 0, 3));
+ $rank = intval(substr($schoolId, 3, 3));
+ if ($year > 200) {
+ $year /= 10;
+ }
+ if ($year < 96) {
+ return null;
+ } else {
+ return sprintf('%04u%04u', 1900 + $year, $rank);
+ }
}
}
}
// }}}
-// {{{ function get_X_mat
-function get_X_mat($ourmat)
-{
- if (!preg_match('/^[0-9]{8}$/', $ourmat)) {
- // le matricule de notre base doit comporter 8 chiffres
- return 0;
- }
-
- $year = intval(substr($ourmat, 0, 4));
- $rang = intval(substr($ourmat, 5, 3));
- if ($year < 1996) {
- return;
- } elseif ($year < 2000) {
- $year = intval(substr(1900 - $year, 1, 3));
- return sprintf('%02u0%03u', $year, $rang);
- } else {
- $year = intval(substr(1900 - $year, 1, 3));
- return sprintf('%03u%03u', $year, $rang);
- }
-}
-
-// }}}
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************/
-require_once('user.func.inc.php');
-
class VCard extends PlVCard
{
private $profile_list = array();
return null;
}
- private static function getMatricule($mat)
- {
- $year = intval(substr($mat, 0, 3));
- $rang = intval(substr($mat, 3, 3));
- if ($year > 200) { $year /= 10; };
- if ($year < 96) {
- return null;
- } else {
- return sprintf('%04u%04u', 1900+$year, $rang);
- }
- }
-
private static function formatNewUser($infosLine, $separator, $promo, $size)
{
$infos = explode($separator, $infosLine);
&& ($sex = self::formatSex($page, $infos[3], $line))) {
$name = $infos[1] . ' ' . $infos[0];
$birthDate = self::formatBirthDate($infos[2]);
- $xorgId = self::getMatricule($infos[4]);
+ $xorgId = Profile::getXorgId($infos[4]);
XDB::execute('INSERT INTO profiles (hrpid, xorg_id, ax_id, birthdate_ref, sex)
VALUES ({?}, {?}, {?}, {?})',
static public function no_login_callback($login)
{
- require_once 'user.func.inc.php';
global $list_unregistered, $globals;
+ /* TODO: fixes this call to a removed function. */
$users = get_not_registered_user($login, true);
if ($users && $users->total()) {
if (!isset($list_unregistered)) {
}
$matricule = $user->profile()->xorg_id;
- require_once('user.func.inc.php');
- $matricule_X = get_X_mat($matricule);
+ $matricule_X = Profile::getSchoolId($matricule);
$page->assign('full_name', $user->fullName());
$page->assign('promo', $user->promo());
// Now that we know this is the profile of an existing user, we can
// switch to the appropriate template.
$page->changeTpl('profile/profile.tpl', SIMPLE);
- require_once 'user.func.inc.php';
// Determines the access level at which the profile will be displayed.
if (!S::logged() || Env::v('view') == 'public') {
function handler_referent(&$page, $user)
{
- require_once 'user.func.inc.php';
$page->changeTpl('profile/fiche_referent.tpl', SIMPLE);
$user = Profile::get($user);
private function changeLogin(PlPage &$page, PlUser &$user, MMList &$mmlist, $login)
{
- require_once 'user.func.inc.php';
// Search the uid of the user...
$res = XDB::query("SELECT f.id, f.alias
FROM aliases AS a
WHERE a.alias = {?}",
$login);
if ($res->numRows() == 0) {
+ // TODO: replace this call to a removed function.
$x = get_not_registered_user($login);
if (!$x) {
$page->trigError("Le login $login ne correspond à aucun X.");