This forum is for module development and code related questions, not general module support. For general support, use the Post installation forum.

Create a block with this code

Hi !
I'd like to create a block with this code but I get an error message related to the Drupal code eval or something like that...

Could you tell me what's wrong with it ?


<?
require("http://radioanda.org/play/config.php");

$db->open("SELECT songlist.*, historylist.listeners as listeners, historylist.requestID as requestID, historylist.date_played as starttime FROM historylist,songlist WHERE (historylist.songID = songlist.ID) AND (songlist.songtype='S') ORDER BY historylist.date_played DESC",6);
$history = $db->rows();
reset($history);

$db->open("SELECT songlist.*, queuelist.requestID as requestID FROM queuelist, songlist WHERE (queuelist.songID = songlist.ID) AND (songlist.songtype='S') AND (songlist.artist <> '') ORDER BY queuelist.sortID ASC",2);
$queue = $db->rows();
reset($queue);

//### Calculate the bezt time to refresh the webpage in order to show new updated song information
//==================================================================================================
list($key, $song) = each($history);
$listeners = $song["listeners"];

$starttime = strtotime($song["date_played"]);
$curtime = time();
$timeleft = $starttime+round($song["duration"]/1000)-$curtime;

//Set refesh interval
if($timeleft>0) # 30 second minimum wait
{ $timeout = $timeleft;} # if timeleft is valid, refresh on timeleft (should be end of song)
else
{ $timeout = 90; } # otherwise, fall back on 90 second refresh

if(($timeout>180) or ($timeout==0)) $timeout = 180;
if($timeout<30) $timeout = 30;

$refreshURL = "index.php?buster=".date('dhis').rand(1,1000);
//==================================================================================================

$pic_cnt = 0;
function PicName()
{
global $pic_cnt;
echo "Picture".$pic_cnt;
}

function NextPicName()
{
global $pic_cnt;
$pic_cnt += 1;
PicName();
}

function PutSongRow(&$song)
{
global $rc, $showpic, $darkrow, $lightrow;
PrepareSong($song);

$rc++;
$bgcolor = $darkrow;
if(($rc % 2)==0) $bgcolor = $lightrow;

?>

<?echo $song["artist"]; ?>

<? echo $song["title"]; ?>

<?if($showpic){?>
<? if($song["haspicture"]) {?>
Only local images are allowed." onError="PictureFail('<? PicName(); ?>')" src="<? echo $song["picture"]; ?>" alt="Cliquez sur cette image pour écouter Anda.">
<?};?>
<?}?> En ce moment sur Anda, on écoute
<?if(!$showpic) echo "colspan=2"?> <? echo $song["title"]; echo " par "; echo $song["artist"]; ?>.
Cliquez ici pour lancer la lecture et rejoindre les autres auditeurs.

New profile.module number field giving me fits in the views module

Description

I've made an additional field in the profile.module to enter and validate numbers (something I *can't* wait to submit - hopefully to be adopted quickly). But, before that I wanted it to play nice with the views.module.

The profile.module stores its information using an EAV data model - therefore my numbers are being stored as text in the database. To make the numbers sort correctly they will need to be converted from text into numbers in the SQL statement...

I've discovered that MySQL 4.1 doesn't support CAST very well (there is no CAST AS DECIMAL), but you can trick MySQL into the conversion by adding 0 to the text value and MySQL will convert on the fly:

This statement will sort the numbers stored as text correctly:
SELECT value FROM {profile_values} WHERE fid = %d ORDER BY (value + 0) DESC

as opposed to:
SELECT value FROM {profile_values} WHERE fid = %d ORDER BY value DESC

So, I'm stuck with the specific question:
How do you write a views handler that changes 'value' to '(value +0)' ?

I've got this far:
<?php
function views_handler_filter_profile_number($op, $filter, $filterinfo, &$query) {

switch ($op) {
case 'handler':
$table = 'profile_value';
$column = 'value';
$query->ensure_table($table);
$field = "$table.$column";

$operator = $filter['operator'];
$where = "(%s + 0) $operator %s";

Extended characters (as select options in a form)

I'm implementing the hook_form() in a module and need to pass some special characters as options to a select box.

Special characters like & are converted to it's "name code" (&amp;) while characters like pund sign (£) or one-half (½) are not.

Since & is converted I can't pass the name-code for the special characters.

If anyone knows how I can get those special characters to appear in the select list I would highly appreciate the help.

Importing Nodes

I was tasked with developing an import tool to pull over our 40,000+ items from our old database. There is a lot of variety to how our old data has been stored, so our nodes had to match the old models and our import tool had to account for this. Also, we have a lot of information that would benefit from being cross-referenced (e.g. 35,000 contacts shared and used as node references for the 40,000 pieces).

So, I tried using the ImportExport API and I ran into wall with it. We needed to be able to take one piece of source data and export it as many nodes as neccessary (e.g. 1 piece and its 4 supporting nodes). As the export builds its data, it makes node ids. makes nodes for them and then puts them in as references in the "main" node. My working title for this module is "direct_node_import" and I have written it for 4.7x with an eye to importing CCK created content-types.

Decisions/Assumptions:
- Expect that command line executions will be common. When dealing with large record sets, it could take hours to process
- Expect that the import destination will be remote. In our case, the old server and the new server are 7,000 miles apart. The old server is unlikely to handle Drupal well, so the export work is done there and the import work is done on the new server
- Use the import site as the source for import directives and taxonomy. To this end, I built in a way to export individual taxonomy references. The exporting site will store these and use them so that it makes the fewest trips possible.

Placing divs in forms in 4.7

I have a module I wrote for Drupal 4.6 where within the edit form I have a DIV that gets rewritten by Javascript. In the 4.6 hook_form, since it just outputs the HTML directly, this was trivially easy to do.

Sugar anyone?

I am looking to create a module or some type of lightweight integration between Drupal and SugarCRM. Anyone interested in helping with this? I'm not too familiar with SOAP, which SugarCRM offers as its webservice, so any help would be greatly appreciated.

SugarCRM is an excellent Client Relationship Management system, definitely the best open source CRM out there. (no offense to CiviCRM, which is so dearly loved by the Drupal community.) Anyway, it's about time Drupal had a module that integrated with Sugar.

Pages

Subscribe with RSS Subscribe to RSS - Module development and code questions