Exemplo n.º 1
0
function slugify($string)
{
    $string = preg_replace('~[^\\pL\\d]+~u', '-', $string);
    $string = trim($string, '-');
    $string = toASCII($string);
    $string = strtolower($string);
    $string = preg_replace('~[^-\\w]+~', '', $string);
    if (empty($string)) {
        return null;
    }
    return $string;
}
Exemplo n.º 2
0
 private function rawprinter_writeData($printer, $data)
 {
     // una impresora de TPV tipica tiene 42 caracteres por linea
     // el simbolo "_" significa un espacio
     /*
     000000000011111111112222222222333333333344444444
     012345678901234567890123456789012345678901234567
     ------------------------------------------------
     PRUEBA        _JORNADA  _MANGA         _HH:MM:SS
     DRS_-_PERRO                  _LICN_C_-_GRDO_Celo
     GUIA                          _CLUB
     F:ff T:tt R:r TI:xxx.xxx TF:xxx.xxx ELimin/NoPre
     ------------------------------------------------
     */
     $p = $data['Prueba']->Nombre;
     $j = $data['Jornada']->Nombre;
     $m = Mangas::$tipo_manga[$data['Manga']->Tipo][3];
     $d = date('H:i:s');
     $l1 = sprintf("% -12s % -7s % 12s %s", substr(toASCII($p), 0, 12), substr(toASCII($j), 0, 7), substr(toASCII($m), 0, 12), $d);
     $printer->text($l1);
     $printer->feed(1);
     $drs = $data['Resultados']['Dorsal'];
     $dog = $data['Resultados']['Nombre'];
     $cat = $data['Resultados']['Categoria'];
     $grd = $data['Resultados']['Grado'];
     $lic = $data['Resultados']['Licencia'];
     $cel = $data['Resultados']['Celo'] != 0 ? "Celo" : "";
     $l2 = sprintf("%03d - % -18s % 4s %1s-% -4s %4s", $drs, substr(toASCII($dog), 0, 24), substr($lic, -5), $cat, $grd, $cel);
     $printer->text($l2);
     $printer->feed(1);
     $guia = $data['Resultados']['NombreGuia'];
     $club = $data['Resultados']['NombreClub'];
     $l3 = sprintf("% -27s % 14s", substr(toASCII($guia), 0, 27), substr(toASCII($club), 0, 14));
     $printer->text($l3);
     $printer->feed(1);
     $f = $data['Resultados']['Faltas'];
     $t = $data['Resultados']['Tocados'];
     $r = $data['Resultados']['Rehuses'];
     $ti = $data['Resultados']['TIntermedio'];
     $tf = $data['Resultados']['Tiempo'];
     // set up text according milliseconds precision and intermediate time status
     $tistr = sprintf("IT:%06.2f ", $ti);
     $tfstr = sprintf("FT:%06.2f ", $tf);
     if ($this->cronoMillis != 0) {
         $tistr = sprintf("IT:%07.3f", $ti);
         $tfstr = sprintf("FT:%07.3f", $tf);
     }
     if ($this->cronoInter != 0) {
         $tistr = "          ";
     }
     // no intermediate time: replace with spaces
     $e = $data['Resultados']['Eliminado'] != 0 ? _("Eliminated") : "";
     $n = $data['Resultados']['NoPresentado'] != 0 ? "Not Present" : "";
     $m = $n !== "" ? $n : $e;
     // Not present has precedence over eliminated
     $l4 = sprintf("F:%02d T:%02d R:%02d %s %s % -5s", $f, $t, $r, $tistr, $tfstr, substr($m, 0, 5));
     $printer->setDoubleStrike(true);
     $printer->text($l4);
     $printer->feed(1);
     // and finally add a separation line
     $printer->text("------------------------------------------");
     $printer->feed(1);
     $printer->setDoubleStrike(false);
     $this->myLogger->trace("\n'012345678901234567890123456789012345678901'\n'{$l1}'\n'{$l2}'\n'{$l3}'\n'{$l4}'");
 }
