* Change ajaxGetProductByRepo function.
This commit is contained in:
+21
-3
@@ -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)));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user