Ejemplo n.º 1
0
 protected function getDocumentoOrCreate($id_documento = 'id_documento')
 {
     $idd_documento = $this->getRequestParameter($id_documento, 0);
     //SI VIENE DE WIKI PUEDE QUE YA EXISTA EL DOCUMENTO, ASI QUE VAMOS A BUSCAR UNO CON EL MISMO NOMBRE DEL MISMO PROYECTO
     $fromWiki = $this->getRequestParameter('fromWiki', 0);
     if ($fromWiki == 1) {
         $arr = pathinfo($_REQUEST["hidFileID"]);
         if ($arr['extension'] != "") {
             $mnombre = substr($arr['basename'], 0, strlen($arr['basename']) - strlen($arr['extension']) - 1);
         } else {
             $mnombre = $arr['basename'];
         }
         $c = new Criteria();
         $c->addAnd(DocumentoPeer::ID_PROYECTO, $this->getUser()->getAttribute('wiki_proyecto', 0), Criteria::EQUAL);
         $c->addAnd(DocumentoPeer::NOMBRE, $mnombre, Criteria::LIKE);
         $documento = DocumentoPeer::doSelectOne($c);
         if ($documento != null) {
             $idd_documento = $documento->getIdDocumento();
             $this->forward404Unless($documento);
             return $documento;
         }
     }
     if ($idd_documento != 0) {
         $documento = DocumentoPeer::retrieveByPk($idd_documento);
         $this->forward404Unless($documento);
     } else {
         $documento = new Documento();
         $documento->setIdEmpresa(sfContext::getInstance()->getUser()->getAttribute('idempresa'));
         if ($id_fase = $this->getRequestParameter('id_fase')) {
             $documento->setIdFase($id_fase);
         }
         if ($id_reunion = $this->getRequestParameter('id_reunion')) {
             $documento->setIdReunion($id_reunion);
         }
     }
     return $documento;
 }
 /**
  * Get the associated Documento object
  *
  * @param      PropelPDO Optional Connection object.
  * @return     Documento The associated Documento object.
  * @throws     PropelException
  */
 public function getDocumento(PropelPDO $con = null)
 {
     if ($this->aDocumento === null && $this->id_documento !== null) {
         $c = new Criteria(DocumentoPeer::DATABASE_NAME);
         $c->add(DocumentoPeer::ID_DOCUMENTO, $this->id_documento);
         $this->aDocumento = DocumentoPeer::doSelectOne($c, $con);
         /* The following can be used additionally to
         		   guarantee the related object contains a reference
         		   to this object.  This level of coupling may, however, be
         		   undesirable since it could result in an only partially populated collection
         		   in the referenced object.
         		   $this->aDocumento->addHistoricoDocumentos($this);
         		 */
     }
     return $this->aDocumento;
 }