controllers/UserPreferencesController.php
/**
     * Save user preference in database
     * 
     * @param array $formParams
     * @return boolean
     */
Save user preference in database

@param array $formParams
@return boolean
Save user preference in database @param array $formParams @return boolean
private function saveUserPreference(array $formParams) {
        $preferenceArr = array();
        $userID = Utils::getLoggedInUserId();
        $preferenceArr[PreferenceKeys::CODE_EDITOR_THEME] = $formParams[PreferenceKeys::CODE_EDITOR_THEME];
        $preferenceArr[PreferenceKeys::CODE_EDITOR_SHOW_INVISIBLE] = $formParams[PreferenceKeys::CODE_EDITOR_SHOW_INVISIBLE];
        $preferenceArr[PreferenceKeys::PAGINATOR_LIMIT] = (int)$formParams[PreferenceKeys::PAGINATOR_LIMIT];
        $content = $this->encodeContents($preferenceArr);
        $this->flushAll($userID);
        $insertArr = array(
            UserPreferences_DBTable::RECORD_ID   => '',
            UserPreferences_DBTable::USER_ID     => $userID,
            UserPreferences_DBTable::CONTENTS    => $content,
            UserPreferences_DBTable::CREATED_ON  => Utils::getCurrentDatetime(),
            UserPreferences_DBTable::MODIFIED_ON => Utils::getCurrentDatetime(),
            UserPreferences_DBTable::IS_DELETED  => '0'
        );
        $tableName = UserPreferences_DBTable::DB_TABLE_NAME;
        if (DBManager::insert($tableName, $insertArr, array())) {
            Session::set(Session::SESS_USER_PREF_KEY, $preferenceArr);
            return true;
        }
        return false;
    }
private function saveUserPreference ( array $ formParams ) { $ preferenceArr = array ( ) ; $ userID = Utils :: getLoggedInUserId ( ) ; $ preferenceArr [ PreferenceKeys :: CODE_EDITOR_THEME ] = $ formParams [ PreferenceKeys :: CODE_EDITOR_THEME ] ; $ preferenceArr [ PreferenceKeys :: CODE_EDITOR_SHOW_INVISIBLE ] = $ formParams [ PreferenceKeys :: CODE_EDITOR_SHOW_INVISIBLE ] ; $ preferenceArr [ PreferenceKeys :: PAGINATOR_LIMIT ] = ( int ) $ formParams [ PreferenceKeys :: PAGINATOR_LIMIT ] ; $ content = $ this -> encodeContents ( $ preferenceArr ) ; $ this -> flushAll ( $ userID ) ; $ insertArr = array ( UserPreferences_DBTable :: RECORD_ID => '' , UserPreferences_DBTable :: USER_ID => $ userID , UserPreferences_DBTable :: CONTENTS => $ content , UserPreferences_DBTable :: CREATED_ON => Utils :: getCurrentDatetime ( ) , UserPreferences_DBTable :: MODIFIED_ON => Utils :: getCurrentDatetime ( ) , UserPreferences_DBTable :: IS_DELETED => '0' ) ; $ tableName = UserPreferences_DBTable :: DB_TABLE_NAME ; if ( DBManager :: insert ( $ tableName , $ insertArr , array ( ) ) ) { Session :: set ( Session :: SESS_USER_PREF_KEY , $ preferenceArr ) ; return true ; } return false ; }
Save user preference in database
Save user preference in database