Merge branch '2014.11' into 2015.11
authorPhilipp Schüle <p.schuele@metaways.de>
Thu, 16 Jun 2016 08:53:08 +0000 (10:53 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Thu, 16 Jun 2016 08:53:08 +0000 (10:53 +0200)
Conflicts:
tine20/Calendar/Convert/Event/Json.php
tine20/Calendar/Frontend/iMIP.php
tine20/Sales/Setup/Update/Release8.php

Change-Id: I94ce69a37d81e860f8fdef95fe687d3eb26bf735

1  2 
tests/tine20/Calendar/Convert/Event/VCalendar/GenericTest.php
tests/tine20/Calendar/Frontend/iMIPTest.php
tine20/Addressbook/Setup/setup.xml
tine20/Calendar/Controller/MSEventFacade.php
tine20/Calendar/Convert/Event/Json.php
tine20/Calendar/Frontend/iMIP.php
tine20/Calendar/Model/Attender.php
tine20/Sales/Setup/Update/Release8.php

Simple merge
@@@ -119,23 -96,14 +119,15 @@@ class Calendar_Convert_Event_Json exten
  
          Tinebase_Notes::getInstance()->getMultipleNotesOfRecords($_records);
          Tinebase_Tags::getInstance()->getMultipleTagsOfRecords($_records);
 -        if (Setup_Controller::getInstance()->isFilesystemAvailable()) {
 +        if (Tinebase_Core::isFilesystemAvailable()) {
              Tinebase_FileSystem_RecordAttachments::getInstance()->getMultipleAttachmentsOfRecords($_records);
          }
-         
          Calendar_Model_Attender::resolveAttendee($_records->attendee, TRUE, $_records);
          Calendar_Convert_Event_Json::resolveRrule($_records);
          Calendar_Controller_Event::getInstance()->getAlarms($_records);
          
-         self::resolveMultipleIdFields($_records, array(
-             'Addressbook_Model_Contact' => array(
-                 'options' => array('ignoreAcl' => TRUE),
-                 'fields'  => array('organizer'),
-             ),
-             'recursive' => array('attachments' => 'Tinebase_Model_Tree_Node')
-         ));
 +        Calendar_Convert_Event_Json::resolveGrantsOfExternalOrganizers($_records);
          Calendar_Model_Rrule::mergeAndRemoveNonMatchingRecurrences($_records, $_filter);
          $_records->sortByPagination($_pagination);
          
@@@ -338,22 -326,12 +338,17 @@@ class Calendar_Frontend_iMI
  
              $iMIPEvent = $_iMIP->getEvent();
  
 -            $events = Calendar_Controller_MSEventFacade::getInstance()->search(new Calendar_Model_EventFilter(array(
 +            $filters = new Calendar_Model_EventFilter(array(
                  array('field' => 'uid',          'operator' => 'equals', 'value' => $iMIPEvent->uid),
 -            )));
 +            ));
 +            if ($_getDeleted) {
 +                $deletedFilter = new Tinebase_Model_Filter_Bool('is_deleted', 'equals', Tinebase_Model_Filter_Bool::VALUE_NOTSET);
 +                $filters->addFilter($deletedFilter);
 +            }
 +            $events = Calendar_Controller_MSEventFacade::getInstance()->search($filters);
  
-             // NOTE: cancelled attendees from ext. organizers don't have read grant
-             // find a better way to check grants
-             if (! $_getDeleted) {
-                 $events = $events->filter(Tinebase_Model_Grants::GRANT_READ, TRUE);
-             }
-             $event = $events->getFirstRecord();
-             Calendar_Model_Attender::resolveAttendee($event['attendee']);
+             $event = $events->filter(Tinebase_Model_Grants::GRANT_READ, TRUE)->getFirstRecord();
+             Calendar_Model_Attender::resolveAttendee($event['attendee'], true, $event);
  
              $_iMIP->existing_event = $event;
          }
Simple merge
@@@ -89,109 -88,15 +89,16 @@@ class Sales_Setup_Update_Release8 exten
       */
      protected function _updateContractsFields()
      {
 -        $adminGroup   = Tinebase_Group::getInstance()->getDefaultAdminGroup();
 +        $adminGroup = Tinebase_Group::getInstance()->getDefaultAdminGroup();
          $groupMembers = Tinebase_Group::getInstance()->getGroupMembers($adminGroup->getId());
 +
          if (count($groupMembers) > 0) {
              $user = Tinebase_User::getInstance()->getUserById($groupMembers[0]);
-             Tinebase_Core::set(Tinebase_Core::USER, $user);
-             // cleared, cleared_in, status gets deleted, if the update is not called on cli
-             $controller = Sales_Controller_Contract::getInstance();
-             $table = new Zend_Db_Table(SQL_TABLE_PREFIX . 'sales_contracts', new Zend_Db_Table_Definition(array(
-                 'id' => array('name' => 'id'),
-                 'status' => array('name' => 'status'),
-                 'cleared' => array('name' => 'cleared'),
-                 'cleared_in' => array('name' => 'cleared_in'),
-                 'description' => array('name' => 'description'),
-                 'last_modified_time' => array('name' => 'last_modified_time')
-             )));
-             $count = 50;
-             $offset = 0;
-             $more = true;
-             $updateDescription = $statusConfig = $clearedConfig = $setEndDate = array();
-             $appId = Tinebase_Application::getInstance()->getApplicationByName('Tinebase')->getId();
-             $pref = Tinebase_Core::getPreference('Tinebase');
-             Tinebase_Core::setupUserLocale($pref->locale);
-             $t = Tinebase_Translation::getTranslation('Sales', Tinebase_Core::getLocale());
-             $config = Sales_Config::getInstance()->get('contractStatus');
-             foreach ($config['records'] as $cfg) {
-                 $statusConfig[$cfg['id']] = $cfg['value'];
-             }
-             $config = Sales_Config::getInstance()->get('contractCleared');
-             foreach ($config['records'] as $cfg) {
-                 $clearedConfig[$cfg['id']] = $cfg['value'];
-             }
-             while ($more) {
-                 $results = $table->fetchAll(NULL, NULL, $count, $offset)->toArray();
-                 foreach ($results as $row) {
-                     if ($row['status'] == 'CLOSED') {
-                         $setEndDate[$row['id']] = $row['last_modified_time'];
-                     }
-                     $desc = $row['description'];
-                     $desc .= PHP_EOL . '---' . PHP_EOL . PHP_EOL;
-                     $contents = FALSE;
-                     if (!empty($row['status'])) {
-                         $desc .= $t->_('Status') . ': ';
-                         $desc .= (isset($statusConfig[$row['status']]) ? $t->_($statusConfig[$row['status']]) : $row['status']);
-                         $desc .= PHP_EOL;
-                         $contents = TRUE;
-                     }
-                     if (!empty($row['cleared'])) {
-                         $desc .= $t->_('Cleared') . ': ';
-                         $desc .= (isset($clearedConfig[$row['cleared']]) ? $t->_($clearedConfig[$row['cleared']]) : $row['cleared']);
-                         $desc .= PHP_EOL;
-                         $contents = TRUE;
-                     }
-                     if (!empty($row['cleared_in'])) {
-                         $desc .= $t->_('Cleared In') . ': ';
-                         $desc .= $row['cleared_in'];
-                         $desc .= PHP_EOL;
-                         $contents = TRUE;
-                     }
-                     if ($contents) {
-                         $updateDescription[$row['id']] = $desc . PHP_EOL;
-                     }
-                 }
-                 if (count($updateDescription) > 50) {
-                     foreach ($controller->getMultiple(array_keys($updateDescription)) as $contr) {
-                         $contr->description = $updateDescription[$contr->getId()];
-                         $controller->update($contr, FALSE);
-                     }
-                     $updateDescription = array();
-                 }
-                 if (count($results) < $count) {
-                     $more = FALSE;
-                 } else {
-                     $offset = $offset + $count;
-                 }
-             }
-             try {
-                 foreach ($controller->getMultiple(array_keys($updateDescription)) as $contr) {
-                     $contr->description = $updateDescription[$contr->getId()];
-                     $controller->update($contr, FALSE);
-                 }
-             } catch (Tinebase_Exception_AccessDenied $tead) {
-                 // could not update contracts ...
-                 Tinebase_Exception::log($tead);
+             if ($user->hasRight('Sales', Sales_Acl_Rights::ADMIN)) {
+                 $this->_updateContractsWithUser($user);
              }
          }
 -        
 +
          // remove deprecated sales contract fields
          foreach (array('status', 'cleared_in', 'cleared') as $colToDrop) {
              try {
          }
      }
  
 -                if (! empty($row['status'])) {
+     protected function _updateContractsWithUser($user)
+     {
+         Tinebase_Core::set(Tinebase_Core::USER, $user);
+         // cleared, cleared_in, status gets deleted, if the update is not called on cli
+         $controller = Sales_Controller_Contract::getInstance();
+         $table = new Zend_Db_Table(SQL_TABLE_PREFIX . 'sales_contracts', new Zend_Db_Table_Definition(array(
+             'id' => array('name' => 'id'),
+             'status' => array('name' => 'status'),
+             'cleared' => array('name' => 'cleared'),
+             'cleared_in' => array('name' => 'cleared_in'),
+             'description' => array('name' => 'description'),
+             'last_modified_time' => array('name' => 'last_modified_time')
+         )));
+         $count = 50;
+         $offset = 0;
+         $more = true;
+         $updateDescription = $statusConfig = $clearedConfig = $setEndDate = array();
+         $pref = Tinebase_Core::getPreference('Tinebase');
+         Tinebase_Core::setupUserLocale($pref->locale);
+         $t = Tinebase_Translation::getTranslation('Sales', Tinebase_Core::getLocale());
+         $config = Sales_Config::getInstance()->get('contractStatus');
+         foreach ($config['records'] as $cfg) {
+             $statusConfig[$cfg['id']] = $cfg['value'];
+         }
+         $config = Sales_Config::getInstance()->get('contractCleared');
+         foreach ($config['records'] as $cfg) {
+             $clearedConfig[$cfg['id']] = $cfg['value'];
+         }
+         while ($more) {
+             $results = $table->fetchAll(NULL, NULL, $count, $offset)->toArray();
+             foreach ($results as $row) {
+                 if ($row['status'] == 'CLOSED') {
+                     $setEndDate[$row['id']] = $row['last_modified_time'];
+                 }
+                 $desc = $row['description'];
+                 $desc .= PHP_EOL . '---' . PHP_EOL . PHP_EOL;
+                 $contents = FALSE;
 -                if (! empty($row['cleared'])) {
++                if (!empty($row['status'])) {
+                     $desc .= $t->_('Status') . ': ';
+                     $desc .= (isset($statusConfig[$row['status']]) ? $t->_($statusConfig[$row['status']]) : $row['status']);
+                     $desc .= PHP_EOL;
+                     $contents = TRUE;
+                 }
 -                if (! empty($row['cleared_in'])) {
++                if (!empty($row['cleared'])) {
+                     $desc .= $t->_('Cleared') . ': ';
+                     $desc .= (isset($clearedConfig[$row['cleared']]) ? $t->_($clearedConfig[$row['cleared']]) : $row['cleared']);
+                     $desc .= PHP_EOL;
+                     $contents = TRUE;
+                 }
 -                foreach($controller->getMultiple(array_keys($updateDescription)) as $contr) {
++                if (!empty($row['cleared_in'])) {
+                     $desc .= $t->_('Cleared In') . ': ';
+                     $desc .= $row['cleared_in'];
+                     $desc .= PHP_EOL;
+                     $contents = TRUE;
+                 }
+                 if ($contents) {
+                     $updateDescription[$row['id']] = $desc . PHP_EOL;
+                 }
+             }
+             if (count($updateDescription) > 50) {
++                foreach ($controller->getMultiple(array_keys($updateDescription)) as $contr) {
+                     $contr->description = $updateDescription[$contr->getId()];
+                     $controller->update($contr, FALSE);
+                 }
+                 $updateDescription = array();
+             }
+             if (count($results) < $count) {
+                 $more = FALSE;
+             } else {
+                 $offset = $offset + $count;
+             }
+         }
+         try {
+             foreach ($controller->getMultiple(array_keys($updateDescription)) as $contr) {
+                 $contr->description = $updateDescription[$contr->getId()];
+                 $controller->update($contr, FALSE);
+             }
+         } catch (Tinebase_Exception_AccessDenied $tead) {
+             // could not update contracts ...
+             Tinebase_Exception::log($tead);
+         }
+     }
+     
      /**
       * update to 8.4
 -     * 
 +     *
       * switch to modelconfig, create divison module
       * remove "status", "cleared", "cleared_in", but append values to the description field
       */