Merge branch '2015.11-develop'
authorPhilipp Schüle <p.schuele@metaways.de>
Mon, 25 Jan 2016 08:09:15 +0000 (09:09 +0100)
committerPhilipp Schüle <p.schuele@metaways.de>
Mon, 25 Jan 2016 08:09:15 +0000 (09:09 +0100)
tests/tine20/Admin/JsonTest.php
tine20/Admin/Controller/User.php
tine20/Admin/Frontend/Json.php
tine20/Calendar/Setup/Update/Release8.php
tine20/Tinebase/js/common.js

index 2b6e252..4051d44 100644 (file)
@@ -4,7 +4,7 @@
  * 
  * @package     Admin
  * @license     http://www.gnu.org/licenses/agpl.html
- * @copyright   Copyright (c) 2008-2014 Metaways Infosystems GmbH (http://www.metaways.de)
+ * @copyright   Copyright (c) 2008-2015 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Philipp Schüle <p.schuele@metaways.de>
  */
 
@@ -1134,46 +1134,15 @@ class Admin_JsonTest extends TestCase
         $secondaryDomainConfig = Tinebase_EmailUser::manages(Tinebase_Config::SMTP) && isset($smtpConfig['secondarydomains'])
             ? $smtpConfig['secondarydomains'] : '';
 
-        $afj = new Admin_Frontend_Json();
-        $registryData = $afj->getRegistryData();
+        $registryData = $this->_json->getRegistryData();
 
         $this->assertEquals($registryData['primarydomain'],  $primaryDomainConfig);
         $this->assertEquals($registryData['secondarydomains'], $secondaryDomainConfig);
     }
 
-//    public function testGetConfig()
-//    {
-//        $afj = new Admin_Frontend_Json();
-//        $config = $afj->getConfig('Calendar');
-//
-//        $this->assertGreaterThanOrEqual(2, count($config));
-//        $this->assertArrayHasKey('attendeeRoles', $config);
-//        $this->assertArrayHasKey('records', $config['attendeeRoles']);
-//        $this->assertGreaterThanOrEqual(1, $config['attendeeRoles']['records']);
-//    }
-//
-//    public function testSetConfig()
-//    {
-//        $afj = new Admin_Frontend_Json();
-//        $config = $afj->getConfig('Calendar');
-//
-//        $attendeeRoles = $config['attendeeRoles'];
-//        $attendeeRoles['records'][] = array(
-//            'id'    => 'CHAIR',
-//            'value' => 'Chair'
-//        );
-//
-//        $afj->setConfig('Calendar', 'attendeeRoles', $attendeeRoles);
-//
-//        $updatedConfig = $afj->getConfig('Calendar');
-//        $this->assertEquals(count($attendeeRoles['records']), count($updatedConfig['attendeeRoles']['records']));
-//    }
-
     public function testSearchConfigs()
     {
-        $afj = new Admin_Frontend_Json();
-
-        $result = $afj->searchConfigs(array(
+        $result = $this->_json->searchConfigs(array(
             'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Calendar')->getId()
         ), array());
 
@@ -1197,8 +1166,7 @@ class Admin_JsonTest extends TestCase
     {
         $attendeeRoles = $this->testUpdateConfig();
 
-        $afj = new Admin_Frontend_Json();
-        $fetchedAttendeeRoles = $afj->getConfig($attendeeRoles['id']);
+        $fetchedAttendeeRoles = $this->_json->getConfig($attendeeRoles['id']);
 
         $this->assertEquals($attendeeRoles['value'], $fetchedAttendeeRoles['value']);
     }
@@ -1215,13 +1183,64 @@ class Admin_JsonTest extends TestCase
         $attendeeRoles['value'] = json_encode($keyFieldConfig);
         $attendeeRoles['id'] = '';
 
-
-        $afj = new Admin_Frontend_Json();
-        $afj->saveConfig($attendeeRoles);
+        $this->_json->saveConfig($attendeeRoles);
 
         $updatedAttendeeRoles = $this->testSearchConfigs();
 
         $this->assertEquals($attendeeRoles['value'], $updatedAttendeeRoles['value']);
         return $updatedAttendeeRoles;
     }
+
+    /**
+     * @see 0011504: deactivated user is removed from group when group is saved
+     */
+    public function testDeactivatedUserGroupSave()
+    {
+        // deactivate user
+        $userArray = $this->testSaveAccount();
+
+        Admin_Controller_User::getInstance()->setAccountStatus($userArray['accountId'], Tinebase_Model_User::ACCOUNT_STATUS_DISABLED);
+
+        // save group
+        $group = Tinebase_Group::getInstance()->getGroupByName('tine20phpunit');
+        $groupArray = $this->_json->getGroup($group->getId());
+        $this->assertEquals(1, $groupArray['groupMembers']['totalcount']);
+        $groupArray['container_id'] = $groupArray['container_id']['id'];
+        $savedGroup = $this->_json->saveGroup($groupArray, array($userArray['accountId']));
+
+        // check group memberships
+        $this->assertEquals(1, $savedGroup['groupMembers']['totalcount']);
+    }
+
+    /**
+     * @see 0011504: deactivated user is removed from group when group is saved
+     */
+    public function testBlockedUserGroupSave()
+    {
+        // deactivate user
+        $userArray = $this->testSaveAccount();
+        $userArray['lastLoginFailure'] = Tinebase_DateTime::now()->toString();
+        $userArray['loginFailures'] = 10;
+
+        // save group
+        // TODO generalize
+        $group = Tinebase_Group::getInstance()->getGroupByName('tine20phpunit');
+        $groupArray = $this->_json->getGroup($group->getId());
+        $this->assertEquals(1, $groupArray['groupMembers']['totalcount']);
+        $groupArray['container_id'] = $groupArray['container_id']['id'];
+        $savedGroup = $this->_json->saveGroup($groupArray, array($userArray['accountId']));
+
+        // check group memberships
+        $this->assertEquals(1, $savedGroup['groupMembers']['totalcount']);
+    }
+
+    /**
+     * test set expired status
+     */
+    public function testSetUserExpiredStatus()
+    {
+        $userArray = $this->testSaveAccount();
+        $result = Admin_Controller_User::getInstance()->setAccountStatus($userArray['accountId'], Tinebase_Model_User::ACCOUNT_STATUS_EXPIRED);
+        $this->assertEquals(1, $result);
+    }
 }
