public function updateGroupIfExists($code, $fields = array())
 {
     $groupId = $this->getGroupId($code);
     if (!$groupId) {
         return false;
     }
     if (empty($fields)) {
         $this->throwException(__METHOD__, 'Set fields for group %s', $code);
     }
     $group = new \CGroup();
     if ($group->Update($groupId, $fields)) {
         return intval($groupId);
     }
     $this->throwException(__METHOD__, $group->LAST_ERROR);
 }
Пример #2
0
$obSite = new CSite();
$obSite->Update("s1", array("NAME" => COption::GetOptionString("main", "site_name", GetMessage("DEFAULT_SITE_NAME"))));
//Edit profile task
$editProfileTask = false;
$dbResult = CTask::GetList(array(), array("NAME" => "main_change_profile"));
if ($arTask = $dbResult->Fetch()) {
    $editProfileTask = $arTask["ID"];
}
//admin security policy
$z = CGroup::GetByID(1);
if ($res = $z->Fetch()) {
    if ($res["SECURITY_POLICY"] == "") {
        $group = new CGroup();
        $arGroupPolicy = array("SESSION_TIMEOUT" => 15, "SESSION_IP_MASK" => "255.255.255.255", "MAX_STORE_NUM" => 1, "STORE_IP_MASK" => "255.255.255.255", "STORE_TIMEOUT" => 60 * 24 * 3, "CHECKWORD_TIMEOUT" => 60, "PASSWORD_LENGTH" => 10, "PASSWORD_UPPERCASE" => "Y", "PASSWORD_LOWERCASE" => "Y", "PASSWORD_DIGITS" => "Y", "PASSWORD_PUNCTUATION" => "Y", "LOGIN_ATTEMPTS" => 3);
        $arFields = array("SECURITY_POLICY" => serialize($arGroupPolicy));
        $group->Update(1, $arFields);
    }
}
//Registered users group
$dbResult = CGroup::GetList($by, $order, array("STRING_ID" => "REGISTERED_USERS"));
if ($dbResult->Fetch()) {
    return;
}
$group = new CGroup();
$arFields = array("ACTIVE" => "Y", "C_SORT" => 3, "NAME" => GetMessage("REGISTERED_GROUP_NAME"), "STRING_ID" => "REGISTERED_USERS");
$groupID = $group->Add($arFields);
if ($groupID > 0) {
    COption::SetOptionString("main", "new_user_registration_def_group", $groupID);
    if ($editProfileTask) {
        CGroup::SetTasks($groupID, array($editProfileTask), true);
    }
Пример #3
0
				{
					$DB->Rollback();
					$lAdmin->AddGroupError(GetMessage("DELETE_ERROR"), $ID);
				}
				$DB->Commit();
			}
			else
				$lAdmin->AddGroupError(GetMessage("MAIN_ERROR_GROUP").$ID.GetMessage("MAIN_ERROR_GROUP_DELETE"));
			break;
		case "activate":
		case "deactivate":
			if($ID>2)
			{
				$ob = new CGroup();
				$arFields["ACTIVE"] = ($_REQUEST['action']=="activate"?"Y":"N");
				if(!$ob->Update($ID, $arFields))
					$lAdmin->AddGroupError(GetMessage("MAIN_EDIT_ERROR").":".$ob->LAST_ERROR, $ID);
			}
			else
				$lAdmin->AddGroupError(GetMessage("MAIN_ERROR_GROUP").$ID.GetMessage("MAIN_ERROR_GROUP_EDIT"));
			break;
		}
	}
}

// инициализация списка - выборка данных
$rsData = CGroup::GetList($by, $order, $arFilter, "Y");
$rsData = new CAdminResult($rsData, $sTableID);
$rsData->NavStart();

// установке параметров списка
Пример #4
0
             $ind++;
             $USER_ID[$ind]["USER_ID"] = intval(${"USER_ID_" . $i});
             $USER_ID[$ind]["DATE_ACTIVE_FROM"] = ${"USER_ID_FROM_" . $i};
             $USER_ID[$ind]["DATE_ACTIVE_TO"] = ${"USER_ID_TO_" . $i};
         }
     }
     if ($ID == 1 && $COPY_ID <= 0) {
         $ind++;
         $USER_ID[$ind]["USER_ID"] = 1;
         $USER_ID[$ind]["DATE_ACTIVE_FROM"] = false;
         $USER_ID[$ind]["DATE_ACTIVE_TO"] = false;
     }
     $arFields["USER_ID"] = $USER_ID;
 }
 if ($ID > 0 && $COPY_ID <= 0) {
     $res = $group->Update($ID, $arFields);
 } else {
     $ID = $group->Add($arFields);
     $res = $ID > 0;
     $new = "Y";
 }
 $strError .= $group->LAST_ERROR;
 if (strlen($strError) <= 0) {
     if (intval($ID) != 1 || COption::GetOptionString("main", "controller_member", "N") == "Y" && COption::GetOptionString("main", "~controller_limited_admin", "N") == "Y") {
         // set per module rights
         $arTasks = array();
         foreach ($arModules as $MID) {
             $moduleName = str_replace(".", "_", $MID);
             if (isset(${"TASKS_" . $moduleName})) {
                 $arTasks[$MID] = ${"TASKS_" . $moduleName};
                 $rt = CTask::GetLetter($arTasks[$MID]);
Пример #5
0
 /**
  * Сохраняет группу
  * @return bool
  */
 public function save()
 {
     $values = $this->getValues();
     $arFields = array();
     foreach ($values as $key => $value) {
         $arFields[strtoupper($key)] = $value;
     }
     $group = new CGroup();
     //записываем поля пользователя
     if (!$this->isNew()) {
         $id = $this->getAttribute('id')->getValue();
         //при обновлении элемента сначала записываем базовые поля
         $res = $group->Update($id, $arFields);
         if (!$res) {
             throw new Exception($group->LAST_ERROR);
         }
         $this->riseEvent('afterSave');
     } else {
         $new = $group->Add($arFields);
         if ($new) {
             $this->getAttribute('id')->setValue($new);
             $this->riseEvent('afterSave');
         } else {
             throw new Exception($group->LAST_ERROR);
         }
     }
 }