From 8ed0fa2b4f9b6e7d085a7ed633864a0a4d4141a4 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Sat, 21 Jul 2018 01:00:34 -0400 Subject: Reorg examples/ directory --- examples/common.mod.php | 497 +++++++++++++++++++++ examples/default.view.php | 51 +++ examples/deleteacct.mod.php | 63 +++ examples/group.setting.modal.view.php | 96 ++++ examples/group.view.php | 43 ++ examples/model/common.mod.php | 497 --------------------- examples/model/deleteacct.mod.php | 63 --- examples/newgroup.modal.view.php | 49 ++ examples/ownership.setting.modal.view.php | 35 ++ examples/permissions.setting.modal.view.php | 82 ++++ examples/setting.modal.view.php | 346 ++++++++++++++ examples/topp.view.php | 83 ++++ examples/view/common/group.setting.modal.view.php | 96 ---- examples/view/common/newgroup.modal.view.php | 49 -- .../view/common/ownership.setting.modal.view.php | 35 -- .../view/common/permissions.setting.modal.view.php | 82 ---- examples/view/common/setting.modal.view.php | 346 -------------- examples/view/common/topp.view.php | 83 ---- examples/view/deleteacct/default.view.php | 51 --- examples/view/obj/group.view.php | 43 -- 20 files changed, 1345 insertions(+), 1345 deletions(-) create mode 100644 examples/common.mod.php create mode 100644 examples/default.view.php create mode 100644 examples/deleteacct.mod.php create mode 100644 examples/group.setting.modal.view.php create mode 100644 examples/group.view.php delete mode 100644 examples/model/common.mod.php delete mode 100644 examples/model/deleteacct.mod.php create mode 100644 examples/newgroup.modal.view.php create mode 100644 examples/ownership.setting.modal.view.php create mode 100644 examples/permissions.setting.modal.view.php create mode 100644 examples/setting.modal.view.php create mode 100644 examples/topp.view.php delete mode 100644 examples/view/common/group.setting.modal.view.php delete mode 100644 examples/view/common/newgroup.modal.view.php delete mode 100644 examples/view/common/ownership.setting.modal.view.php delete mode 100644 examples/view/common/permissions.setting.modal.view.php delete mode 100644 examples/view/common/setting.modal.view.php delete mode 100644 examples/view/common/topp.view.php delete mode 100644 examples/view/deleteacct/default.view.php delete mode 100644 examples/view/obj/group.view.php diff --git a/examples/common.mod.php b/examples/common.mod.php new file mode 100644 index 0000000..6cba871 --- /dev/null +++ b/examples/common.mod.php @@ -0,0 +1,497 @@ +first_setting_tab_active = 0; + $this->first_setting_tab_disp = 0; + $this->common_handleFormSubmissions($_REQUEST['input'], $_FILES['attachment']); + + if (!is_null($guid)) + { + $this->obj = new DBObject($guid); + $this->owner = $this->obj->getOwner(); + $this->members = $this->obj->getMembers(); + } + + $this->common_deflt(); + } + + /* + * Default action + */ + function common_deflt() + { + global $_SCROTT; + + /* Admin settings tab */ + if ($_SCROTT['settSSL'] != "neither") + { + $this->common_settingAdminSettSSLChecked[$_SCROTT['settSSL']] = "checked"; + $this->common_settingAdminSettSSLDisabled = "disabled"; + } + else + $this->common_settingAdminSettSSLChecked[Setting::settSSL()] = "checked"; + + if (Setting::allowPublicSignup()) + $this->common_settingAdminAllowPublicSignupChecked = "checked"; + + /* Admin all-users settings tab */ + $userTbl = new User(); + $this->common_settingAllUsers = $userTbl->getAllUsers_orderByAdminByName(); + + /* Setting modal - what tabs to display? */ + if (isset($this->obj)) + { + if ($this->obj->type == "group") + { + $this->group = new Group($this->obj->guid); + $this->common_settingShowTab['group'] = true; + } + } + } + + /* + * Handle form submissions from common views + */ + function common_handleFormSubmissions($input, $attachment) + { + switch ($input['action']) + { + case "common-group-add": $this->addNewGroup($input); break; + case "common-setting-group": $this->saveSettingGroup($input, $attachment); break; + case "common-setting-user": $this->saveSettingUser($input, $attachment); break; + case "common-setting-admin": $this->saveSettingAdmin($input); break; + case "common-setting-allusers-adduser": $this->saveSettingAllusersAdduser($input); break; + case "common-setting-allusers-edituser": $this->saveSettingAllusersEdituser($input, $attachment); break; + case "common-setting-allusers-deluser": $this->saveSettingAllusersDeluser($input); break; + } + } + + /* + * Create a new user group + */ + function addNewGroup($input) + { + $form = new Form(); + $form->field_text("name"); + + if (!$form->populate($input)) + { + $this->logFormErrors($form); + return; + } + + $group = new Group(); + $group->createNewGroup($form->name, $this->getCurrentUser()); + } + + /* + * Save changes to user group settings + */ + function saveSettingGroup($input, $attachment) + { + $form = new Form(); + $form->field_text("guid"); + $form->field_text("name"); + $form->field_bool("perm0"); + $form->field_bool("perm1"); + $form->field_bool("perm2"); + $form->field_bool("perm3"); + $form->field_bool("perm4"); + $form->field_bool("perm5"); + $form->field_bool("perm6"); + $form->field_bool("perm7"); + $form->field_bool("perm8"); + + if (!$form->populate($input)) + { + $this->logFormErrors($form); + return; + } + + $user = $this->getCurrentUser(); + $group = new Group($form->guid); + + if (!$user || $group->type != "group" || !$group->canModify($user)) + { + $this->logError("You do not have permission to modify this group"); + return; + } + + if (isset($input['rmImage'])) + { + if ($group->rmHeadImage()) + $this->logNotice("Image removed"); + else + $this->logError("Error removing group image"); + + return; + } + + $group->name = $form->name; + + if ($group->canModifyPermissions($user)) + { + $perms = 0; + + if ($form->perm0) + $perms |= 0x100; + if ($form->perm1) + $perms |= 0x080; + if ($form->perm2) + $perms |= 0x040; + if ($form->perm3) + $perms |= 0x020; + if ($form->perm4) + $perms |= 0x010; + if ($form->perm5) + $perms |= 0x008; + if ($form->perm6) + $perms |= 0x004; + if ($form->perm7) + $perms |= 0x002; + if ($form->perm8) + $perms |= 0x001; + + $group->perms = $perms; + } + + $group->saveObj(); + + if ($form->saveFile($attachment, $this->HEAD_IMG_MAX_SIZE, $this->HEAD_IMG_MIME, "assets/img/heads/" . $group->guid)) + $this->logNotice("Image uploaded"); + else + $this->logFormErrors($form); + } + + /* + * Save changes to user account settings + */ + function saveSettingUser($input, $attachment) + { + $form = new Form(); + $form->field_bool("setPasswd"); + $form->field_text("curPasswd", null, false); + $form->field_text("newPasswd", null, false); + $form->field_text("confPasswd", null, false); + $form->field_text("alias", "", false); + $form->field_text("email", "", false); + $form->field_text("emailConfKey", null, false); + + if (!$form->populate($input)) + { + $this->logFormErrors($form); + return; + } + + $user = $this->getCurrentUser(); + + if (!$user) + { + $this->logError("Not logged in"); + return; + } + + if (isset($input['rmImage'])) + { + if ($user->rmHeadImage()) + $this->logNotice("Image removed"); + else + $this->logError("Error removing user image"); + + return; + } + + if ($form->setPasswd) + { + if ($user->validatePassword($form->curPasswd)) + { + if ($form->newPasswd == $form->confPasswd) + { + $user->setPassword($form->newPasswd); + $this->logNotice("Password updated successfully"); + } + else + $this->logWarning("Password not changed -- Passwords did not match"); + } + + else + $this->logWarning("Password not changed -- Current password was incorrect"); + } + + $user->alias = $form->alias; + + if ($form->email != $user->email) + $user->setEmail($form->email); + + else if ($form->emailConfKey != "") + { + if (!$user->confirmEmailKey($form->emailConfKey)) + $this->logWarning("Email not confirmed -- Key was incorrect"); + } + + $user->saveObj(); + + if ($form->saveFile($attachment, $this->HEAD_IMG_MAX_SIZE, $this->HEAD_IMG_MIME, "assets/img/heads/" . $user->guid)) + $this->logNotice("Image uploaded"); + else + $this->logFormErrors($form); + } + + /* + * Save changes to admin settings + */ + function saveSettingAdmin($input) + { + $form = new Form(); + $form->field_enum("settSSL", array("force", "neither", "forbid"), Setting::settSSL()); + $form->field_bool("allowPublicSignup"); + + if (!$form->populate($input)) + { + $this->logFormErrors($form); + return; + } + + $user = $this->getCurrentUser(); + + if (!$user || $user->admin == 0) + { + $this->logError("Admin permissions required"); + return; + } + + Setting::settSSL($form->settSSL); + Setting::allowPublicSignup($form->allowPublicSignup); + } + + /* + * Allow an admin to create a new user account + */ + function saveSettingAllusersAdduser($input) + { + $form = new Form(); + $form->field_text("username"); + $form->field_text("password", null, false); + $form->field_text("cPassword", null, false); + $form->field_bool("admin"); + $form->field_text("alias", "", false); + $form->field_text("email", "", false); + + if (!$form->populate($input)) + { + $this->logFormErrors($form); + return; + } + + $user = $this->getCurrentUser(); + + if (!$user || $user->admin == 0) + { + $this->logError("Admin permissions required"); + return; + } + + if ($form->password != $form->cPassword) + { + $this->logError("Passwords do not match"); + return; + } + + $user = new User(); + + if (!$user->createNewUser($form->username, $form->password)) + { + $this->logError("Username " . $form->username . " is not available"); + return; + } + + if ($form->admin) + $user->admin = 1; + + $user->alias = $form->alias; + $user->setEmail($form->email); + $user->saveObj(); + + $this->logNotice("Created new user " . $form->username); + } + + /* + * Allow an admin to edit user accounts + */ + function saveSettingAllusersEdituser($input, $attachment) + { + $form = new Form(); + $form->field_text("guid"); + $form->field_bool("setPasswd"); + $form->field_text("newPasswd", null, false); + $form->field_text("confPasswd", null, false); + $form->field_bool("admin"); + $form->field_text("alias", "", false); + $form->field_text("email", "", false); + + if (!$form->populate($input)) + { + $this->logFormErrors($form); + return; + } + + $user = $this->getCurrentUser(); + + if (!$user || $user->admin == 0) + { + $this->logError("Admin permissions required"); + return; + } + + $user = new User($form->guid); + + if ($user->type != "user") + { + $this->logError("Invalid user GUID"); + return; + } + + if (isset($input['rmImage'])) + { + if ($user->rmHeadImage()) + $this->logNotice("Image removed"); + else + $this->logError("Error removing user image"); + + return; + } + + if ($form->setPasswd) + { + if ($form->newPasswd == $form->confPasswd) + { + $user->setPassword($form->newPasswd); + $this->logNotice("Password for " . $user->name . " updated successfully"); + } + else + $this->logWarning("Password not changed -- Passwords did not match"); + } + + $user->admin = $form->admin; + $user->alias = $form->alias; + + if ($form->email != $user->email) + $user->setEmail($form->email); + + $user->saveObj(); + + if ($form->saveFile($attachment, $this->HEAD_IMG_MAX_SIZE, $this->HEAD_IMG_MIME, "assets/img/heads/" . $user->guid)) + $this->logNotice("Image uploaded"); + else + $this->logFormErrors($form); + } + + /* + * Allow admin to remove user accounts + */ + function saveSettingAllusersDeluser($input) + { + $form = new Form(); + $form->field_text("guid"); + + if (!$form->populate($input)) + { + $this->logFormErrors($form); + return; + } + + $user = $this->getCurrentUser(); + + if (!$user || $user->admin == 0) + { + $this->logError("Admin permissions required"); + return; + } + + $user = new User($form->guid); + + if ($user->type != "user") + { + $this->logError("Invalid user GUID"); + return; + } + + if ($user->admin && $user->getNumAdmins() == 1) + { + $this->logError("Account not deleted - Cannot remove the last admin account"); + return; + } + + $user->delObj(); + + if (!$this->getCurrentUser()) + { + /* did user delete their own account? */ + $this->redirectTo($this->ar() . "/"); + } + } + + /* + * Set CSS class for the first tab title in the setting modal only + */ + function getSettingModalTabActiveClass() + { + if (!$this->first_setting_tab_active) + { + $this->first_setting_tab_active = 1; + return "active"; + } + + return ""; + } + + /* + * Set CSS classes for the first tab in the setting modal only + */ + function getSettingModalTabDispClasses() + { + if (!$this->first_setting_tab_disp) + { + $this->first_setting_tab_disp = 1; + return "in active"; + } + + return ""; + } +} + +?> diff --git a/examples/default.view.php b/examples/default.view.php new file mode 100644 index 0000000..852a37e --- /dev/null +++ b/examples/default.view.php @@ -0,0 +1,51 @@ + + + + + + + + Scrott - Delete user account + + + + + +
+
+
Warning: Deleting your user account!
+ +
+
+ +

