function getHierarchy($id) { global $sql; $ret = array(); $cursor = $sql->readDB("CATEGORIA_PLATO", "ID______CPL='{$id}' AND ID______CPL!=-1"); if ($cursor && $cursor->num_rows > 0) { if ($cat = $cursor->fetch_assoc()) { $ret[] = $cat; if ((int) $cat['PADRE___CPL'] > 0) { $ret = array_merge(getHierarchy($cat['PADRE___CPL']), $ret); } } } return $ret; }
function dispatcher($type) { switch ($type) { case 'LoginAttempt': loginAttempt(); break; case 'GetInitialCart': getInitialCart(); break; case 'AddItemToCart': addItemToCart(); break; case 'RemoveItemFromCart': removeItemFromCart(); break; case 'EmptyCart': emptyCart(); break; case 'RefreshCatalog': refreshCatalog(); break; case 'GetGuidedSellingValues': getGuidedSellingValues(); break; case 'ReadCatalog': readCatalog(); break; case 'GetSubscriptions': getSubscriptions(); break; case 'SetAmendSubId': setAmendSubId(); break; case 'GetAmendSubscription': getAmendSubscription(); break; case 'PreviewAddRatePlan': previewAddRatePlan(); break; case 'AddRatePlan': addRatePlan(); break; case 'PreviewRemoveRatePlan': previewRemoveRatePlan(); break; case 'RemoveRatePlan': removeRatePlan(); break; case 'PreviewUpdateRatePlan': previewUpdateRatePlan(); break; case 'UpdateRatePlan': updateRatePlan(); break; case 'GetUpgradeDowngradePlans': getUpgradeDowngradePlans(); break; case 'PreviewPlanUpgradeDowngrade': previewPlanUpgradeDowngrade(); break; case 'PlanUpgradeDowngrade': planUpgradeDowngrade(); break; case 'PreviewRenewSubscription': previewRenewSubscription(); break; case 'RenewSubscription': renewSubscription(); break; case 'CancelSubscription': cancelSubscription(); break; case 'GetAccountSummary': getAccountSummary(); break; case 'GetContactSummary': getContactSummary(); break; case 'GetPaymentMethodSummary': getPaymentMethodSummary(); break; case 'GetInvoiceSummary': getInvoiceSummary(); break; case 'GetBillingPreview': getBillingPreview(); break; case 'GetUsageSummary': getUsageSummary(); break; case 'GetCompleteSummary': getCompleteSummary(); break; case 'UpdateContact': updateContact(); break; case 'CheckEmailAvailability': checkEmailAvailability(); break; case 'UpdatePaymentMethod': updatePaymentMethod(); break; case 'RemovePaymentMethod': removePaymentMethod(); break; case 'GetNewIframeSrc': getNewIframeSrc(); break; case 'GetExistingIframeSrc': getExistingIframeSrc(); break; case 'SubscribeWithCurrentCart': subscribeWithCurrentCart(); break; case 'PreviewCurrentCart': previewCurrentCart(); break; case 'IsUserLoggedIn': isUserLoggedIn(); break; // begin new code for Partner - Ming // begin new code for Partner - Ming case 'GetHierarchy': getHierarchy(); break; case 'GoToAccountView': goToAccountView(); break; case 'GetAccountInfo': getAccountInfo(); break; case 'GetSubConfirmInfo': getSubConfirmInfo(); break; case 'IsPartnerLoggedIn': isPartnerLoggedIn(); break; // end new code for Partner - Ming // HPM 2.0 begin // end new code for Partner - Ming // HPM 2.0 begin case 'SubscribeHPM2': subscribeHPM2(); break; // HPM 2.0 end // Start Promo // HPM 2.0 end // Start Promo case 'PromoValidate': promoValidate(); break; // End Promo // Start Set Account Data // End Promo // Start Set Account Data case 'SetAccountInfo': setAccountInfo(); break; // End Set Account Data // Start Get Address Data // End Set Account Data // Start Get Address Data case 'GetAddressInfo': getAddressInfo(); break; // End Set Account Data // Start Get Formatting Data // End Set Account Data // Start Get Formatting Data case 'GetFormatting': getFormatting(); break; // End Set Formatting Data // End Set Formatting Data default: addErrors(null, 'no action specified'); } }
function populate($userId) { // This will contain all of the permissions the user has been specified $permissions = array(); // assuming that $identity has an id column $userPermissions = getUserPermissions(); //$db->query("SELECT * FROM UsersPermissions WHERE UserId = @0", $identity->id); // Go through each user explicit permission foreach ($userPermissions as $permissionName => $values) { // $permission["name"] could be something like "Article1" // $permission["values"] could be something like ""View:true,NewTopic:true,Reply:true,EditSelf:true"" // These are all the access permissions with that permission name $access = array(); // Store that array of permissions in the overall array $permissions[$permissionName] = $values; } // These are all of the permissions specified to the user by roles $rolesPermissions = array(); // Get the permissions on the chains of roles the user is in $roles = getUserRoles($userId); foreach ($roles as $role) { // This is the overall result for the heirarchy of the current role // Something like // [article1] => // [view] => [true] // [edit] => [true] // [delete] => [true] $roleAccess = array(); $parents = getHierarchy($role); foreach ($parents as $parent) { // Foreach node closer to the role the user is in // get the permission //while($permission = getRolesPermissions($parent); $rolePermissions = getRolePermissions($parent); //$db->query("SELECT * FROM RolesPermissions WHERE roleId = @0", $parent); if ($rolePermissions != null) { foreach ($rolePermissions as $name => $values) { // If this key hasn't been initialized, then do it if (!isset($rolesPermissions[$name])) { $rolesPermissions[$name] = array(); } foreach ($values as $key => $value) { $rolesPermissions[$name][$key] = $value; } } } } } // var_dump($permissions); // var_dump($rolesPermissions); // Right now if we get two different answers from different chains, then the result is not gaurenteed. // Aka: Dont have ambiguous ACL trees foreach ($permissions as $name => $values) { if (!isset($rolesPermissions[$name])) { $rolesPermissions[$name] = array(); } foreach ($values as $key => $value) { $rolesPermissions[$name][$key] = $value; } } return $rolesPermissions; //echo "\n"; // var_dump($rolesPermissions); // echo "\n\n\n"; //return $permissions; }
<!DOCTYPE html> <?php include_once 'database.php'; $agency = getallagency(); $hierarchy = getHierarchy(); $hhh = findHierarchy(); for ($i = 0; $i < count($agency); $i++) { foreach ($hierarchy as $hierarchyitem) { if ($agency[$i]["agencyID"] == $hierarchyitem["AgencyID"]) { array_splice($agency, $i, 1); } } } $join = join_hierarchy(); if (isset($_POST['submit'])) { if (!empty($_POST['agency'])) { if (!empty($hhh)) { echo "Your sub-agency cant be your parent agency"; } else { hierarchy($_POST['agency']); echo "Agency has has been added to your hierarchy"; header("Refresh: 1; index.php?page=cascade"); } } } ?> <html> <head> <title></title> </head> <body>