Google Groups Home
Help | Sign in
Bug in ...field/class.upload.php?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
agnul  
View profile
 More options Jul 8, 10:02 am
From: agnul <sucr...@gmail.com>
Date: Tue, 8 Jul 2008 07:02:28 -0700 (PDT)
Local: Tues, Jul 8 2008 10:02 am
Subject: Bug in ...field/class.upload.php?
Hi,

In our docebo installation we've added a few custom fields to the
teacher's profiles. One of those is an upload field, allowing to
upload a cv file. When I look at the teacher profile I would expect
the link next to the "browse" button to point to the uploaded file if
any, but instead I get a 404. The URL I have is

    .../doceboCore/
fo=special&type_field=upload&id_user=20427&id_common=19

I guess something is missing between "doceboCore" and "fo=special",
and looking at the code I guess that getUrl() for upload fields
returns an empty string. This could be because setUrl() is never
called when creating fields via "eval ('return new...')" in
lib.field.php. Any idea how to fix that?

Thanks in advance.
A.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Fabio Pirovano  
View profile
 More options Jul 9, 4:33 am
From: Fabio Pirovano <fa...@docebo.com>
Date: Wed, 09 Jul 2008 10:33:04 +0200
Local: Wed, Jul 9 2008 4:33 am
Subject: Re: [docebo-int] Bug in ...field/class.upload.php?

Hi Agnul,
    i have fixed this some time ago, i think that the attached file is
the only thing that i have modify in order to fix this

put it in : doceboCore/modules/field/

Cya,
Fabio

agnul ha scritto:

--
Fabio Pirovano

Docebo SRL - The open source e-learning company
Tel. +39 039-2323286
Fax  +39 039-3309936
http://www.docebo.com

