public function executeEditDoc(sfWebRequest $request) { $op = $request->getParameter("op", "d"); $id = $request->getParameter("id", 0); $titulo = $request->getParameter("titulo"); $descripcion = $request->getParameter("descripcion"); $this->propuesta = PropuestaPeer::retrieveByPk($id); $this->forward404Unless($this->propuesta); $files = $request->getFiles(); if ($op == 'et') { $this->propuesta->setTitulo(SfVoUtil::cutToLength($titulo, 80, '', false)); $this->propuesta->save(); $this->redirect("propuesta/show?id=" . $this->propuesta->getVanity()); } elseif ($op == 'ed') { $this->propuesta->setDescripcion(SfVoUtil::cutToLength($descripcion, 600, '', false)); $this->propuesta->save(); $this->redirect("propuesta/show?id=" . $this->propuesta->getVanity()); } elseif ($op == 'ep') { $img = $files['img']; if ($img) { $arr = array_reverse(explode(".", $img['name'])); $ext = strtolower($arr[0]); if (!$ext || $ext == "") { $ext = "png"; } $docName = SfVoUtil::fixVanityChars($arr[1]); $docName .= "-" . sprintf("%04d", rand(0, 999)); $docName .= ".{$ext}"; $fileName = sfConfig::get('sf_upload_dir') . '/propuestas/' . $docName; move_uploaded_file($img['tmp_name'], $fileName); $s = new S3Voota(); $s->createFromFile('propuestas', $fileName); $this->propuesta->setImagen($docName); $this->propuesta->save(); } $this->redirect("propuesta/show?id=" . $this->propuesta->getVanity()); } else { switch ($op) { case 's': return 'Saved'; break; case 'd': break; case 'f': $this->propuesta->setDoc(null); $this->propuesta->setDocSize(null); $this->propuesta->save(); return 'Form'; case 'u': $doc = $files['doc']; if ($doc) { $arr = array_reverse(explode(".", $doc['name'])); $ext = strtolower($arr[0]); if (!$ext || $ext == "") { $ext = "png"; } $docName = SfVoUtil::fixVanityChars($arr[1]); $docName .= "-" . sprintf("%04d", rand(0, 999)); $docName .= ".{$ext}"; $fileName = sfConfig::get('sf_upload_dir') . '/docs/' . $docName; move_uploaded_file($doc['tmp_name'], $fileName); $s = new S3Voota(); $s->createDocFromFile('docs', $fileName); $this->propuesta->setDoc($docName); $this->propuesta->setDocSize($s->getSize("docs/{$docName}")); $this->propuesta->save(); echo "0"; die; } return 'Form'; } } }
/** * Get the associated Propuesta object * * @param PropelPDO Optional Connection object. * @return Propuesta The associated Propuesta object. * @throws PropelException */ public function getPropuesta(PropelPDO $con = null) { if ($this->aPropuesta === null && $this->propuesta_id !== null) { $this->aPropuesta = PropuestaPeer::retrieveByPk($this->propuesta_id); /* 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->aPropuesta->addEtiquetaPropuestas($this); */ } return $this->aPropuesta; }