index 1351139..1ff0492 100644 (file)
@@ -125,7 +125,7 @@ class Admin_Controller_User extends Tinebase_Controller_Abstract
      *
      * @param   string $_accountId  account id
      * @param   string $_status     status to set
-     * @return  array with success flag
+     * @return  int
      */
     public function setAccountStatus($_accountId, $_status)
     {
index 828acea..7f288c7 100644 (file)
@@ -629,7 +629,7 @@ class Admin_Frontend_Json extends Tinebase_Frontend_Json_Abstract
      * save group data from edit form
      *
      * @param   array $groupData        group data
-     * @param   array $groupMembers     group members
+     * @param   array $groupMembers     group members (array of ids)
      * 
      * @return  array
      */
index 59257f9..519eaa2 100644 (file)
@@ -502,17 +502,19 @@ class Calendar_Setup_Update_Release8 extends Setup_Update_Abstract
      */
     public function update_11()
     {
-        $deviceBackend = new ActiveSync_Backend_Device();
-        $usersWithiPhones = $deviceBackend->search(new ActiveSync_Model_DeviceFilter(array(
-            'devicetype' => 'iphone'
-        )))->owner_id;
-
-        $activeSyncController = ActiveSync_Controller::getInstance();
-        foreach($usersWithiPhones as $userId) {
-            try {
-                $activeSyncController->resetSyncForUser($userId, 'Calendar');
-            } catch (Exception $e) {
-                Tinebase_Exception::log($e, /* suppress trace */ false);
+        if (Tinebase_Application::getInstance()->isInstalled('ActiveSync')) {
+            $deviceBackend = new ActiveSync_Backend_Device();
+            $usersWithiPhones = $deviceBackend->search(new ActiveSync_Model_DeviceFilter(array(
+                'devicetype' => 'iphone'
+            )))->owner_id;
+
+            $activeSyncController = ActiveSync_Controller::getInstance();
+            foreach ($usersWithiPhones as $userId) {
+                try {
+                    $activeSyncController->resetSyncForUser($userId, 'Calendar');
+                } catch (Exception $e) {
+                    Tinebase_Exception::log($e, /* suppress trace */ false);
+                }
             }
         }
 
index 486dbc4..d28b49f 100644 (file)
@@ -576,6 +576,30 @@ Tine.Tinebase.common = {
     },
 
     /**
+     * i18n renderer
+     *
+     * NOTE: needs to be bound to i18n object!
+     *
+     * renderer: Tine.Tinebase.common.i18nRenderer.createDelegate(this.app.i18n)
+     * @param original
+     */
+    i18nRenderer: function(original) {
+        return this._hidden(original);
+    },
+
+    /**
+     * color renderer
+     *
+     * @param color
+     */
+    colorRenderer: function(color) {
+        // normalize
+        color = String(color).replace('#', '');
+
+        return '<div style="background-color: #' + Ext.util.Format.htmlEncode(color) + '">&#160;</div>';
+    },
+
+    /**
      * sorts account/user objects
      * 
      * @param {Object|String} user_id