Пример #1
0
 /**
  * Class constructor
  *
  * @param string $accountId If null, the current account ID is used
  * @param string $accountType If null, the current account type is used
  * @return OA_Central_M2M
  */
 function OA_Central_M2M($accountId = null)
 {
     parent::OA_Central_Common();
     $currentId = OA_Permission::getAccountId();
     if (is_null($accountId)) {
         $this->accountId = $currentId;
     } else {
         $this->accountId = $accountId;
     }
     if ($this->accountId == $currentId) {
         $this->accountType = OA_Permission::getAccountType();
     } else {
         $doAccounts = OA_Dal::factoryDO('accounts');
         $doAccounts->account_id = $this->accountId;
         $doAccounts->find();
         if ($doAccounts->fetch()) {
             $this->accountType = $doAccounts->account_type;
         } else {
             Max::raiseError('Unexisting account ID', null, PEAR_ERROR_DIE);
         }
     }
     if ($this->accountType == OA_ACCOUNT_ADMIN) {
         $this->accountId = 0;
     }
 }
Пример #2
0
 /**
  * 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;
 }
Пример #3
0
 public static function assignModel(OA_Admin_Template $template, $query = '')
 {
     $accounts = OA_Permission::getLinkedAccounts(true, true);
     $remainingCounts = array();
     // Prepare recently used accountName
     $recentlyUsed = array();
     global $session;
     if (empty($query) && !empty($session['recentlyUsedAccounts'])) {
         $allAcountsNoGroups = array();
         foreach ($accounts as $k => $v) {
             foreach ($accounts[$k] as $accountId => $accountName) {
                 $allAcountsNoGroups[$accountId] = $accountName;
             }
         }
         $recentlyUsedAccountIds = $session['recentlyUsedAccounts'];
         $added = 0;
         foreach ($recentlyUsedAccountIds as $k => $recentlyUserAccountId) {
             if (++$added > self::MAX_ACCOUNTS_IN_GROUP) {
                 break;
             }
             $recentlyUsed[$recentlyUserAccountId] = $allAcountsNoGroups[$recentlyUserAccountId];
         }
     }
     // Prepare admin accounts
     if (isset($accounts[OA_ACCOUNT_ADMIN])) {
         $adminAccounts = self::filterByNameAndLimit($accounts[OA_ACCOUNT_ADMIN], $query, $remainingCounts, OA_ACCOUNT_ADMIN);
         unset($accounts[OA_ACCOUNT_ADMIN]);
     } else {
         $adminAccounts = array();
     }
     $showSearchAndRecent = false;
     foreach ($accounts as $k => $v) {
         $workingFor = sprintf($GLOBALS['strWorkingFor'], ucfirst(strtolower($k)));
         $accounts[$workingFor] = self::filterByNameAndLimit($v, $query, $remainingCounts, $workingFor);
         $count = count($accounts[$workingFor]);
         if ($count == 0) {
             unset($accounts[$workingFor]);
         }
         $showSearchAndRecent |= isset($remainingCounts[$workingFor]);
         unset($accounts[$k]);
     }
     // Prepend recently used to the results
     if (!empty($recentlyUsed) && $showSearchAndRecent) {
         $accounts = array_merge(array($GLOBALS['strRecentlyUsed'] => $recentlyUsed), $accounts);
     }
     $template->assign('adminAccounts', $adminAccounts);
     $template->assign('otherAccounts', $accounts);
     $template->assign('remainingCounts', $remainingCounts);
     $template->assign('query', $query);
     $template->assign('noAccountsMessage', sprintf($GLOBALS['strNoAccountWithXInNameFound'], $query));
     $template->assign('currentAccountId', OA_Permission::getAccountId());
     $template->assign('showSearchAndRecent', $showSearchAndRecent);
 }
Пример #4
0
 function display()
 {
     $conf = $GLOBALS['_MAX']['CONF'];
     if (!$conf['audit']['enabled']) {
         $this->oTpl->assign('screen', 'disabled');
         $this->oTpl->assign('siteTitle', $GLOBALS['strAuditTrailSetup']);
         $this->oTpl->assign('siteUrl', MAX::constructUrl(MAX_URL_ADMIN, 'account-settings-debug.php'));
     } else {
         // Account security
         if (OA_Permission::isAccount(OA_ACCOUNT_MANAGER)) {
             $aParams['account_id'] = OA_Permission::getAccountId();
         }
         if (OA_Permission::isAccount(OA_ACCOUNT_ADVERTISER)) {
             $aParams['advertiser_account_id'] = OA_Permission::getAccountId();
         }
         if (OA_Permission::isAccount(OA_ACCOUNT_TRAFFICKER)) {
             $aParams['website_account_id'] = OA_Permission::getAccountId();
         }
         $oAudit = new OA_Dll_Audit();
         $aAuditData = $oAudit->getAuditLogForAuditWidget($aParams);
         if (count($aAuditData) > 0) {
             foreach ($aAuditData as $key => $aValue) {
                 $aValue['action'] = $this->oTrans->translate($oAudit->getActionName($aValue['actionid']));
                 $result = $oAudit->getParentContextData($aValue);
                 $str = "{$aValue['username']} {$GLOBALS['strHas']} {$aValue['action']} {$aValue['context']}";
                 if (!empty($aValue['contextid'])) {
                     $str .= " ({$aValue['contextid']})";
                 }
                 if (!empty($aValue['parentcontext'])) {
                     $str .= " {$GLOBALS['strFor']} {$aValue['parentcontext']} ({$aValue['parentcontextid']})";
                 }
                 if (!empty($aValue['hasChildren'])) {
                     $str .= " {$GLOBALS['strAdditionItems']}";
                 }
                 $aAuditData[$key]['desc'] = strlen($str) > 30 ? substr($str, 0, 30) . '...' : $str;
             }
         } else {
             $this->oTpl->assign('noData', $GLOBALS['strAuditNoData']);
         }
         $this->oTpl->assign('screen', 'enabled');
         $this->oTpl->assign('aAuditData', $aAuditData);
         $this->oTpl->assign('siteUrl', MAX::constructUrl(MAX_URL_ADMIN, 'userlog-index.php'));
         $this->oTpl->assign('siteTitle', $GLOBALS['strAuditTrailGoTo']);
     }
     $this->oTpl->display();
 }
Пример #5
0
 /**
  * A method to launch and display the widget
  *
  */
 function display()
 {
     $aConf = $GLOBALS['_MAX']['CONF'];
     phpAds_PageHeader(null, new OA_Admin_UI_Model_PageHeaderModel(), '', false, false);
     $oTpl = new OA_Admin_Template('dashboard/main.html');
     if (!$aConf['ui']['dashboardEnabled'] || !$aConf['sync']['checkForUpdates']) {
         $dashboardUrl = MAX::constructURL(MAX_URL_ADMIN, 'dashboard.php?widget=Disabled');
     } else {
         $m2mTicket = OA_Dal_Central_M2M::getM2MTicket(OA_Permission::getAccountId());
         if (empty($m2mTicket)) {
             $dashboardUrl = MAX::constructURL(MAX_URL_ADMIN, 'dashboard.php?widget=Reload');
         } else {
             $dashboardUrl = $this->buildDashboardUrl($m2mTicket, null, '&');
         }
     }
     $oTpl->assign('dashboardURL', $dashboardUrl);
     $oTpl->display();
     phpAds_PageFooter('', true);
 }
 /**
  * A private method to return the account ID of the
  * account that should "own" audit trail entries for
  * this entity type; NOT related to the account ID
  * of the currently active account performing an
  * action.
  *
  * @return integer The account ID to insert into the
  *                 "account_id" column of the audit trail
  *                 database table.
  */
 public function getOwningAccountIds($resetCache = false)
 {
     $accountType = OA_Permission::getAccountType(false);
     switch ($accountType) {
         case OA_ACCOUNT_ADMIN:
             return parent::_getOwningAccountIdsByAccountId($accountId = OA_Permission::getAccountId());
         case OA_ACCOUNT_ADVERTISER:
             $parentTable = 'clients';
             $parentKeyName = 'clientid';
             break;
         case OA_ACCOUNT_TRAFFICKER:
             $parentTable = 'affiliates';
             $parentKeyName = 'affiliateid';
             break;
         case OA_ACCOUNT_MANAGER:
             $parentTable = 'agency';
             $parentKeyName = 'agencyid';
             break;
     }
     return $this->_getOwningAccountIds($parentTable, $parentKeyName);
 }
