コード例 #1
0
ファイル: user.php プロジェクト: DarneoStudio/bitrix
 public static function getUserGroupIds($userId)
 {
     $groups = array();
     // anonymous groups
     $result = GroupTable::getList(array('select' => array('ID'), 'filter' => array('=ANONYMOUS' => 'Y', '=ACTIVE' => 'Y')));
     while ($row = $result->fetch()) {
         $groups[] = $row['ID'];
     }
     if (!in_array(2, $groups)) {
         $groups[] = 2;
     }
     // private groups
     $nowTimeExpression = new SqlExpression(static::getEntity()->getConnection()->getSqlHelper()->getCurrentDateTimeFunction());
     $result = GroupTable::getList(array('select' => array('ID'), 'filter' => array('=UserGroup:GROUP.USER_ID' => $userId, '=ACTIVE' => 'Y', array('LOGIC' => 'OR', '=UserGroup:GROUP.DATE_ACTIVE_FROM' => null, '<=UserGroup:GROUP.DATE_ACTIVE_FROM' => $nowTimeExpression), array('LOGIC' => 'OR', '=UserGroup:GROUP.DATE_ACTIVE_TO' => null, '>=UserGroup:GROUP.DATE_ACTIVE_TO' => $nowTimeExpression), array('LOGIC' => 'OR', '!=ANONYMOUS' => 'Y', '=ANONYMOUS' => null))));
     while ($row = $result->fetch()) {
         $groups[] = $row['ID'];
     }
     sort($groups);
     return $groups;
 }
コード例 #2
0
    /**
     * @return string
     * @throws ArgumentException
     */
    public function getForm()
    {
        $groupInput = '<select name="' . $this->getFieldName('GROUP_ID') . '">';
        $groupDb = \Bitrix\Main\GroupTable::getList(array('select' => array('ID', 'NAME'), 'order' => array('C_SORT' => 'ASC', 'NAME' => 'ASC')));
        while ($group = $groupDb->fetch()) {
            $inputSelected = $group['ID'] == $this->getFieldValue('GROUP_ID') ? 'selected' : '';
            $groupInput .= '<option value="' . $group['ID'] . '" ' . $inputSelected . '>';
            $groupInput .= htmlspecialcharsbx($group['NAME']);
            $groupInput .= '</option>';
        }
        $groupInput .= '</select>';
        $booleanValues = array('' => Loc::getMessage('sender_connector_user_all'), 'Y' => Loc::getMessage('sender_connector_user_y'), 'N' => Loc::getMessage('sender_connector_user_n'));
        $activeInput = '<select name="' . $this->getFieldName('ACTIVE') . '">';
        foreach ($booleanValues as $k => $v) {
            $inputSelected = $k == $this->getFieldValue('ACTIVE') ? 'selected' : '';
            $activeInput .= '<option value="' . $k . '" ' . $inputSelected . '>';
            $activeInput .= htmlspecialcharsbx($v);
            $activeInput .= '</option>';
        }
        $activeInput .= '</select>';
        $dateRegInput = CalendarDate($this->getFieldName('DATE_REGISTER'), $this->getFieldValue('DATE_REGISTER'), $this->getFieldFormName());
        return '
			<table>
				<tr>
					<td>' . Loc::getMessage('sender_connector_user_group') . '</td>
					<td>' . $groupInput . '</td>
				</tr>
				<tr>
					<td>' . Loc::getMessage('sender_connector_user_datereg') . '</td>
					<td>' . $dateRegInput . '</td>
				</tr>
				<tr>
					<td>' . Loc::getMessage('sender_connector_user_active') . '</td>
					<td>' . $activeInput . '</td>
				</tr>
			</table>
		';
    }
コード例 #3
0
ファイル: GroupTools.php プロジェクト: bitrix-expert/tools
 /**
  * Validation string ID of the user group. If string ID not valid (empty string or string ID alredy used)
  * will be throw Bitrix exception.
  *
  * @param string $stringId
  * @param int $groupId Group ID by string ID
  *
  * @return bool
  */
 protected static function validateStringId($stringId, $groupId = null)
 {
     global $APPLICATION;
     if (is_null($stringId)) {
         // if code of group is not updated
         return true;
     }
     try {
         $stringId = trim($stringId);
         if (strlen($stringId) <= 0) {
             throw new \Exception('EMPTY_STRING_ID');
         }
         $rsSimilarGroup = GroupTable::query()->setFilter(['STRING_ID' => $stringId, '!ID' => $groupId])->setSelect(['ID'])->exec();
         if ($rsSimilarGroup->getSelectedRowsCount() > 0) {
             throw new \Exception('STRING_ID_ALREDY_USED');
         }
         return true;
     } catch (\Exception $e) {
         Loc::loadMessages(__FILE__);
         $APPLICATION->ThrowException(Loc::getMessage('BEX_TOOLS_GROUP_' . $e->getMessage()));
         return false;
     }
 }
