Skip to content

Commit 66e411d

Browse files
authored
Add files via upload
1 parent 97939cd commit 66e411d

File tree

14 files changed

+277
-197
lines changed

14 files changed

+277
-197
lines changed

src/Authentication.php

Lines changed: 58 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ function getAuthenticationInfo()
9494
global $dbi, $globalZone;
9595

9696
$dbi->join(_USER_TYPES_. " t", "t.typeID=u.userType", "INNER");
97+
$dbi->join(_SUBELER_. " s", "s.subeID=u.ySubeKodu", "LEFT");
9798

9899
if($this->authDbStdSsnSetting == "on")
99100
{
@@ -118,7 +119,10 @@ function getAuthenticationInfo()
118119

119120
$dbi->where("u.active", "1");
120121
$dbi->where("t.loginType", $this->authLoginTypes, "IN");
121-
$authenticationInfo = $dbi->getOne(_USERS_. " u", "u.aid, u.pwd, u.email, u.picture, u.name, u.lastName, u.ySubeKodu, u.campusID, u.userType, u.expireDate, u.firebaseId, u.firebaseToken, u.pwdPlain, u.id, t.loginType");
122+
$authenticationInfo = $dbi->getOne(_USERS_. " u", "u.aid, u.pwd, u.email, u.picture, u.name, u.lastName, u.ySubeKodu, s.subeID, s.stype, u.userType, u.expireDate, u.firebaseId, u.firebaseToken, u.pwdPlain, u.id, t.loginType");
123+
124+
//make school id 0 if it is null for hq
125+
if(is_null($authenticationInfo["ySubeKodu"])) $authenticationInfo["ySubeKodu"] = "0";
122126

123127
//check picture
124128
if(empty($authenticationInfo["picture"])) $authenticationInfo["picture"] = "https://schst.in/nopicture";
@@ -155,18 +159,45 @@ function getAuthenticationInfo()
155159

156160
if(empty($getLmsUser["users"][0]))
157161
{
158-
159-
$users = array(
160-
'username' => $authenticationInfo["aid"],
161-
'password' => $authenticationInfo["pwdPlain"],
162-
'firstname' => $authenticationInfo["name"],
163-
'lastname' => $authenticationInfo["lastName"],
164-
'email' => $authenticationInfo["email"],
165-
'studentno' => $this->createStudentNo($authenticationInfo["id"]),
166-
'auth' => 'lti'
167-
);
168-
169-
$createLMSUser = $this->lmsCreateUsers($users);
162+
if($authenticationInfo["ySubeKodu"] == "0" || $authenticationInfo["stype"] == "campus")
163+
{
164+
$insKeys = array();
165+
166+
$moodleInsKey = $dbi->get(_MOODLE_CONFIG_, null, "moodleInsKey");
167+
foreach($moodleInsKey as $moodleKey)
168+
{
169+
$insKeys[] = array('institutionkey' => $moodleKey["moodleInsKey"]);
170+
}
171+
172+
$users = array(
173+
'username' => $authenticationInfo["aid"],
174+
'password' => $authenticationInfo["pwdPlain"],
175+
'firstname' => $authenticationInfo["name"],
176+
'lastname' => $authenticationInfo["lastName"],
177+
'email' => $authenticationInfo["email"],
178+
'auth' => 'lti'
179+
);
180+
181+
$createLMSUser = $this->lmsCreateManagerUsers($insKeys, $users);
182+
183+
}
184+
else
185+
{
186+
$users = array(
187+
'username' => $authenticationInfo["aid"],
188+
'password' => $authenticationInfo["pwdPlain"],
189+
'firstname' => $authenticationInfo["name"],
190+
'lastname' => $authenticationInfo["lastName"],
191+
'email' => $authenticationInfo["email"],
192+
'auth' => 'lti'
193+
);
194+
195+
//If User Type is Student
196+
if($authenticationInfo["userType"] == "8") $users["studentno"] = $this->createStudentNo($authenticationInfo["id"]);
197+
198+
$createLMSUser = $this->lmsCreateUsers($users);
199+
200+
}
170201

171202
if(!empty($createLMSUser))
172203
{
@@ -176,7 +207,21 @@ function getAuthenticationInfo()
176207
$dbi->where("id", $authenticationInfo["id"]);
177208
$update = $dbi->update(_USERS_, $queryData);
178209
}
210+
}
211+
else
212+
{
213+
$dbi->where("aid", $authenticationInfo["aid"]);
214+
$dbi->where("id", $authenticationInfo["id"]);
215+
$getLmsUserId = $dbi->getValue(_USERS_, "lmsUserId");
179216

217+
if(empty($getLmsUserId))
218+
{
219+
$queryData = array('lmsUserId' => $getLmsUser["users"][0]["id"]);
220+
221+
$dbi->where("aid", $authenticationInfo["aid"]);
222+
$dbi->where("id", $authenticationInfo["id"]);
223+
$update = $dbi->update(_USERS_, $queryData);
224+
}
180225
}
181226

182227
}

