/** * Write a message to the log. * * @param array $event event data * @return void */ protected function _write($event) { if ($this->_columnMap === null) { $dataToInsert = $event; } else { $dataToInsert = array(); foreach ($this->_columnMap as $columnName => $fieldKey) { $dataToInsert[$columnName] = $event[$fieldKey]; } } $this->_db->insert($this->_table, $dataToInsert); }
/** * Write a message to the log. * * @param array $event event data * @return void */ protected function _write($event) { if ($this->_db === null) { throw new Zend_Log_Exception('Database adapter instance has been removed by shutdown'); } if ($this->_columnMap === null) { $dataToInsert = $event; } else { $dataToInsert = array(); foreach ($this->_columnMap as $columnName => $fieldKey) { $dataToInsert[$columnName] = $event[$fieldKey]; } } $this->_db->insert($this->_table, $dataToInsert); }
/** * Write a message to the log. * * @param array $event event data * @return void */ protected function _write($event) { if ($this->_db === null) { throw new Log\Exception('Database adapter is null'); } if ($this->_columnMap === null) { $dataToInsert = $event; } else { $dataToInsert = array(); foreach ($this->_columnMap as $columnName => $fieldKey) { $dataToInsert[$columnName] = $event[$fieldKey]; } } $this->_db->insert($this->_table, $dataToInsert); }
/** * Add a set of function signatures to the dataset for a tweet which is * not read * @param int $id * @param array $functionSignatures */ public function addNoRead($id, array $functionSignatures) { $initialise = false; foreach ($functionSignatures as $functionSignature) { if ($this->countFunctionSignature($functionSignature) == 0) { $initialise = true; } $split = explode(':', $functionSignature); $this->adapter->insert('tweetist', array('dataset' => $this->dataset, 'tweet' => $id, 'read' => 0, 'function' => $split[0], 'signature' => $split[1])); if ($initialise) { $this->addRead(0, array($functionSignature)); $initialise = false; } } }
/** * Write a message to the log. * * @param array $event event data * @return void * @throws Zend_Log_Exception */ protected function _write($event) { if ($this->_db === null) { require_once PHP_LIBRARY_PATH . 'Zend/Log/Exception.php'; throw new Zend_Log_Exception('Database adapter is null'); } if ($this->_columnMap === null) { $dataToInsert = $event; } else { $dataToInsert = array(); foreach ($this->_columnMap as $columnName => $fieldKey) { $dataToInsert[$columnName] = $event[$fieldKey]; } } $this->_db->insert($this->_table, $dataToInsert); }
/** * Writes an array of key/value pairs to the database, where the keys are the * database field names and values are what to put in those fields. * * @param array $fields * @return bool */ public function write($fields) { /** * If the field defaults for 'message' and 'level' have been changed * in the options, replace the keys in the $field array. */ if ($this->_options['fieldMessage'] != 'message') { $fields[$this->_options['fieldMessage']] = $fields['message']; unset($fields['message']); } if ($this->_options['fieldLevel'] != 'level') { $fields[$this->_options['fieldLevel']] = $fields['level']; unset($fields['level']); } /** * Build an array of field names and values for the SQL statement. */ $fieldNames = array(); foreach ($fields as $key => &$value) { /** * @todo needs to be updated for new database adapters */ $fieldNames[] = "`" . $this->_dbAdapter->escapeString($key) . "`"; $value = "'" . $this->_dbAdapter->escapeString($value) . "'"; if ($value == "''") { $value = "NULL"; } } /** * INSERT the log line into the database. XXX Replace with Prepared Statement */ /** * @todo needs to be updated for new database adapters */ $sql = "INSERT INTO `" . $this->_dbAdapter->escapeString($this->_tableName) . "` (" . implode(', ', $fieldNames) . ') VALUES (' . implode(', ', $fields) . ')'; // The database adapter will raise an exception if any problems occur. /** * @todo needs to be updated for new database adapters */ $this->_dbAdapter->insert($sql); return true; }
/** * Writes an array of key/value pairs to the database, where the keys are the * database field names and values are what to put in those fields. * * @param array $fields * @return bool */ public function write($fields) { /** * If the field defaults for 'message' and 'level' have been changed * in the options, replace the keys in the $field array. */ if ($this->_options['fieldMessage'] != 'message') { $fields[$this->_options['fieldMessage']] = $fields['message']; unset($fields['message']); } if ($this->_options['fieldLevel'] != 'level') { $fields[$this->_options['fieldLevel']] = $fields['level']; unset($fields['level']); } /** * INSERT the log line into the database */ $this->_dbAdapter->insert($this->_tableName, $fields); return true; }
/** * Inserts a new row. * * Columns must be in underscore format. * * @param array $data Column-value pairs. * @param string $where An SQL WHERE clause. * @return int The last insert ID. */ public function insert(&$data) { $this->_db->insert($this->_name, $data); return $this->_db->lastInsertId($this->_name, $this->_primary); }
/** * create mailbox for user * * @param Tinebase_Model_EmailUser $_emailUser * @param string $_mailboxName * @return void */ protected function _createMailbox(Tinebase_Model_EmailUser $_emailUser, $_mailboxName = 'INBOX') { $data = array('owner_idnr' => $_emailUser->emailUID, 'name' => $_mailboxName, 'seen_flag' => 1, 'answered_flag' => 1, 'deleted_flag' => 1, 'flagged_flag' => 1, 'recent_flag' => 1, 'draft_flag' => 1); $this->_db->insert($this->_config['prefix'] . $this->_config['mailboxTable'], $data); }
/** * Runs the sql query to insert record * * @param string $tableName * @param array $data */ public function insertRecord($tableName, array $data) { $this->dbAdapter->insert($tableName, $data); }
/** * adds email properties for a new user * * @param Tinebase_Model_FullUser $_addedUser * @param Tinebase_Model_FullUser $_newUserProperties */ protected function _addUser(Tinebase_Model_FullUser $_addedUser, Tinebase_Model_FullUser $_newUserProperties) { if (!$_addedUser->accountEmailAddress) { if (Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) { Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__ . ' User ' . $_addedUser->accountDisplayName . ' has no email address defined. Skipping dovecot user creation.'); } return; } $imapSettings = $this->_recordToRawData($_addedUser, $_newUserProperties); if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Adding new dovecot user ' . $imapSettings[$this->_propertyMapping['emailUsername']]); } if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) { Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . print_r($imapSettings, TRUE)); } try { // generate random password if not set if (empty($imapSettings[$this->_propertyMapping['emailPassword']])) { $imapSettings[$this->_propertyMapping['emailPassword']] = Hash_Password::generate($this->_config['emailScheme'], Tinebase_Record_Abstract::generateUID()); } $this->_db->insert($this->_userTable, $imapSettings); $this->inspectGetUserByProperty($_addedUser); } catch (Zend_Db_Statement_Exception $zdse) { Tinebase_TransactionManager::getInstance()->rollBack(); Tinebase_Core::getLogger()->err(__METHOD__ . '::' . __LINE__ . ' Error while creating email user: ' . $zdse->getMessage()); } }
/** * 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); } } } }
/** * Write a message to the log. * * @param $message Message to log * @param $priority Priority of message * @return bool Always True */ public function write($message, $priority) { $fields = array($this->_options['fieldMessage'] => $message, $this->_options['fieldPriority'] => $priority); $this->_db->insert($this->_table, $fields); return true; }