converted functions to methods of Tinebase_Helper class
authorLars Kneschke <l.kneschke@metaways.de>
Mon, 13 Oct 2014 16:07:06 +0000 (18:07 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Wed, 15 Oct 2014 15:54:26 +0000 (17:54 +0200)
Change-Id: I0e51968be2d0a940c51d94764fa8b200e1b4ceb3
Reviewed-on: https://gerrit.tine20.org/tine20/2911
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
Tested-by: Philipp Schüle <p.schuele@metaways.de>
70 files changed:
tests/tine20/ActiveSync/Controller/CalendarTests.php
tests/tine20/Calendar/Controller/EventNotificationsTests.php
tests/tine20/Calendar/Controller/EventTests.php
tests/tine20/Calendar/Export/ICalTest.php
tests/tine20/Calendar/Frontend/WebDAV/ContainerTest.php
tests/tine20/Calendar/Frontend/WebDAV/EventTest.php
tests/tine20/Calendar/JsonTests.php
tests/tine20/Felamimail/Controller/AccountTest.php
tests/tine20/Filemanager/Frontend/JsonTests.php
tests/tine20/Tasks/Frontend/WebDAV/TaskTest.php
tests/tine20/Tinebase/ContainerTest.php
tests/tine20/Tinebase/ControllerTest.php
tests/tine20/Tinebase/Frontend/JsonTest.php
tests/tine20/Tinebase/HelperTests.php
tests/tine20/Tinebase/WebDav/Plugin/InverseTest.php
tine20/ActiveSync/Controller/Abstract.php
tine20/Addressbook/Import/VCard.php
tine20/Calendar/Backend/Sql.php
tine20/Calendar/Controller/Event.php
tine20/Calendar/Controller/EventNotifications.php
tine20/Calendar/Convert/Event/VCalendar/Abstract.php
tine20/Calendar/Frontend/WebDAV.php
tine20/Calendar/Import/CalDav/Client.php
tine20/Calendar/Model/Rrule.php
tine20/Crm/Controller.php
tine20/Felamimail/Backend/Imap.php
tine20/Felamimail/Controller/Message/Send.php
tine20/Felamimail/Model/Folder.php
tine20/Setup/Controller.php
tine20/Setup/Core.php
tine20/Setup/Frontend/Cli.php
tine20/SimpleFAQ/Controller.php
tine20/Sipgate/Controller.php
tine20/Timetracker/Model/TimeaccountGrants.php
tine20/Tinebase/Acl/Roles.php
tine20/Tinebase/Container.php
tine20/Tinebase/Controller/Abstract.php
tine20/Tinebase/Convert/VCalendar/Abstract.php
tine20/Tinebase/Core.php
tine20/Tinebase/CustomField.php
tine20/Tinebase/EmailUser/Imap/Cyrus.php
tine20/Tinebase/EmailUser/Imap/Dbmail.php
tine20/Tinebase/EmailUser/Ldap.php
tine20/Tinebase/Frontend/Cli.php
tine20/Tinebase/Frontend/Json.php
tine20/Tinebase/Frontend/Json/PersistentFilter.php
tine20/Tinebase/Group/ActiveDirectory.php
tine20/Tinebase/Group/Ldap.php
tine20/Tinebase/Group/Sql.php
tine20/Tinebase/Helper.php
tine20/Tinebase/Import/CalDav/Client.php
tine20/Tinebase/Ldap.php
tine20/Tinebase/Log/Formatter.php
tine20/Tinebase/Mail.php
tine20/Tinebase/Notes.php
tine20/Tinebase/Server/Abstract.php
tine20/Tinebase/Setup/Import/Egw14/Abstract.php
tine20/Tinebase/Setup/Update/Release0.php
tine20/Tinebase/TempFile.php
tine20/Tinebase/Timemachine/ModificationLog.php
tine20/Tinebase/Translation.php
tine20/Tinebase/User/Abstract.php
tine20/Tinebase/User/ActiveDirectory.php
tine20/Tinebase/WebDav/Collection/Abstract.php
tine20/Tinebase/WebDav/Collection/AbstractContainerTree.php
tine20/Tinebase/WebDav/PrincipalBackend.php
tine20/composer.json
tine20/index.php
tine20/langHelper.php
tine20/library/vcardphp/vcard.php

index 8e4b911..5263cc7 100644 (file)
@@ -799,7 +799,7 @@ Zeile 3</AirSyncBase:Data>
         list($serverId, $syncrotonEvent) = $this->testCreateEntry($syncrotonFolder);
         
         // transfer event to other user
-        $rwright = array_value('rwright', $this->_personas = Zend_Registry::get('personas'));
+        $rwright = Tinebase_Helper::array_value('rwright', $this->_personas = Zend_Registry::get('personas'));
         $eventBackend = new Calendar_Backend_Sql();
         $eventBackend->updateMultiple($eventBackend->getMultipleByProperty($syncrotonEvent->uID, 'uid')->id, array(
             'container_id'  => Tinebase_Core::getPreference('Calendar')->getValueForUser(Calendar_Preference::DEFAULTCALENDAR, $rwright->getId()),
@@ -991,7 +991,7 @@ Zeile 3</AirSyncBase:Data>
     
         $folderA = $this->testCreateFolder(); // personal of test user
         
-        $sclever = array_value('sclever', Zend_Registry::get('personas'));
+        $sclever = Tinebase_Helper::array_value('sclever', Zend_Registry::get('personas'));
         $folderB = Tinebase_Core::getPreference('Calendar')->getValueForUser(Calendar_Preference::DEFAULTCALENDAR, $sclever->getId());
 
         // have syncGerant for sclever
index 120c856..dbd0c49 100644 (file)
@@ -1146,7 +1146,7 @@ class Calendar_Controller_EventNotificationsTests extends Calendar_TestCase
                 $this->_getPersona(trim($personaName))->accountEmailAddress;
             
             foreach ($messages as $message) {
-                if (array_value(0, $message->getRecipients()) == $personaEmail) {
+                if (Tinebase_Helper::array_value(0, $message->getRecipients()) == $personaEmail) {
                     array_push($mailsForPersona, $message);
                 } else {
                     array_push($otherRecipients, $message->getRecipients());
index 163b385..40c32aa 100644 (file)
@@ -700,7 +700,7 @@ class Calendar_Controller_EventTests extends Calendar_TestCase
         
         // Test the same with update
         $group = Admin_Controller_Group::getInstance()->get($defaultAdminGroup->getId());
-        $group->members = array_merge(Admin_Controller_Group::getInstance()->getGroupMembers($defaultAdminGroup->getId()), array(array_value('pwulf', Zend_Registry::get('personas'))->getId()));
+        $group->members = array_merge(Admin_Controller_Group::getInstance()->getGroupMembers($defaultAdminGroup->getId()), array(Tinebase_Helper::array_value('pwulf', Zend_Registry::get('personas'))->getId()));
         Admin_Controller_Group::getInstance()->update($group);
         if (isset(Tinebase_Core::getConfig()->actionqueue)) {
             Tinebase_ActionQueue::getInstance()->processQueue(10000);
@@ -713,7 +713,7 @@ class Calendar_Controller_EventTests extends Calendar_TestCase
             ->filter('user_id', $this->_getPersonasContacts('pwulf')->getId());
         $this->assertEquals(1, count($pwulf), 'pwulf is not attender of event, but should be (via update)');
         
-        $group->members = array_diff(Admin_Controller_Group::getInstance()->getGroupMembers($defaultAdminGroup->getId()), array(array_value('pwulf', Zend_Registry::get('personas'))->getId()));
+        $group->members = array_diff(Admin_Controller_Group::getInstance()->getGroupMembers($defaultAdminGroup->getId()), array(Tinebase_Helper::array_value('pwulf', Zend_Registry::get('personas'))->getId()));
         Admin_Controller_Group::getInstance()->update($group);
         if (isset(Tinebase_Core::getConfig()->actionqueue)) {
             Tinebase_ActionQueue::getInstance()->processQueue(10000);
index ecb73ce..4d8786c 100644 (file)
@@ -129,7 +129,7 @@ class Calendar_Export_ICalTest extends Calendar_TestCase
      */
     public function testExportOrganizer()
     {
-        $this->_testEvent->organizer = array_value('pwulf', Zend_Registry::get('personas'))->contact_id;
+        $this->_testEvent->organizer = Tinebase_Helper::array_value('pwulf', Zend_Registry::get('personas'))->contact_id;
         
         $exporter = new Calendar_Export_Ical();
         $ics = $exporter->eventToIcal($this->_testEvent);
@@ -147,7 +147,7 @@ class Calendar_Export_ICalTest extends Calendar_TestCase
                 'role'          => Calendar_Model_Attender::ROLE_REQUIRED,
                 'status'        => Calendar_Model_Attender::STATUS_ACCEPTED,
                 'user_type'     => Calendar_Model_Attender::USERTYPE_USER,
-                'user_id'       => array_value('pwulf', Zend_Registry::get('personas'))->contact_id,
+                'user_id'       => Tinebase_Helper::array_value('pwulf', Zend_Registry::get('personas'))->contact_id,
             )
         ));
         
index bf8139a..a2bb09c 100644 (file)
@@ -369,7 +369,7 @@ class Calendar_Frontend_WebDAV_ContainerTest extends PHPUnit_Framework_TestCase
      */
     public function testGetSharesWithoutRights()
     {
-        $jmcblack = array_value('jmcblack', Zend_Registry::get('personas'));
+        $jmcblack = Tinebase_Helper::array_value('jmcblack', Zend_Registry::get('personas'));
         $jmcblacksCalId = Tinebase_Core::getPreference('Calendar')->getValueForUser(Calendar_Preference::DEFAULTCALENDAR, $jmcblack->getId());
         $jmcblacksCal = Tinebase_Container::getInstance()->get($jmcblacksCalId);
         
index 652f88f..72acd4a 100644 (file)
@@ -753,7 +753,7 @@ class Calendar_Frontend_WebDAV_EventTest extends Calendar_TestCase
         
         $pwulf = new Calendar_Model_Attender(array(
             'user_type'  => Calendar_Model_Attender::USERTYPE_USER,
-            'user_id'    => array_value('pwulf', Zend_Registry::get('personas'))->contact_id
+            'user_id'    => Tinebase_Helper::array_value('pwulf', Zend_Registry::get('personas'))->contact_id
         ));
         
         $pwulfAttendee = Calendar_Model_Attender::getAttendee($event->getRecord()->attendee, $pwulf);
@@ -862,8 +862,8 @@ class Calendar_Frontend_WebDAV_EventTest extends Calendar_TestCase
             array(
                 $unittestUserEmail,
                 $unittestUserEmail,
-                array_value('pwulf', Zend_Registry::get('personas'))->accountEmailAddress,
-                array_value('sclever', Zend_Registry::get('personas'))->accountEmailAddress,
+                Tinebase_Helper::array_value('pwulf', Zend_Registry::get('personas'))->accountEmailAddress,
+                Tinebase_Helper::array_value('sclever', Zend_Registry::get('personas'))->accountEmailAddress,
             ), 
             $vcalendar
         );
index 365e2a0..0a68dbb 100644 (file)
@@ -486,7 +486,7 @@ class Calendar_JsonTests extends Calendar_TestCase
      */
     public function testCreateRecurException()
     {
-        $recurSet = array_value('results', $this->testSearchRecuringIncludes());
+        $recurSet = Tinebase_Helper::array_value('results', $this->testSearchRecuringIncludes());
         
         $persistentException = $recurSet[1];
         $persistentException['summary'] = 'go sleeping';
@@ -536,7 +536,7 @@ class Calendar_JsonTests extends Calendar_TestCase
      */
     public function testCreateRecurExceptionWithOtherUser()
     {
-        $recurSet = array_value('results', $this->testSearchRecuringIncludes());
+        $recurSet = Tinebase_Helper::array_value('results', $this->testSearchRecuringIncludes());
         
         // create persistent exception (just status update)
         $persistentException = $recurSet[1];
@@ -590,7 +590,7 @@ class Calendar_JsonTests extends Calendar_TestCase
      */
     public function testUpdateRecurSeries()
     {
-        $recurSet = array_value('results', $this->testSearchRecuringIncludes());
+        $recurSet = Tinebase_Helper::array_value('results', $this->testSearchRecuringIncludes());
         
         $persistentException = $recurSet[1];
         $persistentException['summary'] = 'go sleeping';
@@ -668,7 +668,7 @@ class Calendar_JsonTests extends Calendar_TestCase
      */
     public function testDeleteRecurSeries()
     {
-        $recurSet = array_value('results', $this->testSearchRecuringIncludes());
+        $recurSet = Tinebase_Helper::array_value('results', $this->testSearchRecuringIncludes());
         
         $persistentException = $recurSet[1];
         $persistentException['summary'] = 'go sleeping';
@@ -1447,7 +1447,7 @@ class Calendar_JsonTests extends Calendar_TestCase
     public function testAddAttachmentToRecurSeries()
     {
         $tempFile = $this->_getTempFile();
-        $recurSet = array_value('results', $this->testSearchRecuringIncludes());
+        $recurSet = Tinebase_Helper::array_value('results', $this->testSearchRecuringIncludes());
         // update recurseries 
         $someRecurInstance = $recurSet[2];
         $someRecurInstance['attachments'] = array(array('tempFile' => array('id' => $tempFile->getId())));
index 8a39e68..cb9a59b 100644 (file)
@@ -147,7 +147,7 @@ class Felamimail_Controller_AccountTest extends PHPUnit_Framework_TestCase
             'no IMAP4(rev1) capability found in ' . print_r($capabilities['capabilities'], TRUE));
         $this->assertTrue(in_array('QUOTA', $capabilities['capabilities']), 'no QUOTA capability found in ' . print_r($capabilities['capabilities'], TRUE));
         
-        $this->assertEquals($capabilities, array_value($this->_account->getId(), Felamimail_Session::getSessionNamespace()->account));
+        $this->assertEquals($capabilities, Tinebase_Helper::array_value($this->_account->getId(), Felamimail_Session::getSessionNamespace()->account));
     }
 
     /**
index 7abf391..08db175 100644 (file)
@@ -1255,7 +1255,7 @@ class Filemanager_Frontend_JsonTests extends TestCase
     protected function _getOtherUserContainer()
     {
         if (!$this->_otherUserContainer) {
-            $sclever = array_value('sclever', Zend_Registry::get('personas'));
+            $sclever = Tinebase_Helper::array_value('sclever', Zend_Registry::get('personas'));
             
             $this->_otherUserContainer = Tinebase_Container::getInstance()->getDefaultContainer('Filemanager', $sclever->getId());
             Tinebase_Container::getInstance()->addGrants(
index 984e5f9..fc5bfbf 100644 (file)
@@ -310,7 +310,7 @@ class Tasks_Frontend_WebDAV_TaskTest extends Tasks_TestCase
                 $unittestUserEmail,
                 $unittestUserEmail,
                 $unittestUserEmail,
-                array_value('pwulf', Zend_Registry::get('personas'))->accountEmailAddress,
+                Tinebase_Helper::array_value('pwulf', Zend_Registry::get('personas'))->accountEmailAddress,
             ), 
             $vcalendar
         );
index 8ef0c7a..0bc1995 100644 (file)
@@ -660,7 +660,7 @@ class Tinebase_ContainerTest extends PHPUnit_Framework_TestCase
     public function testSetGrantsCacheInvalidation()
     {
         $container = $this->objects['initialContainer'];
-        $sclever = array_value('sclever', Zend_Registry::get('personas'));
+        $sclever = Tinebase_Helper::array_value('sclever', Zend_Registry::get('personas'));
         
         $this->assertEquals(FALSE, $this->_instance->hasGrant($sclever->getId(), $container->getId(), Tinebase_Model_Grants::GRANT_READ), 'sclever should _not_ have a read grant');
         
index 3824e5e..e211ece 100644 (file)
@@ -95,7 +95,7 @@ class Tinebase_ControllerTest extends PHPUnit_Framework_TestCase
         $cache = Tinebase_Core::getCache();
         $oldLifetime = $cache->getOption('lifetime');
         $cache->setLifetime(1);
-        $cacheId = convertCacheId('testCleanupCache');
+        $cacheId = Tinebase_Helper::convertCacheId('testCleanupCache');
         $cache->save('value', $cacheId);
         sleep(3);
         
index 3a01206..1e43cd8 100644 (file)
@@ -538,7 +538,7 @@ class Tinebase_Frontend_JsonTest extends TestCase
         // try to get user profile of different user
         $this->setExpectedException('Tinebase_Exception_AccessDenied');
         
-        $sclever = array_value('sclever',Zend_Registry::get('personas'));
+        $sclever = Tinebase_Helper::array_value('sclever',Zend_Registry::get('personas'));
         $this->_instance->getUserProfile($sclever->getId());
     }
     
index 2e8a096..b02a233 100644 (file)
@@ -57,21 +57,21 @@ class Tinebase_HelperTests extends PHPUnit_Framework_TestCase
             'one' => 'bar'
         );
         
-        $this->assertEquals('foo', array_value(0, $array));
-        $this->assertEquals('bar', array_value('one', $array));
+        $this->assertEquals('foo', Tinebase_Helper::array_value(0, $array));
+        $this->assertEquals('bar', Tinebase_Helper::array_value('one', $array));
     }
     
     public function testGetDevelopmentRevision()
     {
-        $rev = getDevelopmentRevision();
+        $rev = Tinebase_Helper::getDevelopmentRevision();
         $this->assertFalse(empty($rev));
     }
     
     public function testConvertToBytes()
     {
-        $this->assertEquals(1024, convertToBytes('1024'));
-        $this->assertEquals(1024, convertToBytes('1K'));
-        $this->assertEquals(1024*1024, convertToBytes('1M'));
+        $this->assertEquals(1024, Tinebase_Helper::convertToBytes('1024'));
+        $this->assertEquals(1024, Tinebase_Helper::convertToBytes('1K'));
+        $this->assertEquals(1024*1024, Tinebase_Helper::convertToBytes('1M'));
         
     }
 
@@ -89,7 +89,7 @@ class Tinebase_HelperTests extends PHPUnit_Framework_TestCase
             'OTHER' => '4',
         );
         
-        $remoteUserValues = searchArrayByRegexpKey('/REMOTE_USER$/', $server);
+        $remoteUserValues = Tinebase_Helper::searchArrayByRegexpKey('/REMOTE_USER$/', $server);
         
         $this->assertTrue(! empty($remoteUserValues));
         $this->assertEquals(3, count($remoteUserValues));
index b5cea34..b645dd7 100644 (file)
@@ -146,7 +146,7 @@ class Tinebase_WebDav_Plugin_InverseTest extends TestCase
     {
         $body = '<?xml version="1.0" encoding="utf-8"?>
                  <acl-query xmlns="urn:inverse:params:xml:ns:inverse-dav">
-                     <add-user user="' . array_value('pwulf', Zend_Registry::get('personas'))->contact_id . '"/>
+                     <add-user user="' . Tinebase_Helper::array_value('pwulf', Zend_Registry::get('personas'))->contact_id . '"/>
                  </acl-query>';
         
         $request = new Sabre\HTTP\Request(array(
@@ -162,7 +162,7 @@ class Tinebase_WebDav_Plugin_InverseTest extends TestCase
         $this->assertEquals('HTTP/1.1 201 Created', $this->response->status);
         
         $grants = Tinebase_Container::getInstance()->getGrantsOfContainer($this->objects['initialContainer']->id);
-        $this->assertContains(array_value('pwulf', Zend_Registry::get('personas'))->accountId, $grants->account_id);
+        $this->assertContains(Tinebase_Helper::array_value('pwulf', Zend_Registry::get('personas'))->accountId, $grants->account_id);
     }
     
     /**
@@ -175,7 +175,7 @@ class Tinebase_WebDav_Plugin_InverseTest extends TestCase
         
         $body = '<?xml version="1.0" encoding="utf-8"?>
                  <acl-query xmlns="urn:inverse:params:xml:ns:inverse-dav">
-                     <remove-user user="' . array_value('pwulf', Zend_Registry::get('personas'))->contact_id . '"/>
+                     <remove-user user="' . Tinebase_Helper::array_value('pwulf', Zend_Registry::get('personas'))->contact_id . '"/>
                  </acl-query>';
         
         $request = new Sabre\HTTP\Request(array(
@@ -191,7 +191,7 @@ class Tinebase_WebDav_Plugin_InverseTest extends TestCase
         $this->assertEquals('HTTP/1.1 201 Created', $this->response->status);
         
         $grants = Tinebase_Container::getInstance()->getGrantsOfContainer($this->objects['initialContainer']->id);
-        $this->assertNotContains(array_value('pwulf', Zend_Registry::get('personas'))->accountId, $grants->account_id);
+        $this->assertNotContains(Tinebase_Helper::array_value('pwulf', Zend_Registry::get('personas'))->accountId, $grants->account_id);
     }
     
     /**
@@ -204,7 +204,7 @@ class Tinebase_WebDav_Plugin_InverseTest extends TestCase
         
         $body = '<?xml version="1.0" encoding="utf-8"?>
                  <acl-query xmlns="urn:inverse:params:xml:ns:inverse-dav">
-                     <set-roles user="' . array_value('pwulf', Zend_Registry::get('personas'))->contact_id . '">
+                     <set-roles user="' . Tinebase_Helper::array_value('pwulf', Zend_Registry::get('personas'))->contact_id . '">
                          <ObjectEraser/>
                      </set-roles>
                  </acl-query>';
@@ -223,7 +223,7 @@ class Tinebase_WebDav_Plugin_InverseTest extends TestCase
         
         $grantsOfPwulf = Tinebase_Container::getInstance()
             ->getGrantsOfContainer($this->objects['initialContainer']->id)
-            ->filter('account_id', array_value('pwulf', Zend_Registry::get('personas'))->accountId)
+            ->filter('account_id', Tinebase_Helper::array_value('pwulf', Zend_Registry::get('personas'))->accountId)
             ->getFirstRecord();
         $this->assertTrue($grantsOfPwulf->deleteGrant);
         $this->assertFalse($grantsOfPwulf->addGrant);
index 5c0b1c5..3e4f35e 100644 (file)
@@ -724,7 +724,7 @@ abstract class ActiveSync_Controller_Abstract implements Syncroton_Data_IData
         }
         
         // calculate with an overhead of 1.2
-        if (convertToBytes(ini_get('memory_limit')) > memory_get_usage(TRUE) + ($needed * 1.2)) {
+        if (Tinebase_Helper::convertToBytes(ini_get('memory_limit')) > memory_get_usage(TRUE) + ($needed * 1.2)) {
             return true;
         }
         
index f09a9f5..37cdf2f 100644 (file)
@@ -184,7 +184,7 @@ class Addressbook_Import_VCard extends Tinebase_Import_Abstract
                     . ' Address components ' . print_r($components, TRUE));
                 
                 $mapping = array(NULL, 'street2', 'street', 'locality', 'region', 'postalcode', 'countryname');
-                $adrType = ($types && in_array_case($types, 'home')) ? 'two' : 'one';
+                $adrType = ($types && Tinebase_Helper::in_array_case($types, 'home')) ? 'two' : 'one';
                 foreach ($components as $index => $value) {
                     if (! isset($mapping[$index]) || $mapping[$index] === NULL) {
                         continue;
@@ -204,25 +204,25 @@ class Addressbook_Import_VCard extends Tinebase_Import_Abstract
                 
                 $key = 'tel_work';
                 if($types){
-                    if(in_array_case($types, 'home') && !in_array_case($types, 'cell') && !in_array_case($types, 'fax')){
+                    if(Tinebase_Helper::in_array_case($types, 'home') && !Tinebase_Helper::in_array_case($types, 'cell') && !Tinebase_Helper::in_array_case($types, 'fax')){
                         $key = 'tel_home';    
-                    }else if(in_array_case($types, 'home') && in_array_case($types, 'cell')){
+                    }else if(Tinebase_Helper::in_array_case($types, 'home') && Tinebase_Helper::in_array_case($types, 'cell')){
                         $key = 'tel_cell_private';
-                    }else if(in_array_case($types, 'home') && in_array_case($types, 'fax')){
+                    }else if(Tinebase_Helper::in_array_case($types, 'home') && Tinebase_Helper::in_array_case($types, 'fax')){
                         $key = 'tel_fax_home';
-                    }else if(in_array_case($types, 'work') && !in_array_case($types, 'cell') && !in_array_case($types, 'fax')){
+                    }else if(Tinebase_Helper::in_array_case($types, 'work') && !Tinebase_Helper::in_array_case($types, 'cell') && !Tinebase_Helper::in_array_case($types, 'fax')){
                         $key = 'tel_work';
-                    }else if(in_array_case($types, 'work') && in_array_case($types, 'cell')){
+                    }else if(Tinebase_Helper::in_array_case($types, 'work') && Tinebase_Helper::in_array_case($types, 'cell')){
                         $key = 'tel_cell';
-                    }else if(in_array_case($types, 'work') && !in_array_case($types, 'fax')){
+                    }else if(Tinebase_Helper::in_array_case($types, 'work') && !Tinebase_Helper::in_array_case($types, 'fax')){
                         $key = 'tel_fax';
-                    }else if(in_array_case($types, 'car')){
+                    }else if(Tinebase_Helper::in_array_case($types, 'car')){
                         $key = 'tel_car';
-                    }else if(in_array_case($types, 'pager')){
+                    }else if(Tinebase_Helper::in_array_case($types, 'pager')){
                         $key = 'tel_pager';
-                    }else if(in_array_case($types, 'fax')){
+                    }else if(Tinebase_Helper::in_array_case($types, 'fax')){
                         $key = 'tel_fax';
-                    }else if(in_array_case($types, 'cell')){
+                    }else if(Tinebase_Helper::in_array_case($types, 'cell')){
                         $key = 'tel_cell';
                     }
                 }
@@ -241,7 +241,7 @@ class Addressbook_Import_VCard extends Tinebase_Import_Abstract
                 
                 $key = 'email';
                 if($types){
-                    if(in_array_case($types, 'home')){
+                    if(Tinebase_Helper::in_array_case($types, 'home')){
                         $key = 'email_home';    
                     }
                 }
index 9498e66..29c57af 100644 (file)
@@ -470,7 +470,7 @@ class Calendar_Backend_Sql extends Tinebase_Backend_Sql_Abstract
             
             $whereArray = $attendeeSelect->getPart(Zend_Db_Select::SQL_WHERE);
             if (! empty($whereArray)) {
-                $attendeeWhere = ' AND ' . array_value(0, $whereArray);
+                $attendeeWhere = ' AND ' . Tinebase_Helper::array_value(0, $whereArray);
             }
         }
         
index 2be1fb9..5b39130 100644 (file)
@@ -1190,7 +1190,7 @@ class Calendar_Controller_Event extends Tinebase_Controller_Record_Abstract impl
             if (Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__ .
                 ' Got multiple possible base events: ' . print_r($possibleBaseEventIds, true));
         }
-        $baseEventId = array_value(0, $possibleBaseEventIds);
+        $baseEventId = Tinebase_Helper::array_value(0, $possibleBaseEventIds);
         
         if (! $baseEventId) {
             throw new Tinebase_Exception_NotFound('base event of a recurring series not found');
index e9c0e2d..35e88cc 100644 (file)
                 
             } else {
                 if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__
-                    . " Not adding attachment " . $attachment->name . ' to invitation mail (size: ' . convertToMegabytes($attachment-size) . ')');
+                    . " Not adding attachment " . $attachment->name . ' to invitation mail (size: ' . Tinebase_Helper::convertToMegabytes($attachment-size) . ')');
             }
         }
         
index 1a6dcc8..7799a1e 100644 (file)
@@ -955,7 +955,7 @@ class Calendar_Convert_Event_VCalendar_Abstract extends Tinebase_Convert_VCalend
                             $userCredentialCache = Tinebase_Core::get(Tinebase_Core::USERCREDENTIALCACHE);
                             $url = $matches[1] . $userCredentialCache->username . ':' . $userCredentialCache->password . '@' . $matches[2];
                             $attachmentInfo = $matches[1] . $matches[2]. ' ' . $name . ' ' . $managedId;
-                            if (urlExists($url)) {
+                            if (Tinebase_Helper::urlExists($url)) {
                                 if (Tinebase_Core::isLogLevel(Zend_Log::INFO))
                                     Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__
                                             . ' Downloading attachment: ' . $attachmentInfo);
index 2aae0b8..d40ed0e 100644 (file)
@@ -78,7 +78,7 @@ class Calendar_Frontend_WebDAV extends Tinebase_WebDav_Collection_AbstractContai
         
         // do this only for caldav request 
         if ($this->_useIdAsName && count($this->_getPathParts()) == 2) {
-            $tfwdavct = new Tasks_Frontend_WebDAV('tasks/' . array_value(1, $this->_getPathParts()), $this->_useIdAsName);
+            $tfwdavct = new Tasks_Frontend_WebDAV('tasks/' . Tinebase_Helper::array_value(1, $this->_getPathParts()), $this->_useIdAsName);
             
             $children = array_merge($children, $tfwdavct->getChildren());
         }
index a6d7603..e8d780b 100644 (file)
@@ -717,7 +717,7 @@ class Calendar_Import_CalDav_Client extends Tinebase_Import_CalDav_Client
      */
     protected function _getGroupForPrincipal($principal)
     {
-        $cacheId = convertCacheId('_getGroupForPrincipal' . $principal);
+        $cacheId = Tinebase_Helper::convertCacheId('_getGroupForPrincipal' . $principal);
         if (Tinebase_Core::getCache()->test($cacheId)) {
             $group = Tinebase_Core::getCache()->load($cacheId);
             if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) Tinebase_Core::getLogger()->info(__METHOD__ . ' ' . __LINE__
index 000681a..1c8c5b1 100644 (file)
@@ -1208,6 +1208,6 @@ class Calendar_Model_Rrule extends Tinebase_Record_Abstract
         $locale = $locale ?: Tinebase_Core::getLocale();
         
         $weekInfo = Zend_Locale::getTranslationList('week', $locale);
-        return array_value($weekInfo['firstDay'], array_flip(self::$WEEKDAY_MAP));
+        return Tinebase_Helper::array_value($weekInfo['firstDay'], array_flip(self::$WEEKDAY_MAP));
     }
 }
index d718ae9..83bcdaa 100644 (file)
@@ -143,7 +143,7 @@ class Crm_Controller extends Tinebase_Controller_Event implements Tinebase_Conta
     public function getConfigSettings($_resolve = FALSE)
     {
         $cache = Tinebase_Core::get('cache');
-        $cacheId = convertCacheId('getCrmSettings');
+        $cacheId = Tinebase_Helper::convertCacheId('getCrmSettings');
         $result = $cache->load($cacheId);
         
         if (! $result) {
index 62a385a..25b60d1 100644 (file)
@@ -1050,7 +1050,7 @@ class Felamimail_Backend_Imap extends Zend_Mail_Storage_Imap
                         . ' ' . print_r($matches, TRUE));
                     
                     $headerValue = str_replace("\n", '', $matches[1]);
-                    $headerValue = mbConvertTo($headerValue);
+                    $headerValue = Tinebase_Helper::mbConvertTo($headerValue);
                     $headerString = iconv_mime_encode(ucfirst($field), $headerValue);
                     
                     $result = str_replace($matches[0], $headerString . "\n", $result);
index c3b1662..c5fc31e 100644 (file)
@@ -620,7 +620,7 @@ class Felamimail_Controller_Message_Send extends Felamimail_Controller_Message
             
             if ($size > $maxAttachmentSize) {
                 if (Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__
-                    . ' Current attachment size: ' . convertToMegabytes($size) . ' MB / allowed size: ' . convertToMegabytes($maxAttachmentSize) . ' MB');
+                    . ' Current attachment size: ' . Tinebase_Helper::convertToMegabytes($size) . ' MB / allowed size: ' . Tinebase_Helper::convertToMegabytes($maxAttachmentSize) . ' MB');
                 throw new Felamimail_Exception_IMAP('Maximum attachment size exceeded. Please remove one or more attachments.');
             }
             
@@ -651,6 +651,6 @@ class Felamimail_Controller_Message_Send extends Felamimail_Controller_Message
             $configuredMemoryLimit = '512M';
         }
         
-        return convertToBytes($configuredMemoryLimit) / 10;
+        return Tinebase_Helper::convertToBytes($configuredMemoryLimit) / 10;
     }
 }
index cb2aa1d..b5a700c 100644 (file)
@@ -185,7 +185,7 @@ class Felamimail_Model_Folder extends Tinebase_Record_Abstract
             $result = imap_utf7_encode(iconv('utf-8', 'ISO-8859-1', $_folderName));
         } else {
             // fallback
-            $result = replaceSpecialChars($_folderName);
+            $result = Tinebase_Helper::replaceSpecialChars($_folderName);
         }
                 
         return $result;
@@ -205,7 +205,7 @@ class Felamimail_Model_Folder extends Tinebase_Record_Abstract
             $result = iconv('ISO-8859-1', 'utf-8', imap_utf7_decode($_folderName));
         } else {
             // fallback
-            $result = replaceSpecialChars($_folderName);
+            $result = Tinebase_Helper::replaceSpecialChars($_folderName);
         }
         
         return $result;
index 72860ec..f35e4f7 100644 (file)
@@ -715,8 +715,8 @@ class Setup_Controller
             $oldValue = ini_get($variable);
             
             if ($variable == 'memory_limit') {
-                $required = convertToBytes($newValue);
-                $set = convertToBytes($oldValue);
+                $required = Tinebase_Helper::convertToBytes($newValue);
+                $set = Tinebase_Helper::convertToBytes($oldValue);
                 
                 if ( $set < $required) {
                     $result[] = array(
index e6d541a..76d3e36 100644 (file)
@@ -287,7 +287,7 @@ class Setup_Core extends Tinebase_Core
     {\r
         $config = self::getConfig();
         define('TINE20_BUILDTYPE',           strtoupper($config->get('buildtype', 'DEVELOPMENT')));
-        define('TINE20SETUP_CODENAME',       getDevelopmentRevision());
+        define('TINE20SETUP_CODENAME',       Tinebase_Helper::getDevelopmentRevision());
         define('TINE20SETUP_PACKAGESTRING', 'none');
         define('TINE20SETUP_RELEASETIME',   'none');
     }\r
index dd98feb..33691bf 100644 (file)
@@ -393,7 +393,7 @@ class Setup_Frontend_Cli
             $errors[] = 'Missing argument: configvalue';
         }
         $configKey = (string)$options['configkey'];
-        $configValue = (is_json($options['configvalue'])) ? Zend_Json::decode($options['configvalue']) : self::parseConfigValue($options['configvalue']);
+        $configValue = (Tinebase_Helper::is_json($options['configvalue'])) ? Zend_Json::decode($options['configvalue']) : self::parseConfigValue($options['configvalue']);
         $applicationName = (isset($options['app'])) ? $options['app'] : 'Tinebase';
         
         if (empty($errors)) {
index 2bf4edc..b45d9e6 100644 (file)
@@ -149,7 +149,7 @@ Class SimpleFAQ_Controller extends Tinebase_Controller_Event implements Tinebase
     {
         
         $cache = Tinebase_Core::get('cache');
-        $cacheId = convertCacheId('getSimpleFAQSettings');
+        $cacheId = Tinebase_Helper::convertCacheId('getSimpleFAQSettings');
         $result = $cache->load($cacheId);
         
         if (! $result) {
index b6d780f..717d4a7 100644 (file)
 //     {
 //         //        return array('success' => 1);
 //         //        $cache = Tinebase_Core::get('cache');
-//         //        $cacheId = convertCacheId('getSipgateSettings');
+//         //        $cacheId = Tinebase_Helper::convertCacheId('getSipgateSettings');
 //         //        $result = $cache->load($cacheId);
 //         //        if (! $result) {
 //         $settings = Tinebase_Config::getInstance()->getConfigAsArray('account_settings','Sipgate');
index 0621a5b..c8ee0ed 100644 (file)
@@ -133,7 +133,7 @@ class Timetracker_Model_TimeaccountGrants extends Tinebase_Model_Grants
         $timeaccount = ($_timeaccountId instanceof Timetracker_Model_Timeaccount) ? $_timeaccountId : Timetracker_Controller_Timeaccount::getInstance()->get($_timeaccountId);
         $container = Tinebase_Container::getInstance()->getContainerById($timeaccount->container_id);
         $cache = Tinebase_Core::getCache();
-        $cacheId = convertCacheId('getGrantsOfAccount' . Tinebase_Model_User::convertUserIdToInt($_accountId) . $timeaccount->getId() . $_ignoreAcl . $container->last_modified_time);
+        $cacheId = Tinebase_Helper::convertCacheId('getGrantsOfAccount' . Tinebase_Model_User::convertUserIdToInt($_accountId) . $timeaccount->getId() . $_ignoreAcl . $container->last_modified_time);
         $result = $cache->load($cacheId);
         
         if ($result === FALSE) {
@@ -203,7 +203,7 @@ class Timetracker_Model_TimeaccountGrants extends Tinebase_Model_Grants
         
         $container = Tinebase_Container::getInstance()->getContainerById($_timeaccount->container_id);
         $cache = Tinebase_Core::getCache();
-        $cacheId = convertCacheId('getTimeaccountGrants' . Tinebase_Core::getUser()->getId() . $_timeaccount->getId() . $_ignoreACL . $container->last_modified_time);
+        $cacheId = Tinebase_Helper::convertCacheId('getTimeaccountGrants' . Tinebase_Core::getUser()->getId() . $_timeaccount->getId() . $_ignoreACL . $container->last_modified_time);
         $result = $cache->load($cacheId);
         
         if ($result === FALSE) {
index d7c33cd..ca149ed 100644 (file)
@@ -750,7 +750,7 @@ class Tinebase_Acl_Roles
         
         foreach ($rightsInvalidateCache as $rightData) {
             foreach ($userIds as $userId) {
-                $cacheId = convertCacheId('checkRight' . $userId . $rightData);
+                $cacheId = Tinebase_Helper::convertCacheId('checkRight' . $userId . $rightData);
                 
                 if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) 
                     Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' Removing cache id ' . $cacheId);
index 6c5fe63..103cf28 100644 (file)
@@ -1082,7 +1082,7 @@ class Tinebase_Container extends Tinebase_Backend_Sql_Abstract
         $container = ($_containerId instanceof Tinebase_Model_Container) ? $_containerId : $this->getContainerById($_containerId);
         
         $cache = Tinebase_Core::getCache();
-        $cacheId = convertCacheId('hasGrant' . $accountId . $containerId . $container->seq . implode('', (array)$_grant));
+        $cacheId = Tinebase_Helper::convertCacheId('hasGrant' . $accountId . $containerId . $container->seq . implode('', (array)$_grant));
         $result = $cache->load($cacheId);
         
         if ($result === FALSE) {
@@ -1183,7 +1183,7 @@ class Tinebase_Container extends Tinebase_Backend_Sql_Abstract
         $containerId        = Tinebase_Model_Container::convertContainerIdToInt($_containerId);
         $container          = ($_containerId instanceof Tinebase_Model_Container) ? $_containerId : $this->getContainerById($_containerId);
         
-        $cacheKey = convertCacheId('getGrantsOfAccount' . $containerId . $accountId . $container->seq);
+        $cacheKey = Tinebase_Helper::convertCacheId('getGrantsOfAccount' . $containerId . $accountId . $container->seq);
         $cache = Tinebase_Core::getCache();
         $grants = $cache->load($cacheKey);
         if ($grants === FALSE) {
index c7a27d2..c5732bc 100755 (executable)
@@ -77,7 +77,7 @@ abstract class Tinebase_Controller_Abstract extends Tinebase_Pluggable_Abstract
         $right = strtoupper($_right);
         
         $cache = Tinebase_Core::getCache();
-        $cacheId = convertCacheId('checkRight' . Tinebase_Core::getUser()->getId() . $right . $this->_applicationName);
+        $cacheId = Tinebase_Helper::convertCacheId('checkRight' . Tinebase_Core::getUser()->getId() . $right . $this->_applicationName);
         $result = $cache->load($cacheId);
         
         if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . $cacheId);
index 3be8d45..ead260d 100644 (file)
@@ -83,7 +83,7 @@ abstract class Tinebase_Convert_VCalendar_Abstract
     public static function readVCalBlob($blob, $failcount = 0, $spacecount = 0, $lastBrokenLineNumber = 0, $lastLines = array())
     {
         // convert to utf-8
-        $blob = mbConvertTo($blob);
+        $blob = Tinebase_Helper::mbConvertTo($blob);
     
         if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ .
                 ' ' . $blob);
index 631938c..d6d3fef 100644 (file)
  */
 
 /**
- * php helpers
- */
-require_once 'Helper.php';
-
-/**
  * dispatcher and initialisation class (functions are static)
  * - dispatchRequest() function
  * - initXYZ() functions
@@ -490,7 +485,7 @@ class Tinebase_Core
     {
         $config = self::getConfig();
         define('TINE20_BUILDTYPE',     strtoupper($config->get('buildtype', 'DEVELOPMENT')));
-        define('TINE20_CODENAME',      getDevelopmentRevision());
+        define('TINE20_CODENAME',      Tinebase_Helper::getDevelopmentRevision());
         define('TINE20_PACKAGESTRING', 'none');
         define('TINE20_RELEASETIME',   'none');
     }
@@ -1516,7 +1511,7 @@ class Tinebase_Core
     {
         $db = self::getDb();
         if ($db && $db instanceof Zend_Db_Adapter_Pdo_Mysql) {
-            $string = mbConvertTo($string);
+            $string = Tinebase_Helper::mbConvertTo($string);
             
             // remove 4 byte utf8
             $result = preg_replace('/[\xF0-\xF7].../s', '?', $string);
index 4c5c29e..915eb84 100644 (file)
@@ -177,7 +177,7 @@ class Tinebase_CustomField implements Tinebase_Controller_SearchInterface
         } 
         
         $cache = Tinebase_Core::getCache();
-        $cacheId = convertCacheId('getCustomFieldsForApplication' . $cfIndex);
+        $cacheId = Tinebase_Helper::convertCacheId('getCustomFieldsForApplication' . $cfIndex);
         $result = $cache->load($cacheId);
         
         if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__
index 1b4d9a8..57f4df1 100644 (file)
@@ -200,7 +200,7 @@ class Tinebase_EmailUser_Imap_Cyrus extends Tinebase_User_Plugin_Abstract
         $mailboxString = ($_mailboxString !== NULL) ? $_mailboxString : $this->_getUserMailbox($_user->accountLoginName);
         
         if (isset($_user->imapUser)) {
-            $limit = ($_user->imapUser->emailMailQuota) > 0 ? convertToBytes($_user->imapUser->emailMailQuota . 'M') / 1024 : null;
+            $limit = ($_user->imapUser->emailMailQuota) > 0 ? Tinebase_Helper::convertToBytes($_user->imapUser->emailMailQuota . 'M') / 1024 : null;
             
             if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ 
                 . " Setting quota of user " . $_user->getId() . " to " . $limit);
index c03c5d5..2d85934 100644 (file)
@@ -404,7 +404,7 @@ class Tinebase_EmailUser_Imap_Dbmail extends Tinebase_User_Plugin_Abstract
                     case 'emailMailSize':
                     case 'emailSieveQuota':
                     case 'emailSieveSize':
-                        $data[$keyMapping] = convertToMegabytes($value);
+                        $data[$keyMapping] = Tinebase_Helper::convertToMegabytes($value);
                         break;
                         
                     default: 
@@ -448,7 +448,7 @@ class Tinebase_EmailUser_Imap_Dbmail extends Tinebase_User_Plugin_Abstract
                     case 'emailSieveQuota':
                     case 'emailSieveSize':
                         // convert to bytes
-                        $rawData[$property] = convertToBytes($value . 'M');
+                        $rawData[$property] = Tinebase_Helper::convertToBytes($value . 'M');
                         break;
                         
                     default:
index 075f340..b7031eb 100644 (file)
@@ -105,7 +105,7 @@ class Tinebase_EmailUser_Ldap extends Tinebase_User_Plugin_LdapAbstract
                 switch($keyMapping) {
                     case 'emailMailQuota':
                         // convert to megabytes
-                        $accountArray[$keyMapping] = convertToMegabytes($value[0]);
+                        $accountArray[$keyMapping] = Tinebase_Helper::convertToMegabytes($value[0]);
                         break;
                         
                     case 'emailAliases':
@@ -162,7 +162,7 @@ class Tinebase_EmailUser_Ldap extends Tinebase_User_Plugin_LdapAbstract
             switch($objectProperty) {
                 case 'emailMailQuota':
                     // convert to bytes
-                    $_ldapData[$ldapAttribute] = !empty($mailSettings->{$objectProperty}) ? convertToBytes($mailSettings->{$objectProperty} . 'M') : array();
+                    $_ldapData[$ldapAttribute] = !empty($mailSettings->{$objectProperty}) ? Tinebase_Helper::convertToBytes($mailSettings->{$objectProperty} . 'M') : array();
                     break;
                     
                 case 'emailUID':
index f8e4617..b2c5bb5 100644 (file)
@@ -598,7 +598,7 @@ class Tinebase_Frontend_Cli extends Tinebase_Frontend_Cli_Abstract
                 echo 'DemoData in application "' . $appName . '" found!' . PHP_EOL;
                 $required = $className::getRequiredApplications();
                 foreach($required as $requiredApplication) {
-                    if (! in_array_case($applications, $requiredApplication)) {
+                    if (! Tinebase_Helper::in_array_case($applications, $requiredApplication)) {
                         echo 'Creating DemoData for Application ' . $appName . ' is impossible, because application "' . $requiredApplication . '" is not installed.' . PHP_EOL;
                         continue 2;
                     }
index d5afe07..4e8e97e 100644 (file)
@@ -717,8 +717,8 @@ class Tinebase_Frontend_Json extends Tinebase_Frontend_Json_Abstract
             'titlePostfix'      => Tinebase_Config::getInstance()->get(Tinebase_Model_Config::PAGETITLEPOSTFIX),
             'redirectUrl'       => Tinebase_Config::getInstance()->get(Tinebase_Model_Config::REDIRECTURL),
             'helpUrl'           => Tinebase_Core::getConfig()->helpUrl,
-            'maxFileUploadSize' => convertToBytes(ini_get('upload_max_filesize')),
-            'maxPostSize'       => convertToBytes(ini_get('post_max_size')),
+            'maxFileUploadSize' => Tinebase_Helper::convertToBytes(ini_get('upload_max_filesize')),
+            'maxPostSize'       => Tinebase_Helper::convertToBytes(ini_get('post_max_size')),
             'thousandSeparator' => $symbols['group'],
             'decimalSeparator'  => $symbols['decimal'],
             'filesystemAvailable' => Setup_Controller::getInstance()->isFilesystemAvailable(),
index 86d9eb9..40730d0 100644 (file)
@@ -96,7 +96,7 @@ class Tinebase_Frontend_Json_PersistentFilter extends Tinebase_Frontend_Json_Abs
     {
         $recordSet = new Tinebase_Record_RecordSet('Tinebase_Model_PersistentFilter', array($_record));
         
-        return array_value(0, $this->_multipleRecordsToJson($recordSet));
+        return Tinebase_Helper::array_value(0, $this->_multipleRecordsToJson($recordSet));
     }
     
     /**
index 62b2f53..1065fbe 100644 (file)
@@ -155,7 +155,7 @@ class Tinebase_Group_ActiveDirectory extends Tinebase_Group_Ldap
             $ldapData['objectclass'][] = 'posixGroup';
             $ldapData['gidnumber']     = $this->_generateGidNumber();
             
-            $ldapData['msSFU30NisDomain'] = array_value(0, explode('.', $this->_domainName));
+            $ldapData['msSFU30NisDomain'] = Tinebase_Helper::array_value(0, explode('.', $this->_domainName));
         }
         
         if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) 
index c8dc5cf..b984443 100644 (file)
@@ -829,7 +829,7 @@ class Tinebase_Group_Ldap extends Tinebase_Group_Sql implements Tinebase_Group_I
      */
     protected function _getAccountMetaData($_accountId)
     {
-        return array_value(0, $this->_getAccountsMetaData(array($_accountId)));
+        return Tinebase_Helper::array_value(0, $this->_getAccountsMetaData(array($_accountId)));
     }
     
     /**
index 3d24ae4..02ffdfa 100644 (file)
@@ -83,7 +83,7 @@ class Tinebase_Group_Sql extends Tinebase_Group_Abstract
     {
         $accountId = Tinebase_Model_User::convertUserIdToInt($_accountId);
         
-        $cacheId = convertCacheId('groupMemberships' . $accountId);
+        $cacheId = Tinebase_Helper::convertCacheId('groupMemberships' . $accountId);
         $memberships = Tinebase_Core::getCache()->load($cacheId);
 
         if (! $memberships) {
@@ -114,7 +114,7 @@ class Tinebase_Group_Sql extends Tinebase_Group_Abstract
     {
         $groupId = Tinebase_Model_Group::convertGroupIdToInt($_groupId);
         
-        $cacheId = convertCacheId('groupMembers' . $groupId);
+        $cacheId = Tinebase_Helper::convertCacheId('groupMembers' . $groupId);
         $members = Tinebase_Core::getCache()->load($cacheId);
 
         if (! $members) {
@@ -199,7 +199,7 @@ class Tinebase_Group_Sql extends Tinebase_Group_Abstract
     protected function _clearCache($cacheIds = array())
     {
         foreach ($cacheIds as $type => $id) {
-            $cacheId = convertCacheId($type . $id);
+            $cacheId = Tinebase_Helper::convertCacheId($type . $id);
             Tinebase_Core::getCache()->remove($cacheId);
         }
     }
index c43d998..6544224 100644 (file)
  * Tine 2.0
  * 
  * @package     Tinebase
- * @subpackage  Server
  * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
- * @copyright   Copyright (c) 2007-2010 Metaways Infosystems GmbH (http://www.metaways.de)
+ * @copyright   Copyright (c) 2007-2014 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Cornelius Weiss <c.weiss@metaways.de>
  */
 
-
 /**
- * returns one value of an array, indentified by its key
+ * Helper class
  *
- * @param mixed $_key
- * @param array $_array
- * @return mixed
- */
-function array_value($_key, array $_array)
-{
-    return (isset($_array[$_key]) || array_key_exists($_key, $_array)) ? $_array[$_key] : NULL;
-}
-
-/**
- * converts string with M or K to bytes integer
- * - for example: 50M -> 52428800
- *
- * @param mixed $_value
- * @return integer
+ * @package     Tinebase
  */
-function convertToBytes($_value)
+class Tinebase_Helper
 {
-    if (is_int($_value) || ! $_value) {
-        $bytes = $_value;
-    } else {
-        if (preg_match("/M/", $_value)) {
-            $value = substr($_value, 0, strpos($_value, 'M'));
-            $factor = 1024 * 1024;
-        } elseif (preg_match("/K/", $_value)) {
-            $value = substr($_value, 0, strpos($_value, 'K'));
-            $factor = 1024;
-        } elseif (is_string($_value)) {
-            $value = $_value;
-            $factor = 1;
+    /**
+     * returns one value of an array, indentified by its key
+     *
+     * @param mixed $_key
+     * @param array $_array
+     * @return mixed
+     */
+    public static function array_value($_key, array $_array)
+    {
+        return (isset($_array[$_key]) || array_key_exists($_key, $_array)) ? $_array[$_key] : NULL;
+    }
+    
+    /**
+     * converts string with M or K to bytes integer
+     * - for example: 50M -> 52428800
+     *
+     * @param mixed $_value
+     * @return integer
+     */
+    public static function convertToBytes($_value)
+    {
+        if (is_int($_value) || ! $_value) {
+            $bytes = $_value;
         } else {
-            throw new Exception('Argument type not supported:' . gettype($_value));
+            if (preg_match("/M/", $_value)) {
+                $value = substr($_value, 0, strpos($_value, 'M'));
+                $factor = 1024 * 1024;
+            } elseif (preg_match("/K/", $_value)) {
+                $value = substr($_value, 0, strpos($_value, 'K'));
+                $factor = 1024;
+            } elseif (is_string($_value)) {
+                $value = $_value;
+                $factor = 1;
+            } else {
+                throw new Exception('Argument type not supported:' . gettype($_value));
+            }
+            
+            $bytes = intval($value) * $factor;
         }
-        $bytes = intval($value) * $factor;
+        
+        return $bytes;
     }
     
-    return $bytes;
-}
-
-/**
- * converts value to megabytes
- * 
- * @param integer $_value
- * @return integer
- */
-function convertToMegabytes($_value)
-{
-    $result = ($_value) ? round($_value / 1024 / 1024) : $_value;
-    return $result;
-}
-
-/**
- * get svn revision info
- *
- * @return string
- */
-function getDevelopmentRevision()
-{
-    $branch = '';
-    $rev = 0;
-    $date = '';
+    /**
+     * converts value to megabytes
+     * 
+     * @param integer $_value
+     * @return integer
+     */
+    public static function convertToMegabytes($_value)
+    {
+        $result = ($_value) ? round($_value / 1024 / 1024) : $_value;
+        
+        return $result;
+    }
     
-    try {
-        // try to find the .git dir
-        $dir = realpath(dirname(dirname(dirname(__FILE__)))) . '/.git';
-        if (file_exists($dir)) {
-            $HEAD = trim(str_replace('ref: ', '', @file_get_contents("$dir/HEAD")));
-            $explodedHead = explode('/', $HEAD);
-            
-            $branch = array_pop($explodedHead);
-            $rev = trim(@file_get_contents("$dir/$HEAD"));
-            
-            $hashes = str_split($rev, 2);
-
-            $objPath = "$dir/objects";
-            while (count($hashes) != 0) {
-                $objPath .= '/' . array_shift($hashes);
-                $objFile = "$objPath/" . implode('', $hashes);
-                if (@file_exists($objFile)) {
-                    $date = date_create('@' . filemtime($objFile))->format('Y-m-d H:i:s');
-                    break;
+    /**
+     * get svn revision info
+     *
+     * @return string
+     */
+    public static function getDevelopmentRevision()
+    {
+        $branch = '';
+        $rev = 0;
+        $date = '';
+        
+        try {
+            // try to find the .git dir
+            $dir = realpath(dirname(dirname(dirname(__FILE__)))) . '/.git';
+            if (file_exists($dir)) {
+                $HEAD = trim(str_replace('ref: ', '', @file_get_contents("$dir/HEAD")));
+                $explodedHead = explode('/', $HEAD);
+                
+                $branch = array_pop($explodedHead);
+                $rev = trim(@file_get_contents("$dir/$HEAD"));
+                
+                $hashes = str_split($rev, 2);
+    
+                $objPath = "$dir/objects";
+                while (count($hashes) != 0) {
+                    $objPath .= '/' . array_shift($hashes);
+                    $objFile = "$objPath/" . implode('', $hashes);
+                    if (@file_exists($objFile)) {
+                        $date = date_create('@' . filemtime($objFile))->format('Y-m-d H:i:s');
+                        break;
+                    }
                 }
             }
+            $revision = "$branch: $rev ($date)";
+        } catch (Exception $e) {
+            $revision = 'not resolvable';
         }
-        $revision = "$branch: $rev ($date)";
-    } catch (Exception $e) {
-        $revision = 'not resolvable';
+        
+        return $revision;
     }
     
-    return $revision;
-}
-
-/**
- * converts cache id
- * cache id strings can only contain the chars [a-zA-Z0-9_]
- * 
- * @param string $_cacheId
- * @return string
- */
-function convertCacheId($_cacheId) 
-{
-    $result = preg_replace('/[^a-z^A-Z^0-9^_]/', '', $_cacheId);
-
-    return $result;
-}
-
-/**
- * recursive deleting of directory and all containing files
- * 
- * @param string $_dir
- * @return void
- */
-function removeDir($_dir)
-{
-    $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($_dir), RecursiveIteratorIterator::CHILD_FIRST);
-    foreach ($iterator as $fullFilename => $cur) {
-        if (is_dir($fullFilename) && substr($fullFilename, -1) !== '.') {
-            rmdir($fullFilename);
-        } elseif (is_file($fullFilename)) {
-            unlink($fullFilename);
-        }
+    /**
+     * converts cache id
+     * cache id strings can only contain the chars [a-zA-Z0-9_]
+     * 
+     * @param string $_cacheId
+     * @return string
+     */
+    public static function convertCacheId($_cacheId) 
+    {
+        $result = preg_replace('/[^a-z^A-Z^0-9^_]/', '', $_cacheId);
+        
+        return $result;
     }
-    if (is_dir($_dir)) rmdir($_dir);
-}
-
-/**
- * replaces and/or strips special chars from given string
- *
- * @param string $_input
- * @return string
- */
-function replaceSpecialChars($_input)
-{
-    $search  = array('ä',  'ü',  'ö',  'ß',  'é', 'è', 'ê', 'ó' ,'ô', 'á', 'ź', 'Ä',  'Ü',  'Ö',  'É', 'È', 'Ê', 'Ó' ,'Ô', 'Á', 'Ź');
-    $replace = array('ae', 'ue', 'oe', 'ss', 'e', 'e', 'e', 'o', 'o', 'a', 'z', 'Ae', 'Ue', 'Oe', 'E', 'E', 'E', 'O', 'O', 'a', 'z');
-                
-    $output = str_replace($search, $replace, $_input);
     
-    return preg_replace('/[^a-zA-Z0-9._\-]/', '', $output);
-}
-
-/**
- * Checks if needle $_str is in haystack $_arr but ignores case.
- * 
- * @param array $_arr
- * @param string $_str
- * @return boolean
- */
-function in_array_case($_arr, $_str)
-{
-    if (! is_array($_arr)) {
-        return false;
+    /**
+     * replaces and/or strips special chars from given string
+     *
+     * @param string $_input
+     * @return string
+     */
+    public static function replaceSpecialChars($_input)
+    {
+        $search  = array('ä',  'ü',  'ö',  'ß',  'é', 'è', 'ê', 'ó' ,'ô', 'á', 'ź', 'Ä',  'Ü',  'Ö',  'É', 'È', 'Ê', 'Ó' ,'Ô', 'Á', 'Ź');
+        $replace = array('ae', 'ue', 'oe', 'ss', 'e', 'e', 'e', 'o', 'o', 'a', 'z', 'Ae', 'Ue', 'Oe', 'E', 'E', 'E', 'O', 'O', 'a', 'z');
+        
+        $output = str_replace($search, $replace, $_input);
+        
+        return preg_replace('/[^a-zA-Z0-9._\-]/', '', $output);
     }
     
-    foreach ($_arr as $s) {
-        if (strcasecmp($_str, $s) == 0) {
-            return true;
+    /**
+     * Checks if needle $_str is in haystack $_arr but ignores case.
+     * 
+     * @param array $_arr
+     * @param string $_str
+     * @return boolean
+     */
+    public static function in_array_case($_arr, $_str)
+    {
+        if (! is_array($_arr)) {
+            return false;
+        }
+        
+        foreach ($_arr as $s) {
+            if (strcasecmp($_str, $s) == 0) {
+                return true;
+            }
         }
+        return false;
     }
-    return false;
-}
-
-/**
- * try to convert string to utf8 using mb_convert_encoding
- * 
- * @param string $string
- * @param string $encodingTo (default: utf-8)
- * @return string
- */
-function mbConvertTo($string, $encodingTo = 'utf-8')
-{
-    if (! extension_loaded('mbstring')) {
+    
+    /**
+     * try to convert string to utf8 using mb_convert_encoding
+     * 
+     * @param string $string
+     * @param string $encodingTo (default: utf-8)
+     * @return string
+     */
+    public static function mbConvertTo($string, $encodingTo = 'utf-8')
+    {
+        if (! extension_loaded('mbstring')) {
+            return $string;
+        }
+        // try to fix bad encodings
+        $encoding = mb_detect_encoding($string, array('utf-8', 'iso-8859-1', 'windows-1252', 'iso-8859-15'));
+        if ($encoding !== FALSE) {
+            $string = @mb_convert_encoding($string, $encodingTo, $encoding);
+        }
+        
         return $string;
     }
-    // try to fix bad encodings
-    $encoding = mb_detect_encoding($string, array('utf-8', 'iso-8859-1', 'windows-1252', 'iso-8859-15'));
-    if ($encoding !== FALSE) {
-        $string = @mb_convert_encoding($string, $encodingTo, $encoding);
-    }
     
-    return $string;
-}
-
-/**
- * converts all linebreaks to unix linebreaks
- *
- * @param string $string
- * @return string
- */
-function normalizeLineBreaks($string)
-{
-    if (is_string($string)) {
-        $result = str_replace(array("\r\n", "\r"), "\n", $string);
-    } else {
-        $result = $string;
+    /**
+     * converts all linebreaks to unix linebreaks
+     *
+     * @param string $string
+     * @return string
+     */
+    public static function normalizeLineBreaks($string)
+    {
+        if (is_string($string)) {
+            $result = str_replace(array("\r\n", "\r"), "\n", $string);
+        } else {
+            $result = $string;
+        }
+        
+        return $result;
     }
     
-    return $result;
-}
-
-/**
- * get clone to be used with right hand side operator
- *
- * @param  Object $obj
- * @return Object
- */
-function getClone($obj)
-{
-    return clone $obj;
-}
-
-/**
- * returns all elements of an array whose key matches the $pattern
- * 
- * @param string $pattern
- * @param array $array
- * @return array
- */
-function searchArrayByRegexpKey($pattern, $array)
-{
-    $keys = array_keys($array);
-    $result = preg_grep($pattern, $keys);
-    
-    return array_intersect_key($array, array_flip($result));
-}
-
-/**
- * checks if a string is valid json
- * 
- * @param string $string
- * @return boolean 
- */
-function is_json($string)
-{
-    if (! is_string($string) || (substr($string, 0, 1) !== '[' && substr($string, 0, 1) !== '{')) {
-        return false;
+    /**
+     * returns all elements of an array whose key matches the $pattern
+     * 
+     * @param string $pattern
+     * @param array $array
+     * @return array
+     */
+    public static function searchArrayByRegexpKey($pattern, $array)
+    {
+        $keys = array_keys($array);
+        $result = preg_grep($pattern, $keys);
+        
+        return array_intersect_key($array, array_flip($result));
     }
     
-    try {
-        Zend_Json::decode($string);
-    } catch (Exception $e) {
-        return false;
+    /**
+     * checks if a string is valid json
+     * 
+     * @param string $string
+     * @return boolean 
+     */
+    public static function is_json($string)
+    {
+        if (! is_string($string) || (substr($string, 0, 1) !== '[' && substr($string, 0, 1) !== '{')) {
+            return false;
+        }
+        
+        try {
+            Zend_Json::decode($string);
+        } catch (Exception $e) {
+            return false;
+        }
+        
+        // check if error occured (only if json_last_error() exists)
+        return (! function_exists('json_last_error') || json_last_error() == JSON_ERROR_NONE);
     }
     
-    // check if error occured (only if json_last_error() exists)
-    return (! function_exists('json_last_error') || json_last_error() == JSON_ERROR_NONE);
-}
-
-/**
- * formats a microtime diff to an appropriate string containing time unit based on the value range
- * 
- * value ranges
- * below 1s return ms
- * below 1m return s
- * below 1h return m
- * as of 1h return h
- * 
- * @param float $timediff
- * @return string
- */
-function formatMicrotimeDiff($timediff)
-{
-    $ms = (int)($timediff * 1000);
-    if ($ms>=3600000) {
-        return (((int)($ms / 3600000 * 100.0)) / 100.0).'h';
-    } elseif ($ms>=60000) {
-        return (((int)($ms / 60000 * 100.0)) / 100.0).'m';
-    } elseif ($ms>=1000) {
-        return (((int)($ms / 1000 * 100.0)) / 100.0).'s';
-    } else {
-        return $ms.'ms';
-    }
-}
-
-/**
- * checks if an url exists by checking headers 
- * -> inspired by http://php.net/manual/en/function.file-exists.php#75064
- * 
- * @param string $url
- * @return boolean
- */
-function urlExists($url)
-{
-    $file_headers = @get_headers($url);
-    if ($file_headers[0] == 'HTTP/1.1 404 Not Found') {
-        $exists = false;
-    } else {
-        $exists = true;
+    /**
+     * formats a microtime diff to an appropriate string containing time unit based on the value range
+     * 
+     * value ranges
+     * below 1s return ms
+     * below 1m return s
+     * below 1h return m
+     * as of 1h return h
+     * 
+     * @param float $timediff
+     * @return string
+     */
+    public static function formatMicrotimeDiff($timediff)
+    {
+        $ms = (int)($timediff * 1000);
+        if ($ms>=3600000) {
+            return (((int)($ms / 3600000 * 100.0)) / 100.0).'h';
+        } elseif ($ms>=60000) {
+            return (((int)($ms / 60000 * 100.0)) / 100.0).'m';
+        } elseif ($ms>=1000) {
+            return (((int)($ms / 1000 * 100.0)) / 100.0).'s';
+        } else {
+            return $ms.'ms';
+        }
     }
     
-    return $exists;
-}
+    /**
+     * checks if an url exists by checking headers 
+     * -> inspired by http://php.net/manual/en/function.file-exists.php#75064
+     * 
+     * @param string $url
+     * @return boolean
+     */
+    public static function urlExists($url)
+    {
+        $file_headers = @get_headers($url);
+        
+        if ($file_headers[0] == 'HTTP/1.1 404 Not Found') {
+            $exists = false;
+        } else {
+            $exists = true;
+        }
+        
+        return $exists;
+    }
+}
\ No newline at end of file
index 9dfa69c..6f0f462 100644 (file)
@@ -78,7 +78,7 @@ class Tinebase_Import_CalDav_Client extends \Sabre\DAV\Client
      */
     public function findCurrentUserPrincipal($tries = 1)
     {
-        $cacheId = convertCacheId('findCurrentUserPrincipal' . $this->userName);
+        $cacheId = Tinebase_Helper::convertCacheId('findCurrentUserPrincipal' . $this->userName);
         if (Tinebase_Core::getCache()->test($cacheId)) {
             if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) Tinebase_Core::getLogger()->info(__METHOD__ . ' ' . __LINE__
                     . ' Loading user principal from cache');
@@ -163,7 +163,7 @@ class Tinebase_Import_CalDav_Client extends \Sabre\DAV\Client
                     . ' No principal found for user ' . $this->userName);
             return false;
         }
-        $cacheId = convertCacheId('findCalendarHomeSet' . $this->userName);
+        $cacheId = Tinebase_Helper::convertCacheId('findCalendarHomeSet' . $this->userName);
         if (Tinebase_Core::getCache()->test($cacheId)) {
             $this->calendarHomeSet = Tinebase_Core::getCache()->load($cacheId);
             if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) Tinebase_Core::getLogger()->info(__METHOD__ . ' ' . __LINE__
index 0c733a8..b74d90f 100644 (file)
@@ -199,7 +199,7 @@ class Tinebase_Ldap extends Zend_Ldap
      */
     public function getFirstNamingContext()
     {
-        return array_value(0, $this->getRootDse()->getNamingContexts());
+        return Tinebase_Helper::array_value(0, $this->getRootDse()->getNamingContexts());
     }
     
     /**
index ccfd444..5942b07 100644 (file)
@@ -132,10 +132,10 @@ class Tinebase_Log_Formatter extends Zend_Log_Formatter_Simple
         {
             $currenttime = microtime(true);
             if (self::$_logruntime) {
-                $timelog = formatMicrotimeDiff($currenttime - self::$_starttime) . ' ';
+                $timelog = Tinebase_Helper::formatMicrotimeDiff($currenttime - self::$_starttime) . ' ';
             }
             if (self::$_logdifftime) {
-                $timelog .= formatMicrotimeDiff($currenttime - (self::$_lastlogtime ? self::$_lastlogtime : $currenttime)) . ' ';
+                $timelog .= Tinebase_Helper::formatMicrotimeDiff($currenttime - (self::$_lastlogtime ? self::$_lastlogtime : $currenttime)) . ' ';
                 self::$_lastlogtime = $currenttime;
             }
         }
index 2975da8..a69c3fc 100644 (file)
@@ -623,7 +623,7 @@ class Tinebase_Mail extends Zend_Mail
         // TLDs list:  http://data.iana.org/TLD/tlds-alpha-by-domain.txt
        
         $cache = Tinebase_Core::get('cache');
-        $cacheId = convertCacheId('getDomainList');
+        $cacheId = Tinebase_Helper::convertCacheId('getDomainList');
         $validTlds = $cache->load($cacheId);
         
         if (! is_array($validTlds)) {
index 578e7e3..08143b9 100644 (file)
@@ -463,7 +463,7 @@ class Tinebase_Notes implements Tinebase_Backend_Sql_Interface
     {
         // check if $modification->new_value is json string and record set diff
         // @see 0008546: When edit event, history show "code" ...
-        if (is_json($modification->new_value)) {
+        if (Tinebase_Helper::is_json($modification->new_value)) {
             $newValueArray = Zend_Json::decode($modification->new_value);
             if ((isset($newValueArray['model']) || array_key_exists('model', $newValueArray)) && (isset($newValueArray['added']) || array_key_exists('added', $newValueArray))) {
                 $diff = new Tinebase_Record_RecordSetDiff($newValueArray);
index 9ba8976..6ccd915 100644 (file)
@@ -34,7 +34,7 @@ abstract class Tinebase_Server_Abstract implements Tinebase_Server_Interface
             $basicAuthData = base64_decode(substr($_SERVER["HTTP_AUTHORIZATION"], 6));
         } else {
             // check if (REDIRECT_)*REMOTE_USER is found in SERVER vars
-            $remoteUserValues = searchArrayByRegexpKey('/REMOTE_USER$/', $_SERVER);
+            $remoteUserValues = Tinebase_Helper::searchArrayByRegexpKey('/REMOTE_USER$/', $_SERVER);
             if (! empty($remoteUserValues)) {
                 $firstServerValue = array_shift($remoteUserValues);
                 $basicAuthData = base64_decode(substr($firstServerValue, 6));
index 459a107..d1f4cef 100644 (file)
@@ -175,7 +175,7 @@ abstract class Tinebase_Setup_Import_Egw14_Abstract
             
         $this->_appendRecordFilter($select);
         
-        $recordCount = array_value(0, $this->_egwDb->fetchAll($select, NULL, Zend_Db::FETCH_ASSOC));
+        $recordCount = Tinebase_Helper::array_value(0, $this->_egwDb->fetchAll($select, NULL, Zend_Db::FETCH_ASSOC));
         return $recordCount['count'];
     }
     
index f347c2a..0ffc80f 100644 (file)
@@ -2246,7 +2246,7 @@ class Tinebase_Setup_Update_Release0 extends Setup_Update_Abstract
         }
         
         /** convert db contenets for installations which had a clientcharset != utf8 **/
-        $originalCharset = array_value('Value', array_value(0, $orgDb->query("SHOW VARIABLES LIKE 'character_set_client'")->fetchAll()));
+        $originalCharset = Tinebase_Helper::array_value('Value', Tinebase_Helper::array_value(0, $orgDb->query("SHOW VARIABLES LIKE 'character_set_client'")->fetchAll()));
         if (strtolower($originalCharset) != 'utf8') {
             $this->_db->query("SET FOREIGN_KEY_CHECKS=0");
             $orgDb->query("SET FOREIGN_KEY_CHECKS=0");
index 35babed..317c91e 100644 (file)
@@ -202,7 +202,7 @@ class Tinebase_TempFile extends Tinebase_Backend_Sql_Abstract implements Tinebas
     public function createTempFile($_path, $_name = 'tempfile.tmp', $_type = 'unknown', $_size = 0, $_error = 0)
     {
         // sanitize filename (convert to utf8)
-        $filename = mbConvertTo($_name);
+        $filename = Tinebase_Helper::mbConvertTo($_name);
         
         $id = Tinebase_Model_TempFile::generateUID();
         $tempFile = new Tinebase_Model_TempFile(array(
index 26e641f..adece39 100644 (file)
@@ -343,12 +343,12 @@ class Tinebase_Timemachine_ModificationLog
     protected function _resolveDiffs(Tinebase_Record_RecordSet $resolved, Tinebase_Record_RecordSet $diffs, Tinebase_Record_Interface $newRecord)
     {
         foreach ($diffs as $diff) {
-            $newUserValue = isset($newRecord[$diff->modified_attribute]) ? normalizeLineBreaks($newRecord[$diff->modified_attribute]) : NULL;
+            $newUserValue = isset($newRecord[$diff->modified_attribute]) ? Tinebase_Helper::normalizeLineBreaks($newRecord[$diff->modified_attribute]) : NULL;
             
-            if (isset($newRecord[$diff->modified_attribute]) && $newUserValue == normalizeLineBreaks($diff->new_value)) {
+            if (isset($newRecord[$diff->modified_attribute]) && $newUserValue == Tinebase_Helper::normalizeLineBreaks($diff->new_value)) {
                 $this->_resolveScalarSameValue($newRecord, $diff);
             
-            } else if (! isset($newRecord[$diff->modified_attribute]) || $newUserValue == normalizeLineBreaks($diff->old_value)) {
+            } else if (! isset($newRecord[$diff->modified_attribute]) || $newUserValue == Tinebase_Helper::normalizeLineBreaks($diff->old_value)) {
                 $this->_resolveScalarMergeUpdate($newRecord, $diff);
             
             } else if ($newRecord[$diff->modified_attribute] instanceof Tinebase_Record_RecordSet) {
@@ -519,13 +519,13 @@ class Tinebase_Timemachine_ModificationLog
             
             // we loop over the diffs! -> changes over fields which have no diff in storage are not in the loop!
             foreach ($diffs as $diff) {
-                $newUserValue = isset($_newRecord[$diff->modified_attribute]) ? normalizeLineBreaks($_newRecord[$diff->modified_attribute]) : NULL;
+                $newUserValue = isset($_newRecord[$diff->modified_attribute]) ? Tinebase_Helper::normalizeLineBreaks($_newRecord[$diff->modified_attribute]) : NULL;
                 
-                if (isset($_newRecord[$diff->modified_attribute]) && $newUserValue == normalizeLineBreaks($diff->new_value)) {
+                if (isset($_newRecord[$diff->modified_attribute]) && $newUserValue == Tinebase_Helper::normalizeLineBreaks($diff->new_value)) {
                     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__
                         . " User updated to same value for field '" . $diff->modified_attribute . "', nothing to do.");
                     $resolved->addRecord($diff);
-                } elseif (! isset($_newRecord[$diff->modified_attribute]) || $newUserValue == normalizeLineBreaks($diff->old_value)) {
+                } elseif (! isset($_newRecord[$diff->modified_attribute]) || $newUserValue == Tinebase_Helper::normalizeLineBreaks($diff->old_value)) {
                     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__
                         . " Merge current value into update data, as it was not changed in update request.");
                     $_newRecord[$diff->modified_attribute] = $diff->new_value;
index 4601647..3a7dcef 100644 (file)
@@ -85,7 +85,7 @@ class Tinebase_Translation
             $filesToWatch[] = $info['path'];
         }
         
-        $cacheId = convertCacheId(__FUNCTION__ . $appName . sha1(serialize($filesToWatch)));
+        $cacheId = Tinebase_Helper::convertCacheId(__FUNCTION__ . $appName . sha1(serialize($filesToWatch)));
         $cache = new Zend_Cache_Frontend_File(array(
             'master_files' => $filesToWatch
         ));
index d0f07ae..76e5343 100644 (file)
@@ -347,7 +347,7 @@ abstract class Tinebase_User_Abstract implements Tinebase_User_Interface
             if (method_exists($this, '_generateUserWithSchema' . $_schema)) {
                 $userName = call_user_func_array(array($this, '_generateUserWithSchema' . $_schema), array($_account));
             } else {
-                $userName = strtolower(replaceSpecialChars(substr($_account->accountLastName, 0, 10)));
+                $userName = strtolower(Tinebase_Helper::replaceSpecialChars(substr($_account->accountLastName, 0, 10)));
             }
         }
         $userName = $this->_addSuffixToNameIfExists('accountLoginName', $userName);
@@ -377,7 +377,7 @@ abstract class Tinebase_User_Abstract implements Tinebase_User_Interface
      */
     protected function _generateUserWithSchema1($_account)
     {
-        $result = strtolower(replaceSpecialChars(substr($_account->accountLastName, 0, 10) . substr($_account->accountFirstName, 0, 2)));
+        $result = strtolower(Tinebase_Helper::replaceSpecialChars(substr($_account->accountLastName, 0, 10) . substr($_account->accountFirstName, 0, 2)));
         return $result;
     }
     
@@ -392,7 +392,7 @@ abstract class Tinebase_User_Abstract implements Tinebase_User_Interface
         $result = $_account->accountLastName;
         for ($i=0; $i < strlen($_account->accountFirstName); $i++) {
         
-            $userName = strtolower(replaceSpecialChars(substr($_account->accountFirstName, 0, $i+1) . $_account->accountLastName));
+            $userName = strtolower(Tinebase_Helper::replaceSpecialChars(substr($_account->accountFirstName, 0, $i+1) . $_account->accountLastName));
             if (! $this->nameExists('accountLoginName', $userName)) {
                 $result = $userName;
                 break;
@@ -413,7 +413,7 @@ abstract class Tinebase_User_Abstract implements Tinebase_User_Interface
         $result = $_account->accountLastName;
         for ($i=0; $i < strlen($_account->accountFirstName); $i++) {
         
-            $userName = strtolower(replaceSpecialChars(substr($_account->accountFirstName, 0, $i+1) . '.' . $_account->accountLastName));
+            $userName = strtolower(Tinebase_Helper::replaceSpecialChars(substr($_account->accountFirstName, 0, $i+1) . '.' . $_account->accountLastName));
             if (! $this->nameExists('accountLoginName', $userName)) {
                 $result = $userName;
                 break;
index 0f43494..e2855b9 100644 (file)
@@ -567,7 +567,7 @@ class Tinebase_User_ActiveDirectory extends Tinebase_User_Ldap
             }
             $ldapData['gidnumber'] = Tinebase_Group::getInstance()->resolveGidNumber($_user->accountPrimaryGroup);
             
-            $ldapData['msSFU30NisDomain'] = array_value(0, explode('.', $this->_domainName));
+            $ldapData['msSFU30NisDomain'] = Tinebase_Helper::array_value(0, explode('.', $this->_domainName));
         }
         
         if (isset($_user->sambaSAM) && $_user->sambaSAM instanceof Tinebase_Model_SAMUser) {
index e918bbe..ef7f4f6 100644 (file)
@@ -72,7 +72,7 @@ abstract class Tinebase_WebDav_Collection_Abstract extends DAV\Collection implem
     {
         $this->_path            = $_path;
         $this->_pathParts       = $this->_parsePath($_path);
-        $this->_applicationName = array_value(0, explode('_', get_class($this)));
+        $this->_applicationName = Tinebase_Helper::array_value(0, explode('_', get_class($this)));
     }
     
     /**
index 01f89b6..9c09f3e 100644 (file)
@@ -144,7 +144,7 @@ abstract class Tinebase_WebDav_Collection_AbstractContainerTree extends \Sabre\D
             # path == /<applicationPrefix>/<contactid>|'shared'
             # list container
             case 2:
-                if (array_value(1, $this->_getPathParts()) == Tinebase_Model_Container::TYPE_SHARED) {
+                if (Tinebase_Helper::array_value(1, $this->_getPathParts()) == Tinebase_Model_Container::TYPE_SHARED) {
                     try { 
                         if ($name instanceof Tinebase_Model_Container) {
                             $container = $name;
@@ -171,17 +171,17 @@ abstract class Tinebase_WebDav_Collection_AbstractContainerTree extends \Sabre\D
                         // invalid container id provided
                         throw new \Sabre\DAV\Exception\NotFound("Directory $this->_path/$name not found");
                     }
-                } elseif ($this->_hasRecordFolder && array_value(1, $this->_getPathParts()) == Tinebase_FileSystem::FOLDER_TYPE_RECORDS) {
+                } elseif ($this->_hasRecordFolder && Tinebase_Helper::array_value(1, $this->_getPathParts()) == Tinebase_FileSystem::FOLDER_TYPE_RECORDS) {
                     
                     return new Tinebase_Frontend_WebDAV_RecordCollection($this->_path . '/' . $name);
                     
                 } elseif ($this->_hasPersonalFolders) {
-                    if (array_value(1, $this->_getPathParts()) === '__currentuser__') {
+                    if (Tinebase_Helper::array_value(1, $this->_getPathParts()) === '__currentuser__') {
                         $accountId = Tinebase_Core::getUser()->accountId;
                         
                     } else {
                         try {
-                            $accountId = $this->_getContact(array_value(1, $this->_getPathParts()))->account_id;
+                            $accountId = $this->_getContact(Tinebase_Helper::array_value(1, $this->_getPathParts()))->account_id;
                             
                         } catch (Tinebase_Exception_NotFound $tenf) {
                             throw new \Sabre\DAV\Exception\NotFound("Directory $this->_path/$name not found");
@@ -282,7 +282,7 @@ abstract class Tinebase_WebDav_Collection_AbstractContainerTree extends \Sabre\D
             # path == /<applicationPrefix>/<contactid>|'shared'
             # list container
             case 2:
-                if (array_value(1, $this->_getPathParts()) == Tinebase_Model_Container::TYPE_SHARED) {
+                if (Tinebase_Helper::array_value(1, $this->_getPathParts()) == Tinebase_Model_Container::TYPE_SHARED) {
                     $containers = Tinebase_Container::getInstance()->getSharedContainer(
                         Tinebase_Core::getUser(),
                         $this->_getAppliationName(),
@@ -293,12 +293,12 @@ abstract class Tinebase_WebDav_Collection_AbstractContainerTree extends \Sabre\D
                     );
                     
                 } elseif ($this->_hasPersonalFolders) {
-                    if (array_value(1, $this->_getPathParts()) === '__currentuser__') {
+                    if (Tinebase_Helper::array_value(1, $this->_getPathParts()) === '__currentuser__') {
                         $accountId = Tinebase_Core::getUser()->accountId;
                         
                     } else {
                         try {
-                            $accountId = $this->_getContact(array_value(1, $this->_getPathParts()))->account_id;
+                            $accountId = $this->_getContact(Tinebase_Helper::array_value(1, $this->_getPathParts()))->account_id;
                         } catch (Tinebase_Exception_NotFound $tenf) {
                             throw new \Sabre\DAV\Exception\NotFound("Path $this->_path not found");
                         }
@@ -423,11 +423,11 @@ abstract class Tinebase_WebDav_Collection_AbstractContainerTree extends \Sabre\D
     public function getName()
     {
         if (count($this->_getPathParts()) === 2 && 
-            array_value(1, $this->_getPathParts()) !== Tinebase_Model_Container::TYPE_SHARED &&
+            Tinebase_Helper::array_value(1, $this->_getPathParts()) !== Tinebase_Model_Container::TYPE_SHARED &&
             !$this->_useIdAsName
         ) {
             try {
-                $contact = $this->_getContact(array_value(1, $this->_getPathParts()));
+                $contact = $this->_getContact(Tinebase_Helper::array_value(1, $this->_getPathParts()));
                 
                 $name = $contact->n_fileas;
                 
@@ -453,7 +453,7 @@ abstract class Tinebase_WebDav_Collection_AbstractContainerTree extends \Sabre\D
     {
         if (count($this->_getPathParts()) === 2 && $this->getName() !== Tinebase_Model_Container::TYPE_SHARED) {
             try {
-                $contact = $this->_getContact(array_value(1, $this->_getPathParts()));
+                $contact = $this->_getContact(Tinebase_Helper::array_value(1, $this->_getPathParts()));
             } catch (Tinebase_Exception_NotFound $tenf) {
                 return null;
             }
@@ -482,7 +482,7 @@ abstract class Tinebase_WebDav_Collection_AbstractContainerTree extends \Sabre\D
                 case '{DAV:}displayname':
                     if (count($this->_getPathParts()) === 2 && $this->getName() !== Tinebase_Model_Container::TYPE_SHARED) {
                         try {
-                            $contact = $this->_getContact(array_value(1, $this->_getPathParts()));
+                            $contact = $this->_getContact(Tinebase_Helper::array_value(1, $this->_getPathParts()));
                         } catch (Tinebase_Exception_NotFound $tenf) {
                             continue;
                         }
@@ -627,7 +627,7 @@ abstract class Tinebase_WebDav_Collection_AbstractContainerTree extends \Sabre\D
             throw new \Sabre\DAV\Exception\Forbidden('Permission denied to create directory ' . $properties['name']);
         }
         
-        $containerType = array_value(1, $this->_getPathParts()) == Tinebase_Model_Container::TYPE_SHARED ?
+        $containerType = Tinebase_Helper::array_value(1, $this->_getPathParts()) == Tinebase_Model_Container::TYPE_SHARED ?
             Tinebase_Model_Container::TYPE_SHARED :
             Tinebase_Model_Container::TYPE_PERSONAL;
         
@@ -655,7 +655,7 @@ abstract class Tinebase_WebDav_Collection_AbstractContainerTree extends \Sabre\D
     protected function _getAppliationName()
     {
         if (!$this->_applicationName) {
-            $this->_applicationName = array_value(0, explode('_', get_class($this)));
+            $this->_applicationName = Tinebase_Helper::array_value(0, explode('_', get_class($this)));
         }
         
         return $this->_applicationName;
index 0727f1e..db337f2 100644 (file)
@@ -72,7 +72,7 @@ class Tinebase_WebDav_PrincipalBackend implements \Sabre\DAVACL\PrincipalBackend
     public function getPrincipalByPath($path) 
     {
         // any user has to lookup the data at least once
-        $cacheId = convertCacheId('getPrincipalByPath' . Tinebase_Core::getUser()->getId() . $path);
+        $cacheId = Tinebase_Helper::convertCacheId('getPrincipalByPath' . Tinebase_Core::getUser()->getId() . $path);
         
         if (Tinebase_Core::getCache()->test($cacheId)) {
             $principal = Tinebase_Core::getCache()->load($cacheId);
@@ -572,7 +572,7 @@ class Tinebase_WebDav_PrincipalBackend implements \Sabre\DAVACL\PrincipalBackend
         $result = array();
         
         foreach ($containers as $container) {
-            $cacheId = convertCacheId('_containerGrantsToPrincipals' . $container->getId() . $container->seq);
+            $cacheId = Tinebase_Helper::convertCacheId('_containerGrantsToPrincipals' . $container->getId() . $container->seq);
             
             if (Tinebase_Core::getCache()->test($cacheId)) {
                 $containerPrincipals = Tinebase_Core::getCache()->load($cacheId);
index adb1d00..76d44bd 100644 (file)
@@ -31,7 +31,7 @@
         "phpdocumentor/phpdocumentor": "2.1.*"
     },
     "autoload": {
-        "files": ["Tinebase/Helper.php"],
+        "files": [],
         "psr-0": {
             "": ["", "library", "../tests/tine20", "../tests/setup"],
             "TimeZoneConvert": "library/TimeZoneConvert/lib/",
index ca80129..e65e75e 100755 (executable)
@@ -25,5 +25,5 @@ $time = $time_end - $time_start;
 
 if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
     Tinebase_Core::getLogger()->info('index.php ('. __LINE__ . ') ' .
-        'METHOD: ' . Tinebase_Core::get(Tinebase_Core::METHOD) . ' / TIME: ' . formatMicrotimeDiff($time) . ' / ' .Tinebase_Core::logMemoryUsage() . ' / ' . Tinebase_Core::logCacheSize());
+        'METHOD: ' . Tinebase_Core::get(Tinebase_Core::METHOD) . ' / TIME: ' . Tinebase_Helper::formatMicrotimeDiff($time) . ' / ' .Tinebase_Core::logMemoryUsage() . ' / ' . Tinebase_Core::logCacheSize());
 }
index aed52e4..c6b90ad 100755 (executable)
@@ -26,8 +26,6 @@ require_once 'Zend/Loader/Autoloader.php';
 $autoloader = Zend_Loader_Autoloader::getInstance();
 $autoloader->setFallbackAutoloader(true);
 
-require_once 'Tinebase/Helper.php';
-
 /**
  * path to tine 2.0 checkout
  */
@@ -583,7 +581,7 @@ function statistics($_verbose)
     `rm messages.mo`;
     
     $results = array(
-        'version'      => getDevelopmentRevision(),
+        'version'      => Tinebase_Helper::getDevelopmentRevision(),
         'langStats'    => array_values($langStats),
         'poFilesStats' => $poFilesStats
     );
@@ -805,4 +803,4 @@ function gitAdd($_locale)
             git add "$dir/$_locale.mo"`;
         }
     }
-}
\ No newline at end of file
+}
index 9fa2999..64ed6da 100644 (file)
@@ -106,7 +106,7 @@ class VCard
     {
         $our_categories = $this->getCategories();
         foreach ($categories as $category) {
-            if (in_array_case($category, $our_categories)) {
+            if (Tinebase_Helper::in_array_case($category, $our_categories)) {
                 return true;
             }
         }