Merge branch '2015.11' into 2015.11-develop
authorPhilipp Schüle <p.schuele@metaways.de>
Mon, 24 Oct 2016 14:34:47 +0000 (16:34 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Mon, 24 Oct 2016 14:34:47 +0000 (16:34 +0200)
1  2 
tine20/Tinebase/Config.php
tine20/Tinebase/Controller/ScheduledImport.php

@@@ -84,13 -84,6 +84,13 @@@ class Tinebase_Config extends Tinebase_
      const CRONUSERID = 'cronuserid';
  
      /**
 +     * setup user id
 +     *
 +     * @var string
 +     */
 +    const SETUPUSERID = 'setupuserid';
 +
 +    /**
       * FEATURE_SHOW_ADVANCED_SEARCH
       *
       * @var string
      const FEATURE_SHOW_ADVANCED_SEARCH = 'featureShowAdvancedSearch';
  
      /**
 +     * FEATURE_CONTAINER_CUSTOM_SORT
 +     *
 +     * @var string
 +     */
 +    const FEATURE_CONTAINER_CUSTOM_SORT = 'featureContainerCustomSort';
 +
 +    /**
       * FEATURE_SHOW_ACCOUNT_EMAIL
       *
       * @var string
      const FEATURE_SHOW_ACCOUNT_EMAIL = 'featureShowAccountEmail';
  
      /**
 +     * FEATURE_REMEMBER_POPUP_SIZE
 +     *
 +     * @var string
 +     */
 +    const FEATURE_REMEMBER_POPUP_SIZE = 'featureRememberPopupSize';
 +
 +    /**
       * user defined page title postfix for browser page title
       * 
       * @var string
      /**
       * maintenance mode
       *
 -     * @var bool
 +     * @var string
       */
      const MAINTENANCE_MODE = 'maintenanceMode';
  
      /**
 -     * @var array of strings
 +     * @var string
       */
      const FAT_CLIENT_CUSTOM_JS = 'fatClientCustomJS';
      
 +    const BRANDING_LOGO = 'branding_logo';
 +    const BRANDING_FAVICON = 'branding_favicon';
 +    const BRANDING_TITLE = 'branding_title';
 +    const BRANDING_WEBURL = 'branding_weburl';
 +    const BRANDING_DESCRIPTION = 'branding_description';
 +
      /**
 -     * @var boolean
 +     * @var string
       */
      const USE_LOGINNAME_AS_FOLDERNAME = 'useLoginnameAsFoldername';
  
      /**
 -     * @var array of strings
 +     * @var string
       */
      const VERSION_CHECK = 'versionCheck';
  
                      'description'   => 'Show toggle button to switch on or off the advanced search for the quickfilter',
                      //_('Show toggle button to switch on or off the advanced search for the quickfilter')
                  ),
 +                self::FEATURE_CONTAINER_CUSTOM_SORT => array(
 +                    'label'         => 'Container Custom Sort', //_('Container Custom Sort')
 +                    'description'   => 'Allows to sort containers by setting the sort order in Admin/Container',
 +                    //_('Allows to sort containers by setting the sort order in Admin/Container')
 +                ),
                  self::FEATURE_SHOW_ACCOUNT_EMAIL => array(
                      'label'         => 'Show Account Email Address', //_('Show Account Email Address')
                      'description'   => 'Show email address in account picker and attendee grids',
                      //_('Show email address in account picker and attendee grids')
                  ),
 +                self::FEATURE_REMEMBER_POPUP_SIZE => array(
 +                    'label'         => 'Remeber Popup Size', //_('Remeber Popup Size')
 +                    'description'   => 'Save edit dialog size in state',
 +                    //_('Save edit dialog size in state')
 +                ),
              ),
              'default'               => array(
 -                self::FEATURE_SHOW_ADVANCED_SEARCH => false,
 -                self::FEATURE_SHOW_ACCOUNT_EMAIL => false,
 +                self::FEATURE_SHOW_ADVANCED_SEARCH  => false,
 +                self::FEATURE_CONTAINER_CUSTOM_SORT => false,
 +                self::FEATURE_SHOW_ACCOUNT_EMAIL    => false,
 +                self::FEATURE_REMEMBER_POPUP_SIZE   => false,
              ),
          ),
          self::CRONUSERID => array(
                                     //_('Use of external Geolocation services is allowed.')
              'description'           => 'Use of external Geolocation services is allowed.',
              'type'                  => 'bool',
-             'clientRegistryInclude' => TRUE,
-             'setByAdminModule'      => FALSE,
-             'setBySetupModule'      => TRUE,
+             'clientRegistryInclude' => true,
+             'setByAdminModule'      => false,
+             'setBySetupModule'      => true,
+             'default'               => true,
          ),
          self::LDAP_DISABLE_TLSREQCERT => array(
                                     //_('Disable LDAP TLS Certificate Check')
              'setByAdminModule'      => FALSE,
              'setBySetupModule'      => FALSE,
          ),
 +        self::BRANDING_DESCRIPTION => array(
 +                //_('custom description')
 +                'label'                 => 'custom description',
 +                //_('Custom description for branding.')
 +                'description'           => 'Custom description for branding.',
 +                'type'                  => 'string',
 +                'default'               => '',
 +                'clientRegistryInclude' => FALSE,
 +                'setByAdminModule'      => FALSE,
 +                'setBySetupModule'      => FALSE,
 +        ),
 +        self::BRANDING_WEBURL => array(
 +                //_('custom weburl')
 +                'label'                 => 'custom weburl',
 +                //_('Custom weburl for branding.')
 +                'description'           => 'Custom weburl for branding.',
 +                'type'                  => 'string',
 +                'default'               => '',
 +                'clientRegistryInclude' => FALSE,
 +                'setByAdminModule'      => FALSE,
 +                'setBySetupModule'      => FALSE,
 +        ),
 +        self::BRANDING_TITLE => array(
 +                //_('custom title')
 +                'label'                 => 'custom title',
 +                //_('Custom title for branding.')
 +                'description'           => 'Custom ltitle for branding.',
 +                'type'                  => 'string',
 +                'default'               => '',
 +                'clientRegistryInclude' => FALSE,
 +                'setByAdminModule'      => FALSE,
 +                'setBySetupModule'      => FALSE,
 +        ),
 +        self::BRANDING_LOGO => array(
 +                //_('custom logo path')
 +                'label'                 => 'custom logo path',
 +                //_('Path to custom logo.')
 +                'description'           => 'Path to custom logo.',
 +                'type'                  => 'string',
 +                'default'               => '',
 +                'clientRegistryInclude' => FALSE,
 +                'setByAdminModule'      => FALSE,
 +                'setBySetupModule'      => FALSE,
 +        ),
 +        self::BRANDING_FAVICON => array(
 +                //_('custom favicon path')
 +                'label'                 => 'custom favicon path',
 +                //_('Path to custom favicon.')
 +                'description'           => 'Path to custom favicon.',
 +                'type'                  => 'string',
 +                'default'               => '',
 +                'clientRegistryInclude' => FALSE,
 +                'setByAdminModule'      => FALSE,
 +                'setBySetupModule'      => FALSE,
 +        ),
          self::USE_LOGINNAME_AS_FOLDERNAME => array(
          //_('Use login name instead of full name')
              'label'                 => 'Use login name instead of full name',
              'setByAdminModule'      => FALSE,
              'setBySetupModule'      => FALSE,
              'default'               => FALSE,
 -        )
 +        ),
      );
      
      /**
@@@ -23,8 -23,6 +23,8 @@@ class Tinebase_Controller_ScheduledImpo
       * @var Tinebase_Controller_ScheduledImport
       */
      private static $instance = null;
 +
 +    const MAXFAILCOUNT = 5;
      
      /**
       * the constructor
              return $this->_doScheduledImport($record)->toArray();
          }
          
 -        return NULL;
 +        return null;
      }
  
 +    /**
 +     * @return Tinebase_Model_ImportFilter
 +     */
      public function getScheduledImportFilter()
      {
          $timestampBefore = null;
@@@ -92,9 -87,6 +92,9 @@@
          $aWeekAgo->subWeek(1);
  
          $filter = new Tinebase_Model_ImportFilter(array(array(
 +                array('field' => 'failcount', 'operator' => 'greater', 'value' => 5),
 +            ),
 +            array(
              'condition' => 'OR', 'filters' => array(
                  array('field' => 'timestamp', 'operator' => 'isnull', 'value' => null),
                  array('condition' => 'AND', 'filters' => array(
       * 
       * @param interval
       * @param recursive
 -     * @return Object
 +     * @return Tinebase_Model_Import|null
       */
      protected function _getNextScheduledImport()
      {
  
          // Always sort by timestamp to ensure first in first out
          $pagination = new Tinebase_Model_Pagination(array(
 -            'limit'     => 1,
 +            'limit'     => 50,
              'sort'      => 'timestamp',
              'dir'       => 'ASC'
          ));
  
 -        $record = $this->search($filter, $pagination)->getFirstRecord();
 -        
 -        if (! $record) {
 -            if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
 -                Tinebase_Core::getLogger()->debug(__METHOD__ . ' ' . __LINE__ . ' No ScheduledImport could be found.');
 -            }
 +        $records = $this->search($filter, $pagination);
  
 -            return NULL;
 +        foreach ($records as $record) {
 +            // TODO add failcount to filter in getScheduledImportFilter as
 +            //   no more valid imports are run if we have 50+ failing imports
 +            if ($record->failcount < self::MAXFAILCOUNT) {
 +                return $record;
 +            } else {
 +                if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
 +                    Tinebase_Core::getLogger()->info(__METHOD__ . ' ' . __LINE__ . ' Too many failures, skipping import');
 +                }
 +            }
          }
 -        return $record;
 +        
 +        if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
 +            Tinebase_Core::getLogger()->debug(__METHOD__ . ' ' . __LINE__ . ' No valid ScheduledImport could be found.');
 +        }
 +
 +        return null;
      }
      
      /**
      protected function _getFileToImport($source)
      {
          if (strpos($source, 'http') === 0) {
-             $client = new Zend_Http_Client($source);
              try {
+                 $client = new Zend_Http_Client($source);
                  $requestBody = $client->request()->getBody();
              } catch (Exception $e) {
                  Tinebase_Exception::log($e);
              try {
                  $importer = new $importer($options);
                  $importer->import($toImport);
 +                $record->failcount = 0;
              } catch (Exception $e) {
                  if (Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) {
                      Tinebase_Core::getLogger()->notice(__METHOD__ . ' ' . __LINE__
                          . ' Import failed.');
                  }
 -                // TODO log failure message in import record
                  Tinebase_Exception::log($e);
 +
 +                $record->lastfail = $e->getMessage();
 +                $record->failcount = $record->failcount + 1;
              }
  
              if ($record->interval === Tinebase_Model_Import::INTERVAL_ONCE || !$record->timestamp instanceof Tinebase_DateTime) {
                      break;
              }
  
 -            // update record
              $record = $this->update($record);
              
          } else {
          
          return $this->create($record);
      }
- }
+ }