Пример #7
0
 /**
  * A static method for processing preference values from a UI form, and
  * updating the preference values in the database.
  *
  * @static
  * @param array $aElementNames An array of HTML form element names, which
  *                             are also the preference value names.
  * @param array $aCheckboxes   An array of the above HTML form element
  *                             names which are checkboxes, as these will not
  *                             be set in the form POST if unchecked, and
  *                             so need to be treated differently.
  * @return boolean True on success, false otherwise.
  */
 function processPreferencesFromForm($aElementNames, $aCheckboxes)
 {
     phpAds_registerGlobalUnslashed('token');
     if (!phpAds_SessionValidateToken($GLOBALS['token'])) {
         return false;
     }
     // Get all of the preference types that exist
     $aPreferenceTypes = array();
     $doPreferences = OA_Dal::factoryDO('preferences');
     $doPreferences->find();
     if ($doPreferences->getRowCount() < 1) {
         return false;
     }
     while ($doPreferences->fetch()) {
         $aPreference = $doPreferences->toArray();
         $aPreferenceTypes[$aPreference['preference_name']] = array('preference_id' => $aPreference['preference_id'], 'account_type' => $aPreference['account_type']);
     }
     // Are there any preference types in the system?
     if (empty($aPreferenceTypes)) {
         return false;
     }
     // Get the type of the current accout
     $currentAccountType = OA_Permission::getAccountType();
     // Get the current account's ID
     $currentAccountId = OA_Permission::getAccountId();
     // Get the parent account preferences
     $aParentPreferences = OA_Preferences::loadPreferences(false, true, true);
     // Prepare the preference values that should be saved or deleted
     $aSavePreferences = array();
     $aDeletePreferences = array();
     foreach ($aElementNames as $preferenceName) {
         // Ensure that the current account has permission to process
         // the preference type
         $access = OA_Preferences::hasAccess($currentAccountType, $aPreferenceTypes[$preferenceName]['account_type']);
         if ($access == false) {
             // Don't process this value
             continue;
         }
         // Register the HTML element value
         phpAds_registerGlobalUnslashed($preferenceName);
         // Is the HTML element value a checkbox, and unset?
         if (isset($aCheckboxes[$preferenceName]) && !isset($GLOBALS[$preferenceName])) {
             // Set the value of the element to the false string ""
             $GLOBALS[$preferenceName] = '';
         } else {
             if (isset($aCheckboxes[$preferenceName]) && $GLOBALS[$preferenceName]) {
                 // Set the value of the element to the true string "1"
                 $GLOBALS[$preferenceName] = '1';
             }
         }
         // Was the HTML element value set?
         if (isset($GLOBALS[$preferenceName])) {
             // Is the preference value different from the parent value?
             if (!isset($aParentPreferences[$preferenceName]) || $GLOBALS[$preferenceName] != $aParentPreferences[$preferenceName]) {
                 // The preference value is different from the parent, so it
                 // needs to be stored
                 $aSavePreferences[$preferenceName] = $GLOBALS[$preferenceName];
             } else {
                 if ($currentAccountType != OA_ACCOUNT_ADMIN) {
                     // The preference value is not different from the parent, so
                     // it should be deleted if not the admin account (in case it
                     // exists for the account, and so would not inherit correctly
                     // if the admin account changes preferences)
                     $aDeletePreferences[$preferenceName] = $GLOBALS[$preferenceName];
                 }
             }
         }
     }
     // Save the required preferences
     foreach ($aSavePreferences as $preferenceName => $preferenceValue) {
         $doAccount_preference_assoc = OA_Dal::factoryDO('account_preference_assoc');
         $doAccount_preference_assoc->account_id = $currentAccountId;
         $doAccount_preference_assoc->preference_id = $aPreferenceTypes[$preferenceName]['preference_id'];
         $doAccount_preference_assoc->find();
         if ($doAccount_preference_assoc->getRowCount() != 1) {
             // Insert the preference
             $doAccount_preference_assoc->value = $preferenceValue;
             $result = $doAccount_preference_assoc->insert();
             if ($result === false) {
                 return false;
             }
         } else {
             // Update the preference
             $doAccount_preference_assoc->fetch();
             $doAccount_preference_assoc->value = $preferenceValue;
             $result = $doAccount_preference_assoc->update();
             if ($result === false) {
                 return false;
             }
         }
     }
     // Delete the required preferences
     foreach ($aDeletePreferences as $preferenceName => $preferenceValue) {
         $doAccount_preference_assoc = OA_Dal::factoryDO('account_preference_assoc');
         $doAccount_preference_assoc->account_id = $currentAccountId;
         $doAccount_preference_assoc->preference_id = $aPreferenceTypes[$preferenceName]['preference_id'];
         $doAccount_preference_assoc->find();
         if ($doAccount_preference_assoc->getRowCount() == 1) {
             // Delete the preference
             $result = $doAccount_preference_assoc->delete();
             if ($result === false) {
                 return false;
             }
         }
     }
     return true;
 }
    $aParams['advertiser_id'] = $advertiserId;
    $aParams['campaign_id'] = $campaignId;
}
if ($showPublishers) {
    $aParams['publisher_id'] = $publisherId;
    $aParams['zone_id'] = $zoneId;
}
// Account security
if (OA_Permission::isAccount(OA_ACCOUNT_MANAGER)) {
    $aParams['account_id'] = OA_Permission::getAccountId();
}
if (OA_Permission::isAccount(OA_ACCOUNT_ADVERTISER)) {
    $aParams['advertiser_account_id'] = OA_Permission::getAccountId();
}
if (OA_Permission::isAccount(OA_ACCOUNT_TRAFFICKER)) {
    $aParams['website_account_id'] = OA_Permission::getAccountId();
}
$oUserlog = new OA_Dll_Audit();
$aAuditData = $oUserlog->getAuditLog($aParams);
$aParams['totalItems'] = count($aAuditData);
if (!isset($pageID) || $pageID == 1) {
    $aParams['startRecord'] = 0;
} else {
    $aParams['startRecord'] = $pageID * $setPerPage - $setPerPage;
}
if ($aParams['startRecord'] > $aParams['totalItems']) {
    $aParams['startRecord'] = 0;
}
$aParams['perPage'] = MAX_getStoredValue('setPerPage', 10);
// Retrieve audit details
$aAuditData = $oUserlog->getAuditLog($aParams);
Пример #9
0
 /**
  * A method to launch and display the widget
  *
  * @param array $aParams The parameters array, usually $_REQUEST
  */
 function display()
 {
     $conf = $GLOBALS['_MAX']['CONF'];
     if (!$conf['audit']['enabled']) {
         $this->oTpl->assign('screen', 'disabled');
         $this->oTpl->assign('siteTitle', $GLOBALS['strCampaignAuditTrailSetup']);
         $this->oTpl->assign('siteUrl', MAX::constructUrl(MAX_URL_ADMIN, 'account-settings-debug.php'));
     } else {
         $oCache = new OA_Cache('campaignOverview', 'Widgets');
         $aCache = $oCache->load(true);
         $aCampaign = array();
         if (isset($aCache['maxItems'])) {
             if (OA_Permission::isAccount(OA_ACCOUNT_ADMIN)) {
                 foreach ($aCache['aAccounts'] as $aActions) {
                     foreach ($aActions as $aAction) {
                         $aCampaign[$aAction['auditid']] = $aAction;
                     }
                 }
             } else {
                 $aAccountsId = OA_Permission::getOwnedAccounts(OA_Permission::getAccountId());
                 foreach ($aAccountsId as $accountId) {
                     if (isset($aCache['aAccounts'][$accountId])) {
                         foreach ($aCache['aAccounts'][$accountId] as $aAction) {
                             $aCampaign[$aAction['auditid']] = $aAction;
                         }
                     }
                 }
             }
             krsort($aCampaign);
             $aCampaign = array_slice($aCampaign, 0, $aCache['maxItems']);
         }
         if (count($aCampaign)) {
             $aActionMap = array('added' => $GLOBALS['strCampaignStatusAdded'], 'started' => $GLOBALS['strCampaignStatusStarted'], 'restarted' => $GLOBALS['strCampaignStatusRestarted'], 'completed' => $GLOBALS['strCampaignStatusExpired'], 'paused' => $GLOBALS['strCampaignStatusPaused'], 'deleted' => $GLOBALS['strCampaignStatusDeleted']);
             foreach ($aCampaign as $k => $v) {
                 if (isset($aActionMap[$v['action']])) {
                     $aCampaign[$k]['actionDesc'] = $aActionMap[$v['action']];
                 }
             }
         } else {
             // Check if the account has any campaign in its realm
             $doCampaigns = OA_Dal::factoryDO('campaigns');
             if (!empty($aParam['account_id'])) {
                 $doClients = OA_Dal::factoryDO('clients');
                 $doAgency = OA_Dal::factoryDO('agency');
                 $doAgency->account_id = $aParam['account_id'];
                 $doClients->joinAdd($doAgency);
                 $doCampaigns->joinAdd($doClients);
             }
             $doCampaigns->limit(1);
             $this->oTpl->assign('hasCampaigns', $doCampaigns->count());
             if (OA_Permission::isAccount(OA_ACCOUNT_ADMIN)) {
                 $this->oTpl->assign('isAdmin', true);
             }
         }
         $this->oTpl->assign('screen', 'enabled');
         $this->oTpl->assign('aCampaign', $aCampaign);
         $this->oTpl->assign('siteUrl', MAX::constructURL(MAX_URL_ADMIN, 'advertiser-campaigns.php'));
         $this->oTpl->assign('baseUrl', MAX::constructURL(MAX_URL_ADMIN, 'campaign-edit.php'));
     }
     $this->oTpl->display();
 }
 /**
  * This method uses information from the DB_DataObjects links.ini file to handle
  * the hierarchy of tables, and find out if a DB_DataOjects "entity" belongs to
  * a given account ID.
  *
  * It checks if there is a linked (referenced) object to this object with
  * table==$accountTable and id==$accountId
  *
  * @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;
         }
     }
     // Does the table have an account_id field?
     $aFields = $this->table();
     if (isset($aFields['account_id']) && $this->account_id == $accountId) {
         return true;
     }
     $found = null;
     $links = $this->links();
     if (!empty($links)) {
         foreach ($links as $key => $match) {
             list($table, $link) = explode(':', $match);
             $table = $this->getTableWithoutPrefix($table);
             $doCheck =& $this->getCachedLink($key, $table, $link);
             if (!$doCheck) {
                 return null;
             }
             $found = $doCheck->belongsToAccount($accountId);
             if ($found !== null) {
                 return $found;
             }
         }
     }
     return $found;
 }
Пример #11
0
 /**
  * write preferences records for the given plugin
  *
  * @param array $aPreferences
  * @return boolean
  */
 function _registerPreferences($name, $aPreferences = null)
 {
     if ($aPreferences) {
         $accountId = OA_Permission::getAccountId();
         foreach ($aPreferences as $k => &$aPreference) {
             if (!$this->_registerPreferenceOne($name, $aPreference, $accountId)) {
                 return false;
             }
         }
     }
     return true;
 }
