Esempio n. 1
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. 2
0
 function showApp()
 {
     global $navBarText, $categoryColumnsNum, $language, $jQueryLib;
     JavaScript::addInclude(GORUM_JS_DIR . $jQueryLib);
     JavaScript::addCss(CSS_DIR . "/layout.css");
     JavaScript::addCss(CSS_DIR . "/pages.css");
     if (is_callable(array("ThemeConfig", "init"))) {
         ThemeConfig::init();
     }
     $this->makeLoginMenu();
     $this->makeAdminMenu();
     $this->applyDebugMode();
     if (class_exists('rss')) {
         Rss::makeRssFeed();
     } else {
         View::assign("mainClass", 'main_withoutSidebar');
         View::assign("outerMainClass", 'outerMain_withoutSidebar');
     }
     CustomList::getList(customlist_top);
     CustomList::getList(customlist_bottom);
     CustomList::getList(customlist_aboveContent);
     CustomList::getList(customlist_belowContent);
     CustomList::getList(customlist_right);
     CustomList::getList(customlist_left);
     $_S =& new AppSettings();
     View::assign("baseUrl", Controller::getBaseUrl());
     View::assign("userStatus", $this->showUserStatus());
     View::assign("themeSelector", $this->showSelector("Theme"));
     View::assign("languageSelector", $this->showSelector("Language"));
     View::assign("versionFooter", $_S->versionFooter);
     View::assign("infoText", $this->showInfoText());
     View::assign("jsIncludes", JavaScript::getIncludes());
     View::assign("javaScript", JavaScript::getScript());
     View::assign("titlePrefix", $_S->getAttr("titlePrefix"));
     View::assign("categoryColumnsNum", $categoryColumnsNum);
     View::assign("cssDir", CSS_DIR);
     View::assign("imagesDir", IMAGES_DIR);
     View::assign("language", $language);
     View::assign("langDir", $_S->langDir);
     View::assign("extraBody", $_S->getProAttr("extraBody"));
     View::assign("extraFooter", $_S->getProAttr("extraFooter"));
     View::assign("extraHead", $_S->getProAttr("extraHead"));
     View::assign("extraTopContent", $_S->getProAttr("extraTopContent"));
     View::assign("extraBottomContent", $_S->getProAttr("extraBottomContent"));
     AppCategory::assignCurrentCategoryFields();
     User::assignCurrentUserFields();
 }
Esempio n. 3
0
 function handleEnumValueChange($stack = FALSE, $oldValue = FALSE, $newValue = FALSE)
 {
     if ($stack === FALSE) {
         if (!isset($_POST["optionValueModificationStack"]) || !count($stack = JavaScript::jsonDecode($_POST["optionValueModificationStack"]))) {
             return;
         }
         // ha nem vol modositas, vagy torles
     }
     if ($oldValue !== FALSE) {
         // ha propagate van, nem csak azokat a modositasokat kell figyelembe venni, amik az adott modifyban tortentek,
         // hanem a korabbiakat is. Ezt a 'values' regi es uj ertekenek osszehasonlitasaval erjuk el. Ha talalunk olyat,
         // ami nincs benne az uj 'values'-ban, azt hozzaadjuk $stack-hoz egy 'delete' action-nel:
         $oldValueArr = splitByCommas($oldValue, FALSE);
         // without HTML encoding
         $modified = array_unique(array_map(create_function('$v', 'return $v[0]=="modify" ? $v[1] : "";'), $stack));
         foreach ($oldValueArr as $val) {
             if (!in_array($val, $newValue) && !in_array($val, $modified)) {
                 $stack[] = array("delete", $val);
             }
         }
     }
     if (!$stack) {
         return;
     }
     // ha az old es new values osszehasonlitasa utan se derul ki, hogy lett volna torles v. modositas
     CustomField::addCustomColumns($this->getManagedTable());
     $affectedValues = array_map(create_function('$v', 'return quoteSQL(str_replace(",", ",,", $v[1]));'), $stack);
     $regexp = array();
     $columnIndex = G::getAttr($this->id, "itemfield", "columnIndex");
     foreach ($affectedValues as $v) {
         $regexp[] = "{$columnIndex} LIKE '%{$v}%'";
     }
     $whereCond = " WHERE (" . implode(" OR ", $regexp) . ")";
     if ($this->cid) {
         $whereCond .= " AND (cid={$this->cid} OR cid=0)";
     }
     $query = "SELECT id, {$columnIndex} FROM @" . $this->getManagedTable() . $whereCond;
     G::load($objs, $query);
     $customLists = new CustomList();
     $customLists->activateVariableFields();
     $query = "SELECT * FROM @search {$whereCond}";
     if (!loadObjectsSql($customLists, $query, $customLists)) {
         $objs = array_merge($objs, $customLists);
     }
     foreach ($objs as $obj) {
         $vals = splitByCommas($obj->{$columnIndex}, FALSE);
         $map = array_flip($vals);
         foreach ($stack as $action) {
             if (isset($map[$action[1]])) {
                 // modositjuk, ha modify, uresre allitjuk, ha delete:
                 $vals[$map[$action[1]]] = $action[0] == 'modify' ? $action[2] : "";
             }
         }
         $obj->{$columnIndex} = array_filter($vals);
         // removes the empty values
         if (is_a($obj, "search")) {
             $obj->modify(TRUE);
         } else {
             modify($obj);
         }
     }
 }
