Ejemplo n.º 1
0
 /**
  * 	getUserASList
  *
  * 	Prepares a list of EasyContactForms users to send to the Ajax Suggest
  * 	list component
  *
  * @param array $_asmap
  * 	request data
  */
 function getUserASList($_asmap)
 {
     $plainselect = "SELECT\n\t\t\t\t\t\tUsers.id,\n\t\t\t\t\t\tUsers.Description\n\t\t\t\t\tFROM(\n\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\tCONCAT(Users1.Description,' ', Users1.Name) AS Description,\n\t\t\t\t\t\t\tUsers1.id\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t#wp__easycontactforms_users AS Users1) AS Users";
     $values = array();
     $_result = array();
     $_idmode = isset($_asmap['oid']);
     if ($_idmode) {
         $values['fvalues'][':input'] = intval($_asmap['oid']);
         $_query = "{$plainselect} WHERE Users.id=:input";
     } else {
         $asinput = EasyContactFormsUtils::getASInput($_asmap);
         if (!$asinput) {
             return $_result;
         }
         $values['fvalues'][':input'] = "%{$asinput->input}%";
         $_limit = $asinput->limit;
         $_query = "{$plainselect} WHERE Users.Description LIKE :input {$_limit}";
     }
     $_aslist = EasyContactFormsDB::select($_query, $values);
     foreach ($_aslist as $_asitem) {
         $_resultitem = array();
         $_resultitem['id'] = $_asitem->id;
         $_resultitem['value'] = trim($_asitem->Description);
         $_resultitem['info'] = $this->getObjectASForm($_asitem->id);
         $_result[] = (object) $_resultitem;
     }
     return $_result;
 }
 /**
  * 	getBasicASList
  *
  * 	prepares data for ajax suggest lists
  *
  * @param array $_asmap
  * 	request data
  * @param string $query
  * 	an sql statement to execute
  *
  * @return array
  * 	array containing values prepared to be send via json
  */
 function getBasicASList($_asmap, $query)
 {
     $values = array();
     $_result = array();
     $asinput = EasyContactFormsUtils::getASInput($_asmap);
     if ($asinput) {
         $values['fvalues'][':input'] = "%{$asinput->input}%";
         $_limit = $asinput->limit;
         $query = $query . ' ' . $_limit;
     }
     $_items = EasyContactFormsDB::select($query, $values);
     foreach ($_items as $record) {
         $_resultitem = array();
         $_resultitem['id'] = $record->id;
         $_resultitem['value'] = trim($record->Description);
         $_resultitem['info'] = $this->getObjectASForm($record->id);
         $_result[] = (object) $_resultitem;
     }
     return $_result;
 }