Пример #12
0
 // user that is also linked to the admin account
 $aAdminUserIds = array();
 $aUserIds = array();
 $oDbh =& OA_DB::singleton();
 // Get the ID of all users linked to the admin account
 $adminAccountId = OA_Dal_ApplicationVariables::get('admin_account_id');
 $doAccount_user_assoc = OA_Dal::factoryDO('account_user_assoc');
 $doAccount_user_assoc->account_id = $adminAccountId;
 $doAccount_user_assoc->find();
 while ($doAccount_user_assoc->fetch() > 0) {
     // Store the user info for later
     $aInfo = $doAccount_user_assoc->toArray();
     $aAdminUserIds[] = $aInfo['user_id'];
 }
 // Get the current manager account ID
 $currentAccountId = OA_Permission::getAccountId();
 // Select all of the users that are linked with the current manager account
 $doAccount_user_assoc = OA_Dal::factoryDO('account_user_assoc');
 $doAccount_user_assoc->account_id = $currentAccountId;
 $doAccount_user_assoc->find();
 while ($doAccount_user_assoc->fetch() > 0) {
     // Store the user info for later
     $aInfo = $doAccount_user_assoc->toArray();
     if (!in_array($aInfo['user_id'], $aAdminUserIds)) {
         $aUserIds[] = $aInfo['user_id'];
     }
 }
 // Translate the manager account ID into an agency ID
 $doAgency = OA_Dal::factoryDO('agency');
 $doAgency->account_id = $currentAccountId;
 $doAgency->find();
