2014-12-23 14:32:23 +00:00
< ? php
namespace Westdc\Reference ;
2014-12-25 16:53:46 +00:00
use Zend\ServiceManager\ServiceManager ;
use Zend\ServiceManager\ServiceManagerAwareInterface ;
use Westdc\EventModel\AbstractEventManager ;
2014-12-23 14:32:23 +00:00
use Westdc\Reference\Listener\ReferenceListener ;
2014-12-25 16:53:46 +00:00
class Reference extends AbstractEventManager implements ServiceManagerAwareInterface {
protected $serviceManager ;
2014-12-23 14:32:23 +00:00
private $db ; //传入PDO对象.
protected $events = NULL ;
public $table ;
public $keyword ;
public $order ;
public $sort = " DESC " ;
public $field ;
public $reftype ;
function __construct ( $db = NULL , $mail = NULL )
{
2014-12-25 16:53:46 +00:00
2014-12-23 14:32:23 +00:00
}
2014-12-25 16:53:46 +00:00
public function setServiceManager ( ServiceManager $serviceManager )
2014-12-23 14:32:23 +00:00
{
2014-12-25 16:53:46 +00:00
$this -> serviceManager = $serviceManager ;
$this -> init ();
return $this ;
2014-12-23 14:32:23 +00:00
}
2014-12-25 16:53:46 +00:00
private function init (){
$dbService = $this -> serviceManager -> get ( 'Db' );
$this -> db = $dbService -> getPdo ();
unset ( $dbService );
$this -> table = new \stdClass ();
$this -> table -> reference = " reference " ;
$this -> table -> reference_author = " ref_author " ;
$this -> table -> source = " source " ;
2014-12-29 09:55:22 +00:00
$this -> table -> metadata_reference = " mdref " ;
$this -> table -> reference_tag = " ref_tag " ;
2014-12-30 09:34:30 +00:00
$this -> table -> metadata = " metadata " ;
2014-12-30 11:49:04 +00:00
$this -> table -> attachments = " attachments " ;
2014-12-25 16:53:46 +00:00
}
2014-12-29 09:55:22 +00:00
/**
* 添加或编辑文献
* @ param $data
* @ param int $id
* @ return bool | string
*/
public function reference ( $data , $id = 0 )
2014-12-23 14:32:23 +00:00
{
$params = compact ( 'data' );
2014-12-29 09:55:22 +00:00
$results = $this -> getEventManager () -> trigger ( 'submit.before' , $this , $params );
2014-12-23 14:32:23 +00:00
$cache_data = $results -> bottom ();
if ( $cache_data !== true )
{
return $cache_data ;
}
2014-12-29 09:55:22 +00:00
$results = $this -> getEventManager () -> trigger ( 'submit.processData' , $this , $params );
2014-12-23 14:32:23 +00:00
$data = $results -> bottom ();
2014-12-29 09:55:22 +00:00
$dbServices = $this -> serviceManager -> get ( 'Db' );
$dbh = $dbServices -> getDbh ();
2014-12-23 14:32:23 +00:00
if ( empty ( $id ))
{
$id = $dbh -> insert ( $this -> table -> reference , $data , true );
} else {
if ( ! $dbh -> update ( $this -> table -> reference , $data , " id= $id " , true ))
{
return " 修改失败!请重试 " ;
}
}
if ( ! empty ( $id ) && is_numeric ( $id ))
{
return true ;
} else {
return " 修改失败 " ;
}
}
//上传文献PDF
public function uploadReferencePdf ( $file , $autoread = false )
{
2014-12-27 16:03:41 +00:00
$configService = $this -> serviceManager -> get ( 'ConfigService' );
$appConfig = $configService -> get ( 'application.ini' );
2014-12-27 16:33:12 +00:00
$fileUploadService = $this -> serviceManager -> get ( 'File/Upload' );
2015-01-12 12:59:23 +00:00
$fileUploadService -> attachDefaultListener ();
2014-12-28 15:37:16 +00:00
$fileUploadService -> setParams ([ 'file_type' => 'literature' ]);
2014-12-27 16:33:12 +00:00
$file_info = $fileUploadService ( $file , $appConfig [ 'reference_save_path' ], " " , " " , $fileUploadService :: DATETIME_MODEL_Y );
2014-12-23 14:32:23 +00:00
if ( isset ( $file_info [ 'error' ]) && ! empty ( $file_info [ 'error' ]))
{
return array ( " error " => $file_info [ 'error' ]);
}
if ( $autoread )
{
$params = compact ( 'file_data' );
$results = $this -> events () -> trigger ( 'upload.insertToReferenceTable' , $this , $params );
$cache_data = $results -> bottom ();
2014-12-29 09:55:22 +00:00
$file_info = array_merge ( $file_info , $cache_data );
2014-12-23 14:32:23 +00:00
}
2014-12-29 09:55:22 +00:00
return $file_info ;
2014-12-23 14:32:23 +00:00
}
//通过文件名自动提取文章标题
public function getReferenceTitleFromFilenName ( $filename )
{
$file = new Files ();
$title = str_replace ( " . " . $file -> getFileTextExt ( $filename ), " " , $filename );
return $title ;
}
//删除文献文件
public function deleteReferenceAttchment ( $attid )
{
if ( empty ( $attid ) || ! is_numeric ( $attid ))
{
return array ( " error " => " 参数错误 " );
}
$files = new Files ();
$status = $files -> delete ( $attid );
if ( $status !== true )
{
return array ( " error " => $status );
} else {
return array ( " success " => 1 );
}
}
//所有文献
2014-12-25 16:53:46 +00:00
public function fetchAll ()
2014-12-23 14:32:23 +00:00
{
$wheresql = array ();
if ( ! empty ( $this -> keyword ))
{
$wheresql [] = " ( { $this -> table -> reference } .title LIKE '% { $this -> keyword } %' OR { $this -> table -> reference } .reference LIKE '% { $this -> keyword } %') " ;
}
if ( ! empty ( $this -> field ))
{
foreach ( $this -> field as $k => $v )
{
if ( ! empty ( $v ))
{
if ( ! is_numeric ( $v )) $v = " ' { $v } ' " ;
$wheresql [] = " ( { $this -> table -> reference } . { $k } = { $v } ) " ;
} else {
if ( is_numeric ( $v ))
$wheresql [] = " ( { $this -> table -> reference } . { $k } IS NULL OR { $this -> table -> reference } . { $k } =0 ) " ;
else
$wheresql [] = " ( { $this -> table -> reference } . { $k } IS NULL ) " ;
} //if(empty($v)
} //foreach
}
if ( count ( $wheresql ) > 0 )
{
$wheresql = " WHERE " . join ( " AND " , $wheresql );
} else {
$wheresql = " " ;
}
if ( empty ( $this -> order ))
{
$order = " { $this -> table -> reference } .title " ;
} else {
$order = " { $this -> table -> reference } . { $this -> order } " ;
}
2014-12-25 16:53:46 +00:00
$sql = " SELECT { $this -> table -> reference } .* FROM
2014-12-23 14:32:23 +00:00
{ $this -> table -> reference }
$wheresql
ORDER BY $order { $this -> sort } " ;
$rs = $this -> db -> query ( $sql );
return $rs -> fetchAll ();
}
//获取专题数据的文献
public function fetchThemeReferences ( $code )
{
$wheresql = array ();
//$wheresql[] = " s.code='$code' ";
if ( ! empty ( $this -> keyword ))
{
$wheresql [] = " (ref.title iLIKE '% { $this -> keyword } %' OR ref.reference iLIKE '% { $this -> keyword } %') " ;
}
if ( count ( $wheresql ) > 0 )
{
$wheresql = " and " . join ( " AND " , $wheresql );
} else {
$wheresql = " " ;
}
if ( empty ( $this -> order ))
{
$order = " ref.year,ref.title " ;
} else {
$order = " ref. { $this -> order } { $this -> sort } " ;
}
2014-12-25 16:53:46 +00:00
$sql = " select distinct ref.* from { $this -> table -> reference } ref where ref.id in (select r.refid from mdref r
2014-12-23 14:32:23 +00:00
left join datasource ds on r . uuid = ds . uuid left join { $this -> table -> source } s on s . id = ds . sourceid
where s . code = '$code' )
$wheresql
ORDER BY $order " ;
$rs = $this -> db -> query ( $sql );
return $rs -> fetchAll ();
}
//Get WestDC references
public function fetchWestdcReferences ()
{
$wheresql = array ();
$wheresql [] = " r.uuid='e31f5ea7-a4af-4ae3-9ac1-1a84132c4338' " ;
if ( ! empty ( $this -> keyword ))
{
$wheresql [] = " (ref.title LIKE '% { $this -> keyword } %' OR ref.reference LIKE '% { $this -> keyword } %') " ;
}
if ( count ( $wheresql ) > 0 )
{
$wheresql = " WHERE " . join ( " AND " , $wheresql );
} else {
$wheresql = " " ;
}
if ( empty ( $this -> order ))
{
$order = " ref.year,ref.title " ;
} else {
$order = " ref. { $this -> order } { $this -> sort } " ;
}
$sql = " select distinct ref.* from mdref r left join { $this -> table -> reference } ref on r.refid=ref.id
$wheresql
ORDER BY $order " ;
$rs = $this -> db -> query ( $sql );
return $rs -> fetchAll ();
}
//Get references which need to deal with
public function fetchTodoReferences ()
{
$wheresql = array ();
$wheresql [] = " ref.id not in (select distinct refid from mdref) " ;
if ( ! empty ( $this -> keyword ))
{
$wheresql [] = " (ref.title LIKE '% { $this -> keyword } %' OR ref.reference LIKE '% { $this -> keyword } %') " ;
}
if ( count ( $wheresql ) > 0 )
{
$wheresql = " WHERE " . join ( " AND " , $wheresql );
} else {
$wheresql = " " ;
}
if ( empty ( $this -> order ))
{
$order = " ref.year,ref.title " ;
} else {
$order = " ref. { $this -> order } { $this -> sort } " ;
}
$sql = " select distinct ref.* from { $this -> table -> reference } ref
$wheresql
ORDER BY $order " ;
$rs = $this -> db -> query ( $sql );
return $rs -> fetchAll ();
}
//Get data author references which need to deal with
public function fetchAuthorReferences ()
{
$wheresql = array ();
$wheresql [] = " ref.ris is NULL " ;
$wheresql [] = " ref.id in (select distinct refid from mdref where reftype=0) " ;
if ( ! empty ( $this -> keyword ))
{
$wheresql [] = " (ref.title LIKE '% { $this -> keyword } %' OR ref.reference LIKE '% { $this -> keyword } %') " ;
}
if ( count ( $wheresql ) > 0 )
{
$wheresql = " WHERE " . join ( " AND " , $wheresql );
} else {
$wheresql = " " ;
}
if ( empty ( $this -> order ))
{
$order = " ref.year,ref.title " ;
} else {
$order = " ref. { $this -> order } { $this -> sort } " ;
}
$sql = " select distinct ref.* from { $this -> table -> reference } ref
$wheresql
ORDER BY $order " ;
$rs = $this -> db -> query ( $sql );
return $rs -> fetchAll ();
}
//Get references by data UUID
public function fetchReferencesByUUID ( $uuid )
{
$wheresql = array ();
$wheresql [] = " r.uuid=' $uuid ' " ;
if ( ! empty ( $this -> keyword ))
{
$wheresql [] = " (ref.title LIKE '% { $this -> keyword } %' OR ref.reference LIKE '% { $this -> keyword } %') " ;
}
if ( count ( $wheresql ) > 0 )
{
$wheresql = " WHERE " . join ( " AND " , $wheresql );
} else {
$wheresql = " " ;
}
if ( empty ( $this -> order ))
{
$order = " ref.year,ref.title " ;
} else {
$order = " ref. { $this -> order } { $this -> sort } " ;
}
$sql = " select distinct ref.*,r.reftype,r.place,r.id as mrid from { $this -> table -> reference } ref left join { $this -> table -> metadata_reference } r on ref.id=r.refid
$wheresql
ORDER BY $order " ;
$rs = $this -> db -> query ( $sql );
return $rs -> fetchAll ();
}
//Get references with data UUID
public function fetchReferencesWithUUID ( $uuid )
{
$wheresql = array ();
//$wheresql[]=" r.uuid='$uuid' ";
if ( ! empty ( $this -> keyword ))
{
$wheresql [] = " (ref.title LIKE '% { $this -> keyword } %' OR ref.reference LIKE '% { $this -> keyword } %') " ;
}
if ( count ( $wheresql ) > 0 )
{
$wheresql = " WHERE " . join ( " AND " , $wheresql );
} else {
$wheresql = " " ;
}
if ( empty ( $this -> order ))
{
$order = " ref.year,ref.title " ;
} else {
$order = " ref. { $this -> order } { $this -> sort } " ;
}
$sql = " select distinct ref.*,r.reftype,r.place,r.id as mrid from { $this -> table -> reference } ref left join
( select * from { $this -> table -> metadata_reference } r where uuid = '$uuid' ) r on ref . id = r . refid
$wheresql
ORDER BY $order " ;
$rs = $this -> db -> query ( $sql );
return $rs -> fetchAll ();
}
//单条文献的信息
public function getOneReferenceData ( $id )
{
if ( empty ( $id ) || ! is_numeric ( $id ))
{
return false ;
}
$sql = " SELECT * FROM { $this -> table -> reference } WHERE id= $id LIMIT 1 " ;
$rs = $this -> db -> query ( $sql );
$row = $rs -> fetch ();
if ( $row [ 'attid' ])
{
2014-12-29 09:55:22 +00:00
$fileService = $this -> serviceManager -> get ( 'File' );
$attfile = $fileService -> get ( $row [ 'attid' ]);
2014-12-23 14:32:23 +00:00
$row [ 'file' ] = $attfile ;
}
return $row ;
}
//获得reference类型的附件
public function getReferenceFiles ()
{
2014-12-30 11:49:04 +00:00
$wheresql = [
" att.filetype='literature' " ,
];
if ( ! empty ( $this -> keyword ))
{
$wheresql [] = " (att.realname LIKE '% { $this -> keyword } %' OR att.filename LIKE '% { $this -> keyword } %') " ;
}
$wheresql = " WHERE " . join ( " AND " , $wheresql );
2014-12-23 14:32:23 +00:00
$sql = " SELECT att.*,ref.attid,ref.id as refid FROM { $this -> table -> attachments } att
LEFT JOIN { $this -> table -> reference } ref ON att . id = ref . attid
2014-12-30 11:49:04 +00:00
$wheresql " ;
2014-12-23 14:32:23 +00:00
$rs = $this -> db -> query ( $sql );
$rows = $rs -> fetchAll ();
return $rows ;
}
//删除文献
public function deleteReference ( $id , $delete_att = false )
{
if ( empty ( $id ) || ! is_numeric ( $id ))
{
return false ;
}
if ( $delete_att == false )
{
$sql = " DELETE FROM { $this -> table -> reference } WHERE id= $id " ;
@ $this -> db -> exec ( $sql );
$sql = " DELETE FROM { $this -> table -> metadata_reference } WHERE refid= $id " ;
@ $this -> db -> exec ( $sql );
$this -> deleteReferenceAuthor ( $id );
$this -> deleteReferenceTag ( $id );
return true ;
} else {
}
}
//删除作者信息
public function deleteReferenceAuthor ( $id )
{
if ( empty ( $id ) || ! is_numeric ( $id ))
{
return false ;
}
$sql = " DELETE FROM { $this -> table -> reference_author } WHERE id= $id " ;
return $this -> db -> exec ( $sql );
}
//删除标签信息
public function deleteReferenceTag ( $id )
{
if ( empty ( $id ) || ! is_numeric ( $id ))
{
return false ;
}
$sql = " DELETE FROM { $this -> table -> reference_tag } WHERE id= $id " ;
return $this -> db -> exec ( $sql );
}
//建立文献与数据的关系
public function createRelationFromReferenceToData ( $refid , $uuid , $reftype , $place , $id = NULL )
{
if ( empty ( $refid ) || ! is_numeric ( $refid ))
{
return " 参数错误 " ;
}
2014-12-30 09:34:30 +00:00
$tools = $this -> serviceManager -> get ( 'Tools' );
if ( ! $tools -> isUuid ( $uuid ))
2014-12-23 14:32:23 +00:00
{
return " 参数错误 " ;
}
$data = array (
'uuid' => $uuid ,
'refid' => $refid ,
'reftype' => $reftype ,
'place' => $place
);
2014-12-30 09:34:30 +00:00
$dbService = $this -> serviceManager -> get ( 'Db' );
$dbh = $dbService -> getDbh ();
2014-12-23 14:32:23 +00:00
if ( empty ( $id ))
{
$id = $dbh -> insert ( $this -> table -> metadata_reference , $data , true );
if ( is_numeric ( $id ))
{
return $id ;
} else {
return " 关系写入失败,请检查是否已经存在 " ;
}
} else {
$status = $dbh -> update ( $this -> table -> metadata_reference , $data , " id= $id " );
if ( $status === true )
{
return $id ;
} else {
return " 修改失败 " ;
}
}
}
//获得某个文献关联的数据 (根据文献获得数据)
public function getDataByReference ( $id )
{
if ( empty ( $id ) || ! is_numeric ( $id ))
{
return " 参数错误 " ;
}
$sql = " SELECT mr.id,mr.refid,mr.reftype,mr.place,md.title,md.uuid FROM { $this -> table -> metadata_reference } mr
LEFT JOIN { $this -> table -> metadata } md ON mr . uuid = md . uuid
WHERE mr . refid = $id
ORDER BY mr . place ASC " ;
$rs = $this -> db -> query ( $sql );
$rows = $rs -> fetchAll ();
return $rows ;
}
//获得某个数据关联的文献 (根据数据获得文献)
public function getReferenceByData ( $uuid )
{
if ( ! view :: isUuid ( $uuid ))
{
return " 参数错误 " ;
}
$sql = " SELECT mr.reftype,mr.place,md.title,md.uuid FROM { $this -> table -> metadata_reference } mr
LEFT JOIN { $this -> table -> metadata } md
WHERE mr . uuid = $uuid " ;
$rs = $this -> db -> query ( $sql );
$rows = $rs -> fetchAll ();
return $rows ;
}
//文献类型
public function referenceType ()
{
return array (
0 => '相关文献' , //作者建议的文献或数据中心建议的文献
1 => '施引文献' ,
2 => '参考文献' ,
3 => '多篇文献' ,
4 => '专题文献'
);
}
//写入数据文献
2014-12-30 09:34:30 +00:00
public function makeMdref ( $data , $id = NULL )
2014-12-23 14:32:23 +00:00
{
2014-12-30 09:34:30 +00:00
$results = $this -> getEventManager () -> trigger ( 'mdref.pre' , $this , compact ( 'data' ));
2014-12-23 14:32:23 +00:00
$cache_data = $results -> bottom ();
if ( $cache_data !== true )
{
return $cache_data ;
}
2014-12-30 09:34:30 +00:00
$results = $this -> getEventManager () -> trigger ( 'mdref.processData' , $this , compact ( 'data' ));
$data = $results -> last ();
2014-12-23 14:32:23 +00:00
$id = $this -> createRelationFromReferenceToData ( $data [ 'refid' ], $data [ 'uuid' ], $data [ 'reftype' ], $data [ 'place' ], $id );
if ( is_numeric ( $id ))
{
return true ;
} else {
return $id ;
}
}
//删除数据文献
public function delMdref ( $id )
{
if ( empty ( $id ) || ! is_numeric ( $id ))
{
return " 参数错误 " ;
}
$sql = " DELETE FROM { $this -> table -> metadata_reference } WHERE id= $id " ;
if ( $this -> db -> exec ( $sql ))
{
return true ;
} else {
return " 删除失败 " ;
}
}
//按年份获得文献数量
public function countByYear ()
{
$sql = " SELECT count(id) as num,year FROM { $this -> table -> reference } GROUP BY year ORDER BY year DESC " ;
$rs = $this -> db -> query ( $sql );
$rows = $rs -> fetchAll ();
return $rows ;
}
//获得作者
public function getAuthorByReference ( $id , $join = false )
{
if ( is_numeric ( $id ))
{
$sql = " SELECT * FROM { $this -> table -> reference_author } WHERE id= $id ORDER BY place ASC " ;
$rs = $this -> db -> query ( $sql );
if ( ! $join )
{
return $rs -> fetchAll ();
} else {
foreach ( $rows = $rs -> fetchAll () as $k => $v )
{
$rows [ $k ] = ( string ) $v [ 'firstname' ] . $v [ 'lastname' ];
}
return $rows ;
}
}
if ( is_array ( $id ))
{
$sql = " SELECT * FROM { $this -> table -> reference_author } WHERE id IN ( " . join ( " , " , $id ) . " ) " ;
$rs = $this -> db -> query ( $sql );
return $rs -> fetchAll ();
}
return ;
}
//获得标签
public function getTagsByReference ( $id , $single = false )
{
if ( is_numeric ( $id ))
{
$sql = " SELECT * FROM { $this -> table -> reference_tag } WHERE id= $id " ;
$rs = $this -> db -> query ( $sql );
if ( ! $single )
{
return $rs -> fetchAll ();
} else {
foreach ( $rows = $rs -> fetchAll () as $k => $v )
{
$rows [ $k ] = ( string ) $v [ 'tag' ];
}
return $rows ;
}
}
return ;
}
//Get data author references
//$ordertype 0: by data, 1: by literature
public function getReferencesByAuthor ( $uid , $ordertype = 0 , $reftype = 0 )
{
$wheresql = array ();
$wheresql [] = " a.userid= $uid " ;
$wheresql [] = " a.status=1 " ;
if ( ! empty ( $this -> keyword ))
{
if ( $ordertype == 0 )
{
$wheresql [] = " (md.title LIKE '% { $this -> keyword } %' OR md.description LIKE '% { $this -> keyword } %') " ;
} else {
$wheresql [] = " (ref.title LIKE '% { $this -> keyword } %' OR ref.reference LIKE '% { $this -> keyword } %') " ;
}
}
if ( count ( $wheresql ) > 0 )
{
$wheresql = " WHERE " . join ( " AND " , $wheresql );
} else {
$wheresql = " " ;
}
if ( $ordertype == 0 )
{
$order = " md.title " ;
$sql = " SELECT md.title,md.uuid,count(mr.id) as c FROM metadata md
LEFT JOIN ( select * from mdref where reftype = $reftype ) mr ON md . uuid = mr . uuid
LEFT JOIN mdauthor a ON md . uuid = a . uuid
left join reference ref on mr . refid = ref . id
$wheresql
group by md . title , md . uuid
ORDER BY c desc , $order " ;
} else {
$order = " ref.title " ;
$sql = " SELECT ref.*,count(mr.uuid) as c FROM metadata md
LEFT JOIN mdref mr ON md . uuid = mr . uuid
LEFT JOIN mdauthor a ON md . uuid = a . uuid
left join reference ref on mr . refid = ref . id
$wheresql and mr . reftype = $reftype
group by ref . id
ORDER BY c desc , $order " ;
}
$rs = $this -> db -> query ( $sql );
return $rs -> fetchAll ();
}
//Get author references by data uuid
public function getReferencesByAuthorUUID ( $uid , $uuid )
{
$wheresql = array ();
$wheresql [] = " a.userid= $uid " ;
$wheresql [] = " a.status=1 " ;
$wheresql [] = " mr.uuid=' $uuid ' " ;
if ( ! empty ( $this -> keyword ))
{
$wheresql [] = " (ref.title LIKE '% { $this -> keyword } %' OR ref.reference LIKE '% { $this -> keyword } %') " ;
}
if ( count ( $wheresql ) > 0 )
{
$wheresql = " WHERE " . join ( " AND " , $wheresql );
} else {
$wheresql = " " ;
}
$order = " ref.title " ;
$sql = " SELECT md.title as mdtitle,md.uuid,ref.id,ref.reference,ref.link,mr.place,mr.id as mrid,mr.reftype FROM mdref mr
LEFT JOIN metadata md ON md . uuid = mr . uuid
LEFT JOIN mdauthor a ON md . uuid = a . uuid
left join reference ref on mr . refid = ref . id
$wheresql
order by mr . reftype , mr . place ASC , ref . id DESC , md . ts_created desc " ;
$rs = $this -> db -> query ( $sql );
return $rs -> fetchAll ();
}
//数据作者修改推荐文献的排序
public function changeOrderByAuthor ( $uid , $id , $order )
{
$sql = " update mdref set place= $order where id= $id and uuid in
( select uuid from mdauthor where status = 1 and userid = $uid ) " ;
if ( $this -> db -> exec ( $sql ))
{
return true ;
} else {
return false ;
}
}
//数据作者移除推荐文献
public function removeReferenceByAuthor ( $uid , $id )
{
$sql = " DELETE FROM mdref WHERE id= $id and uuid in (select uuid from mdauthor where userid= $uid AND status=1) " ;
if ( $this -> db -> exec ( $sql ))
{
return true ;
} else {
return false ;
}
}
//数据作者添加推荐文献
public function insertMdrefByAuthor ( $uid , $refid , $uuid , $place , $reftype = 0 )
{
$sql = " select * from mdauthor where status=1 and uuid=' $uuid ' and userid= $uid " ;
$rs = $this -> db -> fetchRow ( $sql );
if ( $rs )
{
$id = $this -> createRelationFromReferenceToData ( $refid , $uuid , $reftype , $place );
if ( is_numeric ( $id ))
{
return true ;
} else {
return $id ;
}
} else {
return false ;
}
}
}