Author: Mike Naberezny (mike@maintainable.com)
Author: Derek DeVries (derek@maintainable.com)
Author: Chuck Hagenbuch (chuck@horde.org)
示例#1
0
 /**
  */
 protected function _setSimplifiedType()
 {
     if (Horde_String::lower($this->_sqlType) == 'number' && $this->_precision == 1) {
         $this->_type = 'boolean';
         return;
     }
     parent::_setSimplifiedType();
 }
示例#2
0
 /**
  * @param   mixed  $value
  * @return  boolean
  */
 public function valueToBoolean($value)
 {
     if ($value == '"t"' || $value == "'t'") {
         return true;
     } elseif ($value == '""' || $value == "''") {
         return null;
     } else {
         return parent::valueToBoolean($value);
     }
 }
示例#3
0
文件: Column.php 项目: horde/horde
 /**
  */
 protected function _setSimplifiedType()
 {
     if (strpos(Horde_String::lower($this->_sqlType), 'tinyint(1)') !== false) {
         $this->_type = 'boolean';
         return;
     } elseif (preg_match('/enum/i', $this->_sqlType)) {
         $this->_type = 'string';
         return;
     }
     parent::_setSimplifiedType();
 }
示例#4
0
 /**
  * @param   string  $sqlType
  * @return  int
  */
 protected function _extractScale($sqlType)
 {
     if (preg_match('/^money/', $sqlType)) {
         return 2;
     }
     return parent::_extractScale($sqlType);
 }
示例#5
0
文件: Sql.php 项目: DSNS-LAB/Dmail
 /**
  *
  * @param array $row           Hash of the note data, db keys.
  * @param string  $passphrase  The encryption passphrase.
  *
  * @return array a Task hash.
  * @throws Mnemo_Exception
  */
 protected function _buildNote($row, $passphrase = null)
 {
     // Make sure notes always have a UID.
     if (empty($row['memo_uid'])) {
         $row['memo_uid'] = strval(new Horde_Support_Guid());
         $query = 'UPDATE ' . $this->_table . ' SET memo_uid = ?' . ' WHERE memo_owner = ? AND memo_id = ?';
         $values = array($row['memo_uid'], $row['memo_owner'], $row['memo_id']);
         try {
             $this->_db->update($query, $values);
         } catch (Horde_Db_Exception $e) {
             throw new Mnemo_Exception($e->getMessage());
         }
     }
     // Decrypt note if requested.
     $encrypted = false;
     $body = $this->_column->binaryToString($row['memo_body']);
     $body = Horde_String::convertCharset($body, $this->_charset, 'UTF-8');
     if (strpos($body, '-----BEGIN PGP MESSAGE-----') === 0) {
         $encrypted = true;
         if (empty($passphrase)) {
             $passphrase = Mnemo::getPassphrase($row['memo_id']);
         }
         if (empty($passphrase)) {
             $body = new Mnemo_Exception(_("This note has been encrypted."), Mnemo::ERR_NO_PASSPHRASE);
         } else {
             try {
                 $body = $this->_decrypt($body, $passphrase);
                 $body = $body->message;
             } catch (Mnemo_Exception $e) {
                 $body = $e;
             }
             Mnemo::storePassphrase($row['memo_id'], $passphrase);
         }
     }
     // Create a new note based on $row's values.
     $uid = Horde_String::convertCharset($row['memo_uid'], $this->_charset, 'UTF-8');
     $memo = array('memolist_id' => $row['memo_owner'], 'memo_id' => $row['memo_id'], 'uid' => $uid, 'desc' => Horde_String::convertCharset($row['memo_desc'], $this->_charset, 'UTF-8'), 'body' => $body, 'tags' => $GLOBALS['injector']->getInstance('Mnemo_Tagger')->getTags($uid, 'note'), 'encrypted' => $encrypted);
     try {
         $userId = $GLOBALS['registry']->getAuth();
         $log = $GLOBALS['injector']->getInstance('Horde_History')->getHistory('mnemo:' . $row['memo_owner'] . ':' . $row['memo_uid']);
         foreach ($log as $entry) {
             switch ($entry['action']) {
                 case 'add':
                     $memo['created'] = new Horde_Date($entry['ts']);
                     if ($userId != $entry['who']) {
                         $memo['createdby'] = sprintf(_("by %s"), Mnemo::getUserName($entry['who']));
                     } else {
                         $memo['createdby'] = _("by me");
                     }
                     break;
                 case 'modify':
                     $memo['modified'] = new Horde_Date($entry['ts']);
                     if ($userId != $entry['who']) {
                         $memo['modifiedby'] = sprintf(_("by %s"), Mnemo::getUserName($entry['who']));
                     } else {
                         $memo['modifiedby'] = _("by me");
                     }
                     break;
             }
         }
     } catch (Horde_Exception $e) {
     }
     return $memo;
 }