function core_install_firstcoredata_defaults() { // Install the default institution db_begin(); set_config('session_timeout', 86400); set_config('sitename', 'Mahara'); set_config('defaultaccountinactivewarn', 604800); set_config('createpublicgroups', 'all'); set_config('allowpublicviews', 1); set_config('allowpublicprofiles', 1); // install the applications $app = new StdClass(); $app->name = 'mahara'; $app->displayname = 'Mahara'; $app->xmlrpcserverurl = '/api/xmlrpc/server.php'; $app->ssolandurl = '/auth/xmlrpc/land.php'; insert_record('application', $app); $app->name = 'moodle'; $app->displayname = 'Moodle'; $app->xmlrpcserverurl = '/mnet/xmlrpc/server.php'; $app->ssolandurl = '/auth/mnet/land.php'; insert_record('application', $app); // insert the event types $eventtypes = array('createuser', 'updateuser', 'suspenduser', 'unsuspenduser', 'deleteuser', 'undeleteuser', 'expireuser', 'unexpireuser', 'deactivateuser', 'activateuser', 'userjoinsgroup', 'saveartefact', 'deleteartefact', 'saveview', 'deleteview', 'blockinstancecommit'); foreach ($eventtypes as $et) { $e = new StdClass(); $e->name = $et; insert_record('event_type', $e); } // install the core event subscriptions $subs = array(array('event' => 'createuser', 'callfunction' => 'activity_set_defaults'), array('event' => 'createuser', 'callfunction' => 'add_user_to_autoadd_groups')); foreach ($subs as $sub) { insert_record('event_subscription', (object) $sub); } // install the activity types $activitytypes = array(array('maharamessage', 0, 0), array('usermessage', 0, 0), array('feedback', 0, 0), array('watchlist', 0, 1), array('viewaccess', 0, 1), array('contactus', 1, 1), array('objectionable', 1, 1), array('virusrepeat', 1, 1), array('virusrelease', 1, 1), array('institutionmessage', 0, 0)); foreach ($activitytypes as $at) { $a = new StdClass(); $a->name = $at[0]; $a->admin = $at[1]; $a->delay = $at[2]; insert_record('activity_type', $a); } // install the cronjobs... $cronjobs = array('rebuild_artefact_parent_cache_dirty' => array('*', '*', '*', '*', '*'), 'rebuild_artefact_parent_cache_complete' => array('0', '4', '*', '*', '*'), 'auth_clean_partial_registrations' => array('5', '0', '*', '*', '*'), 'auth_handle_account_expiries' => array('5', '10', '*', '*', '*'), 'auth_handle_institution_expiries' => array('5', '9', '*', '*', '*'), 'activity_process_queue' => array('*/5', '*', '*', '*', '*'), 'auth_remove_old_session_files' => array('30', '20', '*', '*', '*'), 'recalculate_quota' => array('15', '2', '*', '*', '*'), 'import_process_queue' => array('*/5', '*', '*', '*', '*'), 'cron_send_registration_data' => array(rand(0, 59), rand(0, 23), '*', '*', rand(0, 6)), 'export_cleanup_old_exports' => array('0', '3,13', '*', '*', '*')); foreach ($cronjobs as $callfunction => $times) { $cron = new StdClass(); $cron->callfunction = $callfunction; $cron->minute = $times[0]; $cron->hour = $times[1]; $cron->day = $times[2]; $cron->month = $times[3]; $cron->dayofweek = $times[4]; insert_record('cron', $cron); } // install the view column widths install_view_column_widths(); $viewtypes = array('portfolio', 'profile'); foreach ($viewtypes as $vt) { insert_record('view_type', (object) array('type' => $vt)); } db_commit(); }
function install_view_layout_defaults() { db_begin(); require_once 'view.php'; // Make sure all the column widths are present install_view_column_widths(); // Fetch all the existing layouts so we can check below whether each default already exists $oldlayouts = array(); $layoutrecs = get_records_assoc('view_layout', 'iscustom', '0', '', 'id, rows, iscustom'); if ($layoutrecs) { foreach ($layoutrecs as $rec) { $rows = get_records_sql_assoc('select vlrc.row, vlc.widths from {view_layout_rows_columns} vlrc inner join {view_layout_columns} vlc on vlrc.columns = vlc.id where vlrc.viewlayout = ? order by vlrc.row', array($rec->id)); if (!$rows) { // This layout has no rows. Strange, but let's just ignore it for now. log_warn('view_layout ' . $rec->id . ' is missing its row or column width records.'); continue; } $allwidths = ''; foreach ($rows as $rowrec) { $allwidths .= $rowrec->widths . '-'; } // Drop the last comma $allwidths = substr($allwidths, 0, -1); $oldlayouts[$rec->id] = $allwidths; } } foreach (View::$defaultlayoutoptions as $id => $rowscols) { // Check to see whether it matches an existing record $allwidths = ''; $numrows = 0; foreach ($rowscols as $row => $col) { if ($row != 'order') { $allwidths .= $col . '-'; $numrows++; } } $allwidths = substr($allwidths, 0, -1); $found = array_search($allwidths, $oldlayouts); if ($found !== false) { // There's a perfect match in the DB already. Just make sure it has the right menu order if (isset($rowscols['order'])) { update_record('view_layout', (object) array('id' => $found, 'layoutmenuorder' => $rowscols['order'])); } continue; } // It doesn't exist yet! So, set it up. $vlid = insert_record('view_layout', (object) array('iscustom' => 0, 'rows' => $numrows, 'layoutmenuorder' => isset($rowscols['order']) ? $rowscols['order'] : 0), 'id', true); insert_record('usr_custom_layout', (object) array('usr' => 0, 'group' => null, 'layout' => $vlid)); foreach ($rowscols as $row => $col) { // The 'order' field indicates menu order if this layout is meant to be present // in the default layout menu if ($row == 'order') { continue; } // Check for the ID of the column widths that match this row $colsid = get_field('view_layout_columns', 'id', 'widths', $col); if (!$colsid) { // For some reason this layout_columns wasn't present yet. // We'll just insert it, but also throw a warning $colsid = insert_record('view_layout_columns', (object) array('columns' => substr_count($col, ','), 'widths' => $col), 'id', true); log_warn('Default layout option ' . $id . ' uses a column set that is not present in the list of default column widths.'); } insert_record('view_layout_rows_columns', (object) array('viewlayout' => $vlid, 'row' => $row, 'columns' => $colsid)); } } db_commit(); }