vTiger blank page when trying to save any entity - php

I am currently in the process of creating new modules on vTiger 6.5. Currently I have been creating the modules using the vTlib, registering handlers ect.. All has been working well until I suddenly was unable to save any information on any modules even the standard modules.
I started a fresh install and went through the steps of installing my modules, I created one module fine but when registering the handler below I was then unable to save anything and just lead to index.php
<?php
require_once('include/database/PearDatabase.php');
include_once('include/events/include.inc');
$adb = PearDatabase::getInstance();
$em = new VTEventsManager($adb);
$module = 'AddIsa';
$em->registerHandler('vtiger.entity.beforesave', 'modules/'.$module.'/'.$module.'Handler.php', $module.'Handler');
$em->registerHandler('vtiger.entity.beforesave.modifiable', 'modules/'.$module.'/'.$module.'Handler.php', $module.'Handler');
$em->registerHandler('vtiger.entity.beforesave.final', 'modules/'.$module.'/'.$module.'Handler.php', $module.'Handler');
$em->registerHandler('vtiger.entity.aftersave', 'modules/'.$module.'/'.$module.'Handler.php', $module.'Handler');
echo 'Events Added Successfully.';
?>
UPDATE
I went to the table vtiger_eventhandlers and deleted the event handlers relating to my custom module and now it works fine. I cannot see why this would happen as I have previously registered event handlers using the same script which are also in this table.
Any ideas?

Please use vtiger Package Structure. Also if you are using event handler in your module. you must create event handler file and use Vtiger Module Event Structure

event handlers registered will be executed for all modules. Your script might have some error, That's why you can not save to any module. In your handler script you can check current module and skip executing further code like this
$moduleName = $entityData->getModuleName();
if ($moduleName != 'Invoice') {
return;
}

Related

how can i send data from whmcs hook to admin module files?

i created an addon moodule in WHMCS and its working just fine!
now im trying to work and learn hooks
i have tried somethings for client side and it worked but i have problem in admin side
here is what i tried so far in hooks.php on my module directory:
add_hook('AdminAreaPage', 1, function($vars) {
$extraVariables = [];
if ($vars['filename'] == 'addonmodules') {
$extraVariables['newVariable1'] = $vars['admin_username'];
}
return $extraVariables;
});
but when i in list.php (a file in module directory) want to get the $extraVariables like below, its null !
<?php var_dump($extraVariables); ?>
what im doing wrong or whats im missing?
i simply just want to get data im creating in hook in my module files
does whmcs hook variables only works and have access in tpl files?
As seen in the documentation, the answer is, yes variables are only available inside the template(s)
Response
Accepts a return of key/value pairs to be made available to the template layer as additional template variables.

Opencart 2: Events not triggered

