* Change ajaxGetProductByRepo function.

This commit is contained in:
dingguodong
2021-07-22 15:25:32 +08:00
parent f91513425f
commit 0db7f60ed2
+21 -3
View File
@@ -254,12 +254,30 @@ class job extends control
*
* @param int $repoID
* @access public
* @return void
* @return string
*/
public function ajaxGetProductByRepo($repoID)
{
$repo = $this->loadModel('repo')->getRepoByID($repoID);
if($repo) return $repo->product;
die(js::error("Access Violation. 非法访问。"));
if(empty($repo)) die(json_encode(array(""=>"")));
$product = $repo->product;
if(strpos($product, ','))
{
$productList = explode(',', $product);
$matchedProducts = array();
$productPair = $this->loadModel('product')->getPairs();
foreach($productList as $productLeft)
{
foreach($productPair as $productRight => $productName)
{
if($productLeft == $productRight) $matchedProducts[$productName] = $productRight;
}
}
die(json_encode($matchedProduct));
}
$productName = $this->loadModel('product')->getByID($repo->product)->name;
die(json_encode(array($productName => $repo->product)));
}
}