/**
  * check if record with given $id exists
  * 
  * @param string $id
  * @return boolean
  */
 public function exists($id)
 {
     $this->_checkRight('get');
     try {
         $record = $this->_backend->get($id);
         $result = $this->_checkGrant($record, 'get', FALSE);
     } catch (Tinebase_Exception_NotFound $tenf) {
         $result = FALSE;
     }
     return $result;
 }
Example #2
0
 /**
  * get by id
  *
  * @param string $_id
  * @param int $_containerId
  * @return Tinebase_Record_Interface
  * @throws  Tinebase_Exception_AccessDenied
  */
 public function get($_id, $_containerId = NULL)
 {
     $this->_checkRight('get');
     if (!$_id) {
         // yes, we mean 0, null, false, ''
         $record = new $this->_modelName(array(), true);
         if ($this->_doContainerACLChecks) {
             if ($_containerId === NULL) {
                 $containers = Tinebase_Container::getInstance()->getPersonalContainer($this->_currentAccount, $this->_applicationName, $this->_currentAccount, Tinebase_Model_Grants::GRANT_ADD);
                 $record->container_id = $containers[0]->getId();
             } else {
                 $record->container_id = $_containerId;
             }
         }
     } else {
         $record = $this->_backend->get($_id);
         $this->_checkGrant($record, 'get');
         // get tags / notes / relations / alarms
         if ($record->has('tags')) {
             Tinebase_Tags::getInstance()->getTagsOfRecord($record);
         }
         if ($record->has('notes')) {
             $record->notes = Tinebase_Notes::getInstance()->getNotesOfRecord($this->_modelName, $record->getId());
         }
         if ($record->has('relations')) {
             $record->relations = Tinebase_Relations::getInstance()->getRelations($this->_modelName, $this->_backend->getType(), $record->getId());
         }
         if ($record->has('alarms')) {
             $this->getAlarms($record);
         }
         if ($this->resolveCustomfields()) {
             Tinebase_CustomField::getInstance()->resolveRecordCustomFields($record);
         }
     }
     return $record;
 }