示例#1
0
 public function generateCodeForUser($userId)
 {
     $data = array('userId' => $userId, 'code' => md5(microtime()));
     $thisCode = $this->find($userId);
     if (is_null($thisCode)) {
         parent::insert($data);
     } else {
         parent::update($data, null);
     }
     return $data['code'];
 }
示例#2
0
 public function regenerateApiKey($appId)
 {
     $data = array('appId' => $appId, 'apiKey' => $this->_generateApiKey());
     return parent::update($data);
 }
示例#3
0
 public function insert(array $data)
 {
     $tagId = parent::insert($data);
     //$this->index($tagId, $data['name']);
     return $tagId;
 }
示例#4
0
 /**
  * Fetches one row.
  *
  * Honors the Zend_Db_Adapter_Abstract fetch mode.
  *
  * @param string|array $where OPTIONAL An SQL WHERE clause.
  * @param string|array $order OPTIONAL An SQL ORDER clause.
  * @return Zend_Db_Table_Row The row results per the Zend_Db_Adapter_Abstract fetch mode.
  */
 public function fetchRow($where = null, $order = null, $offset = null)
 {
     $result = parent::fetchRow($where, $order, $offset)->toArray();
     $result['zendMailObject'] = unserialize($result['zendMailObject']);
     return $result;
 }
示例#5
0
 /**
  * deletes a role from the db
  *
  * @param unknown_type $where
  */
 public function delete($where)
 {
     parent::delete($where);
     $this->_clearCache();
 }
示例#6
0
 public function delete($where)
 {
     $inTransaction = false;
     //whether or not we're in a transaction prior to this
     $dba = $this->getAdapter();
     try {
         $dba->beginTransaction();
     } catch (Exception $e) {
         $inTransaction = true;
     }
     $thisAccount = $this->fetchRow($where);
     $accountRoles = new Ot_Model_DbTable_AccountRoles();
     $apiApps = new Ot_Model_DbTable_ApiApp();
     $aar = new Ot_Account_Attribute_Register();
     $cahr = new Ot_CustomAttribute_HostRegister();
     $thisHost = $cahr->getHost('Ot_Profile');
     try {
         $deleteResult = parent::delete($where);
         $accountRoles->delete($where);
         $apiApps->delete($where);
         $aar->delete($thisAccount->accountId);
         $thisHost->delete($thisAccount->accountId);
     } catch (Exception $e) {
         if (!$inTransaction) {
             $dba->rollback();
         }
         throw new Ot_Exception('Account delete failed.');
     }
     if (!$inTransaction) {
         $dba->commit();
     }
     return $deleteResult;
 }
示例#7
0
 public function update(array $data, $where)
 {
     $keys = array();
     $dba = $this->getAdapter();
     $inTransaction = false;
     try {
         $dba->beginTransaction();
     } catch (Exception $e) {
         $inTransaction = true;
     }
     $evaluationKey = new Evaluation_Key();
     if ($data['evaluationType'] == 'google') {
         $keys['eventId'] = $data['eventId'];
         $keys['formKey'] = $data['formKey'];
         $keys['answerKey'] = $data['answerKey'];
         try {
             $evaluationKey->update($keys, null);
         } catch (Exception $e) {
             $dba->rollBack();
             throw $e;
         }
     } elseif ($data['evaluationType'] == 'default') {
         $where = $evaluationKey->getAdapter()->quoteInto('eventId = ?', $data['eventId']);
         try {
             $evaluationKey->delete($where);
         } catch (Exception $e) {
             $dba->rollBack();
             throw $e;
         }
     }
     unset($data['formKey'], $data['answerKey']);
     try {
         parent::update($data, $where);
     } catch (Exception $e) {
         $dba->rollBack();
         throw $e;
     }
     if (!$inTransaction) {
         $dba->commit();
     }
 }
示例#8
0
 /**
  * Gets all the bugs, with options to only show new bugs
  *
  * @param boolean $newOnly
  * @return result from fetchAll
  */
 public function getBugText($bugId, $order = 'ASC')
 {
     $where = $this->getAdapter()->quoteInto('bugId = ?', $bugId);
     return parent::fetchAll($where, 'postDt ' . $order);
 }
示例#9
0
 /**
  * Gets all the bugs, with options to only show new bugs
  *
  * @param boolean $newOnly
  * @return result from fetchAll
  */
 public function getBugs($newOnly = true)
 {
     if ($newOnly) {
         $where = $this->getAdapter()->quoteInto('status IN (?)', array('new', 'escalated'));
     } else {
         $where = null;
     }
     return parent::fetchAll($where, 'submitDt DESC');
 }