diff --git a/include/dvb.class.php b/include/dvb.class.php index b7d42c684..e3eba7162 100644 --- a/include/dvb.class.php +++ b/include/dvb.class.php @@ -170,7 +170,7 @@ class dvb extends basis_db WHERE tbl_prestudent.person_id=".$this->db_add_param($person->person_id)." AND tbl_benutzer.aktiv - AND tbl_prestudentstatus.status_kurzbz='Student' + AND tbl_prestudentstatus.status_kurzbz in('Student','Incoming') AND tbl_prestudent.bismelden ORDER BY tbl_prestudentstatus.datum desc LIMIT 1 "; diff --git a/vilesci/cronjobs/bpk.php b/vilesci/cronjobs/bpk.php new file mode 100644 index 000000000..7fa7c8355 --- /dev/null +++ b/vilesci/cronjobs/bpk.php @@ -0,0 +1,126 @@ + + */ +/** + * Erfragt die BPKs von Personen beim Datenverbund und speichert diese wenn gefunden + * Dieses Script sollte nach dem Matrikelnummer Job aufgerufen werden da dieser bereits bpks ermittelt + * Dieser Job versucht die BPKs zu holen die nicht automatisch über den Matrikelnummer Job gefunden wurden. + */ +require_once(dirname(__FILE__).'/../../config/vilesci.config.inc.php'); +require_once(dirname(__FILE__).'/../../include/basis_db.class.php'); +require_once(dirname(__FILE__).'/../../include/dvb.class.php'); +require_once(dirname(__FILE__).'/../../include/benutzerberechtigung.class.php'); +require_once(dirname(__FILE__).'/../../include/datum.class.php'); +require_once(dirname(__FILE__).'/../../include/errorhandler.class.php'); + +if (!$db = new basis_db()) + die('Es konnte keine Verbindung zum Server aufgebaut werden.'); + +$limit = ''; +$debug = false; + +// Wenn das Script nicht ueber Commandline gestartet wird, muss eine +// Authentifizierung stattfinden +if (php_sapi_name() != 'cli') +{ + $nl = '
'; + // Benutzerdefinierte Variablen laden + $user = get_uid(); + loadVariables($user); + + // Berechtigungen pruefen + $rechte = new benutzerberechtigung(); + $rechte->getBerechtigungen($user); + + if (!$rechte->isBerechtigt('admin', null, 'suid')) + die('Sie haben keine Berechtigung für diese Seite'); + + if (isset($_GET['debug'])) + $debug = ($_GET['debug'] == 'true'?true:false); + + if (isset($_GET['limit']) && is_numeric($_GET['limit'])) + $limit = $_GET['limit']; +} +else +{ + $nl = "\n"; + // Commandline Paramter parsen bei Aufruf ueber Cronjob + // zb php matrikelnummer.php --limit 100 --debug true + $longopt = array( + "limit:", + "debug:" + ); + $commandlineparams = getopt('', $longopt); + if (isset($commandlineparams['limit']) && is_numeric($commandlineparams['limit'])) + $limit = $commandlineparams['limit']; + if (isset($commandlineparams['debug'])) + $debug = ($commandlineparams['debug'] == 'true'?true:false); +} + +$webservice = new dvb(DVB_USERNAME, DVB_PASSWORD, $debug); + +$qry = " + SELECT + distinct person_id, vorname, nachname + FROM + public.tbl_person + JOIN public.tbl_benutzer USING(person_id) + JOIN public.tbl_student ON(tbl_student.student_uid=tbl_benutzer.uid) + WHERE + public.tbl_benutzer.aktiv = true + AND tbl_person.matr_nr is not null + AND studiengang_kz<10000 + AND EXISTS(SELECT 1 FROM public.tbl_prestudent WHERE person_id=tbl_person.person_id AND bismelden=true) + AND gebdatum is not null"; + +if ($limit != '') + $qry .= " LIMIT ".$limit; + +$db = new basis_db(); +if ($result = $db->db_query($qry)) +{ + while ($row = $db->db_fetch_object($result)) + { + echo $nl."Pruefe $row->person_id $row->vorname $row->nachname"; + $data = $webservice->getBPK($row->person_id); + if (ErrorHandler::isSuccess($data)) + { + if (ErrorHandler::hasData($data) && isset($data->retval->bpk) && $data->retval->bpk != '') + { + $person = new person(); + if ($person->load($row->person_id)) + { + $person->bpk = $data->retval->bpk; + if ($person->save()) + echo ' OK'; + else + echo ' Failed: '.$person->errormsg; + } + } + else + { + echo 'Failed: BPK Empty'; + } + } + else + echo ' Failed:'.$webservice->errormsg; + } +} +if ($debug) + echo $webservice->debug_output; diff --git a/vilesci/cronjobs/matrikelnummern.php b/vilesci/cronjobs/matrikelnummern.php index 049ddb6e6..9cb3992b4 100644 --- a/vilesci/cronjobs/matrikelnummern.php +++ b/vilesci/cronjobs/matrikelnummern.php @@ -51,14 +51,14 @@ if (php_sapi_name() != 'cli') if (!$rechte->isBerechtigt('admin', null, 'suid')) die('Sie haben keine Berechtigung für diese Seite'); - if(isset($_GET['debug'])) - $debug = ($_GET['debug']=='true'?true:false); + if (isset($_GET['debug'])) + $debug = ($_GET['debug'] == 'true'?true:false); - if(isset($_GET['limit']) && is_numeric($_GET['limit'])) + if (isset($_GET['limit']) && is_numeric($_GET['limit'])) $limit = $_GET['limit']; - if(isset($_GET['softrun'])) - $debug = ($_GET['softrun']=='true'?true:false); + if (isset($_GET['softrun'])) + $debug = ($_GET['softrun'] == 'true'?true:false); } else { @@ -74,9 +74,9 @@ else if (isset($commandlineparams['limit']) && is_numeric($commandlineparams['limit'])) $limit = $commandlineparams['limit']; if (isset($commandlineparams['debug'])) - $debug = ($commandlineparams['debug']=='true'?true:false); + $debug = ($commandlineparams['debug'] == 'true'?true:false); if (isset($commandlineparams['softrun'])) - $softrun = ($commandlineparams['softrun']=='true'?true:false); + $softrun = ($commandlineparams['softrun'] == 'true'?true:false); } $matrikelnummer_added = 0; @@ -97,19 +97,19 @@ $qry = " AND (svnr is not null OR ersatzkennzeichen is not null)"; if ($limit != '') - $qry.=" LIMIT ".$limit; + $qry .= " LIMIT ".$limit; $db = new basis_db(); if ($result = $db->db_query($qry)) { - while($row = $db->db_fetch_object($result)) + while ($row = $db->db_fetch_object($result)) { echo $nl."Pruefe $row->person_id $row->vorname $row->nachname"; $data = $webservice->assignMatrikelnummer($row->person_id, $softrun); - if(ErrorHandler::isSuccess($data)) - echo $nl.$row->person_id.' OK'; + if (ErrorHandler::isSuccess($data)) + echo ' OK'; else - echo $nl.$row->person_id.' Failed:'.$webservice->errormsg; + echo ' Failed:'.$webservice->errormsg; } } if($debug)