Merge branch '2013.10' into 2014.11
authorPhilipp Schüle <p.schuele@metaways.de>
Thu, 6 Aug 2015 09:31:58 +0000 (11:31 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Thu, 6 Aug 2015 09:31:58 +0000 (11:31 +0200)
Conflicts:
tine20/Tinebase/User/Sql.php

Change-Id: I3b26f0f8bc33562cc078ecb31c91332985058b2c

1  2 
tests/tine20/TestCase.php
tine20/Setup/Frontend/Cli.php
tine20/Setup/Server/Cli.php
tine20/Tinebase/User.php
tine20/Tinebase/User/Sql.php

Simple merge
Simple merge
Simple merge
Simple merge
@@@ -1063,83 -1040,18 +1063,100 @@@ class Tinebase_User_Sql extends Tinebas
      }
  
      /**
-         if (! isset($schema['creation_time'])) {
++<<<<<<< HEAD
 +     * send deactivation email to user
 +     * 
 +     * @param mixed $accountId
 +     */
 +    public function sendDeactivationNotification($accountId)
 +    {
 +        if (! Tinebase_Config::getInstance()->get(Tinebase_Config::ACCOUNT_DEACTIVATION_NOTIFICATION)) {
 +            if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(
 +                __METHOD__ . '::' . __LINE__ . ' Deactivation notification disabled.');
 +            return;
 +        }
 +        
 +        try {
 +            $user = $this->getFullUserById($accountId);
 +            
 +            if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(
 +                __METHOD__ . '::' . __LINE__ . ' Send deactivation notification to user ' . $user->accountLoginName);
 +            
 +            $translate = Tinebase_Translation::getTranslation('Tinebase');
 +            
 +            $view = new Zend_View();
 +            $view->setScriptPath(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'views');
 +            
 +            $view->translate            = $translate;
 +            $view->accountLoginName     = $user->accountLoginName;
 +            // TODO add this?
 +            //$view->deactivationDate     = $user->deactivationDate;
 +            $view->tine20Url            = Tinebase_Core::getHostname();
 +            
 +            $messageBody = $view->render('deactivationNotification.php');
 +            $messageSubject = $translate->_('Your Tine 2.0 account has been deactivated');
 +            
 +            $recipient = Addressbook_Controller_Contact::getInstance()->getContactByUserId($user->getId(), /* $_ignoreACL = */ true);
 +            Tinebase_Notification::getInstance()->send(/* sender = */ null, array($recipient), $messageSubject, $messageBody);
 +            
 +        } catch (Exception $e) {
 +            Tinebase_Exception::log($e);
 +        }
 +    }
 +
 +
 +    /**
 +     * returns number of current non-system users
 +     *
 +     * @return number
 +     */
 +    public function countNonSystemUsers()
 +    {
 +        $select = $select = $this->_db->select()
 +            ->from(SQL_TABLE_PREFIX . 'accounts', 'COUNT(id)')
 +            ->where($this->_db->quoteIdentifier('login_name') . " not in ('cronuser', 'calendarscheduling')");
 +        $userCount = $this->_db->fetchOne($select);
 +        return $userCount;
 +    }
 +
 +    /**
 +     * fetch creation time of the first/oldest user
 +     *
 +     * @return Tinebase_DateTime
 +     */
 +    public function getFirstUserCreationTime()
 +    {
 +        $schema = Tinebase_Db_Table::getTableDescriptionFromCache($this->_db->table_prefix . $this->_tableName, $this->_db);
 +        $fallback = new Tinebase_DateTime('2014-12-01');
-         $result = (! empty($creationTime)) ? new Tinebase_DateTime($creationTime) : $fallback;
++        if (!isset($schema['creation_time'])) {
 +            return $fallback;
 +        }
 +
 +        $select = $select = $this->_db->select()
 +            ->from(SQL_TABLE_PREFIX . 'accounts', 'creation_time')
 +            ->where($this->_db->quoteIdentifier('login_name') . " not in ('cronuser', 'calendarscheduling')")
 +            ->where($this->_db->quoteIdentifier('creation_time') . " is not null")
 +            ->order('creation_time ASC')
 +            ->limit(1);
 +        $creationTime = $this->_db->fetchOne($select);
 +
++        $result = (!empty($creationTime)) ? new Tinebase_DateTime($creationTime) : $fallback;
 +        return $result;
 +    }
++
++    /**
+      * fetch all user ids from accounts table
+      *
+      * @return array
+      */
+     public function getAllUserIdsFromSqlBackend()
+     {
+         $sqlbackend = new Tinebase_Backend_Sql(array(
+             'modelName' => 'Tinebase_Model_FullUser',
+             'tableName' => $this->_tableName,
+         ));
+         $userIds = $sqlbackend->search(null, null, Tinebase_Backend_Sql_Abstract::IDCOL);
+         return $userIds;
+     }
  }