/** * delete user by id * * @param Tinebase_Model_FullUser $_user */ public function inspectDeleteUser(Tinebase_Model_FullUser $_user) { Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Delete Dbmail settings for user ' . $_user->accountLoginName); if ($this->_hasTine20Userid === true) { $where = array($this->_db->quoteInto($this->_db->quoteIdentifier($this->_propertyMapping['emailUserId']) . ' = ?', $_user->getId()), $this->_db->quoteInto($this->_db->quoteIdentifier($this->_propertyMapping['emailGID']) . ' = ?', $this->_config['emailGID'])); } else { $where = array($this->_db->quoteInto($this->_db->quoteIdentifier($this->_propertyMapping['emailUserId']) . ' = ?', $this->_convertToInt($_user->getId())), $this->_db->quoteInto($this->_db->quoteIdentifier($this->_propertyMapping['emailGID']) . ' = ?', $this->_convertToInt($this->_config['emailGID']))); } if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) { Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . " delete from {$this->_userTable} " . print_r($where, true)); } $this->_db->delete($this->_userTable, $where); }
/** * check if old entry exists and delete it * * @param array $_userData */ protected function _checkOldUserRecord($_userData) { $userIdProperty = $this->_propertyMapping['emailUsername']; $where = $this->_db->quoteInto($this->_db->quoteIdentifier($userIdProperty) . ' = ?', $_userData[$userIdProperty]); $select = $this->_db->select(); $select->from(array($this->_userTable => $this->_userTable), array($userIdProperty))->where($where)->limit(1); $stmt = $this->_db->query($select); $queryResult = $stmt->fetch(); if ($queryResult) { if (Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) { Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__ . " Delete existing userid {$_userData[$userIdProperty]} from {$this->_userTable}"); } $this->_db->delete($this->_userTable, $where); } }
/** * Write a message to the log. * * @param array $event event data * @return void * @throws Zend_Log_Exception */ protected function _write($event) { $config = Zend_Registry::get('config'); $isLogMsg = (bool) $config['logging']['log']['enable']; $isLogStat = (bool) $config['logging']['statistics']['enable']; $isLogEx = (bool) $config['logging']['exeption']['enable']; // Проверим возможность логирования if ($this->_table == 'log_msg' && !$isLogMsg) { return; } elseif ($this->_table == 'log_stat' && !$isLogStat) { return; } elseif ($this->_table == 'log_error' && !$isLogEx) { return; } // Удалим лишние записи if ($this->_max_rows && $this->_max_rows !== -1) { $select = $this->_db->select(); $select->from($this->_table, 'count(*)'); $count_rows = (int) $this->_db->fetchOne($select); if ($count_rows >= $this->_max_rows) { // Получим массив ids для удаления строк в таблице $limit = $count_rows - $this->_max_rows; $limit++; $select = $this->_db->select(); $select->from($this->_table, 'id'); $select->limit($limit, 0); $row_ids = $this->_db->fetchCol($select); // Удалим строки из таблицы foreach ($row_ids as $id) { $this->_db->delete($this->_table, 'id=' . $id); } } } // Запишем событие в лог parent::_write($event); }
/** * Deletes existing rows. * * The WHERE clause must be in native (underscore) format. * * @param string $where An SQL WHERE clause. * @return int The number of rows deleted. */ public function delete($where) { return $this->_db->delete($this->_name, $where); }
/** * Remove any data associated with a tweet. * @param int $id */ public function reset($id) { $this->adapter->delete('tweetist', array('dataset = ' . $this->dataset, 'tweet = ' . $id)); }
/** * delete user by id * * @param Tinebase_Model_FullUser $_user */ public function inspectDeleteUser(Tinebase_Model_FullUser $_user) { if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) { Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Delete Dovecot settings for user ' . $_user->accountLoginName); } $where = array($this->_db->quoteInto($this->_db->quoteIdentifier($this->_propertyMapping['emailUserId']) . ' = ?', $_user->getId())); // append domain if set or domain IS NULL if (array_key_exists('domain', $this->_config) && !empty($this->_config['domain'])) { $where[] = $this->_db->quoteInto($this->_db->quoteIdentifier($this->_userTable . '.' . 'domain') . ' = ?', $this->_config['domain']); } else { $where[] = $this->_db->quoteIdentifier($this->_userTable . '.' . 'domain') . " =''"; } $this->_db->delete($this->_userTable, $where); }
/** * set email aliases and forwards * * removes all aliases for user * creates default email->email alias if not forward only * creates aliases * creates forwards * * @param array $_smtpSettings as returned from _recordToRawData * @return void */ protected function _setAliases($_smtpSettings) { #if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Setting default alias/forward for ' . print_r($_smtpSettings, true)); // remove all current aliases and forwards for user $where = array($this->_db->quoteInto($this->_db->quoteIdentifier($this->_propertyMapping['emailUserId']) . ' = ?', $_smtpSettings[$this->_propertyMapping['emailUserId']])); $this->_db->delete($this->_destinationTable, $where); #if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Setting default alias/forward for ' . $_smtpSettings[$this->_propertyMapping['emailUsername']]); // create default alias/forward // check if it should be forward only if (!$_smtpSettings[$this->_propertyMapping['emailForwardOnly']]) { // create email -> username alias $aliasArray = array('userid' => $_smtpSettings[$this->_propertyMapping['emailUserId']], 'source' => $_smtpSettings[$this->_propertyMapping['emailAddress']], 'destination' => $_smtpSettings[$this->_propertyMapping['emailUsername']]); // insert into table $this->_db->insert($this->_destinationTable, $aliasArray); // create username -> username alias if email and username are different if ($_smtpSettings[$this->_propertyMapping['emailUsername']] != $_smtpSettings[$this->_propertyMapping['emailAddress']]) { $aliasArray = array('userid' => $_smtpSettings[$this->_propertyMapping['emailUserId']], 'source' => $_smtpSettings[$this->_propertyMapping['emailUsername']], 'destination' => $_smtpSettings[$this->_propertyMapping['emailUsername']]); // insert into table $this->_db->insert($this->_destinationTable, $aliasArray); } } // Set Aliases #if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Setting aliases for ' . $_smtpSettings[$this->_propertyMapping['emailUsername']] . ': ' . print_r($_smtpSettings[$this->_propertyMapping['emailAliases']], TRUE)); if (array_key_exists($this->_propertyMapping['emailAliases'], $_smtpSettings) && is_array($_smtpSettings[$this->_propertyMapping['emailAliases']])) { foreach ($_smtpSettings[$this->_propertyMapping['emailAliases']] as $aliasAddress) { // check if in primary or secondary domains if (!empty($aliasAddress) && $this->_checkDomain($aliasAddress)) { // create alias -> email $aliasArray = array('userid' => $_smtpSettings[$this->_propertyMapping['emailUserId']], 'source' => $aliasAddress, 'destination' => $_smtpSettings[$this->_propertyMapping['emailAddress']]); // insert into table $this->_db->insert($this->_destinationTable, $aliasArray); } } } // Set Forwards #if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Setting forwards for ' . $_smtpSettings[$this->_propertyMapping['emailUsername']] . ': ' . print_r($_smtpSettings[$this->_propertyMapping['emailForwards']], TRUE)); if (array_key_exists($this->_propertyMapping['emailForwards'], $_smtpSettings) && is_array($_smtpSettings[$this->_propertyMapping['emailForwards']])) { foreach ($_smtpSettings[$this->_propertyMapping['emailForwards']] as $forwardAddress) { if (!empty($forwardAddress)) { // create email -> forward $forwardArray = array('userid' => $_smtpSettings[$this->_propertyMapping['emailUserId']], 'source' => $_smtpSettings[$this->_propertyMapping['emailAddress']], 'destination' => $forwardAddress); // insert into table $this->_db->insert($this->_destinationTable, $forwardArray); } } } }