Пример #13
0
 function belongsToAccount($accountId = null)
 {
     // Set the account ID, if not passed in
     if (empty($accountId)) {
         $accountId = OA_Permission::getAccountId();
     }
     $result = parent::belongsToAccount($accountId);
     if (!$result) {
         $doAccounts = OA_Dal::staticGetDO('accounts', $accountId);
         $result = $doAccounts->account_type == OA_ACCOUNT_ADMIN;
     }
     return $result;
 }
Пример #14
0
 function _assignUserAccountInfo($oCurrentSection)
 {
     global $session;
     // Show currently logged on user and IP
     if (OA_Auth::isLoggedIn() || defined('phpAds_installing')) {
         $this->oTpl->assign('helpLink', OA_Admin_Help::getHelpLink($oCurrentSection));
         if (!defined('phpAds_installing')) {
             $this->oTpl->assign('infoUser', OA_Permission::getUsername());
             $this->oTpl->assign('buttonLogout', true);
             $this->oTpl->assign('buttonReportBugs', true);
             // Account switcher
             OA_Admin_UI_AccountSwitch::assignModel($this->oTpl);
             $this->oTpl->assign('strWorkingAs', $GLOBALS['strWorkingAs_Key']);
             $this->oTpl->assign('keyWorkingAs', $GLOBALS['keyWorkingAs']);
             $this->oTpl->assign('accountId', OA_Permission::getAccountId());
             $this->oTpl->assign('accountName', OA_Permission::getAccountName());
             $this->oTpl->assign('accountSearchUrl', MAX::constructURL(MAX_URL_ADMIN, 'account-switch-search.php'));
             $this->oTpl->assign('productUpdatesCheck', OA_Permission::isAccount(OA_ACCOUNT_ADMIN) && $GLOBALS['_MAX']['CONF']['sync']['checkForUpdates'] && !isset($session['maint_update_js']));
             if (OA_Permission::isUserLinkedToAdmin()) {
                 $this->oTpl->assign('maintenanceAlert', OA_Dal_Maintenance_UI::alertNeeded());
             }
         } else {
             $this->oTpl->assign('buttonStartOver', true);
         }
     }
 }