コード例 #4
0
ファイル: discount_edit.php プロジェクト: webgksupport/alpina
	</tr><?php 
$strCond = base64_encode(serialize($arDiscount['CONDITIONS']));
$control->EndCustomField('CONDITIONS', '<input type="hidden" name="CONDITIONS" value="' . htmlspecialcharsbx($strCond) . '">' . '<input type="hidden" name="CONDITIONS_CHECK" value="' . htmlspecialcharsbx(md5($strCond)) . '">');
$control->BeginNextFormTab();
$strHidden = '';
$control->BeginCustomField('USER_GROUPS', GetMessage('BT_SALE_DISCOUNT_EDIT_FIELDS_GROUPS') . ':', true);
?>
<tr id="tr_USER_GROUPS" class="adm-detail-required-field">
		<td valign="top" width="40%"><?php 
echo $control->GetCustomLabelHTML();
?>
</td>
		<td valign="top" width="60%">
			<select name="USER_GROUPS[]" multiple size="8">
			<?php 
$groupIterator = Main\GroupTable::getList(array('select' => array('ID', 'NAME'), 'order' => array('C_SORT' => 'ASC', 'ID' => 'ASC')));
while ($group = $groupIterator->fetch()) {
    $group['ID'] = (int) $group['ID'];
    $selected = in_array($group['ID'], $arDiscountGroupList) ? ' selected' : '';
    ?>
<option value="<?php 
    echo $group['ID'];
    ?>
"<?php 
    echo $selected;
    ?>
>[<?php 
    echo $group['ID'];
    ?>
] <?php 
    echo htmlspecialcharsex($group['NAME']);
コード例 #5
0
$statusLangFields = StatusLangTable::getEntity()->getFields();
// get languages
$result = LanguageTable::getList(array('select' => array('LID', 'NAME'), 'filter' => array('=ACTIVE' => 'Y')));
while ($row = $result->fetch()) {
    $languages[$row['LID']] = $row['NAME'];
}
// get groups
$saleGroupIds = array();
$result = $APPLICATION->GetGroupRightList(array('MODULE_ID' => 'sale', 'G_ACCESS' => 'U'));
while ($row = $result->Fetch()) {
    if ($row['GROUP_ID'] > 2) {
        $saleGroupIds[] = $row['GROUP_ID'];
    }
}
if ($saleGroupIds) {
    $result = GroupTable::getList(array('select' => array('ID', 'NAME'), 'filter' => array('=ID' => $saleGroupIds), 'order' => array('C_SORT' => 'ASC', 'ID' => 'ASC')));
    while ($row = $result->fetch()) {
        $groups[$row['ID']] = $row['NAME'];
    }
}
// A D D / U P D A T E /////////////////////////////////////////////////////////////////////////////////////////////////
if ($_SERVER['REQUEST_METHOD'] == 'POST' && !$readOnly && check_bitrix_sessid() && ($_POST['save'] || $_POST['apply'])) {
    $errors = array();
    $statusType = $_REQUEST['TYPE'] == 'O' ? 'O' : 'D';
    $lockedStatusList = array("O" => array(\Bitrix\Sale\OrderStatus::getInitialStatus(), \Bitrix\Sale\OrderStatus::getFinalStatus()), "D" => array(\Bitrix\Sale\DeliveryStatus::getInitialStatus(), \Bitrix\Sale\DeliveryStatus::getFinalStatus()));
    if ($statusId) {
        foreach ($lockedStatusList as $lockStatusType => $lockStatusIdList) {
            foreach ($lockStatusIdList as $lockStatusId) {
                if ($lockStatusId == $statusId && $statusType != $lockStatusType) {
                    $errors[] = Loc::getMessage('SALE_STATUS_WRONG_TYPE', array('#STATUS_ID#' => htmlspecialcharsEx($statusId), '#STATUS_TYPE#' => Loc::getMessage('SSEN_TYPE_' . $statusType)));
                    break;