[ class.upload.php 23K ]
*/ require_once(dirname(__FILE__).'/class.field.php'); class Field_Upload extends Field { /** * class constructor */ function Field_Upload($id_common) { parent::Field($id_common); } /** * this function is useful for field recognize * * @return string return the identifier of the field * * @access public */ function getFieldType() { return 'upload'; } /** * this function create a new field for future use * * @param string $back indicates the return url * @return nothing * * @access public */ function create($back) { $back_coded = htmlentities(urlencode($back)); $array_lang = array(); $std_lang =& DoceboLanguage::createInstance('standard'); $lang =& DoceboLanguage::createInstance('field'); $array_lang = $GLOBALS['globLangManager']->getAllLangCode(); $out =& $GLOBALS['page']; if(isset($_POST['undo'])) { //undo action jumpTo($back.'&result=undo'); } if(isset($_POST['save_field_'.$this->getFieldType()])) { //insert mandatory translation $mand_lang = getLanguage(); if(isset($_POST['show_on_platform'])) { while(list($code, ) = each($_POST['show_on_platform'])) $show_on .= $code.','; } //insert mandatory translation $mand_lang = getLanguage(); //control if all is ok if(!isset($_POST['new_upload'][$mand_lang])) { $out->add( getErrorUi($lang->def('_ERR_MUST_DEF_MANADATORY_TRANSLATION')) .getBackUi($this->getUrl().'&type_field=' .$this->getFieldType().'&back='.$back_coded, $std_lang->def('_BACK')), 'content' ); return; } if($_POST['new_upload'][$mand_lang] == $lang->def('_NEW_FIELD') || trim($_POST['new_upload'][$mand_lang]) == '') { $out->add( getErrorUi($lang->def('_ERR_MUST_DEF_MANADATORY_TRANSLATION')) .getBackUi($this->getUrl().'&type_field=' .$this->getFieldType().'&back='.$back_coded, $std_lang->def('_BACK')), 'content' ); return; } //insert mandatory field if(!mysql_query(" INSERT INTO ".$this->_getMainTable()." (type_field, lang_code, translation, show_on_platform, use_multilang) VALUES ('".$this->getFieldType()."', '".$mand_lang."', '".$_POST['new_upload'][$mand_lang]."', '".$show_on."', '".$use_multilang."') ")) { jumpTo($back.'&result=fail'); } list($id_common) = mysql_fetch_row(mysql_query("SELECT LAST_INSERT_ID()")); if(!mysql_query(" UPDATE ".$this->_getMainTable()." SET id_common = '".(int)$id_common."' WHERE idField = '".(int)$id_common."'")) { jumpTo($back.'&result=fail'); } $re = true; //insert other field foreach($_POST['new_upload'] as $lang_code => $translation) { if($mand_lang != $lang_code && $translation != $lang->def('_NEW_FIELD') && trim($translation) != '') { $re_ins = mysql_query(" INSERT INTO ".$this->_getMainTable()." (type_field, id_common, lang_code, translation, show_on_platform, use_multilang) VALUES ('".$this->getFieldType()."', '".(int)$id_common."', '".$lang_code."', '".$translation."', '".$show_on."', '".$use_multilang."') "); $re = $re && $re_ins; } } jumpTo($back.'&result='.( $re ? 'success' : 'fail')); } require_once($GLOBALS['where_framework'].'/lib/lib.form.php'); $form = new Form(); $out->setWorkingZone('content'); $out->add('

'); $out->add( $form->getFormHeader($lang->def('_NEW_UPLOAD')) .$form->openForm('create_'.$this->getFieldType(), $this->getUrl()) .$form->openElementSpace() .$form->getHidden('type_field', 'type_field', $this->getFieldType()) .$form->getHidden('back', 'back', $back_coded) ); $mand_lang = getLanguage(); foreach($array_lang as $k => $lang_code ) { $out->add( $form->getTextfield(( ($mand_lang == $lang_code) ? '*' : '' ).$lang_code, 'new_upload_'.$lang_code, 'new_upload['.$lang_code.']', 255, '', $lang_code.' '.$lang->def('_NEW_FIELD') ) ); } $GLOBALS['page']->add($this->getMultiLangCheck(), 'content'); $GLOBALS['page']->add($this->getShowOnPlatformFieldset(), 'content'); $out->add( $form->closeElementSpace() .$form->openButtonSpace() .$form->getButton('save_field', 'save_field_'.$this->getFieldType(), $std_lang->def('_CREATE', 'standard')) .$form->getButton('undo', 'undo', $std_lang->def('_UNDO', 'standard')) .$form->closeButtonSpace() .$form->closeForm() ); $out->add('
'); } /** * this function manage a field * * @param string $back indicates the return url * @return nothing * * @access public */ function edit( $back ) { $back_coded = htmlentities(urlencode($back)); $array_lang = array(); $std_lang =& DoceboLanguage::createInstance('standard'); $lang =& DoceboLanguage::createInstance('field'); $array_lang = $GLOBALS['globLangManager']->getAllLangCode(); $out =& $GLOBALS['page']; if(isset($_POST['undo'])) { //undo action jumpTo($back.'&result=undo'); } if(isset($_POST['save_field_'.$this->getFieldType()])) { //insert mandatory translation $mand_lang = getLanguage(); //control if all is ok if(!isset($_POST['new_upload'][$mand_lang])) { $out->add( getErrorUi($lang->def('_ERR_MUST_DEF_MANADATORY_TRANSLATION')) .getBackUi($this->getUrl().'&type_field=' .$this->getFieldType().'&back='.$back_coded, $std_lang->def('_BACK')), 'content' ); return; } if($_POST['new_upload'][$mand_lang] == $lang->def('_NEW_FIELD') || trim($_POST['new_upload'][$mand_lang]) == '') { $out->add( getErrorUi($lang->def('_ERR_MUST_DEF_MANADATORY_TRANSLATION')) .getBackUi($this->getUrl().'&type_field=' .$this->getFieldType().'&back='.$back_coded, $std_lang->def('_BACK')), 'content' ); return; } $existsing_translation = array(); $re_trans = mysql_query(" SELECT lang_code FROM ".$this->_getMainTable()." WHERE id_common = '".$this->id_common."'"); while(list($l_code) = mysql_fetch_row($re_trans)) { $existsing_translation[$l_code] = 1; } $use_multilang =(isset($_POST['use_multi_lang']) ? 1 : 0); $re = true; if(isset($_POST['show_on_platform'])) { while(list($code, ) = each($_POST['show_on_platform'])) $show_on .= $code.','; } //insert other field foreach($_POST['new_upload'] as $lang_code => $translation) { if(isset($existsing_translation[$lang_code])) { if(!mysql_query(" UPDATE ".$this->_getMainTable()." SET translation = '".$translation."', show_on_platform = '".$show_on."', use_multilang = '".$use_multilang."' WHERE id_common = '".(int)$this->id_common."' AND lang_code = '".$lang_code."'")) $re = false; } else { if(!mysql_query(" INSERT INTO ".$this->_getMainTable()." (type_field, id_common, lang_code, translation, show_on_platform, use_multilang) VALUES ('".$this->getFieldType()."', '".(int)$this->id_common."', '".$lang_code."', '".$translation."', '".$show_on."', '".$use_multilang."') ")) $re= false; } } jumpTo($back.'&result='.( $re ? 'success' : 'fail')); } //load value form database $re_trans = mysql_query(" SELECT lang_code, translation, show_on_platform, use_multilang FROM ".$this->_getMainTable()." WHERE id_common = '".$this->id_common."'"); while(list($l_code, $trans, $show_on, $db_use_multilang) = mysql_fetch_row($re_trans)) { $translation[$l_code] = $trans; if(!isset($show_on_platform)) $show_on_platform = array_flip(explode(',', $show_on)); if(!isset($use_multilang)) $use_multilang = $db_use_multilang; } require_once($GLOBALS['where_framework'].'/lib/lib.form.php'); $form = new Form(); $out->setWorkingZone('content'); $out->add('
'); $out->add( $form->getFormHeader($lang->def('_MODIFY_UPLOAD')) .$form->openForm('create_'.$this->getFieldType(), $this->getUrl()) .$form->openElementSpace() .$form->getHidden('type_field', 'type_field', $this->getFieldType()) .$form->getHidden('id_common', 'id_common', $this->id_common) .$form->getHidden('back', 'back', $back_coded) ); $mand_lang = getLanguage(); foreach($array_lang as $k => $lang_code ) { $out->add( $form->getTextfield(( ($mand_lang == $lang_code) ? '*' : '' ).$lang_code, 'new_upload_'.$lang_code, 'new_upload['.$lang_code.']', 255, ( isset($translation[$lang_code]) ? $translation[$lang_code] : '' ), $lang_code.' '.$lang->def('_NEW_FIELD') ) ); } $GLOBALS['page']->add($this->getMultiLangCheck($use_multilang), 'content'); $GLOBALS['page']->add($this->getShowOnPlatformFieldset($show_on_platform), 'content'); $out->add( $form->closeElementSpace() .$form->openButtonSpace() .$form->getButton('save_field', 'save_field_'.$this->getFieldType(),
...

read more »


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
agnul  
View profile
 More options Jul 15, 7:02 am
From: agnul <sucr...@gmail.com>
Date: Tue, 15 Jul 2008 04:02:04 -0700 (PDT)
Local: Tues, Jul 15 2008 7:02 am
Subject: Re: Bug in ...field/class.upload.php?
Thanks!

that fixed the problem, but now I'm experiencing some inconsistent
behavior... I can upload and download file all right when using the
administration panel, but accessing the user profile via the "my
profile" link I get the wrong URL for uploaded files. What I get is

  .../doceboLms/index.php?modname=field&op=manage...

while I think I should be getting

  .../doceboCore/index.php?modname=field&op=manage...

What's wrong? Did I need to copy the fixed class.upload.php file into
docemoLms too?

Thanks in advance,
Angelo.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google