Пример #1
0
<?php

/**
 * @version $Header$
 * @package address
 */
require_once ADDRESS_PKG_PATH . 'BitAddress.php';
$pkgname = ADDRESS_PKG_NAME;
$grpname = $pkgname . '_admin';
$gBitSmarty->assign('grpname', $grpname);
$list_grpname = $grpname . '_list';
$gBitSmarty->assign('list_grpname', $list_grpname);
$country_grpname = $grpname . '_country';
$gBitSmarty->assign('country_grpname', $country_grpname);
// Process the form if we've made some changes
if (isset($_REQUEST[$grpname . '_submit'])) {
    LibertyForm::storeConfigs($_REQUEST[$list_grpname], $pkgname);
    @BitAddressCountry::setDefault($_REQUEST[$country_grpname]['country_def']);
    @BitAddressCountry::setActive($_REQUEST[$country_grpname]['countries']);
}
$list_fields = array("list_country" => array('description' => 'Country', 'helptext' => 'Display the country.', 'type' => 'checkbox', 'value' => $gBitSystem->getConfig($pkgname . '_list_country')), "list_description" => array('description' => 'Description', 'helptext' => 'Display the address description field.', 'type' => 'checkbox', 'value' => $gBitSystem->getConfig($pkgname . '_list_description')));
$gBitSmarty->assign('list_fields', $list_fields);
$countries = @BitAddressCountry::getPossibles('country_name');
$country_fields = array("country_def" => array("description" => "Default Country", "type" => "options", "options" => $countries, "value" => @BitAddressCountry::getDefault(), "required" => TRUE, "helptext" => "This selects the country that is selected by default when a new address is created."), "countries" => array("description" => "Available Countries", "type" => "options", "typopt" => "multiple", "options" => $countries, "value" => array_keys(BitAddressCountry::getPossibles('isocode2', TRUE)), "required" => TRUE, "helptext" => "Select the multiple countries available by holding down Shift/Ctrl."));
$gBitSmarty->assign_by_ref('country_fields', $country_fields);
Пример #2
0
 /**
  * @param array $pParamHash
  * @return array list of objects of this type in DB, sorted and paging dealt with.
  */
 public static function getList(&$pParamHash)
 {
     global $gBitSystem;
     // Fix default sort mode if one not specified
     if (!isset($pParamHash['sort_mode'])) {
         $pParamHash['sort_mode'] = 'name_last_asc';
     }
     // this makes sure parameters used later on are set
     parent::prepGetList($pParamHash);
     $selectSql = $joinSql = $whereSql = '';
     $bindVars = array();
     array_push($bindVars, self::CONTENT_TYPE_GUID);
     parent::getServicesSql('content_list_sql_function', $selectSql, $joinSql, $whereSql, $bindVars);
     // this will set $find, $sort_mode, $max_records and $offset
     extract($pParamHash);
     if (is_array($find)) {
         $whereSql .= " AND (lc.`title` IN (" . implode(',', array_fill(0, count($find), '?')) . ")) ";
         $bindVars = array_merge($bindVars, $find);
     } elseif (is_string($find)) {
         $whereSql .= " AND (UPPER(lc.`title`) like ?) ";
         $bindVars[] = '%' . strtoupper($find) . '%';
     }
     $query = "\n\t\t\tSELECT data.*, lc.`content_id`, lc.`title`, lc.`data`\n\t\t\t\t{$selectSql}\n\t\t\tFROM `" . BIT_DB_PREFIX . self::DATA_TBL . "` data\n\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON (lc.`content_id` = data.`content_id`)\n\t\t\t\t{$joinSql}\n\t\t\tWHERE (lc.`content_type_guid` = ?)\n\t\t\t\t{$whereSql}\n\t\t\tORDER BY " . $gBitSystem->mDb->convertSortmode($sort_mode);
     $result = $gBitSystem->mDb->query($query, $bindVars, $max_records, $offset);
     $ret = array();
     while ($res = $result->fetchRow()) {
         $res['display_url'] = self::getUrl(PERSON_PKG_URL, 'person_id', $res['person_id']);
         $res['edit_url'] = self::getUrl(PERSON_PKG_URL, 'person_id', $res['person_id'], 'edit');
         $res['remove_url'] = self::getUrl(PERSON_PKG_URL, 'person_id', $res['person_id'], 'remove');
         $ret[] = $res;
     }
     $query_cant = "\n\t\t\tSELECT COUNT(*)\n\t\t\tFROM `" . BIT_DB_PREFIX . self::DATA_TBL . "` data\n\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON (lc.`content_id` = data.`content_id`)\n\t\t\t\t{$joinSql}\n\t\t\tWHERE (lc.`content_type_guid` = ?)\n\t\t\t\t{$whereSql}";
     $pParamHash["cant"] = $gBitSystem->mDb->getOne($query_cant, $bindVars);
     // add all pagination info to pParamHash
     parent::postGetList($pParamHash);
     return $ret;
 }