Show Posts


Messages - dhigz

Pages: [1] 2 3
1
News and Announcements / Re: AbanteCart 1.3.0 Beta is released
« on: April 10, 2021, 02:29:38 AM »
With a new major release, it would sure be nice if the default template was upgraded - maybe a new look.

At a minimum, upgrading Bootstrap would be nice.

2
AbanteCart v2.0 / Re: Suggested Changes to task_api.php
« on: December 15, 2020, 01:26:39 PM »
Thanks

3
AbanteCart v2.0 / Suggested Changes to task_api.php
« on: December 14, 2020, 11:29:22 PM »
After some extensive testing, I have found some issues with task_api.php that should be looked at.

1) Running a task from task_api cron causes an error which can be found in the error log:

Code: [Select]
warning: AbanteCart core v.1.2.16 Use of undefined constant RDIR_TEMPLATE - assumed 'RDIR_TEMPLATE' (this will throw an Error in a future version of PHP) in <b>[path to file]/httpdocs/core/engine/view.php</b> on line <b>93</b>
The error has to do with the declaration of the template directory. The simple solution is to add a declaration to task_api.php as it is in task.php:

Code: [Select]
define('RDIR_TEMPLATE', 'admin/view/default/');

2) The command "--force" is negated when running a task. Take a look at the function processTask().

Code: [Select]
function processTask($options)
{
    $tm_mode = 'cli';
    $tm = new ATaskManager($tm_mode);
    if ($options['force']) {
        echo "Force starting task! \n";
        if (
            !$tm->updateTask($options['task_id'], array('status' => $tm::STATUS_READY))
            || !($steps = $tm->getTaskSteps($options['task_id']))
        ) {
            echo "Error: Task ID {$options['task_id']} can not be re-started! \n";
            exit(1);
        }

        foreach ($steps as $step) {
            $tm->updateStep($step['step_id'], array('status' => $tm::STATUS_READY));
        }
    }

    echo "Running: Task ID {$options['task_id']}: \n";
    if (!$tm->runTask($options['task_id'])) {
        //error
        echo "Error: Task ID ".$options['task_id']." has failed! \n";
    }
    if ($options['show_log']) {
        $run_log = $tm->getRunLog();
        $run_log_text = implode("\n", $run_log);
        echo "{$run_log_text}\n";
    }
    echo "Finished running: Task ID ".$options['task_id'].": \n";
}

If option['force'] etc works as it should. the status values are reset to 1 or STATUS_READY as it should. However, when $tm->runTask is run later in the function, if successful, the status values are set to 5 or STATUS_COMPLETED. STATUS_FAILED if not.

The simple fix is to move the "force" section after the runTask section and before the log section, like:

Code: [Select]
function processTask($options)
{
    $tm_mode = 'cli';
    $tm = new ATaskManager($tm_mode);
    echo "Running: Task ID {$options['task_id']}: \n";
    if (!$tm->runTask($options['task_id'])) {
        //error
        echo "Error: Task ID ".$options['task_id']." has failed! \n";
    }
if ($options['force']) {
        echo "Force starting task! \n";
        if (
            !$tm->updateTask($options['task_id'], array('status' => $tm::STATUS_READY))
            || !($steps = $tm->getTaskSteps($options['task_id']))
        ) {
            echo "Error: Task ID {$options['task_id']} can not be re-started! \n";
            exit(1);
        }

        foreach ($steps as $step) {
            $tm->updateStep($step['step_id'], array('status' => $tm::STATUS_READY));
        }
    }
    if ($options['show_log']) {
        $run_log = $tm->getRunLog();
        $run_log_text = implode("\n", $run_log);
        echo "{$run_log_text}\n";
    }
    echo "Finished running: Task ID ".$options['task_id'].": \n";
}

3. There is no way to use the force option to run all tasks. There are no provisions in the task_api file. There are a couple of ways this can be fixed but involves changing both the task_cli file as well as the core/task_manager file. Regardless it would be a nice option to have.



