From 473dd2888be7787919c8df622955642be8af4039 Mon Sep 17 00:00:00 2001 From: moodler Date: Sun, 26 Mar 2006 05:03:10 +0000 Subject: [PATCH] Various little fixes. --- mod/data/approve.php | 39 ---------------------- mod/data/field/picture/field.class.php | 14 +++++--- mod/data/field/url/field.class.php | 10 +++++- mod/data/field/url/mod.html | 6 +++- mod/data/lib.php | 46 +++++++++----------------- mod/data/templates.php | 1 + mod/data/view.php | 27 ++++++++++----- 7 files changed, 58 insertions(+), 85 deletions(-) delete mode 100755 mod/data/approve.php diff --git a/mod/data/approve.php b/mod/data/approve.php deleted file mode 100755 index 5e9bcc86de..0000000000 --- a/mod/data/approve.php +++ /dev/null @@ -1,39 +0,0 @@ -dataid)) { - error('Data ID is incorrect'); - } - if (! $course = get_record('course', 'id', $data->course)) { - error('Course is misconfigured'); - } - - if (!isteacher($course->id)) { - error(get_string('errormustbeteacher', 'data')); - } - - if (confirm_sesskey()) { /* Approve it! */ - $newrecord->id = $record->id; - $newrecord->approved = 1; - update_record('data_records', $newrecord); - } - - redirect('view.php?d='.$d.'&approved=1&page='.$page.'&rid='.$rid.'&search='.$search.'&sort='.$sort.'&order='.$order.'&', get_string('recordapproved','data')); - - -?> diff --git a/mod/data/field/picture/field.class.php b/mod/data/field/picture/field.class.php index 1689642d69..1afce22800 100755 --- a/mod/data/field/picture/field.class.php +++ b/mod/data/field/picture/field.class.php @@ -80,27 +80,31 @@ class data_field_picture extends data_field_file { $contents[1] = $content->content1; } + if (empty($contents[0])) { // Nothing to show + return ''; + } + $alt = empty($contents[1])? '':$contents[1]; $title = empty($contents[1])? '':$contents[1]; - $src = empty($contents[0])? '':$contents[0]; + $src = $contents[0]; $path = $this->data->course.'/'.$CFG->moddata.'/data/'.$this->data->id.'/'.$this->field->id.'/'.$recordid; if ($CFG->slasharguments) { - $source = $CFG->wwwroot.'/file.php/'.$path; + $source = $CFG->wwwroot.'/file.php/'.$path.'/'.$src; } else { - $source = $CFG->wwwroot.'/file.php?file=/'.$path; + $source = $CFG->wwwroot.'/file.php?file=/'.$path.'/'.$src; } if ($template == 'listtemplate') { $width = $this->field->param4 ? ' width="'.$this->field->param4.'" ' : ' '; $height = $this->field->param5 ? ' height="'.$this->field->param5.'" ' : ' '; $str = ''.$alt.''; + $width.$height.' src="'.$source.'" alt="'.$alt.'" title="'.$title.'" border="0" />'; } else { $width = $this->field->param1 ? ' width="'.$this->field->param1.'" ':' '; $height = $this->field->param2 ? ' height="'.$this->field->param2.'" ':' '; - $str = ''.$alt.''; + $str = ''.$alt.''; } return $str; } diff --git a/mod/data/field/url/field.class.php b/mod/data/field/url/field.class.php index 9a44c4f40e..07c5fd5502 100755 --- a/mod/data/field/url/field.class.php +++ b/mod/data/field/url/field.class.php @@ -45,7 +45,7 @@ class data_field_url extends data_field_base { $url = empty($url) ? 'http://' : $url; $str = '
'; - if (!empty($this->field->param1)) { + if (!empty($this->field->param1) and empty($this->field->param2)) { $str .= ''; $str .= ''; @@ -62,6 +62,14 @@ class data_field_url extends data_field_base { if ($content = get_record('data_content', 'fieldid', $this->field->id, 'recordid', $recordid)){ $url = empty($content->content)? '':$content->content; $text = empty($content->content1)? '':$content->content1; + + if (empty($url) or ($url == 'http://')) { + return ''; + } + + if (!empty($this->field->param2)) { // param2 forces the text to something + $text = $this->field->param2; + } if ($this->field->param1) { // param1 defines whether we want to autolink the url. if (!empty($text)) { diff --git a/mod/data/field/url/mod.html b/mod/data/field/url/mod.html index 7d0c9f7675..7aa403dea4 100755 --- a/mod/data/field/url/mod.html +++ b/mod/data/field/url/mod.html @@ -7,8 +7,12 @@ + + + + -
'; $str .= get_string('url','data').':
'.get_string('text','data').':
:
:
field->param1) {echo 'checked="checked"';} ?> value="1" />
\ No newline at end of file + diff --git a/mod/data/lib.php b/mod/data/lib.php index 1cc5cfba89..81d1cca5f9 100755 --- a/mod/data/lib.php +++ b/mod/data/lib.php @@ -828,12 +828,8 @@ function data_print_template($records, $data, $search, $template, $sort, $page=0 $record = get_record('data_records','id',$record->id); ///replacing special tags (##Edit##, ##Delete##, ##More##) - $patterns[]='/\#\#Edit\#\#/i'; - $patterns[]='/\#\#Delete\#\#/i'; - $patterns[]='/\#\#More\#\#/i'; - $patterns[]='/\#\#Approve\#\#/i'; - $patterns[]='/\#\#Comment\#\#/i'; + $patterns[]='/\#\#Edit\#\#/i'; if (data_isowner($record->id) or isteacheredit($course->id)){ $replacement[] = ''.get_string('edit').''; @@ -841,20 +837,28 @@ function data_print_template($records, $data, $search, $template, $sort, $page=0 $replacement[] = ''; } + $patterns[]='/\#\#Delete\#\#/i'; if (data_isowner($record->id) or isteacheredit($course->id)){ $replacement[] = ''.get_string('delete').''; + .$data->id.'&rid='.$record->id.'&delete='.$record->id.'&sesskey='.sesskey().'">'.get_string('delete').''; }else { $replacement[] = ''; } + $patterns[]='/\#\#More\#\#/i'; $replacement[] = ''.get_string('more').''; + $patterns[]='/\#\#MoreURL\#\#/i'; + $replacement[] = $CFG->wwwroot.'/mod/data/view.php?d='.$data->id.'&rid='.$record->id.'&search='.$search.'&sort='.$sort.'&order='.$order.'&group='.$group; + + + $patterns[]='/\#\#Approve\#\#/i'; if (isteacher($course->id) && ($data->approval) && (!$record->approved)){ - $replacement[] = data_print_approve_button($record->id, $data->id, $page, $rid, $search, $sort, $order); - }else { + $replacement[] = ''.get_string('approve').''; + } else { $replacement[] = ''; } + $patterns[]='/\#\#Comment\#\#/i'; if (($template == 'listtemplate') && ($data->comments)) { $comments = count_records('data_comments','recordid',$record->id); $replacement[] = ''.$comments.' '.get_string('comment','data').''; @@ -884,7 +888,6 @@ function data_print_template($records, $data, $search, $template, $sort, $page=0 data_print_comments($data, $record, $search, $template, $sort, $page, $rid, $order, $group); } - //if this record is not yet approved, and database requires approval, print silly button } } @@ -899,8 +902,9 @@ function data_print_template($records, $data, $search, $template, $sort, $page=0 ************************************************************************/ function data_print_preference_form($data, $perpage, $search, $sort='', $order='ASC'){ echo '
'; - echo '
'; - echo ''; + echo ''; + echo ''; + echo ''; echo ''; echo ''. ''; @@ -945,27 +949,10 @@ function data_print_preference_form($data, $perpage, $search, $sort='', $order=' echo '
'.get_string('pagesize','data').':'; echo ''; echo '
'; + echo ''; echo '
'; } -//silly function that prints a button -function data_print_approve_button($recordid, $d, $page='0', $rid='0', $search='', $sort='', $order='') { - $str= '
'; - $str.= ''; - $str.= ''; - $str.= ''; - $str.= ''; - $str.= ''; - $str.= ''; - $str.= ''; - $str.= ''; - $str.= ''; - $str.= '
'; - return $str; -} - - -//silly function that prints the a form to do ratings function data_print_ratings($data, $record) { global $USER, $course; $ratingsmenuused = false; @@ -1118,7 +1105,6 @@ function data_print_comments($data, $record , $search, $template, $sort, $page=0 } } - //prints silly comment form echo '

'; echo ''; echo ''; diff --git a/mod/data/templates.php b/mod/data/templates.php index 24cfdc5cb6..5589e8aaf2 100755 --- a/mod/data/templates.php +++ b/mod/data/templates.php @@ -178,6 +178,7 @@ // Print special tags. echo ''; echo ''; + echo ''; echo ''; echo ''; echo ''; diff --git a/mod/data/view.php b/mod/data/view.php index dffe81f844..f7a778611f 100755 --- a/mod/data/view.php +++ b/mod/data/view.php @@ -35,6 +35,8 @@ $search = optional_param('search','',PARAM_NOTAGS); //search string $page = optional_param('page', 0, PARAM_INT); //offset of the current record $rid = optional_param('rid', 0, PARAM_INT); //record id + $approve = optional_param('approve', 0, PARAM_INT); //approval recordid + $delete = optional_param('delete', 0, PARAM_INT); //delete recordid $perpagemenu = optional_param('perpage1', 0, PARAM_INT); //value from drop down $sort = optional_param('sort',0,PARAM_INT); //sort by field $order = optional_param('order','ASC',PARAM_ALPHA); //sort order @@ -71,7 +73,7 @@ } //set user preference if available - if (isset($_POST['updatepref'])){ + if (isset($_GET['updatepref'])){ if (!$perpage = $perpagemenu){ //if menu not in use, use the text field $perpage = (int)optional_param('perpage',10); @@ -156,16 +158,23 @@ $currenttab = 'browse'; include('tabs.php'); -/// Print the browsing interface +/// Approve any requested records - if (optional_param('approved','0',PARAM_INT)) { - print_heading(get_string('recordapproved','data')); + if ($approve && confirm_sesskey() && isteacher($course->id)) { + if ($record = get_record('data_records', 'id', $approve)) { // Need to check this is valid + if ($record->dataid == $data->id) { // Must be from this database + $newrecord->id = $record->id; + $newrecord->approved = 1; + if (update_record('data_records', $newrecord)) { + notify(get_string('recordapproved','data'), 'notifysuccess'); + } + } + } } - /*************************** - * code to delete a record * - ***************************/ - if (($delete = optional_param('delete',0,PARAM_INT)) && confirm_sesskey()) { +/// Delete any requested records + + if ($delete && confirm_sesskey()) { if (isteacheredit($course) or data_isowner($delete)){ if ($confirm = optional_param('confirm',0,PARAM_INT)) { if ($contents = get_records('data_content','recordid', $delete)) { @@ -193,7 +202,7 @@ } } - //if not editting teacher, check whether user has sufficient records to view +// If not editting teacher, check whether user has sufficient records to view if (!isteacheredit($course->id) and data_numentries($data) < $data->requiredentriestoview){ notify (($data->requiredentriestoview - data_numentries($data)).' '.get_string('insufficiententries','data')); echo ''; -- 2.39.5