Question

There is a function in opencart which I need to replace as following:

protected function validateDelete() {
        if (!$this->user->hasPermission('modify', 'catalog/download')) {
            $this->error['warning'] = $this->language->get('error_permission');

Should be:

protected function validateDelete() {
        if (!$this->user->hasPermission('delete', 'catalog/download')) {
            $this->error['warning'] = $this->language->get('error_permission_delete');

I have tried:

<search position="replace"><![CDATA[
            protected function validateDelete() {
                if (!$this->user->hasPermission('modify',]]></search>
            <add><![CDATA[
            protected function validateDelete() {
                if (!$this->user->hasPermission('delete',
            ]]></add>

but its not working. The third line appears in multiple locations, so cant just replace in single line.

Please help

Was it helpful?

Solution

Multiple line search cannot be done in vqmod. So you need to use the vqmod index attribute. If the “Search” string is 'hello' and there are 5 'hello's in the file, but you only want to replace the 1st and 3rd, use Index: 1,3.

So change your vqmod code as below:

<operation>
    <search position="replace" index="3"><![CDATA[if (!$this->user->hasPermission('modify', 'catalog/download')) {]]></search>
    <add><![CDATA[
        if (!$this->user->hasPermission('delete', 'catalog/download')) {
    ]]></add>
</operation>
<operation>
    <search position="replace" index="3"><![CDATA[$this->error['warning'] = $this->language->get('error_permission');]]></search>
    <add><![CDATA[
        $this->error['warning'] = $this->language->get('error_permission_delete');
    ]]></add>
</operation>

Don't forget to update the index value.

Reference links: https://sankartypo3.wordpress.com/2013/11/25/opencart-vqmod-tutorial/ , http://code.google.com/p/vqmod/wiki/Scripting

Have a nice day !!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top