20 include
'admin_header.php';
48 if (count(
$cats) > 0) {
49 foreach (array_keys(
$cats) as
$i) {
50 $categories[
$cats[
$i]->getVar(
'cat_id')] = $cats[
$i]->getVar(
'cat_title');
53 $GLOBALS[
'xoopsTpl']->assign(
'categories', $categories);
83 foreach (array_keys(
$fields) as $i) {
87 $fields[
$i][
'valuetype'] = $valuetypes[$fields[
$i][
'field_valuetype']];
88 $categories[$fields[
$i][
'cat_id']][] = $fields[
$i];
89 $weights[$fields[
$i][
'cat_id']][] = $fields[
$i][
'field_weight'];
93 foreach (array_keys($categories) as $i) {
94 array_multisort($weights[$i], SORT_ASC, array_keys($categories[$i]), SORT_ASC, $categories[$i]);
97 $GLOBALS[
'xoopsTpl']->assign(
'fieldcategories', $categories);
98 $GLOBALS[
'xoopsTpl']->assign(
'token',
$GLOBALS[
'xoopsSecurity']->getTokenHTML());
99 $template_main =
"profile_admin_fieldlist.html";
103 include_once(
'../include/forms.php');
111 if (!$obj->getVar(
'field_config') && !$obj->getVar(
'field_show') && !$obj->getVar(
'field_edit')) {
114 include_once(
'../include/forms.php');
120 if (!
$GLOBALS[
'xoopsSecurity']->check()) {
123 if (isset(
$_POST[
'field_ids']) && count(
$_POST[
'field_ids']) > 0) {
124 $oldweight =
$_POST[
'oldweight'];
125 $oldcat =
$_POST[
'oldcat'];
126 $category =
$_POST[
'category'];
127 $weight =
$_POST[
'weight'];
129 foreach (
$_POST[
'field_ids'] as $field_id) {
130 if ($oldweight[$field_id] != $weight[$field_id] || $oldcat[$field_id] != $category[$field_id]) {
132 $ids[] = intval($field_id);
135 if (count($ids) > 0) {
140 foreach ($ids as $i) {
141 $fields[
$i]->setVar(
'field_weight', intval($weight[$i]));
142 $fields[
$i]->setVar(
'cat_id', intval($category[$i]));
158 if (!
$GLOBALS[
'xoopsSecurity']->check()) {
161 $redirect_to_edit =
false;
164 if (!$obj->getVar(
'field_config') && !$obj->getVar(
'field_show') && !$obj->getVar(
'field_edit')) {
169 $obj->setVar(
'field_name',
$_REQUEST[
'field_name']);
170 $obj->setVar(
'field_moduleid',
$GLOBALS[
'xoopsModule']->getVar(
'mid'));
171 $obj->setVar(
'field_show', 1);
172 $obj->setVar(
'field_edit', 1);
173 $obj->setVar(
'field_config', 1);
174 $redirect_to_edit =
true;
176 $obj->setVar(
'field_title',
$_REQUEST[
'field_title']);
177 $obj->setVar(
'field_description',
$_REQUEST[
'field_description']);
178 if ($obj->getVar(
'field_config')) {
179 $obj->setVar(
'field_type',
$_REQUEST[
'field_type']);
180 if (isset(
$_REQUEST[
'field_valuetype'])) {
181 $obj->setVar(
'field_valuetype',
$_REQUEST[
'field_valuetype']);
183 $options = $obj->getVar(
'field_options');
189 $redirect_to_edit =
true;
193 foreach (
$_REQUEST[
'addOption'] as $option) {
194 if (empty($option[
'value']))
continue;
195 $options[$option[
'key']] = $option[
'value'];
196 $redirect_to_edit =
true;
199 $obj->setVar(
'field_options',
$options);
201 if ($obj->getVar(
'field_edit')) {
203 $obj->setVar(
'field_required', $required);
204 if (isset(
$_REQUEST[
'field_maxlength'])) {
205 $obj->setVar(
'field_maxlength',
$_REQUEST[
'field_maxlength']);
208 $field_default = $obj->getValueForSave(
$_REQUEST[
'field_default']);
210 if (is_array($field_default)) {
211 $obj->setVar(
'field_default', serialize($field_default));
213 $obj->setVar(
'field_default', $field_default);
218 if ($obj->getVar(
'field_show')) {
219 $obj->setVar(
'field_weight',
$_REQUEST[
'field_weight']);
220 $obj->setVar(
'cat_id',
$_REQUEST[
'field_category']);
223 $obj->setVar(
'step_id',
$_REQUEST[
'step_id']);
229 if ($obj->getVar(
'field_show')) {
230 $perm_arr[] =
'profile_show';
231 $perm_arr[] =
'profile_visible';
233 if ($obj->getVar(
'field_edit')) {
234 $perm_arr[] =
'profile_edit';
236 if ($obj->getVar(
'field_edit') || $obj->getVar(
'field_show')) {
237 $perm_arr[] =
'profile_search';
239 if (count($perm_arr) > 0) {
240 foreach ($perm_arr as $perm) {
245 $perms = $groupperm_handler->getObjects(
$criteria);
246 if (count($perms) > 0) {
247 foreach (array_keys($perms) as $i) {
248 $groups[$perms[
$i]->getVar(
'gperm_groupid')] =& $perms[
$i];
254 $groupid = intval($groupid);
255 if (!isset(
$groups[$groupid])) {
256 $perm_obj =& $groupperm_handler->create();
257 $perm_obj->setVar(
'gperm_name', $perm);
258 $perm_obj->setVar(
'gperm_itemid', intval($obj->getVar(
'field_id')));
259 $perm_obj->setVar(
'gperm_modid',
$GLOBALS[
'xoopsModule']->getVar(
'mid'));
260 $perm_obj->setVar(
'gperm_groupid', $groupid);
261 $groupperm_handler->insert($perm_obj);
266 if (count($removed_groups) > 0) {
267 $criteria->add(
new Criteria(
'gperm_groupid',
"(" . implode(
',', $removed_groups) .
")",
"IN"));
268 $groupperm_handler->deleteAll(
$criteria);
273 $groupperm_handler->deleteAll(
$criteria);
278 $url = $redirect_to_edit ?
'field.php?op=edit&id=' . $obj->getVar(
'field_id') :
'field.php';
281 include_once(
'../include/forms.php');
282 echo $obj->getHtmlErrors();
289 if (!$obj->getVar(
'field_config')) {
293 if (!
$GLOBALS[
'xoopsSecurity']->check()) {
299 echo $obj->getHtmlErrors();
308 $field_id = intval(
$_REQUEST[
'field_id']);
309 if (isset(
$_REQUEST[
'field_required'])) {
310 $field_required = intval(
$_REQUEST[
'field_required']);
317 if (isset($template_main)) {
318 $GLOBALS[
'xoopsTpl']->display(
"db:{$template_main}");
323 $field_required = ($field_required == 1) ? 0 : 1;
324 $this_handler =& xoops_getModuleHandler(
'field',
'profile');
325 $obj = $this_handler->get($field_id);
326 $obj->setVar(
'field_required', $field_required);
327 if ($this_handler->insert($obj,
true)) {
335 include
'admin_footer.php';