diff --git a/src/admin/clubs.php b/src/admin/clubs.php index aea8f99..58ca6d0 100644 --- a/src/admin/clubs.php +++ b/src/admin/clubs.php @@ -1,5 +1,18 @@ input; + +$task = $input->getCmd("task", "display"); + +$view = $input->getCmd('view', 'users'); +$input->set('view', $view); + +$controller->execute($task); +$controller->redirect(); diff --git a/src/admin/controller.php b/src/admin/controller.php index 134a89f..edebd9f 100644 --- a/src/admin/controller.php +++ b/src/admin/controller.php @@ -8,4 +8,13 @@ defined('_JEXEC') or die; class ClubsController extends BaseController { + protected $default_view = 'users'; + + public function display($cachable = false, $urlparams = array()) + { + $this->input->get('view', $this->default_view); + + parent::display($cachable, $urlparams); + } + } diff --git a/src/admin/controllers/user.php b/src/admin/controllers/user.php new file mode 100644 index 0000000..4b87f6a --- /dev/null +++ b/src/admin/controllers/user.php @@ -0,0 +1,11 @@ + true)) + { + $model = parent::getModel($name, $prefix, $config); + + return $model; + } + +} \ No newline at end of file diff --git a/src/admin/models/forms/changeuser.xml b/src/admin/models/forms/changeuser.xml new file mode 100644 index 0000000..2df793b --- /dev/null +++ b/src/admin/models/forms/changeuser.xml @@ -0,0 +1,76 @@ + +
diff --git a/src/admin/models/forms/newuser.xml b/src/admin/models/forms/newuser.xml new file mode 100644 index 0000000..3f265d2 --- /dev/null +++ b/src/admin/models/forms/newuser.xml @@ -0,0 +1,96 @@ + + diff --git a/src/admin/models/rules/clubusername.php b/src/admin/models/rules/clubusername.php new file mode 100644 index 0000000..a67c3ac --- /dev/null +++ b/src/admin/models/rules/clubusername.php @@ -0,0 +1,41 @@ +getQuery(true); + + // Build the query. + $query->select('COUNT(*)') + ->from('#__club_users') + ->where('user = ' . $db->quote($value)); + + // Get the extra field check attribute. + $userId = $input->get('id'); + $query->where($db->quoteName('id') . ' <> ' . (int) $userId); + + // Set and query the database. + $db->setQuery($query); + $duplicate = (bool) $db->loadResult(); + + if ($duplicate) + { + return false; + } + + return true; + } + +} \ No newline at end of file diff --git a/src/admin/models/user.php b/src/admin/models/user.php new file mode 100644 index 0000000..535755a --- /dev/null +++ b/src/admin/models/user.php @@ -0,0 +1,91 @@ +loadForm( + 'com_clubs.newuser', + 'newuser', + array( + 'control' => 'jform', + 'load_data' => $loadData + ) + ); + + if (empty($form)) + { + return false; + } + + return $form; + } + + public function getFormChangeUser($data = [], $loadData = true) + { + $form = $this->loadForm( + 'com_clubs.changeuser', + 'changeuser', + array( + 'control' => 'jform', + 'load_data' => $loadData + ) + ); + + if (empty($form)) + { + return false; + } + + return $form; + } + + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = Factory::getApplication()->getUserState( + 'com_clubs.edit.user.data', + array() + ); + + if (empty($data)) + { + $data = $this->getItem(); + } + + return $data; + } + + protected function prepareTable($table) + { + /* define which columns can have NULL values */ + $defnull = array('phone', 'mobile'); + + foreach ($defnull as $val) + /* define the rules when the value is set NULL */ + if (!strlen($table->$val)) + $table->$val = NULL; + + if(isset($table->password)) + { + } + } + + function getForm($data = [], $loadData = true) + {} + + +} \ No newline at end of file diff --git a/src/admin/models/users.php b/src/admin/models/users.php new file mode 100644 index 0000000..8d914a9 --- /dev/null +++ b/src/admin/models/users.php @@ -0,0 +1,22 @@ +getDbo(); + $q = $db->getQuery(true); + + $q->select('*') + ->from('#__club_users'); + + return $q; + } + +} \ No newline at end of file diff --git a/src/admin/tables/user.php b/src/admin/tables/user.php new file mode 100644 index 0000000..028c652 --- /dev/null +++ b/src/admin/tables/user.php @@ -0,0 +1,21 @@ + + + diff --git a/src/admin/views/user/view.html.php b/src/admin/views/user/view.html.php new file mode 100644 index 0000000..6057dc4 --- /dev/null +++ b/src/admin/views/user/view.html.php @@ -0,0 +1,61 @@ +item = $this->get('Item'); + $isNew = ($this->item->id == 0); + if($isNew) + $this->form = $this->get('FormNewUser'); + else + $this->form = $this->get('FormChangeUser'); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + JError::raiseError(500, implode('