Commit 1088d237 authored by Clément Damiens's avatar Clément Damiens
Browse files

search answer algo

parent 301bb792
<?php
/**
* Display the directory of back office
* @param String $id Not mandatory : if specify, look for the person with this Id.
* Else will get the id of the person logged
* @return type
*/
class DirectoryAction extends CAction
{
public function run($source=null, $form=null){
$controller = $this->getController();
$res=array();
$searchParams = $_POST;
$res = Form::getBySourceAndId($source, $form);
//var_dump($params["form"]);exit;
$answers=Answer::globalAutocomplete($res["form"], $searchParams);
$answerList = Form::listForAdmin($answers["results"]) ;
foreach ($answerList as $key => $value) {
if(isset($res["form"]["mapping"])){
$answerList[$key]["mappingValues"]=Answer::getMappingValues($res["form"]["mapping"], $value);
}
$answerList[$key]["countComment"] = PHDB::count(Comment::COLLECTION, array("contextId"=>$key,"contextType"=>Form::ANSWER_COLLECTION));
}
if(isset($answers["count"]))
$res["count"]=$answers["count"];
$res["results"] = $answerList ;
$res["what"] = (isset($params["form"]["what"])) ? $params["form"]["what"] : "réponses";
$el = Slug::getElementBySlug( $res["form"]["parentSlug"] );
$res['el'] = $el["el"];
//ce code ne marchera pas pour deux formulaire identaique , d'un meme slug
//TODO utiliser le parntForm Id en plus
$res['canEdit'] = ( isset(Yii::app()->session["userId"]) && isset($el["type"]) && isset($el["id"]) ) ?
Authorisation::canEditItem(Yii::app()->session["userId"],$el["type"], $el["id"])
: false ;
// if($tpl=="json")
Rest::json( $res );
//else if(Yii::app()->request->isAjaxRequest)
// echo $controller->renderPartial("costum.views.custom.default.".$page,$params,true);
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment