public function display()
    {
        $jirafe = new Jirafe();
        $ps = $jirafe->getPrestashopClient();
        $apiUrl = JIRAFE_DEBUG ? 'https://test-api.jirafe.com/v1' : 'https://api.jirafe.com/v1';
        $token = $ps->get('token');
        $appId = $ps->get('app_id');
        $locale = $ps->getLanguage();
        $title = $this->l('Dashboard');
        $errMsg = $this->l("We're unable to connect with the Jirafe service for the moment. Please wait a few minutes and refresh this page later.");
        echo <<<EOF
<div>
    <h1>{$title}</h1>
    <hr style="background-color: #812143;color: #812143;" />
    <br />
</div>
<style>#container { width:1260px; }</style>
<!-- Jirafe Dashboard Begin -->
<div id="jirafe"></div>
<script type="text/javascript">
(function(jQuery) {
    var \$ = jQuery;
     \$('#jirafe').jirafe({
        api_url:    '{$apiUrl}',
        api_token:  '{$token}',
        app_id:     '{$appId}',
        locale:     '{$locale}',
        version:    'presta-v0.1.0'
     });
})(jirafe.jQuery);
setTimeout(function() {
    if (\$('mod-jirafe') == undefined){
        \$('messages').insert ("<ul class=\\"messages\\"><li class=\\"error-msg\\">{$errMsg}</li></ul>");
    }
}, 2000);
</script>
<!-- Jirafe Dashboard End -->
EOF;
    }
Ejemplo n.º 2
0
 public function hookActionObjectUpdateBefore($params)
 {
     // do not sync all updated object by default,
     // only if certain fields are updated
     self::$syncUpdatedObject = false;
     $object = $params['object'];
     // sync only if following fields are changed
     if ($object instanceof Employee) {
         $employee = new Employee();
         $oldObject = $employee->getByEmail($object->email);
         if ($oldObject) {
             if ($object->lastname != $oldObject->lastname || $object->firstname != $oldObject->firstname || $object->email != $oldObject->email || $object->active != $oldObject->active) {
                 self::$syncUpdatedObject = true;
             }
         } else {
             // sync if email change
             self::$syncUpdatedObject = true;
         }
     } elseif ($object instanceof Shop) {
         $oldShop = Shop::getShop($object->id);
         if ($object->name != $oldShop['name'] || $object->active != $oldShop['active']) {
             self::$syncUpdatedObject = true;
         }
     }
 }