We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 29039
    • 58 Posts
    BUG
    FDM in page with editorpageid can edit them self or unpublish or delete.

    for my mind the best is dont show buton bar in page with editorpageid and forbid FDM make any actions when id = editorpageid.

    UPD. SOLVED!
    case ’none’: // render the links action bar
    if ($this->doc[’id’] != $this->config[’editorpageid’]){
    $tpl = new FDMCChunkie($this->templates[’link’][’tpl’]);
    $tpl->AddVar(’user’,$this->user);
    $tpl->AddVar(’link’,$this->link);
    $tpl->AddVar(’doc’,$this->doc);
    $links[] = $tpl->Render();
    $output_links = join(’’,$links);
    echo $output_links;
    //unset($_SESSION[’fdm’]);
    $this->debug_run (’fdm id’, $this->config[’md5’]);
    } break;
    Just add if ($this->doc[’id’] != $this->config[’editorpageid’]) before rendering buttons bar
      • 27889
      • 415 Posts
      Sorry, but I was not at home last week.
      @swit4er
      What do you mean by :
      we need action placeholder in chunk to work with TV.

        MODx Sites & Prestations: http://dp-site.fr [Last MODx Site]
        MODx Repository: [HOME] [MetaTagsExtra] / Current Dev: [xFDM]
        • 29039
        • 58 Posts
        Hi Soda!
        First of all.
        Its snipet for FDM tvfields beta.

        <?php
        $docid=isset($docid)?$docid:'214';
        $field_name=isset($field_name)?$field_name:'drop';
        	
        	if (!function_exists('ParseIntputOptionsTV')){function ParseIntputOptionsTV($v) {
        		$a = array();
        		if(is_array($v)) return $v;
        		else if(is_resource($v)) {
        			while ($cols = mysql_fetch_row($v)) $a[] = $cols;
        		}
        		else $a = explode("||", $v);
        		return $a;
        	}
                }
        	
        	
        	$rs = $modx->db->select("id, type, caption, description, elements, default_text", $modx->getFullTableName('site_tmplvars'), "name = '$field_name'");
        	$limit = mysql_num_rows($rs);
        	if ($limit != 1) { echo "TV с именем '$field_name' отсутствует, или произошло задвоение имен TV."; }
        	else {
        	$tvfields = mysql_fetch_assoc($rs);
        	$tvid = $tvfields['id'];
        	$field_type = $tvfields['type'];
        	$field_caption = $tvfields['caption'];
        	$field_description = $tvfields['description'];
        	$field_elements = $tvfields['elements'];
        	$field_default_text = $tvfields['default_text'];
        	}
        	
        	$rs = $modx->db->select("value", $modx->getFullTableName('site_tmplvar_contentvalues'), "tmplvarid = '$tvid' and contentid = '$docid'");
        	$limit = mysql_num_rows($rs);
        	if ($limit != 1) {echo "Ошибка значения TV";}
        	else {
        	$field = mysql_fetch_assoc($rs);
        	$field_value = $field['value'];
        	}
        	
        	$field_html ='';
        		
        		switch ($field_type) {
        
        			case "text": // handler for regular text boxes
        			case "rawtext"; // non-htmlentity converted text boxes
        			case "email": // handles email input fields
        			case "number": // handles the input of numbers
        				$field_html .=  '<input type="text" id="tv'.$field_name.'" name="tv'.$field_name.'" value="'.htmlspecialchars($field_value).'" style="width:100%" />';
        				break;
        			case "textareamini": // handler for textarea mini boxes
        				$field_html .=  '<textarea id="tv'.$field_name.'" name="tv'.$field_name.'" cols="40" rows="5" style="width:100%">' . htmlspecialchars($field_value) .'</textarea>';
        				break;
        			case "textarea": // handler for textarea boxes
        			case "rawtextarea": // non-htmlentity convertex textarea boxes
        			case "htmlarea": // handler for textarea boxes (deprecated)
        			case "richtext": // handler for textarea boxes
        				$field_html .=  '<textarea id="tv'.$field_name.'" name="tv'.$field_name.'" cols="40" rows="15" style="width:100%;">' . htmlspecialchars($field_value) .'</textarea>';
        				break;
        			case "date":
                        if($field_value=='') $field_value=0;
                        $cal = 'cal' . $field_name;
        
        				$field_html .=  '<input id="tv'.$field_name.'" name="tv'.$field_name.'" type="hidden" value="' . ($field_value==0 || !isset($field_value) ? "" : $field_value) . '">';
        
        				$field_html .=  '	<table width="250" border="0" cellspacing="0" cellpadding="0">';
        				$field_html .=  '	  <tr>';
        				$field_html .=  '		<td width="160" style="border: 1px solid #808080;"><span id="tv'.$field_name.'_show" class="inputBox"> ' . ($field_value==0 || !isset($field_value) ? '(not set)' : $field_value) . '</span> </td>';
        
        				$field_html .=  '		<td> ';
        				$field_html .=  '			<a onClick="documentDirty=false; '.$cal.'.popup();" onMouseover="window.status=\'Select a date\'; return true;" onMouseout="window.status=\'\'; return true;" style="cursor:pointer; cursor:hand"><img src="media/style/'.($manager_theme ? "$manager_theme/":"").'images/icons/cal.gif" width="16" height="16" border="0"></a>';
        				$field_html .=  '			<a onClick="document.forms[\'mutate\'].elements[\'tv'.$field_name.'\'].value=\'\';document.forms[\'mutate\'].elements[\'tv'.$field_name.'\'].onblur();document.getElementById(\'tv'.$field_name.'_show\').innerHTML=\'(not set)\'; return true;" onMouseover="window.status=\'clear the date\'; return true;" onMouseout="window.status=\'\'; return true;" style="cursor:pointer; cursor:hand"><img src="media/style/'.($manager_theme ? "$manager_theme/":"").'images/icons/cal_nodate.gif" width="16" height="16" border="0" alt="No date"></a>';
        
        				$field_html .=  '		</td>';
        				$field_html .=  '	  </tr>';
        				$field_html .=  '    </table>';
        
        				$field_html .=  '<script type="text/javascript">';
        				$field_html .=  '	var '.$cal.' = new calendar1(document.forms[\'mutate\'].elements[\'tv'.$field_name.'\'], document.getElementById("tv'.$field_name.'_show"));';
        				$field_html .=  '   '.$cal.'.path="' . str_replace("index.php", "media/", $_SERVER["PHP_SELF"]) . '";';
        
        				$field_html .=  '	'.$cal.'.year_scroll = true;';
        				$field_html .=  '   '.$cal.'.time_comp = true;';
        
        				$field_html .=  '</script>';
        
        				break;
        // select (dropdown)
        			case "dropdown":
        				
        				if (!$field_value && $field_default_text) {
        				list($default_item, $default_itemvalue) = explode("==",$field_default_text);
        				if (strlen($default_itemvalue)==0) $default_itemvalue = $default_item;
        				$field_value = $default_itemvalue;
        				}
        				$field_html .=  '<select id="tv'.$field_name.'" name="tv'.$field_name.'" size="1">';
        				$index_list = ParseIntputOptionsTV($field_elements);
        				while (list($item, $itemvalue) = each ($index_list))
        				{
        					list($item,$itemvalue) =  (is_array($itemvalue)) ? $itemvalue : explode("==",$itemvalue);
        					if (strlen($itemvalue)==0) $itemvalue = $item;
        					$field_html .=  '<option value="'.htmlspecialchars($itemvalue).'"'.($itemvalue==$field_value ?' selected="selected"':'').'>'.htmlspecialchars($item).'</option>';
        				}
        				$field_html .=  "</select>";
        				break;
        // select (listbox)
        			case "listbox":
        				$field_html .=  '<select id="tv'.$field_name.'" name="tv'.$field_name.'" size="8">';	
        				$index_list = ParseIntputOptionsTV($field_elements);
        				while (list($item, $itemvalue) = each ($index_list))
        				{
        					list($item,$itemvalue) =  (is_array($itemvalue)) ? $itemvalue : explode("==",$itemvalue);
        					if (strlen($itemvalue)==0) $itemvalue = $item;
        					$field_html .=  '<option value="'.htmlspecialchars($itemvalue).'"'.($itemvalue==$field_value ?' selected="selected"':'').'>'.htmlspecialchars($item).'</option>';
        				}
        				$field_html .=  "</select>";
        				break;
        // multiple select
        			case "listbox-multiple":
        			
        				if (!$field_value && $field_default_text) {
        				$field_default_text_index = explode("||",$field_default_text);
        //				$field_default_text_index = ParseIntputOptionsTV($field_default_text);
        				$field_value = "";
        				while (list($default_item, $default_itemvalue) = each($field_default_text_index))
        				{
        				list($default_item,$default_itemvalue) =  (is_array($default_itemvalue)) ? $default_itemvalue : explode("==",$default_itemvalue);
        				if (strlen($default_itemvalue)==0) $default_itemvalue = $default_item;
        				$field_value .= '|| '.$default_itemvalue.'';
        //				$field_value = $default_itemvalue;
        //				echo $field_value;
        				}
        //				$field_value = implode("||",$field_value);
        //				$field_value .= "";
        				}
        //				echo $field_value;
        				
        				$field_value = explode("||",$field_value);
        				$field_html .=  '<select id="tv'.$field_name.'[]" name="tv'.$field_name.'[]" multiple="multiple" size="8">';
        				$index_list = ParseIntputOptionsTV($field_elements);
        				while (list($item, $itemvalue) = each ($index_list))
        				{
        					list($item,$itemvalue) =  (is_array($itemvalue)) ? $itemvalue : explode("==",$itemvalue);
        					if (strlen($itemvalue)==0) $itemvalue = $item;
        					$field_html .=  '<option value="'.htmlspecialchars($itemvalue).'"'.(in_array($itemvalue,$field_value) ?' selected="selected"':'').'>'.htmlspecialchars($item).'</option>';
        				}
        				$field_html .=  "</select>";
        				
        				break;
        // url input fields
        				case "url":
        				$urls= array(''=>'--', 'http://'=>'http://', 'https://'=>'https://', 'ftp://'=>'ftp://', 'mailto:'=>'mailto:');
        				$field_html ='<table border="0" cellspacing="0" cellpadding="0"><tr><td><select id="tv'.$field_name.'_prefix" name="tv'.$field_name.'_prefix" onchange="documentDirty=true; setVariableModified(\''.$field_name.'\');">';
        				foreach($urls as $k => $v){
        					if(strpos($field_value,$v)===false) $field_html.='<option value="'.$v.'">'.$k.'</option>';
        					else{
        						$field_value = str_replace($v,"",$field_value);
        						$field_html.='<option value="$v" selected="selected">'.$k.'</option>';
        					}
        				}
        				$field_html .='</select></td><td>';
        				$field_html .=  '<input type="text" id="tv'.$field_name.'" name="tv'.$field_name.'" value="'.htmlspecialchars($field_value).'" width="100" /></td></tr></table>';
        				break;
        // check boxes
        			case "checkbox":
        			
        			
        			
        				if (!$field_value && $field_default_text) {
        				$field_default_text_index = explode("||",$field_default_text);
        //				$field_default_text_index = ParseIntputOptionsTV($field_default_text);
        				$field_value = "";
        				while (list($default_item, $default_itemvalue) = each($field_default_text_index))
        				{
        				list($default_item,$default_itemvalue) =  (is_array($default_itemvalue)) ? $default_itemvalue : explode("==",$default_itemvalue);
        				if (strlen($default_itemvalue)==0) $default_itemvalue = $default_item;
        				$field_value .= '|| '.$default_itemvalue.'';
        //				$field_value = $default_itemvalue;
        //				echo $field_value;
        				}
        //				$field_value = implode("||",$field_value);
        //				$field_value .= "";
        				}
        				echo $field_value;
        			
        			
        				$field_value = explode("||",$field_value);
        				$index_list = ParseIntputOptionsTV($field_elements);
        				static $i=0;
        				while (list($item, $itemvalue) = each ($index_list))
        				{
        					list($item,$itemvalue) =  (is_array($itemvalue)) ? $itemvalue : explode("==",$itemvalue);
        					if (strlen($itemvalue)==0) $itemvalue = $item;
        					$field_html .=  '<input type="checkbox" value="'.htmlspecialchars($itemvalue).'" id="tv_'.$i.'" name="tv'.$field_name.'[]" '. (in_array($itemvalue,$field_value)?" checked='checked'":"").' /><label for="tv_'.$i.'">'.$item.'</label><br />';
        					$i++;
        				}
        				break;
        // radio buttons (option)
        			case "option":
        				$index_list = ParseIntputOptionsTV($field_elements);
        				while (list($item, $itemvalue) = each ($index_list))
        				{
        					list($item,$itemvalue) =  (is_array($itemvalue)) ? $itemvalue : explode("==",$itemvalue);
        					if (strlen($itemvalue)==0) $itemvalue = $item;
        					$field_html .=  '<input type="radio" value="'.htmlspecialchars($itemvalue).'" name="tv'.$field_name.'" '.($itemvalue==$field_value ?'checked="checked"':'').' />'.$item.'<br />';
        				}
        				break;
        // image fields (image manager)
        			case "image":
        				global $_lang;
        				global $ResourceManagerLoaded;
        				global $content,$use_editor,$which_editor;
        				if (!$ResourceManagerLoaded && !(($content['richtext']==1 || $_GET['a']==4) && $use_editor==1 && $which_editor==3)){ 
        					$field_html .="
        					<script type=\"text/javascript\">
        							var lastImageCtrl;
        							var lastFileCtrl;
        							function OpenServerBrowser(url, width, height ) {
        								var iLeft = (screen.width  - width) / 2 ;
        								var iTop  = (screen.height - height) / 2 ;
        
        								var sOptions = 'toolbar=no,status=no,resizable=yes,dependent=yes' ;
        								sOptions += ',width=' + width ;
        								sOptions += ',height=' + height ;
        								sOptions += ',left=' + iLeft ;
        								sOptions += ',top=' + iTop ;
        
        								var oWindow = window.open( url, 'FCKBrowseWindow', sOptions ) ;
        							}			
        							function BrowseServer(ctrl) {
        								lastImageCtrl = ctrl;
        								var w = screen.width * 0.7;
        								var h = screen.height * 0.7;
        								OpenServerBrowser('".$base_url."manager/media/browser/mcpuk/browser.html?Type=images&Connector=".$base_url."manager/media/browser/mcpuk/connectors/php/connector.php&ServerPath=".$base_url."', w, h);
        							}
        							
        							function BrowseFileServer(ctrl) {
        								lastFileCtrl = ctrl;
        								var w = screen.width * 0.7;
        								var h = screen.height * 0.7;
        								OpenServerBrowser('".$base_url."manager/media/browser/mcpuk/browser.html?Type=files&Connector=".$base_url."manager/media/browser/mcpuk/connectors/php/connector.php&ServerPath=".$base_url."', w, h);
        							}
        							
        							function SetUrl(url, width, height, alt){
        								if(lastFileCtrl) {
        									var c = document.mutate[lastFileCtrl];
        									if(c) c.value = url;
        									lastFileCtrl = '';
        								} else if(lastImageCtrl) {
        									var c = document.mutate[lastImageCtrl];
        									if(c) c.value = url;
        									lastImageCtrl = '';
        								} else {
        									return;
        								}
        							}
        					</script>";
        					$ResourceManagerLoaded  = true;					
        				} 
        				$field_html .='<input type="text" id="tv'.$field_name.'" name="tv'.$field_name.'"  value="'.$field_value .'" /> <input type="button" value="'.$_lang['insert'].'" onclick="setVariableModified(\''.$field_name.'\');BrowseServer(\'tv'.$field_name.'\')" />';
        				break;
        			case "file": // handles the input of file uploads
        			/* Modified by Timon for use with resource browser */
                        global $_lang;
        				global $ResourceManagerLoaded;
        				global $content,$use_editor,$which_editor;
        				if (!$ResourceManagerLoaded && !(($content['richtext']==1 || $_GET['a']==4) && $use_editor==1 && $which_editor==3)){
        				/* I didn't understand the meaning of the condition above, so I left it untouched ;-) */ 
        					$field_html .="
        					<script type=\"text/javascript\">
        							var lastImageCtrl;
        							var lastFileCtrl;
        							function OpenServerBrowser(url, width, height ) {
        								var iLeft = (screen.width  - width) / 2 ;
        								var iTop  = (screen.height - height) / 2 ;
        
        								var sOptions = 'toolbar=no,status=no,resizable=yes,dependent=yes' ;
        								sOptions += ',width=' + width ;
        								sOptions += ',height=' + height ;
        								sOptions += ',left=' + iLeft ;
        								sOptions += ',top=' + iTop ;
        
        								var oWindow = window.open( url, 'FCKBrowseWindow', sOptions ) ;
        							}
        							
        								function BrowseServer(ctrl) {
        								lastImageCtrl = ctrl;
        								var w = screen.width * 0.7;
        								var h = screen.height * 0.7;
        								OpenServerBrowser('".$base_url."manager/media/browser/mcpuk/browser.html?Type=images&Connector=".$base_url."manager/media/browser/mcpuk/connectors/php/connector.php&ServerPath=".$base_url."', w, h);
        							}
        										
        							function BrowseFileServer(ctrl) {
        								lastFileCtrl = ctrl;
        								var w = screen.width * 0.7;
        								var h = screen.height * 0.7;
        								OpenServerBrowser('".$base_url."manager/media/browser/mcpuk/browser.html?Type=files&Connector=".$base_url."manager/media/browser/mcpuk/connectors/php/connector.php&ServerPath=".$base_url."', w, h);
        							}
        							
        							function SetUrl(url, width, height, alt){
        								if(lastFileCtrl) {
        									var c = document.mutate[lastFileCtrl];
        									if(c) c.value = url;
        									lastFileCtrl = '';
        								} else if(lastImageCtrl) {
        									var c = document.mutate[lastImageCtrl];
        									if(c) c.value = url;
        									lastImageCtrl = '';
        								} else {
        									return;
        								}
        							}
        					</script>";
        					$ResourceManagerLoaded  = true;					
        				} 
        				$field_html .='<input type="text" id="tv'.$field_name.'" name="tv'.$field_name.'"  value="'.$field_value .'" /> <input type="button" value="'.$_lang['insert'].'" onclick="setVariableModified(\''.$field_name.'\');BrowseFileServer(\'tv'.$field_name.'\')" />';
                        
        				break;
        			default: // the default handler -- for errors, mostly
        				$field_html .=  '<input type="text" id="tv'.$field_name.'" name="tv'.$field_name.'" value="'.htmlspecialchars($field_value).'" />';
        
        		} // end switch statement
        	
        
        return $field_html;
        ?>


        With this you can realy edit any type of tv like: dropdown; listbox-multiple, check boxes, radio buttons and etc.
        Snipet can take defaul values.
        Usage: [[tvfields? &docid=[*id*] &field_name=listbox]] in FDM eform template, where &field_name - name of TV.
        But when i create new doc, i need model (model id to copy TV values) & action (realy i need ADD action identified for put default values in new doc TV) placeholders.
        Or we can integrate this snipet in FDM.
          • 6726
          • 7,075 Posts
          Cool addition swit4er, I’ll give this a try !
          Waow, this rocks grin
            .: COO - Commerce Guys - Community Driven Innovation :.


            MODx est l&#39;outil id
            • 27889
            • 415 Posts
            @swit4er
            action is available in session var: $_SESSION[’fdm’][’action’] or in $_GET[’fdmaction’] before the form is displayed.
            model is in $_SESSION[’fdm’][’model’]
              MODx Sites & Prestations: http://dp-site.fr [Last MODx Site]
              MODx Repository: [HOME] [MetaTagsExtra] / Current Dev: [xFDM]
              • 23050
              • 1,842 Posts
              Hi Soda,

              Great job you’ve done since the last time I try to install it ! I’ve almost achieved what I want... all is ok when I’m logged in the manager. I can see the form.

              But, when I’m anonymous, the form doesn’t show up.

              Here is my call :

              [!FDM? &parent=`2` &redirect=`11` &anonymous=`1` &eform_tpl=`fdmEformannu` &model=`0` &language=`french` &eform_to=`[email protected]` &eform_subject=`Nouveau communiqué sur l'annuaire déco` &eform_report=`ReportFDMForm` &disableedit=`1` &disablepublish=`1` &disableunpublish=`1` &disabledelete=`1`!]


              I’ve tried to add &canpost=`anonymous` (just to give a try :p) but didn’t work.

              Did you notice such a thing on your install ?

              Thank you smiley
                • 11975
                • 2,542 Posts
                Hi all,

                To fix the anonymous issue.
                Add in the snippet code around line #26

                $FDM->SetP('anonymous',$anonymous);
                


                :-)
                  Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
                  • 29039
                  • 58 Posts
                  security issue

                  :) easy hack, just puting ’ or " in fdmid parametr in URL, like
                  ?fdmaction=edit3906aaca2204bcbf366ebdb3aa1bc85a&fdmid=94’
                  and make any sql injection.... wink
                    • 23050
                    • 1,842 Posts
                    Thank you Helio wink

                    swit4er, do you know how to correct this issue ? Don’t want to put my website online until this is not corrected grin
                      • 29039
                      • 58 Posts
                      @Perrine: Sorry! I am on work now and have not time! Only in weekend.