Jump to content

Adam

Members
  • Posts

    131
  • Joined

  • Last visited

  • Days Won

    16

Reputation Activity

  1. Like
    Adam got a reaction from activa in Increase Session Timeout?   
    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
     
  2. Like
    Adam got a reaction from Michael in Where to Get Customized Blesta Works Done?   
    https://www.blesta.com/development/
    -Adam
  3. Like
    Adam got a reaction from Abdy in Where to Get Customized Blesta Works Done?   
    https://www.blesta.com/development/
    -Adam
  4. Like
    Adam got a reaction from Michael in Event Handlers - Client & Contact CRUD   
    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
  5. Like
    Adam got a reaction from activa in Event Handlers - Client & Contact CRUD   
    Just post a patch file. Stop uploading zips, they are a pain to work with and make it hard to merge.
     
  6. Like
    Adam got a reaction from activa in Event Handlers - Client & Contact CRUD   
    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  
  7. Like
    Adam got a reaction from evolvewh in Increase Session Timeout?   
    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
     
  8. Like
    Adam got a reaction from Michael in Event Handlers - Client & Contact CRUD   
    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  
  9. Like
    Adam got a reaction from activa in Secure Ftp Backup Failing   
    SFTP and FTPS are two different things. Is your server configured to use the correct one?
    SFTP uses SSH over port 22
    FTPS uses FTP with TLS/SSL over port 21
     
    -Adam
  10. Like
    Adam got a reaction from activa in v4 Changelog for Developers on Plugin System   
    Does not appear to be working (v4):
    http://source-docs.blesta.com/class-Record.html
    as an example.
    3.6 still works.
    -Adam
  11. Like
    Adam got a reaction from activa in 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
     
  12. Like
    Adam got a reaction from activa in v4 Changelog for Developers on Plugin System   
    Hello,
    We literally just finished our development of the Cerb helpdesk plugin that would allow Blesta clients to use Cerb instead of the default helpdesk with Blesta. Now we noticed that v4 is out (congratulations).
    Is there a write up somewhere, for developers, on what changed when creating a custom plugin? What functions depreciated? New features added? etc.
    We have not tried our new plugin on a v4 system yet, but I suspect we will start that process soon.
     
    Thanks,
    -Adam
    P.S. For those wondering, we plan on releasing the Cerb plugin, free of charge, to the rest of the Blesta community. No ETA yet.
  13. Like
    Adam got a reaction from Michael in successfully added message, but no data inserted in databse   
    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
  14. Like
    Adam got a reaction from BeZazz in Cache Directory Writable Test   
    We are installing Blesta 4.0.0 and notice that during the installation process an alert was issued saying that our cache directory was not writable. This was strange to us because in our environment, the user who runs PHP has write access (we use suPHP for security reasons).
     
    Upon closer look we notice that Blesta 4.0.0 does not ship with an empty cache directory (as defined by CACHEDIR). Rather, the code assumes that the cache directory already exists. You can see this below:
     
    app/controllers/install.php 807 'cache_writable' => [ 808 'message' => Language::_('SystemRequirements.!warning.cache_writable.recommended', true, CACHEDIR), 809 'req' => true, 810 'cur' => is_writable(CACHEDIR) 811 ], // To cache view files for performance The PHP function is_writable does two things: checks if the user can write AND if the file exists. Since Blesta does not ship with an empty CACHEDIR (nor was anything mentioned to create one in the README), we get an error for no reason.
     
    Below is a patch for a proposed fix. It checks to see if a file exists, if it does, then performs the is_writable test. Otherwise, attempt to create a directory and check if we can write to it The second test is probably pointless cause if you can create a directory you should be able to write to it, but edge cases can be tricky if parent folder has sticky bits enable, etc.
    -Adam
     
    diff --git a/app/controllers/install.php b/app/controllers/install.php index a6c462e..414d3a8 100644 --- a/app/controllers/install.php +++ b/app/controllers/install.php @@ -807,7 +807,7 @@ class Install extends Controller 'cache_writable' => [ 'message' => Language::_('SystemRequirements.!warning.cache_writable.recommended', true, CACHEDIR), 'req' => true, - 'cur' => is_writable(CACHEDIR) + 'cur' => (file_exists(CACHEDIR)) ? is_writable(CACHEDIR) : (mkdir(CACHEDIR, 0755) && is_writable(CACHEDIR)) ? true : false ], // To cache view files for performance 'ext-simplexml' => [ 'message' => Language::_('SystemRequirements.!warning.simplexml.recommended', true),  
  15. Like
    Adam got a reaction from Blesta Addons in Cache Directory Writable Test   
    We are installing Blesta 4.0.0 and notice that during the installation process an alert was issued saying that our cache directory was not writable. This was strange to us because in our environment, the user who runs PHP has write access (we use suPHP for security reasons).
     
    Upon closer look we notice that Blesta 4.0.0 does not ship with an empty cache directory (as defined by CACHEDIR). Rather, the code assumes that the cache directory already exists. You can see this below:
     
    app/controllers/install.php 807 'cache_writable' => [ 808 'message' => Language::_('SystemRequirements.!warning.cache_writable.recommended', true, CACHEDIR), 809 'req' => true, 810 'cur' => is_writable(CACHEDIR) 811 ], // To cache view files for performance The PHP function is_writable does two things: checks if the user can write AND if the file exists. Since Blesta does not ship with an empty CACHEDIR (nor was anything mentioned to create one in the README), we get an error for no reason.
     
    Below is a patch for a proposed fix. It checks to see if a file exists, if it does, then performs the is_writable test. Otherwise, attempt to create a directory and check if we can write to it The second test is probably pointless cause if you can create a directory you should be able to write to it, but edge cases can be tricky if parent folder has sticky bits enable, etc.
    -Adam
     
    diff --git a/app/controllers/install.php b/app/controllers/install.php index a6c462e..414d3a8 100644 --- a/app/controllers/install.php +++ b/app/controllers/install.php @@ -807,7 +807,7 @@ class Install extends Controller 'cache_writable' => [ 'message' => Language::_('SystemRequirements.!warning.cache_writable.recommended', true, CACHEDIR), 'req' => true, - 'cur' => is_writable(CACHEDIR) + 'cur' => (file_exists(CACHEDIR)) ? is_writable(CACHEDIR) : (mkdir(CACHEDIR, 0755) && is_writable(CACHEDIR)) ? true : false ], // To cache view files for performance 'ext-simplexml' => [ 'message' => Language::_('SystemRequirements.!warning.simplexml.recommended', true),  
  16. Like
    Adam got a reaction from Blesta Addons in v4 Changelog for Developers on Plugin System   
    Hello,
    We literally just finished our development of the Cerb helpdesk plugin that would allow Blesta clients to use Cerb instead of the default helpdesk with Blesta. Now we noticed that v4 is out (congratulations).
    Is there a write up somewhere, for developers, on what changed when creating a custom plugin? What functions depreciated? New features added? etc.
    We have not tried our new plugin on a v4 system yet, but I suspect we will start that process soon.
     
    Thanks,
    -Adam
    P.S. For those wondering, we plan on releasing the Cerb plugin, free of charge, to the rest of the Blesta community. No ETA yet.
  17. Like
    Adam got a reaction from Stu in New Install Display Error   
    Morning,
     
    It looks like your CSS and images are not loading. Maybe a permissions issues or you forgot to upload the files / folder.
    View the source on the webpage, and try to load a CSS file. See what the server response back with:
    Example:
    Visit: domain.tld/app/views/client/bootstrap/css/bootstrap.min.css
    -Adam
     
  18. Like
    Adam got a reaction from Michael in New Install Display Error   
    Morning,
     
    It looks like your CSS and images are not loading. Maybe a permissions issues or you forgot to upload the files / folder.
    View the source on the webpage, and try to load a CSS file. See what the server response back with:
    Example:
    Visit: domain.tld/app/views/client/bootstrap/css/bootstrap.min.css
    -Adam
     
  19. Like
    Adam got a reaction from S.H. in Adding Public Note To Invoice Leads To 403 Forbidden Error   
    Check your error/access log of your webserver. It will tell you why it is giving a 403. It could very well be mod_security related.
    -Adam
  20. Like
    Adam got a reaction from Paul in Adding Public Note To Invoice Leads To 403 Forbidden Error   
    Check your error/access log of your webserver. It will tell you why it is giving a 403. It could very well be mod_security related.
    -Adam
  21. Like
    Adam reacted to Paul in Release 3.6.1   
    Constructive criticism, thank you I appreciate the feedback.
  22. Like
    Adam got a reaction from Lucas in Update Geoip Database Weekly.   
    If you run this in a cronjob, no need to log each message since you log the whole script (email or pipe redirection). I would also make the suggestion you use https as opposed to http for the transfer (geolite supports this).
    You could get a small performance boost if you used named pipes and curl. Something like this would work:
     

    curl -L https://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz | gunzip > GeoLiteCity.dat That is pretty agressive. The Maxmind website says the database is updated on the first Tuesday of the month. Taking into account the various number of timezones and not knowing when on Tuesday the database is updated, lets run this on Wednesdays instead.
     

    0 9 * * 3 [ `date +\%d` -le 7 ] && curl -L https://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz | gunzip > /srv/uploads/system/GeoLiteCity.dat  Runs on the first Wednesday of every month at 9AM server time.
     
    It is more then just countries, cities are accounted for. With IPv4 shortage, v4 addresses are being reallocated, reassigned more fequrently then ever before.
    Note to Blesta Devs: Should switch to the new GeoLite2 database format. The current one is legacy and will be deprecated at some point. The new GeoLite2 also includes md5 sums which can be added to the script above.
    http://dev.maxmind.com/geoip/geoip2/geolite2/
    -Adam
  23. Like
    Adam got a reaction from Michael in Will Pay To Check   
    While the next comment I make is going to make me sound like an asshole, eh, why not.
    If you are having trouble / issue with setting up cron, perhaps you should not be in offering web hosting or and offering WordPress Websites & Support (as your signature says). I am making this statement, not based off this one single post, but as a whole with all the other posts you have made.
    None the less, READ the documenation here: http://docs.blesta.com/display/user/Installing+Blesta#InstallingBlesta-4.SetupaCronJob and if you have a specific question about cron, ask away. May you provide us more information as to the issue you are having with cron -- provider error logs maybe? Or a detailed description of the problem?
    -Adam
  24. Like
    Adam reacted to serge in Will Pay To Check   
    do you always create xx topics related to same things,
     
    by the way I think you will afraid anybody trying to help as issue could not only be technical...but a never ending same 's guy story
  25. Like
    Adam got a reaction from Michael in Blesta Colours   
    Is the following not useful? http://www.blesta.com/resources/
    -Adam
×
×
  • Create New...