Sfoglia il codice sorgente

Ticket #3265 - 'Check Name' service added.

AntonLV 5 anni fa
parent
commit
a4c1b532eb
1 ha cambiato i file con 22 aggiunte e 15 eliminazioni
  1. 22 15
      modules/boonex/ads/classes/BxAdsModule.php

+ 22 - 15
modules/boonex/ads/classes/BxAdsModule.php

@@ -57,23 +57,10 @@ class BxAdsModule extends BxBaseModTextModule
     {
         $CNF = &$this->_oConfig->CNF;
 
-        $sName = '';
-
-    	$sTitle = bx_process_input(bx_get($CNF['FIELD_TITLE']));
-    	if(empty($sTitle))
-            return echoJson(array());
-
         $iId = (int)bx_get($CNF['FIELD_ID']);
-        if(!empty($iId)) {
-            $aEntry = $this->_oDb->getContentInfoById($iId); 
-            if(strcmp($sTitle, $aEntry[$CNF['FIELD_NAME']]) == 0) 
-                $sName = $sTitle;
-        }
+    	$sTitle = bx_process_input(bx_get($CNF['FIELD_TITLE']));
 
-    	echoJson(array(
-            'title' => $sTitle,
-            'name' => !empty($sName) ? $sName : $this->_oConfig->getEntryName($sTitle, $iId)
-    	));
+    	echoJson($this->serviceCheckName($sTitle, $iId));
     }
 
     public function actionInterested()
@@ -195,6 +182,26 @@ class BxAdsModule extends BxBaseModTextModule
         ));
     }
 
+    public function serviceCheckName($sTitle, $iId = 0)
+    {
+        $CNF = &$this->_oConfig->CNF;
+
+    	if(empty($sTitle))
+            return array();
+
+        $sName = '';
+        if(!empty($iId)) {
+            $aEntry = $this->_oDb->getContentInfoById($iId); 
+            if(strcmp($sTitle, $aEntry[$CNF['FIELD_NAME']]) == 0) 
+                $sName = $sTitle;
+        }
+
+        return array(
+            'title' => $sTitle,
+            'name' => !empty($sName) ? $sName : $this->_oConfig->getEntryName($sTitle, $iId)
+    	);
+    }
+
     public function serviceUpdateCategoriesStats()
     {
         $aStats = $this->_oDb->getCategories(array('type' => 'collect_stats'));