From 924f20e221218bca9fd8237210e20585f28137ae Mon Sep 17 00:00:00 2001 From: toyomoyo Date: Wed, 15 Mar 2006 04:15:09 +0000 Subject: [PATCH] many functions removed, might have broken a few things --- blog/lib.php | 946 +----------------------------------------- blog/preferences.html | 5 - 2 files changed, 22 insertions(+), 929 deletions(-) diff --git a/blog/lib.php b/blog/lib.php index 50db382d42..40f48ee538 100755 --- a/blog/lib.php +++ b/blog/lib.php @@ -73,38 +73,6 @@ if (empty($CFG->blog_default_fetch_num_entries) ) { $CFG->blog_default_fetch_num_entries = 8; } -/** - * blog_user_bloginfo - * - * returns a blogInfo object if the user has a blog in the acl table - * This function stores the currently logged in user's bloginfo object - * statically - do not release/unset the returned object. - * added by Daryl Hawes for moodle integration - * $userid - if no userid specified it will attempt to use the logged in user's id - */ -function blog_user_bloginfo($userid='') { -//Daryl Hawes note: not sure that this attempt at optimization is correct -// static $bloginfosingleton; //store the logged in user's bloginfo in a static var - - if ($userid == '') { - global $USER; - if (!isset($USER) || !isset($USER->id)) { - return; - } - $userid = $USER->id; - } - -/* if (isset($USER) && $USER->id == $uid && !empty($bloginfosingleton)) { - return $bloginfosingleton; - }*/ - - $thisbloginfo = new BlogInfo($userid); -/* if (isset($USER) && $USER->id == $userid) { - $bloginfosingleton = $thisbloginfo; - }*/ - return $thisbloginfo; -} - /** * Verify that a user is logged in based on the session * @return bool True if user has a valid login session @@ -117,116 +85,6 @@ function blog_isLoggedIn() { return 0; } -/** - * This function upgrades the blog's tables as needed. - * It's called from moodle/admin/index.php - */ -function blog_upgrade_blog_db($continueto) { - - global $CFG, $db; - - require_once($CFG->dirroot.'/blog/version.php'); // Get code versions - - if (empty($CFG->blog_version)) { // Blog has never been installed. - $strdatabaseupgrades = get_string('databaseupgrades'); - print_header($strdatabaseupgrades, $strdatabaseupgrades, $strdatabaseupgrades, - '', '', false, ' ', ' '); - - $db->debug=true; - if (modify_database($CFG->dirroot .'/blog/db/'. $CFG->dbtype .'.sql')) { - $db->debug = false; - if (set_config('blog_version', $blog_version)) { - notify(get_string('databasesuccess'), 'green'); - notify(get_string('databaseupgradeblog', 'blog', $blog_version)); - - /// Added by Daryl Hawes - since blog has to be installed the first time before blog's blocks, and on first install creating default blocks when none exist is a bad idea, just reset blocks for blog index here - require_once($CFG->libdir .'/pagelib.php'); - require_once($CFG->dirroot .'/blog/blogpage.php'); - page_map_class(PAGE_BLOG_VIEW, 'page_blog'); - // Now, create our page object. - $page = page_create_object(PAGE_BLOG_VIEW, 0); - // Add default blocks to the new page type - blocks_repopulate_page($page); - - print_continue($continueto); - exit; - } else { - error('Upgrade of blogging system failed! (Could not update version in config table)'); - } - } else { - error('blog tables could NOT be set up successfully!'); - } - } - - - if ($blog_version > $CFG->blog_version) { // Upgrade tables - $strdatabaseupgrades = get_string('databaseupgrades'); - print_header($strdatabaseupgrades, $strdatabaseupgrades, $strdatabaseupgrades); - - require_once($CFG->dirroot. '/blog/db/'. $CFG->dbtype .'.php'); - - $db->debug=true; - if (blog_upgrade($CFG->blog_version)) { - $db->debug=false; - if (set_config('blog_version', $blog_version)) { - notify(get_string('databasesuccess'), 'green'); - notify(get_string('databaseupgradeblocks', '', $blog_version)); - print_continue($continueto); - exit; - } else { - error('Upgrade of blogging system failed! (Could not update version in config table)'); - } - } else { - $db->debug=false; - error('Upgrade failed! See blog/version.php'); - } - - } else if ($blog_version < $CFG->blog_version) { - notify('WARNING!!! The blog code you are using is OLDER than the version that made these databases! ('. $version .' < '. $CFG->blog_version .')'); - } -} - -/** - * course_has_blog_entries - * Given a course id return true if there are blog entries from any user related to that course - * $courseid - the id for the course - * Daryl Hawes note: When forum entries start using post table this function will no longer behave as expected - * Since non blog posts will be associated with this course. Perhaps moduleid or another field could be wrangled - * into identifying the type of post? - */ -function blog_course_has_blog_entries($courseid) { - $entries = get_records('post', 'courseid', $courseid); - if (! empty($entries) ) { - return true; - } - return false; -} - -/** - * Output a hidden html form used by text entry pages that require preview.php's functionality - */ -function blog_print_preview_form($userid=0, $categoryelement='', $return=false) { - - $returnstring = "\n".''."\n"; - - if ($return) { - return $returnstring; //return the form as a string if requested - } - print $returnstring; //else just print the string and exit the function -} - /** * blog_user_has_rights - returns true if user is the blog's owner or a moodle admin. * @@ -291,203 +149,31 @@ function blog_isediting() { } /** - * Turns a php string into a string ready for insert into an rss xml feed - */ -function blog_rss_content($str) { - $str = superhtmlentities($str); - $content = "\n"; - - return $content; -} - -/** - * function found when searching on problem of smart quotes - * posted at http://daynah.php-princess.net/index.php?p=94 - */ -function superhtmlentities($text) { - $entities = array(128 => 'euro', 130 => 'sbquo', - 131 => 'fnof', 132 => 'bdquo', 133 => 'hellip', - 134 => 'dagger', 135 => 'Dagger', 136 => 'circ', - 137 => 'permil', 138 => 'Scaron', 139 => 'lsaquo', - 140 => 'OElig', 145 => 'lsquo', 146 => 'rsquo', - 147 => 'ldquo', 148 => 'rdquo', 149 => 'bull', - 150 => 'ndash', 151 => 'mdash', 152 => 'tilde', - 153 => 'trade', 154 => 'scaron', 155 => 'rsaquo', - 156 => 'oelig', 159 => 'Yuml'); - - $new_text = ''; - for($i = 0; $i < strlen($text); $i++) { - $num = ord($text{$i}); - if (array_key_exists($num, $entities)) { - $new_text .= '&\\'.$entities[$num].';'; - } else if ($num < 127 || $num > 159) { - $new_text .= $text{$i}; - } - } - return htmlentities($new_text); -} - -/** - * blog_get_recent_entries_byrange - * not in blogInfo because entries being searched - * can be found in any number of blogs rather than just one. - * - * Returns specified range of entries since a given time. - * - * In using this function be aware for your where clause that the tables being - * read are post (e) and blog_categories_entries (c) and the returned values - * will be e.* - * - * @param int $limit . - * @param int $start . - * @param string $where . - * @param string $orderby . - * @param bool $includeCategories . - * - * @return BlogEntries - */ -function blog_get_recent_entries_byrange($limit, $start, $where='', $orderby='lastmodified DESC', $includeCategories=false) { - global $CFG; - -// echo 'Debug: where clause in blog_get_recent_entries_byrange: $where
'; //debug - - if ($includeCategories) { - $records = get_records_select('post e, '. $CFG->prefix .'blog_categories_entries c', $where, $orderby, '*', $start, $limit); - } else { - $records = get_records_select('post', $where, $orderby, '*', $start, $limit); - } -// print_object($records); //debug - - if (empty($records)) { - return array(); - } else { - $blogEntries = array(); - foreach($records as $record) { - $blogEntry = new BlogEntry($record); - //ensure that the user has rights to view this entry - if ($blogEntry->user_can_view() ) { - $blogEntries[] = $blogEntry; - } - } - return $blogEntries; - } -} - -/** - * returns a unix time stamp from year month and day - * used to get start and end dates for comparing against timestamps in databases - */ -function blog_get_month_time($y, $m, $d, $firstday=true) { - - if ( !empty($y) && !empty($m) && !empty($d)) { - $time = mktime(0, 0, 0, $m, $d, $y); - } else if ( !empty($y) && !empty($m) ) { - $day = blog_mk_getLastDayofMonth($m, $y); - if ($firstday) { - $day = 1; - } - $time = mktime(0, 0, 0, $m, $day, $y); - } else { - $time = ''; - } - return $time; -} - -/** - * attempting to create a method useful for a popup form on the index - * page that will allow a user to filter entries based upon date + * blog_user_bloginfo * - * This function will return a list, in order, formatted as "MM-YYYY" for each year and month - * in which this blog has entries. - * @param BlogFilter $blogFilter - a BlogFilter object with the current filter settings for this page - */ -function blog_get_year_month_of_viewable_entries(&$blogFilter) { - global $_SERVER; - - $entries = $blogFilter->get_filtered_entries(); - $datearray = array(); - $datearray['m=&y='] = 'All Dates'; - - if ( !empty($entries) ) { - foreach ($entries as $entry) { - if ( $entry->user_can_view() ) { -// print_object($entry); //debug - //user is allowed to see this entry, so return its year/month information - $date = $entry->entryLastModified; - $truncDate = date("F Y", $date); // this will return January 2004 for the date. - $curmonth = date("m", $date); // this will return January 2004 for the date. - $curyear = date("Y", $date); // this will return January 2004 for the date. - $index = 'm='. $curmonth .'&y='. $curyear; - $datearray[$index] = $truncDate; - } - } - } -// print_object($datearray); //debug - - if (is_numeric($blogFilter->startmonth) && is_numeric($blogFilter->startyear)) { - $selected = 'm='. $blogFilter->startmonth .'&y='. $blogFilter->startyear; - } else { - $selected = ''; - } - $unused = array('startmonth', 'startyear'); - $getvars = $blogFilter->get_getvars($unused); - //attach a random number to the popup function's form name - //becuase there may be multiple instances of this form on each page - $self = basename($_SERVER['PHP_SELF']); - $form = popup_form($self . $getvars .'&', $datearray, 'blog_date_selection'. mt_rand(), $selected, '', '', '', true); - return str_replace('get_getvars('courseid'); - - if ( !isset($USER) || !isset($USER->id) ) { - return; - } - - if (isguest($USER->id)) { - return ''; - } - - if (isadmin($USER->id)) { - $courses = get_courses('all', 'c.shortname'); - - } else { - $courses = get_my_courses($USER->id, 'shortname'); - } - - unset($courses[1]); - - $courseoptions[1] = get_string('fulllistofcourses'); - foreach ($courses as $course) { - // Verify that there are actually blog entries for this course before showing it as a selection. - if ($entries = count_records('post', 'courseid', $course->id)) { - $courseoptions[$course->id] = $course->shortname; +function blog_user_bloginfo($userid='') { +//Daryl Hawes note: not sure that this attempt at optimization is correct +// static $bloginfosingleton; //store the logged in user's bloginfo in a static var + global $USER; + if ($userid == '') { + global $USER; + if (!isset($USER) || !isset($USER->id)) { + return; } + $userid = $USER->id; } - //if there were no courses added then simply return - if (count($courseoptions) == 1) { - return; - } - - if (is_numeric($blogFilter->courseid)) { - $selected = $blogFilter->courseid; - } else { - $selected = ''; - } - //attach a random number to the popup function's form name - //because there may be multiple instances of this form on each page - $self = basename($_SERVER['PHP_SELF']); - $form = popup_form($self . $getvars .'&courseid=', - $courseoptions, 'blog_course_selection'. mt_rand(), $selected, '', '', '', true); - - return str_replace('id == $userid) { + $bloginfosingleton = $thisbloginfo; + }*/ + return $thisbloginfo; } /** @@ -567,27 +253,6 @@ function blog_member_list(&$blogFilter, &$memberrecords, $format=1, $return=true return; } -/** - * @param int courseid the selected course in popup - */ -function blog_get_course_selection_popup($courseid='') { - global $USER; - if ( !isset($USER) || !isset($USER->id) ) { - return; - } - if ( isadmin() ) { - $courses = get_courses(); //show admin users all courses - } else { - $courses = get_my_courses($USER->id) ; //get_my_courses is in datalib.php - } - //print_object($courses); //debug - $courseoptions = array(); - foreach ($courses as $course) { - $courseoptions[$course->id] = $course->shortname; - } - return choose_from_menu($courseoptions, 'course_selection', $courseid, '', '', '0', true); -} - /** * This function is in lib and not in BlogInfo because entries being searched * might be found in any number of blogs rather than just one. @@ -623,7 +288,6 @@ function blog_print_html_formatted_entries(&$blogFilter, $filtertype, $filtersel } } - $morelink = '
  '; // show personal or general heading block as applicable echo '
'; @@ -660,13 +324,7 @@ function blog_print_html_formatted_entries(&$blogFilter, $filtertype, $filtersel } } -/* - if (blog_isLoggedIn() && blog_isediting() ) { - //Daryl Hawes note: localize this submit button! - print '
'."\n"; - print ''."\n"; - } -*/ + //yu: testing code if (blog_isLoggedIn()) { //the user's blog is enabled and they are viewing their own blog @@ -686,7 +344,6 @@ function blog_print_html_formatted_entries(&$blogFilter, $filtertype, $filtersel } $output = '
'. get_string('noentriesyet', 'blog') .'

'; - $userbloginfo = blog_user_bloginfo(); if (blog_isLoggedIn()) { //the user's blog is enabled and they are viewing their own blog @@ -696,33 +353,6 @@ function blog_print_html_formatted_entries(&$blogFilter, $filtertype, $filtersel unset($blogFilter->filtered_entries); } -/** - * What text should be displayed claiming ownership to the current blog entries? - * @uses $PAGE - * @return string - */ -function blog_get_title_text() { - global $PAGE; //hackish - - if (isset($PAGE) && isset($PAGE->bloginfo)) { - $blogInfo = &$PAGE->bloginfo; - $title = $blogInfo->get_blog_title(); - if($title != '') { - $displaytitle = $title; - $tagline = $blogInfo->get_blog_tagline(); - if ($tagline != '') { - $displaytitle .= ' - '. $tagline; - } - } - } - if (isset($displaytitle)) { - return $displaytitle; - } else { - // Daryl Hawes - better wording would be good here, localize this line once the wording is selected. - return 'Combined Blog '. get_string('entries', 'blog') .'
'; - } -} - /** * blog_get_moodle_pix_path * @@ -877,11 +507,7 @@ function blog_applicable_publish_states($courseid='') { $options['course'] = get_string('publishtocourse', 'blog', $course->shortname); } } - /* - //groups not supported quite yet - pseudocode: - if (isset($post->groupid) && $post->groupid != '') { - $options['group'] = 'Fellow group members and teachers can view'; - }*/ + if (!$CFG->blog_enable_moderation || isadmin() || (is_numeric($courseid) && isteacher($courseid)) ) { // only admins and teachers can see site and public options when moderation is enabled $options['site'] = get_string('publishtosite', 'blog'); @@ -890,532 +516,4 @@ function blog_applicable_publish_states($courseid='') { return $options; } -/** - * blog_get_entries_by_category - not in blogInfo because entries being searched - * can be found in any number of blogs rather than just one. - * catids can be an array of category ids or a single category id - * defined as either - * $catids = array(1, 2, 3, 4, 5); - * or - * $catids = 2; - * - * Used by rss.php - */ -function blog_get_entries_by_category($catids, $courseid=0, $limit=8, $start=0) { - $catsearch = ' e.id=c.entryid AND '; //only gets categories whose postid matches entries retrieved - if (blog_array_count($catids) > 0) { - $count = 0; - foreach ($catids as $catid) { - $catsearch .= 'c.categoryid='. $catid .' '; - $count += 1; - if (count($catids) != $count) { - $catsearch .= 'OR '; - } - } - } else { - $catsearch .= 'c.categoryid='. $catids; - } - $wherecourse = ''; - if (is_numeric($courseid) && $courseid != 0 && $courseid != 1) { - $wherecourse = ' AND e.courseid='. $courseid; - } - $where = $catsearch.$wherecourse; -// echo 'Debug: where clause for blog_get_entries_by_category: '. $where; //debug - return blog_get_recent_entries_byrange($limit, $start, $where, '', true); -} - -/** - * builds calendar with links to filter entries by date - * modified by Daryl Hawes to build links even when no userid is specified - * and to return the html as a string if desired - */ -function blog_draw_calendar(&$blogFilter, $return=false) -{ - global $CFG; -// print_object($blogFilter); - - if (!empty($blogFilter->startmonth)) { - $m = $blogFilter->startmonth; - } else { - $m = date('n', mktime()); - $blogFilter->startmonth = $m; - } - if (!empty($blogFilter->startyear)) { - $y = $blogFilter->startyear; - } else { - $y = date('Y', mktime()); - $blogFilter->startyear = $y; - } - $userid = $blogFilter->userid; - - //create a string to represent a URL argument with userid info. If no userid then string is empty. - $useridString = '&userid='. $userid; - if ($userid == 0 || $userid == '') { - $useridString = ''; - } - - // calculate the weekday the first of the month is on - $tmpd = getdate(mktime(0, 0, 0, $m, 1, $y)); - $monthname = $tmpd['month']; - $firstwday= $tmpd['wday']; - $today = date('Ymd', mktime()); - - $lastday = blog_mk_getLastDayofMonth($m, $y); - - //determine next and previous month - if (($m - 1) < 1) { $pm = 12; } else { $pm = $m - 1; } - if (($m + 1) > 12) { $nm = 1; } else { $nm = $m + 1; } - - if (strlen($pm) == 1) { $pm = '0'. $pm; }; - if (strlen($nm) == 1) { $nm = '0'. $nm; }; - - $returnstring = "\n".''."\n"; - $returnstring .= ''."\n"; - - $blogFilter->startyear = $currentyear; - $blogFilter->startmonth = $currentmonth; - - $returnstring .= '
'."\n"; - - $currentyear = $y; - $currentmonth = $m; - - if (($m - 1) < 1) { - $blogFilter->startyear = $y - 1; - } else { - $blogFilter->startyear = $y; - } - - $blogFilter->startmonth = $pm; - $self = basename($_SERVER['PHP_SELF']); - $returnstring .= $blogFilter->get_complete_link( $self, '<<' , array('startday'))."\n"; - - $blogFilter->startyear = $currentyear; - $blogFilter->startmonth = $currentmonth; - - $returnstring .= ''."\n"; -// $returnstring .= $blogFilter->get_complete_link($CFG->wwwroot .'/blog/archive.php', $monthname .' '. $y, array('startday')); - $returnstring .= $blogFilter->get_complete_link($self, $monthname .' '. $y, array('startday')); - - if (($m + 1) > 12) { - $blogFilter->startyear = $blogFilter->startyear + 1; - } else { - $blogFilter->startyear = $y; - } - - $blogFilter->startmonth = $nm; - $returnstring .= ''."\n"; - $returnstring .= $blogFilter->get_complete_link( $self, '>>', array('startday'))."\n"; - $returnstring .= '
'."\n"; - $returnstring .= ''."\n"; - $returnstring .= ''."\n"; - $returnstring .= ''."\n"; - $returnstring .= ''."\n"; - $returnstring .= ''."\n"; - $returnstring .= ''."\n"; - $returnstring .= ''."\n"; - $returnstring .= ''."\n"; - - $d = 1; - $wday = $firstwday; - $firstweek = true; - - // loop through all the days of the month - while ( $d <= $lastday) - { - // set up blank days for first week - if ($firstweek) { - $returnstring .= ''."\n"; - for ($i=1; $i <= $firstwday; $i++) { - $returnstring .= ''."\n"; - } - $firstweek = false; - } - - // Sunday start week with - if ($wday==0) { - $returnstring .= ''."\n"; - } - - $mo = $m; - if ($mo < 10) { - if (!preg_match("/0\d/", $mo)) { - $mo = '0'. $mo; - } - } - - // Look for blog entries for this day - $tstart = blog_get_month_time($y, $m, $d, true); - $tend = blog_get_month_time($y, $m, $d + 1, false); - $where = " lastmodified >= $tstart AND lastmodified <= $tend "; - - if ($userid != 0 && $userid != '') { - $where .= ' AND author = '. $userid .' '; - } - - $count = count_records_select('post', $where); - -//echo 'Where clause: '. $where .' | count:'. $count. '
'."\n"; //debug - $da = $d; - if($da < 10) { - if(!preg_match("/0\d/", $da)) { - $da = "0". $da; - } - } - // check for event - $showdate = $y . $mo . $da; - - $returnstring .= ''."\n"; - - // Saturday end week with - if ($wday == 6) { - $returnstring .= ''."\n"; - } - - $wday++; - $wday = $wday % 7; - $d++; - } - - if ($wday != 0) { - for($i = $wday; $i < 7; $i++) { - $returnstring .= ''."\n"; - } - $returnstring .= ''."\n"; - } - - $returnstring .= '
'. get_string('calsun', 'blog') .''. get_string('calmon', 'blog') .''. get_string('caltue', 'blog') .''. get_string('calwed', 'blog') .''. get_string('calthu', 'blog') .''. get_string('calfri', 'blog') .''. get_string('calsat', 'blog') .'
 
0) { - $blogFilter->startday = $d; - $returnstring .= $blogFilter->get_complete_link($CFG->wwwroot .'/blog/index.php', $d); - } else { - $returnstring .= $d."\n"; - } - $returnstring .= '
 
'."\n"; - - $returnstring .= '
'."\n"; - - if ($return) { - return $returnstring; - } - print $returnstring; -// end blog_draw_calendar function -} - -/** - * get the last day of the month - */ -function blog_mk_getLastDayofMonth($mon, $year) -{ - for ($tday=28; $tday <= 31; $tday++) - { - $tdate = getdate(mktime(0, 0, 0, $mon, $tday, $year)); - if ($tdate['mon'] != $mon) - { break; } - - } - $tday--; - - return $tday; -} - -/** - * blog_safeHTML - * Clean up user input (currently unused, moodle's format_text() is preferable) - */ -function blog_safeHTML($html, $tags = 'b|br|i|u|ul|ol|li|p|a|blockquote|em|strong') { -// removes all tags that are considered unsafe -// Adapted from a function posted in the comments about the strip_tags() -// function on the php.net web site. -// -// This function is not perfect! It can be bypassed! -// Remove any nulls from the input - $html = preg_replace('/\0/', '', $html); - - // convert the ampersands to null characters (to save for later) - $html = preg_replace('/&/', '\0', $html); - - // convert the sharp brackets to their html code and escape special characters such as " - $html=htmlspecialchars($html); - - // restore the tags that are considered safe - if ($tags) { - // Fix start tags - $html = preg_replace("/<(($tags).*?)>/i", '<$1>', $html); - // Fix end tags - $html = preg_replace("/<\/($tags)>/i", '', $html); - // Fix quotes - $html = preg_replace("/"/", '"', $html); - $html = addslashes($html); - // Don't allow, e.g. - $html = preg_replace("/<($tags)([^>]*)>/ie", "'<$1' . stripslashes_safe(str_replace('javascript', 'hackerscript', '$2')) .'>'", $html); - // Don't allow, e.g. - $html = preg_replace("/<($tags)([^>]*)>/ie", "'<$1' . stripslashes_safe(str_replace(' on', ' off', '$2')) .'>'", $html); - $html = stripslashes_safe($html); - - } - - // restore the ampersands - $html = preg_replace('/\0/', '&', $html); - - return($html); -} // safeHTML - -// I don't like how the PHP count() function returns 1 if -// you pass it a scalar. So this is my custom function that -// will return 0 if the argument isn't an array. -function blog_array_count($arr) { - if (!is_array($arr)) { - return 0; - } - - return count($arr); -} - -/** -* check_dir_exists - * Function to check if a directory exists - * and, optionally, create it - * copied from moodle/backup/lib.php - */ -if (! function_exists('check_dir_exists')) { - function check_dir_exists($dir, $create=false) { - - global $CFG; - - $status = true; - if (!is_dir($dir)) { - if (!$create) { - $status = false; - } else { - umask(0000); - $status = mkdir ($dir, $CFG->directorypermissions); - } - } - return $status; - } -} - -/////////////// Time and Date display functions /////////////// - -/* - * Returns the current time as a readable date string - * using moodle's chosen full date display format from admin configuration. - */ -function blog_now() { - $strftimedaydatetime = get_string('strftimedaydatetime'); - $date = userdate(time(), $strftimedaydatetime); - return $date; -} - -/** -* UNIX timestamp to a readable format. - * using moodle's chosen date format from admin configuration. - */ -function blog_format_date($datetime) { - $strftimedate = get_string('strftimedate'); - $date = userdate($datetime, $strftimedate); - return $date; -} - -/** -* converts unix timestamp to just a date - * using moodle's chosen short date format from admin configuration. - */ -function blog_short_date($datetime) { - $strftimedateshort = get_string('strftimedateshort'); - $date = userdate($datetime, $strftimedateshort); - return $date; -} - -/** -* converts unix timestamp to just a date - * using moodle's chosen time format from admin configuration. - */ -function blog_short_time($datetime) { - $strftimetime = get_string('strftimetime'); - $time = userdate($datetime, $strftimedateshort); - return $time; -} - -/////////////// Trackback functions /////////////// - -// Note: trackback specification -// http://www.movabletype.org/docs/mttrackback.html - - -/** - * generate rdf for trackback autodiscovery - */ -function blog_get_trackback_rdf_string($blogEntry) { - - global $CFG; - $userid = $blogEntry->entryuserid; - $entryid = $blogEntry->entryId; - $blogInfo = new BlogInfo($userid); - -// echo 'in blog_get_trackback_rdf_string blogEntry:
'."\n"; //debug -// print_object($blogEntry); //debug - - $rdf = "\n".''."\n"; - unset($blogInfo); //clean up after ourselves - return $rdf; -} - - -/** - * Return a list of trackbacks for a particular id - */ -function blog_list_trackbacks($postid) { - global $db, $CFG; - - //Daryl Hawes note: convert this sql statement to a moodle function call - $sql = 'SELECT * FROM '. $CFG->prefix .'blog_trackback WHERE entryid = '. $postid; - $res = $db->Execute($sql); - - //iterate results - $list = array(); - while( !$res->EOF && isset($res->fields) ) { - $list[] = $res->fields; - $res->MoveNext(); - } - - return $list; -} - - -/////////////////////// CATEGORY MANAGEMENT //////////////////////////////////// - - - - -/** - *called by blog_category_list - * @return string html links for each category - */ -function blog_get_html_display_for_categories(&$blogFilter, $shownumentries, &$records, $showseparators, $title, $section) { - global $CFG, $editing; - $returnstring =''; - if ($showseparators) { - //first show a separator if requested - $returnstring .= $title .'
'."\n"; - } - $editallowed = false; - - if ($editing) { - $isteacher = false; - if (isset($blogFilter->courseid)) { - $isteacher = isteacher($blogFilter->courseid); - } - if ( isadmin() ) { - // admin is allowed to edit any categories on the site - $editallowed = true; - } else if ( ($section == 'course' || $section == 'group') && $isteacher ) { - // teacher of course can modify course categories and group categories - $editallowed = true; - } else if ($section == 'personal' && blog_is_blog_admin($blogFilter->userid) ) { - // user can modify their own blog categories - $editallowed = true; - } - } - - if (!isset($records) ) { - return; - } - - foreach($records as $record) { - $catcount = ''; - $categoryid = $record->id; - $categoryname = $record->catname; - if ($shownumentries) { - $tempfilter =& new BlogFilter('', $categoryid); - $catcount = ' ('; - $catcount .= $tempfilter->get_filtered_entry_count(); - $catcount .= ')'; - } - $blogFilter->categoryid = $categoryid; - $returnstring .= $blogFilter->get_complete_link($CFG->wwwroot .'/blog/index.php', stripslashes_safe($categoryname) . $catcount); - if ($editallowed) { - // note that only the 'act' and 'categoryid' vars are needed here because the me() function includes the - // existing query string - $returnstring .= ' 
'; - $returnstring .= ''. get_string('edit');
-            $returnstring .= ''."\n"; - if ($categoryid != 1) { //do not remove "General" sitewide category - $returnstring .= ' '; - $returnstring .= ''. get_string('delete');
-$returnstring .= ''."\n"; - } - } - $returnstring .= '
'."\n"; - } - return $returnstring; -} - -/** - * - */ -function blog_get_popup_display_for_categories(&$blogFilter, $format, $shownumentries, &$records) { - global $CFG; - - if (!isset($records) ) { - return; - } - $returnstring = ''; - - foreach ($records as $record) { - if ($format == 2) { - $value = $CFG->wwwroot .'/blog/index.php?categoryid='. $record->id; - $value .= '&userid='. $blogFilter->userid .'&courseid='. $blogFilter->courseid .'&groupid='. $blogFilter->groupid; - } else { - $value = $record->id; - } - - $returnstring .= ''; - } - return $returnstring; -} ?> diff --git a/blog/preferences.html b/blog/preferences.html index 6cbee77842..da0323c7ed 100755 --- a/blog/preferences.html +++ b/blog/preferences.html @@ -1,8 +1,3 @@ -userid); -?> -
-- 2.39.5