in mymodule/helper.php :
<?php
defined('_JEXEC') or die;
class modvmymodHelper {
public static function function_one() {
function update_sql(){
$i = 5;
}
update_sql();
}
}
Whyy Joomla 3.10 php 7.4 returns internal server error ? please
hot to get function in function in joomla 3.10 ?
Related
How can i get current module name, or current namespace. of laravel
I use this library [nwidart/laravel-modules].
I trid this code but not solve problem
$module_name = basename(__FILE__, '.module');
To get module entity: $module = Module::find('blog');
To get module name: $module->getName();
This is documented pretty well by package author here:
https://nwidart.com/laravel-modules/v1/advanced-tools/module-methods
Add this to your modules __construct controller :
private $module_name;
public function __construct()
{
$class = get_called_class(); // or $class = static::class;
$arr_class = explode("\\", $class);
$this->module_name = $arr_class[1];
}
public function index()
{
echo $this->module_name;
}
I'm a very happy user of XCRUD V 1.6. I want to integrate it in Codeigniter 3 but when I use the codeigniter session-library in for my XCRUD-pages I get an error in XCRUD: "The verification key is out of date". When the session-library from codeigniter is not being used, XCRUD is working fine. Is there anyone who can tell me how to fix? I need the codeigniter session-library in my xcrud pages for user-details.
This is my current controller: (the session library is loaded in the login_model)
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Cms extends CI_Controller {
function __construct()
{
parent::__construct();
$this->load->database();
$this->load->helper('url');
include('cms/xcrud/xcrud.php');
$this->load->model("login_model");
}
public function nieuws()
{
$xcrud = Xcrud::get_instance();
$xcrud->table('nieuws');
$output['output'] = $xcrud->render();
$this->_cms_output($output);
}
function useAuthorID($post_array) {
$post_array['afdeling_id'] = $this->login_model->id();
return $post_array;
}
function useCatID($post_array) {
$post_array['nieuwscat_afdeling_id'] = $this->login_model->id();
return $post_array;
}
function _cms_output($output = null)
{
$this->load->view('beheer/default',$output);
}
}
Assuming that you are using xcrud's CI integration examples, you may try the following in xcrud_config.php:
Use the same session name that your CI installation is using, if it differs from "PHPSESSID".
Use alternative session.
I got Class 'F0FDispatcher' not found in /var/www/joomla/components/com_ducatspremium/dispatcher.php on line 10 Error in Joomla Project.
My Dispatcher Code :
defined('_JEXEC') or die();
include_once JPATH_LIBRARIES.'/fof/include.php';
class DucatsPremiumDispatcher extends F0FDispatcher
{
public function onBeforeDispatch() {
$result = parent::onBeforeDispatch();
if($result) {
// Load Akeeba Strapper
include_once JPATH_ROOT.'/media/akeeba_strapper/strapper.php';
AkeebaStrapper::bootstrap();
AkeebaStrapper::jQueryUI();
AkeebaStrapper::addCSSfile('media://com_timesheet/css/frontend.css');
}
return $result;
}
}
Once I had same problem than I noticed that it's FOFDispatcher that is O not 0(zero).
So you should Try replacing F0FDispatcher with FOFDispatcher and let us know if you still have issue.
Currently following a Laravel 4 book on writing tests, the following returns no output from PHPUnit if the function is named link_to(), but does return the result if it is named something else like link_tox(). Why is this?
app/helpers.php
<?php
function link_to($url, $body) {
$url = url($url);
return "<a href='{$url}'>{$body}</a>";
}
app/tests/ExampleTests.php
<?php
class FunctionsTest extends TestCase {
public function testGeneratesAnchorTag() {
$actual = link_to('dogs/1', 'Show Dog');
$expected = "<a href='http://localhost/dogs/1'>Show Dog</a>";
$this->assertEquals($expected, $actual);
}
}
Laravel already has a link_to function.
I searched the whole Internet and either there is no one mentioning my problem, or I'm stupid, or maybe it's just a bad day for coding.
What's the situation:
controller "source"
model "source"
model "login"
The "login" model is loaded from autoload.php, then in each controller's constructor I have $this->login->check(), which is checking if the user is logged in (obviously). Then in some of the methods I'm using the "source" model to connect to the database.
I tried loading both of the models from the autoload array, I also tried to load them in the way described here, but it's obviously for an old CI version (the thread is from 2008) and I tried all the possible ways I had in my mind.
Anyway, the result is this:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Source::$login
Filename: controllers/source.php
Line Number: 10
Fatal error: Call to a member function check() on a non-object in ...\application\controllers\source.php on line 10
Any ideas what I'm missing or how to fix it...? I'm stuck for hours and I don't have any ideas what I could do...
Edit 1: here is the code from the "source" controller:
class Source extends CI_Controller {
function __construct() {
parent::__construct();
$this->load->model('login');
$this->login->check();
}
function index() {
// Pagination config, getting records from DB
$this->load->view('templates/layout', $data);
}
function add() {
$this->load->model('source', '', true);
$btn = $this->input->post('btn');
if(isset($btn)) {
// More form validation
if($this->form_validation->run() == TRUE) {
if($btn == "Add") {
// here I am supposed to use the source model...
}
}
}
$data['page'] = 'source_add';
$this->load->view('templates/layout', $data);
}
}
?>
Edit 2: login.php:
<?php
class Login extends CI_Model {
function __construct() {
parent::__construct();
}
function authenticate($username, $password) {
// the login script comes here
}
function logged() {
if($this->session->userdata('logged') == true) {
return true;
} else return false;
}
function check() {
if(!$this->logged()) {
redirect('/authentication');
}
}
}
?>
Conventionally, the classname of Models should end with _model, so it not collides with controllers with the same name, so try changing
class Login extends CI_Model {
to
class Login_model extends CI_Model {
I resolved this issue by utilizing the hooks and turned the login process into a controller, thereby being able to access user information and setting access levels.
First I added the following to the hooks.php file in the config folder
$hook['post_controller_constructor'][] = array('function' => 'check_login','filename' => 'authority.php','filepath' => 'hooks');
Then I have the following functions in a hook file called authority.php
[EDIT]Having reviewed this I am going to change it to a pre_controller_constructor and see if I can remove what seems to be a double page flash on initial construct.[/EDIT]
function check_login(){
$CI =& get_instance();
$is_logged_in = $CI->session->userdata('is_logged_in');
if(!$is_logged_in){
$unauth_pages = array(your unauthorized pages go here);
if(!in_array($CI->router->class,$unauth_pages)){
$CI->session->set_userdata('before_login_url',current_url());
redirect('login');
}
}
}
function check_authority(){
$CI =& get_instance();
if($CI->session->userdata('usergroupID') == 'SUPADMIN'){return;}
$page = $CI->router->class ;
$method = $CI->router->method;
$method = ($method=='index')?'':$method;
$unauth_pages = array(your unauthorized pages go here);
if(in_array($page,$unauth_pages))return;
$user_group = $CI->session->userdata('usergroupID');
$CI->load->model('user_model');
if($user_group == 'ADMIN' || $user_group == 'USER'){
if($CI->session->userdata('timezone') == ''){
date_default_timezone_set('Canada/Pacific');
} else {
date_default_timezone_set($CI->session->userdata('timezone'));
}
}
if( !$CI->user_model->authorized_content($CI->session->userdata('usergroupID'),$page, $method)){
redirect('unauthorized');
}
}
With the above I dont have to worry about checking on each page but instead utilize the ci framework to do the checking for me.. if its not in the unauth page array then it is a page that requires authorization checking.
Hope this works for you.