214 $connection = Main\Application::getConnection();
216 $res = static::getList(
219 '=APP_ID' => (
int)$appId,
234 while ($placement = $res->fetch())
236 $eventList[] =
new Event(
238 static::PREFIX_EVENT_ON_AFTER_DELETE . $placement[
'PLACEMENT'],
240 'ID' => $placement[
'ID'],
241 'PLACEMENT' => $placement[
'PLACEMENT'],
246 $queryResult = $connection->query(
"DELETE FROM ".static::getTableName().
" WHERE APP_ID='".intval($appId).
"'");
248 foreach ($eventList as $event)
250 EventManager::getInstance()->send($event);
253 static::clearHandlerCache();
266 public static function getHandlersList($placement, $skipInstallCheck =
false,
int $userId =
null)
268 if(!array_key_exists($placement, static::$handlersListCache))
270 static::$handlersListCache[$placement] = array();
272 $cache = Main\Application::getInstance()->getManagedCache();
273 if($cache->read(static::CACHE_TTL, static::getCacheId($placement), static::CACHE_DIR))
275 static::$handlersListCache = $cache->get(static::getCacheId($placement));
279 $res = static::getHandlers($placement, $userId);
280 foreach ($res->fetchCollection() as $handler)
282 $id = $handler->getId();
283 $app = $handler->getRestApp();
286 'APP_ID' => $handler->getAppId(),
287 'USER_ID' => $handler->getUserId(),
288 'ICON_ID' => $handler->getIconId(),
289 'ADDITIONAL' => $handler->getAdditional(),
298 'OPTIONS' => $handler->getOptions(),
299 'INSTALLED' => $app->getInstalled(),
300 'APP_NAME' => $app->getAppName(),
301 'APP_ACCESS' => $app->getAccess(),
305 if ($placementItem[
'ICON_ID'] > 0 && ($file = \CFile::GetFileArray($placementItem[
'ICON_ID'])))
307 $placementItem[
'ICON'] = array_change_key_case($file, CASE_LOWER);
310 $handler->fillLangAll();
311 if (!is_null($handler->getLangAll()))
313 foreach ($handler->getLangAll() as $lang)
315 $placementItem[
'LANG_ALL'][$lang->getLanguageId()] = [
316 'TITLE' => $lang->getTitle(),
317 'DESCRIPTION' => $lang->getDescription(),
318 'GROUP_NAME' => $lang->getGroupName(),
322 static::$handlersListCache[$placement][] = $placementItem;
325 $cache->set(static::getCacheId($placement), static::$handlersListCache);
329 $result = static::$handlersListCache[$placement];
331 foreach($result as $key => $handler)
335 unset($result[$key]);
338 $placement !== Api\UserFieldType::PLACEMENT_UF_TYPE
339 && !\CRestUtil::checkAppAccess($handler[
'APP_ID'], array(
340 'ACCESS' => $handler[
'APP_ACCESS']
345 unset($result[$key]);
350 if (empty($result[$key][
'TITLE']))
352 $result[$key][
'TITLE'] = static::getDefaultTitle($handler[
'ID']);
357 $result = array_values($result);
471 $id = $event->getParameter(
'id');
472 $id = (int)$id[
'ID'];
477 static::PREFIX_EVENT_ON_AFTER_DELETE . static::$beforeDeleteList[$id][
'PLACEMENT'],
480 'PLACEMENT' => static::$beforeDeleteList[$id][
'PLACEMENT'],
483 unset(static::$beforeDeleteList[$id]);
484 EventManager::getInstance()->send($data);
487 static::clearHandlerCache();
541 $data = array_merge($event->getParameter(
'fields'), $result->getModified());