How to recover superuser after using recovery script? - dokuwiki

Background
I had to apply the recovery script (https://github.com/splitbrain/dokuwiki-recover, 93fce60, 31. Aug. 2020) because the wiki did not work after installation of plugin "code3".?
I followed the instructions that appeared when executing the script, in which one step were saying:
Change the superuser configuration back to contain your usual admin account
Question
How to perform the mentioned step ("Change the superuser configuration back to contain your usual admin account")?

In order to perform the mentioned step ("Change the superuser configuration back to contain your usual admin account"), the file local.php in folder "/config" has to be changed to
<?php
/**
* Dokuwiki's Main Configuration File - Local Settings
* Auto-generated by install script
* Date: ...
*/
$conf['title'] = '<YourDokuWikiName>';
$conf['lang'] = '<YourLanguage>';
$conf['license'] = '<YourDokuWikiLicense>';
$conf['useacl'] = 1;
$conf['superuser'] = '#admin';
$conf['disableactions'] = 'register';
...by removing the lines that have been added by the recover script
// The following lines were added be dokuwiki-recover
// 2021-...
$conf['useacl'] = 1;
$conf['authtype'] = 'authplain';
$conf['superuser'] = '#dokuwiki-recover';
$conf['userewrite'] = 0;
$conf['lang'] = 'en';
$conf['template'] = 'dokuwiki';
The obvious reason is that the last php assignment wins, and hence...
$conf['superuser'] = '#dokuwiki-recover';
...made all users of group dokuwiki-recover to adminintrators.

Related

OpenStack Swift proxy-server.conf already had [filter:authtoken] section

I'm trying to use swift with keystone authentication. I followed this link https://docs.openstack.org/swift/latest/overview_auth.html#keystone-auth to edit my proxy-server.conf but I noticed that at the bottom of the file [filter:authtoken] is already there, while in the comments section I can uncomment a section with the same name of [filter:authtoken], right now the bottom part looks like this:
[filter:authtoken]
include_service_catalog = False
cache = swift.cache
delay_auth_decision = 1
memcached_servers = localhost:11211
cafile = /opt/stack/data/ca-bundle.pem
project_domain_name = Default
project_name = service
user_domain_name = Default
password = 1234
username = swift
auth_url = http://10.180.204.223/identity
interface = public
auth_type = password
What should I do with it? Should I keep it, modify it according to the link, or should I uncomment the section and add the code according to the link?

How to write a value to the workflow container

Below is my workflow inbox content
STEP 1: ln HTML table, the user can approve or reject WBS by checked radio
STEP 2: When user click confirm, then the workflow will update status for each WBS that shown in the table.
Purpose:
I need to get the user's action from step 1.
For now I've enhanced SAPEVENT and make it called my Function Module.
In my function function module I can use 'SAP_WAPI_READ_CONTAINER' properly but I cannot use 'SAP_WAPI_WRITE_CONTAINER' to write the value to workflow.
There was error msg 900 occurs.
Please see my code below:
DATA: LT_CONTAINER TYPE STANDARD TABLE OF SWR_CONT,
LT_MSG_LINES TYPE SAPI_MSG_LINES,
LT_MSG_STRUC TYPE SAPI_MSG_STRUC.
DATA: LV_RETCODE TYPE SY-SUBRC.
*** Get workflow container by using 'SAP_WAPI_READ_CONTAINER' ***
CALL FUNCTION 'SAP_WAPI_READ_CONTAINER'
EXPORTING
WORKITEM_ID = IV_WORKITEMID
IMPORTING
RETURN_CODE = LV_RETCODE
TABLES
SIMPLE_CONTAINER = LT_CONTAINER
MESSAGE_LINES = LT_MSG_LINES
MESSAGE_STRUCT = LT_MSG_STRUC.
*** then I change data inside LT_CONTAINER as my requirement below ***
REPLACE |type="submit" id="ALLAPPV"| IN TABLE LT_CONTAINER[]
WITH |type="button" id="ALLAPPV" hidden|.
*** use SAP_WAPI_WRITE_CONTAINER in order to write value to workflow container but it return error msg 900 ***
CALL FUNCTION 'SAP_WAPI_WRITE_CONTAINER'
EXPORTING
WORKITEM_ID = IV_WORKITEMID
DO_COMMIT = 'X'
OVERWRITE_TABLES_SIMPLE_CONT = 'X'
IMPORTING
RETURN_CODE = LV_RETCODE
TABLES
SIMPLE_CONTAINER = LT_CONTAINER
MESSAGE_LINES = LT_MSG_LINES
MESSAGE_STRUCT = LT_MSG_STRUC.

Why does Jooq code-generation break with PostGIS?

Context - I am trying out Postgres' Geographic Information System extension PostGis that enables stories latitude and longitudes as Point and operations on it.
If I understand correctly then I need to add a custom converter that can convert the point between JOOQ and PostGis and add it to the gradle file.
Problem - When I generate the jooq-code, few files are generated incorrectly and have the fields defined twice which fail compilation. These are:
<configured-generation-dir>/tables/StValuecount.java
<configured-generation-dir>/tables/records/StValuecountRecord.java
<configured-generation-dir>/tables/records/StValuepercentRecord.java
<configured-generation-dir>/tables/_StValuecount.java
<configured-generation-dir>/tables/records/_StValuecountRecord.java
<configured-generation-dir>/tables/_StHistogram.java
<configured-generation-dir>/tables/records/_StHistogramRecord.java
<configured-generation-dir>/tables/_StQuantile.java
Gradle config =>
jooq{
myAwesomeApp(sourceSets.main){
logging = 'WARN'
jdbc {
driver = 'org.postgresql.Driver'
url = db_url
user = db_user
password = db_password
}
generator {
name = 'org.jooq.codegen.DefaultGenerator'
strategy {
name = 'org.jooq.codegen.DefaultGeneratorStrategy'
}
database {
name = 'org.jooq.meta.postgres.PostgresDatabase'
inputSchema = 'public'
forcedTypes {
forcedType {
userType = 'org.postgis.Point'
converter = 'com.example.JooqBreaksWithPostGis.jooq.converters.PostgresPointJooqConverter'
expression = '.*\\.point'
types = '.*'
}
}
}
generate {
routines = false
relations = true
deprecated = false
records = true
immutablePojos = false
fluentSetters = true
}
target {
packageName = 'jooq.fancy.app'
directory = 'src/main/java/generated'
}
}
}
}
What am I doing wrong?
I have also created a minimal project where I have reproduced the problem in case someone wants to quickly try it.
Steps to reproduce
Checkout project
git clone git#github.com:raj-saxena/JooqBreaksWithPostGis.git
Go to the project directory and start postgis docker container with
docker-compose up
Similarly, to remove postgis docker container run
docker-compose down
Run migrations that add a simple City table containing Point type with
./gradlew flywayMigrate
I have added few rows in a second migration to verify if the DB structure was working. Details to connect to Postgres instance in the build.gradle file.
Generate jooq files with
./gradlew generateMyAwesomeAppJooqSchemaSource
Verify that the files are generated in the configured src/main/java/generated directory.
Verify that the files mentioned above fail to compile.
Taking Lukas' advice, I added the exclude configuration to the jooq config as below:
database {
name = 'org.jooq.meta.postgres.PostgresDatabase'
...
excludes = '.*ST_ValueCount' +
'|.*St_Valuepercent' +
'|.*St_Histogram' +
'|.*St_Quantile' +
'|.*St_Approxhistogram' +
'|.*St_PixelOfValue' +
'|.*St_Approxquantile' +
'|.*ST_Tile'
}
This allowed the code to compile.
This sounds a lot like https://github.com/jOOQ/jOOQ/issues/4055. jOOQ 3.11 currently cannot handle overloaded table valued functions in any RDBMS that supports table valued functions. Your best option here is to exclude all the affected functions from the code generation, using <excludes>:
https://www.jooq.org/doc/latest/manual/code-generation/codegen-advanced/codegen-config-database/codegen-database-includes-excludes/

IPython script runs on Spotfire Client, not Spotfire Web

I have the following python script (reduced, but the rest of it performs similar actions):
from Spotfire.Dxp.Application.Visuals import *
from Spotfire.Dxp.Data import *
#assign default values for prompts if needed
if Document.Properties['cannedKPISelected'].isspace():
Document.Properties['cannedKPISelected'] = 'GS'
if Document.Properties['cannedTimeSelected'].isspace():
Document.Properties['cannedTimeSelected'] = 'Month'
#determine which type of viz needs displayed based on a flag in the data
tableName='PrimaryDataTable'
columnToFetch='displayPercentageFlag'
activeTable=Document.Data.Tables[tableName]
rowCount = activeTable.RowCount
rowsToInclude = IndexSet(rowCount,True)
cursor1 = DataValueCursor.CreateFormatted(activeTable.Columns[columnToFetch])
for row in activeTable.GetRows(rowsToInclude,cursor1):
rowIndex = row.Index
percentageNeeded = cursor1.CurrentValue
break
#create consumer report
for page in Document.Pages:
for viz in page.Visuals:
if str(viz.Id) == 'a7f5b4ec-f545-4d5f-a967-adec4c9fec79':
if Document.Properties['coffeeReportSelected'] == 'Brand Category by Market':
if Document.Properties['cannedKPISelected'] == 'GS' and Document.Properties['cannedTimeSelected'] == 'Month' and percentageNeeded == 'Y':
visualContentObject = viz.As[VisualContent]()
visualContentObject.MeasureAxis.Expression = 'Sum([GS Month]) as [GS Mnth]'
visualContentObject.RowAxis.Expression = '<[BRAND] as [Brand Category] NEST [MARKET] as [Market]>'
visualContentObject.ColumnAxis.Expression = '<[Axis.Default.Names] as [Measure Names]>'
visualContentObject.ShowColumnGrandTotal = True
visualContentObject.ShowColumnSubtotals = True
visualContentObject.ShowRowGrandTotal = False
visualContentObject.Title = 'Monthly GS by Brand, Market'
visualContentObject.Data.WhereClauseExpression = '[NAME] = "CANADA"'
visualContentObject.CellWidth = 125
Document.Properties['cannedReportHideRows'] = 'Sum(Abs(SN([GS Month],0)))'
elif Document.Properties['cannedKPISelected'] == 'GS' and Document.Properties['cannedTimeSelected'] == 'Quarter' and percentageNeeded == 'Y':
visualContentObject = viz.As[VisualContent]()
visualContentObject.MeasureAxis.Expression = 'Sum([GS Quarter]) as [GS Qtr]'
visualContentObject.RowAxis.Expression = '<[BRAND] as [Brand] NEST [MARKET] as [Market]>'
visualContentObject.ColumnAxis.Expression = '<[Axis.Default.Names] as [Measure Names]>'
visualContentObject.ShowColumnGrandTotal = True
visualContentObject.ShowColumnSubtotals = True
visualContentObject.ShowRowGrandTotal = False
visualContentObject.Title = 'Quarterly GS by Brand, Market'
visualContentObject.Data.WhereClauseExpression = '[NAME] = "CANADA"'
visualContentObject.CellWidth = 125
Document.Properties['cannedReportHideRows'] = 'Sum(Abs(SN([GS Quarter],0)))'
So on and so forth.
This script (and others) run perfectly fine in the client. It does not run in the web. The web will say processing, then say ready (in the bottom left corner), all while doing nothing (no error, nothing). A few other scripts that I have in the same analysis run perfectly fine.
I know there are some limitations on IPython scripts on the web for security reasons, but I am only building a table. This cant be restricted can it? Web server logs are not capturing anything out of the ordinary.
We are on Spotfire 7.6
UPDATE: It seems to be due to this: if str(viz.Id) == 'a7f5b4ec-f545-4d5f-a967-adec4c9fec79':. This is because IDs are different between Web and Client unfortunately. Knowing my title changes as well, any ideas on what I could reference a visualization by that stays the same between client and web?
Because Spotfire changes IDs of a vis depending on whether it is on the web player vs the client, the script was not working as intended. I simply added the vis as a parameter instead of relying on the script to go and locate the correct vis. When the name of the vis changes, the parameter is updated correctly so it is still dynamic.
Could you just figure out what the index is on the current visual and refer to it that way?
Try something like:
Replace this line:
if str(viz.Id) == 'a7f5b4ec-f545-4d5f-a967-adec4c9fec79':
With:
if viz[0] (or whatever the index is)
Not sure if this is what you had in mind, but I believe this will give you a way to refer to the visualization without having to use an ID.

Moodle: Automating user/course creation and enrolments

I had a look at the documentation on enrolments, but all the enrolment methods seem to involve some interaction with the GUI.
Is there a way to script enrolments? Something like:
./moodle_do_enrolments imsdata.xml
Or even some web services calls that I can call from an external program?
I'd like to be able to do the following in an automated fashion:
1) Add a user.
2) Create a course with specified title etc.
3) Enrol that user in that course.
Of course at some point I'd hook this up with our user systems and other management systems, but for the moment, I'm just trying to do a proof of concept.
Where is some documentation that explains the process of automated enrolments?
You could try to create your own PHP script: parse the XML file and use internal moodle functions to solve the problem.
Basic ideas to solve these problems
1) Add a user:
In user/lib.php is a method: user_create_user($user).
Just include that lib.php and find out which information is needed in the user object.
2) Create a course
In course/lib.php is a method: create_course($data, $editoroptions).
Just include that lib.php and find out which information is needed in data array.
3) Enrol a user
I created the following method to do the job for me.
// enroll student to course (roleid = 5 is student role)
function enroll_to_course($courseid, $userid, $roleid=5, $extendbase=3, $extendperiod=0) {
global $DB;
$instance = $DB->get_record('enrol', array('courseid'=>$courseid, 'enrol'=>'manual'), '*', MUST_EXIST);
$course = $DB->get_record('course', array('id'=>$instance->courseid), '*', MUST_EXIST);
$today = time();
$today = make_timestamp(date('Y', $today), date('m', $today), date('d', $today), 0, 0, 0);
if(!$enrol_manual = enrol_get_plugin('manual')) { throw new coding_exception('Can not instantiate enrol_manual'); }
switch($extendbase) {
case 2:
$timestart = $course->startdate;
break;
case 3:
default:
$timestart = $today;
break;
}
if ($extendperiod <= 0) { $timeend = 0; } // extendperiod are seconds
else { $timeend = $timestart + $extendperiod; }
$enrolled = $enrol_manual->enrol_user($instance, $userid, $roleid, $timestart, $timeend);
add_to_log($course->id, 'course', 'enrol', '../enrol/users.php?id='.$course->id, $course->id);
return $enrolled;
}
Using a GUI is not necessary, you can create an enrolment/authentication plugin to achieve this or use one of the built in ones. I'm not too familiar with the ims enrollment plugin, but the standard ldap/database plugins have scripts which can be used to automate this sync process.
See for example:
enrol/database/cli/sync.php