call get_string() function problem

call get_string() function problem

by Zoran Jeremic -
Number of replies: 3

Hi,

I have created moodle extension as moodle/depths/mapping/depths_insert.php. It starts as:

<?php
require_once(dirname(__FILE__).'/../../config.php');

require_once('http://localhost:8080/JavaBridge/java/Java.inc');
$myLib=get_string('moodle_jar_file','depths');
java_require($CFG->wwwroot.'/'.$myLib);

If I try to deploy it I get an error message that get_string function is undefined:

javax.servlet.ServletException: java.lang.RuntimeException: PHP Fatal error:  Call to undefined function get_string() in C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\moodleDEPTHS\depths\mapper\depths_insert.php on line 8

 php.java.servlet.PhpCGIServlet.handle(PhpCGIServlet.java:390)
 php.java.servlet.CGIServlet.doGet(CGIServlet.java:469)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


root cause

java.lang.RuntimeException: PHP Fatal error:  Call to undefined function get_string() in C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\moodleDEPTHS\depths\mapper\depths_insert.php on line 8

 php.java.servlet.fastcgi.FastCGIServlet$CGIRunner.parseBody(FastCGIServlet.java:473)
 php.java.servlet.fastcgi.FastCGIServlet$CGIRunner.doExecute(FastCGIServlet.java:368)
 php.java.servlet.fastcgi.FastCGIServlet$CGIRunner.execute(FastCGIServlet.java:376)
 php.java.servlet.CGIServlet.handle(CGIServlet.java:400)
 php.java.servlet.PhpCGIServlet.handle(PhpCGIServlet.java:356)
 php.java.servlet.CGIServlet.doGet(CGIServlet.java:469)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

What is confusing me is that I have created another set of files, such as moodle/depths/setup/mappingAllMoodleData.php, where exactly the same code works fine.

Could somebody explain me what makes the problem here?

Thanks

Zoran

Average of ratings: -
In reply to Zoran Jeremic

Re: call get_string() function problem

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Could it be because you are mixing PHP and Java? tongueout Why are you doing that?
In reply to Martin Dougiamas

Re: call get_string() function problem

by Zoran Jeremic -

Hi,

>>Why are you doing that?

I'm working my PhD research on integrating Moodle, ArgoUML and tool for annotation of online repositories of Software patterns based on common ontologies. I'm using Sesame API to provide access to ontology repository. As Sesame provides only Java API I have to use PHP/Java bridge to access Java application which will insert new triple or update existing one in ontology when some event happen in Moodle.

>>Could it be because you are mixing PHP and Java?

I don't think that it is a case here. I have already created Moodle block that use moodle/depths/setup/mappingAllMoodleDataAction.php to access java application. It works fine. This file, moodle/depths/mapper/depths_insert.php has function  depths_insert_record() which is called from moodle/lib/dmlib.php from insert_record() function in order to provide mapping of all data that is inserted to moodle database in Sesame repository.

However, in order to verify your question I have deleted all code from this file that access java application, and I have the same problem.

Do you have some other suggestions?

Thanks

Zoran

In reply to Zoran Jeremic

Re: call get_string() function problem

by Zoran Jeremic -

Hi,

I've solved this problem. As I'm newby in PHP I didn't know that in this case global $CFG is available in called function without require_once('config.php');

So, I created something like this:

<?php

function

{

require_once('http://localhost:8080/JavaBridge/java/Java.inc'); $myLib=get_string('moodle_jar_file','depths');

java_require($CFG->wwwroot.'/'.$myLib);

It works now.

Thanks

depths_insert_record($table,$dataobject, $id,$insertSQL)global $CFG;