Ejemplo n.º 1
0
 /**
  * Executes the query
  *
  * @param string $filterField
  * @param mixed $filterFieldValue
  * @param string $method
  *
  * @return \Bitrix\Main\DB\MysqlResult
  */
 private function execute($filterField, $filterFieldValue, $method)
 {
     $queryBuilder = new Entity\Query(Model\VarsGroupTable::getEntity());
     $queryBuilder->setSelect(array('ID', 'NAME', 'CODE'))->setOrder(array('ID' => 'ASC'))->setFilter(array($filterField => $filterFieldValue));
     if ($method == 'findOneBy') {
         $queryBuilder->setLimit(1);
     }
     return $queryBuilder->exec();
 }
    }
} else {
    $dataGroup = array_fill_keys(array('ID', 'NAME', 'CODE'), '');
}
if ($isOldGroup && $request->getQuery('action') == 'delete' && check_bitrix_sessid()) {
    Model\VarsGroupTable::delete($dataGroup['ID']);
    LocalRedirect(sprintf('user_vars.php?lang=%s', LANGUAGE_ID));
}
if ($request->isPost() && check_bitrix_sessid()) {
    $postData = array_map('strip_tags', $request->getPostList()->toArray());
    $postData = array_intersect_key($postData, array('NAME' => null, 'CODE' => null));
    if ($isNewGroup) {
        $result = Model\VarsGroupTable::add($postData);
        $groupId = $result->getId();
    } else {
        $result = Model\VarsGroupTable::update($dataGroup['ID'], $postData);
        $groupId = $dataGroup['ID'];
    }
    if (!$result->isSuccess()) {
        $errorsList = $result->getErrorMessages();
    } else {
        if ($submitTypeApply) {
            $redirectPath = sprintf('user_vars_group_edit.php?ID=%dlang=%s', $groupId, LANGUAGE_ID);
        } else {
            $redirectPath = sprintf('user_vars.php?lang=%s', LANGUAGE_ID);
        }
        LocalRedirect($redirectPath);
    }
    foreach ($postData as $key => $value) {
        $dataGroup[$key] = $value;
    }
Ejemplo n.º 3
0
<?php

/*
 * This file is part of the Studio Fact package.
 *
 * (c) Kulichkin Denis (onEXHovia) <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
use Bitrix\Main\Localization\Loc;
use Bitrix\Main\Entity;
use Bitrix\Main\Loader;
use Citfact\UserVars\Model;
Loc::loadMessages(__FILE__);
Loader::includeModule('citfact.uservars');
$queryBuilder = new Entity\Query(Model\VarsGroupTable::getEntity());
$queryBuilder->setSelect(array('ID', 'NAME', 'CODE'))->setOrder(array('ID' => 'ASC'));
$varsGroupResult = $queryBuilder->exec();
$varsGroupList = array();
while ($group = $varsGroupResult->fetch()) {
    $varsGroupList[] = array('text' => $group['NAME'], 'url' => 'user_vars_list.php?GROUP_ID=' . $group['ID'] . '&lang=' . LANG, 'module_id' => 'user_vars', 'more_url' => array('user_vars_edit.php?GROUP_ID=' . $group['ID'] . '&lang=' . LANG));
}
$menuList[] = array('parent_menu' => Loader::includeModule('citfact.core') ? 'global_menu_citfact' : 'global_menu_services', 'section' => 'user_vars', 'sort' => 200, 'text' => Loc::getMessage('USER_VARS_TITLE'), 'url' => 'user_vars.php?lang=' . LANGUAGE_ID, 'icon' => 'user_vars_menu_icon', 'page_icon' => 'user_vars_page_icon', 'more_url' => array('user_vars_group_edit.php'), 'items_id' => 'uservars_menu', 'items' => $varsGroupList);
return $menuList;