diff --git a/application/default/controllers/ArchivesController.php b/application/default/controllers/ArchivesController.php index be31c2fb..43916d26 100644 --- a/application/default/controllers/ArchivesController.php +++ b/application/default/controllers/ArchivesController.php @@ -177,10 +177,10 @@ class ArchivesController extends Zend_Controller_Action $this->view->deepField = $category->DeepTitle; - $time = date("Y-m-d",time()); + $time = date("Y-m-d H:i:s",time()); - $sql = "SELECT n.*,c.title as typename,c.code,u.realname as author FROM ".$News->tbl_archives." n + $sql = "SELECT n.*,c.title as typename,c.code,u.realname as author,ct.uuid as mduuid FROM ".$News->tbl_archives." n left join ".$News->tbl_catalog." ct on ct.aid=n.id left join ".$News->tbl_categorys." c ON ct.cid=c.id LEFT JOIN users u ON n.userid=u.id @@ -197,6 +197,14 @@ class ArchivesController extends Zend_Controller_Action $this->view->infos = $row; + if(!empty($row['mduuid'])) + { + $sql = "SELECT uuid,title FROM metadata WHERE uuid='{$row['mduuid']}'"; + $sth = $this->db->query($sql); + $mdinfo = $sth->fetch(); + } + $this->view->mdinfo = $mdinfo; + } function searchAction() diff --git a/application/default/controllers/AuthorController.php b/application/default/controllers/AuthorController.php index eaebe2ca..bcbd311a 100644 --- a/application/default/controllers/AuthorController.php +++ b/application/default/controllers/AuthorController.php @@ -15,7 +15,7 @@ class AuthorController extends Zend_Controller_Action // 调试模式中将显示全部错误细节,电子邮件将发往调试邮箱 // 1 为开启 // 0 为关闭 - public $debug = 0; + public $debug = 1; //调试模式邮箱地址 public $debug_email = "wangliangxu@lzb.ac.cn"; @@ -142,13 +142,13 @@ class AuthorController extends Zend_Controller_Action $sql = "UPDATE dataorder SET authorpermitted=1 WHERE uuid=? and id=?"; $sth = $this->db->prepare($sql); if($sth->execute(array($uuid,$oid))) - { - //发送相关邮件给数据中心服务人员 - $sql="select m.title,a.username from dataorder o left join metadata m on o.uuid=m.uuid left join offlineapp a on o.offlineappid=a.id where o.id=?"; - $sth = $this->db->prepare($sql); - $sth->execute(array($oid)); - $row = $sth->fetch(); - $mail = new WestdcMailer($this->view->config->smtp); + { + //发送相关邮件给数据中心服务人员 + $sql="select m.title,a.username from dataorder o left join metadata m on o.uuid=m.uuid left join offlineapp a on o.offlineappid=a.id where o.id=?"; + $sth = $this->db->prepare($sql); + $sth->execute(array($oid)); + $row = $sth->fetch(); + $mail = new WestdcMailer($this->view->config->smtp); $mailtp=new EmailText($this->db,'offline-author-yes',array('user'=>$row['username'],'data'=>$row['title'],'email'=>$u_email)); $mail->setFrom($this->view->config->service->email,'西部数据中心服务组'); $mail->setBodyText($mailtp->getBody()); @@ -1234,44 +1234,58 @@ class AuthorController extends Zend_Controller_Action $u_id = $user->id; } + $News = new Archive($this->db); + $category = new ArchiveCategory($this->db); + //新闻列表 if(empty($ac) || $ac=="list") { $keyword = $this->_request->getParam('q'); $uuid = $this->_request->getParam('uuid'); - $wheresql = ""; + $wheresql = array(); $join = ""; if(!empty($keyword)) { $this->view->q = $keyword; $search = new Search($keyword); - $wheresql = $search->sql_expr(array("arc.title","arc.description")); - } - - if(!empty($wheresql)) - { - $wheresql = " AND ".$wheresql; + $wheresql[] = $search->sql_expr(array("arc.title","arc.description")); } if(!empty($uuid) && preg_match("/^[0-9A-Za-z]{8}-[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]{12}$/",$uuid)) { - $join = "LEFT JOIN news_mdnews mdnews ON mdnews.aid=arc.id"; - $wheresql .= " AND mdnews.uuid='$uuid'"; + $wheresql[] = " ct.uuid='$uuid' "; } - $sql = "SELECT arc.id,arc.title,arc.ts_published,arc.description,u.realname FROM news_archives arc + $wheresql[] = " c.code='".$category->DataNewsCode."' "; + $wheresql[] = " ct.uuid IS NOT NULL "; + $wheresql[] = " arc.userid=$u_id"; + + if(count($wheresql)>0) + { + $wheresql = " WHERE ".join(" AND ",$wheresql); + } + + $sql = "SELECT arc.*,c.id as cid,u.realname,md.title as mdtitle,md.uuid as mduuid FROM ".$News->tbl_archives." arc + LEFT JOIN ".$News->tbl_catalog." ct ON arc.id=ct.aid + LEFT JOIN ".$News->tbl_categorys." c ON ct.cid=c.id LEFT JOIN users u ON arc.userid=u.id - $join - WHERE arc.is_pub>0 AND arc.ts_published<'now()' $wheresql - ORDER BY arc.ts_published"; + LEFT JOIN metadata md ON ct.uuid=md.uuid + $wheresql + ORDER BY arc.ts_published DESC"; $sth = $this->db->prepare($sql); $sth->execute(); $rows = $sth->fetchAll(); + foreach($rows as $k=>$v) + { + $arcinfo = $News->getArchiveUrlByCid($v['id'],$v['cid']); + $rows[$k]['url'] = $arcinfo['archive_url']; + } + $paginator = Zend_Paginator::factory($rows); $paginator->setCurrentPageNumber($this->_getParam('page')); $paginator->setItemCountPerPage(10); @@ -1279,32 +1293,6 @@ class AuthorController extends Zend_Controller_Action Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml'); $this->view->paginator=$paginator; - } - - if($ac == "view") - { - - $this->_helper->viewRenderer('news-view'); - $aid = (int)$this->_request->getParam('aid'); - - if(empty($aid) || !is_numeric($aid)) - { - $this->_redirect('/error/error'); - } - - else - { - $this->db->exec("UPDATE news_archives arc SET click=click+1 WHERE arc.id=$aid"); - $sql = "SELECT arc.*,u.realname FROM news_archives arc - LEFT JOIN users u ON u.id=arc.userid - WHERE arc.id=?"; - $sth = $this->db->prepare($sql); - $sth -> execute(array($aid)); - $row = $sth->fetch(); - $this->view->info = $row; - } - - } //新闻发布 @@ -1329,21 +1317,41 @@ class AuthorController extends Zend_Controller_Action $this->_helper->viewRenderer('news-edit'); $aid = (int)$this->_request->getParam('aid'); + $uuid = $this->_request->getParam('uuid'); if(empty($aid) || !is_numeric($aid)) { $this->_redirect('/error/error'); } - $sql = "SELECT arc.*,mdarc.uuid FROM news_archives arc - LEFT JOIN news_mdnews mdarc ON mdarc.aid = arc.id + if(!preg_match("/^[0-9A-Za-z]{8}-[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]{12}$/",$uuid)) + { + $this->_redirect('/error/error'); + } + + $this->view->uuid = $uuid; + + $sql = "SELECT arc.* FROM ".$News->tbl_archives." arc WHERE id=?"; $sth = $this->db->prepare($sql); $sth->execute(array($aid)); $row = $sth->fetch(); + $keywords = $News->GetTags($aid); + $row['keywords'] = join(",",$keywords); + $this->view->info = $row; + $sql = "SELECT md.title,md.uuid FROM metadata md + LEFT JOIN mdauthor a ON a.uuid = md.uuid + WHERE a.userid=? AND a.status=1 + "; + $sth = $this->db->prepare($sql); + $sth->execute(array($u_id)); + $rows = $sth->fetchAll(); + + $this->view->md = $rows; + }//$ac == "edit" //新闻发布的ajax动作 @@ -1436,47 +1444,28 @@ class AuthorController extends Zend_Controller_Action //默认填充数据 $data['source'] = "西部数据中心"; - $data['typeid'] = 0; $data['userid'] = $u_id; - $data['keyword'] = str_replace(",",",",$data['keyword']); + $keyword = str_replace(",",",",$data['keyword']); + $data['ts_published'] = date("Y-m-d H:i:s",time()); + $data['is_pub'] = true; + $data['image'] = ""; + + unset($data['keyword']); + + $dataNewsCategory = $category->GetOne('datanews'); + $dataNewsCategoryID = $dataNewsCategory['id']; //新闻添加 if(empty($aid)) { - $sql = "INSERT INTO news_archives - (userid,title,keywords,description,image,source,ts_published,is_pub,body) - VALUES - (?,?,?,?,?,?,?,?,?) - RETURNING id - "; - $sth = $this->db->prepare($sql); - $ex = $sth -> execute(array($data['userid'],$data['title'],$data['keyword'],$data['description'],'',$data['source'],'now()',1,$data['body'])); - + $newAid = $News->addArchive($data,$dataNewsCategoryID,$keyword,$uuid); //添加成功 - if($ex) + if($newAid>0) { - //写入文章ID对应UUID的表 - $archive = $sth->fetch(PDO::FETCH_ASSOC); - $aid = $archive['id']; - - $sql = "INSERT INTO news_mdnews (aid,uuid) VALUES (?,?)"; - $sth = $this->db->prepare($sql); - $uuidex = $sth->execute(array($aid,$uuid)); - - if($uuidex) - { - $msg['status'] = 1; - $msg['outstring'] = "新闻添加成功"; - $this->getResponse()->setHeader('Content-Type', 'application/json')->appendBody(Zend_Json::encode($msg)); - return true; - }else{ - $sql = "DELETE FROM news_archives WHERE id=$aid"; - @$this->db->exec($sql); //如果新闻添加失败就删除原新闻,否则产生重复错误 - $msg['status'] = 0; - $msg['error'] = "新闻添加失败,请重试"; - $this->getResponse()->setHeader('Content-Type', 'application/json')->appendBody(Zend_Json::encode($msg)); - return true; - } + $msg['status'] = 1; + $msg['outstring'] = "新闻添加成功"; + $this->getResponse()->setHeader('Content-Type', 'application/json')->appendBody(Zend_Json::encode($msg)); + return true; //添加失败 }else{ $msg['status'] = 0; @@ -1489,11 +1478,15 @@ class AuthorController extends Zend_Controller_Action //新闻修改 else { - $sql = "UPDATE news_archives SET title=?,keywords=?,description=?,body=? WHERE id=? AND userid=?"; - $sth = $this->db->prepare($sql); - $ex = $sth -> execute(array($data['title'],$data['keyword'],$data['description'],$data['body'],$aid,$data['userid'])); - - if($ex) + if($u_id != $News->getArchiveField($aid,"userid")) + { + $msg['status'] = 0; + $msg['outstring'] = "新闻编辑失败,您没有权限"; + $this->getResponse()->setHeader('Content-Type', 'application/json')->appendBody(Zend_Json::encode($msg)); + return true; + } + $updated = $News->updateArchive($aid,$data,$dataNewsCategoryID,$keyword,$uuid); + if($updated) { $msg['status'] = 1; $msg['outstring'] = "新闻编辑成功"; @@ -1526,8 +1519,36 @@ class AuthorController extends Zend_Controller_Action }//catch end }//$ac = 'newsadd' endif; - - }//newsAction() 数据新闻 + if($ac == "del") + { + $this->_helper->layout->disableLayout(); + $this->_helper->viewRenderer->setNoRender(); + + $aid = $this->_getParam('aid'); + if(!is_numeric($aid)) + { + $this->jsonexit(array("error"=>"参数错误")); + return true; + } + + $News = new Archive($this->db); + + if($u_id != $News->getArchiveField($aid,"userid")) + { + $this->jsonexit(array("error"=>"您没有权限")); + return true; + } + + if($News->DeleteArchives($aid)) + { + $this->jsonexit(array("deleted"=>$aid)); + return true; + }else{ + $this->jsonexit(array("error"=>"删除失败",'aid'=>$aid)); + return true; + } + } + }//newsAction() 数据新闻 function viewauthorsAction(){ @@ -1813,13 +1834,13 @@ class AuthorController extends Zend_Controller_Action if (empty($mrow)) //说明是新数据 { //导入元数据 - $iso=new ISO19115(); - @$iso->loadXML($row['xml']); - if ($iso->validate()) - { - $data=array("error"=>"元数据导入过程中发现错误。
".implode("
",$iso->error)); - $this->jsonexit($data); - return true; + $iso=new ISO19115(); + @$iso->loadXML($row['xml']); + if ($iso->validate()) + { + $data=array("error"=>"元数据导入过程中发现错误。
".implode("
",$iso->error)); + $this->jsonexit($data); + return true; } @$iso->saveDB($this->db); //进入评审库 @@ -1874,13 +1895,13 @@ class AuthorController extends Zend_Controller_Action return true; } else { //说明是已发布的数据且数据不存在评审信息 //同步元数据 - $iso=new ISO19115(); - @$iso->loadXML($row['xml']); - if ($iso->validate()) - { - $data=array("error"=>"元数据导入过程中发现错误。
".implode("
",$iso->error)); - $this->jsonexit($data); - return true; + $iso=new ISO19115(); + @$iso->loadXML($row['xml']); + if ($iso->validate()) + { + $data=array("error"=>"元数据导入过程中发现错误。
".implode("
",$iso->error)); + $this->jsonexit($data); + return true; } @$iso->saveDB($this->db); @@ -1921,13 +1942,13 @@ class AuthorController extends Zend_Controller_Action else if ($row['status']==-1 || $row['status']==0 || $row['status']==1) //取消发布的数据,初始状态,已接收 { //同步元数据 - $iso=new ISO19115(); - @$iso->loadXML($row['xml']); - if ($iso->validate()) - { - $data=array("error"=>"元数据导入过程中发现错误。
".implode("
",$iso->error)); - $this->jsonexit($data); - return true; + $iso=new ISO19115(); + @$iso->loadXML($row['xml']); + if ($iso->validate()) + { + $data=array("error"=>"元数据导入过程中发现错误。
".implode("
",$iso->error)); + $this->jsonexit($data); + return true; } @$iso->saveDB($this->db); @@ -2058,13 +2079,13 @@ class AuthorController extends Zend_Controller_Action else if ($row['status']>=5)//数据已经发布,再次修改后将只通知管理员,保留发布状态 { //同步元数据 - $iso=new ISO19115(); - @$iso->loadXML($row['xml']); - if ($iso->validate()) - { - $data=array("error"=>"元数据导入过程中发现错误。
".implode("
",$iso->error)); - $this->jsonexit($data); - return true; + $iso=new ISO19115(); + @$iso->loadXML($row['xml']); + if ($iso->validate()) + { + $data=array("error"=>"元数据导入过程中发现错误。
".implode("
",$iso->error)); + $this->jsonexit($data); + return true; } @$iso->saveDB($this->db); @@ -2249,7 +2270,7 @@ class AuthorController extends Zend_Controller_Action } //提交数据 else if($ac=="commit") - { + { $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(); @@ -2296,15 +2317,15 @@ class AuthorController extends Zend_Controller_Action $data = array("error"=>'无权限修改数据'); $this->jsonexit($data); return true; - } - //首先检查元数据错误 - $iso=new ISO19115(); - @$iso->loadXML($row['data']); - if ($iso->validate()) - { - $data=array("error"=>"元数据导入过程中发现错误。
".implode("
",$iso->error)); - $this->jsonexit($data); - return true; + } + //首先检查元数据错误 + $iso=new ISO19115(); + @$iso->loadXML($row['data']); + if ($iso->validate()) + { + $data=array("error"=>"元数据导入过程中发现错误。
".implode("
",$iso->error)); + $this->jsonexit($data); + return true; } // 保存数据作者信息 @@ -2376,7 +2397,7 @@ class AuthorController extends Zend_Controller_Action $this->jsonexit($data); return true; } - } + } //FTP else if($ac == "ftp") { @@ -2394,13 +2415,13 @@ class AuthorController extends Zend_Controller_Action ); $this->jsonexit($data); return true; - } - //安全检查: uuid必须是当前用户且为新建数据 - $sql="select * from geonetworkmetadata where uuid=? and uuid not in (select uuid from metadata) and owner=?"; - $sth=$this->db->prepare($sql); - $sth->execute(array($uuid,$u_id)); - $row=$sth->fetch(); - if (empty($row)) + } + //安全检查: uuid必须是当前用户且为新建数据 + $sql="select * from geonetworkmetadata where uuid=? and uuid not in (select uuid from metadata) and owner=?"; + $sth=$this->db->prepare($sql); + $sth->execute(array($uuid,$u_id)); + $row=$sth->fetch(); + if (empty($row)) { $data = array( 'error'=>"参数错误" @@ -2418,15 +2439,15 @@ class AuthorController extends Zend_Controller_Action $sql = "SELECT * FROM proftpusers WHERE userid='$uname' ORDER BY pkid DESC"; $sth = $this->db->prepare($sql); $sth->execute(); - $row = $sth->fetch(); - - //create directory for upload + $row = $sth->fetch(); + + //create directory for upload //server is not localhost, so we need a trick //$old=umask(0); //@mkdir($homedir,0777); - //umask($old); - $page=file_get_contents('http://ftp1.westgis.ac.cn/proftp_upload.php?uuid='.$uuid); - if (!empty($page)) die($page);//there are errors in visit ftp page + //umask($old); + $page=file_get_contents('http://ftp1.westgis.ac.cn/proftp_upload.php?uuid='.$uuid); + if (!empty($page)) die($page);//there are errors in visit ftp page if(!empty($row['pkid'])) @@ -2449,8 +2470,8 @@ class AuthorController extends Zend_Controller_Action $passwd = $this->genRandomString(16); //$sql = "UPDATE proftpusers SET passwd=?,uid=?,gid=?,homedir=? WHERE userid=?"; //$sth = $this->db->prepare($sql); - //$rs = $sth->execute(array($passwd,$uid,$gid,$homedir,$uname)); - $sql="update proftpusers SET passwd='".$passwd."',uid=".$uid.",gid=".$gid.",homedir='".$homedir."' WHERE userid='".$uname."'"; + //$rs = $sth->execute(array($passwd,$uid,$gid,$homedir,$uname)); + $sql="update proftpusers SET passwd='".$passwd."',uid=".$uid.",gid=".$gid.",homedir='".$homedir."' WHERE userid='".$uname."'"; $rs=$this->db->query($sql); if($rs) { @@ -2478,8 +2499,8 @@ class AuthorController extends Zend_Controller_Action //$sql = "INSERT INTO proftpusers (userid,passwd,uid,gid,homedir) VALUES (?,?,?,?,?)"; //$sth = $this->db->prepare($sql); - //$rs = $sth->execute(array($uname,$passwd,$uid,$gid,$homedir)); - $sql="insert into proftpusers (userid,passwd,uid,gid,homedir) values('".$uname."','".$passwd."',109,1002,'".$homedir."')"; + //$rs = $sth->execute(array($uname,$passwd,$uid,$gid,$homedir)); + $sql="insert into proftpusers (userid,passwd,uid,gid,homedir) values('".$uname."','".$passwd."',109,1002,'".$homedir."')"; $rs=$this->db->query($sql); if($rs) { @@ -3442,7 +3463,7 @@ class AuthorController extends Zend_Controller_Action $this->getResponse()->setHeader('Content-Type', 'application/json')->appendBody(Zend_Json::encode($data)); return true; }//jsonexit() 退出并返回json数据 - + private function genRandomString($len) { $chars = array( diff --git a/application/default/views/scripts/archives/archive.phtml b/application/default/views/scripts/archives/archive.phtml index e9eed3d3..d46fd579 100644 --- a/application/default/views/scripts/archives/archive.phtml +++ b/application/default/views/scripts/archives/archive.phtml @@ -40,6 +40,9 @@ $this->headMeta()->appendName('description', mb_substr($this->infos['description
infos['title'];?>
时间 : infos['ts_published']));?>  作者 : infos['author'];?>  来源 : infos['source'];?>
+ mdinfo)){?> +
相关数据:《mdinfo['title']?>
+
diff --git a/application/default/views/scripts/author/news-edit.phtml b/application/default/views/scripts/author/news-edit.phtml index eba0ad46..3ba60960 100644 --- a/application/default/views/scripts/author/news-edit.phtml +++ b/application/default/views/scripts/author/news-edit.phtml @@ -38,6 +38,27 @@ $this->breadcrumb()->setSeparator(' > '); 请准确概况新闻内容

+

+
+ + 从数据中选择一条 +


diff --git a/application/default/views/scripts/author/news.phtml b/application/default/views/scripts/author/news.phtml index 02c2125d..ef0ed7f4 100644 --- a/application/default/views/scripts/author/news.phtml +++ b/application/default/views/scripts/author/news.phtml @@ -4,6 +4,8 @@ $this->headTitle($this->config->title->author); $this->headTitle()->setSeparator(' - '); $this->headScript()->appendFile('/js/jquery-1.7.min.js'); $this->headLink()->appendStylesheet('/css/author.css'); +$this->headScript()->appendFile('/js/jquery.colorbox-min.js'); +$this->headLink()->appendStylesheet('/css/colorbox.css'); $this->breadcrumb('首页'); $this->breadcrumb('数据作者'); $this->breadcrumb('数据新闻'); @@ -37,9 +39,14 @@ $this->breadcrumb()->setSeparator(' > '); foreach ($this->paginator as $item): $autoindex++; ?> -

  • -

    -

    作者: 发布时间:

    +
  • +

    +

    + 作者: | + 发布时间: | + 关联数据:《》 | + 操作:编辑 · + 删除

  • breadcrumb()->setSeparator(' > '); \ No newline at end of file diff --git a/application/models/Archive.php b/application/models/Archive.php index 9540347f..26a2c3e0 100644 --- a/application/models/Archive.php +++ b/application/models/Archive.php @@ -124,21 +124,31 @@ class Archive foreach($rows as $k=>$v) { $types[] = $v['cid']; - if(!in_array($v['cid'],$typeid)) + if(is_array($typeid)) { - //删除一个栏目 + if(!in_array($v['cid'],$typeid)) + { + //删除一个栏目 + $this->DeleteCatalog($v['id']); + } + }else{ $this->DeleteCatalog($v['id']); } } - foreach($typeid as $v) + if(is_array($typeid)) { - - if(!in_array($v,$types)) + foreach($typeid as $v) { - //添加一个栏目 - $this->ToCatalog($aid,$v); + + if(!in_array($v,$types)) + { + //添加一个栏目 + $this->ToCatalog($aid,$v,$uuid,$status); + } } + }else{ + $this->ToCatalog($aid,$typeid,$uuid,$status); } return true; }catch(Exception $e){ @@ -204,7 +214,7 @@ class Archive { $tag = explode(",",$keywords); }else{ - if($this->db->insert($this->tbl_tag,array("id"=>$aid,"tag"=>$tag))) + if($this->db->insert($this->tbl_tag,array("id"=>$aid,"tag"=>$keywords))) { return true; }else{ @@ -275,7 +285,7 @@ class Archive * * @return int; */ - function addArchive($data,$typeid,$keyword='') + function addArchive($data,$typeid,$keyword='',$uuid='') { $data = $this->scanField($data); @@ -303,7 +313,7 @@ class Archive { $temp = $sth->fetch(PDO::FETCH_ASSOC); $newAid = $temp['id']; - $this->AddToCatalog($newAid,$typeid); + $this->AddToCatalog($newAid,$typeid,$uuid); if(!empty($keyword)) { $this->MakeTags($newAid,$keyword); @@ -325,7 +335,7 @@ class Archive * * @return int */ - function updateArchive($aid,$data,$typeid,$keyword='') + function updateArchive($aid,$data,$typeid,$keyword='',$uuid='') { if(!is_numeric($aid)) { @@ -356,7 +366,7 @@ class Archive $this->DeleteTags($aid); $this->MakeTags($aid,$keyword); } - $this->ChangeCatalog($aid,$typeid); + $this->ChangeCatalog($aid,$typeid,$uuid); return $aid; }else{ return 0; @@ -503,4 +513,25 @@ class Archive $rows=$sth->fetch(); return $rows; } + + /* + * getArchiveField() 读取某个文档的某个字段 + * + * @param int $aid + * + * @return string + */ + function getArchiveField($aid,$field) + { + if(!is_numeric($aid)) + { + return false; + } + + $sql = "SELECT $field as output_string FROM ".$this->tbl_archives." WHERE id=$aid"; + $sth = $this->db->query($sql); + $row = $sth->fetch(); + + return $row['output_string']; + } } diff --git a/application/models/ArchiveCategory.php b/application/models/ArchiveCategory.php index 3edbbec7..bc6fa3e7 100644 --- a/application/models/ArchiveCategory.php +++ b/application/models/ArchiveCategory.php @@ -241,12 +241,12 @@ class ArchiveCategory if(is_numeric($tid)) { - $wehresql = "id=$tid"; + $wheresql = "id=$tid"; }else{ $wheresql = "code='$tid'"; } - $sql = "SELECT * FROM ".$this->CategoryTable." WHERE id=$tid"; + $sql = "SELECT * FROM ".$this->CategoryTable." WHERE $wheresql"; $sth = $this->db->query($sql); return $sth->fetch();