Skip to content

Commit

Permalink
more cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
toyomoyo committed Mar 16, 2006
1 parent a0fd7c1 commit 91366ca
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 62 deletions.
53 changes: 0 additions & 53 deletions blog/class.BlogEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,24 +72,6 @@ function BlogEntry(&$entrydetails) {

$this->entryId = $entrydetails->id;

if (!empty($entrydetails->categoryid)) {
if (is_array($entrydetails->categoryid)) {
$this->entryCategoryIds = $entrydetails->categoryid;
} else {
$this->entryCategoryIds = array($entrydetails->categoryid);
}
} else {
// load up all categories that this entry is associated with
// cannot use moodle's get_records() here because this table does not conform well enough
$sql = 'SELECT * FROM '. $CFG->prefix .'blog_categories_entries WHERE entryid='. $this->entryId;
if($rs = $db->Execute($sql)) {
while (!$rs->EOF) {
$this->entryCategoryIds[] = $rs->fields['categoryid'];
$rs->MoveNext();
}
}
}
$this->entryCategoryIds = array_unique($this->entryCategoryIds);
// print "Debug: entryId: $this->entryId"; //debug
// print_object($this->entryCategoryIds); //debug

Expand All @@ -103,10 +85,8 @@ function BlogEntry(&$entrydetails) {

$this->entryuserid = $entrydetails->userid;


//added stripslashes_safe here for rss feeds. Will this conflict anywhere?

$this->entryTitle = ereg_replace('<tick>', "'", stripslashes_safe($entrydetails->subject)); //subject, not title!

$this->entryFormat = $entrydetails->format;
Expand All @@ -126,17 +106,6 @@ function BlogEntry(&$entrydetails) {
//need to make sure that email is actually just a link to our email sending page.
$this->entryAuthorEmail = $rs->email;

// then each category
if (!empty($this->entryCategoryIds)) {
foreach ($this->entryCategoryIds as $categoryid) {
if (! $currcat = get_record('blog_categories', 'id', $categoryid)) {
print 'Could not find category id '. $categoryid ."\n";
$this->entryCategories[$categoryid] = '';
} else {
$this->entryCategories[$categoryid] = $currcat->catname;
}
}
}
}

/**
Expand Down Expand Up @@ -375,16 +344,6 @@ function _update() {
$dataobject->userid = intval($this->entryuserid);
$dataobject->publishstate = $this->entryPublishState;

if ($this->entryCourseId) {
$dataobject->courseid = $this->entryCourseId;
} else {
$dataobject->courseid = SITEID; //yu: in case change to all course
}
if ($this->entryGroupId) {
$dataobject->groupid = $this->entryGroupId;
} else {
$dataobject->groupid = 0; //yu: in case we change to all groups
}
$dataobject->lastmodified = $timenow;

$dataobject->summary = ereg_replace("'", '<tick>', $dataobject->summary);
Expand All @@ -403,18 +362,6 @@ function _update() {
$sql = 'DELETE FROM '. $CFG->prefix .'blog_categories_entries WHERE entryid='. $this->entryId;
$rs = $db->Execute($sql);

if (!empty($this->entryCategoryIds)) {
if (!is_array($this->entryCategoryIds)) {
$this->entryCategoryIds = array($this->entryCategoryIds);
}
$this->entryCategoryIds = array_unique($this->entryCategoryIds);
foreach ($this->entryCategoryIds as $categoryid) {
$cat->entryid = $this->entryId;
$cat->categoryid = $categoryid;
insert_record('blog_categories_entries', $cat);
}
}

// next update the entry itself
if (update_record('post', $dataobject)) {
return true;
Expand Down
1 change: 0 additions & 1 deletion blog/class.BlogFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ function BlogFilter($userid='', $postid='', $fetchlimit='', $fetchstart='', $fil
$this->fetchlimit = $fetchlimit;
}


$this->postid = $postid;

$this->sort = $sort;
Expand Down
1 change: 0 additions & 1 deletion blog/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,6 @@ function do_update(&$post, &$bloginfo) {
echo "id id ".$post->postid;
// print_object($blogentry); //debug

$blogentry->set_title($post->etitle);
$blogentry->set_body($post->body);
$blogentry->set_format($post->format);
$blogentry->set_publishstate($post->publishstate); //we don't care about the return value here
Expand Down
14 changes: 7 additions & 7 deletions blog/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@
$PAGE->courseid = $courseid;
$PAGE->init_full(); //init the BlogInfo object and the courserecord object

if (isset($tagid) && $tagid) {
if (!empty($tagid)) {
$taginstance = get_record('tags', 'id', $tagid);
} else {
$tagid = '';
if (isset($tag) && $tag) {
if (!empty($tag)) {
$tagrec = get_record('tags', 'text', $tag);
$tagid = $tagrec->id;
$taginstance = get_record('tags', 'id', $tagid);
Expand All @@ -84,7 +84,7 @@

switch ($filtertype) {
case 'site':
if ($tagid || (isset($tag) && $tag)) {
if ($tagid || !empty($tag)) {
print_header("$site->shortname: $blogstring", "$site->fullname",
'<a href="index.php?filtertype=site">'. "$blogstring</a> -> $tagstring: $taginstance->text",'','',true,$PAGE->get_extra_header_string());
} else {
Expand All @@ -94,7 +94,7 @@
break;

case 'course':
if ($tagid || (isset($tag) && $tag)) {
if ($tagid || !empty($tag)) {
print_header("$course->shortname: $blogstring", "$course->fullname",
'<a href="'.$CFG->wwwroot.'/course/view.php?id='.$filterselect.'">'.$course->shortname.'</a> ->
<a href="index.php?filtertype=course&amp;filterselect='.$filterselect.'">'. "$blogstring</a> -> $tagstring: $taginstance->text",'','',true,$PAGE->get_extra_header_string());
Expand All @@ -109,7 +109,7 @@

$thisgroup = get_record('groups', 'id', $filterselect);

if ($tagid || (isset($tag) && $tag)) {
if ($tagid || !empty($tag)) {
print_header("$course->shortname: $blogstring", "$course->fullname",
'<a href="'.$CFG->wwwroot.'/course/view.php?id='.$course->id.'">'.$course->shortname.'</a> ->
<a href="'.$CFG->wwwroot.'/user/index.php?id='.$course->id.'&amp;group='.$filterselect.'">'.$thisgroup->name.'</a> ->
Expand All @@ -129,7 +129,7 @@
$participants = get_string('participants');

if (isset($course->id) && $course->id && $course->id != SITEID) {
if ($tagid || (isset($tag) && $tag)) {
if ($tagid || !empty($tag)) {
print_header("$course->shortname: $blogstring", "$course->fullname",
'<a href="'.$CFG->wwwroot.'/course/view.php?id='.$course->id.'">'.$course->shortname.'</a> ->
<a href="'.$CFG->wwwroot.'/user/index.php?id='.$course->id.'">'.$participants.'</a> ->
Expand All @@ -149,7 +149,7 @@
//in top view
else {

if ($tagid || (isset($tag) && $tag)) {
if ($tagid || !empty($tag)) {
print_header("$site->shortname: $blogstring", "$site->fullname",
'<a href="'.$CFG->wwwroot.'/user/view.php?id='.$filterselect.'">'.fullname($user).'</a> ->
<a href="index.php?filtertype=user&amp;filterselect='.$filterselect.'">'. "$blogstring</a> -> $tagstring: $taginstance->text",'','',true,$PAGE->get_extra_header_string());
Expand Down

0 comments on commit 91366ca

Please sign in to comment.