3namespace Bitrix\Vote\Attachment;
5use Bitrix\Main\AccessDeniedException;
6use Bitrix\Main\ArgumentException;
7use Bitrix\Main\ArgumentNullException;
8use Bitrix\Main\Localization\Loc;
9use Bitrix\Main\ObjectNotFoundException;
10use Bitrix\Main\ORM\Fields\ExpressionField;
11use Bitrix\Vote\EventTable;
15Loc::loadMessages(__FILE__);
29 "method" =>
array(
"POST")
32 "method" =>
array(
"POST",
"GET")
35 "method" =>
array(
"POST",
"GET")
38 "method" =>
array(
"POST",
"GET")
41 "method" =>
array(
"POST",
"GET")
43 "getmobilevoted" =>
array(
44 "method" =>
array(
"POST",
"GET"),
45 "check_sessid" =>
false
48 "method" =>
array(
"POST",
"GET")
55 if ($this->request->getQuery(
"attachId"))
57 else if ($this->request->getQuery(
"voteId"))
59 "MODULE_ID" =>
"vote",
60 "ENTITY_TYPE" =>
"VOTE",
61 "ENTITY_ID" => $this->request->getQuery(
"voteId")
62 ), $this->request->getQuery(
"voteId"));
75 if (!$this->attach->canRead($this->getUser()->getId()))
78 $request = $this->request->getPostList()->toArray();
81 if ($this->attach->voteFor(
$request))
87 "ID" => $this->attach[
"ID"],
88 "VOTE_ID" => $this->attach[
"VOTE_ID"],
89 "COUNTER" => $this->attach[
"COUNTER"],
90 "QUESTIONS" => $this->attach[
"QUESTIONS"]
96 $this->errorCollection->add(
$errors);
104 if (!$this->attach->canRead($this->getUser()->getId()))
112 if ($this->
getUser()->isAdmin() && $this->request->getQuery(
"eventId") > 0)
113 $eventId = $this->request->getQuery(
"eventId");
127 $userAnswersResult =
$attach->getUserEventAnswers($eventId);
128 $stat = $userAnswersResult->stat;
129 $extras = $userAnswersResult->extras;
130 if ($userAnswersResult->userId)
132 $userId = $userAnswersResult->userId;
140 "VOTE_ID" =>
$attach[
"VOTE_ID"],
141 "FIELD_NAME" =>
$attach[
"FIELD_NAME"],
142 "QUESTIONS" =>
$attach[
"QUESTIONS"]
165 "ID" => $this->attach[
"ID"],
166 "VOTE_ID" => $this->attach[
"VOTE_ID"],
167 "COUNTER" => $this->attach[
"COUNTER"],
168 "QUESTIONS" => $this->attach[
"QUESTIONS"]
185 "ID" => $this->attach[
"ID"],
186 "VOTE_ID" => $this->attach[
"VOTE_ID"],
187 "COUNTER" => $this->attach[
"COUNTER"],
188 "QUESTIONS" => $this->attach[
"QUESTIONS"]
202 $iNumPage = intval($pageParams[
"iNumPage"]);
203 $nPageSize = intval($pageParams[
"nPageSize"]);
204 $showAll = $pageParams[
"bShowAll"] ===
true;
206 $cache = new \CPHPCache();
208 "statusPage" =>
"done",
213 $cacheTtl = defined(
"BX_COMP_MANAGED_CACHE") ? 3153600 : 3600*4;
214 $cacheId =
"voted_".serialize(
array($cacheParams[
"answerId"], $nPageSize, $iNumPage));
215 $cacheDir =
"/vote/".$cacheParams[
"voteId"].
"/voted/";
217 if (\
Bitrix\
Main\
Config\Option::get(
"main",
"component_cache_on",
"Y") ==
"Y" && $cache->initCache($cacheTtl, $cacheId, $cacheDir))
233 "=VOTE_ID" => $cacheParams[
"voteId"],
236 "=QUESTION.ANSWER.ANSWER_ID" => $cacheParams[
"answerId"],
244 "ANSWER_ID" => $cacheParams[
"answerId"],
248 "bGetMemoStat" =>
"N"
251 "nPageSize" => $nPageSize,
252 "bShowAll" => $showAll,
253 "iNumPage" => $iNumPage
257 $result[
"statusPage"]= ((
$dbRes->NavPageNomer >=
$dbRes->NavPageCount || $nPageSize >
$dbRes->NavRecordCount) ?
"done" :
"continue");
259 $userIds[] =
$res[
"AUTH_USER_ID"];
262 $result[
"statusPage"] =
"done";
265 $departments =
array();
267 (
$iblockId = \COption::GetOptionInt(
"intranet",
"iblock_structure", 0)) &&
272 $dbRes = \CIBlockSection::GetList(
273 array(
"LEFT_MARGIN" =>
"DESC"),
280 $departments[
$res[
"ID"]] =
$res[
"NAME"];
286 array(
"ID" => implode(
"|", $userIds)),
288 "FIELDS" => [
"ID",
"NAME",
"LAST_NAME",
"SECOND_NAME",
"LOGIN",
"PERSONAL_PHOTO",
"WORK_POSITION"] +
295 if (array_key_exists(
"PERSONAL_PHOTO",
$res))
297 if (!empty(
$res[
"PERSONAL_PHOTO"]))
299 $f = \CFile::resizeImageGet(
300 $res[
"PERSONAL_PHOTO"],
301 array(
"width" => 64,
"height" => 64),
305 $res[
"PHOTO_SRC"] = (
$f[
"src"] ?
$f[
"src"] :
"");
306 $res[
"PHOTO"] = \CFile::showImage(
$f[
"src"], 21, 21,
"border=0");
310 $res[
"PHOTO"] =
$res[
"PHOTO_SRC"] =
"";
314 if (array_key_exists(
"EXTERNAL_AUTH_ID",
$res) &&
$res[
"EXTERNAL_AUTH_ID"] ==
"email")
315 $res[
"TYPE"] =
"mail";
316 elseif (array_key_exists(
"UF_DEPARTMENT",
$res))
318 if (empty(
$res[
"UF_DEPARTMENT"]) || intval(
$res[
"UF_DEPARTMENT"][0]) <= 0)
319 $res[
"TYPE"] =
"extranet";
323 foreach (
$res[
"UF_DEPARTMENT"] as $departmentId)
325 if (array_key_exists($departmentId, $departments))
326 $ds[] = $departments[$departmentId];
329 $res[
"TAGS"] = implode(
",", array_merge(
$res[
"TAGS"], $ds));
330 $res[
"WORK_DEPARTMENTS"] = $ds;
339 $cache->startDataCache($cacheTtl, $cacheId, $cacheDir);
340 \CVoteCacheManager::setTag($cacheDir,
"V", $cacheParams[
"voteId"]);
350 $answerId = intval($this->request->getQuery(
"answerId"));
359 foreach (
$attach[
"QUESTIONS"] as $qID => $question)
361 if (array_key_exists($answerId, $question[
"ANSWERS"]))
370 $nameTemplate = $this->request->getPost(
"nameTemplate") ?: \CSite::getNameFormat(
null, $this->request->getPost(
"SITE_ID"));
371 $iNumPage = $this->request->getPost(
"iNumPage");
377 "voteId" =>
$attach->getVoteId(),
378 "answerId" => $answerId),
380 "iNumPage" => $iNumPage,
381 "nPageSize" => $nPageSize,
385 if (
$result[
"hiddenItems"] > 0)
389 "COUNT" =>
$result[
"hiddenItems"],
390 "FULL_NAME" => Loc::getMessage(
"VOTE_HIDDEN_VOTES_COUNT", [
"#COUNT#" =>
$result[
"hiddenItems"]]),
397 "TYPE" =>
$res[
"TYPE"],
398 "PHOTO" =>
$res[
"PHOTO"],
399 "PHOTO_SRC" =>
$res[
"PHOTO_SRC"],
400 "FULL_NAME" => \CUser::formatName($nameTemplate,
$res),
404 $result[
"pageSize"] = $nPageSize;
405 $result[
"iNumPage"] = $iNumPage;
416 $answerId = intval($this->request->getQuery(
"answerId"));
425 foreach (
$attach[
"QUESTIONS"] as $qID => $question)
427 if (array_key_exists($answerId, $question[
"ANSWERS"]))
436 $nameTemplate = $this->request->getPost(
"nameTemplate") ?: \CSite::getNameFormat(
null, $this->request->getPost(
"SITE_ID"));
440 "voteId" =>
$attach->getVoteId(),
441 "answerId" => $answerId),
451 $url = \CComponentEngine::MakePathFromTemplate(
452 "/mobile/users/?user_id=#user_id#",
454 "USER_ID" =>
$res[
"ID"])
458 "NAME" => \CUser::FormatName($nameTemplate,
$res,
true,
false),
459 "IMAGE" =>
$res[
"PHOTO_SRC"],
460 "TAGS" =>
$res[
"TAGS"],
461 "WORK_POSITION" =>
$res[
"WORK_POSITION"],
462 "WORK_DEPARTMENTS" =>
$res[
"WORK_DEPARTMENTS"],
465 'bx24ModernStyle' =>
true,
478 "voted" =>
"Voted users"
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
static includeModule($moduleName)
static getVoted(array $cacheParams, array $pageParams)
processActionGetMobileVoted()
static loadFromVoteId(array $attach, $id)
static loadFromAttachId($id)
sendJsonSuccessResponse(array $response=array())
checkRequiredGetParams(array $required)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
const BX_RESIZE_IMAGE_EXACT
IsModuleInstalled($module_id)
AddEventHandler($FROM_MODULE_ID, $MESSAGE_ID, $CALLBACK, $SORT=100, $FULL_PATH=false)
GetMessage($name, $aReplace=null)
BXClearCache($full=false, $initdir='')
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)