Jump to content

Adam

Members
  • Posts

    131
  • Joined

  • Last visited

  • Days Won

    16

Posts posted by Adam

  1. How does everyone do logging in their custom module and plugin?

    Does Blesta have some common log controller we can call into? Or does everyone roll their own logging software?

    I see that CORE-1847 has made it into the next release (4.1). May we assume that modules and plugins will be able to use this?

     

    Thanks,
    -Adam

     

  2. On 5/20/2017 at 9:21 AM, Anton Qcl said:

    It looks like fortune telling. Yes, problems could be caused by plenty of reasons and I want to find these reasons. However "the guessing" is not the way I want to use. So, I'm asking you, how can I find real source of the problems? Do you have instrument for debug this kind of problems (like extended logging to the file)? Maybe I can temporarily place some snippet for debug purposes somewhere? Please, tell me about variants of diagnostic. What would you do to find cause of this problem?
     

    Should take this conversation out of the forums and open a support ticket directly with Blesta (assuming you have an active support and update subscription with them).

    -Adam

  3. 32 minutes ago, fossxplorer said:

    I'd like to know how i can read in different parameters before provisiong a product.

    in WHMCS it was done as following:

    $fullname = $params["clientsdetails"]["firstname"] . " " . $params["clientsdetails"]["lastname"];
    $email = $params["clientsdetails"]["email"];
    $myusername = $params["clientsdetails"]["customfields1"];
    $mypassword = $params["password"];
    $pid = $params["pid"];  //Product/Service ID

    Thanks.

     

     

    Where are you planning on running this code? In a plugin? In a module? 

    More information here: https://docs.blesta.com/display/dev/Overview

    -Adam

  4. 23 minutes ago, evolvewh said:

    Adam,

    Thanks for the help. I think you're trying to show me how to order the existing tickets (open, awaiting reply, closed, etc) but I was trying to re order the actual list of departments that a client sees before they open a ticket. My way of editing the database works enough and I can deal with the departments that got changed in the support tickets.

    Thanks!

    Er ya, I totally missed that part in your original post. My bad.

    That is a bit more complicated and would require more changes to get done right -- modify the Blesta Admin GUI to allow admins reorder departments, which would require controller code changes as well as add an extra column to the database schema. No simple one line fix.

    I would highly recommend and avoid changing the id column in the database. That id is the primary key and used in multiple tables as you noted earlier.

     

    The hackiest solution I can think of would be to modify views/default/client_tickets_departments.pdt and hard code the order there. I have not tested this code but something like this should work:

     20                     $departmentsSorted = array();
     21                     foreach ($this->Html->ifSet($departments, []) as $department) {
     22                         if($department->name == 'Test 2')
     23                             $departmentedSorted = array_unshift($departmentsSorted,$department);
     24                         else if($department->name == 'Test 3')
     25                             $departmentedSorted = array_unshift($departmentsSorted,$department);
     26                         // All other departments get pushed to the end
     27                         else
     28                             $departmentedSorted = array_push($departmentsSorted,$department);
     29                     }       
     30                     foreach ($this->Html->ifSet($departmentsSorted, []) as $department) {

    Test 3 is the name of the department and it will be shown first. array_unshift inserts to the front of the list while push inserts to the end. You could also use $department->id which would allow you to change the department name without having to re-do this file.

     

    If you are looking for something more complex, then you need to get some custom work done.

    -Adam

     

  5. 14 hours ago, evolvewh said:

    How do I reorder the support ticket departments on the clients page? Can I do it through the database or through the files?

    What ordering do you want? Blesta clients can click on a column and change the order they see. 

     

    If you want to change the default, take a look at the following settings in support_manager/controllers/client_tickets.php

     62     public function index()
     63     {
     64         $status = (isset($this->get[0]) ? $this->get[0] : 'not_closed');
     65         $page = (isset($this->get[1]) ? (int)$this->get[1] : 1);
     66         $sort = (isset($this->get['sort']) ? $this->get['sort'] : 'last_reply_date');
     67         $order = (isset($this->get['order']) ? $this->get['order'] : 'desc');

     

    Lines 66 and 67 is most likely what you are after. The 'last_reply_date' and 'desc' are the default values when a Blesta client does not do manual sorting by clicking on a column header.

    -Adam

  6. 32 minutes ago, Blesta Addons said:

    we don't know if we have the right to fix the actual bug and upload the files in our website. if @PauloV give us the right we can fix the actual bug for v4.

    Looking at the source code on GitHub: https://github.com/qlpqlp/Blesta/tree/master/plugins/support_managerpro

    It appears @PauloV has licensed the software under's Blesta license agreement AND gives all copyright to Phillips Data, Inc. Does not even include himself.

    http://www.blesta.com/license/

    Quote

    You agree not to make nor to permit the making of copies of the Software (including its documentation) except as authorized by this License Agreement or otherwise authorized in writing by us.

    I am no lawyer, but I think @PauloV is breaking the license agreement as he is distributing the software without the written authorization of Phillips Data, Inc. Again, @PauloVchoose that license and why he did is a mystery. One could argue that Phillips Data, Inc. can submit a cease and desist order to GitHub and they would be obligated to remove the code from GitHub.

     

    I do not think @PauloV understands much about software licensing. I would assume his intend was to make it available, free of charge, to the community and for them to do what they want with it -- public domain.

    -Adam

  7. 50 minutes ago, Daniel B said:

    hopefully this isn't a stupid question...but where exactly does this need to be added? :)

    I think the intent was to produce a patch file that you can run from the command line and fill in all the changes automatically, or fail if it can not. However it looks like @Hix posted an diff based on an older RCS format. Creating a diff with the 

    diff -u

    option would be better and easier to understand, IMO. 

    -Adam

  8. 5 hours ago, ginner159 said:

    cool ill wait for it to be released before moving up to version 4

    cPanel is not removing the old WHM authentication anytime soon. It will be years, and I mean years, before cPanel fully deprecates the old style key based authentication in favor for the ReST one.

    This should not be the only reason holding you back on upgrading.

     

  9. 3 hours ago, Paul said:

    I spent some time trying to find the right API docs for this, but I might not be smart enough. A link to the API docs? Is it just "WHM API 1"? Do you know if they have released a PHP API Library for this version of the API? If so, where is it?

    Yes, WHM API 1 (not 0). cPanel has a few SDKs. Their official one is only for XML responses 

    https://github.com/CpanelInc/publicapi-php

    But they also support JSON. All API functions support XML and JSON. If you look at their confluence page for all SDKs, they provide sample Perl and JSON code.

    Example:
    https://documentation.cpanel.net/display/SDK/Guide+to+API+Authentication+-+API+Tokens
     

     

    Here a list of 3rd party cPanel libraries. PHP is included.

    https://documentation.cpanel.net/display/SDK/Quickstart+Development+Guide+-+Libraries

     

    -Adam

  10. 15 minutes ago, Licensecart said:

    Ah :D so we can use that code can't we mate? just using the dateToUtc function?

    Yup. Its in the core of Blesta: app/app_model.php. Alternatively, do not use date('c') but perhaps a timestamp (UNIX/epoch, etc.).

     

    One could make the argument to the Blesta guys that they should be checking the errorCode of a PDOStatement->execute within minPHP either in Records class of their PdoConnection class.

    http://php.net/manual/en/pdostatement.errorinfo.php#refsect1-pdostatement.errorinfo-examples

    -Adam

  11. 2 hours ago, Blesta Addons said:

    the problem is not the timezone but the date format itself , @Adam has identified the issue . my question why the date('c') is accepted in invoices, orders, and so many place in blesta and is not added in some plugins?

    Thats because all the core code uses the dateToUtc function:

    http://source-docs.blesta.com/class-AppModel.html#_dateToUtc
     

    Quote

    Converts dates and date times to a UTC date time stamp suitable for inserting into the database.

    If $date does not contain any timezone information the company timezone setting will attempt to be used to disambiguate the timezone of the given date.

    This method accepts many different date time formats including (but not limited to):

    2010-12-31 12:00:00 PST 2010-12-31 12:00:00 UTC 2010-12-31T12:00:00 +0200 2010-12-31T12:00:00 +02:00

     

    The function basically converts:

    2017-04-25T14:43:00+00:00

    which as you know is ISO 8601 format (date('c')) to something MySQL understands as explained in their documentation:

    2017-04-25 14:43:00

    -Adam

  12. 5 hours ago, mlsto said:

    Hello

    Since I moved over to Blesta from CE I am now getting failure messages from paypal about the ipn url. It seems clients with subscriptions have the client exec url still which is locked to their subscription. Is there a way to get this url to direct to the blesta url as paypal may disable ipn on my account.

    Other option I see is to cancel all recurring subscriptions in paypal and have clients pay when their invoices are due.

    Hoping I do not have to go this way.

    Thank you for any help on this.

    Not sure if this will help. Try this:

    Log into PayPal and update your IPN URL (I am assuming you have not):

    Profile -> Profile and Settings -> My Selling Tools -> Instant payment notifications

    change the URL to the gateway callback.

    -Adam

  13. Sorry for the spam, but I am pretty sure I know what is going on. The issue was right in front of us -- the datetime is invalid :) . You should really be using a timestamp (UNIX/epoch as an example).

     

    Blesta uses PDO statements to insert into the database. When you create a PDO connection, you get to set the 'sql_mode'. Blesta's minPHP framework uses the system's default settings. It appears your system does NOT have the following enabled (system wide):

    SET SQL_MODE='ALLOW_INVALID_DATES';

    As mentioned earlier, when Blesta creates a PDO connection, it uses system defaults and not override anything for that session.

    Why is this important, because PHP's date('c') produces invalid datetime for MySQL. Its explained fairly well in their documentation:

    https://dev.mysql.com/doc/refman/5.6/en/sql-mode.html#sqlmode_allow_invalid_dates

     

    You can see it live from a system I created to reproduce the issue:

    MariaDB [datetest]> select @@sql_mode;
    +----------------------------------------------------------------+
    | @@sql_mode                                                     |
    +----------------------------------------------------------------+
    | STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
    +----------------------------------------------------------------+
    1 row in set (0.00 sec)
    
    MariaDB [datetest]> INSERT INTO test (id, col1) VALUES (NULL, '2017-04-25T05:04:57+00:00');
    ERROR 1292 (22007): Incorrect datetime value: '2017-04-25T05:04:57+00:00' for column 'col1' at row 1
    MariaDB [datetest]> set @@sql_mode='ALLOW_INVALID_DATES';
    Query OK, 0 rows affected (0.00 sec)
    
    MariaDB [datetest]> INSERT INTO test (id, col1) VALUES (NULL, '2017-04-25T05:04:57+00:00');
    Query OK, 1 row affected, 1 warning (0.01 sec)
    
    MariaDB [datetest]> show warnings;
    +---------+------+-------------------------------------------+
    | Level   | Code | Message                                   |
    +---------+------+-------------------------------------------+
    | Warning | 1265 | Data truncated for column 'col1' at row 1 |
    +---------+------+-------------------------------------------+
    1 row in set (0.00 sec)
    
    MariaDB [datetest]> select * from test;
    +----+---------------------+
    | id | col1                |
    +----+---------------------+
    | 10 | 2017-04-25 05:04:57 |
    +----+---------------------+
    1 row in set (0.01 sec)
    
    MariaDB [datetest]> 

     

    You will notice that datetime format is different then what we inserted because date('c') from PHP is not accepted by MySQL. 

     

    Again, issue is with your environment. Tricky to find if you do not have experience.


    -Adam

     

  14. 7 hours ago, Blesta Addons said:

    no is not the issue, as other plugins didn't has the date field and has the same effect. take a look at this plugin in github , is working fine in php 5.5, but in php 5.6 is not working. not sure if the table shema has something to do with the issue .

    Thank you for providing more detailed information like someone else can reproduce the issue....

     

    Please apply the following patch file and let me know the results:

    diff --git a/announcements/models/announcements.php b/announcements/models/announcements.php                        
    index a61adc6..91c7856 100644                                                                                                                                                        
    --- a/announcements/models/announcements.php                                                                                                                                         
    +++ b/announcements/models/announcements.php                                                                                                                                         
    @@ -201,7 +201,13 @@ class Announcements extends AnnouncementsModel {                                               
                            $this->Record->begin();                                                                                         
                                                                                                                        
                            $fields = array("title", "body", "date_added", "active", "company_id", "public", "permit_client_groups", "permit_packages");
    -                       $this->Record->insert("nh_announcement_news", $vars, $fields);                              
    +                       $pdoStatement = $this->Record->insert("nh_announcement_news", $vars, $fields);              
    +            if($pdoStatement instanceof PDOStatement && $pdoStatement->errorCode() !== '00000') {                  
    +                echo "<pre>";                                                                                      
    +                print_r($pdoStatement->errorInfo());                                                               
    +                echo "</pre>";                                                                                     
    +                die();                                                                                                                                                                   
    +            }                                                                                                                                                                            
                            $announcement_id = $this->Record->lastInsertId();                                                                                                                 
                                                                                                                        
                            // Add client groups

     

  15. 16 minutes ago, Blesta Addons said:

    mike has just post a sample of insertion , we need to change it to a propre our query.

    I think what he posted is wrong. It does not make sense. Read my message.

    16 minutes ago, Blesta Addons said:

    from your response i feel that blesta CMS plugin was also infected with this behavior ?

    Doubt it, seeing how no one else is having issues.. just you...

    -Adam

  16. 17 minutes ago, Licensecart said:

    Does this work mate:

    
    $this->Record->insert('nh_announcement_news', [
                    'title'         => $vars['uri'],
                    'body'          => $company_id,
                    'active'        => serialize($vars['title']),
                    'company_id'    => $company_id,
                    'public'        => serialize($vars['meta_tags']),
                    'date_added'    => serialize($vars['description'])
                ]);

    Something like that but edited as that's what Abdy has done in our cms.

    Ugh.. That does not make sense. You have a field called "dated_added" but its a serialization of a field called description? If you run a query to find all announcements by date_added or sorted by date_added how does that work? Are you doing it application side -- not having the database do all the work for you?

    -Adam

  17. Can you make a single PHP file without Blesta or minPHP that 

    1. Creates the schema
    2. Inserts into sql
    3. Delete everything

    Does the problem still exist? This will help narrow if the issue is with minPHP or something else. Please also share the file and I can try and recreate it on my environment. I run CloudLinux and have access to multiple versions of PHP I can help test with.

    -Adam

×
×
  • Create New...