Jump to content

Adam

Members
  • Posts

    131
  • Joined

  • Last visited

  • Days Won

    16

Everything posted by Adam

  1. 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. If your hosting provider does not offer Mailparse, then find a different one. It is standard among good hosting providers. -Adam
  3. Thanks Paul and of course the rest of the Blesta team.
  4. Blesta aka Phillips Data is the maker for Blesta and minPHP. Please provide documentation to minPHP. If source-docs.blesta.com is not the right place for minPHP then let everyone one where the new place should be.
  5. 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
  6. 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
  7. 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
  8. 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
  9. Your not using cPanel/WHM correctly. Login to WHM Select Module Install Select PHP pecl Then search for mailparse 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
  10. FYI: The new 4.0 source docs still appear to be missing all the minphp classes (Record, etc.) -Adam
  11. Doh! 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
  12. https://www.blesta.com/development/ -Adam
  13. Added a feature request: https://requests.blesta.com/topic/pull-request-client-and-contact-create-update-and-delete-callbacks Lets hope the Blesta team acknowledges it and gets it into main branch. Would be a shame to ignore it, seeing how the only thing left for them to do merge + QA it. -Adam
  14. 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
  15. Just post a patch file. Stop uploading zips, they are a pain to work with and make it hard to merge.
  16. 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
  17. Hello, Is https://docs.blesta.com/display/dev/Event+Handlers up to date? I am trying to register a callback so that when any CRUD operation is performed on a client or sub-contact, our plugin gets notified. Reading the documentation makes it seems the only callback available is when a client is created. What about updated, or deleted? Sames goes for sub-contacts. Thanks, -Adam
  18. Adam

    Nginx Config

    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
  19. Does not appear to be working (v4): http://source-docs.blesta.com/class-Record.html as an example. 3.6 still works. -Adam
  20. 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
  21. 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
  22. 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
  23. 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
  24. 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
  25. Do you understand how database transactions work? If any SQL statement fails, everything in the transaction fails and the rollback function is called. 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...