src/Classes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ function getTeacherClasses($teacherId, $branches = "")
289289
$dbi->joinWhere(_CLASSES_." c", "FIND_IN_SET(?, c.donemKodu)", array("$this->seasonId"));
290290
$dbi->join($classBatches, "cbb.classId=c.dag_id", "LEFT");
291291
$dbi->where("t.teacherId", $teacherId);
292-
if (!empty($branches)) $dbi->where("c.ders_brans_code",$branches,"IN");
292+
if (!empty($branches)) $dbi->where("c.ders_brans_code", $branches, "IN");
293293
$dbi->where("t.seasonId", $this->seasonId);
294294
$dbi->where("t.schoolId", $ySubeKodu);
295295
$dbi->groupBy("t.classId");

src/Content.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ function showEditableContent($question)
6565
<button class="btn btn-xs btn-primary"><i class="fa fa-save"></i></button>
6666
</div>
6767
</div>
68-
<?
68+
<?php
6969
}
7070

7171
/* function */
@@ -260,6 +260,6 @@ function showReadOnlyContent($evaluated = "0", $question, $orderNumber = "", $qu
260260
?>
261261

262262
</div>
263-
<?
263+
<?php
264264
}
265265
}

src/Core.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,16 @@ function __construct()
5252

5353
if($globalUserType == "parent") $this->student_picture = showPhoto($myStudent["Foto"], "", "40px", "sims-dashboard-student img-rounded");
5454

