23 error_reporting(E_ALL);
24 if ((php_sapi_name() !=
'cli')) {
25 trigger_error(
"You can only run this script from the command line\n", E_USER_ERROR);
28 $SYSTEM_ROOT = (isset($_SERVER[
'argv'][1])) ? $_SERVER[
'argv'][1] :
'';
29 if (empty($SYSTEM_ROOT)) {
30 echo
"ERROR: You need to supply the path to the System Root as the first argument\n";
34 if (!is_dir($SYSTEM_ROOT) || !is_readable($SYSTEM_ROOT.
'/core/include/init.inc')) {
35 echo
"ERROR: Path provided doesn't point to a Matrix installation's System Root. Please provide correct path and try again.\n";
39 require_once $SYSTEM_ROOT.
'/core/include/init.inc';
41 $root_user = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'root_user');
44 if (!$GLOBALS[
'SQ_SYSTEM']->setCurrentUser($root_user)) {
45 echo
"ERROR: Failed logging in as root user\n";
49 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
50 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
52 $am = $GLOBALS[
'SQ_SYSTEM']->am;
54 $GLOBALS[
'SQ_SYSTEM']->setRunLevel(SQ_RUN_LEVEL_FORCED);
56 $ecommerce_formids = $GLOBALS[
'SQ_SYSTEM']->am->getTypeAssetids(
'form_ecommerce', FALSE);
58 $formids = $GLOBALS[
'SQ_SYSTEM']->am->getTypeAssetids(
'form', FALSE);
59 foreach ($formids as $formid) {
60 $form = $am->getAsset($formid);
62 if (in_array($formid, $ecommerce_formids))
continue;
64 pre_echo(
'Moving submissions for '.$form->name.
' ('.$form->id.
') to submissions folder');
65 $submissions_folder = $form->getSubmissionsFolder();
66 if (is_null($submissions_folder)) {
67 trigger_error(
'Submissions folder not found for form #'.$formid.
'; upgrade may be required', E_USER_ERROR);
69 $submission_links = $am->getLinks($formid, SQ_SC_LINK_ALL,
'form_submission', FALSE);
70 foreach ($submission_links as $link) {
71 $am->moveLink($link[
'linkid'], $submissions_folder->id, $link[
'link_type'], $link[
'sort_order']);
75 $GLOBALS[
'SQ_SYSTEM']->restoreRunLevel();
77 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');