foreach (array_keys($aManagers) as $key) { $agency = $aManagers[$key]; echo "\t\t\t\t<tr height='25' " . ($i % 2 == 0 ? "bgcolor='#F6F6F6'" : "") . ">\n"; // Icon & name echo "\t\t\t\t\t<td height='25'>\n"; echo "\t\t\t\t\t\t<img src='" . OX::assetPath() . "/images/spacer.gif' height='16' width='16' align='absmiddle'>\n"; echo "\t\t\t\t\t\t<img src='" . OX::assetPath() . "/images/icon-advertiser.gif' align='absmiddle'>\n"; echo "\t\t\t\t\t\t<a href='agency-edit.php?agencyid=" . $agency['agencyid'] . "'>" . htmlspecialchars($agency['name']) . "</a>\n"; echo "\t\t\t\t\t</td>\n"; // ID echo "\t\t\t\t\t<td height='25'>" . $agency['agencyid'] . "</td>\n"; echo "\t\t\t\t\t<td height='25'> </td>\n"; echo "\t\t\t\t\t<td height='25'> </td>\n"; // Button - Channels echo "<td height='25'>"; if (OA_Permission::hasAccess($agency['account_id'])) { echo "<a href='account-switch.php?account_id={$agency['account_id']}'>"; echo $strSwitchAccount . "</a> "; } else { echo " "; } echo "</td>"; // Delete echo "\t\t\t\t\t<td height='25'>"; echo "<img src='" . OX::assetPath() . "/images/icon-recycle.gif' border='0' align='absmiddle' alt='{$strDelete}'> <a href='agency-delete.php?token=" . urlencode(phpAds_SessionGetToken()) . "&agencyid=" . $agency['agencyid'] . "&returnurl=agency-index.php'" . phpAds_DelConfirm($strConfirmDeleteAgency) . ">{$strDelete}</a> "; echo "</td>\n"; echo "\t\t\t\t</tr>\n"; echo "\t\t\t\t<tr height='1'>\n"; echo "\t\t\t\t\t<td colspan='6' bgcolor='#888888'><img src='" . OX::assetPath() . "/images/break.gif' height='1' width='100%'></td>\n"; echo "\t\t\t\t</tr>\n"; $i++;
function attemptToSwitchForAccess($entityTable, $entityId) { if (!($userId = OA_Permission::getUserId())) { return false; } $doEntity = OA_Dal::staticGetDO($entityTable, $entityId); if ($doEntity) { $aAccountIds = $doEntity->getOwningAccountIds(); foreach ($aAccountIds as $accountId) { if (OA_Permission::hasAccess($accountId)) { OA_Permission::switchAccount($accountId, $hasAccess = true); return true; } } if (OA_Permission::isUserLinkedToAdmin()) { $accountId = $doEntity->getRootAccountId(); OA_Permission::switchAccount($accountId, $hasAccess = true); return true; } } return false; }