public function testConstructFromIsoString() { $dt = new Tinebase_DateTime('2010-06-25 18:04:00'); $this->assertEquals('1277489040', $dt->getTimestamp()); // after 32 Bit timestamp overflow (2038-01-19 03:14:07) $dt = new Tinebase_DateTime('2040-06-25 18:04:00'); $this->assertEquals('2224260240', $dt->getTimestamp()); }
/** * inspect set expiry date * * @param Tinebase_DateTime $_expiryDate the expirydate * @param array $_ldapData the data to be written to ldap */ public function inspectExpiryDate($_expiryDate, array &$_ldapData) { if ($_expiryDate instanceof Tinebase_DateTime) { // seconds since Jan 1, 1970 $_ldapData['sambakickofftime'] = $_expiryDate->getTimestamp(); } else { $_ldapData['sambakickofftime'] = array(); } }
/** * sets/unsets expiry date in ldap backend * * expiryDate is the number of days since Jan 1, 1970 * * @param mixed $_accountId * @param Tinebase_DateTime $_expiryDate */ public function setExpiryDateInSyncBackend($_accountId, $_expiryDate) { if ($this->_isReadOnlyBackend) { return; } $metaData = $this->_getMetaData($_accountId); if ($_expiryDate instanceof DateTime) { // days since Jan 1, 1970 $ldapData = array('shadowexpire' => floor($_expiryDate->getTimestamp() / 86400)); } else { $ldapData = array('shadowexpire' => array()); } foreach ($this->_ldapPlugins as $plugin) { $plugin->inspectExpiryDate($_expiryDate, $ldapData); } if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) { Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . " {$metaData['dn']} ldapData: " . print_r($ldapData, true)); } $this->_ldap->update($metaData['dn'], $ldapData); }
/** * appends filter to egw14 select obj. for raw event retirval * * @param Zend_Db_Select $_select * @return void */ protected function _appendRecordFilter($_select) { $_select->where($this->_egwDb->quoteInto($this->_egwDb->quoteIdentifier('cal_reference') . ' = ?', 0)); parent::_appendRecordFilter($_select); if ($this->_config->importStartDate) { $importStartDate = new Tinebase_DateTime($this->_config->importStartDate); $_select->where($this->_egwDb->quoteIdentifier('records.cal_id') . " IN (SELECT DISTINCT(cal_id) FROM egw_cal_dates WHERE cal_end > {$importStartDate->getTimestamp()})"); } }
/** * sets/unsets expiry date in ldap backend * * @param mixed $_accountId * @param Tinebase_DateTime $_expiryDate */ public function setExpiryDateInSyncBackend($_accountId, $_expiryDate) { if ($this->_isReadOnlyBackend) { return; } $metaData = $this->_getMetaData($_accountId); if ($_expiryDate instanceof DateTime) { $ldapData['accountexpires'] = bcmul(bcadd($_expiryDate->getTimestamp(), '11644473600'), '10000000'); if ($this->_options['useRfc2307']) { // days since Jan 1, 1970 $ldapData = array_merge($ldapData, array('shadowexpire' => floor($_expiryDate->getTimestamp() / 86400))); } } else { $ldapData = array('accountexpires' => '9223372036854775807'); if ($this->_options['useRfc2307']) { $ldapData = array_merge($ldapData, array('shadowexpire' => array())); } } foreach ($this->_ldapPlugins as $plugin) { $plugin->inspectExpiryDate($_expiryDate, $ldapData); } if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) { Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . " {$metaData['dn']} {$ldapData}: " . print_r($ldapData, true)); } $this->_ldap->update($metaData['dn'], $ldapData); }
/** * sets/unsets expiry date (calls backend class with the same name) * * @param int $_accountId * @param Tinebase_DateTime $_expiryDate */ public function setExpiryDate($_accountId, $_expiryDate) { $metaData = $this->_getMetaData($_accountId); $data = array('shadowexpire' => $_expiryDate->getTimestamp()); $this->_backend->update($metaData['dn'], $data); }
/** * set the status of the user * * @param mixed $_accountId * @param string $_status * @return unknown */ public function setStatus($_accountId, $_status) { if ($this instanceof Tinebase_User_Interface_SyncAble) { $this->setStatusInSyncBackend($_accountId, $_status); } $accountId = Tinebase_Model_User::convertUserIdToInt($_accountId); switch ($_status) { case 'enabled': $accountData[$this->rowNameMapping['loginFailures']] = 0; $accountData[$this->rowNameMapping['accountExpires']] = null; $accountData['status'] = $_status; break; case 'disabled': $accountData['status'] = $_status; break; case 'expired': $accountData['expires_at'] = Tinebase_DateTime::getTimestamp(); break; default: throw new Tinebase_Exception_InvalidArgument('$_status can be only enabled, disabled or expired'); break; } $accountsTable = new Tinebase_Db_Table(array('name' => SQL_TABLE_PREFIX . 'accounts')); $where = array($this->_db->quoteInto($this->_db->quoteIdentifier('id') . ' = ?', $accountId)); $result = $accountsTable->update($accountData, $where); return $result; }