Esempio n. 4
0
 function deleteColumn($field)
 {
     if ($field->isCommon) {
         $cidCond = "";
     } else {
         $cidCond = " AND cid=#cid#";
     }
     // ha nem common a custom field, amit torlunk, csak azoknak a custom listeknek az oszlopaibol kell torolni,
     // amik a field categoriajara specifikusak:
     $query = array("SELECT id, `columns`, cache FROM @search WHERE FIND_IN_SET(#id#, `columns`)!=0 {$cidCond}", "columns", $field->id, "columns", $field->cid);
     loadObjectsSql($lists = new CustomList(), $query, $lists);
     foreach ($lists as $l) {
         $f = preg_replace("{(,)?\\b{$this->id}\\b(?(1)|(,|\$))}", "", $l->columns);
         executeQuery(array("UPDATE @search SET `columns`=#f# WHERE id=#id#", "columns", $f, $l->id));
         if ($l->cache) {
             CacheManager::resetCache($l->id, TRUE, FALSE);
         }
     }
     $query = array("SELECT *, '' AS str FROM @search WHERE query LIKE '%{$field->columnIndex}%' {$cidCond}", $field->cid);
     $lists = new CustomList();
     $lists->cid = $field->cid;
     $lists->activateVariableFields();
     loadObjectsSql($lists, $query, $lists);
     foreach ($lists as $l) {
         unset($l->{$field->columnIndex});
         $l->makeSearchQuery(TRUE);
         modify($l);
         if ($l->cache) {
             CacheManager::resetCache($l->id, TRUE, FALSE);
         }
     }
 }
Esempio n. 5
0
 function getCacheTimeFrameAndCategorySpecificity()
 {
     global $gorumroll;
     $timeFrame = $categorySpecific = 0;
     if ($gorumroll->list == "item_search" && $gorumroll->rollid > 2) {
         // lekerdezzuk a custom list 'cache' mezejet:
         if ($result = executeQuery(array("SELECT * FROM @search WHERE id=#id#", $gorumroll->rollid))) {
             $row = mysql_fetch_array($result, MYSQL_ASSOC);
             $timeFrame = $row["cache"];
             $categorySpecific = $row["categorySpecific"];
             CustomList::getSortingSql($row["primarySort"], $row["primaryDir"], $row["primaryPersistent"], $row["secondarySort"], $row["secondaryDir"], $row["secondaryPersistent"]);
         }
     }
     return array($timeFrame, $categorySpecific);
 }
