XOOPS 2.5.6  Final
 All Classes Namespaces Files Functions Variables Pages
visibility.php
Go to the documentation of this file.
1 <?php
20 include 'admin_header.php';
21 
22 //there is no way to override current tabs when using system menu
23 //this dirty hack will have to do it
24 $_SERVER['REQUEST_URI'] = "admin/permissions.php";
25 
27 
28 $op = isset($_REQUEST['op']) ? $_REQUEST['op'] : "visibility";
29 
32 $fields = $field_handler->getList();
33 
34 if ( isset($_REQUEST['submit']) ) {
35  $visibility = $visibility_handler->create();
36  $visibility->setVar('field_id', $_REQUEST['field_id']);
37  $visibility->setVar('user_group', $_REQUEST['ug']);
38  $visibility->setVar('profile_group', $_REQUEST['pg']);
39  $visibility_handler->insert($visibility, true);
40  redirect_header("visibility.php", 2, sprintf(_PROFILE_AM_SAVEDSUCCESS, _PROFILE_AM_PROF_VISIBLE) );
41  exit();
42 }
43 if ( $op == "del" ) {
44  $criteria = new CriteriaCompo(new Criteria('field_id', intval($_REQUEST['field_id']) ));
45  $criteria->add(new Criteria('user_group', intval($_REQUEST['ug']) ));
46  $criteria->add(new Criteria('profile_group', intval($_REQUEST['pg']) ));
47  $visibility_handler->deleteAll($criteria, true);
49  exit();
50 }
51 
52 include_once $GLOBALS['xoops']->path( "/class/xoopsformloader.php" );
53 $opform = new XoopsSimpleForm('', 'opform', 'permissions.php', "get");
54 $op_select = new XoopsFormSelect("", 'op', $op);
55 $op_select->setExtra('onchange="document.forms.opform.submit()"');
56 $op_select->addOption('visibility', _PROFILE_AM_PROF_VISIBLE);
57 $op_select->addOption('edit', _PROFILE_AM_PROF_EDITABLE);
58 $op_select->addOption('search', _PROFILE_AM_PROF_SEARCH);
59 $op_select->addOption('access', _PROFILE_AM_PROF_ACCESS);
60 $opform->addElement($op_select);
61 $opform->display();
62 
64 $criteria->setGroupby("field_id, user_group, profile_group");
65 $criteria->setSort('field_id');
66 $criteria->setOrder('DESC');
67 $visibilities = $visibility_handler->getAll($criteria, false, false, true);
68 
70 $groups = $member_handler->getGroupList();
72 asort($groups);
73 
74 $GLOBALS['xoopsTpl']->assign('fields', $fields);
75 $GLOBALS['xoopsTpl']->assign('visibilities', $visibilities);
76 $GLOBALS['xoopsTpl']->assign('groups', $groups);
77 
78 $add_form = new XoopsSimpleForm('', 'addform', 'visibility.php');
79 
81 $sel_field->setExtra("style='width: 200px;'");
82 $sel_field->addOptionArray($fields);
83 $add_form->addElement($sel_field);
84 
86 $sel_ug->addOptionArray($groups);
87 $add_form->addElement($sel_ug);
88 
89 unset($groups[XOOPS_GROUP_ANONYMOUS]);
91 $sel_pg->addOptionArray($groups);
92 $add_form->addElement($sel_pg);
93 
94 $add_form->addElement(new XoopsFormButton('', 'submit', _ADD, 'submit') );
95 $add_form->assign($GLOBALS['xoopsTpl']);
96 
97 $GLOBALS['xoopsTpl']->display("db:profile_admin_visibility.html");
98 
99 include 'admin_footer.php';
100 //xoops_cp_footer();