Fixed director view bug. Other fixes

parent 88da1f2e
......@@ -5,8 +5,6 @@ use Drupal\Core\Entity\Query\QueryFactory;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Controller\ControllerBase;
// require_once '/home/haris/devel/eepal/drupal/modules/casost/src/CAS/phpCAS.php';
use phpCAS;
use Drupal\user\Entity\User;
use Drupal\Core\Database\Connection;
......
......@@ -14,16 +14,21 @@ use Drupal\Core\Logger\LoggerChannelFactoryInterface;
class DirectorView extends ControllerBase
{
protected $entityTypeManager;
protected $logger;
protected $testSchoolId='0640050';
public function __construct(EntityTypeManagerInterface $entityTypeManager)
public function __construct(EntityTypeManagerInterface $entityTypeManager,
LoggerChannelFactoryInterface $loggerChannel)
{
$this->entityTypeManager = $entityTypeManager;
$this->logger = $loggerChannel->get('epal-school');
}
public static function create(ContainerInterface $container)
{
return new static(
$container->get('entity_type.manager')
$container->get('entity_type.manager'),
$container->get('logger.factory')
);
}
......@@ -34,10 +39,23 @@ public function getSectorsPerSchool(Request $request, $epalId)
$authToken = $request->headers->get('PHP_AUTH_USER');
$epalUsers = $this->entityTypeManager->getStorage('epal_users')->loadByProperties(array('authtoken' => $authToken));
$epalUser = reset($epalUsers);
if ($epalUser) {
$userid = $epalUser -> user_id -> entity -> id();
$users = $this->entityTypeManager->getStorage('user')->loadByProperties(array('name' => $authToken));
$user = reset($users);
if ($user) {
// $schools = $this->entityTypeManager->getStorage('eepal_school')->loadByProperties(array('registry_no' => $user->mail->value, 'id' => intval($epalId)));
$schools = $this->entityTypeManager->getStorage('eepal_school')->loadByProperties(array('registry_no' => $this->testSchoolId, 'id' => intval($epalId)));
$school = reset($schools);
if (!$school) {
$this->logger->warning("no access to this school=" . $user->id());
$response = new Response();
$response->setContent('No access to this school');
$response->setStatusCode(Response::HTTP_FORBIDDEN);
$response->headers->set('Content-Type', 'application/json');
return $response;
}
$userid = $user -> id();
$epalIdNew = intval($epalId);
$sectorPerSchool = $this->entityTypeManager->getStorage('eepal_sectors_in_epal')->loadByProperties(array('epal_id'=> $epalIdNew));
$i = 0;
......@@ -60,7 +78,7 @@ public function getSectorsPerSchool(Request $request, $epalId)
else {
return $this->respondWithStatus([
'message' => t("School not found!!!"),
], Response::HTTP_FORBIDDEN);
], Response::HTTP_OK);
}
......@@ -79,10 +97,21 @@ public function getSpecialPerSchool(Request $request, $epalId , $sectorId)
$authToken = $request->headers->get('PHP_AUTH_USER');
$epalUsers = $this->entityTypeManager->getStorage('epal_users')->loadByProperties(array('authtoken' => $authToken));
$epalUser = reset($epalUsers);
if ($epalUser) {
$userid = $epalUser -> user_id -> entity -> id();
$users = $this->entityTypeManager->getStorage('user')->loadByProperties(array('name' => $authToken));
$user = reset($users);
if ($user) {
// $schools = $this->entityTypeManager->getStorage('eepal_school')->loadByProperties(array('registry_no' => $user->mail->value, 'id' => intval($epalId)));
$schools = $this->entityTypeManager->getStorage('eepal_school')->loadByProperties(array('registry_no' => $this->testSchoolId, 'id' => intval($epalId)));
$school = reset($schools);
if (!$school) {
$this->logger->warning("no access to this school=" . $user->id());
$response = new Response();
$response->setContent('No access to this school');
$response->setStatusCode(Response::HTTP_FORBIDDEN);
$response->headers->set('Content-Type', 'application/json');
return $response;
}
$userid = $user -> id();
$epalIdNew = intval($epalId);
$specialityPerSchool = $this->entityTypeManager->getStorage('eepal_specialties_in_epal')->loadByProperties(array('epal_id'=> $epalIdNew));
$i = 0;
......@@ -111,7 +140,7 @@ public function getSpecialPerSchool(Request $request, $epalId , $sectorId)
else {
return $this->respondWithStatus([
'message' => t("School not found!!!"),
], Response::HTTP_FORBIDDEN);
], Response::HTTP_OK);
}
......@@ -131,10 +160,22 @@ public function getStudentPerSchool(Request $request, $epalId , $selectId, $clas
$authToken = $request->headers->get('PHP_AUTH_USER');
$epalUsers = $this->entityTypeManager->getStorage('epal_users')->loadByProperties(array('authtoken' => $authToken));
$epalUser = reset($epalUsers);
if ($epalUser) {
$userid = $epalUser -> user_id -> entity -> id();
$users = $this->entityTypeManager->getStorage('user')->loadByProperties(array('name' => $authToken));
$user = reset($users);
if ($user) {
// $schools = $this->entityTypeManager->getStorage('eepal_school')->loadByProperties(array('registry_no' => $user->mail->value, 'id' => intval($epalId)));
$schools = $this->entityTypeManager->getStorage('eepal_school')->loadByProperties(array('registry_no' => $this->testSchoolId, 'id' => intval($epalId)));
$school = reset($schools);
if (!$school) {
$this->logger->warning("no access to this school=" . $user->id());
$response = new Response();
$response->setContent('No access to this school');
$response->setStatusCode(Response::HTTP_FORBIDDEN);
$response->headers->set('Content-Type', 'application/json');
return $response;
}
$userid = $user -> id();
$epalIdNew = intval($epalId);
$selectIdNew = intval($selectId);
if ($classId == 1)
......@@ -180,7 +221,7 @@ public function getStudentPerSchool(Request $request, $epalId , $selectId, $clas
else {
return $this->respondWithStatus([
'message' => t("No students found!!!"),
], Response::HTTP_FORBIDDEN);
], Response::HTTP_OK);
}
......@@ -207,9 +248,21 @@ public function getStudentPerSchool(Request $request, $epalId , $selectId, $clas
}
$authToken = $request->headers->get('PHP_AUTH_USER');
$epalUsers = $this->entityTypeManager->getStorage('epal_users')->loadByProperties(array('authtoken' => $authToken));
$epalUser = reset($epalUsers);
if ($epalUser) {
$users = $this->entityTypeManager->getStorage('user')->loadByProperties(array('name' => $authToken));
$user = reset($users);
if ($user) {
// $schools = $this->entityTypeManager->getStorage('eepal_school')->loadByProperties(array('registry_no' => $user->mail->value, 'id' => intval($epalId)));
$schools = $this->entityTypeManager->getStorage('eepal_school')->loadByProperties(array('registry_no' => $this->testSchoolId));
$school = reset($schools);
if (!$school) {
$this->logger->warning("no access to this school=" . $user->id());
$response = new Response();
$response->setContent('No access to this school');
$response->setStatusCode(Response::HTTP_FORBIDDEN);
$response->headers->set('Content-Type', 'application/json');
return $response;
}
$postData = null;
if ($content = $request->getContent())
......@@ -259,9 +312,20 @@ public function SaveCapacity(Request $request,$taxi,$tomeas,$specialit,$schoolid
}
$authToken = $request->headers->get('PHP_AUTH_USER');
$epalUsers = $this->entityTypeManager->getStorage('epal_users')->loadByProperties(array('authtoken' => $authToken));
$epalUser = reset($epalUsers);
if ($epalUser) {
$users = $this->entityTypeManager->getStorage('user')->loadByProperties(array('name' => $authToken));
$user = reset($users);
if ($user) {
// $schools = $this->entityTypeManager->getStorage('eepal_school')->loadByProperties(array('registry_no' => $user->mail->value, 'id' => intval($epalId)));
$schools = $this->entityTypeManager->getStorage('eepal_school')->loadByProperties(array('registry_no' => $this->testSchoolId));
$school = reset($schools);
if (!$school) {
$this->logger->warning("no access to this school=" . $user->id());
$response = new Response();
$response->setContent('No access to this school');
$response->setStatusCode(Response::HTTP_FORBIDDEN);
$response->headers->set('Content-Type', 'application/json');
return $response;
}
$postData = null;
if ($content = $request->getContent())
......@@ -325,12 +389,6 @@ public function SaveCapacity(Request $request,$taxi,$tomeas,$specialit,$schoolid
private function respondWithStatus($arr, $s) {
$res = new JsonResponse($arr);
$res->setStatusCode($s);
......@@ -342,8 +400,3 @@ public function SaveCapacity(Request $request,$taxi,$tomeas,$specialit,$schoolid
}
......@@ -193,6 +193,26 @@ class EpalCriteria extends ContentEntityBase implements EpalCriteriaInterface {
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['category'] = BaseFieldDefinition::create('string')
->setLabel(t('Κατηγορα'))
->setDescription(t('Κατηγορία κριτηρίου.'))
->setSettings(array(
'max_length' => 100,
'text_processing' => 0,
))
->setRequired(true)
->setDisplayOptions('view', array(
'label' => 'above',
'type' => 'string',
'weight' => -4,
))
->setDisplayOptions('form', array(
'type' => 'string_textfield',
'weight' => -4,
))
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['value_limit'] = BaseFieldDefinition::create('float')
->setLabel(t('Αριθμητικό όριο'))
->setDescription(t('Αριθμητικό όριο.'))
......
......@@ -134,7 +134,7 @@ import {
{
this.selectionBClass.next(true);
this.selectionCClass.next(false);
this.StudentSelected$ = new BehaviorSubject([{}]);
this.StudentSelectedSub = this._hds.getSectorPerSchool(this.SchoolId).subscribe(this.StudentSelected$);
}
else if (txop.value === "3")
......@@ -144,12 +144,11 @@ import {
if (this.formGroup.value.tomeas != '')
{
var sectorint = +this.formGroup.value.tomeas;
this.StudentSelectedSpecial$ = new BehaviorSubject([{}]);
this.StudentSelectedSpecialSub = this._hds.getSpecialityPerSchool(this.SchoolId, sectorint).subscribe(this.StudentSelectedSpecial$);
}
this.selectionBClass.next(true);
this.selectionCClass.next(true);
this.StudentSelected$ = new BehaviorSubject([{}]);
this.StudentSelectedSub = this._hds.getSectorPerSchool(this.SchoolId).subscribe(this.StudentSelected$);
}
}
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment