Ejemplo n.º 1
0
function MAX_checkAgency($agencyId)
{
    $allowed = false;
    if (MAX_checkGenericId($agencyId)) {
        if (OA_Permission::isAccount(OA_ACCOUNT_ADMIN)) {
            $allowed = count(Admin_DA::getAgencies(array('agency_id' => $agencyId)));
        } elseif (OA_Permission::isAccount(OA_ACCOUNT_MANAGER)) {
            $allowed = $agencyId == OA_Permission::getEntityId() && count(Admin_DA::getAgencies(array('agency_id' => $agencyId)));
        } elseif (OA_Permission::isAccount(OA_ACCOUNT_ADVERTISER)) {
            $allowed = $agencyId == OA_Permission::getAgencyId() && count(Admin_DA::getAgencies(array('agency_id' => $agencyId)));
        }
    }
    return $allowed;
}
Ejemplo n.º 2
0
 function testGetAgencies()
 {
     TestEnv::startTransaction();
     $id = Admin_DA::addAgency(array('name' => 'foo', 'contact' => 'bar', 'username' => 'user', 'email' => '*****@*****.**'));
     $agencies = Admin_DA::getAgencies(array('agency_id' => $id));
     $this->assertTrue(count($agencies) == 1);
     $aKey = array_keys($agencies);
     $id = $aKey[0];
     $this->assertTrue(is_int($id));
     $this->assertTrue(is_array($agencies[$id]));
     $this->assertTrue(array_key_exists('agency_id', $agencies[$id]));
     $this->assertTrue(array_key_exists('name', $agencies[$id]));
     TestEnv::rollbackTransaction();
 }