307 | | Also the difference in the code is that we check if admin only can access this page. The '''$GLOBALS!['logged']!['admin']''' variable is set to true if admin is logged in. Additionally, you can check if regular members are logged in by using the '''$GLOBALS['logged']['member']''' variable. If none of these values are true, then a guest is accessing your page. The '''displayAccessDenied''' function displays a page with an "access denied" message - in this case, we don't need to care much about that, and we can just return from the function or even exit. The '''$GLOBALS['logged']''' does not always exist, and is initialized in the '''check_logged''' function. In our case this function is called in the '''bloggie/request.php''' file. |
308 | | |
309 | | Another new function here is '''DesignBoxAdmin'''. It wraps our content in a nice box. The box title is the first parameter and box content is the second one. There is an optional 3rd parameter where you can define the box menu. Also, there is an analog of this function in the user side called '''DesignBoxContent'''. You can examine existing Dolphin code for a lot of examples. |
| 307 | Also the difference in the code is that we check if admin only can access this page. The '''$GLOBALS!['logged']!['admin']''' variable is set to true if admin is logged in. Additionally, you can check if regular members are logged in by using the '''$GLOBALS!['logged']!['member']''' variable. If none of these values are true, then a guest is accessing your page. The '''displayAccessDenied''' function displays a page with an "access denied" message - in this case, we don't need to care much about that, and we can just return from the function or even exit. The '''$GLOBALS!['logged']''' does not always exist, and is initialized in the '''check_logged''' function. In our case this function is called in the '''bloggie/request.php''' file. |
| 308 | |
| 309 | Another new function here is '''!DesignBoxAdmin'''. It wraps our content in a nice box. The box title is the first parameter and box content is the second one. There is an optional 3rd parameter where you can define the box menu. Also, there is an analog of this function in the user side called '''!DesignBoxContent'''. You can examine existing Dolphin code for a lot of examples. |
471 | | * '''_oDb''' is automatically defined in the '''MeBlggDb''' class |
472 | | * the '''MsgBox''' function wraps text in a nice message box |
473 | | * the '''bx_import''' function automatically imports a class by its name, and it can load classes with '''BxDol''', '''BxBase''', '''BxTempl''' prefixes if they are correctly named and located. Also, it can load module classes if the module config is passed as the second parameter. |
474 | | * the '''BxDolAdminSettings''' class is used to display and save settings. Just use it as shown above. Make a note that the '''saveSettings''' function returns a result message which we append at the beginning of the result string. |
| 471 | * '''_oDb''' is automatically defined in the '''!MeBlggDb''' class |
| 472 | * the '''!MsgBox''' function wraps text in a nice message box |
| 473 | * the '''bx_import''' function automatically imports a class by its name, and it can load classes with '''!BxDol''', '''!BxBase''', '''!BxTempl''' prefixes if they are correctly named and located. Also, it can load module classes if the module config is passed as the second parameter. |
| 474 | * the '''!BxDolAdminSettings''' class is used to display and save settings. Just use it as shown above. Make a note that the '''saveSettings''' function returns a result message which we append at the beginning of the result string. |
736 | | * '''pass''' is the function to pass data through, it validates data properly - to not allow an inappropriate value in a particular field. The value of this field may be '''Xss''', '''XssHtml''', '''Int''', '''Float''', '''Date''', etc. |
| 736 | * '''pass''' is the function to pass data through, it validates data properly - to not allow an inappropriate value in a particular field. The value of this field may be '''Xss''', '''!XssHtml''', '''Int''', '''Float''', '''Date''', etc. |
740 | | Let's come back to the '''actionAdd''' function. First, we check that only members and admins can add blog posts. We have already described the '''$GLOBALS['logged']''' array. Then '''pageStart''' tells us that output will be below. Then, we import the '''BxTemplFormView''' class and create a class instance by passing the form description array to the class constructor. '''initChecker''' initializes the checker function. It is needed if the form was submitted with wrong values. Then, if the form was not submitted or it has invalid data the the form will be displayed ('''getCode''' function is called). Otherwise we will save the submitted data by calling the '''insert''' form function. Before saving, we added additional database fields, and after successful saving we are redirected to the post view page (which we will create in the next step). This page displays when we call the '''pageCode''' function. |
| 740 | Let's come back to the '''actionAdd''' function. First, we check that only members and admins can add blog posts. We have already described the '''$GLOBALS!['logged']''' array. Then '''pageStart''' tells us that output will be below. Then, we import the '''!BxTemplFormView''' class and create a class instance by passing the form description array to the class constructor. '''initChecker''' initializes the checker function. It is needed if the form was submitted with wrong values. Then, if the form was not submitted or it has invalid data the the form will be displayed ('''getCode''' function is called). Otherwise we will save the submitted data by calling the '''insert''' form function. Before saving, we added additional database fields, and after successful saving we are redirected to the post view page (which we will create in the next step). This page displays when we call the '''pageCode''' function. |