55+
$isAdmin = Admin();
56+
5557
//frequent menus
5658
$dbi->join(_MENUS_. " m", "f.menu_id=m.id", "INNER");
57-
if(!Admin()) $dbi->where("m.aktif", "1");
59+
if(!$isAdmin) $dbi->where("m.aktif", "1");
5860
$dbi->where("m.". $globalUserManagerMenu, "on");
5961
$dbi->where("f.user_id", $userId);
6062
$dbi->orderBy("numberOfUse", "DESC");
6163
$this->freqMenus = $dbi->get(_FREQUENT_MENUS_. " f", 10, "f.id AS fId, m.id, m.menu, m.resim, m.url");
64+
6265
foreach($this->freqMenus as $k => $f)
6366
{
6467
$this->freqMenus[$k]["menuType"] = (strpos($f["url"], "blank") == false) ? "maintab" : "blank";
@@ -321,12 +324,14 @@ function getMainMenus()
321324
//manager type based on school id
322325
//$managerMenuType = empty($ySubeKodu) ? (empty($yCampusID) ? "headQuarterMenu" : "campusMenu") : "branchMenu";
323326

327+
$isAdmin = Admin();
328+
324329
//start query for menus
325330
$dbi->where($globalUserManagerMenu, "on");
326331
$dbi->where("parent_id", NULL, "IS");
327332

328333
//if dev or admin then show all menus else show only active ones
329-
if((defined("DEV_MODE") && DEV_MODE == "1") || (Admin() && $_GET["showAllMenus"] == "1")) $dbi->where("aktif", array("0", "1"), "IN");
334+
if((defined("DEV_MODE") && DEV_MODE == "1") || ($isAdmin && $_GET["showAllMenus"] == "1")) $dbi->where("aktif", array("0", "1"), "IN");
330335
else $dbi->where("aktif", "1");
331336

332337
$dbi->orderBy("menuSirasi", "ASC");
@@ -368,7 +373,7 @@ function getMainMenus()
368373
$dbi->where("parent_id", $mainMenu["id"]);
369374

370375
//if dev or admin then show all menus else show only active ones
371-
if((defined("DEV_MODE") && DEV_MODE == "1") || (Admin() && $_GET["showAllMenus"] == "1")) $dbi->where("aktif", array("0", "1"), "IN");
376+
if((defined("DEV_MODE") && DEV_MODE == "1") || ($isAdmin && $_GET["showAllMenus"] == "1")) $dbi->where("aktif", array("0", "1"), "IN");
372377
else $dbi->where("aktif", "1");
373378

374379
$dbi->orderBy("menuSirasi", "ASC");
@@ -439,7 +444,7 @@ function getMainMenus()
439444
$dbi->where("parent_id", $subMenu["id"]);
440445

441446
//if dev or admin then show all menus else show only active ones
442-
if((defined("DEV_MODE") && DEV_MODE == "1") || (Admin() && $_GET["showAllMenus"] == "1")) $dbi->where("aktif", array("0", "1"), "IN");
447+
if((defined("DEV_MODE") && DEV_MODE == "1") || ($isAdmin && $_GET["showAllMenus"] == "1")) $dbi->where("aktif", array("0", "1"), "IN");
443448
else $dbi->where("aktif", "1");
444449

445450
$dbi->orderBy("menuSirasi", "ASC");

src/Courses.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,11 @@ function searchCourses($filters = array(), $fields = "*")
8484
if(!empty($filters))
8585
{
8686
if(!empty($filters["daterange"])) {
87-
if(!empty($filters["daterange"]["startDate"])) $dbi->where("g.kursBaslangic", $startDate, ">=");
88-
if(!empty($filters["daterange"]["endDate"])) $dbi->where("g.kursBaslangic", $endDate, "<=");
87+
if(!empty($filters["daterange"]["startDate"])) $dbi->where("g.kursBaslangic", $filters["daterange"]["startDate"], ">=");
88+
if(!empty($filters["daterange"]["endDate"])) $dbi->where("g.kursBaslangic", $filters["daterange"]["endDate"], "<=");
8989
}
90-
if(!empty($filters["gradeLevels"])) $dbi->where("g.seviyeKodu", $gradeLevels, "IN");
91-
if(!empty($filters["tagCourses"])) $dbi->where("g.kursID", $tagCourses, "IN");
90+
if(!empty($filters["gradeLevels"])) $dbi->where("g.seviyeKodu", $filters["gradeLevels"], "IN");
91+
if(!empty($filters["tagCourses"])) $dbi->where("g.kursID", $filters["tagCourses"], "IN");
9292
}
9393

9494
//other filters

src/DatatablesPage.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,16 @@ class DatatablesPage {
1717

1818
private $boxTag = "div";
1919
private $boxId = "";
20+
private $boxType = "";
2021
private $boxTitle = "SmartClass";
2122
private $datatablesHeader = "";
2223
private $actionsTitle = _ACTIONS;
2324
private $exportTitle = _EXPORT;
2425
private $actionButtons = array();
2526
private $exportButtons = array();
2627
private $toggleButtons = array();
27-
private $settingsButtons = array();
28+
private $settingsButton = array();
29+
private $printButton = "";
2830
private $alerts = array();
2931
private $dtTemplate = "full_table.html";
3032
private $dtTemplateContent = "";
@@ -113,6 +115,12 @@ function setTemplateContent($content)
113115
$this->dtTemplateContent = $content;
114116
}
115117

118+
/* function */
119+
function getPage()
120+
{
121+
return get_object_vars($this);
122+
}
123+
116124
/* function */
117125
function generatePage()
118126
{

0 commit comments

Comments
 (0)