? blog_improvement-7-1-08-patch.txt ? config.php Index: admin/settings/security.php =================================================================== RCS file: /cvsroot/moodle/moodle/admin/settings/security.php,v retrieving revision 1.26 diff -u -a -w -b -B -r1.26 security.php --- admin/settings/security.php 31 May 2008 09:54:12 -0000 1.26 +++ admin/settings/security.php 2 Jul 2008 03:43:47 -0000 @@ -39,6 +39,7 @@ 1 => get_string('personalblogs','blog'), 0 => get_string('disableblogs','blog')))); $temp->add(new admin_setting_configcheckbox('usetags', get_string('usetags','admin'),get_string('configusetags', 'admin'),'1')); + $temp->add(new admin_setting_configcheckbox('useassoc', get_string('useassoc','admin'),get_string('configuseassoc', 'admin'),'1')); $temp->add(new admin_setting_configcheckbox('keeptagnamecase', get_string('keeptagnamecase','admin'),get_string('configkeeptagnamecase', 'admin'),'1')); $temp->add(new admin_setting_configcheckbox('cronclionly', get_string('cronclionly', 'admin'), get_string('configcronclionly', 'admin'), 0)); $temp->add(new admin_setting_configpasswordunmask('cronremotepassword', get_string('cronremotepassword', 'admin'), get_string('configcronremotepassword', 'admin'), '')); Index: blog/edit.php =================================================================== RCS file: /cvsroot/moodle/moodle/blog/edit.php,v retrieving revision 1.66 diff -u -a -w -b -B -r1.66 edit.php --- blog/edit.php 19 Jun 2008 09:21:45 -0000 1.66 +++ blog/edit.php 2 Jul 2008 03:43:47 -0000 @@ -122,6 +122,20 @@ if ($itemotags = tag_get_tags_array('post', $post->id, 'official')) { $post->otags = array_keys($itemotags); } + //add associations + if ($blog_associations = $DB->get_records('blog_association', array('blogid' => $existing->id))) { + foreach($blog_associations as $assoc_rec) { + $context_rec = $DB->get_record('context', array('id' => $assoc_rec->contextid)); + switch($context_rec->contextlevel) { + case CONTEXT_COURSE: + $post->courseassoc = $assoc_rec->contextid; + break; + case CONTEXT_MODULE: + $post->modassoc[] = $assoc_rec->contextid; + break; + } + } + } break; default : print_error('unknowaction'); @@ -138,8 +152,14 @@ $navigation = build_navigation($navlinks); print_header("$SITE->shortname: $strblogs", $SITE->fullname, $navigation,'','',true); + +if($courseid) { //pre-select the course for associations + $context = get_context_instance(CONTEXT_COURSE, $courseid); + $post->courseassoc = $context->id; +} $blogeditform->set_data($post); $blogeditform->display(); +$blogeditform->display_extra_javascript($post); print_footer(); @@ -160,6 +180,8 @@ blog_delete_old_attachments($post); + remove_associations($post->id); + add_to_log(SITEID, 'blog', 'delete', 'index.php?userid='. $post->userid, 'deleted blog entry with entry id# '. $post->id); if (!$status) { @@ -187,6 +209,9 @@ $DB->set_field("post", "attachment", $newfilename, array("id"=>$post->id)); } add_tags_info($post->id); + + if($CFG->useassoc) add_associations($post); + add_to_log(SITEID, 'blog', 'add', 'index.php?userid='.$post->userid.'&postid='.$post->id, $post->subject); } else { @@ -201,6 +226,7 @@ * @todo complete documenting this function. enable trackback and pingback between entries on the same server */ function do_edit($post, $blogeditform) { + global $CFG, $USER, $returnurl, $DB; $post->lastmodified = time(); @@ -220,6 +246,8 @@ // add them back add_tags_info($post->id); + if($CFG->useassoc) add_associations($post); + add_to_log(SITEID, 'blog', 'update', 'index.php?userid='.$USER->id.'&postid='.$post->id, $post->subject); } else { @@ -229,7 +257,7 @@ /** * function to attach tags into a post - * @param int postid - id of the blog + * @param int postid - id of the blog post */ function add_tags_info($postid) { @@ -248,4 +276,96 @@ tag_set('post', $postid, $tags); } + +/** + * remove all associations for a blog post + * @param int blogid - id of the blog post + */ +function remove_associations($blogid) { + global $DB; + $DB->delete_records('blog_association', array('blogid' => $blogid)); +} + +/** + * add a single association for a blog entry + * @param int blogid - id of blog post + */ +function add_association($blogid, $contextid, $allow_add_course = true) { + global $DB; + + //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + //!! I need to move this validation stuff to the 'validate' method in edit_form.php + //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + + //validate context id + if(!$DB->record_exists('context', array('id' => $contextid))) { + print_error('There was an error updating this post in the database', '', $returnurl); + } + $context_rec = $DB->get_record('context', array('id' => $contextid)); + + //check context level and find the record for the relevant course + switch($context_rec->contextlevel) { + case CONTEXT_COURSE: + $course_context = $context_rec; + break; + case CONTEXT_MODULE: + $path = split('/', $context_rec->path); + $course_context = $DB->get_record('context', array('id' => $path[3])); + break; + default: + print_error('There was an error updating this post in the database', '', $returnurl); + break; + } + + //check capability for course + if (has_capability('moodle/course:view', $course_context)) { + if (!empty($USER->realuser)) { // Make sure the REAL person can also access this course + if (!has_capability('moodle/course:view', $course_context, $USER->realuser)) { + remove_associations($blogid); + print_header_simple(); + notice(get_string('studentnotallowed', '', fullname($USER, true)), $CFG->wwwroot .'/'); + } + } + } else { + remove_associations($blogid); + print_header_simple(); + notice(get_string('studentnotallowed', '', fullname($USER, true)), $CFG->wwwroot .'/'); + } + + //if it's a mod, check to see if its course is already associated + if($context_rec->contextlevel == CONTEXT_MODULE) { + if(!$DB->record_exists('blog_association', array('contextid' => $course_context->id, + 'blogid' => $blogid))) { + if($allow_add_course) { + add_association($blogid, $course_context->id); + } else { + return; //don't add the mod if we can't add the course + } + } + } + + //add association + $assoc_object = new StdClass; + $assoc_object->contextid = $contextid; + $assoc_object->blogid = $blogid; + $DB->insert_record('blog_association', $assoc_object); + +} + +function add_associations($post) { + $allow_add_course_assoc = true; + remove_associations($post->id); + if(isset($post->courseassoc)) { + if($post->courseassoc > 0) { + add_association($post->id, $post->courseassoc); + $allow_add_course_assoc = false; + } + } + if(isset($post->modassoc)) { + foreach($post->modassoc as $modid) { + add_association($post->id, $modid, $allow_add_course_assoc); + $allow_add_course_assoc = false; //let the course be added the first time + } + } +} ?> Index: blog/edit_form.php =================================================================== RCS file: /cvsroot/moodle/moodle/blog/edit_form.php,v retrieving revision 1.15 diff -u -a -w -b -B -r1.15 edit_form.php --- blog/edit_form.php 19 Jun 2008 09:21:45 -0000 1.15 +++ blog/edit_form.php 2 Jul 2008 03:43:47 -0000 @@ -5,7 +5,7 @@ class blog_edit_form extends moodleform { function definition() { - global $CFG, $COURSE, $USER; + global $CFG, $COURSE, $USER, $DB; $mform =& $this->_form; @@ -45,6 +45,31 @@ $mform->setType('ptagsadd', PARAM_NOTAGS); } + if (!empty($CFG->useassoc)) { + $mform->addElement('header', 'assochdr', get_string('associations', 'blog')); + $courses = get_my_courses($USER->id, 'visible DESC, fullname ASC'); + $course_names[0] = 'none'; + foreach($courses as $course) { + $course_names[$course->context->id] = $course->fullname; + $modinfo = get_fast_modinfo($course, $USER->id); + $course_context_path = $DB->get_field('context', 'path', array('id' => $course->context->id)); + + foreach($modinfo->instances as $modname => $instances) { + foreach($instances as $modid => $mod) { + $mod_context_id = $DB->get_field_select('context', 'id', + 'instanceid = '.$mod->id.' AND ' . + 'contextlevel = ' . CONTEXT_MODULE . ' AND ' . + 'path LIKE \''.$course_context_path.'/%\''); + $this->mod_names[$course->context->id][$mod_context_id] = $modname . ": ".$mod->name; + $all_mod_names[$mod_context_id] = $course->shortname . " - " . $modname . ": ".$mod->name; + } + } + } + $mform->addElement('select', 'courseassoc', get_string('course'), $course_names, 'onchange="addCourseAssociations()"'); + $selectassoc = &$mform->addElement('select', 'modassoc', get_string('managemodules'), $all_mod_names); + $selectassoc->setMultiple(true); + } + $this->add_action_buttons(); $mform->addElement('hidden', 'action'); @@ -58,6 +83,110 @@ $mform->setType('id', PARAM_INT); $mform->setDefault('id', 0); + + } + + + + + function validation($data) { + global $CFG; + if(!$data['courseassoc'] && ($data['publishstate'] == 'course' || + $data['publishstate'] == 'group') + && $CFG->useassoc) + return array('publishstate' => get_string('mustassociatecourse', 'blog')); + return true; + } + + //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + //I'm sure this is not how they want me to do the javascript. + //get rid of this function and add the javascript correctly, however they seem to be doing it + //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + function display_extra_javascript($post) { +?> + +get_record('course_modules', array('id' => $filterselect)); + $cm->modname = $DB->get_field('modules', 'name', array('id' => $cm->module)); + $cm->name = $DB->get_field($cm->modname, 'name', array('id' => $cm->instance)); + $COURSE = $DB->get_record('course', array('id' => $cm->course)); + $navlinks[] = array('name' => $blogstring, 'link' => null, 'type' => 'misc'); + if ($tagid || !empty($tag)) { + $navlinks[] = array('name' => "$tagstring: $taginstance->name", 'link' => null, 'type' => 'misc'); + } + $navigation = build_navigation($navlinks, $cm); + print_header("$course->shortname: $blogstring", $course->fullname, $navigation,'','',true,$PAGE->get_extra_header_string()); + + break; + case 'course': if ($tagid || !empty($tag)) { $navlinks[] = array('name' => $blogstring, Index: blog/index.php =================================================================== RCS file: /cvsroot/moodle/moodle/blog/index.php,v retrieving revision 1.42 diff -u -a -w -b -B -r1.42 index.php --- blog/index.php 1 Jun 2008 13:48:13 -0000 1.42 +++ blog/index.php 2 Jul 2008 03:43:47 -0000 @@ -61,6 +61,22 @@ switch ($filtertype) { + case 'mod': + if ($CFG->bloglevel < BLOG_COURSE_LEVEL) { + print_error('Course blogs is not enabled'); + } + if (!$mod = $DB->get_record('course_modules', array('id' => $filterselect))) { + print_error('Incorrect module isntance id specified'); + } + $courseid = $mod->course; + $coursecontext = get_context_instance(CONTEXT_COURSE, $courseid); + $course = $DB->get_record('course', array('id'=>$filterselect)); + require_login($course); + if (!has_capability('moodle/blog:view', $coursecontext)) { + print_error('You do not have the required permissions to view blogs in this course'); + } + break; + case 'site': if ($CFG->bloglevel < BLOG_SITE_LEVEL) { print_error('siteblogdisable', 'blog'); Index: blog/lib.php =================================================================== RCS file: /cvsroot/moodle/moodle/blog/lib.php,v retrieving revision 1.97 diff -u -a -w -b -B -r1.97 lib.php --- blog/lib.php 30 Jun 2008 01:51:45 -0000 1.97 +++ blog/lib.php 2 Jul 2008 03:43:47 -0000 @@ -166,9 +166,20 @@ $user = $DB->get_record('user', array('id'=>$template['userid'])); + //check to see if the post is unassociated with group/course level access + $unassociatedpost = false; + if($CFG->useassoc && ($blogEntry->publishstate == 'group' || + $blogEntry->publishstate == 'course')) { + if(!$DB->record_exists('blog_association', array('blogid' => $blogEntry->id))) { + $unassociatedpost = true; + } + } + /// Start printing of the blog - echo ''; + + echo '
'; echo '
'; print_user_picture($user, SITEID, $user->picture); @@ -201,6 +212,14 @@ case 'draft': $blogtype = get_string('publishtonoone', 'blog'); break; + case 'course': + $blogtype = $CFG->useassoc ? get_string('publishtocourseassoc', 'blog') + : get_string('publishtocourse', 'blog'); + break; + case 'group': + $blogtype = $CFG->useassoc ? get_string('publishtogroupassoc', 'blog') + : get_string('publishtogroup', 'blog'); + break; case 'site': $blogtype = get_string('publishtosite', 'blog'); break; @@ -230,6 +249,40 @@ echo ''; } + //add associations + if ( !empty($CFG->useassoc) && $blog_associations = $DB->get_records('blog_association', array('blogid' => $blogEntry->id))) { + echo '
'; + $assoc_str = ''; + foreach($blog_associations as $assoc_rec) { //first find and show the associated course + $context_rec = $DB->get_record('context', array('id' => $assoc_rec->contextid)); + if($context_rec->contextlevel == CONTEXT_COURSE) { + $assoc_str .= ''; + $assoc_str .= ''; + $assoc_str .= $DB->get_field('course', 'shortname', array('id' => $context_rec->instanceid)); + $assoc_str .= ''; + } + } + foreach($blog_associations as $assoc_rec) { //now show each mod association + $context_rec = $DB->get_record('context', array('id' => $assoc_rec->contextid)); + if($context_rec->contextlevel == CONTEXT_MODULE) { + $mod_info = $DB->get_record('course_modules', array('id' => $context_rec->instanceid)); + $mod_name = $DB->get_field('modules', 'name', array('id' => $mod_info->module)); + $assoc_str .= ', '; + $assoc_str .= ''; + $assoc_str .= ''; + $assoc_str .= $DB->get_field($mod_name, 'name', array('id' => $mod_info->instance)); + $assoc_str .= ''; + } + } + echo get_string('associations', 'blog') . ': '. $assoc_str; + + echo '
'; + } + + if($unassociatedpost) { + echo '
'.get_string('associationunviewable', 'blog').'
'; + } + /// Commands echo '
'; @@ -348,7 +401,17 @@ $options = array ( 'draft' => get_string('publishtonoone', 'blog') ); } - if ($CFG->bloglevel > BLOG_USER_LEVEL) { + if ($CFG->bloglevel >= BLOG_GROUP_LEVEL) { + $options['group'] = $CFG->useassoc ? get_string('publishtogroupassoc', 'blog') + : get_string('publishtogroup', 'blog'); + } + + if ($CFG->bloglevel >= BLOG_COURSE_LEVEL) { + $options['course'] = $CFG->useassoc ? get_string('publishtocourseassoc', 'blog') + : get_string('publishtocourse', 'blog'); + } + + if ($CFG->bloglevel >= BLOG_SITE_LEVEL) { $options['site'] = get_string('publishtosite', 'blog'); } @@ -515,95 +578,117 @@ } } - $params = array(); + // The query used to locate blog entries is complicated. It will be built from the following components: + $requiredfields = "p.*, u.firstname,u.lastname,u.email"; // the SELECT clause + $tables = array('p' => 'post', 'u' => 'user'); // components of the FROM clause (table_id => table_name) + $conditions = array('u.deleted = 0', 'p.userid = u.id'); // components of the WHERE clause (conjunction) + $params = array(); // parameters for the WHERE clause if ($tag) { - $tagtablesql = ", {tag_instance} ti"; - $tagquerysql = "AND ti.itemid = p.id AND ti.tagid = :tag AND ti.itemtype = 'post'"; + $tables['ti'] = 'tag_instance'; $params['tag'] = $tag; - } else { - $tagtablesql = ''; - $tagquerysql = ''; + $conditions[] = 'ti.itemid = p.id'; + $conditions[] = 'ti.tagid = :tag'; + $conditions[] = 'ti.itemtype = \'post\''; } - if (isloggedin() && !has_capability('moodle/legacy:guest', get_context_instance(CONTEXT_SYSTEM), $USER->id, false)) { - $permissionsql = "AND (p.publishstate = 'site' OR p.publishstate = 'public' OR p.userid = :userid)"; - $params['userid'] = $USER->id; + + // build up a clause for permission constraints + if (isloggedin() && !has_capability('moodle/legacy:guest', get_context_instance(CONTEXT_SYSTEM, SITEID), $USER->id, false)) { + $tables['ra'] = 'role_assignments'; + $usergroups = ''; + $usercourses = ''; + foreach($DB->get_records('groups_members', array('userid' => $USER->id)) as $rec) { + $usergroups .= ($usergroups ? ', ' : '') . $rec->groupid; + } + foreach(get_my_courses($USER->id) as $course) { + $usercourses .= ($usercourses ? ', ' : '') . $course->context->id; + } + + $permissionsql = '(p.publishstate = \'site\' OR p.publishstate = \'public\' OR p.userid = '.$USER->id.' '; + if($CFG->useassoc) { // insure viewer has access to the associated course (if course or group level access is used) + if($usercourses) { + $tables['ba'] = 'blog_association'; + $permissionsql .=' OR (p.publishstate = \'course\' AND p.id = ba.blogid AND ba.contextid IN ('.$usercourses.'))'; + } + if($usergroups) { + $tables['gma'] = 'groups_members'; + $tables['gmb'] = 'groups_members'; + $tables['ba'] = 'blog_association'; + $permissionsql .=' OR (p.publishstate = \'group\' AND p.id = ba.blogid AND ba.contextid IN ('.$usercourses.') + AND gma.groupid = gmb.groupid AND gma.userid = '.$USER->id.' AND gmb.userid = p.userid) '; + } + } else { // insure viewer shares *any* course/group with the poster + if($usergroups) { + $tables['gm'] = 'groups_members'; + $permissionsql .= ' OR (p.publishstate = \'group\' AND gm.groupid = p.userid AND gm.groupid IN ('.$usergroups.'))'; + } + if($usercourses) $permissionsql .=' OR (p.publishstate = \'course\' AND p.userid = ra.userid AND ra.contextid IN ('.$usercourses.'))'; + } + $permissionsql .= ') '; } else { - $permissionsql = "AND p.publishstate = 'public'"; + $permissionsql = "p.publishstate = 'public'"; } // fix for MDL-9165, use with readuserblogs capability in a user context can read that user's private blogs // admins can see all blogs regardless of publish states, as described on the help page if (has_capability('moodle/user:readuserblogs', get_context_instance(CONTEXT_SYSTEM))) { - $permissionsql = ''; + // don't add permission constraints } else if ($filtertype=='user' && has_capability('moodle/user:readuserblogs', get_context_instance(CONTEXT_USER, $filterselect))) { - $permissionsql = ''; + // don't add permission constraints + } else { + $conditions[] = $permissionsql; //add permission constraints } - /**************************************** - * depending on the type, there are 4 * - * different possible sqls * - ****************************************/ - - $requiredfields = "p.*, u.firstname,u.lastname,u.email"; if ($filtertype == 'course' && $filterselect == SITEID) { // Really a site $filtertype = 'site'; } - switch ($filtertype) { - - case 'site': - - $SQL = "SELECT $requiredfields - FROM {post} p, {user} u $tagtablesql - WHERE p.userid = u.id $tagquerysql - AND u.deleted = 0 - $permissionsql $typesql"; + $specificsql = ''; + switch ($filtertype) { // apply the selected filter + case 'mod': //only view posts associated with a particular mod + $context = get_context_instance(CONTEXT_MODULE, $filterselect); + $tables['ba'] = 'blog_association'; + $conditions[] = 'p.id = ba.blogid'; + $conditions[] = 'ba.contextid = '.$context->id; + break; + case 'site': //view posts for the whole site + //no constraints to add in this case break; - case 'course': - // all users with a role assigned + case 'course': // view posts for all members of a course + $tables['ra'] = 'role_assignments'; $context = get_context_instance(CONTEXT_COURSE, $filterselect); // MDL-10037, hidden users' blogs should not appear - if (has_capability('moodle/role:viewhiddenassigns', $context)) { - $hiddensql = ''; - } else { - $hiddensql = 'AND ra.hidden = 0'; + if (!has_capability('moodle/role:viewhiddenassigns', $context)) { + $conditions[] = 'ra.hidden = 0'; } - $SQL = "SELECT $requiredfields - FROM {post} p, {user} u, {role_assignments} ra $tagtablesql - WHERE p.userid = ra.userid $tagquerysql - AND ra.contextid ".get_related_contexts_string($context)." - AND u.id = p.userid - AND u.deleted = 0 - $hiddensql $permissionsql $typesql"; - + $conditions[] = 'p.userid = ra.userid'; + $conditions[] = 'ra.contextid '.get_related_contexts_string($context); + if($CFG->useassoc) { // only show blog entries associated with this course + $tables['ba'] = 'blog_association'; + $conditions[] = 'p.id = ba.blogid'; + $conditions[] = 'ba.contextid = '.$context->id; + } break; - case 'group': + case 'group': // view posts for all members of a group + $tables['gm'] = 'groups_members'; + $conditions[] = 'p.userid = gm.userid'; + $conditions[] = 'gm.groupid = '.$filterselect; + if($CFG->useassoc) { // only show blog entries associated with this course + $course_context = get_context_instance(CONTEXT_COURSE, $DB->get_field('groups', 'courseid', array('id' => $filterselect))); + $conditions[] = 'gm.groupid = '.$filterselect; + $conditions[] = 'ba.contextid = '.$course_context->id; + $conditions[] = 'ba.blogid = p.id'; + } + break; - $SQL = "SELECT $requiredfields - FROM {post} p, {user} u, {groups_members} gm $tagtablesql - WHERE p.userid = gm.userid AND u.id = p.userid $tagquerysql - AND gm.groupid = :groupid - AND u.deleted = 0 - $permissionsql $typesql"; - $params['groupid'] = $filterselect; - break; - - case 'user': - - $SQL = "SELECT $requiredfields - FROM {post} p, {user} u $tagtablesql - WHERE p.userid = u.id $tagquerysql - AND u.id = :uid - AND u.deleted = 0 - $permissionsql $typesql"; - $params['uid'] = $filterselect; + case 'user': // view posts for a single user + $conditions[] = 'u.id = '.$filterselect; break; } @@ -615,9 +700,18 @@ $limitnum = $fetchlimit; } - $orderby = "ORDER BY $sort"; + $tablessql = ''; // build up the FROM clause + foreach($tables as $tablename => $table) { + $tablessql .= ($tablessql ? ', ' : '').'{'.$table.'} '.$tablename; + } + + $conditionssql = ''; // build up the WHERE clause + foreach($conditions as $condition) { + $conditionssql .= ($conditionssql ? ' AND ' : '').$condition; + } - $records = $DB->get_records_sql("$SQL $orderby", $params, $limitfrom, $limitnum); + $SQL = 'SELECT '.$requiredfields.' FROM '.$tablessql.' WHERE '.$conditionssql.' GROUP BY p.id ORDER BY '. $sort; + $records = $DB->get_records_sql($SQL, $params, $limitfrom, $limitnum); if (empty($records)) { return array(); Index: lang/en_utf8/admin.php =================================================================== RCS file: /cvsroot/moodle/moodle/lang/en_utf8/admin.php,v retrieving revision 1.197 diff -u -a -w -b -B -r1.197 admin.php --- lang/en_utf8/admin.php 30 Jun 2008 11:12:23 -0000 1.197 +++ lang/en_utf8/admin.php 2 Jul 2008 03:43:47 -0000 @@ -758,5 +758,8 @@ $string['webproxyinfo'] = 'Fill in following options if your Moodle server can not access internet directly. Internet access is required for download of environment data, language packs, RSS feeds, timezones, etc.
PHP cURL extension is highly recommended.'; $string['xmlrpcrecommended'] = 'Installing the optional xmlrpc extension is useful for Moodle Networking functionality.'; $string['xmlstrictheaders'] = 'XML strict headers'; +$string['useassoc'] = 'Enable associations'; +$string['configuseassoc'] = 'Should users be able to organize their blog by associating entries with courses and course modules?'; + ?> Index: lang/en_utf8/blog.php =================================================================== RCS file: /cvsroot/moodle/moodle/lang/en_utf8/blog.php,v retrieving revision 1.25 diff -u -a -w -b -B -r1.25 blog.php --- lang/en_utf8/blog.php 24 Apr 2008 02:24:49 -0000 1.25 +++ lang/en_utf8/blog.php 2 Jul 2008 03:43:47 -0000 @@ -66,5 +66,10 @@ $string['viewsiteentries'] = 'View site entries'; $string['wrongpostid'] = 'Wrong blog post id'; $string['worldblogs'] = 'The world can read entries set to be world-accessible'; - +$string['associations'] = 'Associations';$string['publishtocourse'] = 'Users sharing a course with you'; +$string['publishtogroup'] = 'Users sharing a group with you'; +$string['publishtocourseassoc'] = 'Members of the associated course'; +$string['publishtogroupassoc'] = 'Your group members in the associated course'; +$string['associationunviewable'] = 'This entry cannot be viewed by others until a course is associated with it or the \'Publish To\' field is changed'; +$string['mustassociatecourse'] = 'If you are publishing to course or group members, you must associate a course with this entry'; ?> Index: lib/db/install.xml =================================================================== RCS file: /cvsroot/moodle/moodle/lib/db/install.xml,v retrieving revision 1.153 diff -u -a -w -b -B -r1.153 install.xml --- lib/db/install.xml 30 Jun 2008 11:00:42 -0000 1.153 +++ lib/db/install.xml 2 Jul 2008 03:43:47 -0000 @@ -1,5 +1,5 @@ - @@ -692,7 +692,7 @@ - + @@ -1661,7 +1661,7 @@
- +
@@ -1682,6 +1682,20 @@
+ + + + + + + + + + + + + +
Index: lib/db/upgrade.php =================================================================== RCS file: /cvsroot/moodle/moodle/lib/db/upgrade.php,v retrieving revision 1.209 diff -u -a -w -b -B -r1.209 upgrade.php --- lib/db/upgrade.php 30 Jun 2008 11:00:42 -0000 1.209 +++ lib/db/upgrade.php 2 Jul 2008 03:43:47 -0000 @@ -187,6 +187,55 @@ upgrade_main_savepoint($result, 2008063002); } + + if ($result && $oldversion < 2008030700) { + + /// Define index contextid-lowerboundary (not unique) to be dropped form grade_letters + $table = new XMLDBTable('grade_letters'); + $index = new XMLDBIndex('contextid-lowerboundary'); + $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('contextid', 'lowerboundary')); + + /// Launch drop index contextid-lowerboundary + $result = $result && drop_index($table, $index); + + /// Define index contextid-lowerboundary-letter (unique) to be added to grade_letters + $table = new XMLDBTable('grade_letters'); + $index = new XMLDBIndex('contextid-lowerboundary-letter'); + $index->setAttributes(XMLDB_INDEX_UNIQUE, array('contextid', 'lowerboundary', 'letter')); + + /// Launch add index contextid-lowerboundary-letter + $result = $result && add_index($table, $index); + + /// Main savepoint reached + upgrade_main_savepoint($result, 2008030700); + } +/* + if($result && $oldversion < 2008070100.01) { + /// Define table blog_association to be created + $table = new XMLDBTable('blog_association'); + + /// Adding fields to table blog_association + $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null); + $table->addFieldInfo('contextid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null); + $table->addFieldInfo('blogid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null); + /// Adding keys to table blog_association + $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id')); + $table->addKeyInfo('contextid', XMLDB_KEY_FOREIGN, array('contextid'), 'context', array('id')); + $table->addKeyInfo('blogid', XMLDB_KEY_FOREIGN, array('blogid'), 'post', array('id')); + + if ($result and !table_exists($table)) { + /// Launch create table for blog_association + $result = $result && create_table($table); + } + + /// Main savepoint reached + upgrade_main_savepoint($result, 2008070100.01); + } + if($result && $oldversion < 2008070100.02) { + /// Update enumeration 'puglishstate' in 'post' + $table = new XMLDBTable('post'); + + }*/ /* * TODO: * drop adodb_logsql table and create a new general sql log table