Esempio n. 6
0
 public function display()
 {
     $template = new Template();
     $template->load("formeditor");
     $form = new Form($_GET['form']);
     if (isset($_POST['datatype']) && !isset($_POST['save'])) {
         $form->dataTypeID = $_POST['datatype'];
         $form->clearFieldsFromDB();
     }
     foreach ($_POST as $key => $value) {
         $id = explode('_', $key);
         $id = $id[0];
         if (is_numeric($id)) {
             $key = substr($key, strlen($id) + 1);
             $fields[$id][$key] = $value;
         }
     }
     if (isset($fields)) {
         foreach ($fields as $field) {
             $formField = new FormField();
             $formField->sortIndex = $field['sortIndex'];
             $formField->dataName = $field['dataname'];
             $formField->label = $field['label'];
             if ($field['insert']) {
                 $formField->insert = true;
             } else {
                 $formField->insert = false;
             }
             if (isset($field['mandatory']) && $field['mandatory']) {
                 $formField->mandatory = true;
             } else {
                 $formField->mandatory = false;
             }
             if ($field['show']) {
                 $formField->show = true;
             } else {
                 $formField->show = false;
             }
             $formField->edit = $field['edit'];
             $formField->preAllocate = $field['value'];
             $form->addField($formField);
         }
     }
     if (isset($_POST['save'])) {
         $form->buttonText = $_POST['buttontext'];
         $form->succeedMessage = $_POST['succeedmessage'];
         $form->dataTypeID = $_POST['datatype'];
         if (isset($_POST['captcha']) && $_POST['captcha']) {
             $form->captcha = true;
         } else {
             $form->captcha = false;
         }
         if (isset($_POST['showAfterInsert']) && $_POST['showAfterInsert']) {
             $form->showAfterInsert = true;
         } else {
             $form->showAfterInsert = false;
         }
         $form->save();
     }
     $combobox = new combobox();
     $combobox->fillSelect = "SELECT 0 as value, '' as label UNION SELECT id as value, displayName as label FROM {'dbprefix'}datatypes ORDER BY label";
     $combobox->value = $form->dataTypeID;
     $combobox->name = 'datatype';
     $combobox->onChange = "document.form.submit();";
     $template->assign_var("DATATYPE", $combobox->getCode());
     $buttonText = new textbox();
     $buttonText->name = "buttontext";
     $buttonText->value = $form->buttonText;
     $template->assign_var("BUTTONTEXT", $buttonText->getCode());
     $succeedMessage = new textbox();
     $succeedMessage->name = "succeedmessage";
     $succeedMessage->value = $form->succeedMessage;
     $template->assign_var("SUCCEEDMESSAGE", $succeedMessage->getCode());
     $captcha = new checkbox();
     $captcha->name = "captcha";
     $captcha->value = $form->captcha;
     $template->assign_var("CAPTCHA", $captcha->getCode());
     $showAfterInsert = new checkbox();
     $showAfterInsert->name = "showAfterInsert";
     $showAfterInsert->value = $form->showAfterInsert;
     $template->assign_var("SHOWAFTERINSERT", $showAfterInsert->getCode());
     $list = new CustomList();
     if ($form->isEmpty()) {
         $list->fillSelect = "SELECT *, @rownum:=@rownum+1 AS sortindex, 'checked' as show_check, '' as mandatory_check, 'checked' as insert_check, '\\'\\'' as preallocate FROM (SELECT @rownum:=0) r, {'dbprefix'}datafields WHERE dataType = '" . $form->dataTypeID . "' ORDER BY displayName";
     } else {
         $list->fillSelect = "SELECT *, label as displayname, @rownum:=@rownum+1 as id, IF( `show` = '1', 'checked', '' ) as show_check, IF( `insert` = '1', 'checked', '' ) as insert_check, IF( `mandatory` = '1', 'checked', '' ) as mandatory_check FROM (SELECT @rownum:=0) r, {'dbprefix'}form_fields WHERE form = '" . $form->id . "' ORDER by sortIndex";
     }
     $list->template = "formfield_editor";
     $list->paddingLeft = 0;
     $list->showButtons = false;
     $template->assign_var("FIELDS", $list->getCode());
     $template->output();
 }
Esempio n. 7
0
        $this->items = $items;
        $this->position = 0;
    }
    function rewind()
    {
        $this->position = 0;
    }
    function current()
    {
        return $this->items[$this->position];
    }
    function key()
    {
        return $this->position;
    }
    function next()
    {
        ++$this->position;
    }
    function valid()
    {
        return isset($this->items[$this->position]);
    }
}
$customList = new CustomList();
for ($i = 1; $i < 10; $i++) {
    $customList->add(new CustomObject("Object {$i}"));
}
foreach ($customList as $obj) {
    echo $obj->name, "\n";
}
Esempio n. 8
0
 function getList($position)
 {
     global $gorumview, $gorumroll, $ajaxMethods;
     if (!class_exists("rss")) {
         return;
     }
     $positionMapping = array("customListAboveContent", "customListBelowContent", "customListTop", "customListBottom", "customListLeft", "customListRight");
     $listToPageAssignment =& CustomList::getListToPageAssignment();
     $ajaxMethods["item_search"]["showhtmllist"] = array();
     foreach ($listToPageAssignment[$position] as $listId) {
         // hogy a page title, description es keyword-be ne zavarjon be:
         $ajaxMethods["item_search"]["showhtmllist"][] = $listId;
         $ctrl =& new AppController("customlist/{$listId}");
         $gorumroll->processMethod($ctrl, $positionMapping[$position]);
     }
 }