mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-24 02:12:17 +00:00
importing the api calls in the component and creating api endpoints for the cis profile page
This commit is contained in:
@@ -16,10 +16,16 @@ class Profil extends Auth_Controller
|
||||
{
|
||||
parent::__construct([
|
||||
'index' => ['student/anrechnung_beantragen:r','user:r'], // TODO(chris): permissions?
|
||||
'getUser' => ['student/anrechnung_beantragen:r','user:r']
|
||||
'getUser' => ['student/anrechnung_beantragen:r','user:r'],
|
||||
'isMitarbeiterOrStudent' => ['student/anrechnung_beantragen:r','user:r'],
|
||||
'getPersonInformation' => ['student/anrechnung_beantragen:r','user:r'],
|
||||
|
||||
]);
|
||||
$this->load->model('ressource/mitarbeiter_model', 'MitarbeiterModel');
|
||||
$this->load->model('ressource/student_model', 'StudentModel');
|
||||
$this->load->model('person/Benutzer_model', 'BenutzerModel');
|
||||
$this->load->model('person/Person_model', 'PersonModel');
|
||||
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
@@ -30,9 +36,11 @@ class Profil extends Auth_Controller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//echo = getAuthUID();
|
||||
|
||||
$this->load->view('Cis/Profil', ["uid" => getAuthUID()]);
|
||||
//? we can pass data to the view by using the second parameter of the load->view() function
|
||||
//* the first parameter is the route that Code Igniter will switch to
|
||||
//* the second parameter can be used to pass data to the view
|
||||
$this->load->view('Cis/Profil', ["uid" => getAuthUID(),"pid" => getAuthPersonId()]);
|
||||
}
|
||||
|
||||
|
||||
@@ -42,14 +50,36 @@ class Profil extends Auth_Controller
|
||||
//* retrieve info from the Mitarbeiter model
|
||||
$mitarbeiter_result = $this->MitarbeiterModel->load(getAuthUID());
|
||||
//* retrieve info from the Benutzer model
|
||||
$benutzer_result = $this->BenutzerModel->load([getAuthUID()]);
|
||||
$benutzer_result = $this->BenutzerModel->getFromPersonId(getAuthUID());
|
||||
//* return JSON with info
|
||||
$res = ['mitarbeiter' => $mitarbeiter_result,
|
||||
'Benutzer' => $benutzer_result];
|
||||
//! was removed from $res for testing purposes: 'Benutzer' => $benutzer_result
|
||||
$res = ['mitarbeiter' => $mitarbeiter_result,'Benutzer' => $benutzer_result
|
||||
];
|
||||
|
||||
echo json_encode($res);
|
||||
}
|
||||
|
||||
public function getPersonInformation($pid){
|
||||
//? get the person information using the benutzer uid
|
||||
echo json_encode($this->PersonModel->getPersonStammdaten($pid)->retval);
|
||||
}
|
||||
|
||||
//? check wheter the parameter uid is a Mitarbeiter or a Student
|
||||
public function isMitarbeiterOrStudent($uid){
|
||||
if($this->MitarbeiterModel->isMitarbeiter($uid)->retval){
|
||||
echo json_encode("Mitarbeiter");
|
||||
}//! not sure if the user is automatically a student if he is not a mitarbeiter
|
||||
else if($this->StudentModel->isStudent($uid)->retval){
|
||||
echo json_encode("Student");
|
||||
}else{
|
||||
echo json_encode("Not a Mitarbeiter or Student");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
class Student_model extends DB_Model
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->dbTable = 'public.tbl_student';
|
||||
$this->pk = 'student_uid';
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the user is a Student.
|
||||
* @param string $uid
|
||||
* @return array
|
||||
*/
|
||||
public function isStudent($uid)
|
||||
{
|
||||
$this->addSelect('1');
|
||||
|
||||
|
||||
$result = $this->loadWhere(array('student_uid' => $uid));
|
||||
|
||||
|
||||
if(hasData($result))
|
||||
{
|
||||
return success(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
return success(false);
|
||||
}
|
||||
}
|
||||
|
||||
//! THIS FILE WAS CREATED USING THE Mitarbeiter_model.php FILE
|
||||
|
||||
|
||||
}
|
||||
@@ -9,10 +9,11 @@ $this->load->view('templates/CISHTML-Header', $includesArray);
|
||||
?>
|
||||
|
||||
<div id="content">
|
||||
<h2>Profil</h2>
|
||||
<h2>Profil2</h2>
|
||||
<hr>
|
||||
<p><?php echo $uid; ?></p>
|
||||
<Profil></Profil>
|
||||
<!-- we can pass information from the php view file to the public js file through interpolating data from php into vue props -->
|
||||
<Profil uid="<?php echo $uid ?>" pid="<?php echo $pid ?>"></Profil>
|
||||
</div>
|
||||
|
||||
<?php $this->load->view('templates/CISHTML-Footer', $includesArray); ?>
|
||||
|
||||
Reference in New Issue
Block a user