Exemplo n.º 3
0
/**
 * This function encapsulates all the strategies to find old records in moodle, matching
 * a new user proposal. In standard cases (regular updates), the username is sufficiant and
 * consistant. In cases of a system initialisation or IDP change, the username matching may require
 * some translation ro catch older records.
 *
 * the matching strategy adopted is a regressive check from very constrainted match to less constraint match
 */
function local_ent_installer_guess_old_record($newuser, &$status)
{
    global $DB;
    // We do not take care of case, our collation is FRENCH_CI_AI
    // If users come from an ITOP Active Directory we use the GUID ENT which is consistent and unique (not always the case for idnumber)
    if (isset($newuser->objectGUID) && strlen($newuser->objectGUID) == 36) {
        $oldrecs = $DB->get_records_sql('SELECT u.* FROM {user} u' . ' INNER JOIN {user_info_data} d ON u.id = d.userid' . ' INNER JOIN {user_info_field} f ON d.fieldid = f.id' . ' WHERE f.shortname = ? AND d.data = ?', array('guident', $newuser->objectGUID));
        if ($oldrecs) {
            $status = ENT_MATCH_GUID;
            return array_shift($oldrecs);
        }
    }
    // If all ID parts match, we are sure (usual case when regular updating).
    if (ENT_MATCH_FULL >= ENT_ALLOW_MINIMUM_MATCH_LEVEL) {
        $oldrec = $DB->get_record('user', array('username' => $newuser->username, 'idnumber' => $newuser->idnumber, 'firstname' => toASCII($newuser->firstname), 'lastname' => toASCII($newuser->lastname)));
        if ($oldrec) {
            $status = ENT_MATCH_FULL;
            return $oldrec;
        }
    }
    // Assuming matching IDNumber and all name parts is good : username not matching, will be updated to new
    if (ENT_MATCH_ID_NO_USERNAME >= ENT_ALLOW_MINIMUM_MATCH_LEVEL) {
        $oldrec = $DB->get_record('user', array('idnumber' => $newuser->idnumber, 'firstname' => toASCII($newuser->firstname), 'lastname' => toASCII($newuser->lastname)));
        if ($oldrec) {
            $status = ENT_MATCH_ID_NO_USERNAME;
            return $oldrec;
        }
    }
    // failover : IDNumber and last name match, but not firstname. this may occur with misspelling
    if (ENT_MATCH_ID_LASTNAME_NO_USERNAME_FIRSTNAME >= ENT_ALLOW_MINIMUM_MATCH_LEVEL) {
        $oldrec = $DB->get_record('user', array('idnumber' => $newuser->idnumber, 'lastname' => toASCII($newuser->lastname)));
        if ($oldrec) {
            $status = ENT_MATCH_ID_LASTNAME_NO_USERNAME_FIRSTNAME;
            return $oldrec;
        }
    }
    // failover : only login match
    if (ENT_MATCH_USERNAME_ONLY >= ENT_ALLOW_MINIMUM_MATCH_LEVEL) {
        $oldrec = $DB->get_record('user', array('username' => $newuser->username));
        if ($oldrec) {
            $status = ENT_MATCH_USERNAME_ONLY;
            return $oldrec;
        }
    }
    // failover : Only lastname and firstname match, but we might have more than one records
    if (ENT_MATCH_NO_ID_NO_USERNAME_LASTNAME_FIRSTNAME >= ENT_ALLOW_MINIMUM_MATCH_LEVEL) {
        $oldrecs = $DB->get_records('user', array('firstname' => toASCII($newuser->firstname), 'lastname' => toASCII($newuser->lastname)));
        if ($oldrecs) {
            $status = ENT_MATCH_NO_ID_NO_USERNAME_LASTNAME_FIRSTNAME;
            return array_shift($oldrecs);
        }
    }
    $status = ENT_NO_MATCH;
    return null;
}
Exemplo n.º 4
0
 function normalizeSheetName($name)
 {
     // convert to ASCII-7
     $name = toASCII($name);
     // remove forbidden characters
     $name = preg_replace('/[^A-Za-z0-9\\. -]/', '', $name);
     // limit to 31 chars
     $name = substr($name, 0, 31);
     return $name;
 }