4
How-to questions / Re: Task.php, Task API Key and tsk Documentation
« on: December 09, 2020, 05:33:01 PM »
abolabo,

You have always been a great help to me. But, respectfully, I think you may have missed the problem I was trying to point out.

1. The documentation says to use the task.php file with CRON.
2. The task.php file requires the use of the task_api_key (which does need to be entered on the settings API page) and verifies the task api key is passed to the task.php file in order to run without error (see line 67 of task.php file).
3. CRON does not allow you to pass the task key variable in the file name and the task.php file does not have provisions to interpret any command parameters sent from CRON.

To sum it all up: No matter what I have tried I have not been able to successfully run task.php from CRON as it states in the documentation.

As I initially stated, I am currently using task_api.php in order to run the task fro CRON. The use of task_api.php is not even discussed in the documentation for setting up CRON.

What I am asking for is 1) a how to answer to number 3 above or 2) address the documentation discrepancy and/or 3) fix the task.php file.



5
How-to questions / Re: Task.php, Task API Key and tsk Documentation
« on: December 08, 2020, 02:24:59 PM »
abolabo,

Sigh  ??? That is all you have to say after everything I wrote?

Of course I entered a TASK API KEY in the settings.


6
How-to questions / Task.php, Task API Key and tsk Documentation
« on: December 05, 2020, 10:44:01 PM »
OK,

I have a task set up. It works perfectly when run from the Schedule Tasks screen. It also works perfectly when run from the browser when adding ?task_api_key=[my key] to the url. What I cannot get to work is running the task.php from CRON.

Following the examples on CRON in the documentation: https://abantecart.atlassian.net/wiki/spaces/AD/pages/15007901/Scheduled+Tasks#ScheduledTasks-CRON for my Plesk server CRON will run the Task.php script but I get a response of: "Authorize the Access".

Looking at the task.php code it is clear this message is coming from the following:
Code: [Select]
// add to settings API et task_api_key
$task_api_key = $config->get('task_api_key');
if (!$task_api_key || $task_api_key != (string)$_GET['task_api_key']) {
    exit('Authorize to access.');
}

What is clear is that running the command in CRON per the documentation does not work and to get it to work requires the task_api_key to be sent. However, there is no mention or explanation on how to do this.

My attempts at different methods to send the key have all failed. I attempted adding parameters to the file name gave a could not open file error. Passing the key value pair as an argument open the file but gave me the "Authorize the Access" error.

The only way I can successfully run the task.php file from CRON is to remove the $_GET requirement from the is statement.

What does work and I am doing for now is to direct CRON to the task_cli.php file instead. Problem is there is no API Key security. Using task_cli.php is not even mentioned on this documentation page. 

My point of this post is that something needs to be fixed so others do not have their time wasted as mine was today.
  • Tell me how to pass the task api parameter for I can use task.php.
  • Fix task.php so it recognizes an argument value and not just $_GET.
  • Fix the documentation.

I am ready to release a new extension and this is the only thing holding me up. I do not want to mislead people by sending them to misleading documentation. If there is an answer to #1, I would sure like to know it.

Thanks


7
How-to questions / Re: Task Manager Configuration
« on: November 02, 2020, 12:17:18 PM »
Thanks dvagner.

I will give it a try.


8
How-to questions / Task Manager Configuration
« on: November 01, 2020, 03:33:56 PM »
Hi,

Working on a new extension that requires the creation and execution of two tasks. This is the first time I have created a task and I understand the idea is to call the task.php file by way of Crontab which will then run all of the tasks in the tasks in the tasks table. My question concerns the frequency of each task.

One of my new tasks need to run every hour while the other needs to run once a day. Reading the documentation and looking at the existing tasks, there are no examples of setting different run times. I do see the 'run_interval' value in the addTask array but this is described as "interval in seconds since last run" in the documentation.