Пример #15
0
 function getCacheId()
 {
     return array_merge(parent::getCacheId(), array(OA_Permission::getAccountId()));
 }
Пример #16
0
 /**
  * Store user rights per account
  *
  * @param array $aPermissions  Array of permission IDs
  * @param integer $accountId  account ID
  * @param integer $userId  user ID
  * @param array $aAllowedPermissions  Array of allowed permissions - keys of array are permissions IDs
  * @return true on success else false
  */
 function storeUserAccountsPermissions($aPermissions, $accountId = null, $userId = null, $aAllowedPermissions = null)
 {
     if (empty($userId)) {
         $userId = OA_Permission::getUserId();
     }
     if (empty($accountId)) {
         $accountId = OA_Permission::getAccountId();
     }
     OA_Permission::deleteExistingPermissions($accountId, $userId, $aAllowedPermissions);
     // add new permissions
     foreach ($aPermissions as $permissionId) {
         if (!is_null($aAllowedPermissions) && !isset($aAllowedPermissions[$permissionId])) {
             // check if permission is on the list of allowed permissions
             continue;
         }
         $doAccount_user_permission_assoc = OA_Dal::factoryDO('account_user_permission_assoc');
         $doAccount_user_permission_assoc->account_id = $accountId;
         $doAccount_user_permission_assoc->user_id = $userId;
         $doAccount_user_permission_assoc->permission_id = $permissionId;
         $doAccount_user_permission_assoc->is_allowed = 1;
         if (!$doAccount_user_permission_assoc->insert()) {
             return false;
         }
     }
     return true;
 }