本文整理汇总了PHP中OA_Permission::getAccountTypeByAccountId方法的典型用法代码示例。如果您正苦于以下问题:PHP OA_Permission::getAccountTypeByAccountId方法的具体用法?PHP OA_Permission::getAccountTypeByAccountId怎么用?PHP OA_Permission::getAccountTypeByAccountId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OA_Permission
的用法示例。
在下文中一共展示了OA_Permission::getAccountTypeByAccountId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: belongsToAccount
/**
* The belongsToAccount() method behaves in a different way when looking
* at entries in the "audit" table. To check if an account has access
* to view specific audit data, we only need to check if the account's
* ID is set in the appropriate column in the record.
*
* @param string $accountId The account ID to test if this DB_DataObject is
* owned by.
* @return boolean|null Returns true if the entity belongs to the specified
* account, false if doesn't, or null if it was not
* possible to find the required object references.
*/
function belongsToAccount($accountId = null)
{
// Set the account ID, if not passed in
if (empty($accountId)) {
$accountId = OA_Permission::getAccountId();
}
// Prepare $this with the required info of the "entity" to be tested
if (!$this->N) {
$key = $this->getFirstPrimaryKey();
if (empty($this->{$key})) {
MAX::raiseError('Key on object is not set, table: ' . $this->getTableWithoutPrefix());
return null;
}
if (!$this->find($autoFetch = true)) {
return null;
}
}
// Test the account ID type, and then test for access
$accountType = OA_Permission::getAccountTypeByAccountId($accountId);
// Test the access to the audit trail entry
if ($accountType == OA_ACCOUNT_ADMIN) {
// Admin always has access
return true;
} else {
if ($accountType == OA_ACCOUNT_MANAGER) {
// Test if the account ID is equal to the account_id field
if (is_null($this->account_id)) {
return null;
}
if ($this->account_id == $accountId) {
return true;
}
} else {
if ($accountType == OA_ACCOUNT_ADVERTISER) {
// Test if the account ID is equal to the advertiser_account_id field
if (is_null($this->advertiser_account_id)) {
return null;
}
if ($this->advertiser_account_id == $accountId) {
return true;
}
} else {
if ($accountType == OA_ACCOUNT_TRAFFICKER) {
// Test if the account ID is equal to the website_account_id field
if (is_null($this->website_account_id)) {
return null;
}
if ($this->website_account_id == $accountId) {
return true;
}
}
}
}
}
return false;
}
示例2: _getOwningAccountIdsByAccountId
/**
* A private method to return the owning account IDs in a format suitable
* for use by the DB_DataObjectCommon::getOwningAccountIds() method as a
* return parameter, given the account ID of the account that is the owner
* of the entity being audited.
*
* @access private
* @param integer $accountId The account ID that "owns" the entity being
* audited.
* @return array An array with the same format as the return array of the
* DB_DataObjectCommon::getOwningAccountIds() method.
*/
protected function _getOwningAccountIdsByAccountId($accountId)
{
// Get the type of the "owning" account
$accountType = OA_Permission::getAccountTypeByAccountId($accountId);
if ($accountType == OA_ACCOUNT_ADMIN) {
// Simply return the admin account ID
$aAccountIds = array(OA_ACCOUNT_ADMIN => $accountId);
} else {
if ($accountType == OA_ACCOUNT_MANAGER) {
// Simply return the manager account ID
$aAccountIds = array(OA_ACCOUNT_MANAGER => $accountId);
} else {
if ($accountType == OA_ACCOUNT_ADVERTISER) {
// Set the owning manager account ID to the admin
// account ID, in case something goes wrong
$managerAccountId = OA_Dal_ApplicationVariables::get('admin_account_id');
// This is an advertiser account, so find the
// "owning" manager account ID
$doClients = OA_Dal::factoryDO('clients');
$doClients->account_id = $accountId;
$doClients->find();
if ($doClients->getRowCount() == 1) {
$doClients->fetch();
$managerAccountId = $doClients->getOwningManagerId();
}
// Return the manager and advertiser account IDs
$aAccountIds = array(OA_ACCOUNT_MANAGER => $managerAccountId, OA_ACCOUNT_ADVERTISER => $accountId);
} else {
if ($accountType == OA_ACCOUNT_TRAFFICKER) {
// Set the owning manager account ID to the admin
// account ID, in case something goes wrong
$managerAccountId = OA_Dal_ApplicationVariables::get('admin_account_id');
// This is a trafficker account, so find the
// "owning" manager account ID
$doAffiliates = OA_Dal::factoryDO('affiliates');
$doAffiliates->account_id = $accountId;
$doAffiliates->find();
if ($doAffiliates->getRowCount() == 1) {
$doAffiliates->fetch();
$managerAccountId = $doAffiliates->getOwningManagerId();
}
// Return the manager and trafficker account IDs
$aAccountIds = array(OA_ACCOUNT_MANAGER => $managerAccountId, OA_ACCOUNT_TRAFFICKER => $accountId);
}
}
}
}
return $aAccountIds;
}
示例3: getOwnedAccounts
/**
* Returns all of the account IDs for those accounts "owned"
* by the given account ID.
*
* @param int $accountId The desired "parent" account account to test
* for all "owned" account IDs.
* @return array An array of account IDs, including the account itself.
*/
function getOwnedAccounts($accountId)
{
$aAccountIds = array();
$accoutType = OA_Permission::getAccountTypeByAccountId($accountId);
switch ($accoutType) {
case OA_ACCOUNT_MANAGER:
$aAccountIds[] = $accountId;
// Retrive the agency ID that corresponds with the manager account
$doAgency = OA_Dal::factoryDO('agency');
$doAgency->selectAdd();
$doAgency->selectAdd('agencyid');
$doAgency->account_id = $accountId;
$doAgency->find();
if ($doAgency->getRowCount() == 1) {
$doAgency->fetch();
$agencyId = $doAgency->agencyid;
// Retrieve all advertiser account IDs that the manager
// account "owns" (from the affiliates table)
$doAffiliates = OA_Dal::factoryDO('affiliates');
$doAffiliates->selectAdd();
$doAffiliates->selectAdd('account_id');
$doAffiliates->agencyid = $agencyId;
$doAffiliates->find();
if ($doAffiliates->getRowCount() > 0) {
$doAffiliates->fetch();
$aAccountIds[] = $doAffiliates->account_id;
}
// Retrieve all website account IDs that the manager
// account "owns" (from the clients table)
$doClients = OA_Dal::factoryDO('clients');
$doClients->selectAdd();
$doClients->selectAdd('account_id');
$doClients->agencyid = $agencyId;
$doClients->find();
if ($doClients->getRowCount() > 0) {
while ($doClients->fetch()) {
$aAccountIds[] = $doClients->account_id;
}
}
}
break;
case OA_ACCOUNT_ADMIN:
// Select all account IDs
$doAccounts = OA_Dal::factoryDO('accounts');
$doAccounts->selectAdd();
$doAccounts->selectAdd('account_id');
$doAccounts->find();
if ($doAccounts->getRowCount() > 0) {
while ($doAccounts->fetch()) {
$aAccountIds[] = $doAccounts->account_id;
}
}
break;
default:
$aAccountIds[] = $accountId;
}
return $aAccountIds;
}