コード例 #1
0
 /**
  * Removes Group from the list stored in the session and from 
  * the list of application-defined groups.
  *
  * @access private
  * @param mixed groupList List of groups (id => displayName) stored in session
  * @param mixed group_arg Array or string containing id of group to remove
  * @return TRUE if group successfully deleted
  * @see smdoc_group_user::deleteAll
  * @see smdoc_group_appext::getInstance
  */
 function _deleteGroup(&$groupList, $group_arg)
 {
     if (is_string($group_arg)) {
         $group = $group_arg;
         $group_arg = array();
         $group_arg[$group] = $group;
     } elseif (!is_array($group_arg)) {
         return FALSE;
     }
     // we don't know what this thing is, don't muck up the list.
     $app_defined =& smdoc_group_appext::getInstance($this->foowd);
     foreach ($group_arg as $id) {
         if (smdoc_group::checkGroup($this->foowd, $id)) {
             continue;
         }
         // can't reset system groups
         unset($groupList[$id]);
         if (isset($app_defined->groups[$id])) {
             smdoc_group_user::deleteAll($this->foowd, $id);
             unset($app_defined->groups[$id]);
             $app_defined->foowd_changed = TRUE;
         }
     }
     return $app_defined->foowd_changed;
 }
コード例 #2
0
 /**
  * Output a list of all known groups.
  *
  * Values set in template:
  *  + grouplist       - below
  *  + addForm         - Form for adding a new group
  *  + deleteForm      - Form for deleting groups
  *
  * Sample contents of $t['grouplist']:
  * <pre>
  * array (
  *   'GroupId' => array ( 
  *                 'group_name' => 'GroupName',
  *                 'group_count' => 8,
  *                 'group_delete' => checkbox for deletion
  *                )
  * )
  * </pre>
  *
  * @static
  * @global array Specifies table information for user persistance.
  * @param smdoc $foowd Reference to the foowd environment object.
  * @param string className The name of the class.
  */
 function class_list(&$foowd, $className)
 {
     $foowd->track('smdoc_group->class_list');
     include_once INPUT_DIR . 'input.textbox.php';
     include_once INPUT_DIR . 'input.form.php';
     include_once INPUT_DIR . 'input.checkbox.php';
     global $GROUP_USER_SOURCE;
     $groupList = array();
     /*
      * Create form for adding new group
      */
     $addForm = new input_form('addForm', NULL, SQ_POST, _("Add Group"));
     $newGroup = new input_textbox('newGroup', REGEX_TITLE, NULL, 'New Group', FALSE);
     if ($addForm->submitted() && !empty($newGroup->value) && $newGroup->wasValid) {
         if ($foowd->groups->addGroup($newGroup->value)) {
             $newGroup->value = '';
         }
     }
     $addForm->addObject($newGroup);
     /*
      * Get list of groups that includes only those
      * that users can be assigned to
      */
     $groups = $foowd->getUserGroups(FALSE);
     /*
      * Create form for deleting groups
      */
     $deleteForm = new input_form('deleteForm', NULL, SQ_POST, _("Delete Groups"));
     if (!empty($groups)) {
         foreach ($groups as $id => $name) {
             $elem = array();
             $elem['group_name'] = $name;
             $elem['group_count'] = $foowd->database->count($GROUP_USER_SOURCE, array('title' => $id));
             // Create checkbox for delete form
             // only add checkboxes for groups that can be deleted
             if (!smdoc_group::checkGroup($foowd, $id)) {
                 $deleteBox = new input_checkbox($id, $deleteForm, FALSE, 'Delete');
                 if ($deleteForm->submitted() && $deleteBox->checked) {
                     $foowd->groups->deleteGroup($id);
                     unset($elem);
                 } else {
                     // Add box to form and array
                     $deleteForm->addObject($deleteBox);
                     $elem['group_delete'] =& $deleteForm->objects[$id];
                 }
             } else {
                 $elem['group_delete'] = NULL;
             }
             // Add array to group list
             if (isset($elem)) {
                 $groupList[$id] = $elem;
             }
         }
     }
     $foowd->template->assign_by_ref('addForm', $addForm);
     $foowd->template->assign_by_ref('deleteForm', $deleteForm);
     $foowd->template->assign('grouplist', $groupList);
     $foowd->track();
 }