public function executeAdd(sfWebRequest $request) { if ($request->isXmlHttpRequest()) { $form = new InformativeWorkflowForm(null, array('available_status' => informativeWorkflow::getAvailableStatus($this->getUser()->getDbUserType()))); $form->bind(array('comment' => $request->getParameter('comment'), 'status' => $request->getParameter('status'))); if ($form->isValid()) { $data = array('referenced_relation' => $request->getParameter('table'), 'record_id' => $request->getParameter('id'), 'status' => $request->getParameter('status'), 'comment' => $request->getParameter('comment'), 'user_ref' => $this->getUser()->getId()); $workflow = new InformativeWorkflow(); $workflow->fromArray($data); $workflow->save(); } // else : nothing append, and it's a good thing return $this->renderText('ok'); } $this->redirect('board/index'); }
public function executeView(sfWebRequest $request) { $this->full = false; if ($request->hasParameter('full')) { $this->full = true; $this->setLayout('refined'); } $ajax = false; if ($request->isXmlHttpRequest()) { $suggestion = $request->getParameter('suggestion'); $captcha = array('recaptcha_challenge_field' => $request->getParameter('recaptcha_challenge_field'), 'recaptcha_response_field' => $request->getParameter('recaptcha_response_field')); $id = $suggestion['id']; $ajax = true; } else { $id = $request->getParameter('id'); } $this->forward404Unless(ctype_digit($request->getParameter('id'))); $this->specimen = Doctrine::getTable('Specimens')->find((int) $request->getParameter('id')); $this->comments = Doctrine::getTable('Comments')->getRelatedComment('specimens', (int) $request->getParameter('id')); $this->forward404Unless($this->specimen); if (!$this->specimen->getCollectionIsPublic()) { $this->forwardToSecureAction(); } $collection = Doctrine::getTable('Collections')->findOneById($this->specimen->getCollectionRef()); $this->institute = Doctrine::getTable('People')->findOneById($collection->getInstitutionRef()); $this->files = Doctrine::getTable('Multimedia')->findForPublic($this->specimen); $this->specFilesCount = $this->taxFilesCount = $this->chronoFilesCount = $this->lithoFilesCount = $this->lithologyFilesCount = $this->mineraloFilesCount = 0; foreach ($this->files as $file) { switch ($file->getReferencedRelation()) { case 'taxonomy': $this->taxFilesCount += 1; break; case 'chronostratigraphy': $this->chronoFilesCount += 1; break; case 'lithostratigraphy': $this->lithoFilesCount += 1; break; case 'lithology': $this->lithologyFilesCount += 1; break; case 'mineralogy': $this->mineraloFilesCount += 1; break; default: $this->specFilesCount += 1; break; } } $this->col_manager = Doctrine::getTable('Users')->find($collection->getMainManagerRef()); $this->col_staff = Doctrine::getTable('Users')->find($collection->getStaffRef()); $this->manager = Doctrine::getTable('UsersComm')->fetchByUser($collection->getMainManagerRef()); $this->codes = Doctrine::getTable('Codes')->getCodesRelated('specimens', $this->specimen->getId()); $this->properties = Doctrine::getTable('Properties')->findForTable('specimens', $this->specimen->getId()); $ids = $this->FecthIdForCommonNames(); $this->common_names = Doctrine::getTable('VernacularNames')->findAllCommonNames($ids); if ($tag = $this->specimen->getGtuCountryTagValue()) { $this->tags = explode(';', $tag); } else { $this->tags = false; } $this->form = new SuggestionForm(null, array('ref_id' => $id, 'ajax' => $ajax)); if ($request->isXmlHttpRequest()) { $this->form->bind($suggestion, array('captcha' => $captcha)); if ($this->form->isBound() && $this->form->isValid()) { $comment = $suggestion['comment']; if ($suggestion['email'] != '') { $comment = $this->getI18N()->__("Suggestion send by") . " : " . $suggestion['email'] . "\n" . $suggestion['comment']; } $data = array('referenced_relation' => 'specimens', 'record_id' => $suggestion['id'], 'status' => 'suggestion', 'comment' => $comment, 'formated_name' => $suggestion['formated_name'] != '' ? $suggestion['formated_name'] : 'anonymous'); $workflow = new InformativeWorkflow(); $workflow->fromArray($data); $workflow->save(); return $this->renderPartial("info_msg"); } return $this->renderPartial("suggestion", array('form' => $this->form, 'id' => $id)); } }