@@ -173,6 +173,7 @@ public function createParamsString($data, $name)
173173 return $ res ;
174174 }
175175 // --------------------------------------------------------------------
176+
176177 /**
177178 * Restoring module data from query string
178179 *
@@ -251,13 +252,13 @@ public function restoreParams()
251252
252253 /**
253254 * Restoring module data from query string (old version)
254- * @deprecated
255255 * @return void
256+ * @deprecated
256257 */
257258 public function restoreParamsOld ()
258259 {
259- $ md= gr ('md ' ); // query param - current module
260- $ pd= gr ('pd ' ); // query param - all params
260+ $ md = gr ('md ' ); // query param - current module
261+ $ pd = gr ('pd ' ); // query param - all params
261262
262263 $ global_params = array ();
263264
@@ -323,7 +324,7 @@ public function saveParentParams()
323324 public function checkInstalled ()
324325 {
325326
326- $ flag_filename = ROOT . 'cms/modules_installed/ ' . $ this ->name . '.installed ' ;
327+ $ flag_filename = ROOT . 'cms/modules_installed/ ' . $ this ->name . '.installed ' ;
327328 if (!file_exists ($ flag_filename )) {
328329 $ this ->install ();
329330 } else {
@@ -412,13 +413,13 @@ public function install($parent_name = "")
412413 } else {
413414 SQLUpdate ("project_modules " , $ rec );
414415 }
415- SQLExec ("DELETE FROM project_modules WHERE NAME = ' " . $ this ->name . "' AND ID!= " . $ rec ["ID " ]);
416+ SQLExec ("DELETE FROM project_modules WHERE NAME = ' " . $ this ->name . "' AND ID!= " . $ rec ["ID " ]);
416417
417- if (!is_dir (ROOT . 'cms/modules_installed ' )) {
418+ if (!is_dir (ROOT . 'cms/modules_installed ' )) {
418419 umask (0 );
419- mkdir (ROOT . 'cms/modules_installed ' ,0777 );
420+ mkdir (ROOT . 'cms/modules_installed ' , 0777 );
420421 }
421- $ flag_filename = ROOT . 'cms/modules_installed/ ' . $ this ->name . '.installed ' ;
422+ $ flag_filename = ROOT . 'cms/modules_installed/ ' . $ this ->name . '.installed ' ;
422423 if (!file_exists ($ flag_filename )) SaveFile ($ flag_filename , date ("H:m d.M.Y " ));
423424 }
424425
@@ -445,12 +446,13 @@ public function uninstall()
445446 SQLExec ($ sqlQuery );
446447 }
447448
448- $ flag_filename = ROOT . 'cms/modules_installed/ ' . $ this ->name . '.installed ' ;
449+ $ flag_filename = ROOT . 'cms/modules_installed/ ' . $ this ->name . '.installed ' ;
449450 if (file_exists ($ flag_filename )) unlink ($ flag_filename );
450451 }
451452
452453
453454 // --------------------------------------------------------------------
455+
454456 /**
455457 * Module data installation
456458 *
@@ -528,14 +530,14 @@ public function dbInstall($data)
528530 $ definition = str_replace ('` ' , '' , $ definition );
529531 $ sql = "ALTER TABLE $ table ADD $ definition; " ;
530532 SQLExec ($ sql );
531- SQLExec ("FLUSH TABLES " . $ table. "; " );
533+ SQLExec ("FLUSH TABLES " . $ table . "; " );
532534 $ to_optimize [] = $ table ;
533535 }
534536 } elseif (!isset ($ tbl_fields [$ table ][$ field ])) {
535537 // new field
536538 $ sql = "ALTER TABLE $ table ADD $ definition; " ;
537539 SQLExec ($ sql );
538- SQLExec ("FLUSH TABLES " . $ table. "; " );
540+ SQLExec ("FLUSH TABLES " . $ table . "; " );
539541 }
540542 }
541543
@@ -599,13 +601,14 @@ public function redirect($url)
599601 global $ session ;
600602
601603 $ new_url = $ this ->makeRealURL ($ url );
602- if (isset ($ this ->owner ) && $ this ->owner ->name == 'panel ' && preg_match ('/nf\.php/ ' ,$ new_url )) {
603- $ new_url = str_replace ('nf.php ' ,'admin.php ' ,$ new_url );
604+ if (isset ($ this ->owner ) && $ this ->owner ->name == 'panel ' && preg_match ('/nf\.php/ ' , $ new_url )) {
605+ $ new_url = str_replace ('nf.php ' , 'admin.php ' , $ new_url );
604606 }
605607
606608 $ session ->save ();
607609
608- if ($ _GET ['part_load ' ]) {
610+ $ part_load = gr ('part_load ' );
611+ if ($ part_load ) {
609612 $ res = array ();
610613 $ res ['CONTENT ' ] = '' ;
611614 $ res ['NEED_RELOAD ' ] = 1 ;
@@ -723,7 +726,7 @@ public function dynamic($content)
723726 */
724727 public function parseLinks ($ result )
725728 {
726- $ md= gr ('md ' );
729+ $ md = gr ('md ' );
727730 if (!isset ($ _SERVER ['PHP_SELF ' ])) {
728731 global $ PHP_SELF ;
729732 $ _SERVER ['PHP_SELF ' ] = $ PHP_SELF ;
@@ -843,55 +846,55 @@ public function codeParams($in)
843846
844847 return $ res_str ;
845848 }
846-
847- public function sendNotification ($ str , $ type = 'default ' )
849+
850+ public function sendNotification ($ str , $ type = 'default ' )
848851 {
849852
850853 if (!SQLTableExists ('module_notifications ' )) {
851- return json_encode (array ('status ' => false ));
852- }
853-
854- if ($ type != 'info ' && $ type != 'danger ' && $ type != 'warning ' && $ type != 'success ' && $ type != 'default ' ) {
855- $ type = 'default ' ;
856- }
857-
858- $ rec ["ADDED " ] = date ('Y-m-d H:i:s ' );
859- $ rec ["TYPE " ] = $ type ;
860- $ rec ["MODULE_NAME " ] = $ this ->name ;
861- $ rec ["MESSAGE " ] = htmlspecialchars (strip_tags ($ str ));
862-
863- if (SQLSelectOne ("SELECT COUNT(*) AS TOTAL_UNREAD FROM `module_notifications` WHERE `MODULE_NAME` = ' " . $ rec ["MODULE_NAME " ]. "' AND `IS_READ` = '0' " )['TOTAL_UNREAD ' ] > 10 ) {
864- return json_encode (array ('status ' => false , 'error ' => 'More than 10 notifications in the unread status. ' ));
865- }
866-
867- $ ifExist = SQLSelectOne ("SELECT ID FROM `module_notifications` WHERE `MESSAGE` = ' " . DBSafe ($ rec ['MESSAGE ' ]). "' AND TYPE=' " . DBSafe ($ rec ['TYPE ' ]). "' AND `IS_READ` = '0' " );
868- if (!empty ($ ifExist ) && is_array ($ ifExist )) {
869- return json_encode (array ('status ' => false , 'error ' => 'Notification already exists. ID: ' . $ ifExist ['ID ' ], 'id ' => $ ifExist ['ID ' ]));
870- }
871-
872- $ rec ["ID " ] = SQLInsert ("module_notifications " , $ rec );
873-
874- return json_encode (array ('status ' => true , 'id ' => $ rec ["ID " ]));
854+ return json_encode (array ('status ' => false ));
855+ }
856+
857+ if ($ type != 'info ' && $ type != 'danger ' && $ type != 'warning ' && $ type != 'success ' && $ type != 'default ' ) {
858+ $ type = 'default ' ;
859+ }
860+
861+ $ rec ["ADDED " ] = date ('Y-m-d H:i:s ' );
862+ $ rec ["TYPE " ] = $ type ;
863+ $ rec ["MODULE_NAME " ] = $ this ->name ;
864+ $ rec ["MESSAGE " ] = htmlspecialchars (strip_tags ($ str ));
865+
866+ if (SQLSelectOne ("SELECT COUNT(*) AS TOTAL_UNREAD FROM `module_notifications` WHERE `MODULE_NAME` = ' " . $ rec ["MODULE_NAME " ] . "' AND `IS_READ` = '0' " )['TOTAL_UNREAD ' ] > 10 ) {
867+ return json_encode (array ('status ' => false , 'error ' => 'More than 10 notifications in the unread status. ' ));
868+ }
869+
870+ $ ifExist = SQLSelectOne ("SELECT ID FROM `module_notifications` WHERE `MESSAGE` = ' " . DBSafe ($ rec ['MESSAGE ' ]) . "' AND TYPE=' " . DBSafe ($ rec ['TYPE ' ]) . "' AND `IS_READ` = '0' " );
871+ if (!empty ($ ifExist ) && is_array ($ ifExist )) {
872+ return json_encode (array ('status ' => false , 'error ' => 'Notification already exists. ID: ' . $ ifExist ['ID ' ], 'id ' => $ ifExist ['ID ' ]));
873+ }
874+
875+ $ rec ["ID " ] = SQLInsert ("module_notifications " , $ rec );
876+
877+ return json_encode (array ('status ' => true , 'id ' => $ rec ["ID " ]));
875878
876879 }
877-
878- public function readNotification ($ notification_id )
880+
881+ public function readNotification ($ notification_id )
879882 {
880883
881884 if (!SQLTableExists ('module_notifications ' )) {
882- return json_encode (array ('status ' => false ));
883- }
884-
885- $ rec ["ID " ] = $ notification_id ;
886- $ rec ["IS_READ " ] = 1 ;
887-
888- if (empty (SQLSelectOne ("SELECT ID FROM `module_notifications` WHERE `ID` = ' " . $ rec ["ID " ]. "' AND `IS_READ` = '0' " )['ID ' ])) {
889- return json_encode (array ('status ' => false , 'error ' => 'No such noty found ' ));
890- }
891-
892- SQLUpdate ("module_notifications " , $ rec );
893-
894- return json_encode (array ('status ' => true ));
885+ return json_encode (array ('status ' => false ));
886+ }
887+
888+ $ rec ["ID " ] = $ notification_id ;
889+ $ rec ["IS_READ " ] = 1 ;
890+
891+ if (empty (SQLSelectOne ("SELECT ID FROM `module_notifications` WHERE `ID` = ' " . $ rec ["ID " ] . "' AND `IS_READ` = '0' " )['ID ' ])) {
892+ return json_encode (array ('status ' => false , 'error ' => 'No such noty found ' ));
893+ }
894+
895+ SQLUpdate ("module_notifications " , $ rec );
896+
897+ return json_encode (array ('status ' => true ));
895898
896899 }
897900}
0 commit comments