Esempio n. 1
0
     $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();
 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();
 }
Esempio n. 3
0
 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;
 }
 /**
  * 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'));
     }
 }
 /**
  * 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;
 }
Esempio n. 6
0
/**
 * 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;
}
Esempio n. 7
0
 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();
     }
 }
 public function SetApprover($sStimulusCode)
 {
     $this->Set('approver_id', UserRights::GetUserId());
     return true;
 }
Esempio n. 9
0
 /**
  * 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;
 }
Esempio n. 10
0
 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;
 }
Esempio n. 11
0
 /**
  * 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;
 }
Esempio n. 12
0
/**
 * Displays the user's changeable preferences
 * @param $oP WebPage The web page used for the output
 */
function DisplayPreferences($oP)
{
    $oAppContext = new ApplicationContext();
    $sURL = utils::GetAbsoluteUrlAppRoot() . 'pages/UI.php?' . $oAppContext->GetForLink();
    $oP->add('<div class="page_header"><h1><img style="vertical-align:middle" src="../images/preferences.png"/>&nbsp;' . Dict::S('UI:Preferences') . "</h1></div>\n");
    $oP->add('<div id="user_prefs" style="max-width:800px; min-width:400px;">');
    //////////////////////////////////////////////////////////////////////////
    //
    // User Language selection
    //
    //////////////////////////////////////////////////////////////////////////
    $oP->add('<fieldset><legend>' . Dict::S('UI:FavoriteLanguage') . '</legend>');
    $oP->add('<form method="post">');
    $aLanguages = Dict::GetLanguages();
    $aSortedlang = array();
    foreach ($aLanguages as $sCode => $aLang) {
        if (MetaModel::GetConfig()->Get('demo_mode')) {
            if ($sCode != Dict::GetUserLanguage()) {
                // Demo mode: only the current user language is listed in the available choices
                continue;
            }
        }
        $aSortedlang[$aLang['description']] = $sCode;
    }
    ksort($aSortedlang);
    $oP->add('<p>' . Dict::S('UI:Favorites:SelectYourLanguage') . ' <select name="language">');
    foreach ($aSortedlang as $sCode) {
        $sSelected = $sCode == Dict::GetUserLanguage() ? 'selected' : '';
        $oP->add('<option value="' . $sCode . '" ' . $sSelected . '/>' . $aLanguages[$sCode]['description'] . ' (' . $aLanguages[$sCode]['localized_description'] . ')</option>');
    }
    $oP->add('</select></p>');
    $oP->add('<input type="hidden" name="operation" value="apply_language"/>');
    $oP->add($oAppContext->GetForForm());
    $oP->add('<p><input type="button" onClick="window.location.href=\'' . $sURL . '\'" value="' . Dict::S('UI:Button:Cancel') . '"/>');
    $oP->add('&nbsp;&nbsp;');
    $oP->add('<input type="submit" value="' . Dict::S('UI:Button:Apply') . '"/></p>');
    $oP->add('</form>');
    $oP->add('</fieldset>');
    //////////////////////////////////////////////////////////////////////////
    //
    // Other (miscellaneous) settings
    //
    //////////////////////////////////////////////////////////////////////////
    $oP->add('<fieldset><legend>' . Dict::S('UI:FavoriteOtherSettings') . '</legend>');
    $oP->add('<form method="post" onsubmit="return ValidateOtherSettings()">');
    $iDefaultPageSize = appUserPreferences::GetPref('default_page_size', MetaModel::GetConfig()->GetMinDisplayLimit());
    $oP->add('<p>' . Dict::Format('UI:Favorites:Default_X_ItemsPerPage', '<input id="default_page_size" name="default_page_size" type="text" size="3" value="' . $iDefaultPageSize . '"/><span id="v_default_page_size"></span>') . '</p>');
    $oP->add('<input type="hidden" name="operation" value="apply_others"/>');
    $oP->add($oAppContext->GetForForm());
    $oP->add('<p><input type="button" onClick="window.location.href=\'' . $sURL . '\'" value="' . Dict::S('UI:Button:Cancel') . '"/>');
    $oP->add('&nbsp;&nbsp;');
    $oP->add('<input id="other_submit" type="submit" value="' . Dict::S('UI:Button:Apply') . '"/></p>');
    $oP->add('</form>');
    $oP->add('</fieldset>');
    $oP->add_script(<<<EOF
function ValidateOtherSettings()
{
\tvar sPageLength = \$('#default_page_size').val();
\tvar iPageLength = parseInt(sPageLength , 10);
\tif (/^[0-9]+\$/.test(sPageLength) && (iPageLength > 0))
\t{
\t\t\$('#v_default_page_size').html('');
\t\t\$('#other_submit').removeAttr('disabled');
\t\treturn true;
\t}
\telse
\t{
\t\t\$('#v_default_page_size').html('<img src="../images/validation_error.png"/>');
\t\t\$('#other_submit').attr('disabled', 'disabled');
\t\treturn false;
\t}
}
EOF
);
    //////////////////////////////////////////////////////////////////////////
    //
    // Favorite Organizations
    //
    //////////////////////////////////////////////////////////////////////////
    $oP->add('<fieldset><legend>' . Dict::S('UI:FavoriteOrganizations') . '</legend>');
    $oP->p(Dict::S('UI:FavoriteOrganizations+'));
    $oP->add('<form method="post">');
    // Favorite organizations: the organizations listed in the drop-down menu
    $sOQL = ApplicationMenu::GetFavoriteSiloQuery();
    $oFilter = DBObjectSearch::FromOQL($sOQL);
    $oBlock = new DisplayBlock($oFilter, 'list', false);
    $oBlock->Display($oP, 1, array('menu' => false, 'selection_mode' => true, 'selection_type' => 'multiple', 'cssCount' => '.selectedCount', 'table_id' => 'user_prefs'));
    $oP->add($oAppContext->GetForForm());
    $oP->add('<input type="hidden" name="operation" value="apply"/>');
    $oP->add('<p><input type="button" onClick="window.location.href=\'' . $sURL . '\'" value="' . Dict::S('UI:Button:Cancel') . '"/>');
    $oP->add('&nbsp;&nbsp;');
    $oP->add('<input type="submit" value="' . Dict::S('UI:Button:Apply') . '"/></p>');
    $oP->add('</form>');
    $oP->add('</fieldset>');
    $aFavoriteOrgs = appUserPreferences::GetPref('favorite_orgs', null);
    if ($aFavoriteOrgs == null) {
        // All checked
        $oP->add_ready_script(<<<EOF
\tif (\$('#user_prefs table.pagination').length > 0)
\t{
\t\t// paginated display, restore the selection
\t\tvar pager = \$('#user_prefs form .pager');
\t\t\$(':input[name=selectionMode]', pager).val('negative');
\t\t\$('#user_prefs table.listResults').trigger('load_selection');
\t}
\telse
\t{
\t\t\$('#user_prefs table.listResults').trigger('check_all');
\t}
EOF
);
    } else {
        $sChecked = implode('","', $aFavoriteOrgs);
        $oP->add_ready_script(<<<EOF
\tvar aChecked = ["{$sChecked}"];
\tif (\$('#user_prefs table.pagination').length > 0)
\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 .= '&nbsp;';
        $sButtons .= '<button id="shortcut_btn_rename">' . Dict::S('UI:Button:Rename') . '</button>';
        $sButtons .= '&nbsp;';
        $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{
\t\tvar oParams = \$('#datatable_shortcut_list').datatable('GetMultipleSelectionParams');
\t\toParams.operation = 'shortcut_delete_go';

\t\t\$.post(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php', oParams, function(data){
\t\t\t\$('body').append(data);
\t\t});
\t}
\treturn false;
}

function OnSelectionCountChange()
{
\tvar iCountSelected = \$("#shortcut_selection_count").val();
\tif (iCountSelected == 0)
\t{
\t\t\$('#shortcut_btn_rename').attr('disabled', 'disabled');
\t\t\$('#shortcut_btn_delete').attr('disabled', 'disabled');
\t}
\telse if (iCountSelected == 1)
\t{
\t\t\$('#shortcut_btn_rename').removeAttr('disabled');
\t\t\$('#shortcut_btn_delete').removeAttr('disabled');
\t}
\telse
\t{
\t\t\$('#shortcut_btn_rename').attr('disabled', 'disabled');
\t\t\$('#shortcut_btn_delete').removeAttr('disabled');
\t}
}

var oUpperCheckBox = \$('#datatable_shortcut_list .checkAll').first();
oUpperCheckBox.parent().width(oUpperCheckBox.width() + 2);

\$('#datatable_shortcut_list').append('<tr><td colspan="2">&nbsp;&nbsp;&nbsp;{$sButtons}</td></tr>');
\$('#shortcut_selection_count').bind('change', OnSelectionCountChange);
\$('#shortcut_btn_rename').bind('click', OnShortcutBtnRename);
\$('#shortcut_btn_delete').bind('click', OnShortcutBtnDelete);
OnSelectionCountChange();
EOF
);
    }
    // if count > 0
    //////////////////////////////////////////////////////////////////////////
    //
    // Footer
    //
    $oP->add('</div>');
    $oP->add_ready_script("\$('#fav_page_length').bind('keyup change', function(){ ValidateOtherSettings(); })");
}
 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');
 }