本文整理汇总了PHP中UserRights::GetUserId方法的典型用法代码示例。如果您正苦于以下问题:PHP UserRights::GetUserId方法的具体用法?PHP UserRights::GetUserId怎么用?PHP UserRights::GetUserId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserRights
的用法示例。
在下文中一共展示了UserRights::GetUserId方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: DBObjectSearch
$oShortcut = MetaModel::GetObject('Shortcut', $iShortcut);
$oShortcut->StartRenameDialog($oPage);
break;
case 'shortcut_rename_go':
$iShortcut = utils::ReadParam('id', 0);
$oShortcut = MetaModel::GetObject('Shortcut', $iShortcut);
$sName = utils::ReadParam('attr_name', '', false, 'raw_data');
if (strlen($sName) > 0) {
$oShortcut->Set('name', $sName);
$oShortcut->DBUpdate();
$oPage->add_ready_script('window.location.reload();');
}
break;
case 'shortcut_delete_go':
$oSearch = new DBObjectSearch('Shortcut');
$oSearch->AddCondition('user_id', UserRights::GetUserId(), '=');
$aShortcuts = utils::ReadMultipleSelection($oSearch);
foreach ($aShortcuts as $iShortcut) {
$oShortcut = MetaModel::GetObject('Shortcut', $iShortcut);
$oShortcut->DBDelete();
$oPage->add_ready_script('window.location.reload();');
}
break;
case 'export_dashboard':
$sMenuId = utils::ReadParam('id', '', false, 'raw_data');
ApplicationMenu::LoadAdditionalMenus();
$index = ApplicationMenu::GetMenuIndexById($sMenuId);
$oMenu = ApplicationMenu::GetMenuNode($index);
if ($oMenu instanceof DashboardMenuNode) {
$oDashboard = $oMenu->GetDashboard();
$oPage->TrashUnexpectedOutput();
示例2: PopulateChildMenus
public function PopulateChildMenus()
{
// Load user shortcuts in DB
//
$oBMSearch = new DBObjectSearch('Shortcut');
$oBMSearch->AddCondition('user_id', UserRights::GetUserId(), '=');
$oBMSet = new DBObjectSet($oBMSearch, array('friendlyname' => true));
// ascending on friendlyname
$fRank = 1;
while ($oShortcut = $oBMSet->Fetch()) {
$sName = $this->GetMenuId() . '_' . $oShortcut->GetKey();
$oShortcutMenu = new ShortcutMenuNode($sName, $oShortcut, $this->GetIndex(), $fRank++);
}
// Complete the tree
//
parent::PopulateChildMenus();
}
示例3: AddLogEntryFromJSON
public function AddLogEntryFromJSON($oJson, $bCheckUserId = true)
{
$sText = isset($oJson->message) ? $oJson->message : '';
if (isset($oJson->user_id)) {
if (!UserRights::IsAdministrator()) {
throw new Exception("Only administrators can set the user id", RestResult::UNAUTHORIZED);
}
if ($bCheckUserId && $oJson->user_id != 0) {
try {
$oUser = RestUtils::FindObjectFromKey('User', $oJson->user_id);
} catch (Exception $e) {
throw new Exception('user_id: ' . $e->getMessage(), $e->getCode());
}
$iUserId = $oUser->GetKey();
$sOnBehalfOf = $oUser->GetFriendlyName();
} else {
$iUserId = $oJson->user_id;
$sOnBehalfOf = $oJson->user_login;
}
} else {
$iUserId = UserRights::GetUserId();
$sOnBehalfOf = UserRights::GetUserFriendlyName();
}
if (isset($oJson->date)) {
$oDate = new DateTime($oJson->date);
$iDate = (int) $oDate->format('U');
} else {
$iDate = time();
}
$sDate = date(Dict::S('UI:CaseLog:DateFormat'), $iDate);
$sSeparator = sprintf(CASELOG_SEPARATOR, $sDate, $sOnBehalfOf, $iUserId);
$iSepLength = strlen($sSeparator);
$iTextlength = strlen($sText);
$this->m_sLog = $sSeparator . $sText . $this->m_sLog;
// Latest entry printed first
$this->m_aIndex[] = array('user_name' => $sOnBehalfOf, 'user_id' => $iUserId, 'date' => $iDate, 'text_length' => $iTextlength, 'separator_length' => $iSepLength);
$this->m_bModified = true;
}
示例4: PrepareProcessing
/**
* Prepare structures in memory, to speedup the processing of a given replica
*/
public function PrepareProcessing($bFirstPass = true)
{
if ($this->m_oDataSource->Get('status') == 'obsolete') {
throw new SynchroExceptionNotStarted(Dict::S('Core:SyncDataSourceObsolete'));
}
if (!UserRights::IsAdministrator() && $this->m_oDataSource->Get('user_id') != UserRights::GetUserId()) {
throw new SynchroExceptionNotStarted(Dict::S('Core:SyncDataSourceAccessRestriction'));
}
// Get the list of SQL columns
$sClass = $this->m_oDataSource->GetTargetClass();
$aAttCodesExpected = array();
$aAttCodesToReconcile = array();
$aAttCodesToUpdate = array();
$sSelectAtt = "SELECT SynchroAttribute WHERE sync_source_id = :source_id AND (update = 1 OR reconcile = 1)";
$oSetAtt = new DBObjectSet(DBObjectSearch::FromOQL($sSelectAtt), array(), array('source_id' => $this->m_oDataSource->GetKey()));
while ($oSyncAtt = $oSetAtt->Fetch()) {
if ($oSyncAtt->Get('update')) {
$aAttCodesToUpdate[$oSyncAtt->Get('attcode')] = $oSyncAtt;
}
if ($oSyncAtt->Get('reconcile')) {
$aAttCodesToReconcile[$oSyncAtt->Get('attcode')] = $oSyncAtt;
}
$aAttCodesExpected[$oSyncAtt->Get('attcode')] = $oSyncAtt;
}
$aColumns = $this->m_oDataSource->GetSQLColumns(array_keys($aAttCodesExpected));
$aExtDataFields = array_keys($aColumns);
$aExtDataFields[] = 'primary_key';
$this->m_aExtDataSpec = array('table' => $this->m_oDataSource->GetDataTable(), 'join_key' => 'id', 'fields' => $aExtDataFields);
// Get the list of attributes, determine reconciliation keys and update targets
//
if ($this->m_oDataSource->Get('reconciliation_policy') == 'use_attributes') {
$this->m_aReconciliationKeys = $aAttCodesToReconcile;
} elseif ($this->m_oDataSource->Get('reconciliation_policy') == 'use_primary_key') {
// Override the settings made at the attribute level !
$this->m_aReconciliationKeys = array("primary_key" => null);
}
if ($bFirstPass) {
$this->m_oStatLog->AddTrace("Update of: {" . implode(', ', array_keys($aAttCodesToUpdate)) . "}");
$this->m_oStatLog->AddTrace("Reconciliation on: {" . implode(', ', array_keys($this->m_aReconciliationKeys)) . "}");
}
if (count($aAttCodesToUpdate) == 0) {
$this->m_oStatLog->AddTrace("No attribute to update");
throw new SynchroExceptionNotStarted('There is no attribute to update');
}
if (count($this->m_aReconciliationKeys) == 0) {
$this->m_oStatLog->AddTrace("No attribute for reconciliation");
throw new SynchroExceptionNotStarted('No attribute for reconciliation');
}
$this->m_aAttributes = array();
foreach ($aAttCodesToUpdate as $sAttCode => $oSyncAtt) {
$oAttDef = MetaModel::GetAttributeDef($this->m_oDataSource->GetTargetClass(), $sAttCode);
if ($oAttDef->IsWritable()) {
$this->m_aAttributes[$sAttCode] = $oSyncAtt;
}
}
// Compute and keep track of the limit date taken into account for obsoleting replicas
//
if ($this->m_oLastFullLoadStartDate == null) {
// No previous import known, use the full_load_periodicity value... and the current date
$this->m_oLastFullLoadStartDate = new DateTime();
// Now
$iLoadPeriodicity = $this->m_oDataSource->Get('full_load_periodicity');
// Duration in seconds
if ($iLoadPeriodicity > 0) {
$sInterval = "-{$iLoadPeriodicity} seconds";
$this->m_oLastFullLoadStartDate->Modify($sInterval);
} else {
$this->m_oLastFullLoadStartDate = new DateTime('1970-01-01');
}
}
if ($bFirstPass) {
$this->m_oStatLog->AddTrace("Limit Date: " . $this->m_oLastFullLoadStartDate->Format('Y-m-d H:i:s'));
}
}
示例5: Load
/**
* Loads the preferences for the current user, creating the record in the database
* if needed
*/
protected static function Load()
{
if (self::$oUserPrefs != null) {
return;
}
$oSearch = new DBObjectSearch('appUserPreferences');
$oSearch->AddCondition('userid', UserRights::GetUserId(), '=');
$oSet = new DBObjectSet($oSearch);
$oObj = $oSet->Fetch();
if ($oObj == null) {
// No prefs (yet) for this user, create the object
$oObj = new appUserPreferences();
$oObj->Set('userid', UserRights::GetUserId());
$oObj->Set('preferences', array());
// Default preferences: an empty array
try {
$oObj->DBInsert();
} catch (Exception $e) {
// Ignore errors
}
}
self::$oUserPrefs = $oObj;
}
示例6: IsPowerUSer
/**
* Determine if the current user can be considered as being a portal power user
*/
function IsPowerUSer()
{
$iUserID = UserRights::GetUserId();
$sOQLprofile = "SELECT URP_Profiles AS p JOIN URP_UserProfile AS up ON up.profileid=p.id WHERE up.userid = :user AND p.name = :profile";
$oProfileSet = new DBObjectSet(DBObjectSearch::FromOQL($sOQLprofile), array(), array('user' => $iUserID, 'profile' => PORTAL_POWER_USER_PROFILE));
$bRes = $oProfileSet->count() > 0;
return $bRes;
}
示例7: Revert
public function Revert()
{
$oUDSearch = new DBObjectSearch('UserDashboard');
$oUDSearch->AddCondition('user_id', UserRights::GetUserId(), '=');
$oUDSearch->AddCondition('menu_code', $this->sId, '=');
$oUDSet = new DBObjectSet($oUDSearch);
if ($oUDSet->Count() > 0) {
// Assuming there is at most one couple {user, menu}!
$oUserDashboard = $oUDSet->Fetch();
$oUserDashboard->DBDelete();
}
}
示例8: SetApprover
public function SetApprover($sStimulusCode)
{
$this->Set('approver_id', UserRights::GetUserId());
return true;
}
示例9: SetCurrentUser
/**
* Lifecycle action: Set the current logged in user for the given attribute
*/
public function SetCurrentUser($sAttCode)
{
$oAttDef = MetaModel::GetAttributeDef(get_class($this), $sAttCode);
if ($oAttDef instanceof AttributeString) {
// Note: the user friendly name is the contact friendly name if a contact is attached to the logged in user
$this->Set($sAttCode, UserRights::GetUserFriendlyName());
} else {
if ($oAttDef->IsExternalKey()) {
if ($oAttDef->GetTargetClass() != 'User') {
throw new Exception("SetCurrentUser: the attribute {$sAttCode} must be an external key to 'User', found '" . $oAttDef->GetTargetClass() . "'");
}
}
$this->Set($sAttCode, UserRights::GetUserId());
}
return true;
}
示例10: GetCreationForm
public static function GetCreationForm($sOQL = null, $sTableSettings = null)
{
$oForm = new DesignerForm();
// Find a unique default name
// -> The class of the query + an index if necessary
if ($sOQL == null) {
$sDefault = '';
} else {
$oBMSearch = new DBObjectSearch('Shortcut');
$oBMSearch->AddCondition('user_id', UserRights::GetUserId(), '=');
$oBMSet = new DBObjectSet($oBMSearch);
$aNames = $oBMSet->GetColumnAsArray('name');
$oSearch = DBObjectSearch::FromOQL($sOQL);
$sDefault = utils::MakeUniqueName($oSearch->GetClass(), $aNames);
}
$oField = new DesignerTextField('name', Dict::S('Class:Shortcut/Attribute:name'), $sDefault);
$oField->SetMandatory(true);
$oForm->AddField($oField);
/*
$oField = new DesignerComboField('auto_reload', Dict::S('Class:ShortcutOQL/Attribute:auto_reload'), 'none');
$oAttDef = MetaModel::GetAttributeDef(__class__, 'auto_reload');
$oField->SetAllowedValues($oAttDef->GetAllowedValues());
$oField->SetMandatory(true);
$oForm->AddField($oField);
*/
$oField = new DesignerBooleanField('auto_reload', Dict::S('Class:ShortcutOQL/Attribute:auto_reload'), false);
$oForm->AddField($oField);
$oField = new DesignerTextField('auto_reload_sec', Dict::S('Class:ShortcutOQL/Attribute:auto_reload_sec'), MetaModel::GetConfig()->GetStandardReloadInterval());
$oField->SetValidationPattern('^$|^0*([5-9]|[1-9][0-9]+)$');
// Can be empty, or a number > 4
$oField->SetMandatory(false);
$oForm->AddField($oField);
$oField = new DesignerHiddenField('oql', '', $sOQL);
$oForm->AddField($oField);
$oField = new DesignerHiddenField('table_settings', '', $sTableSettings);
$oForm->AddField($oField);
return $oForm;
}
示例11: FindExporterFromToken
/**
* Find the exporter corresponding to the given persistent token
* @param int $iPersistentToken The identifier of the BulkExportResult object storing the information
* @return iBulkExport|NULL
*/
public static function FindExporterFromToken($iPersistentToken = null)
{
$oBulkExporter = null;
$oInfo = MetaModel::GetObject('BulkExportResult', $iPersistentToken, false);
if ($oInfo && $oInfo->Get('user_id') == UserRights::GetUserId()) {
$sFormatCode = $oInfo->Get('format');
$oSearch = DBObjectSearch::unserialize($oInfo->Get('search'));
$oBulkExporter = self::FindExporter($sFormatCode, $oSearch);
if ($oBulkExporter) {
$oBulkExporter->SetFormat($sFormatCode);
$oBulkExporter->SetObjectList($oSearch);
$oBulkExporter->SetChunkSize($oInfo->Get('chunk_size'));
$oBulkExporter->SetStatusInfo(json_decode($oInfo->Get('status_info'), true));
$oBulkExporter->sTmpFile = $oInfo->Get('temp_file_path');
$oBulkExporter->oBulkExportResult = $oInfo;
}
}
return $oBulkExporter;
}
示例12: DisplayPreferences
//.........这里部分代码省略.........
\t{
\t\t// paginated display, restore the selection
\t\tvar pager = \$('#user_prefs form .pager');
\t\t\$(':input[name=selectionMode]', pager).val('positive');
\t\tfor (i=0; i<aChecked.length; i++)
\t\t{
\t\t\tpager.append('<input type="hidden" name="storedSelection[]" id="'+aChecked[i]+'" value="'+aChecked[i]+'"/>');
\t\t}
\t\t\$('#user_prefs table.listResults').trigger('load_selection');
\t\t
\t}
\telse
\t{
\t\t\$('#user_prefs form :checkbox[name^=selectObject]').each( function()
\t\t\t{
\t\t\t\tif (\$.inArray(\$(this).val(), aChecked) > -1)
\t\t\t\t{
\t\t\t\t\t\$(this).attr('checked', true);
\t\t\t\t\t\$(this).trigger('change');
\t\t\t\t}
\t\t\t});
\t}
EOF
);
}
//////////////////////////////////////////////////////////////////////////
//
// Shortcuts
//
//////////////////////////////////////////////////////////////////////////
$oP->add('<fieldset><legend>' . Dict::S('Menu:MyShortcuts') . '</legend>');
//$oP->p(Dict::S('UI:Menu:MyShortcuts+'));
$oBMSearch = new DBObjectSearch('Shortcut');
$oBMSearch->AddCondition('user_id', UserRights::GetUserId(), '=');
//$aExtraParams = array('menu' => false, 'toolkit_menu' => false, 'display_limit' => false, 'localize_values' => $bLocalize, 'zlist' => 'details');
$aExtraParams = array();
$oBlock = new DisplayBlock($oBMSearch, 'list', false, $aExtraParams);
$oBlock->Display($oP, 'shortcut_list', array('view_link' => false, 'menu' => false, 'toolkit_menu' => false, 'selection_mode' => true, 'selection_type' => 'multiple', 'cssCount' => '#shortcut_selection_count', 'table_id' => 'user_prefs_shortcuts'));
$oP->add('<p>');
$oSet = new DBObjectSet($oBMSearch);
if ($oSet->Count() > 0) {
$sButtons = '<img src="../images/tv-item-last.gif">';
$sButtons .= ' ';
$sButtons .= '<button id="shortcut_btn_rename">' . Dict::S('UI:Button:Rename') . '</button>';
$sButtons .= ' ';
$sButtons .= '<button id="shortcut_btn_delete">' . Dict::S('UI:Button:Delete') . '</button>';
// Selection count updated by the pager, and used to enable buttons
$oP->add('<input type="hidden" id="shortcut_selection_count"/>');
$oP->add('</fieldset>');
$sConfirmDelete = addslashes(Dict::S('UI:ShortcutDelete:Confirm'));
$oP->add_ready_script(<<<EOF
function OnShortcutBtnRename()
{
\tvar oParams = \$('#datatable_shortcut_list').datatable('GetMultipleSelectionParams');
\toParams.operation = 'shortcut_rename_dlg';
\t\$.post(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php', oParams, function(data){
\t\t\$('body').append(data);
\t});
\treturn false;
}
function OnShortcutBtnDelete()
{
\tif (confirm('{$sConfirmDelete}'))
\t{
示例13: TakeOwnership
protected function TakeOwnership($sToken = null)
{
if ($this->oToken == null) {
$this->oToken = new iTopOwnershipToken();
$this->oToken->Set('obj_class', $this->sObjClass);
$this->oToken->Set('obj_key', $this->iObjKey);
}
$this->oToken->Set('acquired', date('Y-m-d H:i:s'));
$this->oToken->Set('user_id', UserRights::GetUserId());
$this->oToken->Set('last_seen', date('Y-m-d H:i:s'));
if ($sToken === null) {
$sToken = sprintf('%X', microtime(true));
}
$this->oToken->Set('token', $sToken);
$this->oToken->DBWrite();
return $this->oToken->Get('token');
}