Esempio n. 1
0
 function create($fromInstall = FALSE, $fromClone = FALSE)
 {
     global $lll;
     if (!isset($this->sortId)) {
         $query = "SELECT MAX(sortId) as sortId FROM @category WHERE up=#up#";
         loadSQL($catStat = new AppCategory(), array($query, $this->up));
         $this->sortId = isset($catStat->sortId) ? $catStat->sortId + 100 : 100;
     }
     $this->handleExpirationFieldsContraversy();
     Category::create();
     if (!$fromClone && !Roll::isFormInvalid()) {
         $this->addDefaultCustomFields($fromInstall);
         $this->storeAttachment();
         Roll::setInfoText("created", $lll[$this->get_class()]);
     }
 }
Esempio n. 2
0
 function create()
 {
     global $lll, $noahVersion, $gorumroll;
     $exportExtensions = array(customlist_xml => "xml", customlist_csv => "csv");
     hasAdminRights($isAdm);
     if (!$isAdm) {
         return;
     }
     include GORUM_DIR . "/gorum_view.php";
     $list = new CustomList();
     $list->activateVariableFields();
     if (loadSQL($list, array("SELECT * FROM @search WHERE id=#id#", $gorumroll->rollid)) || !$list->exportFormat) {
         return;
     }
     $ext = $exportExtensions[$list->exportFormat];
     $date = date("Y-m-d-H-i-s");
     $fileName = LOG_DIR . "/export_{$date}.{$ext}";
     G::load($unsortedColumns, "SELECT * FROM @itemfield WHERE FIND_IN_SET(id, '{$list->exportFields}')!=0");
     // Hogy a $columns arary sorrendje ugyanaz legyen, mint $list->exportFields-ben:
     $columns = array();
     $length = count($unsortedColumns);
     foreach (explode(",", $list->exportFields) as $id) {
         for ($i = 0; $i < $length; $i++) {
             if ($unsortedColumns[$i]->id == $id) {
                 $columns[] = $unsortedColumns[$i];
                 break;
             }
         }
     }
     $ad = new Item();
     $ad->loadHtmlList($ads);
     array_walk($columns, create_function('$v', '
     if( $v->userField ) 
     { 
         list( $v->userColumnIndex, $v->type, $v->name, $v->allowHtml) = G::getAttr($v->userField, "userfield", "columnIndex", "type", "name", "allowHtml");            
     }
     else $v->userColumnIndex = "";
     $v->name = preg_replace(array("/$[\\d.-]/", "/[^\\w:]/"), "_", $v->name);'));
     $owner = new User();
     $owner->activateVariableFields();
     $fgName = "create_{$ext}";
     $this->{$fgName}($fileName, $list, $ads, $columns);
     $this->nextAction =& new AppController("customlist/list");
     Roll::setInfoText("exportSavedAs", $fileName);
 }
Esempio n. 3
0
 function getSortType(&$sortType, &$sortSqlAttr, $isCommon, $cid, $attr)
 {
     $sortType = 0;
     $sortSqlAttr = "";
     if (preg_match("/col_(\\d+)/", $attr, $matches)) {
         if (!loadSQL($cf = new CustomField(), array("SELECT * FROM @customfield WHERE isCommon=#isCommon# AND cid=#cid# AND columnIndex='{$attr}' LIMIT 1", $isCommon, $cid))) {
             if ($cf->userField) {
                 list($cf->type, $cf->subType, $attr) = G::getAttr($cf->userField, "customfield", "type", "subType", "columnIndex");
                 $sortSqlAttr = "u.{$attr}";
             } else {
                 $sortSqlAttr = "n.{$attr}";
             }
             if ($cf->type == customfield_date) {
                 $sortType = customfield_date;
             } elseif ($cf->subType == customfield_integer || $cf->subType == customfield_float) {
                 $sortType = $cf->subType;
             }
         }
     }
 }
Esempio n. 4
0
function load(&$base, $whereFields = "", $whatFields = "*")
{
    $whereExists = FALSE;
    $query = $base->getSelect();
    if (!$query) {
        $typ =& $base->getTypeInfo();
        $table = $base->get_table();
        $firstField = TRUE;
        $query = "SELECT {$whatFields} FROM @{$table}";
        if ($whereFields == "") {
            $whereFields = getPrimaryKey($typ);
        }
        foreach ($whereFields as $index => $attribute) {
            if (!isset($base->{$attribute})) {
                unset($whereFields[$index]);
            }
        }
        if (sizeof($whereFields) == 0) {
            $whereFields = array_keys($typ["attributes"]);
            foreach ($whereFields as $index => $attribute) {
                if (!isset($base->{$attribute})) {
                    unset($whereFields[$index]);
                }
            }
        }
        $sqlParams = array();
        foreach ($whereFields as $key) {
            if (isset($base->{$key})) {
                $value = $base->{$key};
                if (is_object($value)) {
                    $value = $value->getDbFormat($typ["attributes"][$key]["type"]);
                }
                $sqlParams[] = $value;
                if ($firstField) {
                    $query .= " WHERE @{$table}.{$key}=#param#";
                    $firstField = FALSE;
                    $whereExists = TRUE;
                } else {
                    $query .= " AND @{$table}.{$key}=#param#";
                }
            }
        }
        array_unshift($sqlParams, $query);
        $query = $sqlParams;
    } else {
        if (stristr($query, "WHERE")) {
            $whereExists = TRUE;
        }
    }
    if ($whereExists) {
        $ret = loadSQL($base, $query);
    } else {
        trigger_error("Load without WHERE: " . print_r($query, TRUE), E_USER_ERROR);
    }
    return $ret;
}
Esempio n. 5
0
 function getTransferData(&$_GS, $withReg = FALSE)
 {
     global $_GP, $_GA, $_GE;
     $_S =& new AppSettings();
     loadSQL($user = new User(), "SELECT email FROM @user WHERE isAdm=1 LIMIT 1");
     $data = "id=" . $_GS->reg;
     $data .= "&ip=" . urlencode($_SERVER["REMOTE_ADDR"]);
     $data .= "&name=" . urlencode(Controller::getBaseUrl());
     $data .= "&php=" . urlencode(phpversion());
     $data .= "&mysql=" . urlencode(mysql_get_server_info());
     $data .= "&version=" . urlencode($_GS->instver);
     $data .= "&date=" . urlencode($_GS->creationtime->getDbFormat());
     $data .= "&lastUpdate=" . urlencode($_GS->lastUpdate->getDbFormat());
     $data .= "&systemEmail=" . urlencode($_S->adminEmail);
     $data .= "&adminEmail=" . urlencode($user->email);
     if (!empty($_GE)) {
         $data .= "&orderEmail=" . urlencode($_GE);
     }
     if (!empty($_GP)) {
         $data .= "&orderCode=" . urlencode($_GP);
     }
     if (!empty($_GA)) {
         $data .= "&affiliateId=" . urlencode($_GA);
     }
     $branch = $this->getBranch();
     $data .= "&branch={$branch}";
     getDbCount($count, "SELECT COUNT(*) FROM @item");
     $data .= "&itemNum={$count}";
     getDbCount($count, "SELECT COUNT(*) FROM @category");
     $data .= "&catNum={$count}";
     $data .= "&webServer=" . (!empty($_SERVER['REQUEST_URI']) ? 'Apache' : 'IIS');
     $data .= "&theme=" . urlencode($_S->defaultTheme);
     $data .= "&lang=" . urlencode($_S->defaultLanguage);
     $data .= "&allowSelectTheme=" . $_S->allowSelectTheme;
     $data .= "&enablePermalinks=" . $_S->enablePermalinks;
     $data .= "&cascadingCategorySelect=" . $_S->cascadingCategorySelect;
     $data .= "&ecommerceEnabled=" . $_S->ecommerceEnabled;
     $data .= "&enableCombine=" . $_S->enableCombine;
     $data .= "&mainTitle=" . urlencode($_S->mainTitle);
     $data .= "&mainDescription=" . urlencode($_S->mainDescription);
     $data .= "&mainKeywords=" . urlencode($_S->mainKeywords);
     if ($_S->ecommerceEnabled == Settings_ecommEnabled) {
         $_ES =& new ECommSettings();
         $data .= "&model=" . $_ES->model;
         $data .= "&paypal_enabled=" . $_ES->paypal_enabled;
         $data .= "&authorize_net_enabled=" . $_ES->authorize_net_enabled;
         $data .= "&paypal_integrationMethod=" . $_ES->paypal_integrationMethod;
         $data .= "&authorize_net_integrationMethod=" . $_ES->authorize_net_integrationMethod;
         $gateways = array();
         foreach (GateWay::getGateways() as $gateway) {
             if ($gateway != 'paypal' && $gateway != 'authorize_net') {
                 $gateways[] = $gateway;
             }
         }
         $data .= "&extraGateways=" . urlencode(implode(", ", $gateways));
     }
     if ($withReg) {
         $data .= "&company=" . urlencode($_POST["company"]);
         $data .= "&firstName=" . urlencode($_POST["firstName"]);
         $data .= "&lastName=" . urlencode($_POST["lastName"]);
         $data .= "&email=" . urlencode($_POST["email"]);
     }
     return $data;
 }
Esempio n. 6
0
 function getDescription($encoding = TRUE)
 {
     static $commonDescriptionField = 0;
     $columnIndex = FALSE;
     if ($fields = $this->getFields()) {
         foreach ($fields as $field) {
             if ($field->seo == customfield_description) {
                 $columnIndex = $field->columnIndex;
                 break;
             }
         }
         if ($columnIndex === FALSE || !isset($this->{$columnIndex})) {
             return "";
         } else {
             if (!$commonDescriptionField) {
                 loadSQL($commonDescriptionField = new ItemField(), "SELECT * FROM @customfield WHERE isCommon=1 AND columnIndex='description'");
             }
             // a displayLength-en nem az egyes kategoriak description mezoinek displayLenght-je hatarozza meg,
             // hanem az amit a common description fieldben van:
             $this->applyDisplayLengthLimit($this->{$columnIndex}, $commonDescriptionField->displaylength);
             if ($encoding && !$field->allowHtml) {
                 return htmlspecialchars($this->{$columnIndex});
             } else {
                 return $this->{$columnIndex};
             }
         }
     } else {
         return "";
     }
 }
Esempio n. 7
0
 function exists($cid, $unsub)
 {
     $whereCond = "";
     if ($cid !== '*') {
         $whereCond .= "AND cid='{$cid}'";
     }
     if ($unsub !== '*') {
         $whereCond .= "AND unsub=" . intval($unsub);
     }
     $query = "SELECT id FROM @subscription WHERE email=#email# {$whereCond} LIMIT 1";
     //FP::log($query);
     return !loadSQL($s = new Subscription(), array($query, $this->email));
 }
Esempio n. 8
0
 function getListSelect()
 {
     global $lll, $gorumroll, $gorumuser;
     if ($gorumroll->list == "user" || $gorumroll->list == "user_inactive") {
         $select = "SELECT n.* " . $this->getSpecialSortAttrs() . " FROM @user AS n WHERE id!=name && isAdm=0 AND active=";
         $select .= $gorumroll->list == "user" ? "1" : "0";
     } elseif ($gorumroll->list == "user_search") {
         loadSQL($search = new Search(), array("SELECT query FROM @search WHERE uid=#uid# AND name=''", $gorumuser->id));
         $select = $search->query;
     }
     CustomField::addCustomColumns("user");
     //echo("$select<br><br>");
     return $select;
 }
Esempio n. 9
0
 function validPermaLink($queryPieces)
 {
     $_S =& new AppSettings();
     if (count($queryPieces) == 1 && !$_S->ommitCatPermaLink) {
         // Pl: /cars
         if (!loadSQL($cat = new AppCategory(), array("SELECT id FROM @category WHERE up=0 AND permaLink=#name# LIMIT 1", strtolower($queryPieces[0])))) {
             $this->Controller("appcategory", "showhtmllist", $cat->id);
             return TRUE;
         }
     } else {
         if (($pos = array_search("off", $queryPieces)) !== FALSE) {
             $catNameArr = array_slice($queryPieces, 0, $pos);
             $restOfTheQuery = array_slice($queryPieces, $pos);
         } else {
             $catNameArr =& $queryPieces;
             $restOfTheQuery = array();
         }
         // Pl: cars/1_audi_for_sale
         if (preg_match("/^(\\d+)_/", $catNameArr[count($catNameArr) - 1], $matches)) {
             $this->Controller("item", "showdetails", $matches[1]);
             return TRUE;
         }
         // Pl: /cars/economy_cars
         if (!loadSQL($cat = new AppCategory(), array("SELECT id FROM @category WHERE permaLink=#name# LIMIT 1", strtolower(implode("/", $catNameArr))))) {
             $this->Controller("appcategory", "showhtmllist", $cat->id, $restOfTheQuery);
             return TRUE;
         }
     }
     return FALSE;
 }
Esempio n. 10
0
 function getTitleDescriptionCondition($columnIndex)
 {
     if ($this->{$columnIndex} === '') {
         return "";
     }
     $word = quoteSQL($this->{$columnIndex});
     G::load($categories, "SELECT id FROM @category WHERE allowAd=1 AND directItemNum>0");
     $condOut = array();
     $tag = $columnIndex == "title" ? customfield_title : customfield_description;
     // az osszes kategoria title ill. description szerepkoru attributumaban keresunk:
     foreach ($categories as $cat) {
         if (!loadSQL($v = new CustomField(), "SELECT columnIndex, type, subType FROM @customfield WHERE cid='{$cat->id}' AND seo={$tag}")) {
             if ($v->subType == customfield_alnum || $v->type == customfield_textarea) {
                 $cond = "n.{$v->columnIndex} LIKE '%{$word}%'";
             } else {
                 $cond = "n.{$v->columnIndex}='{$word}'";
             }
             $condOut[] = "(cid='{$cat->id}' AND {$cond})";
         }
     }
     if (count($condOut)) {
         return "(" . implode(" OR ", $condOut) . ")";
     } else {
         return "";
     }
 }