Jump to content

Adam

Members
  • Posts

    131
  • Joined

  • Last visited

  • Days Won

    16

Posts posted by Adam

  1. On 4/3/2017 at 3:56 AM, Blesta Addons said:

    i found something very interesting !

    when we set date to date('c') it wont add , but when we set date to something like '05/02/2017' it work !!!! as the database schema the dates will set

    
    				setField("date_added", array('type' => "datetime"))->
    				setField("date_updated", array('type' => "datetime", 'is_null'=>true, 'default'=>null))->

     

    Sounds like you found your problem...

     

    What does 

    <? echo date('c'); ?>

    produce? When you insert that manually via a SQL query from command line or something like phpMyAdmin... does it work? 

    Can you also verify that table structure you are using is setup correctly. Are date_added or date_updated DATES, or TIMESTAMPS or DATETIMES, etc.?

     

    -Adam

     

  2. 7 hours ago, PreMadeKB said:

    I did everything as said and even read various tutorials, Installed it but still its show "not available".

    So It will be really good If blesta add a alternative of this which can be available by default in any hosting company.

     

    My Feature Request: https://www.blesta.com/forums/index.php?/topic/9491-alternative-of-mailparse/&do=getNewComment

    If your hosting provider does not offer Mailparse, then find a different one. It is standard among good hosting providers. 

    -Adam

  3. 16 minutes ago, turner2f said:

    Hello Adam,

     

    Sure hope you get the assistance you need.

    Checked out CERB, and it looks fantastic. 

    And it's got all the functions we all need too.

     

    Will be happy to stress-test your plugin when ready.

    Great! Glad to hear. Please vote for https://requests.blesta.com/topic/pull-request-client-and-contact-create-update-and-delete-callbacks This is one requirement to make sure that Blesta and Cerb are sync when it comes to multi company support.

    Still have not heard back from the anyone at Blesta on the requests page or on the forums about this. 

    -Adam

  4. On 2/13/2017 at 2:08 PM, Paul said:

    I see that CORE-2338 was scheduled for blesta v4 beta 5, but the resolution is still unresolved. Did this not make in? 

    As a developer, I hate modifying modules like the Universal Module (fork'ing it) for each custom feature tab/page we need for all our services. The idea of another module or even a plugin extending functionality, or implementation callbacks for this would be extremely valuable.

    -Adam

  5. 1 hour ago, Tyson said:

    Source docs don't include vendor code, so minPHP classes like Record wouldn't be apart of the list.

    But the 3.6 docs did. http://source-docs.blesta.com/3.6/

     

    Since minPHP framework does not have public documentation of its own, this was the only docs. May you please add back that functionality? Otherwise, grep'ing around in the source code to figure out what parameters a function takes is a pain.

    -Adam

  6. 19 minutes ago, care4servers said:

    Hi adam,

    I have done all the action as per you specified. But still unable to use mailparse. Please have a check the below error. Are you sure that blesta will works in php 7?

     

    ========

    [11-Apr-2017 20:40:02 UTC] PHP Fatal error:  The file /home/xxxx/public_html/customer/app/app_controller.php was encoded by the ionCube Encoder for PHP 5.4 and cannot run under PHP 7.0.                                                                                                                             
     Please ask the provider of the script to provide a version encoded with the ionCube Encoder for PHP 5.6. in Unknown on line 0

    =========

    Follow the instructions in README when you downloaded Blesta. For PHP 7 support, you have to patch the app_controller.php file. Its in the top level folder.

     

     

    -Adam

     

  7. 50 minutes ago, Serverhosh said:

    Tried.. But no luck.. :(

    Your not using cPanel/WHM correctly.

    1. Login to WHM
    2. Select Module Install
    3. Select PHP pecl
    4. Then search for mailparse
    5. Install

     

    I highly recommend you use CloudLinux with cPanel/WHM or even cPanel's MulitPHP Manager. 

    https://documentation.cpanel.net/display/ALD/MultiPHP+Manager+for+WHM

    Either solution allows you have cPanel accounts use different version of PHP. This is great for legacy applications that require specific versions of PHP or specialized setups.

     

    -Adam

    whm-mailparse.png

  8. On 4/4/2017 at 9:22 AM, Paul said:

    Wow, disk full. I'm beginning to hate CSF/LFD, it spams itself with email and fills up the disk. Give it a few minutes, and it should work again.

    The new source docs look a bit off, I'll have to check into that.

    FYI: The new 4.0 source docs still appear to be missing all the minphp classes (Record, etc.)

    -Adam

  9. 21 hours ago, Tyson said:

    v4 doesn't observe the Session.ttl config value. It is now set in the bridge service provider. It will probably be back as a config value somewhere in the future.

    Doh!

    54 minutes ago, evolvewh said:

    Is there a temporary solution to increase the amount of time that a login is active? We have clients that are typing a long support ticket (usually for website design / update tickets) and all of their message is lost by the time they are ready to click submit.

     

    Apply this patch file. It should work. It will attempt to load from config/blesta.php if a key named 'Session.ttl' exists. Otherwise, defaults to 30 minutes.

    diff --git a/core/ServiceProviders/MinphpBridge.php b/core/ServiceProviders/MinphpBridge.php
    index ccefd20..9367ff4 100644         
    --- a/core/ServiceProviders/MinphpBridge.php                     
    +++ b/core/ServiceProviders/MinphpBridge.php                   
    @@ -197,9 +197,10 @@ class MinphpBridge implements ServiceProviderInterface
         {                                                                                       
             $this->container->set('minphp.session', function ($c) {
                 // Determine the TTLs and which to set for the database session
    +            Configure::load('blesta');                                                                          
                 $cookieName = 'csid';               
                 $ttls = [
    -                'ttl' => 1800, // 30 mins                                               
    +                'ttl' => (Configure::exists('Session.ttl')) ? Configure::get('Session.ttl') : 1800, // 30 minutes
                     'cookie_ttl' => 604800, // 7 days
                 ];          
                 $dbTtl = (isset($_COOKIE[$cookieName]) ? $ttls['cookie_ttl'] : $ttls['ttl']);

     

    -Adam

     

  10. 32 minutes ago, evolvewh said:

    Where has this value moved to in 4.0? I have clients being timed out before they can complete a detailed support ticket response which doesn't get sent after.

    It does appear to be removed from the defaults.

    The good news is the code (components/session/session.php) still checks to see a Configuration value of 'Session.ttl' exists. Just add that to your config (config/blesta.php) and you should be good to go.

    Configure::set('Session.ttl', 9000);

    -Adam

     

  11. 4 hours ago, activa said:

    I Dont think is available such event . You can check users model file to verify the existance of the event in edit function .

    Yup, I figured that out pretty quickly. I ended up adding that functionality to Blesta itself. 

     

    Here is the Pull Request. Hopefully the guys can accept it. In the mean time, use git apply to merge my changes.

    From: Adam Brenner <adam@netops.me>
    Date: Thu, 6 Apr 2017 22:45:22 -0700
    Subject: [PATCH 1/1] CUD Callbacks on Clients and Contacts
    
    This is a new feature to Blesta that will allow anyone to
    get callbacks when any CUD operation occurs on a client or
    contact.
    
    Signed-off-by: Adam Brenner <adam@netops.me>
    ---
     app/models/clients.php                             |  6 +++
     app/models/contacts.php                            |  9 +++++
     .../events/default/events_clients_callback.php     | 22 +++++++++++
     .../events/default/events_contacts_callback.php    | 46 ++++++++++++++++++++++
     4 files changed, 83 insertions(+)
     create mode 100644 components/events/default/events_contacts_callback.php
    
    diff --git a/app/models/clients.php b/app/models/clients.php
    index c6fdef0..1bd4468 100644
    --- a/app/models/clients.php
    +++ b/app/models/clients.php
    @@ -302,6 +302,9 @@ class Clients extends AppModel
                 $fields = ['user_id', 'client_group_id', 'status'];
                 $this->Record->where('id', '=', $client_id)->update('clients', $vars, $fields);
             }
    +
    +        $this->Events->register('Clients.edit', ['EventsClientsCallback', 'edit']);
    +        $this->Events->trigger(new EventObject('Clients.edit', ['client' => $this->get($client_id)]));
         }
     
         /**
    @@ -337,6 +340,9 @@ class Clients extends AppModel
                     $this->Users->delete($client->user_id);
                 }
             }
    +
    +        $this->Events->register('Clients.delete', ['EventsClientsCallback', 'delete']);
    +        $this->Events->trigger(new EventObject('Clients.delete', ['client' => $client]));
         }
     
         /**
    diff --git a/app/models/contacts.php b/app/models/contacts.php
    index 8776585..3e39efc 100644
    --- a/app/models/contacts.php
    +++ b/app/models/contacts.php
    @@ -93,6 +93,9 @@ class Contacts extends AppModel
                     $this->setPermissions($contact_id, $vars['permissions']);
                 }
     
    +            $this->Events->register('Contacts.create', ['EventsContactsCallback', 'create']);
    +            $this->Events->trigger(new EventObject('Contacts.create', ['contact' => $this->get($contact_id)]));
    +
                 return $contact_id;
             }
         }
    @@ -227,6 +230,9 @@ class Contacts extends AppModel
                     $this->Logs->addContact(['contact_id'=>$contact_id, 'fields'=>$fields]);
                 }
     
    +            $this->Events->register('Contacts.edit', ['EventsContactsCallback', 'edit']);
    +            $this->Events->trigger(new EventObject('Contacts.edit', ['contact' => $new_contact]));
    +
                 return $new_contact;
             }
         }
    @@ -270,6 +276,9 @@ class Contacts extends AppModel
                     $this->Users->delete($contact->user_id);
                 }
             }
    +
    +        $this->Events->register('Contacts.delete', ['EventsContactsCallback', 'delete']);
    +        $this->Events->trigger(new EventObject('Contacts.delete', ['contact' => $contact]));
         }
     
         /**
    diff --git a/components/events/default/events_clients_callback.php b/components/events/default/events_clients_callback.php
    index b9fc40c..6c81144 100644
    --- a/components/events/default/events_clients_callback.php
    +++ b/components/events/default/events_clients_callback.php
    @@ -21,4 +21,26 @@ class EventsClientsCallback extends EventCallback
         {
             return parent::triggerPluginEvent($event);
         }
    +
    +    /**
    +     * Handle Clients.edit events
    +     *
    +     * @param EventObject $event An event object for Clients.edit events
    +     * @return EventObject The processed event object
    +     */
    +    public static function edit(EventObject $event)
    +    {
    +        return parent::triggerPluginEvent($event);
    +    }
    +
    +    /**
    +     * Handle Clients.delete events
    +     *
    +     * @param EventObject $event An event object for Clients.delete events
    +     * @return EventObject The processed event object
    +     */
    +    public static function delete(EventObject $event)
    +    {
    +        return parent::triggerPluginEvent($event);
    +    }
     }
    diff --git a/components/events/default/events_contacts_callback.php b/components/events/default/events_contacts_callback.php
    new file mode 100644
    index 0000000..42b55c9
    --- /dev/null
    +++ b/components/events/default/events_contacts_callback.php
    @@ -0,0 +1,46 @@
    +<?php
    +/**
    + * Handle all default Contacts events callbacks
    + *
    + * @package blesta
    + * @subpackage blesta.components.events.default
    + * @copyright Copyright (c) 2010, Phillips Data, Inc.
    + * @license http://www.blesta.com/license/ The Blesta License Agreement
    + * @link http://www.blesta.com/ Blesta
    + */
    +class EventsContactsCallback extends EventCallback
    +{
    +
    +    /**
    +     * Handle Contacts.create events
    +     *
    +     * @param EventObject $event An event object for Contacts.create events
    +     * @return EventObject The processed event object
    +     */
    +    public static function create(EventObject $event)
    +    {
    +        return parent::triggerPluginEvent($event);
    +    }
    +
    +    /**
    +     * Handle Contacts.edit events
    +     *
    +     * @param EventObject $event An event object for Contacts.edit events
    +     * @return EventObject The processed event object
    +     */
    +    public static function edit(EventObject $event)
    +    {
    +        return parent::triggerPluginEvent($event);
    +    }
    +
    +    /**
    +     * Handle Contacts.delete events
    +     *
    +     * @param EventObject $event An event object for Contacts.delete events
    +     * @return EventObject The processed event object
    +     */
    +    public static function delete(EventObject $event)
    +    {
    +        return parent::triggerPluginEvent($event);
    +    }
    +}
    -- 
    2.12.1

     

  12. This is what I have setup on my Arch box (minus all the fastcgi, security and optimization I have):

     

    location / {
        root   /srv/http/blesta.netops.local/public;
        index  index.html index.htm index.php;
        
        autoindex off;
        rewrite ^(.*)$ https://$http_host$request_uri redirect;
    
        if (!-e $request_filename) {
            rewrite ^(.*)$ /index.php;
        }
    
        if ($request_uri ~ "^(.*)/install.php$") {
            rewrite install.php /%1/install/ redirect;
        }
    }
    
    location ~ ^/(.*/)?\.git(/|$) {
        deny all;
    }
    
    location ~ \.(pdt)$ {
        deny all;
    }

     

    -Adam

     

  13. 27 minutes ago, Blesta Addons said:

    Not sure if this possible, but what i do normally is to the set request inside the widget itself .

    are you want to make sorting table by indexes or something similar ?

     

    I could move away from using GET parameters and make it part of the route, etc. But I still think this is a bug in Blesta (or something they should document), hence the bug report and patch. Lets see what @Paul and folks say.

     

    -Adam

  14. Hello,

    I was trying to register an action for my plugin so a widget will appear on the client dashboard (widget_client_home). What I found is that the URL can not contain any GET parameters as jQuery fails with the following via the browser. 

    public function getActions() {
        return array(
    ...
            array(
                'action' => 'widget_client_home',
                'uri'    => 'plugin/cerberus/client_tickets/index/?whole_widget=true',
                'name' => Language::_('cerberus.widget.title', true),
            ),
    ...
        );
    }
    Uncaught Error: Syntax error, unrecognized expression: #widget_container_plugin_cerberus_client_tickets_index_?test=blah
        at Function.ot.error (jquery.min.js:4)
        at gt (jquery.min.js:4)
        at kt (jquery.min.js:4)
        at Function.ot [as find] (jquery.min.js:4)
        at init.find (jquery.min.js:5)
        at init (jquery.min.js:4)
        at x (jquery.min.js:4)
        at Object.$.blestaRequest.widget_id [as success] (jquery-client-3.5.0.js:113)
        at l (jquery.min.js:4)
        at Object.fireWith [as resolveWith] (jquery.min.js:4)

     

    If you look in app/client_controller.php the issue is not specifically with the URL but rather the method used to generate the $key/unique identifier for the that widget.

     

    Knowing that, I figured we could just take the SHA1 hash of the URL as that would give us a unique string with no special character issues. It also reduces memory since the key is fixed length and not variable with the URL.

    diff --git a/app/client_controller.php b/app/client_controller.php
    index cdc1dbc..752793e 100644
    --- a/app/client_controller.php
    +++ b/app/client_controller.php
    @@ -95,7 +95,7 @@ class ClientController extends AppController
             // Load widgets configured for display
             $plugin_actions = $this->PluginManager->getActions($this->company_id, $widget_location, true);
             foreach ($plugin_actions as $plugin) {
    -            $key = str_replace('/', '_', trim($plugin->uri, '/'));
    +            $key = sha1($plugin->uri);
                 $widgets[$key] = [
                     'uri'=>$this->base_uri . $plugin->uri
                 ];

     

    -Adam

     

  15. 18 minutes ago, Blesta Addons said:

    Thanks fro your help .

    Finnaly is a blesta BUG, i have searched some blesta files that use equivalent code to my, and i found the support manager . so to reproduce the case do the fallowing

    add a new KB article, try to edit it !!!! that all no change has been made with a success message . i hope this should be fixed as soon as possible .

     

    I did not understand what you wrote. Something is wrong in your environment, not Blesta.

    If you login to the demo system on Blesta's system: everything works fine. I was able to add a new KB article, then edit it, and the changes worked.

    https://demo.blesta.com/admin/plugin/support_manager/admin_knowledgebase/edit/1/1/

    -Adam

  16. 25 minutes ago, Blesta Addons said:

    the equivalent sql code that is working

    
    UPDATE `nh_store_products` SET `category_id` =2, `access` = 'public' WHERE `id` =18

     

     

    Good.

     

    I think you are already in a transaction and that is why you are seeing this issue.

    In my dev system I was able to re-create similar behavior where I started a transaction, ran the update statement and nothing was updated in the database, but http post was fine and directed me back to a new page.

    If you try and get another transaction, while in the middle of one, you should NOT be able to get one and get an error.

    $data = [];
    $data['category_id'] = '3';
    $data['date_added'] = date('c');
    $ret = $this->Record->begin();
    echo "In transaction: $ret True:" . true;
    $tmp = $this->Record->where('id', '=', $product_id)->update('nh_store_products', $data);

     

    -Adam

     

  17. 31 minutes ago, Blesta Addons said:

    i was firstly thinking about it , and i have removed the transaction, and made a simple query to just test and is returni g a success messages but is not affecting in database

    
    			$data = [];
    			$data['category_id'] = '3';
    			$data['date_added'] = date('c');
                $this->Record->where('id', '=', $product_id)
                    ->update('nh_store_products', $data, ['category_id', 'date_added']);

     

    http://source-docs.blesta.com/class-Record.html#_update

    Pretty sure you can remove the third parameter on update as $data is a key/value value 

    Since update returns a PDOStatement, save the value to a variable and print it out. You should see some more information as to what is going on.

    Also, you checked the basics: $product_id is not null? Enable debugging, etc.

    $data = [];
    $data['category_id'] = '3';
    $data['date_added'] = date('c');
    $tmp = $this->Record->where('id', '=', $product_id)->update('nh_store_products', $data);
    echo "<pre>";
    print_r($tmp);
    echo "</pre>";

    -Adam

  18. 4 hours ago, Blesta Addons said:

    i have added the begin() commit() rollback() fucntion to see what happen but no result, also the error_reporting and the debugger is not catching any error !!!

    Do you understand how database transactions work? If any SQL statement fails, everything in the transaction fails and the rollback function is called.

    4 hours ago, Blesta Addons said:

    after some investigation , the $this->Record->lastInsertId(); return 0 .

    hope he can come soon :)

    That is probably your issue, especially if you are using a transaction. What does your database schema look like? Do you have a primary or foreign key indices that could be causing issues -- a unique index constraint?

    Without knowing your custom plugin or a link to a bitbucket or github repo, its hard for anyone to help you out further.

    -Adam

×
×
  • Create New...