Are you sure?!

+

Please confirm you want to delete your Scrott account. Type your current password in the box below and click the confirm button

+ +
+ + +
+ + +
+
+
+
+ + + + diff --git a/examples/deleteacct.mod.php b/examples/deleteacct.mod.php new file mode 100644 index 0000000..0178c95 --- /dev/null +++ b/examples/deleteacct.mod.php @@ -0,0 +1,63 @@ +field_text("password", null, false); + + if (!$form->populate($input)) + { + $this->logFormErrors($form); + return; + } + + $user = $this->getCurrentUser(); + + if (!$user->validatePassword($form->password)) + { + $this->logError("Account not deleted - Password was incorrect"); + return; + } + + if ($user->admin && $user->getNumAdmins() == 1) + { + $this->logError("Account not deleted - Cannot remove the last admin account"); + return; + } + + $user->delObj(); + $this->redirectTo($this->ar() . "/"); + } +} + +?> diff --git a/examples/group.setting.modal.view.php b/examples/group.setting.modal.view.php new file mode 100644 index 0000000..d0e11ca --- /dev/null +++ b/examples/group.setting.modal.view.php @@ -0,0 +1,96 @@ + + + + +
+

 

+ +
+ + + +
+
+
+ + group->canModify($mod->getCurrentUser()) ? "" : "disabled")?> /> +
+
+ +
+ <?=$mod->group->name?> + + group->canModify($mod->getCurrentUser())) { ?> +
+
+ +
+ + +
+
+ +
+
+ + +
+
+ + group); ?> + + group->canModify($mod->getCurrentUser())) { ?> +

 

+ + +
+ +

 

+

 

+ +
+ group->canModifyMembers($mod->getCurrentUser())) { ?> + + + + group->isOwner($mod->getCurrentUser())) { ?> + + + + +
+ +

 

+
diff --git a/examples/group.view.php b/examples/group.view.php new file mode 100644 index 0000000..dde4df1 --- /dev/null +++ b/examples/group.view.php @@ -0,0 +1,43 @@ + + + + + + + + Scrott - <?=$mod->group->name?> + + + + + +
+
+

group->name?>

+ <?=$mod->owner->getDisplayName()?> + + members)) { ?> + + + + members as $member) { ?> + <?=$member->getDisplayName()?> + +
+
+ + + + diff --git a/examples/model/common.mod.php b/examples/model/common.mod.php deleted file mode 100644 index 6cba871..0000000 --- a/examples/model/common.mod.php +++ /dev/null @@ -1,497 +0,0 @@ -first_setting_tab_active = 0; - $this->first_setting_tab_disp = 0; - $this->common_handleFormSubmissions($_REQUEST['input'], $_FILES['attachment']); - - if (!is_null($guid)) - { - $this->obj = new DBObject($guid); - $this->owner = $this->obj->getOwner(); - $this->members = $this->obj->getMembers(); - } - - $this->common_deflt(); - } - - /* - * Default action - */ - function common_deflt() - { - global $_SCROTT; - - /* Admin settings tab */ - if ($_SCROTT['settSSL'] != "neither") - { - $this->common_settingAdminSettSSLChecked[$_SCROTT['settSSL']] = "checked"; - $this->common_settingAdminSettSSLDisabled = "disabled"; - } - else - $this->common_settingAdminSettSSLChecked[Setting::settSSL()] = "checked"; - - if (Setting::allowPublicSignup()) - $this->common_settingAdminAllowPublicSignupChecked = "checked"; - - /* Admin all-users settings tab */ - $userTbl = new User(); - $this->common_settingAllUsers = $userTbl->getAllUsers_orderByAdminByName(); - - /* Setting modal - what tabs to display? */ - if (isset($this->obj)) - { - if ($this->obj->type == "group") - { - $this->group = new Group($this->obj->guid); - $this->common_settingShowTab['group'] = true; - } - } - } - - /* - * Handle form submissions from common views - */ - function common_handleFormSubmissions($input, $attachment) - { - switch ($input['action']) - { - case "common-group-add": $this->addNewGroup($input); break; - case "common-setting-group": $this->saveSettingGroup($input, $attachment); break; - case "common-setting-user": $this->saveSettingUser($input, $attachment); break; - case "common-setting-admin": $this->saveSettingAdmin($input); break; - case "common-setting-allusers-adduser": $this->saveSettingAllusersAdduser($input); break; - case "common-setting-allusers-edituser": $this->saveSettingAllusersEdituser($input, $attachment); break; - case "common-setting-allusers-deluser": $this->saveSettingAllusersDeluser($input); break; - } - } - - /* - * Create a new user group - */ - function addNewGroup($input) - { - $form = new Form(); - $form->field_text("name"); - - if (!$form->populate($input)) - { - $this->logFormErrors($form); - return; - } - - $group = new Group(); - $group->createNewGroup($form->name, $this->getCurrentUser()); - } - - /* - * Save changes to user group settings - */ - function saveSettingGroup($input, $attachment) - { - $form = new Form(); - $form->field_text("guid"); - $form->field_text("name"); - $form->field_bool("perm0"); - $form->field_bool("perm1"); - $form->field_bool("perm2"); - $form->field_bool("perm3"); - $form->field_bool("perm4"); - $form->field_bool("perm5"); - $form->field_bool("perm6"); - $form->field_bool("perm7"); - $form->field_bool("perm8"); - - if (!$form->populate($input)) - { - $this->logFormErrors($form); - return; - } - - $user = $this->getCurrentUser(); - $group = new Group($form->guid); - - if (!$user || $group->type != "group" || !$group->canModify($user)) - { - $this->logError("You do not have permission to modify this group"); - return; - } - - if (isset($input['rmImage'])) - { - if ($group->rmHeadImage()) - $this->logNotice("Image removed"); - else - $this->logError("Error removing group image"); - - return; - } - - $group->name = $form->name; - - if ($group->canModifyPermissions($user)) - { - $perms = 0; - - if ($form->perm0) - $perms |= 0x100; - if ($form->perm1) - $perms |= 0x080; - if ($form->perm2) - $perms |= 0x040; - if ($form->perm3) - $perms |= 0x020; - if ($form->perm4) - $perms |= 0x010; - if ($form->perm5) - $perms |= 0x008; - if ($form->perm6) - $perms |= 0x004; - if ($form->perm7) - $perms |= 0x002; - if ($form->perm8) - $perms |= 0x001; - - $group->perms = $perms; - } - - $group->saveObj(); - - if ($form->saveFile($attachment, $this->HEAD_IMG_MAX_SIZE, $this->HEAD_IMG_MIME, "assets/img/heads/" . $group->guid)) - $this->logNotice("Image uploaded"); - else - $this->logFormErrors($form); - } - - /* - * Save changes to user account settings - */ - function saveSettingUser($input, $attachment) - { - $form = new Form(); - $form->field_bool("setPasswd"); - $form->field_text("curPasswd", null, false); - $form->field_text("newPasswd", null, false); - $form->field_text("confPasswd", null, false); - $form->field_text("alias", "", false); - $form->field_text("email", "", false); - $form->field_text("emailConfKey", null, false); - - if (!$form->populate($input)) - { - $this->logFormErrors($form); - return; - } - - $user = $this->getCurrentUser(); - - if (!$user) - { - $this->logError("Not logged in"); - return; - } - - if (isset($input['rmImage'])) - { - if ($user->rmHeadImage()) - $this->logNotice("Image removed"); - else - $this->logError("Error removing user image"); - - return; - } - - if ($form->setPasswd) - { - if ($user->validatePassword($form->curPasswd)) - { - if ($form->newPasswd == $form->confPasswd) - { - $user->setPassword($form->newPasswd); - $this->logNotice("Password updated successfully"); - } - else - $this->logWarning("Password not changed -- Passwords did not match"); - } - - else - $this->logWarning("Password not changed -- Current password was incorrect"); - } - - $user->alias = $form->alias; - - if ($form->email != $user->email) - $user->setEmail($form->email); - - else if ($form->emailConfKey != "") - { - if (!$user->confirmEmailKey($form->emailConfKey)) - $this->logWarning("Email not confirmed -- Key was incorrect"); - } - - $user->saveObj(); - - if ($form->saveFile($attachment, $this->HEAD_IMG_MAX_SIZE, $this->HEAD_IMG_MIME, "assets/img/heads/" . $user->guid)) - $this->logNotice("Image uploaded"); - else - $this->logFormErrors($form); - } - - /* - * Save changes to admin settings - */ - function saveSettingAdmin($input) - { - $form = new Form(); - $form->field_enum("settSSL", array("force", "neither", "forbid"), Setting::settSSL()); - $form->field_bool("allowPublicSignup"); - - if (!$form->populate($input)) - { - $this->logFormErrors($form); - return; - } - - $user = $this->getCurrentUser(); - - if (!$user || $user->admin == 0) - { - $this->logError("Admin permissions required"); - return; - } - - Setting::settSSL($form->settSSL); - Setting::allowPublicSignup($form->allowPublicSignup); - } - - /* - * Allow an admin to create a new user account - */ - function saveSettingAllusersAdduser($input) - { - $form = new Form(); - $form->field_text("username"); - $form->field_text("password", null, false); - $form->field_text("cPassword", null, false); - $form->field_bool("admin"); - $form->field_text("alias", "", false); - $form->field_text("email", "", false); - - if (!$form->populate($input)) - { - $this->logFormErrors($form); - return; - } - - $user = $this->getCurrentUser(); - - if (!$user || $user->admin == 0) - { - $this->logError("Admin permissions required"); - return; - } - - if ($form->password != $form->cPassword) - { - $this->logError("Passwords do not match"); - return; - } - - $user = new User(); - - if (!$user->createNewUser($form->username, $form->password)) - { - $this->logError("Username " . $form->username . " is not available"); - return; - } - - if ($form->admin) - $user->admin = 1; - - $user->alias = $form->alias; - $user->setEmail($form->email); - $user->saveObj(); - - $this->logNotice("Created new user " . $form->username); - } - - /* - * Allow an admin to edit user accounts - */ - function saveSettingAllusersEdituser($input, $attachment) - { - $form = new Form(); - $form->field_text("guid"); - $form->field_bool("setPasswd"); - $form->field_text("newPasswd", null, false); - $form->field_text("confPasswd", null, false); - $form->field_bool("admin"); - $form->field_text("alias", "", false); - $form->field_text("email", "", false); - - if (!$form->populate($input)) - { - $this->logFormErrors($form); - return; - } - - $user = $this->getCurrentUser(); - - if (!$user || $user->admin == 0) - { - $this->logError("Admin permissions required"); - return; - } - - $user = new User($form->guid); - - if ($user->type != "user") - { - $this->logError("Invalid user GUID"); - return; - } - - if (isset($input['rmImage'])) - { - if ($user->rmHeadImage()) - $this->logNotice("Image removed"); - else - $this->logError("Error removing user image"); - - return; - } - - if ($form->setPasswd) - { - if ($form->newPasswd == $form->confPasswd) - { - $user->setPassword($form->newPasswd); - $this->logNotice("Password for " . $user->name . " updated successfully"); - } - else - $this->logWarning("Password not changed -- Passwords did not match"); - } - - $user->admin = $form->admin; - $user->alias = $form->alias; - - if ($form->email != $user->email) - $user->setEmail($form->email); - - $user->saveObj(); - - if ($form->saveFile($attachment, $this->HEAD_IMG_MAX_SIZE, $this->HEAD_IMG_MIME, "assets/img/heads/" . $user->guid)) - $this->logNotice("Image uploaded"); - else - $this->logFormErrors($form); - } - - /* - * Allow admin to remove user accounts - */ - function saveSettingAllusersDeluser($input) - { - $form = new Form(); - $form->field_text("guid"); - - if (!$form->populate($input)) - { - $this->logFormErrors($form); - return; - } - - $user = $this->getCurrentUser(); - - if (!$user || $user->admin == 0) - { - $this->logError("Admin permissions required"); - return; - } - - $user = new User($form->guid); - - if ($user->type != "user") - { - $this->logError("Invalid user GUID"); - return; - } - - if ($user->admin && $user->getNumAdmins() == 1) - { - $this->logError("Account not deleted - Cannot remove the last admin account"); - return; - } - - $user->delObj(); - - if (!$this->getCurrentUser()) - { - /* did user delete their own account? */ - $this->redirectTo($this->ar() . "/"); - } - } - - /* - * Set CSS class for the first tab title in the setting modal only - */ - function getSettingModalTabActiveClass() - { - if (!$this->first_setting_tab_active) - { - $this->first_setting_tab_active = 1; - return "active"; - } - - return ""; - } - - /* - * Set CSS classes for the first tab in the setting modal only - */ - function getSettingModalTabDispClasses() - { - if (!$this->first_setting_tab_disp) - { - $this->first_setting_tab_disp = 1; - return "in active"; - } - - return ""; - } -} - -?> diff --git a/examples/model/deleteacct.mod.php b/examples/model/deleteacct.mod.php deleted file mode 100644 index 0178c95..0000000 --- a/examples/model/deleteacct.mod.php +++ /dev/null @@ -1,63 +0,0 @@ -field_text("password", null, false); - - if (!$form->populate($input)) - { - $this->logFormErrors($form); - return; - } - - $user = $this->getCurrentUser(); - - if (!$user->validatePassword($form->password)) - { - $this->logError("Account not deleted - Password was incorrect"); - return; - } - - if ($user->admin && $user->getNumAdmins() == 1) - { - $this->logError("Account not deleted - Cannot remove the last admin account"); - return; - } - - $user->delObj(); - $this->redirectTo($this->ar() . "/"); - } -} - -?> diff --git a/examples/newgroup.modal.view.php b/examples/newgroup.modal.view.php new file mode 100644 index 0000000..3dd631c --- /dev/null +++ b/examples/newgroup.modal.view.php @@ -0,0 +1,49 @@ + + + diff --git a/examples/ownership.setting.modal.view.php b/examples/ownership.setting.modal.view.php new file mode 100644 index 0000000..3f7c382 --- /dev/null +++ b/examples/ownership.setting.modal.view.php @@ -0,0 +1,35 @@ + + + + isOwner($mod->getCurrentUser())) { ?> + +
+ +
+ +
+
+ + +
+
+ + diff --git a/examples/permissions.setting.modal.view.php b/examples/permissions.setting.modal.view.php new file mode 100644 index 0000000..55e4157 --- /dev/null +++ b/examples/permissions.setting.modal.view.php @@ -0,0 +1,82 @@ + + + + canModifyPermissions($mod->getCurrentUser())) { ?> + +
+
+
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+
+ +
+
+ +
+ +
+ +
+ +
+ +
+
+
+ + diff --git a/examples/setting.modal.view.php b/examples/setting.modal.view.php new file mode 100644 index 0000000..2217805 --- /dev/null +++ b/examples/setting.modal.view.php @@ -0,0 +1,346 @@ + + + diff --git a/examples/topp.view.php b/examples/topp.view.php new file mode 100644 index 0000000..d9e0df0 --- /dev/null +++ b/examples/topp.view.php @@ -0,0 +1,83 @@ + + + + +getCurrentUser()) { ?> + + + + + diff --git a/examples/view/common/group.setting.modal.view.php b/examples/view/common/group.setting.modal.view.php deleted file mode 100644 index d0e11ca..0000000 --- a/examples/view/common/group.setting.modal.view.php +++ /dev/null @@ -1,96 +0,0 @@ - - - - -
-

 

- -
- - - -
-
-
- - group->canModify($mod->getCurrentUser()) ? "" : "disabled")?> /> -
-
- -
- <?=$mod->group->name?> - - group->canModify($mod->getCurrentUser())) { ?> -
-
- -
- - -
-
- -
-
- - -
-
- - group); ?> - - group->canModify($mod->getCurrentUser())) { ?> -

 

- - -
- -

 

-

 

- -
- group->canModifyMembers($mod->getCurrentUser())) { ?> - - - - group->isOwner($mod->getCurrentUser())) { ?> - - - - -
- -

 

-
diff --git a/examples/view/common/newgroup.modal.view.php b/examples/view/common/newgroup.modal.view.php deleted file mode 100644 index 3dd631c..0000000 --- a/examples/view/common/newgroup.modal.view.php +++ /dev/null @@ -1,49 +0,0 @@ - - - diff --git a/examples/view/common/ownership.setting.modal.view.php b/examples/view/common/ownership.setting.modal.view.php deleted file mode 100644 index 3f7c382..0000000 --- a/examples/view/common/ownership.setting.modal.view.php +++ /dev/null @@ -1,35 +0,0 @@ - - - - isOwner($mod->getCurrentUser())) { ?> - -
- -
- -
-
- - -
-
- - diff --git a/examples/view/common/permissions.setting.modal.view.php b/examples/view/common/permissions.setting.modal.view.php deleted file mode 100644 index 55e4157..0000000 --- a/examples/view/common/permissions.setting.modal.view.php +++ /dev/null @@ -1,82 +0,0 @@ - - - - canModifyPermissions($mod->getCurrentUser())) { ?> - -
-
-
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
-
- -
-
- -
- -
- -
- -
- -
-
-
- - diff --git a/examples/view/common/setting.modal.view.php b/examples/view/common/setting.modal.view.php deleted file mode 100644 index 2217805..0000000 --- a/examples/view/common/setting.modal.view.php +++ /dev/null @@ -1,346 +0,0 @@ - - - diff --git a/examples/view/common/topp.view.php b/examples/view/common/topp.view.php deleted file mode 100644 index d9e0df0..0000000 --- a/examples/view/common/topp.view.php +++ /dev/null @@ -1,83 +0,0 @@ - - - - -getCurrentUser()) { ?> - - - - - diff --git a/examples/view/deleteacct/default.view.php b/examples/view/deleteacct/default.view.php deleted file mode 100644 index 852a37e..0000000 --- a/examples/view/deleteacct/default.view.php +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - Scrott - Delete user account - - - - - -
-
-
Warning: Deleting your user account!
- -
-
- -

Are you sure?!

-

Please confirm you want to delete your Scrott account. Type your current password in the box below and click the confirm button

- -
- - -
- - -
-
-
-
- - - - diff --git a/examples/view/obj/group.view.php b/examples/view/obj/group.view.php deleted file mode 100644 index dde4df1..0000000 --- a/examples/view/obj/group.view.php +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - Scrott - <?=$mod->group->name?> - - - - - -
-
-

group->name?>

- <?=$mod->owner->getDisplayName()?> - - members)) { ?> - - - - members as $member) { ?> - <?=$member->getDisplayName()?> - -
-
- - - - -- cgit v1.2.3