How do you suggest I solve my problem with two tasks to be run at different run times?

Don

9
Built-in Features / Resouce Library Modal Icon images
« on: September 13, 2020, 04:08:49 PM »
I am a  long term user of AbanteCart. It has always annoyed me that all icons how in the Resource Library Modal with the fa-code icon instead of the actual icon. Since my the issue has been corrected in the Media Manager and icons show as they truly are and my level of frustration reached a peak, I decided to fix the problem. Little did I know how easy it was.

A small edit to /admin/view/default/template/responses/common/resource_library.tpl is all it took.

On line 184 find:
Code: [Select]
<?php if ($rl['resource_code']) { ?>
<div class="thmb-prev thmb-icon">
<i class="fa fa-code fa-3"></i>
        </div>
<?php } else { ?>

Change it to:

Code: [Select]
<?php if ($rl['resource_code']) { ?>
<div class="thmb-prev thmb-icon">
<?php echo $rl['resource_code']; ?>
         </div>
<?php } else { ?>

Please consider making this change in future releases.


10
Extensions and Add-Ons / Re: Loading resource scripts in hook function
« on: September 07, 2020, 05:52:31 PM »
Thanks. That worked.

that was the last issues I needed to resolve.

11
Extensions and Add-Ons / Loading resource scripts in hook function
« on: September 03, 2020, 09:09:24 PM »
Hi,

I am attempting to add image functionality to and existing controller by loading the resource_scripts though dispatch and dispatchGetOutput like other controllers. I can add the html using addChild with no problem. The script portion is throwing an error: Call to protected method AController::dispatch() from context '...

Here is the code which is included in function onController...._UpdateData().
Code: [Select]
$resources_scripts = $that->dispatch(
            'responses/common/resource_library/get_resources_scripts',
            array(
                'object_name' => 'collections',
                'object_id'   => $id,
                'types'       => array('image'),
            )
        );
        $that->view->assign('resources_scripts', $resources_scripts->dispatchGetOutput());


Any suggestions of how I can get around this error or a different method to add the resource scripts?

Don

12
abolabo,

I seem to have run into another issue. I created the function afterModelCheckoutOrder_confirm() and I am able to get the order_id value with func_get_args(). But it seems not matter what I do I cannot call a query in the normal manor:  $that->model_catalog.... I even tried loading the model with this instead of that and using this-> for the query and they did not work either. I get the error: Call to a member function queryName() on null.

My assumption is that since I am not actually hooking on a controller, the normal rules do not apply. Any suggestions of how I can get a query to work in this case? 

13
Thanks abalabo,

I see the hook for this function as well as others. Not sure why it did not notice them before. I did find some hooks in the core/lib/order.pdf file specifically $this->extensions->hk_ProcessData($this, 'build_order_data', $order_info);.

If I want to add data to the build_order_data function $order_info array, what would be the proper function name to use?

Thanks

14
Extensions and Add-Ons / Best place to hook for a completed order?
« on: July 16, 2020, 08:22:27 PM »
Hi,

What is the best controller and method to hook to in order to capture a successfully completed order with payment made. Is ControllerPagesCheckoutSuccess the best controller? Or do you recommend another controller/method?

I do see the value for $this->session->data['processed_order_id'] is created after validation. Are there any other indicators of a successful order?

Thanks.

15
Thanks Basara,

I pretty much came up with the same solution of changing the
value = tinyMCE.activeEditor.getContent();
to
value = tinymce.get('text_editor_<?php echo $id ?>').getContent()

I also changed it in the else statement
} else {
            $('#'+newtab_id+ ' textarea')
                  .val(textarea.val())
                  .removeAttr('disabled');
            if(tinyMCE.activeEditor != null) {
               value = textarea.val();
               value = html2visual(value);
               tinyMCE.activeEditor.setContent( value );
            }

Thanks for making the change.

Pages: [1] 2 3

Powered by SMFPacks Social Login Mod