<?php
require_once("CustomFieldAdminO.php");
require_once("ArtistAdminO.php");
require_once("ArtistAdminBiz.php");
require_once("ChartAdminDAO.php");
class ArtistAdminDAO{
var $db;
var $prefix;
var $error;
/**
* The constructor
* @param $db database connection
* @param $prefix tables prefix
* @author sergids
*/
function ArtistAdminDAO($db,$prefix="nuke"){
$this->db=$db;
$this->prefix=$prefix;
}
function insertArtist(&$artist,$language){
$name=(!get_magic_quotes_gpc())?addslashes($artist->getName()):$artist->getName();
$bornyear=$artist->getBornyear();
$deadyear=$artist->getDeadyear();
$genreid=$artist->getGenreid();
$photo=$artist->getPhoto();
$photo_file=$artist->getPhotoFile();
$web=$artist->getWeb();
$forum=$artist->getForum();
$members=$artist->getMembers();
if($members!="" && count($artistList)>0){
$artistList=ArtistAdminDAO::getSelectList();
if(count($artistList)>0){
foreach($artistList as $artist1){
$members=ereg_replace($artist1[1],"<a href=\"modules.php?name=topMusic&op=artist&idartist=".$artist1[0]."\">".$artist1[1]."</a>", $members);
}
}
$members=(!get_magic_quotes_gpc())?addslashes($members):$members;
}
$views=$artist->getCount();
$avgvotes=$artist->getAvgvotes();
$musicmoz_url=(!get_magic_quotes_gpc())?addslashes($artist->musicmoz_url):$artist->musicmoz_url;
$musicbrainz_url=(!get_magic_quotes_gpc())?addslashes($artist->musicbrainz_url):$artist->musicbrainz_url;
$sql="INSERT INTO ".$this->prefix."_topmusic_artist (name,photo,webpage,forumURL,members";
if($photo_file!="")
$sql.=",photo_file";
if($genreid!="" && is_numeric($genreid))
$sql.=",idgenre";
if($bornyear!="")
$sql.=",bornyear";
if($deadyear!="")
$sql.=",deadyear";
if($views!="" && is_numeric($views))
$sql.=",views";
if($musicmoz_url!="")
$sql.=",musicmoz_url";
if($musicbrainz_url!="")
$sql.=",musicbrainz_url";
$sql.=") VALUES ('".$name."','".$photo."','".$web."','".$forum."','".$members."'";
if($photo_file!="")
$sql.=",'".$photo_file."'";
if($genreid!="" && is_numeric($genreid))
$sql.=",".$genreid;
if($bornyear!="")
$sql.=",'".$bornyear."'";
if($deadyear!="")
$sql.=",'".$deadyear."'";
if($views!="" && is_numeric($views))
$sql.=",".$views;
if($musicmoz_url!="")
$sql.=",'".$musicmoz_url."'";
if($musicbrainz_url!="")
$sql.=",'".$musicbrainz_url."'";
$sql.=")";
//echo "sql1=".$sql."<br>";
$this->db->sql_query($sql);
$idart=$this->db->sql_nextid();
$artist->setId($idart);
$error=$this->db->sql_error();
$biography=$artist->biography;
if($error['message']==""){
if($biography!=""){
$artistList=ArtistAdminDAO::getSelectList();
if(count($artistList)>0){
//insert biography currentlang
foreach($artistList as $artist1){
$biography=ereg_replace($artist1[1],"<a href=\"modules.php?name=topMusic&op=artist&idartist=".$artist1[0]."\">".$artist1[1]."</a>", $biography);
}
}
$biography=(!get_magic_quotes_gpc())?addslashes($biography):$biography;
$sql="INSERT INTO ".$this->prefix."_topmusic_artist_lang (idartist,language,biography)
VALUES (".$idart.",'".$language."','".$biography."')";
//echo "sql2=".$sql;
$this->db->sql_query($sql);
$error=$this->db->sql_error();
}
if($error['message']==""){
return true;
}else
return false;
}else{
return false;
}
}
function updateArtist($artist,$language){
$idartist=$artist->getId();
$name=(!get_magic_quotes_gpc())?addslashes($artist->getName()):$artist->getName();
$bornyear=$artist->getBornyear();
$deadyear=$artist->getDeadyear();
$genreid=$artist->getGenreid();
$photo=$artist->getPhoto();
$photo_file=$artist->photo_file;
$web=$artist->getWeb();
$forum=$artist->getForum();
$members=$artist->getMembers();
$artistList=ArtistAdminDAO::getSelectList();
$members=(!get_magic_quotes_gpc())?addslashes($members):$members;
$views=$artist->getCount();
$biography=$artist->biography;
$sql="UPDATE ".$this->prefix."_topmusic_artist SET name='".$name."',photo='".$photo."',webpage='".$web."',forumURL='".$forum."',members='".$members."'";
$sql.=",photo_file='".$photo_file."'";
if($genreid!="" && is_numeric($genreid))
$sql.=",idgenre=".$genreid;
else
$sql.=",idgenre=NULL";
if($bornyear!="")
$sql.=",bornyear=".$bornyear;
if($deadyear!="")
$sql.=",deadyear=".$deadyear;
else
$sql.=",deadyear=NULL";
if($views!="" && is_numeric($views))
$sql.=",views=".$views;
$sql.=" WHERE idartist=".$idartist;
//echo "sql1=".$sql."<br>";
$this->db->sql_query($sql);
$error=$this->db->sql_error();
//die("mess=".$error['message']);
if($error['message']==""){
if($this->existsBiography($idartist,$language)){//if currentlang exists
//update biography currentlang
if($biography!=""){
$biography=(!get_magic_quotes_gpc())?addslashes($biography):$biography;
$sql="UPDATE ".$this->prefix."_topmusic_artist_lang SET biography='".$biography."' WHERE idartist=".$idartist." AND language='".$language."'";
}else{
$sql="DELETE FROM ".$this->prefix."_topmusic_artist_lang WHERE idartist=".$idartist." AND language='".$language."'";
}
}else{
if(count($artistList)>0){
//insert biography
foreach($artistList as $artist1){
$biography=ereg_replace($artist1[1],"<a href=\"modules.php?name=topMusic&op=artist&idartist=".$artist1[0]."\">".$artist1[1]."</a>", $biography);
}
}
$biography=(!get_magic_quotes_gpc())?addslashes($biography):$biography;
$sql="INSERT INTO ".$this->prefix."_topmusic_artist_lang (idartist,language,biography)
VALUES (".$idartist.",'".$language."','".$biography."')";
}
//echo "sql2=".$sql;
$this->db->sql_query($sql);
}
}
function deleteArtist($idartist){
$chartAdminDAO=new ChartAdminDAO($this->db,$this->prefix);
//del artist from all charts
$sSql="SELECT element.idchart, element.position FROM ".$this->prefix."_topmusic_chart_element element INNER JOIN ".$this->prefix."_topmusic_chart chart ON element.idchart=chart.idchart where chart.type='artist' and element.idelement=".$idartist;
$stmt=$this->db->sql_query($sSql);
while($rs=$this->db->sql_fetchrow($stmt)){
//delete chart element and recalculate positions
$chartAdminDAO->delElement($rs['idchart'],$idartist,$rs['position']);
}
$this->db->sql_freeresult($stmt);
//del all album and song related data
$sql="SELECT idalbum FROM ".$this->prefix."_topmusic_album WHERE idartist=".$idartist;
//echo "sql=$sql<br>";
$stmt1=$this->db->sql_query($sql,BEGIN_TRANSACTION);
while($rs1=$this->db->sql_fetchrow($stmt1)){
$idalbum=$rs1['idalbum'];
$sql="SELECT idsong FROM ".$this->prefix."_topmusic_song WHERE idalbum=".$idalbum;
$stmt2=$this->db->sql_query($sql);
while($rs2=$this->db->sql_fetchrow($stmt2)){
$idsong=$rs2['idsong'];
//del songs_relations
$sql="DELETE FROM ".$this->prefix."_topmusic_song_relation where idsong=".$idsong." OR idsong_related=".$idsong;
//echo "sql=$sql<br>";
$this->db->sql_query($sql);
//del song custom fields values
$sql="DELETE FROM ".$this->prefix."_topmusic_song_fields_values where idsong=".$idsong;
//echo "sql=$sql<br>";
$this->db->sql_query($sql);
//delete song votes
$sql="DELETE FROM ".$this->prefix."_topmusic_song_votes WHERE idsong=".$idsong;
//echo "sql=$sql<br>";
$this->db->sql_query($sql);
}
$this->db->sql_freeresult($stmt2);
//del songs
$sql="DELETE FROM ".$this->prefix."_topmusic_song WHERE idalbum=".$idalbum;
//echo "sql=$sql<br>";
$this->db->sql_query($sql);
//del album relations
$sql="DELETE FROM ".$this->prefix."_topmusic_album_relation where idalbum=".$idalbum." OR idalbum_related=".$idalbum;
//echo "sql=$sql<br>";
$this->db->sql_query($sql);
//del album custom fields values
$sql="DELETE FROM ".$this->prefix."_topmusic_album_fields_values where idalbum=".$idalbum;
//echo "sql=$sql<br>";
$this->db->sql_query($sql);
//del albums lang
$sql="DELETE FROM ".$this->prefix."_topmusic_album_lang WHERE idalbum=".$idalbum;
//echo "sql=$sql<br>";
$this->db->sql_query($sql);
//delete album votes
$sql="DELETE FROM ".$this->prefix."_topmusic_album_votes WHERE idalbum=".$idalbum;
//echo "sql=$sql<br>";
$this->db->sql_query($sql);
}
$this->db->sql_freeresult($stmt1);
//del albums
$sql="DELETE FROM ".$this->prefix."_topmusic_album WHERE idartist=".$idartist;
//echo "sql=$sql<br>";
$this->db->sql_query($sql);
//delete artists lang
$sql="DELETE FROM ".$this->prefix."_topmusic_artist_lang where idartist=".$idartist;
//echo "sql=$sql<br>";
$this->db->sql_query($sql);
//delete artists relations
$sql="DELETE FROM ".$this->prefix."_topmusic_artist_relation where idartist=".$idartist." OR idartist_related=".$idartist;
//echo "sql=$sql<br>";
$this->db->sql_query($sql);
//delete artists custom fields values
$sql="DELETE FROM ".$this->prefix."_topmusic_artist_fields_values WHERE idartist=".$idartist;
//echo "sql=$sql<br>";
$this->db->sql_query($sql);
//delete artists votes
$sql="DELETE FROM ".$this->prefix."_topmusic_artist_votes WHERE idartist=".$idartist;
//echo "sql=$sql<br>";
$this->db->sql_query($sql);
//delete artists
$sql="DELETE FROM ".$this->prefix."_topmusic_artist where idartist=".$idartist;
//echo "sql=$sql<br>";
$this->db->sql_query($sql,END_TRANSACTION);
}
function getArtistIndex(){
$sSql=" SELECT
".$this->prefix."_topmusic_artist.idartist,
".$this->prefix."_topmusic_artist.name
FROM
".$this->prefix."_topmusic_artist";
//echo "sql=".$sSql."<br>";
$stmt=$this->db->sql_query($sSql);
$i=0;
while($rs=$this->db->sql_fetchrow($stmt)){
$artistOi=new ArtistAdminO();
$artistOi->setId($rs['idartist']);
$artistOi->setName($rs['name']);
$artistList[$i]=$artistOi;
$i++;
}
$this->db->sql_freeresult($stmt);
return $artistList;
}
function getArtist($id,$language){
$artistOg=new ArtistAdminO();
$sSql="
SELECT
".$this->prefix."_topmusic_artist.idartist,
".$this->prefix."_topmusic_genre_lang.name as genrename,
".$this->prefix."_topmusic_genre_lang.idgenre as idgenre,
".$this->prefix."_topmusic_artist.name as artistname,
".$this->prefix."_topmusic_artist.bornyear,
".$this->prefix."_topmusic_artist.deadyear,
".$this->prefix."_topmusic_artist.registerdate,
".$this->prefix."_topmusic_artist.photo,
".$this->prefix."_topmusic_genre_lang.name,
".$this->prefix."_topmusic_artist.webpage,
".$this->prefix."_topmusic_artist.forumURL,
".$this->prefix."_topmusic_artist.members,
".$this->prefix."_topmusic_artist.views,
".$this->prefix."_topmusic_artist.photo_file
FROM
".$this->prefix."_topmusic_artist
LEFT OUTER JOIN ".$this->prefix."_topmusic_genre ON (".$this->prefix."_topmusic_artist.idgenre = ".$this->prefix."_topmusic_genre.idgenre)
LEFT OUTER JOIN ".$this->prefix."_topmusic_genre_lang ON (".$this->prefix."_topmusic_genre.idgenre = ".$this->prefix."_topmusic_genre_lang.idgenre)
WHERE
".$this->prefix."_topmusic_artist.idartist =".$id." AND
(".$this->prefix."_topmusic_genre_lang.language='".$language."'
OR ".$this->prefix."_topmusic_genre_lang.language is null)";
//echo "sql=".$sSql."<br>";
$stmt=$this->db->sql_query($sSql);
if($rs=$this->db->sql_fetchrow($stmt)){
$artistOg->setId($rs['idartist']);
$artistOg->setName($rs['artistname']);
$artistOg->setBornyear($rs['bornyear']);
$artistOg->setDeadyear($rs['deadyear']);
$artistOg->setGenreid($rs['idgenre']);
$artistOg->setGenrename($rs['genrename']);
$artistOg->setPhoto($rs['photo']);
$artistOg->setPhoto_file($rs['photo_file']);
$artistOg->setWeb($rs['webpage']);
$artistOg->setForum($rs['forumURL']);
$artistOg->setMembers($rs['members']);
$artistOg->setCount($rs['views']);
}
$this->db->sql_freeresult($stmt);
$sSql="SELECT biography FROM ".$this->prefix."_topmusic_artist_lang WHERE idartist=".$id." AND language='".$language."'";
$stmt=$this->db->sql_query($sSql);
if($rs=$this->db->sql_fetchrow($stmt))
$artistOg->setBiography($rs['biography']);
$this->db->sql_freeresult($stmt);
return $artistOg;
}
function existsBiography($idartist,$currentlang){
$sql="SELECT * FROM ".$this->prefix."_topmusic_artist_lang WHERE idartist=".$idartist." AND language='".$currentlang."'";
$stmt=$this->db->sql_query($sql);
if($this->db->sql_fetchrow($stmt))
return 1;
else
return 0;
}
function searchArtist($artist,$freetext,$language,$page=1,$numppage=10){
$sSql=" SELECT
".$this->prefix."_topmusic_artist.idartist,
".$this->prefix."_topmusic_artist.idgenre,
".$this->prefix."_topmusic_artist.name as artistname,
".$this->prefix."_topmusic_artist.bornyear,
".$this->prefix."_topmusic_artist.deadyear,
".$this->prefix."_topmusic_artist.photo,
".$this->prefix."_topmusic_album.title as albumtitle,
".$this->prefix."_topmusic_song.title as songtitle
FROM
".$this->prefix."_topmusic_artist
LEFT OUTER JOIN ".$this->prefix."_topmusic_album ON (".$this->prefix."_topmusic_artist.idartist = ".$this->prefix."_topmusic_album.idartist)
LEFT OUTER JOIN ".$this->prefix."_topmusic_song ON (".$this->prefix."_topmusic_album.idalbum = ".$this->prefix."_topmusic_song.idalbum)
LEFT OUTER JOIN ".$this->prefix."_topmusic_artist_lang ON (".$this->prefix."_topmusic_artist.idartist = ".$this->prefix."_topmusic_artist_lang.idartist)";
$junc=" AND ";
$sWhere="";
if($artist->getGenreid()!="" && $artist->getGenreid()!="...")
$sWhere.=" ".$this->prefix."_topmusic_artist.idgenre=".$artist->getGenreid();
if($artist->getName()!=""){
if($sWhere!="")
$sWhere.=$junc;
$sWhere.=" ".$this->prefix."_topmusic_artist.name like '%".$artist->getName()."%'";
}
if($artist->getAlbumname()!=""){
if($sWhere!="")
$sWhere.=$junc;
$sWhere.=" ".$this->prefix."_topmusic_album.title like '%".$artist->getAlbumname()."%'";
}
if($artist->getSongtitle()!=""){
if($sWhere!="")
$sWhere.=$junc;
$sWhere.=" ".$this->prefix."_topmusic_song.title like '%".$artist->getSongtitle()."%'";
}
if($artist->getBornyear()!=""){
if($sWhere!="")
$sWhere.=$junc;
$sWhere.=" (".$this->prefix."_topmusic_artist.bornyear <= ".$artist->getBornyear()." AND
".$this->prefix."_topmusic_artist.deadyear >= ".$artist->getBornyear().")
OR
(".$this->prefix."_topmusic_artist.bornyear <= ".$artist->getBornyear()." AND
".$this->prefix."_topmusic_artist.deadyear IS NULL)";
}
if($freetext!=""){
if($sWhere!="")
$sWhere.=$junc;
$sWhere.=" ".$this->prefix."_topmusic_artist_lang.biography like '%".$freetext."%'";
}
if($sWhere!="")
$sWhere=" WHERE (".$this->prefix."_topmusic_artist_lang.language='".$language."' || ".$this->prefix."_topmusic_artist_lang.language IS NULL) AND ".$sWhere;
$groupBy=" GROUP BY ".$this->prefix."_topmusic_artist.idartist";
$sSql.=$sWhere.$groupBy;
//echo "sql=".$sSql."<br>";
$stmt=$this->db->sql_query($sSql);
$i=0;
$numtotal=$this->db->sql_numrows();
$pagetotal=ceil($numtotal/$numppage);
if($page>1 && $page<=$pagetotal)
$this->db->sql_rowseek(($page-1)*$numppage);
while($rs=$this->db->sql_fetchrow($stmt)){
$artistO=new ArtistAdminO();
$artistO->setId($rs['idartist']);
$artistO->setName($rs['artistname']);
$artistO->setBornyear($rs['bornyear']);
$artistO->setDeadyear($rs['deadyear']);
$artistO->setCount($numtotal);
$artistList[$i]=$artistO;
$i++;
}
$this->db->sql_freeresult($stmt);
return $artistList;
}
function getSelectList($orphan=false){
$sSql="SELECT
".$this->prefix."_topmusic_artist.idartist,
".$this->prefix."_topmusic_artist.name
FROM
".$this->prefix."_topmusic_artist
ORDER BY name";
//echo "sql=".$sSql."<br>";
$stmt=$this->db->sql_query($sSql);
$i=0;
if($orphan){
$artistList[$i][0]='orphan';
$artistList[$i][1]='no artist';
$i++;
}
while($rs=$this->db->sql_fetchrow($stmt)){
$artistList[$i][0]=$rs['idartist'];
$artistList[$i][1]=$rs['name'];
$i++;
}
$this->db->sql_freeresult($stmt);
return $artistList;
}
function insertRelated($idart,$idrel){
$sql="INSERT INTO ".$this->prefix."_topmusic_artist_relation (idartist,idartist_related)
VALUES (".$idart.",".$idrel.")";
$this->db->sql_query($sql);
$error=$this->db->sql_error();
if($error["message"]=="")
return true;
else
return false;
}
function getRelated($idartist){
$sSql=" SELECT
artist.idartist,
name,
photo_file,
photo
FROM
".$this->prefix."_topmusic_artist artist
INNER JOIN ".$this->prefix."_topmusic_artist_relation rel ON (artist.idartist = rel.idartist_related)
WHERE rel.idartist=$idartist
ORDER BY name desc";
//echo "sql=".$sSql."<br>";
$stmt=$this->db->sql_query($sSql);
$i=0;
while($rs=$this->db->sql_fetchrow($stmt)){
$artistO=new ArtistAdminO();
$artistO->setId($rs['idartist']);
$artistO->setName($rs['name']);
$artistO->setPhoto($rs['photo']);
$artistO->setPhoto_file($rs['photo_file']);
$artistO->setPhoto($rs['photo']);
$artistList[$i]=$artistO;
$i++;
}
$this->db->sql_freeresult($stmt);
return $artistList;
}
function deleteRelated($idart,$idrel){
$sql="DELETE FROM ".$this->prefix."_topmusic_artist_relation WHERE idartist=".$idart." AND idartist_related=".$idrel;
$this->db->sql_query($sql);
$error=$this->db->sql_error();
if($error["message"]=="")
return true;
else
return false;
}
function getCustomFields(){
$sSql=" SELECT
idartist_field,
name,
description,
type,
file_path,
file_icon,
image_width,
select_values
FROM
".$this->prefix."_topmusic_artist_fields
ORDER BY name";
//echo "sql=".$sSql."<br>";
$stmt=$this->db->sql_query($sSql);
while($rs=$this->db->sql_fetchrow($stmt)){
$artistFieldO=new CustomFieldAdminO();
$artistFieldO->idfield=$rs['idartist_field'];
$artistFieldO->name=$rs['name'];
$artistFieldO->type=$rs['type'];
$artistFieldO->description=$rs['description'];
$artistFieldO->file_icon=$rs['file_icon'];
$artistFieldO->file_path=$rs['file_path'];
$artistFieldO->image_width=$rs['image_width'];
$artistFieldO->select_values=$rs['select_values'];
$artistFields[]=$artistFieldO;
}
$this->db->sql_freeresult($stmt);
return $artistFields;
}
function getCustomFieldsValues($idartist){
$fields=$this->getCustomFields();
$sSql=" SELECT
idartist_field,
value
FROM
".$this->prefix."_topmusic_artist_fields_values
WHERE idartist=$idartist OR idartist IS NULL";
//echo "sql=".$sSql."<br>";
$stmt=$this->db->sql_query($sSql);
$fields2=$fields;
//print_r($fields2);
while($rs=$this->db->sql_fetchrow($stmt)){
foreach($fields as $key => $field){
if($field->idfield==$rs['idartist_field']){
$field->value=$rs['value'];
array_splice($fields2,$key,1,array($field));
break;
}
}
}
$this->db->sql_freeresult($stmt);
//print_r($fields2);
return $fields2;
}
function updateCustomFields($idartist,$POST){
//all artist custom fields with their original values
$fieldsValues=$this->getCustomFieldsValues($idartist);
//those fields with not values still set
$sql="SELECT camps.idartist_field
FROM ".$this->prefix."_topmusic_artist_fields camps
left outer JOIN ".$this->prefix."_topmusic_artist_fields_values valors on camps.idartist_field = valors.idartist_field AND valors.idartist=".$idartist."
where idartist is null";
//echo "sql=".$sql."<br>";
$stmt=$this->db->sql_query($sql);
while($rs=$this->db->sql_fetchrow($stmt)){
foreach($fieldsValues as $field){
if($field->idfield==$rs['idartist_field']){
switch($field->type){
case "image":
case "file":
//print_r($_FILES);
if($_FILES[$field->name]["size"]>0){
$directory="modules/"._TOPMUSIC_MODULENAME."/".$field->file_path."/";
//print($directory);
if(move_uploaded_file($_FILES[$field->name]["tmp_name"],($directory.$_FILES[$field->name]["name"]))){
chmod($directory.$_FILES[$field->name]["name"],0755);
$POST[$field->name]=$_FILES[$field->name]["name"];
}
//print "post=".$POST[$field->name]."<br>";
}
break;
}
$value=(!get_magic_quotes_gpc())?addslashes($POST[$field->name]):$POST[$field->name];
$sql="INSERT INTO ".$this->prefix."_topmusic_artist_fields_values (idartist_field,idartist,value) values (".$field->idfield.",".$idartist.",'".$value."')";
//echo "sql=".$sql."<br>";
$this->db->sql_query($sql);
break;
}
}
//echo "sql=".$sql."<br>";
}
$this->db->sql_freeresult($stmt);
//update those values already set and changed
if(count($fieldsValues)>0){
foreach($fieldsValues as $field){
//print $POST[$field->name];
if($field->value!=$POST[$field->name] || $field->value!=$_FILES[$field->name]["name"]){
switch($field->type){
case "image":
case "file":
//print "postval=".$POST[$field->name]."<br>";
//print "oldval=".$POST[$field->value]."<br>";
//print "files_name=".$_FILES[$field->name]["name"]."<br>";
if($field->value!=$_FILES[$field->name]["name"]){
if($_FILES[$field->name]["size"]>0){
$directory="modules/"._TOPMUSIC_MODULENAME."/".$field->file_path."/";
//delete old file
if($field->value!="")
unlink($directory.$field->value);
//upload new file
if(move_uploaded_file($_FILES[$field->name]["tmp_name"],($directory.$_FILES[$field->name]["name"]))){
chmod($directory.$_FILES[$field->name]["name"],0755);
$POST[$field->name]=$_FILES[$field->name]["name"];
}
//print "post=".$POST[$field->name]."<br>";
}
}
break;
}
if($POST[$field->name]!="" || ($POST[$field->name]=="" && $field->type!="image" && $field->type!="file")){
$value=(!get_magic_quotes_gpc())?addslashes($POST[$field->name]):$POST[$field->name];
$sql="UPDATE ".$this->prefix."_topmusic_artist_fields_values SET value='".$value."' WHERE idartist=".$idartist." AND idartist_field=".$field->idfield;
//echo "sql=".$sql."<br>";
$this->db->sql_query($sql);
}
$error=$this->db->sql_error();
if($error["message"]!="")
return false;
}
}
}
return true;
}
function addCustomField($field){
if($field->image_width=="")
$field->image_width=0;
$field_description=(!get_magic_quotes_gpc())?addslashes($field->description):$field->description;
$select_values=(!get_magic_quotes_gpc())?addslashes($field->select_values):$field->select_values;
$sql="INSERT INTO ".$this->prefix."_topmusic_artist_fields
(name,description,type,image_width,file_path,file_icon,select_values)
values
('".$field->name."','".$field_description."','".$field->type."',".$field->image_width.",'".$field->file_path."','".$field->file_icon."','".$select_values."')";
//echo "sql=".$sql."<br>";
$this->db->sql_query($sql);
$error=$this->db->sql_error();
if($error["message"]!="")
return false;
return true;
}
function delCustomField($idfield){
if(is_numeric($idfield)){
$sql="DELETE FROM ".$this->prefix."_topmusic_artist_fields_values WHERE idartist_field=".$idfield;
//echo "sql=".$sql."<br>";
$this->db->sql_query($sql);
$sql="DELETE FROM ".$this->prefix."_topmusic_artist_fields WHERE idartist_field=".$idfield;
//echo "sql=".$sql."<br>";
$this->db->sql_query($sql);
$error=$this->db->sql_error();
if($error["message"]!="")
return false;
return true;
}else
return false;
}
}
?>