/** * get note type by name * * @param string $_name * @return Tinebase_Model_NoteType * @throws Tinebase_Exception_NotFound */ public function getNoteTypeByName($_name) { $row = $this->_noteTypesTable->fetchRow($this->_db->quoteInto($this->_db->quoteIdentifier('name') . ' = ?', $_name)); if (!$row) { throw new Tinebase_Exception_NotFound('Note type not found.'); } return new Tinebase_Model_NoteType($row->toArray()); }
/** * add single role rights * * @param int $_roleId * @param int $_applicationId * @param string $_right */ public function addSingleRight($_roleId, $_applicationId, $_right) { // check if already in $select = $this->_roleRightsTable->select(); $select->where($this->_db->quoteInto($this->_db->quoteIdentifier('role_id') . ' = ?', $_roleId))->where($this->_db->quoteInto($this->_db->quoteIdentifier('right') . ' = ?', $_right))->where($this->_db->quoteInto($this->_db->quoteIdentifier('application_id') . ' = ?', $_applicationId)); if (!($row = $this->_roleRightsTable->fetchRow($select))) { $data = array('role_id' => $_roleId, 'application_id' => $_applicationId, 'right' => $_right); $this->_roleRightsTable->insert($data); } }
/** * check if relation already exists but is_deleted * * @param Tinebase_Model_Relation $_relation * @return string relation id */ protected function _checkExistance($_relation) { $where = array($this->_db->quoteInto($this->_db->quoteIdentifier('own_model') . ' = ?', $_relation->own_model), $this->_db->quoteInto($this->_db->quoteIdentifier('own_backend') . ' = ?', $_relation->own_backend), $this->_db->quoteInto($this->_db->quoteIdentifier('own_id') . ' = ?', $_relation->own_id), $this->_db->quoteInto($this->_db->quoteIdentifier('related_id') . ' = ?', $_relation->related_id), $this->_db->quoteIdentifier('is_deleted') . ' = 1'); $relationRow = $this->_dbTable->fetchRow($where); if ($relationRow) { return $relationRow->rel_id; } else { return FALSE; } }
/** * checks if email is in invitations table * * @param string $_email * @return bool true if email is in invitations table * @todo add to tests */ public function checkInvitation($_email) { $where = $this->_db->quoteInto($this->_db->quoteIdentifier('email') . ' = ?', $_email); if ($row = $this->_invitationsTable->fetchRow($where)) { // remove from table $this->_invitationsTable->delete($where); $result = true; } else { $result = false; } return $result; }
/** * registers new persistent observer * * @param Tinebase_Model_PersistentObserver $_persistentObserver * @return Tinebase_Model_PersistentObserver the new persistentObserver */ public function addObserver($_persistentObserver) { if ($_persistentObserver->getId()) { throw new Tinebase_Exception_Record_NotAllowed('Could not add existing observer'); } $_persistentObserver->created_by = Tinebase_Core::getUser()->getId(); $_persistentObserver->creation_time = Tinebase_DateTime::now(); if ($_persistentObserver->isValid()) { $data = $_persistentObserver->toArray(); // resolve apps $application = Tinebase_Application::getInstance(); $data['observable_application'] = $application->getApplicationByName($_persistentObserver->observable_application)->id; $data['observer_application'] = $application->getApplicationByName($_persistentObserver->observer_application)->id; $identifier = $this->_db->insert($data); $persistentObserver = $this->_db->fetchRow("identifier = {$identifier}"); return new Tinebase_Model_PersistentObserver($persistentObserver->toArray(), true); } else { throw new Tinebase_Exception_Record_Validation('some fields have invalid content'); } }
/** * Returns Status identifier * * @param string $_egw14Status * @return id identifier */ protected static function getStatus($_egw14Status) { static $stati; $oldstatus = strtoupper($_egw14Status); if (!isset($stati[$oldstatus])) { $statusTable = new Tinebase_Db_Table(array('name' => SQL_TABLE_PREFIX . 'tasks_status')); $status = $statusTable->fetchRow($statusTable->getAdapter()->quoteInto('status LIKE ?', $oldstatus)); if (!$status) { $identifier = $statusTable->insert(array('created_by' => Tinebase_Core::getUser()->getId(), 'creation_time' => Tinebase_DateTime::now()->get(Tinebase_Record_Abstract::ISO8601LONG), 'status' => $oldstatus)); $stati[$oldstatus] = $identifier; } else { $stati[$oldstatus] = $status->identifier; } } return $stati[$oldstatus]; }
/** * get prefered extension of this account * * @param int $_accountId the id of the account to get the prefered extension for * @return array * @throws Phone_Exception_NotFound */ public function getPreferedExtension($_accountId) { $accountId = Tinebase_Model_User::convertUserIdToInt($_accountId); $extensionsTable = new Tinebase_Db_Table(array('name' => SQL_TABLE_PREFIX . 'phone_extensions')); $select = $extensionsTable->select()->where($this->_db->quoteIdentifier('account_id') . ' = ?', $accountId); $row = $extensionsTable->fetchRow($select); if ($row === NULL) { throw new Phone_Exception_NotFound('No prefered extension found.'); } return $row->toArray(); }