Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Commonwell
/
broker-site
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
310afb59
authored
2024-02-13 11:33:59 -0500
by
Jeremy Groot
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
added broker id
1 parent
fdd55866
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
2 deletions
wp-content/themes/commonwell-broker/inc/brokers_cli.php
wp-content/themes/commonwell-broker/inc/brokers_cli.php
View file @
310afb5
...
...
@@ -7,6 +7,50 @@ if ( class_exists( 'WP_CLI' ) ) {
campaign_Monitor_LoadData
();
}
public
function
shift_brokers_from_to
(
$args
)
{
$from
=
$args
[
0
];
$to
=
$args
[
1
];
$broker_list
=
getBrokerageList
();
foreach
(
$broker_list
as
$broker
)
{
if
(
$broker
[
'broker_id'
]
==
$from
)
{
$from_brokerage
=
$broker
;
}
if
(
$broker
[
'broker_id'
]
==
$to
)
{
$to_brokerage
=
$broker
;
}
}
if
(
!
$from_brokerage
)
{
WP_CLI
::
log
(
'From Brokerage not found!'
);
return
;
}
if
(
!
$to_brokerage
)
{
WP_CLI
::
log
(
'To Brokerage not found!'
);
return
;
}
$all_brokers
=
get_users
();
foreach
(
$all_brokers
as
$broker
)
{
$old_broker_id
=
get_user_meta
(
$broker
->
ID
,
'broker_id'
,
true
);
if
(
$old_broker_id
==
$from_brokerage
[
'broker_id'
])
{
update_user_meta
(
$broker
->
ID
,
'broker_id'
,
$to_brokerage
[
'broker_id'
]);
}
}
}
function
import_brokers_from_csv
()
{
$data
=
[];
$row
=
0
;
...
...
@@ -300,6 +344,7 @@ if ( class_exists( 'WP_CLI' ) ) {
$new_brokers
=
[];
$row
=
0
;
$id
=
1
;
if
((
$handle
=
fopen
(
wp_get_upload_dir
()[
'basedir'
]
.
"/"
.
$args
[
0
],
"r"
))
!==
FALSE
)
{
while
((
$data
=
fgetcsv
(
$handle
,
1000
,
","
))
!==
FALSE
)
{
if
(
$row
==
0
)
{
...
...
@@ -308,8 +353,9 @@ if ( class_exists( 'WP_CLI' ) ) {
}
$new_id
=
$data
[
0
];
$name
=
$data
[
1
];
$new_brokers
[]
=
[
"broker_id"
=>
$new_id
,
"brokerage"
=>
$name
];
$new_brokers
[]
=
[
'id'
=>
$id
,
"broker_id"
=>
$new_id
,
"brokerage"
=>
$name
];
// echo $name;
++
$id
;
++
$row
;
}
fclose
(
$handle
);
...
...
@@ -319,7 +365,7 @@ if ( class_exists( 'WP_CLI' ) ) {
$old_saved_brokers
=
get_option
(
'old_broker_list'
);
if
(
!
$old_saved_brokers
)
{
update_option
(
'old_broker_list'
,
serialize
(
$old_brokers
));
update_option
(
'old_broker_list
_feb92024
'
,
serialize
(
$old_brokers
));
}
update_option
(
'broker_list'
,
serialize
(
$new_brokers
));
...
...
Please
register
or
sign in
to post a comment