public static function update_view_access($config, $viewids) { db_begin(); // Use set_access() on the first view to get a hopefully consistent // and complete representation of the access list $firstview = new View($viewids[0]); $fullaccesslist = $firstview->set_access($config['accesslist'], $viewids, $config['allowcomments']); // Copy the first view's access records to all the other views $firstview->copy_access($viewids); // Sort the full access list in the same order as the list // returned by get_access, so that views with the same set of // access records get grouped together usort($fullaccesslist, array('self', 'cmp_accesslist')); // Hash the config object so later on we can easily find // all the views with the same config/access rights $config['accesslist'] = $fullaccesslist; $accessconf = substr(md5(serialize($config)), 0, 10); foreach ($viewids as $viewid) { $v = new View((int) $viewid); $v->set('startdate', $config['startdate']); $v->set('stopdate', $config['stopdate']); $v->set('template', $config['template']); $v->set('retainview', $config['retainview']); $v->set('allowcomments', $config['allowcomments']); $v->set('approvecomments', $config['approvecomments']); if (isset($config['copynewuser'])) { $v->set('copynewuser', $config['copynewuser']); } if (isset($config['copynewgroups'])) { $v->set('copynewgroups', $config['copynewgroups']); } $v->set('accessconf', $accessconf); $v->commit(); } db_commit(); }