Merge branch '2013.10' into 2014.09
authorPhilipp Schüle <p.schuele@metaways.de>
Thu, 16 Oct 2014 08:43:53 +0000 (10:43 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Thu, 16 Oct 2014 08:43:53 +0000 (10:43 +0200)
Conflicts:
tine20/Admin/Frontend/Cli.php
tine20/Tinebase/Translation.php
tine20/Tinebase/User/Abstract.php

Change-Id: I75ecd3929ef7b6780624cb3dfe86161ffd649f93

1  2 
tests/tine20/Courses/JsonTest.php
tests/tine20/Inventory/Import/CsvTest.php
tine20/Admin/Frontend/Cli.php
tine20/Calendar/Setup/Update/Release8.php
tine20/Inventory/Model/InventoryItem.php
tine20/Inventory/Setup/Initialize.php
tine20/Tinebase/Controller.php
tine20/Tinebase/Translation.php
tine20/Tinebase/User/Abstract.php

Simple merge
@@@ -50,36 -50,46 +50,80 @@@ class Admin_Frontend_Cli extends Tineba
      }
      
      /**
 -     * overwirte Samba options for users
 +     * import groups
 +     *
 +     * @param Zend_Console_Getopt $_opts
 +     */
 +    public function importGroups($_opts)
 +    {
 +        parent::_import($_opts);
 +    }
 +    
 +    /**
 +     * repair groups
 +     * add missing lists
 +     *
 +     */
 +    public function repairGroups()
 +    {
 +        $count = 0;
 +        $be = new Tinebase_Group_Sql();
 +        
 +        $groups = $be->getGroups();
 +        
 +        foreach ($groups as $group) {
 +            if ($group->list_id == null) {
 +                $list = Addressbook_Controller_List::getInstance()->createByGroup($group);
 +                $group->list_id = $list->getId();
 +                $group->visibility = Tinebase_Model_Group::VISIBILITY_DISPLAYED;
 +                $be->updateGroupInSqlBackend($group);
 +                $count++;
 +            }
 +        }
 +        echo $count . ' groups repaired!';
 +    }
++    
++    /**
++     * overwrite Samba options for users
+      *
+      */
+     public function repairUserSambaoptions($_opts)
+     {
+         $args = $_opts->getRemainingArgs();
+         if ($_opts->d) {
+             array_push($args, '--dry');
+         }
+         $_opts->setArguments($args);
+         $blacklist = array(); // List of Loginnames
+         $count = 0;
+         $tinebaseUser  = Tinebase_User::getInstance();
+         $users = $tinebaseUser->getUsers();
+         
+         foreach ($users as $id) {
+             $user = $tinebaseUser->getFullUserById($id->getId());
+             
+             if (isset($user['sambaSAM']) && empty($user['sambaSAM']['homeDrive']) && !in_array($user->accountLoginName, $blacklist)) {
+                 echo($user->getId() . ' : ' . $user->accountLoginName);
+                 echo("\n");
+                 
+                 //This must be adjusted
+                 $samUser = new Tinebase_Model_SAMUser(array(
+                     'homePath'    => '\\\\fileserver\\' . $user->accountLoginName,
+                     'homeDrive'   => 'H:',
+                     'logonScript' => 'script.cmd',
+                     'profilePath' => '\\\\fileserver\\profiles\\' . $user->accountLoginName
+                 ));
+                 $user->sambaSAM = $samUser;
+                 
+                 if ($_opts->d) {
+                     print_r($user);
+                 } else {
+                     $tinebaseUser->updateUser($user);
+                 }
+                 $count++;
+             };
+         }
+         echo('Found ' . $count . ' users!');
+         echo("\n");
+     }
  }
