MidCOM svn: r12759 - in branches/MidCOM_2_8/midcom.admin.user: .
config documentation handler handler/group handler/user
locale midcom static style
bergie
midcom-commits at lists.midgard-project.org
Thu Oct 11 14:33:27 CEST 2007
Author: bergie
Date: Thu Oct 11 14:33:26 2007
New Revision: 12759
URL: http://trac.midgard-project.org/software/changeset/12759
Log:
Backporting user management, refs #7
Added:
branches/MidCOM_2_8/midcom.admin.user/
branches/MidCOM_2_8/midcom.admin.user/config/
branches/MidCOM_2_8/midcom.admin.user/config/config.inc
branches/MidCOM_2_8/midcom.admin.user/config/manifest.inc
branches/MidCOM_2_8/midcom.admin.user/config/schemadb_account.inc
branches/MidCOM_2_8/midcom.admin.user/config/schemadb_group.inc
branches/MidCOM_2_8/midcom.admin.user/config/schemadb_person.inc
branches/MidCOM_2_8/midcom.admin.user/documentation/
branches/MidCOM_2_8/midcom.admin.user/handler/
branches/MidCOM_2_8/midcom.admin.user/handler/group/
branches/MidCOM_2_8/midcom.admin.user/handler/group/create.php
branches/MidCOM_2_8/midcom.admin.user/handler/group/edit.php
branches/MidCOM_2_8/midcom.admin.user/handler/list.php
branches/MidCOM_2_8/midcom.admin.user/handler/user/
branches/MidCOM_2_8/midcom.admin.user/handler/user/create.php
branches/MidCOM_2_8/midcom.admin.user/handler/user/edit.php
branches/MidCOM_2_8/midcom.admin.user/locale/
branches/MidCOM_2_8/midcom.admin.user/locale/default.en.txt (contents, props changed)
branches/MidCOM_2_8/midcom.admin.user/locale/default.fi.txt (contents, props changed)
branches/MidCOM_2_8/midcom.admin.user/midcom/
branches/MidCOM_2_8/midcom.admin.user/midcom/interfaces.php
branches/MidCOM_2_8/midcom.admin.user/package.xml
branches/MidCOM_2_8/midcom.admin.user/plugin.php
branches/MidCOM_2_8/midcom.admin.user/static/
branches/MidCOM_2_8/midcom.admin.user/static/usermgmt.css
branches/MidCOM_2_8/midcom.admin.user/style/
branches/MidCOM_2_8/midcom.admin.user/style/midcom-admin-user-group-create.php
branches/MidCOM_2_8/midcom.admin.user/style/midcom-admin-user-group-edit.php
branches/MidCOM_2_8/midcom.admin.user/style/midcom-admin-user-person-create.php
branches/MidCOM_2_8/midcom.admin.user/style/midcom-admin-user-person-edit.php
branches/MidCOM_2_8/midcom.admin.user/style/midcom-admin-user-personlist-footer.php
branches/MidCOM_2_8/midcom.admin.user/style/midcom-admin-user-personlist-header.php
branches/MidCOM_2_8/midcom.admin.user/style/midcom-admin-user-personlist-item.php
Added: branches/MidCOM_2_8/midcom.admin.user/config/config.inc
==============================================================================
--- (empty file)
+++ branches/MidCOM_2_8/midcom.admin.user/config/config.inc Thu Oct 11 14:33:26 2007
@@ -0,0 +1,22 @@
+'schemadb_person' => 'file:/midcom/admin/user/config/schemadb_person.inc',
+'schemadb_account' => 'file:/midcom/admin/user/config/schemadb_account.inc',
+'schemadb_group' => 'file:/midcom/admin/user/config/schemadb_group.inc',
+'list_without_search' => 20,
+'allow_manage_accounts' => true, // Turn this off if the accounts are integrated with some external source like AD or LDAP
+'search_fields' => array
+(
+ 'firstname',
+ 'lastname',
+ 'username',
+ 'email',
+ 'city',
+ 'postcode',
+),
+'list_fields' => array
+(
+ 'firstname',
+ 'lastname',
+ 'username',
+ 'email',
+ 'city',
+),
\ No newline at end of file
Added: branches/MidCOM_2_8/midcom.admin.user/config/manifest.inc
==============================================================================
--- (empty file)
+++ branches/MidCOM_2_8/midcom.admin.user/config/manifest.inc Thu Oct 11 14:33:26 2007
@@ -0,0 +1,42 @@
+
+ 'name' => 'midcom.admin.user',
+ 'description' => 'User management tool',
+ 'purecode' => true,
+ 'version' => '0.0.1alpha',
+ 'privileges' =>
+ array (
+ ),
+ 'class_definitions' =>
+ array (
+ ),
+ 'package.xml' =>
+ array (
+ 'license' => 'LGPL',
+ 'maintainers' =>
+ array (
+ 'bergie' =>
+ array (
+ 'name' => 'Henri Bergius',
+ 'email' => 'henri.bergius at iki.fi',
+ 'role' => 'lead',
+ ),
+ ),
+ 'dependencies' =>
+ array (
+ 0 => 'midcom.admin.help',
+ 'midcom' =>
+ array (
+ ),
+ ),
+ ),
+ 'state' => 'alpha',
+ 'customdata' => array
+ (
+ 'asgard_plugin' => array
+ (
+ 'class' => 'midcom_admin_user_plugin',
+ 'src' => 'file:/midcom/admin/user/plugin.php',
+ 'name' => 'User Management',
+ 'config' => null,
+ ),
+ ),
Added: branches/MidCOM_2_8/midcom.admin.user/config/schemadb_account.inc
==============================================================================
--- (empty file)
+++ branches/MidCOM_2_8/midcom.admin.user/config/schemadb_account.inc Thu Oct 11 14:33:26 2007
@@ -0,0 +1,27 @@
+// This is for a midcom_db_person object
+'default' => array
+(
+ 'description' => 'person',
+ 'l10n_db' => 'midcom.admin.user',
+ 'fields' => array
+ (
+ 'username' => array
+ (
+ // COMPONENT-REQUIRED
+ 'title' => 'username',
+ 'storage' => 'username',
+ 'type' => 'text',
+ 'widget' => 'text',
+ 'index_method' => 'noindex',
+ ),
+ 'password' => array
+ (
+ // COMPONENT-REQUIRED
+ 'title' => 'password',
+ 'storage' => 'password',
+ 'type' => 'password',
+ 'widget' => 'password',
+ 'index_method' => 'noindex',
+ ),
+ )
+)
\ No newline at end of file
Added: branches/MidCOM_2_8/midcom.admin.user/config/schemadb_group.inc
==============================================================================
--- (empty file)
+++ branches/MidCOM_2_8/midcom.admin.user/config/schemadb_group.inc Thu Oct 11 14:33:26 2007
@@ -0,0 +1,101 @@
+// This is for a midcom_db_person object
+'default' => array
+(
+ 'description' => 'group',
+ 'l10n_db' => 'midcom.admin.user',
+ 'fields' => array
+ (
+ 'name' => array
+ (
+ // COMPONENT-REQUIRED
+ 'title' => 'name',
+ 'storage' => 'name',
+ 'type' => 'text',
+ 'widget' => 'text',
+ 'index_method' => 'noindex',
+ ),
+ 'official' => array
+ (
+ // COMPONENT-RECOMMENDED
+ 'title' => 'official',
+ 'storage' => 'official',
+ 'type' => 'text',
+ 'widget' => 'text',
+ 'required' => true,
+ ),
+ 'owner' => array
+ (
+ 'title' => 'owner group',
+ 'storage' => 'owner',
+ 'type' => 'select',
+ 'type_config' => array
+ (
+ 'require_corresponding_option' => false,
+ 'allow_multiple' => false,
+ 'options' => array(),
+ ),
+ 'widget' => 'chooser',
+ 'widget_config' => array
+ (
+ 'clever_class' => 'group',
+ 'id_field' => 'id',
+ ),
+ ),
+ 'email' => array
+ (
+ 'title' => 'email',
+ 'type' => 'text',
+ 'widget' => 'text',
+ 'storage' => 'email',
+ 'validation' => 'email',
+ ),
+ 'postcode' => array
+ (
+ 'title' => 'postcode',
+ 'type' => 'text',
+ 'widget' => 'text',
+ 'storage' => 'postcode',
+ ),
+ 'city' => array
+ (
+ 'title' => 'city',
+ 'type' => 'text',
+ 'widget' => 'text',
+ 'storage' => 'city',
+ ),
+ 'persons' => array
+ (
+ 'title' => 'members',
+ 'storage' => null,
+ 'type' => 'mnrelation',
+ 'type_config' => array
+ (
+ 'mapping_class_name' => 'midcom_db_member',
+ 'master_fieldname' => 'gid',
+ 'member_fieldname' => 'uid',
+ 'master_is_id' => true,
+ 'option_callback' => 'midcom_helper_datamanager2_callback_select_personlister',
+ 'option_callback_arg' => array
+ (
+ 'key_field' => 'id'
+ ),
+ ),
+ 'widget' => 'chooser',
+ 'widget_config' => array
+ (
+ 'id_field' => 'id',
+ 'result_headers' => array
+ (
+ array(
+ 'name' => 'name',
+ 'title' => 'Name',
+ ),
+ array(
+ 'name' => 'email',
+ 'title' => 'Email',
+ ),
+ ),
+ ),
+ ),
+ ),
+),
\ No newline at end of file
Added: branches/MidCOM_2_8/midcom.admin.user/config/schemadb_person.inc
==============================================================================
--- (empty file)
+++ branches/MidCOM_2_8/midcom.admin.user/config/schemadb_person.inc Thu Oct 11 14:33:26 2007
@@ -0,0 +1,89 @@
+// This is for a midcom_db_person object
+'default' => array
+(
+ 'description' => 'person',
+ 'l10n_db' => 'midcom.admin.user',
+ 'fields' => array
+ (
+ 'firstname' => array
+ (
+ 'title' => 'firstname',
+ 'type' => 'text',
+ 'widget' => 'text',
+ 'storage' => 'firstname',
+ 'index_method' => 'noindex',
+ ),
+ 'lastname' => array
+ (
+ 'title' => 'lastname',
+ 'type' => 'text',
+ 'widget' => 'text',
+ 'storage' => 'lastname',
+ 'index_method' => 'noindex',
+ ),
+ 'email' => array
+ (
+ 'title' => 'email',
+ 'type' => 'text',
+ 'widget' => 'text',
+ 'storage' => 'email',
+ 'validation' => 'email',
+ ),
+ 'workphone' => array
+ (
+ 'title' => 'workphone',
+ 'type' => 'text',
+ 'widget' => 'text',
+ 'storage' => 'workphone'
+ ),
+ 'postcode' => array
+ (
+ 'title' => 'postcode',
+ 'type' => 'text',
+ 'widget' => 'text',
+ 'storage' => 'postcode',
+ ),
+ 'city' => array
+ (
+ 'title' => 'city',
+ 'type' => 'text',
+ 'widget' => 'text',
+ 'storage' => 'city',
+ ),
+ 'groups' => array
+ (
+ 'title' => 'groups',
+ 'storage' => null,
+ 'type' => 'mnrelation',
+ 'type_config' => array
+ (
+ 'mapping_class_name' => 'midcom_db_member',
+ 'master_fieldname' => 'uid',
+ 'member_fieldname' => 'gid',
+ 'master_is_id' => true,
+ 'option_callback' => 'midcom_helper_datamanager2_callback_select_grouplister',
+ 'option_callback_arg' => array
+ (
+ 'value_field' => 'official',
+ 'key_field' => 'id'
+ ),
+ ),
+ 'widget' => 'chooser',
+ 'widget_config' => array
+ (
+ 'id_field' => 'id',
+ 'result_headers' => array
+ (
+ array(
+ 'name' => 'name',
+ 'title' => 'Name',
+ ),
+ array(
+ 'name' => 'official',
+ 'title' => 'Official',
+ ),
+ ),
+ ),
+ ),
+ ),
+),
\ No newline at end of file
Added: branches/MidCOM_2_8/midcom.admin.user/handler/group/create.php
==============================================================================
--- (empty file)
+++ branches/MidCOM_2_8/midcom.admin.user/handler/group/create.php Thu Oct 11 14:33:26 2007
@@ -0,0 +1,154 @@
+<?php
+/**
+ * @package midcom.admin.user
+ * @author The Midgard Project, http://www.midgard-project.org
+ * @version $Id: viewer.php 3975 2006-09-06 17:36:03Z bergie $
+ * @copyright The Midgard Project, http://www.midgard-project.org
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License
+ */
+
+/**
+ * group creation class
+ *
+ * @package midcom.admin.user
+ */
+class midcom_admin_user_handler_group_create extends midcom_baseclasses_components_handler
+{
+ var $_group = null;
+
+ /**
+ * Simple constructor
+ *
+ * @access public
+ */
+ function midcom_admin_user_handler_group_create()
+ {
+ $this->_component = 'midcom.admin.user';
+ parent::midcom_baseclasses_components_handler();
+ }
+
+ function _update_breadcrumb()
+ {
+ // Populate breadcrumb
+ $tmp = Array();
+ $tmp[] = Array
+ (
+ MIDCOM_NAV_URL => "__mfa/asgard_midcom.admin.user/",
+ MIDCOM_NAV_NAME => $_MIDCOM->i18n->get_string('midcom.admin.user', 'midcom.admin.user'),
+ );
+ $tmp[] = Array
+ (
+ MIDCOM_NAV_URL => "__mfa/asgard_midcom.admin.user/group/create/",
+ MIDCOM_NAV_NAME => $this->_request_data['view_title'],
+ );
+ $_MIDCOM->set_custom_context_data('midcom.helper.nav.breadcrumb', $tmp);
+ }
+
+ /**
+ * Loads and prepares the schema database.
+ */
+ function _load_schemadb()
+ {
+ $this->_schemadb = midcom_helper_datamanager2_schema::load_database($this->_config->get('schemadb_group'));
+ }
+
+ /**
+ * Internal helper, loads the controller for the current group. Any error triggers a 500.
+ *
+ * @access private
+ */
+ function _load_controller()
+ {
+ $this->_load_schemadb();
+ $this->_controller =& midcom_helper_datamanager2_controller::create('create');
+ $this->_controller->schemadb =& $this->_schemadb;
+ $this->_controller->schemaname = 'default';
+ $this->_controller->callback_object =& $this;
+ if (! $this->_controller->initialize())
+ {
+ $_MIDCOM->generate_error(MIDCOM_ERRCRIT, 'Failed to initialize a DM2 create controller.');
+ // This will exit.
+ }
+ }
+
+ /**
+ * DM2 creation callback, creates a new group and binds it to the selected group.
+ *
+ * Assumes Admin Privileges.
+ */
+ function & dm2_create_callback (&$controller)
+ {
+ // Create a new group
+ $this->_group = new midcom_db_group();
+ if (! $this->_group->create())
+ {
+ debug_push_class(__CLASS__, __FUNCTION__);
+ debug_print_r('We operated on this object:', $this->_group);
+ debug_pop();
+ $_MIDCOM->generate_error(MIDCOM_ERRCRIT,
+ 'Failed to create a new group, cannot continue. Last Midgard error was: '. mgd_errstr());
+ // This will exit.
+ }
+
+ return $this->_group;
+ }
+
+ /**
+ * Handler method for listing style elements for the currently used component topic
+ *
+ * @access private
+ * @param string $handler_id Name of the used handler
+ * @param mixed $args Array containing the variable arguments passed to the handler
+ * @param mixed $data Data passed to the show method
+ * @return boolean Indicating successful request
+ */
+ function _handler_create($handler_id, $args, &$data)
+ {
+ $data['view_title'] = $_MIDCOM->i18n->get_string('create group', 'midcom.admin.user');
+ $_MIDCOM->set_pagetitle($data['view_title']);
+
+ $data['asgard_toolbar'] = new midcom_helper_toolbar();
+
+ $this->_load_controller();
+ switch ($this->_controller->process_form())
+ {
+ case 'save':
+ // Show confirmation for the group
+ $_MIDCOM->uimessages->add($this->_l10n->get('midcom.admin.user'), sprintf($this->_l10n->get('group %s saved'), $this->_group->name));
+ $_MIDCOM->relocate("__mfa/asgard_midcom.admin.user/group/edit/{$this->_group->guid}/");
+
+ case 'cancel':
+ $_MIDCOM->relocate('__mfa/asgard_midcom.admin.user/');
+ // This will exit.
+ }
+
+ // Ensure we get the correct styles
+ $_MIDCOM->style->prepend_component_styledir('midgard.admin.asgard');
+ $_MIDCOM->style->prepend_component_styledir('midcom.admin.user');
+ $_MIDCOM->skip_page_style = true;
+
+ $this->_update_breadcrumb();
+
+ return true;
+ }
+
+ /**
+ * Show list of the style elements for the currently createed topic component
+ *
+ * @access private
+ * @param string $handler_id Name of the used handler
+ * @param mixed $data Data passed to the show method
+ */
+ function _show_create($handler_id, &$data)
+ {
+ midcom_show_style('midgard_admin_asgard_header');
+ midcom_show_style('midgard_admin_asgard_middle');
+
+ $data['group'] =& $this->_group;
+ $data['controller'] =& $this->_controller;
+ midcom_show_style('midcom-admin-user-group-create');
+
+ midcom_show_style('midgard_admin_asgard_footer');
+ }
+}
+?>
Added: branches/MidCOM_2_8/midcom.admin.user/handler/group/edit.php
==============================================================================
--- (empty file)
+++ branches/MidCOM_2_8/midcom.admin.user/handler/group/edit.php Thu Oct 11 14:33:26 2007
@@ -0,0 +1,152 @@
+<?php
+/**
+ * @package midcom.admin.user
+ * @author The Midgard Project, http://www.midgard-project.org
+ * @version $Id: viewer.php 3975 2006-09-06 17:36:03Z bergie $
+ * @copyright The Midgard Project, http://www.midgard-project.org
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License
+ */
+
+/**
+ * Style editor class for listing style elements
+ *
+ * @package midcom.admin.user
+ */
+class midcom_admin_user_handler_group_edit extends midcom_baseclasses_components_handler
+{
+ var $_group = null;
+
+ /**
+ * Simple constructor
+ *
+ * @access public
+ */
+ function midcom_admin_user_handler_group_edit()
+ {
+ $this->_component = 'midcom.admin.user';
+ parent::midcom_baseclasses_components_handler();
+ }
+
+ function _update_breadcrumb()
+ {
+ // Populate breadcrumb
+ $tmp = Array();
+
+ $grp = $this->_group;
+ while ($grp)
+ {
+ $tmp[] = Array
+ (
+ MIDCOM_NAV_URL => "__mfa/asgard_midcom.admin.user/group/edit/{$grp->guid}",
+ MIDCOM_NAV_NAME => $grp->official,
+ );
+ $grp = $grp->get_parent();
+ }
+ $tmp[] = Array
+ (
+ MIDCOM_NAV_URL => "__mfa/asgard_midcom.admin.user/",
+ MIDCOM_NAV_NAME => $_MIDCOM->i18n->get_string('midcom.admin.user', 'midcom.admin.user'),
+ );
+ $tmp = array_reverse($tmp);
+
+ $_MIDCOM->set_custom_context_data('midcom.helper.nav.breadcrumb', $tmp);
+ }
+
+ /**
+ * Loads and prepares the schema database.
+ */
+ function _load_schemadb()
+ {
+ $this->_schemadb = midcom_helper_datamanager2_schema::load_database($this->_config->get('schemadb_group'));
+ }
+
+ /**
+ * Internal helper, loads the controller for the current group. Any error triggers a 500.
+ *
+ * @access private
+ */
+ function _load_controller()
+ {
+ $this->_load_schemadb();
+ $this->_controller =& midcom_helper_datamanager2_controller::create('simple');
+ $this->_controller->schemadb =& $this->_schemadb;
+ $this->_controller->set_storage($this->_group, 'default');
+ if (! $this->_controller->initialize())
+ {
+ $_MIDCOM->generate_error(MIDCOM_ERRCRIT, "Failed to initialize a DM2 controller instance for group {$this->_group->id}.");
+ // This will exit.
+ }
+ }
+
+
+ /**
+ * Handler method for listing style elements for the currently used component topic
+ *
+ * @access private
+ * @param string $handler_id Name of the used handler
+ * @param mixed $args Array containing the variable arguments passed to the handler
+ * @param mixed $data Data passed to the show method
+ * @return boolean Indicating successful request
+ */
+ function _handler_edit($handler_id, $args, &$data)
+ {
+ $this->_group = new midcom_db_group($args[0]);
+ if ( !$this->_group
+ || !$this->_group->guid)
+ {
+ return false;
+ }
+ $this->_group->require_do('midgard:update');
+
+ $data['view_title'] = sprintf($_MIDCOM->i18n->get_string('edit %s', 'midcom.admin.user'), $this->_group->official);
+ $_MIDCOM->set_pagetitle($data['view_title']);
+ $this->_update_breadcrumb();
+
+ $data['asgard_toolbar'] = new midcom_helper_toolbar();
+
+ $this->_load_controller();
+ switch ($this->_controller->process_form())
+ {
+ case 'save':
+ // Show confirmation for the group
+ $_MIDCOM->uimessages->add($this->_l10n->get('midcom.admin.user'), sprintf($this->_l10n->get('group %s saved'), $this->_group->name));
+ $_MIDCOM->relocate("__mfa/asgard_midcom.admin.user/group/edit/{$this->_group->guid}/");
+ // This will exit.
+
+ case 'cancel':
+ $_MIDCOM->relocate('__mfa/asgard_midcom.admin.user/');
+ // This will exit.
+ }
+
+ // Ensure we get the correct styles
+ $_MIDCOM->style->prepend_component_styledir('midgard.admin.asgard');
+ $_MIDCOM->style->prepend_component_styledir('midcom.admin.user');
+ $_MIDCOM->skip_page_style = true;
+
+ $data['language_code'] = '';
+ midgard_admin_asgard_plugin::bind_to_object($this->_group, $handler_id, &$data);
+ $this->_update_breadcrumb();
+
+ return true;
+ }
+
+ /**
+ * Show list of the style elements for the currently edited topic component
+ *
+ * @access private
+ * @param string $handler_id Name of the used handler
+ * @param mixed $data Data passed to the show method
+ */
+ function _show_edit($handler_id, &$data)
+ {
+ midcom_show_style('midgard_admin_asgard_header');
+ midcom_show_style('midgard_admin_asgard_middle');
+
+ $data['group'] =& $this->_group;
+ $data['controller'] =& $this->_controller;
+ midcom_show_style('midcom-admin-user-group-edit');
+
+ midcom_show_style('midgard_admin_asgard_footer');
+ }
+}
+?>
Added: branches/MidCOM_2_8/midcom.admin.user/handler/list.php
==============================================================================
--- (empty file)
+++ branches/MidCOM_2_8/midcom.admin.user/handler/list.php Thu Oct 11 14:33:26 2007
@@ -0,0 +1,220 @@
+<?php
+/**
+ * @package midcom.admin.user
+ * @author The Midgard Project, http://www.midgard-project.org
+ * @version $Id: viewer.php 3975 2006-09-06 17:36:03Z bergie $
+ * @copyright The Midgard Project, http://www.midgard-project.org
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License
+ */
+
+/**
+ * Style editor class for listing style elements
+ *
+ * @package midcom.admin.user
+ */
+class midcom_admin_user_handler_list extends midcom_baseclasses_components_handler
+{
+ var $_persons = array();
+
+ /**
+ * Simple constructor
+ *
+ * @access public
+ */
+ function midcom_admin_user_handler_list()
+ {
+ $this->_component = 'midcom.admin.user';
+ parent::midcom_baseclasses_components_handler();
+ }
+
+ function _update_breadcrumb()
+ {
+ // Populate breadcrumb
+ $tmp = Array();
+ $tmp[] = Array
+ (
+ MIDCOM_NAV_URL => "__mfa/asgard_midcom.admin.user/",
+ MIDCOM_NAV_NAME => $this->_request_data['view_title'],
+ );
+ $_MIDCOM->set_custom_context_data('midcom.helper.nav.breadcrumb', $tmp);
+ }
+
+ /**
+ * Handler method for listing style elements for the currently used component topic
+ *
+ * @access private
+ * @param string $handler_id Name of the used handler
+ * @param mixed $args Array containing the variable arguments passed to the handler
+ * @param mixed $data Data passed to the show method
+ * @return boolean Indicating successful request
+ */
+ function _handler_list($handler_id, $args, &$data)
+ {
+ $data['view_title'] = $_MIDCOM->i18n->get_string('midcom.admin.user', 'midcom.admin.user');
+ $_MIDCOM->set_pagetitle($data['view_title']);
+
+ $data['asgard_toolbar'] = new midcom_helper_toolbar();
+ $data['asgard_toolbar']->add_item
+ (
+ array
+ (
+ MIDCOM_TOOLBAR_URL => "__mfa/asgard_midcom.admin.user/create/",
+ MIDCOM_TOOLBAR_LABEL => $_MIDCOM->i18n->get_string('create user', 'midcom.admin.user'),
+ MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock_person.png',
+ MIDCOM_TOOLBAR_ENABLED => $this->_config->get('allow_manage_accounts'),
+ )
+ );
+ $data['asgard_toolbar']->add_item
+ (
+ array
+ (
+ MIDCOM_TOOLBAR_URL => "__mfa/asgard_midcom.admin.user/group/create/",
+ MIDCOM_TOOLBAR_LABEL => $_MIDCOM->i18n->get_string('create group', 'midcom.admin.user'),
+ MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock_people.png',
+ )
+ );
+
+ // See what fields we want to use in the search
+ $data['search_fields'] = $this->_config->get('search_fields');
+ $data['list_fields'] = $this->_config->get('list_fields');
+
+ if ( isset($_POST['midcom_admin_user'])
+ && is_array($_POST['midcom_admin_user'])
+ && $_POST['midcom_admin_user_action'])
+ {
+ foreach ($_POST['midcom_admin_user'] as $person_id)
+ {
+ $person = new midcom_db_person($person_id);
+
+ switch ($_POST['midcom_admin_user_action'])
+ {
+ case 'removeaccount':
+ if (!$this->_config->get('allow_manage_accounts'))
+ {
+ break;
+ }
+ $person->parameter('net.nehmer.account', 'username', $person->username);
+ $person->username = '';
+ $person->password = '';
+ if ($person->update())
+ {
+ $_MIDCOM->uimessages->add($this->_l10n->get('midcom.admin.user'), sprintf($this->_l10n->get('user account revoked for %s'), $person->name));
+ }
+ break;
+
+ case 'groupadd':
+ if (isset($_POST['midcom_admin_user_group']))
+ {
+ $member = new midcom_db_member();
+ $member->uid = $person->id;
+ $member->gid = (int) $_POST['midcom_admin_user_group'];
+ if ($member->create())
+ {
+ $_MIDCOM->uimessages->add($this->_l10n->get('midcom.admin.user'), sprintf($this->_l10n->get('user %s added to group'), $person->name));
+ }
+ }
+ }
+ }
+ }
+
+ if (isset($_REQUEST['midcom_admin_user_search']))
+ {
+ // Run the person-seeking QB
+ $qb = midcom_db_person::new_query_builder();
+ $qb->begin_group('OR');
+ foreach ($data['search_fields'] as $field)
+ {
+ $qb->add_constraint($field, 'LIKE', "{$_REQUEST['midcom_admin_user_search']}%");
+ }
+ $qb->end_group('OR');
+ $qb->add_order('lastname');
+ $qb->add_order('firstname');
+
+ $this->_persons = $qb->execute();
+ }
+ else
+ {
+ // List all persons if there are less than N of them
+ $qb = midcom_db_person::new_query_builder();
+
+ if ($qb->count() < $this->_config->get('list_without_search'))
+ {
+ $qb->add_order('lastname');
+ $qb->add_order('firstname');
+
+ $this->_persons = $qb->execute();
+ }
+ }
+
+ $data['groups'] = array
+ (
+ 0 => 'Midgard Administrators',
+ );
+ if (count($this->_persons) > 0)
+ {
+ $qb = midcom_db_group::new_query_builder();
+ $groups = $qb->execute();
+ foreach ($groups as $group)
+ {
+ $data['groups'][$group->id] = $group;
+ }
+ }
+
+ $this->_update_breadcrumb();
+
+ // Ensure we get the correct styles
+ $_MIDCOM->style->prepend_component_styledir('midgard.admin.asgard');
+ $_MIDCOM->style->prepend_component_styledir('midcom.admin.user');
+ $_MIDCOM->skip_page_style = true;
+
+ $_MIDCOM->add_link_head
+ (
+ array
+ (
+ 'rel' => 'stylesheet',
+ 'type' => 'text/css',
+ 'href' => MIDCOM_STATIC_URL . '/midcom.admin.user/usermgmt.css',
+ )
+ );
+
+
+ return true;
+ }
+
+ /**
+ * Show list of the style elements for the currently edited topic component
+ *
+ * @access private
+ * @param string $handler_id Name of the used handler
+ * @param mixed $data Data passed to the show method
+ */
+ function _show_list($handler_id, &$data)
+ {
+ midcom_show_style('midgard_admin_asgard_header');
+ midcom_show_style('midgard_admin_asgard_middle');
+ $data['config'] =& $this->_config;
+
+ $data['persons'] =& $this->_persons;
+ midcom_show_style('midcom-admin-user-personlist-header');
+
+ $data['even'] = false;
+ foreach ($data['persons'] as $person)
+ {
+ $data['person'] = $person;
+ midcom_show_style('midcom-admin-user-personlist-item');
+ if (!$data['even'])
+ {
+ $data['even'] = true;
+ }
+ else
+ {
+ $data['even'] = false;
+ }
+ }
+
+ midcom_show_style('midcom-admin-user-personlist-footer');
+
+ midcom_show_style('midgard_admin_asgard_footer');
+ }
+}
+?>
Added: branches/MidCOM_2_8/midcom.admin.user/handler/user/create.php
==============================================================================
--- (empty file)
+++ branches/MidCOM_2_8/midcom.admin.user/handler/user/create.php Thu Oct 11 14:33:26 2007
@@ -0,0 +1,154 @@
+<?php
+/**
+ * @package midcom.admin.user
+ * @author The Midgard Project, http://www.midgard-project.org
+ * @version $Id: viewer.php 3975 2006-09-06 17:36:03Z bergie $
+ * @copyright The Midgard Project, http://www.midgard-project.org
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License
+ */
+
+/**
+ * Person creation class
+ *
+ * @package midcom.admin.user
+ */
+class midcom_admin_user_handler_user_create extends midcom_baseclasses_components_handler
+{
+ var $_person = null;
+
+ /**
+ * Simple constructor
+ *
+ * @access public
+ */
+ function midcom_admin_user_handler_user_create()
+ {
+ $this->_component = 'midcom.admin.user';
+ parent::midcom_baseclasses_components_handler();
+ }
+
+ function _update_breadcrumb()
+ {
+ // Populate breadcrumb
+ $tmp = Array();
+ $tmp[] = Array
+ (
+ MIDCOM_NAV_URL => "__mfa/asgard_midcom.admin.user/",
+ MIDCOM_NAV_NAME => $_MIDCOM->i18n->get_string('midcom.admin.user', 'midcom.admin.user'),
+ );
+ $tmp[] = Array
+ (
+ MIDCOM_NAV_URL => "__mfa/asgard_midcom.admin.user/create/",
+ MIDCOM_NAV_NAME => $this->_request_data['view_title'],
+ );
+ $_MIDCOM->set_custom_context_data('midcom.helper.nav.breadcrumb', $tmp);
+ }
+
+ /**
+ * Loads and prepares the schema database.
+ */
+ function _load_schemadb()
+ {
+ $this->_schemadb = midcom_helper_datamanager2_schema::load_database($this->_config->get('schemadb_person'));
+ }
+
+ /**
+ * Internal helper, loads the controller for the current person. Any error triggers a 500.
+ *
+ * @access private
+ */
+ function _load_controller()
+ {
+ $this->_load_schemadb();
+ $this->_controller =& midcom_helper_datamanager2_controller::create('create');
+ $this->_controller->schemadb =& $this->_schemadb;
+ $this->_controller->schemaname = 'default';
+ $this->_controller->callback_object =& $this;
+ if (! $this->_controller->initialize())
+ {
+ $_MIDCOM->generate_error(MIDCOM_ERRCRIT, 'Failed to initialize a DM2 create controller.');
+ // This will exit.
+ }
+ }
+
+ /**
+ * DM2 creation callback, creates a new person and binds it to the selected group.
+ *
+ * Assumes Admin Privileges.
+ */
+ function & dm2_create_callback (&$controller)
+ {
+ // Create a new person
+ $this->_person = new midcom_db_person();
+ if (! $this->_person->create())
+ {
+ debug_push_class(__CLASS__, __FUNCTION__);
+ debug_print_r('We operated on this object:', $this->_person);
+ debug_pop();
+ $_MIDCOM->generate_error(MIDCOM_ERRCRIT,
+ 'Failed to create a new person, cannot continue. Last Midgard error was: '. mgd_errstr());
+ // This will exit.
+ }
+
+ return $this->_person;
+ }
+
+ /**
+ * Handler method for listing style elements for the currently used component topic
+ *
+ * @access private
+ * @param string $handler_id Name of the used handler
+ * @param mixed $args Array containing the variable arguments passed to the handler
+ * @param mixed $data Data passed to the show method
+ * @return boolean Indicating successful request
+ */
+ function _handler_create($handler_id, $args, &$data)
+ {
+ $data['view_title'] = $_MIDCOM->i18n->get_string('create user', 'midcom.admin.user');
+ $_MIDCOM->set_pagetitle($data['view_title']);
+
+ $data['asgard_toolbar'] = new midcom_helper_toolbar();
+
+ $this->_load_controller();
+ switch ($this->_controller->process_form())
+ {
+ case 'save':
+ // Show confirmation for the user
+ $_MIDCOM->uimessages->add($this->_l10n->get('midcom.admin.user'), sprintf($this->_l10n->get('person %s saved'), $this->_person->name));
+ $_MIDCOM->relocate("__mfa/asgard_midcom.admin.user/edit/{$this->_person->guid}/");
+
+ case 'cancel':
+ $_MIDCOM->relocate('__mfa/asgard_midcom.admin.user/');
+ // This will exit.
+ }
+
+ // Ensure we get the correct styles
+ $_MIDCOM->style->prepend_component_styledir('midgard.admin.asgard');
+ $_MIDCOM->style->prepend_component_styledir('midcom.admin.user');
+ $_MIDCOM->skip_page_style = true;
+
+ $this->_update_breadcrumb();
+
+ return true;
+ }
+
+ /**
+ * Show list of the style elements for the currently createed topic component
+ *
+ * @access private
+ * @param string $handler_id Name of the used handler
+ * @param mixed $data Data passed to the show method
+ */
+ function _show_create($handler_id, &$data)
+ {
+ midcom_show_style('midgard_admin_asgard_header');
+ midcom_show_style('midgard_admin_asgard_middle');
+
+ $data['person'] =& $this->_person;
+ $data['controller'] =& $this->_controller;
+ midcom_show_style('midcom-admin-user-person-create');
+
+ midcom_show_style('midgard_admin_asgard_footer');
+ }
+}
+?>
Added: branches/MidCOM_2_8/midcom.admin.user/handler/user/edit.php
==============================================================================
--- (empty file)
+++ branches/MidCOM_2_8/midcom.admin.user/handler/user/edit.php Thu Oct 11 14:33:26 2007
@@ -0,0 +1,172 @@
+<?php
+/**
+ * @package midcom.admin.user
+ * @author The Midgard Project, http://www.midgard-project.org
+ * @version $Id: viewer.php 3975 2006-09-06 17:36:03Z bergie $
+ * @copyright The Midgard Project, http://www.midgard-project.org
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License
+ */
+
+/**
+ * Style editor class for listing style elements
+ *
+ * @package midcom.admin.user
+ */
+class midcom_admin_user_handler_user_edit extends midcom_baseclasses_components_handler
+{
+ var $_person = null;
+
+ /**
+ * Simple constructor
+ *
+ * @access public
+ */
+ function midcom_admin_user_handler_user_edit()
+ {
+ $this->_component = 'midcom.admin.user';
+ parent::midcom_baseclasses_components_handler();
+ }
+
+ function _update_breadcrumb($handler_id)
+ {
+ // Populate breadcrumb
+ $tmp = Array();
+ $tmp[] = Array
+ (
+ MIDCOM_NAV_URL => "__mfa/asgard_midcom.admin.user/",
+ MIDCOM_NAV_NAME => $_MIDCOM->i18n->get_string('midcom.admin.user', 'midcom.admin.user'),
+ );
+ $tmp[] = Array
+ (
+ MIDCOM_NAV_URL => "__mfa/asgard_midcom.admin.user/edit/{$this->_person->guid}",
+ MIDCOM_NAV_NAME => $this->_request_data['view_title'],
+ );
+
+ if ($handler_id == '____mfa-asgard_midcom.admin.user-user_edit_password')
+ {
+ $tmp[] = Array
+ (
+ MIDCOM_NAV_URL => "__mfa/asgard_midcom.admin.user/password/{$this->_person->guid}",
+ MIDCOM_NAV_NAME => $_MIDCOM->i18n->get_string('edit account', 'midcom.admin.user'),
+ );
+ }
+
+ $_MIDCOM->set_custom_context_data('midcom.helper.nav.breadcrumb', $tmp);
+ }
+
+ /**
+ * Loads and prepares the schema database.
+ */
+ function _load_schemadb($config_key)
+ {
+ $this->_schemadb = midcom_helper_datamanager2_schema::load_database($this->_config->get($config_key));
+ }
+
+ /**
+ * Internal helper, loads the controller for the current person. Any error triggers a 500.
+ *
+ * @access private
+ */
+ function _load_controller()
+ {
+ $this->_controller =& midcom_helper_datamanager2_controller::create('simple');
+ $this->_controller->schemadb =& $this->_schemadb;
+ $this->_controller->set_storage($this->_person, 'default');
+ if (! $this->_controller->initialize())
+ {
+ $_MIDCOM->generate_error(MIDCOM_ERRCRIT, "Failed to initialize a DM2 controller instance for person {$this->_person->id}.");
+ // This will exit.
+ }
+ }
+
+
+ /**
+ * Handler method for listing style elements for the currently used component topic
+ *
+ * @access private
+ * @param string $handler_id Name of the used handler
+ * @param mixed $args Array containing the variable arguments passed to the handler
+ * @param mixed $data Data passed to the show method
+ * @return boolean Indicating successful request
+ */
+ function _handler_edit($handler_id, $args, &$data)
+ {
+ $this->_person = new midcom_db_person($args[0]);
+ if ( !$this->_person
+ || !$this->_person->guid)
+ {
+ return false;
+ }
+ $this->_person->require_do('midgard:update');
+
+ $data['view_title'] = sprintf($_MIDCOM->i18n->get_string('edit %s', 'midcom.admin.user'), $this->_person->name);
+ $_MIDCOM->set_pagetitle($data['view_title']);
+
+ if ($handler_id == '____mfa-asgard_midcom.admin.user-user_edit_password')
+ {
+ $this->_load_schemadb('schemadb_account');
+ }
+ else
+ {
+ $this->_load_schemadb('schemadb_person');
+ }
+
+ $this->_load_controller();
+ switch ($this->_controller->process_form())
+ {
+ case 'save':
+ // Show confirmation for the user
+ $_MIDCOM->uimessages->add($this->_l10n->get('midcom.admin.user'), sprintf($this->_l10n->get('person %s saved'), $this->_person->name));
+ $_MIDCOM->relocate("__mfa/asgard_midcom.admin.user/edit/{$this->_person->guid}/");
+ // This will exit.
+
+ case 'cancel':
+ $_MIDCOM->relocate('__mfa/asgard_midcom.admin.user/');
+ // This will exit.
+ }
+
+ // Ensure we get the correct styles
+ $_MIDCOM->style->prepend_component_styledir('midgard.admin.asgard');
+ $_MIDCOM->style->prepend_component_styledir('midcom.admin.user');
+ $_MIDCOM->skip_page_style = true;
+
+ $data['language_code'] = '';
+ midgard_admin_asgard_plugin::bind_to_object($this->_person, $handler_id, &$data);
+
+ if ($handler_id != '____mfa-asgard_midcom.admin.user-user_edit_password')
+ {
+ $data['asgard_toolbar']->add_item
+ (
+ array
+ (
+ MIDCOM_TOOLBAR_URL => "__mfa/asgard_midcom.admin.user/password/{$this->_person->guid}/",
+ MIDCOM_TOOLBAR_LABEL => $_MIDCOM->i18n->get_string('edit account', 'midcom.admin.user'),
+ MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/repair.png',
+ )
+ );
+ }
+ $this->_update_breadcrumb($handler_id);
+
+ return true;
+ }
+
+ /**
+ * Show list of the style elements for the currently edited topic component
+ *
+ * @access private
+ * @param string $handler_id Name of the used handler
+ * @param mixed $data Data passed to the show method
+ */
+ function _show_edit($handler_id, &$data)
+ {
+ midcom_show_style('midgard_admin_asgard_header');
+ midcom_show_style('midgard_admin_asgard_middle');
+
+ $data['person'] =& $this->_person;
+ $data['controller'] =& $this->_controller;
+ midcom_show_style('midcom-admin-user-person-edit');
+
+ midcom_show_style('midgard_admin_asgard_footer');
+ }
+}
+?>
Added: branches/MidCOM_2_8/midcom.admin.user/locale/default.en.txt
==============================================================================
--- (empty file)
+++ branches/MidCOM_2_8/midcom.admin.user/locale/default.en.txt Thu Oct 11 14:33:26 2007
@@ -0,0 +1,109 @@
+---# MidCOM String Database
+---VERSION 2.1.0
+---CVS $Id$
+---LANGUAGE en
+
+---STRING add to group
+Add to group
+---STRINGEND
+
+---STRING apply to selected
+Apply to selected
+---STRINGEND
+
+---STRING choose action
+Choose action
+---STRINGEND
+
+---STRING city
+City
+---STRINGEND
+
+---STRING create group
+Create group
+---STRINGEND
+
+---STRING create user
+Create user
+---STRINGEND
+
+---STRING edit account
+Edit account
+---STRINGEND
+
+---STRING email
+Email
+---STRINGEND
+
+---STRING firstname
+Firstname
+---STRINGEND
+
+---STRING go
+Go
+---STRINGEND
+
+---STRING group %s saved
+Group %s saved
+---STRINGEND
+
+---STRING groups
+Groups
+---STRINGEND
+
+---STRING lastname
+Lastname
+---STRINGEND
+
+---STRING members
+Members
+---STRINGEND
+
+---STRING midcom.admin.user
+User management
+---STRINGEND
+
+---STRING official
+Official name
+---STRINGEND
+
+---STRING owner group
+Owner group
+---STRINGEND
+
+---STRING person %s saved
+User %s saved
+---STRINGEND
+
+---STRING postcode
+Postcode
+---STRINGEND
+
+---STRING remove account
+Remove account
+---STRINGEND
+
+---STRING search person
+Search users
+---STRINGEND
+
+---STRING the following fields will be searched: %s
+The following fields will be searched: %s
+---STRINGEND
+
+---STRING user %s added to group
+User %s added to group
+---STRINGEND
+
+---STRING user account revoked for %s
+User account revoked for %s
+---STRINGEND
+
+---STRING username
+Username
+---STRINGEND
+
+---STRING workphone
+Work phone
+---STRINGEND
+
Added: branches/MidCOM_2_8/midcom.admin.user/locale/default.fi.txt
==============================================================================
--- (empty file)
+++ branches/MidCOM_2_8/midcom.admin.user/locale/default.fi.txt Thu Oct 11 14:33:26 2007
@@ -0,0 +1,109 @@
+---# MidCOM String Database
+---VERSION 2.1.0
+---CVS $Id$
+---LANGUAGE fi
+
+---STRING add to group
+Lisää ryhmään
+---STRINGEND
+
+---STRING apply to selected
+Tee valituille
+---STRINGEND
+
+---STRING choose action
+Valitse toiminto
+---STRINGEND
+
+---STRING city
+Kaupunki
+---STRINGEND
+
+---STRING create group
+Luo ryhmä
+---STRINGEND
+
+---STRING create user
+Luo käyttäjä
+---STRINGEND
+
+---STRING edit account
+Muokkaa käyttäjätunnusta
+---STRINGEND
+
+---STRING email
+Sähköposti
+---STRINGEND
+
+---STRING firstname
+Etunimi
+---STRINGEND
+
+---STRING go
+Hae
+---STRINGEND
+
+---STRING groups
+Ryhmät
+---STRINGEND
+
+---STRING group %s saved
+Ryhmä %s tallennettu
+---STRINGEND
+
+---STRING lastname
+Sukunimi
+---STRINGEND
+
+---STRING members
+Jäsenet
+---STRINGEND
+
+---STRING midcom.admin.user
+Käyttäjien hallinta
+---STRINGEND
+
+---STRING official
+Virallinen nimi
+---STRINGEND
+
+---STRING owner group
+Omistajaryhmä
+---STRINGEND
+
+---STRING person %s saved
+Käyttäjä %s tallennettu
+---STRINGEND
+
+---STRING postcode
+Postinumero
+---STRINGEND
+
+---STRING remove account
+Poista käyttäjätunnus
+---STRINGEND
+
+---STRING search person
+Hae käyttäjiä
+---STRINGEND
+
+---STRING the following fields will be searched: %s
+Haku tehdään seuraavista kentistä: %s
+---STRINGEND
+
+---STRING username
+Käyttäjätunnus
+---STRINGEND
+
+---STRING workphone
+Työpuhelin
+---STRINGEND
+
+---STRING user %s added to group
+Käyttäjä %s lisätty ryhmään
+---STRINGEND
+
+---STRING user account revoked for %s
+Käyttäjätunnus %s mitätöity
+---STRINGEND
+
Added: branches/MidCOM_2_8/midcom.admin.user/midcom/interfaces.php
==============================================================================
--- (empty file)
+++ branches/MidCOM_2_8/midcom.admin.user/midcom/interfaces.php Thu Oct 11 14:33:26 2007
@@ -0,0 +1,25 @@
+<?php
+/**
+ * @package midcom.admin.user
+ * @author The Midgard Project, http://www.midgard-project.org
+ * @version $Id$
+ * @copyright The Midgard Project, http://www.midgard-project.org
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License
+ */
+
+/**
+ * Style editor class for listing style elements
+ *
+ * @package midcom.admin.user
+ */
+class midcom_admin_user_interface extends midcom_baseclasses_components_interface
+{
+ function midcom_admin_user_interface()
+ {
+ parent::midcom_baseclasses_components_interface();
+
+ $this->_component = 'midcom.admin.user';
+ $this->_purecode = true;
+ }
+}
+?>
Added: branches/MidCOM_2_8/midcom.admin.user/package.xml
==============================================================================
--- (empty file)
+++ branches/MidCOM_2_8/midcom.admin.user/package.xml Thu Oct 11 14:33:26 2007
@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="UTF-8"?>
+ <package packagerversion="1.4.5" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0
+ http://pear.php.net/dtd/tasks-1.0.xsd
+ http://pear.php.net/dtd/package-2.0
+ http://pear.php.net/dtd/package-2.0.xsd">
+ <name>midcom_admin_user</name>
+ <channel>pear.midcom-project.org</channel>
+ <summary>
+ MidCOM component midcom.admin.user
+ </summary>
+ <description>
+ MidCOM component midcom.admin.user
+ </description>
+
+ <lead>
+ <name>Henri Bergius</name>
+ <user>bergie</user>
+ <email>henri.bergius at iki.fi</email>
+ <active>yes</active>
+ </lead>
+
+ <date>2007-10-09</date>
+ <time>15:35:38</time>
+ <version>
+ <release>0.0.1alpha</release>
+ <api>0.0.1alpha</api>
+ </version>
+ <stability>
+ <release>alpha</release>
+ <api>alpha</api>
+ </stability>
+ <license>LGPL</license>
+ <notes>0.0.1alpha alpha</notes>
+ <contents>
+ <dir name="midcom.admin.user">
+ <dir name="config">
+ <file baseinstalldir="midcom/lib/midcom/admin/user" name="config.inc" role="php" />
+ <file baseinstalldir="midcom/lib/midcom/admin/user" name="manifest.inc" role="php" />
+ <file baseinstalldir="midcom/lib/midcom/admin/user" name="schemadb_group.inc" role="php" />
+ <file baseinstalldir="midcom/lib/midcom/admin/user" name="schemadb_person.inc" role="php" />
+ </dir>
+ <dir name="documentation">
+ </dir>
+ <dir name="handler">
+ <dir name="group">
+ <file baseinstalldir="midcom/lib/midcom/admin/user" name="create.php" role="php" />
+ <file baseinstalldir="midcom/lib/midcom/admin/user" name="edit.php" role="php" />
+ </dir>
+ <file baseinstalldir="midcom/lib/midcom/admin/user" name="list.php" role="php" />
+ <dir name="user">
+ <file baseinstalldir="midcom/lib/midcom/admin/user" name="create.php" role="php" />
+ <file baseinstalldir="midcom/lib/midcom/admin/user" name="edit.php" role="php" />
+ </dir>
+ </dir>
+ <dir name="locale">
+ <file baseinstalldir="midcom/lib/midcom/admin/user" name="default.en.txt" role="php" />
+ <file baseinstalldir="midcom/lib/midcom/admin/user" name="default.fi.txt" role="php" />
+ </dir>
+ <dir name="midcom">
+ <file baseinstalldir="midcom/lib/midcom/admin/user" name="interfaces.php" role="php" />
+ </dir>
+ <file baseinstalldir="midcom/lib/midcom/admin/user" name="plugin.php" role="php" />
+ <dir name="static">
+ <file baseinstalldir="/midcom.admin.user" install-as="usermgmt.css" name="usermgmt.css" role="web" />
+ </dir>
+ <dir name="style">
+ <file baseinstalldir="midcom/lib/midcom/admin/user" name="midcom-admin-user-group-create.php" role="php" />
+ <file baseinstalldir="midcom/lib/midcom/admin/user" name="midcom-admin-user-group-edit.php" role="php" />
+ <file baseinstalldir="midcom/lib/midcom/admin/user" name="midcom-admin-user-person-create.php" role="php" />
+ <file baseinstalldir="midcom/lib/midcom/admin/user" name="midcom-admin-user-person-edit.php" role="php" />
+ <file baseinstalldir="midcom/lib/midcom/admin/user" name="midcom-admin-user-personlist-footer.php" role="php" />
+ <file baseinstalldir="midcom/lib/midcom/admin/user" name="midcom-admin-user-personlist-header.php" role="php" />
+ <file baseinstalldir="midcom/lib/midcom/admin/user" name="midcom-admin-user-personlist-item.php" role="php" />
+ </dir>
+ </dir>
+ </contents>
+ <dependencies>
+ <required>
+ <php>
+ <min>4.3.0</min>
+ </php>
+ <pearinstaller>
+ <min>1.4.0</min>
+ </pearinstaller>
+
+ <package>
+ <name>0</name>
+ <channel>pear.midcom-project.org</channel>
+
+ </package>
+
+ <package>
+ <name>midcom</name>
+ <channel>pear.midcom-project.org</channel>
+
+ </package>
+
+ <extension>
+ <name>midgard</name>
+ <min>1.8.1</min>
+ </extension>
+ </required>
+ </dependencies>
+ <phprelease />
+ </package>
+
\ No newline at end of file
Added: branches/MidCOM_2_8/midcom.admin.user/plugin.php
==============================================================================
--- (empty file)
+++ branches/MidCOM_2_8/midcom.admin.user/plugin.php Thu Oct 11 14:33:26 2007
@@ -0,0 +1,112 @@
+<?php
+/**
+ * @package midcom.admin.user
+ * @author The Midgard Project, http://www.midgard-project.org
+ * @version $Id$
+ * @copyright The Midgard Project, http://www.midgard-project.org
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License
+ */
+
+/**
+ * user editor interface for on-site editing of user elements, CSS and JavaScript
+ * files and pictures
+ *
+ * @package midcom.admin.user
+ */
+class midcom_admin_user_plugin extends midcom_baseclasses_components_request
+{
+ /**
+ * Constructor. This probably isn't called in normal plugin users.
+ *
+ * @access public
+ */
+ function midcom_admin_user_plugin()
+ {
+ parent::midcom_baseclasses_components_request();
+ }
+
+ /**
+ * Get the plugin handlers, which act alike with Request Switches of MidCOM
+ * Baseclasses Components (midcom.baseclasses.components.request)
+ *
+ * @access public
+ * @return mixed Array of the plugin handlers
+ */
+ function get_plugin_handlers()
+ {
+ $_MIDCOM->load_library('midgard.admin.asgard');
+ $_MIDCOM->load_library('midcom.admin.user');
+
+ return array
+ (
+ /**
+ * user editor for onsite user editing
+ */
+ /**
+ * List users
+ *
+ * Match /user-editor/
+ */
+ 'user_list' => array
+ (
+ 'handler' => array ('midcom_admin_user_handler_list', 'list'),
+ ),
+ /**
+ * Edit a user
+ *
+ * Match /user-editor/edit/<guid>/
+ */
+ 'user_edit' => array
+ (
+ 'handler' => array ('midcom_admin_user_handler_user_edit', 'edit'),
+ 'fixed_args' => array ('edit'),
+ 'variable_args' => 1,
+ ),
+ /**
+ * Edit a user's password
+ *
+ * Match /user-editor/edit/<guid>/
+ */
+ 'user_edit_password' => array
+ (
+ 'handler' => array ('midcom_admin_user_handler_user_edit', 'edit'),
+ 'fixed_args' => array ('password'),
+ 'variable_args' => 1,
+ ),
+ /**
+ * Create new user
+ *
+ * Match /create/
+ *
+ */
+ 'user_create' => array
+ (
+ 'handler' => array ('midcom_admin_user_handler_user_create','create'),
+ 'fixed_args' => array ('create'),
+ ),
+ /**
+ * Edit a group
+ *
+ * Match /user-editor/group/edit/<guid>/
+ */
+ 'group_edit' => array
+ (
+ 'handler' => array ('midcom_admin_user_handler_group_edit', 'edit'),
+ 'fixed_args' => array ('group', 'edit'),
+ 'variable_args' => 1,
+ ),
+ /**
+ * Create new user
+ *
+ * Match /create/
+ *
+ */
+ 'group_create' => array
+ (
+ 'handler' => array ('midcom_admin_user_handler_group_create','create'),
+ 'fixed_args' => array ('group', 'create'),
+ ),
+ );
+ }
+}
+?>
Added: branches/MidCOM_2_8/midcom.admin.user/static/usermgmt.css
==============================================================================
--- (empty file)
+++ branches/MidCOM_2_8/midcom.admin.user/static/usermgmt.css Thu Oct 11 14:33:26 2007
@@ -0,0 +1,35 @@
+form.midcom_admin_user_search .helptext
+{
+ font-size: smaller;
+}
+
+form.midcom_admin_user_search
+{
+ margin-top: 1em;
+ margin-bottom: 1em;
+}
+
+table.midcom_admin_user_search_results
+{
+ border-collapse: collapse;
+}
+
+table.midcom_admin_user_search_results thead
+{
+ background-color: #555753;
+ color: #ffffff;
+ padding-top: 4px;
+ padding-bottom: 4px;
+}
+table.midcom_admin_user_search_results thead th,
+table.midcom_admin_user_search_results tbody td
+{
+ padding-left: 4px;
+ padding-right: 2px;
+ text-align: left;
+}
+
+table.midcom_admin_user_search_results tr.even td
+{
+ background-color: #eeeeef;
+}
Added: branches/MidCOM_2_8/midcom.admin.user/style/midcom-admin-user-group-create.php
==============================================================================
--- (empty file)
+++ branches/MidCOM_2_8/midcom.admin.user/style/midcom-admin-user-group-create.php Thu Oct 11 14:33:26 2007
@@ -0,0 +1,3 @@
+<h1><?php echo $data['view_title']; ?></h1>
+
+<?php $data['controller']->display_form(); ?>
\ No newline at end of file
Added: branches/MidCOM_2_8/midcom.admin.user/style/midcom-admin-user-group-edit.php
==============================================================================
--- (empty file)
+++ branches/MidCOM_2_8/midcom.admin.user/style/midcom-admin-user-group-edit.php Thu Oct 11 14:33:26 2007
@@ -0,0 +1,3 @@
+<h1><?php echo $data['view_title']; ?></h1>
+
+<?php $data['controller']->display_form(); ?>
\ No newline at end of file
Added: branches/MidCOM_2_8/midcom.admin.user/style/midcom-admin-user-person-create.php
==============================================================================
--- (empty file)
+++ branches/MidCOM_2_8/midcom.admin.user/style/midcom-admin-user-person-create.php Thu Oct 11 14:33:26 2007
@@ -0,0 +1,3 @@
+<h1><?php echo $data['view_title']; ?></h1>
+
+<?php $data['controller']->display_form(); ?>
\ No newline at end of file
Added: branches/MidCOM_2_8/midcom.admin.user/style/midcom-admin-user-person-edit.php
==============================================================================
--- (empty file)
+++ branches/MidCOM_2_8/midcom.admin.user/style/midcom-admin-user-person-edit.php Thu Oct 11 14:33:26 2007
@@ -0,0 +1,3 @@
+<h1><?php echo $data['view_title']; ?></h1>
+
+<?php $data['controller']->display_form(); ?>
\ No newline at end of file
Added: branches/MidCOM_2_8/midcom.admin.user/style/midcom-admin-user-personlist-footer.php
==============================================================================
--- (empty file)
+++ branches/MidCOM_2_8/midcom.admin.user/style/midcom-admin-user-personlist-footer.php Thu Oct 11 14:33:26 2007
@@ -0,0 +1,42 @@
+<?php
+if (count($data['persons']) > 0)
+{
+ ?>
+ </tbody>
+ <tfoot>
+ <tr>
+ <td> </td>
+ <td colspan="<?php echo count($data['list_fields']); ?>">
+ <select name="midcom_admin_user_action">
+ <option value=""><?php echo $_MIDCOM->i18n->get_string('choose action', 'midcom.admin.user'); ?></option>
+ <?php
+ if ($data['config']->get('allow_manage_accounts'))
+ {
+ ?>
+ <option value="removeaccount"><?php echo $_MIDCOM->i18n->get_string('remove account', 'midcom.admin.user'); ?></option>
+ <?php
+ }
+ ?>
+ <option value="groupadd" onclick="javascript:document.getElementById('midcom_admin_user_group').style.display='inline';"><?php echo $_MIDCOM->i18n->get_string('add to group', 'midcom.admin.user'); ?></option>
+ </select>
+ <select name="midcom_admin_user_group" id="midcom_admin_user_group" style="display: none;">
+ <?php
+ foreach ($data['groups'] as $group)
+ {
+ if (!is_object($group))
+ {
+ continue;
+ }
+ echo "<option value=\"{$group->id}\">{$group->official}</option>\n";
+ }
+ ?>
+ </select>
+ <input type="submit" value="<?php echo $_MIDCOM->i18n->get_string('apply to selected', 'midcom.admin.user'); ?>" />
+ </td>
+ </tr>
+ </tfoot>
+ </table>
+ </form>
+ <?php
+}
+?>
\ No newline at end of file
Added: branches/MidCOM_2_8/midcom.admin.user/style/midcom-admin-user-personlist-header.php
==============================================================================
--- (empty file)
+++ branches/MidCOM_2_8/midcom.admin.user/style/midcom-admin-user-personlist-header.php Thu Oct 11 14:33:26 2007
@@ -0,0 +1,40 @@
+<form method="get" class="midcom_admin_user_search">
+ <label>
+ <span><?php echo $_MIDCOM->i18n->get_string('search person', 'midcom.admin.user'); ?></span>
+ <input type="text" name="midcom_admin_user_search" value="<?php if (isset($_REQUEST['midcom_admin_user_search'])) { echo $_REQUEST['midcom_admin_user_search']; } ?>" />
+ </label>
+ <input type="submit" value="<?php echo $_MIDCOM->i18n->get_string('go', 'midcom.admin.user'); ?>" />
+ <div class="helptext">
+ <?php
+ $data['search_fields_l10n'] = array();
+ foreach ($data['search_fields'] as $field)
+ {
+ $data['search_fields_l10n'][] = $_MIDCOM->i18n->get_string($field, 'midcom.admin.user');
+ }
+ echo sprintf($_MIDCOM->i18n->get_string('the following fields will be searched: %s', 'midcom.admin.user'), implode(', ', $data['search_fields_l10n']));
+ ?>
+ </div>
+</form>
+
+<?php
+if (count($data['persons']) > 0)
+{
+ ?>
+ <form method="post">
+ <table class="midcom_admin_user_search_results">
+ <thead>
+ <tr>
+ <th> </th>
+ <?php
+ foreach ($data['list_fields'] as $field)
+ {
+ echo '<th>' . $_MIDCOM->i18n->get_string($field, 'midcom.admin.user') . "</th>\n";
+ }
+ ?>
+ <th><?php echo $_MIDCOM->i18n->get_string('groups', 'midcom.admin.user'); ?></th>
+ </tr>
+ </thead>
+ <tbody>
+ <?php
+}
+?>
\ No newline at end of file
Added: branches/MidCOM_2_8/midcom.admin.user/style/midcom-admin-user-personlist-item.php
==============================================================================
--- (empty file)
+++ branches/MidCOM_2_8/midcom.admin.user/style/midcom-admin-user-personlist-item.php Thu Oct 11 14:33:26 2007
@@ -0,0 +1,53 @@
+<tr<?php if ($data['even']) { echo ' class="even"'; } ?>>
+ <?php
+ $checked = '';
+ if (isset($_POST['midcom_admin_user'])
+ && is_array($_POST['midcom_admin_user'])
+ && in_array($data['person']->id, $_POST['midcom_admin_user']))
+ {
+ $checked = ' checked="checked"';
+ }
+
+ if (!$data['person']->can_do('midgard:update'))
+ {
+ $checked .= ' disabled="disabled"';
+ }
+ ?>
+ <td><input type="checkbox" name="midcom_admin_user[]" value="<?php echo $data['person']->id; ?>" <?php echo $checked; ?>/></td>
+ <?php
+ $prefix = $_MIDCOM->get_context_data(MIDCOM_CONTEXT_ANCHORPREFIX);
+ $linked = 0;
+ foreach ($data['list_fields'] as $field)
+ {
+ $value = $data['person']->$field;
+ if ( $linked < 2
+ && $data['person']->can_do('midgard:update'))
+ {
+ if (!$value)
+ {
+ $value = "<{$field}>";
+ }
+ $value = "<a href=\"{$prefix}__mfa/asgard_midcom.admin.user/edit/{$data['person']->guid}/\">{$value}</a>";
+ $linked++;
+ }
+ echo "<td>{$value}</td>\n";
+ }
+
+ $qb = midcom_db_member::new_query_builder();
+ $qb->add_constraint('uid', '=', $data['person']->id);
+ $memberships = $qb->execute();
+ $groups = array();
+ foreach ($memberships as $member)
+ {
+ if (!is_object($data['groups'][$member->gid]))
+ {
+ $groups[] = $data['groups'][$member->gid];
+ }
+ else
+ {
+ $groups[] = "<a href=\"{$prefix}__mfa/asgard_midcom.admin.user/group/edit/{$data['groups'][$member->gid]->guid}/\">{$data['groups'][$member->gid]->official}</a>";
+ }
+ }
+ echo "<td>" . implode(', ', $groups) . "</td>\n";
+ ?>
+</tr>
\ No newline at end of file
More information about the midcom-commits
mailing list