Методы для класса Награда:
<?php
/**
* Справочник типов наград
* Структура в БД:
* 1 ID Индекс int(11)
* 2 award varchar(255)
*/
class Award
{
private $ID;
private $award;
/**
* Get the value of ID
*/
public function getID()
{
return $this->ID;
}
/**
* Set the value of ID
*
* @return self
*/
public function setID($ID)
{
$this->ID = $ID;
return $this;
}
/**
* Get the value of award
*/
public function getAward()
{
return $this->award;
}
/**
* Set the value of award
*
* @return self
*/
public function setAward($award)
{
$this->award = $award;
return $this;
}
/**
* Update the value of award
*
* @return self
*/
public function updateAward()
{
DataBase::SQL(
"UPDATE `award_list` SET `award` =? WHERE `ID` =?",
[$this->award, $this->ID]
);
return $this;
}
}
Методы для класса Кафедра:
<?php
/**
* Справочник кафедр
* Структура в БД:
* 1 ID Индекс int(11)
* 2 id_fac Индекс int(11)
* 2 chair_name text
*/
class Chair
{
private $ID;
private $name;
private $idFac;
/**
* Get the value of ID
*/
public function getID()
{
return $this->ID;
}
/**
* Set the value of ID
*
* @return self
*/
public function setID($ID)
{
$this->ID = $ID;
return $this;
}
/**
* Get the value of name
*/
public function getName()
{
return $this->name;
}
/**
* Set the value of name
*
* @return self
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Update the value of chair name
*
* @return self
*/
public function updateChairName()
{
DataBase::SQL(
"UPDATE `chairs` SET `chair_name` =? WHERE `ID` =?",
[$this->name, $this->ID]
);
return $this;
}
/**
* Get the value of idFac
*/
public function getIdFac()
{
return $this->idFac;
}
/**
* Set the value of idFac
*
* @return self
*/
public function setIdFac($idFac)
{
$this->idFac = $idFac;
return $this;
}
}
Методы для класса Мероприятие:
<?php
/**
* Класс мероприятий по показателям НИРС
* Структура в БД:
* 1 ID Индекс int(11)
* 2 id_type_event Индекс int(11)
* 3 id_level_event Индекс int(11)
* 4 year int(4)
* 5 date_start date
* 6 date_end date
* 7 location text
* 8 organization text
* 9 is_order tinyint(1)
*/
class Event
{
private $ID;
private $idType;
private $idLevel;
private $year;
private $name;
private $dateStart;
private $dateEnd;
private $location;
private $organization;
private $isOrder;
/**
* Get the value of ID
*/
public function getID()
{
return $this->ID;
}
/**
* Set the value of ID
*
* @return self
*/
public function setID($ID)
{
$this->ID = $ID;
return $this;
}
/**
* Get the value of idType
*/
public function getIdType()
{
return $this->idType;
}
/**
* Set the value of idType
*
* @return self
*/
public function setIdType($idType)
{
$this->idType = $idType;
return $this;
}
/**
* Get the value of idLevel
*/
public function getIdLevel()
{
return $this->idLevel;
}
/**
* Set the value of idLevel
*
* @return self
*/
public function setIdLevel($idLevel)
{
$this->idLevel = $idLevel;
return $this;
}
/**
* Get the value of year
*/
public function getYear()
{
return $this->year;
}
/**
* Set the value of year
*
* @return self
*/
public function setYear($year)
{
$this->year = $year;
return $this;
}
/**
* Get the value of name
*/
public function getName()
{
return $this->name;
}
/**
* Set the value of name
*
* @return self
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get the value of dateStart
*/
public function getDateStart()
{
return $this->dateStart;
}
/**
* Set the value of dateStart
*
* @return self
*/
public function setDateStart($dateStart)
{
$this->dateStart = $dateStart;
return $this;
}
/**
* Get the value of dateEnd
*/
public function getDateEnd()
{
return $this->dateEnd;
}
/**
* Set the value of dateEnd
*
* @return self
*/
public function setDateEnd($dateEnd)
{
$this->dateEnd = $dateEnd;
return $this;
}
/**
* Get the value of location
*/
public function getLocation()
{
return $this->location;
}
/**
* Set the value of location
*
* @return self
*/
public function setLocation($location)
{
$this->location = $location;
return $this;
}
/**
* Get the value of organization
*/
public function getOrganization()
{
return $this->organization;
}
/**
* Set the value of organization
*
* @return self
*/
public function setOrganization($organization)
{
$this->organization = $organization;
return $this;
}
/**
* Get the value of isOrder
*/
public function getIsOrder()
{
return $this->isOrder;
}
/**
* Set the value of isOrder
*
* @return self
*/
public function setIsOrder($isOrder)
{
$this->isOrder = $isOrder;
return $this;
}
}
Методы для класса Уровень мероприятия:
<?php
/**
* Справочник уровней мероприятий
* Структура в БД:
* 1 ID Индекс int(11)
* 2 events_nirs_level varchar(255)
*/
class EventLevel
{
private $ID;
private $level;
/**
* Get the value of ID
*/
public function getID()
{
return $this->ID;
}
/**
* Set the value of ID
*
* @return self
*/
public function setID($ID)
{
$this->ID = $ID;
return $this;
}
/**
* Get the value of level
*/
public function getLevel()
{
return $this->level;
}
/**
* Set the value of level
*
* @return self
*/
public function setLevel($level)
{
$this->level = $level;
return $this;
}
/**
* Update the value of level
*
* @return self
*/
public function updateLevel()
{
DataBase::SQL(
"UPDATE `events_nirs_levels` SET `events_nirs_level` =? WHERE `ID` =?",
[$this->type, $this->ID]
);
return $this;
}
}
Методы для класса Тип мероприятия:
<?php
/**
* Справочник типов мероприятий
* Структура в БД:
* 1 ID Индекс int(11)
* 2 events_nirs_type varchar(255)
*/
class EventType
{
private $ID;
private $type;
/**
* Get the value of ID
*/
public function getID()
{
return $this->ID;
}
/**
* Set the value of ID
*
* @return self
*/
public function setID($ID)
{
$this->ID = $ID;
return $this;
}
/**
* Get the value of type
*/
public function getType()
{
return $this->type;
}
/**
* Set the value of type
*
* @return self
*/
public function setType($type)
{
$this->type = $type;
return $this;
}
/**
* Update the value of type
*
* @return self
*/
public function updateType()
{
DataBase::SQL(
"UPDATE `events_nirs_types` SET `events_nirs_type` =? WHERE `ID` =?",
[$this->type, $this->ID]
);
return $this;
}
}
Методы для класса Факультет:
<?php
class Fac
{
private $ID;
private $idLkChuvsu;
private $name;
private $countStudents;
private $countTeachers;
private $description;
private $fullName;
private $decan;
private $photoURL;
/**
* Get the value of ID
*/
public function getID()
{
return $this->ID;
}
/**
* Set the value of ID
*
* @return self
*/
public function setID($ID)
{
$this->ID = $ID;
return $this;
}
/**
* Get the value of idLkChuvsu
*/
public function getIdLkChuvsu()
{
return $this->idLkChuvsu;
}
/**
* Set the value of idLkChuvsu
*
* @return self
*/
public function setIdLkChuvsu($idLkChuvsu)
{
$this->idLkChuvsu = $idLkChuvsu;
return $this;
}
/**
* Get the value of name
*/
public function getName()
{
return $this->name;
}
/**
* Set the value of name
*
* @return self
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get the value of countStudents
*/
public function getCountStudents()
{
return $this->countStudents;
}
/**
* Set the value of countStudents
*
* @return self
*/
public function setCountStudents($countStudents)
{
$this->countStudents = $countStudents;
return $this;
}
/**
* Get the value of countTeachers
*/
public function getCountTeachers()
{
return $this->countTeachers;
}
/**
* Set the value of countTeachers
*
* @return self
*/
public function setCountTeachers($countTeachers)
{
$this->countTeachers = $countTeachers;
return $this;
}
/**
* Get the value of description
*/
public function getDescription()
{
return $this->description;
}
/**
* Set the value of description
*
* @return self
*/
public function setDescription($description)
{
$this->description = $description;
return $this;
}
/**
* Get the value of fullName
*/
public function getFullName()
{
return $this->fullName;
}
/**
* Set the value of fullName
*
* @return self
*/
public function setFullName($fullName)
{
$this->fullName = $fullName;
return $this;
}
/**
* Get the value of decan
*/
public function getDecan()
{
return $this->decan;
}
/**
* Set the value of decan
*
* @return self
*/
public function setDecan($decan)
{
$this->decan = $decan;
return $this;
}
/**
* Get the value of photoURL
*/
public function getPhotoURL()
{
return $this->photoURL;
}
/**
* Set the value of photoURL
*
* @return self
*/
public function setPhotoURL($photoURL)
{
$this->photoURL = $photoURL;
return $this;
}
}
Методы для класса Новость:
<?php
class News
{
private $ID;
private $text;
/**
* Get the value of ID
*/
public function getID()
{
return $this->ID;
}
/**
* Set the value of ID
*
* @return self
*/
public function setID($ID)
{
$this->ID = $ID;
return $this;
}
/**
* Get the value of text
*/
public function getText()
{
return $this->text;
}
/**
* Set the value of text
*
* @return self
*/
public function setText($text)
{
$this->text = $text;
return $this;
}
}
Методы для класса Пользователь:
<?php
class User
{
private $ID;
private $pass;
private $name;
/**
* Get the value of ID
*/
public function getID()
{
return $this->ID;
}
/**
* Set the value of ID
*
* @return self
*/
public function setID($ID)
{
$this->ID = $ID;
return $this;
}
/**
* Get the value of pass
*/
public function getPass()
{
return $this->pass;
}
/**
* Set the value of pass
*
* @return self
*/
public function setPass($pass)
{
$this->pass = $pass;
return $this;
}
/**
* Get the value of name
*/
public function getName()
{
return $this->name;
}
/**
* Set the value of name
*
* @return self
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
}
API
<?php
class API
{
static function getMenu()
{
$data = json_decode(file_get_contents(__DIR__. '/../config.json'));
$roleID = 4;
$response = ["sitename" => $data->sitename, "controllers" => []];
foreach ($data->controllers as $key => $controller) {
if (isset($controller->data->menu) && $controller->data->status <= $roleID) {
$response["controllers"][] = [
"name" => $controller->data->title,
"url" => $key,
];
}
}
return $response;
}
static function auth($login, $pass)
{
$tmp = DataBase::SQL(
"SELECT `pass_hash`, `ID`, `GUID` FROM `users` WHERE `id_vk` =?",
'',
[$login]
);
if (password_verify(trim($pass), $tmp[0]['pass_hash'])) {
Cookies::setCookie($tmp[0]['GUID'], $tmp[0]['ID']);
return ["code" => 0];
} else {
return ["code" => 1, "msg" => "Неправильный логин или пароль!"];
}
}
static function getFacs($isObject = TRUE)
{
return DataBase::SQL(
"SELECT
`ID`,
`id_lk_chuvsu` AS `idLkChuvsu`,
`name`,
`count_users` AS `countStudents`,
`count_teachers` AS `countTeachers`,
`description`,
`full_name` AS `fullName`,
`decan`,
`photo_url` AS `photoURL`
FROM `facs`",
($isObject)? 'Fac': ''
);
}
static function getAwards($isObject = TRUE)
{
return DataBase::SQL(
"SELECT `ID`,`award`
FROM `awards`",
($isObject)? 'Award': ''
);
}
static function getChairs($isObject = TRUE)
{
return DataBase::SQL(
"SELECT `ID`, `id_fac` AS `idFac`, `name`
FROM `chairs`",
($isObject)? 'Chair': ''
);
}
static function getEventTypes($isObject = TRUE)
{
return DataBase::SQL(
"SELECT `ID`, `events_nirs_type` AS `type`
FROM `events_nirs_types`",
($isObject)? 'EventType': ''
);
}
static function getEventLevels($isObject = TRUE)
{
return DataBase::SQL(
"SELECT `ID`, `events_nirs_level` AS `level`
FROM `events_nirs_levels`",
($isObject)? 'EventLevel': ''
);
}
static function getEvents($year, $isObject = TRUE)
{
return DataBase::SQL(
"SELECT
`ID`,
`id_type_event` AS `idType`,
`id_level_event` AS `idLevel`,
`year`,
`name`,
`date_start` AS `dateStart`,
`date_end` AS `dateEnd`,
`location`,
`organization`,
`is_order` AS `isOrder`
FROM `events_nirs`
WHERE `year` =?",
($isObject)? 'Event': '',
[intval($year)]
);
}
static function getYears()
{
$tmp = [];
for ($i = 2018; $i <= 2025; $i++) {
$tmp[] = $i;
}
return ["code" => 0, "years" => $tmp];
}
static function getNews($isObject = TRUE)
{
return DataBase::SQL(
"SELECT
`ID`,
`text`
FROM `news`",
($isObject)? 'News': ''
);
}
}