Simple merge
@@@ -37,10 -38,12 +38,12 @@@ class Tinebase_Controller extends Tineb
       * the constructor
       *
       */
 -    private function __construct() 
 +    private function __construct()
      {
-         $this->_writeAccessLog = Tinebase_Core::get('serverclassname') !== 'ActiveSync_Server_Http' ||
-             !(ActiveSync_Config::getInstance()->get(ActiveSync_Config::DISABLE_ACCESS_LOG));
+         $this->_writeAccessLog = Setup_Controller::getInstance()->isInstalled('Tinebase')
+             && (Tinebase_Core::get('serverclassname') !== 'ActiveSync_Server_Http' 
+                 || (Setup_Controller::getInstance()->isInstalled('ActiveSync')
+                         && !(ActiveSync_Config::getInstance()->get(ActiveSync_Config::DISABLE_ACCESS_LOG))));
      }
  
      /**
@@@ -85,17 -88,20 +88,28 @@@ class Tinebase_Translatio
              $filesToWatch[] = $info['path'];
          }
          
-         $cacheId = Tinebase_Helper::convertCacheId(__FUNCTION__ . $appName . sha1(serialize($filesToWatch)));
-         $cache = new Zend_Cache_Frontend_File(array(
-             'master_files' => $filesToWatch
-         ));
-         $cache->setBackend(Tinebase_Core::get(Tinebase_Core::CACHE)->getBackend());
 -        $cache = Tinebase_Core::getCache();
 -        if (is_object($cache)) {
 -            $cacheId = convertCacheId(__FUNCTION__ . $appName . sha1(serialize($filesToWatch)));
++        if (Tinebase_Config::isReady()) {
++            $cache = new Zend_Cache_Frontend_File(array(
++                'master_files' => $filesToWatch
++            ));
++            $cache->setBackend(Tinebase_Core::get(Tinebase_Core::CACHE)->getBackend());
++        } else {
++            $cache = null;
++        }
 +        
-         if ($cachedTranslations = $cache->load($cacheId)) {
-             $cachedTranslations = unserialize($cachedTranslations);
++        if ($cache) {
++            $cacheId = Tinebase_Helper::convertCacheId(__FUNCTION__ . $appName . sha1(serialize($filesToWatch)));
+             $cache = new Zend_Cache_Frontend_File(array(
+                 'master_files' => $filesToWatch
+             ));
+             $cache->setBackend(Tinebase_Core::get(Tinebase_Core::CACHE)->getBackend());
              
-             if ($cachedTranslations !== null) {
-                 return $cachedTranslations;
+             if ($cachedTranslations = $cache->load($cacheId)) {
+                 $cachedTranslations = unserialize($cachedTranslations);
+                 
+                 if ($cachedTranslations !== null) {
+                     return $cachedTranslations;
+                 }
              }
          }
          
  
          ksort($availableTranslations);
          
-         $cache->save(serialize($availableTranslations), $cacheId, array(), /* 1 day */ 86400);
 -        if (is_object($cache)) {
++        if ($cache) {
+             $cache->save(serialize($availableTranslations), $cacheId, array(), /* 1 day */ 86400);
+         }
          
          return $availableTranslations;
      }
@@@ -347,7 -347,7 +347,7 @@@ abstract class Tinebase_User_Abstract i
              if (method_exists($this, '_generateUserWithSchema' . $_schema)) {
                  $userName = call_user_func_array(array($this, '_generateUserWithSchema' . $_schema), array($_account));
              } else {
-                 $userName = strtolower(Tinebase_Helper::replaceSpecialChars(substr($_account->accountLastName, 0, 10)));
 -                $userName = strtolower(substr(replaceSpecialChars($_account->accountLastName), 0, 10));
++                $userName = strtolower(substr(Tinebase_Helper::replaceSpecialChars($_account->accountLastName), 0, 10));
              }
          }
          $userName = $this->_addSuffixToNameIfExists('accountLoginName', $userName);
       */
      protected function _generateUserWithSchema1($_account)
      {
-         $result = strtolower(Tinebase_Helper::replaceSpecialChars(substr($_account->accountLastName, 0, 10) . substr($_account->accountFirstName, 0, 2)));
 -        $result = strtolower(substr(replaceSpecialChars($_account->accountLastName), 0, 10) . substr(replaceSpecialChars($_account->accountFirstName), 0, 2));
++        $result = strtolower(substr(Tinebase_Helper::replaceSpecialChars($_account->accountLastName), 0, 10) . substr(Tinebase_Helper::replaceSpecialChars($_account->accountFirstName), 0, 2));
          return $result;
      }
      
          $result = $_account->accountLastName;
          for ($i=0; $i < strlen($_account->accountFirstName); $i++) {
          
-             $userName = strtolower(Tinebase_Helper::replaceSpecialChars(substr($_account->accountFirstName, 0, $i+1) . $_account->accountLastName));
 -            $userName = strtolower(substr(replaceSpecialChars($_account->accountFirstName), 0, $i+1) . replaceSpecialChars($_account->accountLastName));
++            $userName = strtolower(substr(Tinebase_Helper::replaceSpecialChars($_account->accountFirstName), 0, $i+1) . Tinebase_Helper::replaceSpecialChars($_account->accountLastName));
              if (! $this->nameExists('accountLoginName', $userName)) {
                  $result = $userName;
                  break;
          $result = $_account->accountLastName;
          for ($i=0; $i < strlen($_account->accountFirstName); $i++) {
          
-             $userName = strtolower(Tinebase_Helper::replaceSpecialChars(substr($_account->accountFirstName, 0, $i+1) . '.' . $_account->accountLastName));
 -            $userName = strtolower(substr(replaceSpecialChars($_account->accountFirstName), 0, $i+1) . '.' . replaceSpecialChars($_account->accountLastName));
++            $userName = strtolower(substr(Tinebase_Helper::replaceSpecialChars($_account->accountFirstName), 0, $i+1) . '.' . Tinebase_Helper::replaceSpecialChars($_account->accountLastName));
              if (! $this->nameExists('accountLoginName', $userName)) {
                  $result = $userName;
                  break;