/** show a dialog for modifying page manager permissions for a group/capacity
  *
  * @return void results are returned as output in $this->output
  * @uses $WAS_SCRIPT_NAME
  * @uses $CFG
  */
 function capacity_pagemanager()
 {
     global $WAS_SCRIPT_NAME, $CFG;
     $group_id = get_parameter_int('group', NULL);
     $capacity_code = get_parameter_int('capacity', NULL);
     // 0 -- sanity check
     if (!$this->valid_group_capacity($group_id, $capacity_code)) {
         $this->groups_overview();
         return;
     }
     // 1 -- maybe change the state of the open/closed areas
     if (!isset($_SESSION['aclmanager_open_areas'])) {
         $_SESSION['aclmanager_open_areas'] = FALSE;
         // default: everything is closed
     }
     $area_id = get_parameter_int('area', NULL);
     $_SESSION['aclmanager_open_areas'] = $this->areas_expand_collapse($_SESSION['aclmanager_open_areas'], $area_id);
     // 2 -- which acl to use?
     if (($acl_id = $this->calc_acl_id($group_id, $capacity_code)) === FALSE) {
         $this->capacity_overview();
         return;
     }
     //
     // 3A -- construct necessary parameters for dialog
     //
     $a_params = $this->a_params(TASK_GROUP_CAPACITY_SAVE, $group_id, $capacity_code);
     $limit = get_parameter_int('limit', $CFG->pagination_height);
     $offset = get_parameter_int('offset', 0);
     if ($limit != $CFG->pagination_height) {
         $a_params['limit'] = $limit;
     }
     if ($offset != 0) {
         $a_params['offset'] = $offset;
     }
     //
     // 3B -- setup Aclmanager to do the dirty work
     //
     include_once $CFG->progdir . '/lib/aclmanager.class.php';
     $acl = new AclManager($this->output, $acl_id, ACL_TYPE_PAGEMANAGER);
     $acl->set_action($a_params);
     $params = $this->get_group_capacity_names($group_id, $capacity_code);
     $acl->set_header(t('groupmanager_capacity_pagemanager_header', 'admin', $params));
     $acl->set_intro(t('groupmanager_capacity_pagemanager_explanation', 'admin', $params));
     $acl->set_dialog(GROUPMANAGER_DIALOG_CAPACITY_PAGEMANAGER);
     // Enable pagination for this one: the list of nodes can be very very long so split up in smaller screens.
     $a_params = $this->a_params(TASK_GROUP_CAPACITY_PAGEMANAGER, $group_id, $capacity_code);
     $acl->enable_pagination($a_params, $limit, $offset);
     // Also enable the expand/collapse feature
     $acl->enable_area_view($a_params, $_SESSION['aclmanager_open_areas']);
     //
     // 4 -- show dialog + menu
     //
     $acl->show_dialog();
     $this->show_menu_groupcapacity($group_id, $capacity_code, TASK_GROUP_CAPACITY_PAGEMANAGER);
 }
 /** show a dialog for modifying page manager permissions for a user
  *
  * @return void results are returned as output in $this->output
  * @uses $WAS_SCRIPT_NAME
  * @uses $CFG
  */
 function user_pagemanager()
 {
     global $WAS_SCRIPT_NAME, $CFG;
     //
     // 0 -- sanity check
     //
     $user_id = get_parameter_int('user', NULL);
     if (is_null($user_id)) {
         logger("usermanager->user_pagemanager(): unspecified parameter user");
         $this->output->add_message(t('error_invalid_parameters', 'admin'));
         $this->users_overview();
         return;
     }
     //
     // 1 -- maybe change the state of the open/closed areas
     //
     if (!isset($_SESSION['aclmanager_open_areas'])) {
         $_SESSION['aclmanager_open_areas'] = FALSE;
         // default: everything is closed
     }
     $area_id = get_parameter_int('area', NULL);
     $_SESSION['aclmanager_open_areas'] = $this->areas_expand_collapse($_SESSION['aclmanager_open_areas'], $area_id);
     //
     // 2 -- which acl to use?
     //
     if (($acl_id = $this->calc_acl_id($user_id)) === FALSE) {
         $this->user_edit();
         return;
     }
     //
     // 3A -- construct necessary parameters for dialog
     //
     $related_acls = calc_user_related_acls($user_id);
     $a_params = $this->a_params(TASK_USER_SAVE, $user_id);
     $params = $this->get_user_names($user_id);
     $limit = get_parameter_int('limit', $CFG->pagination_height);
     $offset = get_parameter_int('offset', 0);
     if ($limit != $CFG->pagination_height) {
         $a_params['limit'] = $limit;
     }
     if ($offset != 0) {
         $a_params['offset'] = $offset;
     }
     //
     // 3B -- setup Aclmanager to do the dirty work
     //
     include_once $CFG->progdir . '/lib/aclmanager.class.php';
     $acl = new AclManager($this->output, $acl_id, ACL_TYPE_PAGEMANAGER);
     $acl->set_related_acls($related_acls);
     $acl->set_action($a_params);
     $acl->set_header(t('usermanager_pagemanager_header', 'admin', $params));
     $acl->set_intro(t('usermanager_pagemanager_explanation', 'admin', $params));
     $acl->set_dialog(USERMANAGER_DIALOG_PAGEMANAGER);
     // Enable pagination for this one: the list of nodes can be very very long so split up in smaller screens.
     $a_params = $this->a_params(TASK_USER_PAGEMANAGER, $user_id);
     $acl->enable_pagination($a_params, $limit, $offset);
     // Also enable the expand/collapse feature
     $acl->enable_area_view($a_params, $_SESSION['aclmanager_open_areas']);
     //
     // 4 -- show dialog + menu
     //
     $acl->show_dialog();
     $this->show_menu_user($user_id, TASK_USER_PAGEMANAGER);
 }