I'm using opencart version 2.1.0.1 and trying to use the new script notification system.
Please note that I have simply installed the original version. Nothing extra added or modified.
Following the tutorial found here: http://isenselabs.com/posts/opencart2-event-system-tutorial
I managed to create a new module and install it successfully.
I can confirm from the database that it has registered the events that I want to trigger.
To give you a better picture I have created these files:
admin/controller/module/testo.php
admin/view/template/module.testo.tpl
admin/language/english/module/testo.php
catalog/controller/module/testo.php
Now although the admin events are triggered with no problem the Catalog (fronted) Order Events never fire.
On admin/controller/module/testo.php function install I have the following call:
$this->model_extension_event->addEvent('testo', 'post.order.add', 'module/testo/on_order_add');
And according to the tutorial the function to fire should be in catalog/controller/model/testo.php
public function on_order_add($order_id) { .... }
The function simply writes the order_id to a text file, nothing tricky there.
So when I complete an order the function never runs.
I have tried most Order Notification Hooks with no luck.
Am I missing something?
Is there something I'm not understanding?
Please help since there is absolutely no documentation and I'm on a dead end (for the time)
You are calling it incorrectly, your catalog file path must be
catalog/controller/module/testo.php
not
catalog/controller/model/testo.php
because your trigger is
$this->model_extension_event->addEvent('testo', 'post.order.add', 'module/testo/on_order_add');
it's meaning -> Opencart will search catalog/controller/module/testo.php file and will call it's on_order_add() function when 'post.order.add' trigger will execute (because trigger in catalog side it will use catalog/* or else it will use admin/*), 'testo' is just name part noting important.
In your case it's searching correctly but you don't have any file on this path because you added file to
catalog/controller/model/testo.php
so change your folder structure -> model to module or change your trigger from module to model.
Are you sure writing to text file is working?
because i also tried to get post.order.add event on my Opencart 2.0.3.1, and its working fine.
try writing to log file
<?php
class ControllerModuleTesto extends Controller
{
public function on_order_add($order_id)
{
$this->log->write("Order Id " . $order_id . " was created.");
}
}
?>
and check logs at backend->Tools->Error Logs

How to wp_dequeue_script or wp_deregister_script jquery (not effected) file from wp theme

NOTE: I already use wp_dequeue_script or wp_deregister_script but not successfull
Here is the scenario, i make a image slider plugin that use jquery-cycle2 and it work successfully.
There is a user who used a wp theme and in theme there is a jquery-cycle1, now when he install my plugin the jquery-cycle1 and jquery-cycle2 conflicts, when user delete the jquery-cycle1 file all things work fine and perfectly but i don't want to delete file by user.
Now i am trying that when user install my plugin the jquery-cycle1 in theme close or deregister or stop its effect.
I get file from theme successfully
if((file_exists($theme_file_path."/jquery.cycle.all.js"))){
echo "yes";
}
but i have no idea to close jquery-cycle1 file or stop its effect.
Last Option: I have last solution that delete the file from theme but its my last option.
Please any suggestions, help me.
You will have to place an incompatibility notice on your theme.
It is not possible to attempt to detect the existence of script from server side. You are able to detect queued scripts via the word press methods, however, this assumes that the user has not simply linked the file with a <script></script> tag. The file_exists method assume the file is stored on the server itself - it could be linked from a CDN or another server.
Also, whatever methods you use to detect and remove jQuery-Cycle; You are going to break any feature on the site that uses the existing plugin.
Thus, any solution you able to devise would either be extremely complicated, or would not be generalised enough to account for all these possibilities.
You may be able to use the following to prevent loading your script
if (jQuery().cycle) {
// Script already loaded
console.log("Error: Another version of jQuery-Cycle is already loaded!");
} else {
// Load your script
}
but this cannot unload what is already loaded.
There is a simple hack you can do on you end. In the Cycle2 source replace all $.fn.cycle with $.fn.cycle2 and ).cycle( to ).cycle2(.
I am using the source from here http://malsup.github.io/jquery.cycle2.js
After that You can access it like
$("#id").cycle2({option})
Here is a demo http://jsfiddle.net/33g6z79h/
Here i assume that you are not using cycle events http://jquery.malsup.com/cycle2/api/#events
and cycle extra transitions.
If you are using it you can make a fiddle for your cycle2 implementation and i would be glad to help :)

How to configure Vimeo-Service-module in Silverstripe

Forgive me for my English
I am new in PHP. And I'm building a site using Silverstripe and trying to configure Vimeo-Service-module. I'd follow the steps from this link
https://github.com/r0nn1ef/Silverstripe-Vimeo-Service-module
I did everything that mentions in the article. And created a page in admin panel of VimeoGallery page type and set the parameters on Videos tab to grab the videos for display.
After created page, I visited my and clicked on video menu but then all I see is no videos returned. It is showing blank page and no any error messages.
Is that I've done anything wrong. Please guide me...
Thanks in advance.
OK, I think I see the issue here. You are calling VimeoService::setAPIKey() however accessing the method like that is deprecated in the new version (the 2.0 branch - I was incorrect in my comment when I mentioned master) of the module.
The module instead uses the Site Config in the CMS to set the API key and a few other settings.
Now just remove VimeoService::setAPIKey() from your _config.php file, run /dev/build and set the API key through the CMS.
EDIT
On line 142 of VimeoGalleryPage.php, there is a function called flushCache. Replace the code in that function with the following:
public function flushCache($persistent = true) {
parent::flushCache($persistent);
unset($this->_cachedVideos);
}
Basically, the code in the 2.0 branch for this function does not correctly extend the same named function in SiteTree.

Vtiger Custom Module : "Sorry! Attempt to access restricted file."

I have created a test module name Mytest. While saving values from the module, I am getting a blank page and it saying "Sorry! Attempt to access restricted file. " . Do anyone know, why this happening. Any help on this is really appreciating.
The most likely cause for the vTiger error “Sorry! Attempt to access restricted file.” is the $root_directory value in the ‘config.inc.php’ is incorrect or misspelled.
In order to correct it follow the steps below:
Go to your vTigerCRM directory
Open “config.inc.php” with your favorite text editor
Go to line 86 and adjust $root_directory value to correct vTiger
directory. Note, that the directory must end with /. It should look
something like this – $root_directory = ‘/var/www/vtigercrm/’;
Also there is a problem with cache memory. So do check your cache file for template files. For that go to your vTigerCRM directory.
Then Go to Smarty->templates_c.
Here you will get list of cache files. Delete this file and check weather your problem is solved or not.
Don't worry about deletion of this file.
When trying to include files from your custom module, you will get these messages because Vtiger thinks you are including these files from a location they find rather unsafe.
To avoid this error you could use the standard way a module is used in Vtiger by navigating to it like so: ......./index.php?module=Mytest&action=index. Vtiger will include your module and now there is no need for you to include CRMEntity and other data or utils related files. It should all be available this way but make sure you are using the global statement for $current_user, $current_module etc though.
Another way is to edit the following functions located in utils/CommonUtils.php:
heckFileAccessForInclusion() and checkFileAccess()
Remove or comment out the die() in these functions to fix it.
In Save.php file, just add a line.
$focus->column_fields['assigned_user_id'] = '';
before the
if($_REQUEST['assigntype'] == 'U') {
$focus->column_fields['assigned_user_id'] = $_REQUEST['assigned_user_id'];
} elseif($_REQUEST['assigntype'] == 'T') {
$focus->column_fields['assigned_user_id'] = $_REQUEST['assigned_group_id'];
}
To second what caspersky said:
Go to /include/database/PearDatabase.php and add
$adb->setDebug(true); right after $adb->connect();
I just wrote a module and received this error and it was because the record could not save because I left out:
$moduleInstance->setEntityIdentifier($fieldInstance);
Check out file permissions and file path it's trying to refer.
If you want to debug more set $adb->setDebug(true) in your index file and checkout for the errors.
A couple of things spring to mind:
Have you actually created the modules/CustomeModule directory and populated
it? (Using the template in vtlib/ModuleDir/5.4.0 and then editing the
filenames and class of CustomeModule.php)
Check the case of your module class definition, e.g. class CustomeModule
vs. class Customemodule
If you are using any version control or symlinks in the development
of your modules/Mytest code then this can trigger the "Sorry! Attempt
to access restricted file." messages.
In module setup script make sure you have added this lines.
$module->initTables();
$module->initWebservice();
Check that all language files exist.
The user module allows the admin user to configure a user's language even though the language file is not present on disk.
To quickly verify this is indeed the issue :-
- Edit the include/utils/CommonUtils.php and print the $realfilepath variable ,and comment out the die();
- In the database, "select distinct language from xxx_users";
You can fix this by downloading the required files.
As a quick fix (read:hack):-
- go to the include/language directory
- copy an existing language file as the required one. (may not always work - for example en_us to en_gb is great, but en_us to sp_es is not)
It seems you did not set write permission for Smarty folder
Probably a file is missing in your vtiger install.
To find out which one is mission you would need to edit the include/utils/CommonUtils.php file. Open it with a text editor, go around line 2755 and add the following
echo “REAL: $realfilepath, ROOT: $rootdirpath”;
Before die(Sorry....)
This would print on the screen which one is the missing file.
Sometimes this error is caused by an nonexistent module, what I mean here is that vtiger thinks you have a module but the files are not in there (might be caused by a bad migration to a new server).
Disable some modules and try again until you find which module is broken.
In my case the broken module was VGS.
I solved this on vtiger 7.3.. (maybe it works for other vesion)
I went to users permission on vtiger inside configuration settings and update tham all again with the same settings .. and got them to a more default settings .. them all users appeared back and I was able to create new users ..change password again.
I suggest logging out and maybe forcing refresh and waiting a little to make it work .

Categories