Пример #1
0
 public function deleteGoogleVer($url)
 {
     //if there is a google verification tag then replace it with empty space
     if (getMetaData($url)) {
         $fp = fopen($url, 'w+');
         $lines = file($fp);
         $allLines = implode("", $lines);
         $entry = str_replace($googleTokenString, '', $allLines);
         fclose($fp);
         return true;
     } else {
         return false;
     }
 }
function arrayThemes()
{
    $ruta = '/archivos/labs/tfox/themes/';
    $directorio = $_SERVER["DOCUMENT_ROOT"] . $ruta;
    $baseURL = "http://www.mozilla-hispano.org";
    if (is_dir($directorio)) {
        $mydir = opendir($directorio);
        $num = 0;
        while ($archivo = readdir($mydir)) {
            $rutaArchivo = $directorio . $archivo;
            // Leemos todas las carpetas existentes y guardamos los datos
            if (is_dir($rutaArchivo) && $archivo != "." && $archivo != "..") {
                $datos = getMetaData($archivo, $directorio);
                $themes[$num] = array('name' => $datos['name'], 'screenshot' => $ruta . $archivo . '/screenshot.png', 'icon' => $baseURL . $ruta . $archivo . '/icon.png', 'theme' => $baseURL . $ruta . $archivo . '/theme.css', 'author' => $datos['author'], 'version' => $datos['version']);
                $num++;
            }
        }
        closedir($mydir);
    }
    return $themes;
}
<?php

// VARIABLES
$address = getMetaAddress();
$listingType = getMetaData('et_er_type');
$paymentType = getMetaData('et_er_adtype');
$secondaryTitle = $listingType . ' for ' . $paymentType;
$rentAmount = getMetaData('et_er_rent_price');
$saleAmount = getMetaData('et_er_price');
$paymentAmount = $paymentType == 'Rent' ? $rentAmount : $saleAmount;
$paymentFrequency = getMetaData('et_er_rent_tenure');
$property_imgs_ids = get_property_images_ids();
?>
<div class="banner-container cf">
  <div class="column">
    <div class='title'>
        <?php 
the_title();
?>
    </div>

    <div>

      <?php 
echo $address;
?>
    </div>
  </div>
  
  <div class="column">
Пример #4
0
function displayForm($formframe, $entry = "", $mainform = "", $done_dest = "", $button_text = "", $settings = "", $titleOverride = "", $overrideValue = "", $overrideMulti = "", $overrideSubMulti = "", $viewallforms = 0, $profileForm = 0, $printall = 0, $screen = null)
{
    include_once XOOPS_ROOT_PATH . '/modules/formulize/include/functions.php';
    include_once XOOPS_ROOT_PATH . '/modules/formulize/include/extract.php';
    formulize_benchmark("Start of formDisplay.");
    if ($titleOverride == "formElementsOnly") {
        $titleOverride = "all";
        $formElementsOnly = true;
    }
    if (!is_numeric($titleOverride) and $titleOverride != "" and $titleOverride != "all") {
        // we can pass in a text title for the form, and that will cause the $titleOverride "all" behaviour to be invoked, and meanwhile we will use this title for the top of the form
        $passedInTitle = $titleOverride;
        $titleOverride = "all";
    }
    //syntax:
    //displayform($formframe, $entry, $mainform)
    //$formframe is the id of the form OR title of the form OR name of the framework.  Can also be an array.  If it is an array, then flag 'formframe' is the $formframe variable, and flag 'elements' is an array of all the elements that are to be displayed.
    //the array option is intended for displaying only part of a form at a time
    //$entry is the numeric entry to display in the form -- if $entry is the word 'proxy' then it is meant to force a new form entry when the form is a single-entry form that the user already may have an entry in
    //$mainform is the starting form to use, if this is a framework (can be specified by form id or by handle)
    //$done_dest is the URL to go to after the form has been submitted
    //Steps:
    //1. identify form or framework
    //2. if framework, check for unified display options
    //3. if entry specified, then get data for that entry
    //4. drawform with data if necessary
    global $xoopsDB, $xoopsUser, $myts;
    global $sfidsDrawn;
    if (!is_array($sfidsDrawn)) {
        $sfidsDrawn = array();
    }
    $groups = $xoopsUser ? $xoopsUser->getGroups() : array(0 => XOOPS_GROUP_ANONYMOUS);
    $original_entry = $entry;
    // flag used to tell whether the function was called with an actual entry specified, ie: we're supposed to be editing this entry, versus the entry being set by coming back form a sub_form or other situation.
    $mid = getFormulizeModId();
    $currentURL = getCurrentURL();
    /* Alter currentURL if necessary.
     * Display list of entries screen on-click of form buttons "Save and Leave" and "Leave Page".
     */
    if (isset($_GET['sid'])) {
        $curr_screen = xoops_getmodulehandler('screen', 'formulize')->get($_GET['sid']);
        if ($curr_screen->getVar('type') == 'form') {
            $currentURL = $_SERVER['PHP_SELF'] . "?fid=" . $curr_screen->form_id();
        }
    } elseif (isset($_GET['ve']) && isset($_GET['fid'])) {
        $currentURL = $_SERVER['PHP_SELF'] . "?fid=" . $_GET['fid'];
    }
    // identify form or framework
    $elements_allowed = "";
    // if a screen object is passed in, select the elements for display based on the screen's settings
    if ($screen and is_a($screen, "formulizeFormScreen")) {
        $elements_allowed = $screen->getVar("formelements");
    }
    if (is_array($formframe)) {
        $elements_allowed = $formframe['elements'];
        $printViewPages = isset($formframe['pages']) ? $formframe['pages'] : "";
        $printViewPageTitles = isset($formframe['pagetitles']) ? $formframe['pagetitles'] : "";
        $formframetemp = $formframe['formframe'];
        unset($formframe);
        $formframe = $formframetemp;
    }
    list($fid, $frid) = getFormFramework($formframe, $mainform);
    if ($_POST['deletesubsflag']) {
        // if deletion of sub entries requested
        foreach ($_POST as $k => $v) {
            if (strstr($k, "delbox")) {
                $subs_to_del[] = $v;
            }
        }
        if (count($subs_to_del) > 0) {
            deleteFormEntries($subs_to_del, intval($_POST['deletesubsflag']));
            // deletesubsflag will be the sub form id
            sendNotifications($_POST['deletesubsflag'], "delete_entry", $subs_to_del, $mid, $groups);
        }
    }
    if ($_POST['parent_form']) {
        // if we're coming back from a subform
        $entry = $_POST['parent_entry'];
        $fid = $_POST['parent_form'];
    }
    if ($_POST['go_back_form']) {
        // we just received a subform submission
        $entry = $_POST['sub_submitted'];
        $fid = $_POST['sub_fid'];
        $go_back['form'] = $_POST['go_back_form'];
        $go_back['entry'] = $_POST['go_back_entry'];
    }
    // set $entry in the case of a form_submission where we were editing an entry (just in case that entry is not what is used to call this function in the first place -- ie: we're on a subform and the mainform has no entry specified, or we're clicking submit over again on a single-entry form where we started with no entry)
    $entrykey = "entry" . $fid;
    if ((!$entry or $entry == "proxy") and $_POST[$entrykey]) {
        // $entrykey will only be set when *editing* an entry, not on new saves
        $entry = $_POST[$entrykey];
    }
    // this is probably not necessary any more, due to architecture changes in Formulize 3
    // formulize_newEntryIds is set when saving data
    if (!$entry and isset($GLOBALS['formulize_newEntryIds'][$fid])) {
        $entry = $GLOBALS['formulize_newEntryIds'][$fid][0];
    }
    $member_handler =& xoops_gethandler('member');
    $gperm_handler =& xoops_gethandler('groupperm');
    if ($profileForm === "new") {
        // spoof the $groups array based on the settings for the regcode that has been validated by register.php
        $reggroupsq = q("SELECT reg_codes_groups FROM " . XOOPS_DB_PREFIX . "_reg_codes WHERE reg_codes_code=\"" . $GLOBALS['regcode'] . "\"");
        $groups = explode("&8(%\$", $reggroupsq[0]['reg_codes_groups']);
        if ($groups[0] === "") {
            unset($groups);
        }
        // if a code has no groups associated with it, then kill the null value that will be in position 0 in the groups array.
        $groups[] = XOOPS_GROUP_USERS;
        $groups[] = XOOPS_GROUP_ANONYMOUS;
    }
    $uid = $xoopsUser ? $xoopsUser->getVar('uid') : '0';
    $single_result = getSingle($fid, $uid, $groups, $member_handler, $gperm_handler, $mid);
    $single = $single_result['flag'];
    // if we're looking at a single entry form with no entry specified and where the user has no entry of their own, or it's an anonymous user, then set the entry based on a cookie if one is present
    // want to do this check here and override $entry prior to the security check since we don't like trusting cookies!
    $cookie_entry = (isset($_COOKIE['entryid_' . $fid]) and !$entry and $single and ($single_result['entry'] == "" or intval($uid) === 0)) ? $_COOKIE['entryid_' . $fid] : "";
    include_once XOOPS_ROOT_PATH . "/modules/formulize/class/data.php";
    $data_handler = new formulizeDataHandler($fid);
    if ($cookie_entry) {
        // check to make sure the cookie_entry exists...
        //$check_cookie_entry = q("SELECT id_req FROM " . $xoopsDB->prefix("formulize_form") . " WHERE id_req=" . intval($cookie_entry));
        //if($check_cookie_entry[0]['id_req'] > 0) {
        if ($data_handler->entryExists(intval($cookie_entry))) {
            $entry = $cookie_entry;
        } else {
            $cookie_entry = "";
        }
    }
    $owner = ($cookie_entry and $uid) ? $uid : getEntryOwner($entry, $fid);
    // if we're pulling a cookie value and there is a valid UID in effect, then assume this user owns the entry, otherwise, figure out who does own the entry
    $owner_groups = $data_handler->getEntryOwnerGroups($entry);
    if ($single and !$entry and !$overrideMulti and $profileForm !== "new") {
        // only adjust the active entry if we're not already looking at an entry, and there is no overrideMulti which can be used to display a new blank form even on a single entry form -- useful for when multiple anonymous users need to be able to enter information in a form that is "one per user" for registered users. -- the pressence of a cookie on the hard drive of a user will override other settings
        $entry = $single_result['entry'];
        $owner = getEntryOwner($entry, $fid);
        unset($owner_groups);
        //$owner_groups =& $member_handler->getGroupsByUser($owner, FALSE);
        $owner_groups = $data_handler->getEntryOwnerGroups($entry);
    }
    if ($entry == "proxy") {
        $entry = "";
    }
    // convert the proxy flag to the actual null value expected for new entry situations (do this after the single check!)
    $editing = is_numeric($entry);
    // will be true if there is an entry we're looking at already
    if (!($scheck = security_check($fid, $entry, $uid, $owner, $groups, $mid, $gperm_handler)) and !$viewallforms and !$profileForm) {
        print "<p>" . _NO_PERM . "</p>";
        return;
    }
    // main security check passed, so let's initialize flags
    $go_back['url'] = substr($done_dest, 0, 1) == "/" ? XOOPS_URL . $done_dest : $done_dest;
    // set these arrays for the one form, and they are added to by the framework if it is in effect
    $fids[0] = $fid;
    if ($entry) {
        $entries[$fid][0] = $entry;
    } else {
        $entries[$fid][0] = "";
    }
    if ($frid) {
        $linkResults = checkForLinks($frid, $fids, $fid, $entries, $gperm_handler, $owner_groups, $mid, $member_handler, $owner, true);
        // final true means only include entries from unified display linkages
        unset($entries);
        unset($fids);
        $fids = $linkResults['fids'];
        $entries = $linkResults['entries'];
        $sub_fids = $linkResults['sub_fids'];
        $sub_entries = $linkResults['sub_entries'];
    }
    // need to handle submission of entries
    $formulize_mgr =& xoops_getmodulehandler('elements', 'formulize');
    $info_received_msg = 0;
    $info_continue = 0;
    if ($entries[$fid][0]) {
        $info_continue = 1;
    }
    $add_own_entry = $gperm_handler->checkRight("add_own_entry", $fid, $groups, $mid);
    $add_proxy_entries = $gperm_handler->checkRight("add_proxy_entries", $fid, $groups, $mid);
    if ($_POST['form_submitted'] and $profileForm !== "new" and formulizePermHandler::user_can_edit_entry($fid, $uid, $entry)) {
        $info_received_msg = "1";
        // flag for display of info received message
        if (!isset($GLOBALS['formulize_readElementsWasRun'])) {
            include_once XOOPS_ROOT_PATH . "/modules/formulize/include/readelements.php";
        }
        $temp_entries = $GLOBALS['formulize_allWrittenEntryIds'];
        // set in readelements.php
        if (!$formElementsOnly and ($single or $_POST['target_sub'] or $entries[$fid][0] and ($original_entry or $_POST[$entrykey] and !$_POST['back_from_sub']) or $overrideMulti or $_POST['go_back_form'] and $overrideSubMulti)) {
            // if we just did a submission on a single form, or we just edited a multi, then assume the identity of the new entry.  Can be overridden by values passed to this function, to force multi forms to redisplay the just-saved entry.  Back_from_sub is used to override the override, when we're saving after returning from a multi-which is like editing an entry since entries are saved prior to going to a sub. -- Sept 4 2006: adding an entry in a subform forces us to stay on the same page too! -- Dec 21 2011: added check for !$formElementsOnly so that when we're getting just the elements in the form, we ignore any possible overriding, since that is an API driven situation where the called entry is the only one we want to display, period.
            $entry = $temp_entries[$fid][0];
            unset($entries);
            foreach ($fids as $thisWrittenFid) {
                $entries[$thisWrittenFid] = $temp_entries[$thisWrittenFid];
            }
            // also remove any fids that aren't part of the $temp_entries...added Oct 26 2011...checkforlinks now can return the mainform when we're on a sub!  It's smarter, but displayForm (and possibly other places) were not built to assume it was that smart.
            $writtenFids = array_keys($temp_entries);
            $fids = array_intersect($fids, $writtenFids);
            $owner = getEntryOwner($entry, $fid);
            unset($owner_groups);
            $owner_groups = $data_handler->getEntryOwnerGroups($entry);
            //$owner_groups =& $member_handler->getGroupsByUser($owner, FALSE);
            $info_continue = 1;
        } elseif (!$_POST['target_sub']) {
            // as long as the form was submitted and we're not going to a sub form, then display the info received message and carry on with a blank form
            if (!$original_entry) {
                // if we're on a multi-form where the display form function was called without an entry, then clear the entries and behave as if we're doing a new add
                unset($entries);
                unset($sub_entries);
                $entries[$fid][0] = "";
                $sub_entries[$sub_fids[0]][0] = "";
            }
            $info_continue = 2;
        }
    }
    $sub_entries_synched = synchSubformBlankDefaults($fid, $entry);
    foreach ($sub_entries_synched as $synched_sfid => $synched_ids) {
        foreach ($synched_ids as $synched_id) {
            $sub_entries[$synched_sfid][] = $synched_id;
        }
    }
    if (count($sub_entries_synched) > 0) {
        formulize_updateDerivedValues($entry, $fid, $frid);
    }
    // special use of $settings added August 2 2006 -- jwe -- break out of form if $settings so indicates
    // used to allow saving of information when you don't want the form itself to reappear
    if ($settings == "{RETURNAFTERSAVE}" and $_POST['form_submitted']) {
        return "returning_after_save";
    }
    // need to add code here to switch some things around if we're on a subform for the first time (add)
    // note: double nested sub forms will not work currently, since on the way back to the intermediate level, the go_back values will not be set correctly
    // target_sub is only set when adding a sub entry, and adding sub entries is now down by the subform ui
    //if($_POST['target_sub'] OR $_POST['goto_sfid']) {
    if ($_POST['goto_sfid']) {
        $info_continue = 0;
        if ($_POST['goto_sfid']) {
            $new_fid = $_POST['goto_sfid'];
        } else {
            $new_fid = $_POST['target_sub'];
        }
        $go_back['form'] = $fid;
        $go_back['entry'] = $temp_entries[$fid][0];
        unset($entries);
        unset($fids);
        unset($sub_fids);
        unset($sub_entries);
        $fid = $new_fid;
        $fids[0] = $new_fid;
        if ($_POST['target_sub']) {
            // if we're adding a new entry
            $entries[$new_fid][0] = "";
        } else {
            // if we're going to an existing entry
            $entries[$new_fid][0] = $_POST['goto_sub'];
        }
        $entry = $entries[$new_fid][0];
        $single_result = getSingle($fid, $uid, $groups, $member_handler, $gperm_handler, $mid);
        $single = $single_result['flag'];
        if ($single and !$entry) {
            $entry = $single_result['entry'];
            unset($entries);
            $entries[$fid][0] = $entry;
        }
        unset($owner);
        $owner = getEntryOwner($entries[$new_fid][0], $new_fid);
        $editing = is_numeric($entry);
        unset($owner_groups);
        //$owner_groups =& $member_handler->getGroupsByUser($owner, FALSE);
        $newFidData_handler = new formulizeDataHandler($new_fid);
        $owner_groups = $newFidData_handler->getEntryOwnerGroups($entries[$new_fid][0]);
        $info_received_msg = 0;
        // never display this message when a subform is displayed the first time.
        if ($entry) {
            $info_continue = 1;
        }
        if (!($scheck = security_check($fid, $entries[$fid][0], $uid, $owner, $groups, $mid, $gperm_handler)) and !$viewallforms) {
            print "<p>" . _NO_PERM . "</p>";
            return;
        }
    }
    // there are several points above where $entry is set, and now that we have a final value, store in ventry
    if ($entry > 0 and (!isset($settings['ventry']) or "addnew" != $settings['ventry'])) {
        $settings['ventry'] = $entry;
    }
    // set the alldoneoverride if necessary -- August 22 2006
    $config_handler =& xoops_gethandler('config');
    $formulizeConfig = $config_handler->getConfigsByCat(0, $mid);
    // remove the all done button if the config option says 'no', and we're on a single-entry form, or the function was called to look at an existing entry, or we're on an overridden Multi-entry form
    $allDoneOverride = (!$formulizeConfig['all_done_singles'] and !$profileForm and (($single or $overrideMulti or $original_entry) and !$_POST['target_sub'] and !$_POST['goto_sfid'] and !$_POST['deletesubsflag'] and !$_POST['parent_form'])) ? true : false;
    if (($allDoneOverride or isset($_POST['save_and_leave']) and $_POST['save_and_leave']) and $_POST['form_submitted']) {
        drawGoBackForm($go_back, $currentURL, $settings, $entry);
        print "<script type=\"text/javascript\">window.document.go_parent.submit();</script>\n";
        return;
    } else {
        // only do all this stuff below, the normal form displaying stuff, if we are not leaving this page now due to the all done button being overridden
        // we cannot have the back logic above invoked when dealing with a subform, but if the override is supposed to be in place, then we need to invoke it
        if (!$allDoneOverride and !$formulizeConfig['all_done_singles'] and !$profileForm and ($_POST['target_sub'] or $_POST['goto_sfid'] or $_POST['deletesubsflag'] or $_POST['parent_form']) and ($single or $original_entry or $overrideMulti)) {
            $allDoneOverride = true;
        }
        /*if($uid==1) {
        		print "Forms: ";
        		print_r($fids);
        		print "<br>Entries: ";
        		print_r($entries);
        		print "<br>Subforms: ";
        		print_r($sub_fids);
        		print "<br>Subentries: ";
        		print_r($sub_entries); // debug block - ONLY VISIBLE TO USER 1 RIGHT NOW 
        		} */
        formulize_benchmark("Ready to start building form.");
        $title = "";
        foreach ($fids as $this_fid) {
            if (!($scheck = security_check($this_fid, $entries[$this_fid][0], $uid, $owner, $groups, $mid, $gperm_handler)) and !$viewallforms) {
                continue;
            }
            // if there is more than one form, try to make the 1-1 links
            // and if we made any, then include the newly linked up entries
            // in the index of entries that we're keeping track of
            if (count($fids) > 1) {
                list($form1s, $form2s, $form1EntryIds, $form2EntryIds) = formulize_makeOneToOneLinks($frid, $this_fid);
                foreach ($form1EntryIds as $i => $form1EntryId) {
                    // $form1EntryId set above, now set other values for this iteration based on the key
                    $form2EntryId = $form2EntryIds[$i];
                    $form1 = $form1s[$i];
                    $form2 = $form2s[$i];
                    if ($form1EntryId) {
                        $entries[$form1][0] = $form1EntryId;
                    }
                    if ($form2EntryId) {
                        $entries[$form2][0] = $form2EntryId;
                    }
                }
            }
            unset($prevEntry);
            // if there is an entry, then get the data for that entry
            if ($entries[$this_fid]) {
                $groupEntryWithUpdateRights = ($single == "group" and $gperm_handler->checkRight("update_own_entry", $fid, $groups, $mid) and $entry == $single_result['entry']);
                $prevEntry = getEntryValues($entries[$this_fid][0], $formulize_mgr, $groups, $this_fid, $elements_allowed, $mid, $uid, $owner, $groupEntryWithUpdateRights);
            }
            // display the form
            //get the form title: (do only once)
            $firstform = 0;
            if (!$form) {
                $firstform = 1;
                $title = isset($passedInTitle) ? $passedInTitle : trans(getFormTitle($this_fid));
                if ($screen) {
                    $title = trans($screen->getVar('title'));
                }
                unset($form);
                if ($formElementsOnly) {
                    $form = new formulize_elementsOnlyForm($title, 'formulize', "{$currentURL}", "post", true);
                } else {
                    // extended class that puts formulize element names into the tr tags for the table, so we can show/hide them as required
                    $form = new formulize_themeForm($title, 'formulize', "{$currentURL}", "post", true);
                    // necessary to trigger the proper reloading of the form page, until Done is called and that form does not have this flag.
                    if (!isset($settings['ventry'])) {
                        $settings['ventry'] = 'new';
                    }
                    $form->addElement(new XoopsFormHidden('ventry', $settings['ventry']));
                }
                $form->setExtra("enctype='multipart/form-data'");
                // impératif!
                if (is_array($settings)) {
                    $form = writeHiddenSettings($settings, $form);
                }
                // include who the entry belongs to and the date
                // include acknowledgement that information has been updated if we have just done a submit
                // form_meta includes: last_update, created, last_update_by, created_by
                $breakHTML = "";
                if (!$profileForm and $titleOverride != "all") {
                    // build the break HTML and then add the break to the form
                    if (!strstr($currentURL, "printview.php")) {
                        $breakHTML .= "<center class=\"no-print\">";
                        $breakHTML .= "<p><b>";
                        if ($info_received_msg) {
                            $breakHTML .= _formulize_INFO_SAVED . "&nbsp;";
                        }
                        if ($info_continue == 1 and formulizePermHandler::user_can_edit_entry($fid, $uid, $entry)) {
                            $breakHTML .= "<p class=\"no-print\">" . _formulize_INFO_CONTINUE1 . "</p>";
                        } elseif ($info_continue == 2) {
                            $breakHTML .= "<p class=\"no-print\">" . _formulize_INFO_CONTINUE2 . "</p>";
                        } elseif (!$entry and formulizePermHandler::user_can_edit_entry($fid, $uid, $entry)) {
                            $breakHTML .= "<p class=\"no-print\">" . _formulize_INFO_MAKENEW . "</p>";
                        }
                        $breakHTML .= "</b></p>";
                        $breakHTML .= "</center>";
                    }
                    $breakHTML .= "<table cellpadding=5 width=100%><tr><td width=50% style=\"vertical-align: bottom;\">";
                    $breakHTML .= "<p><b>" . _formulize_FD_ABOUT . "</b><br>";
                    if ($entries[$this_fid][0]) {
                        $form_meta = getMetaData($entries[$this_fid][0], $member_handler, $this_fid);
                        $breakHTML .= _formulize_FD_CREATED . $form_meta['created_by'] . " " . formulize_formatDateTime($form_meta['created']) . "<br>" . _formulize_FD_MODIFIED . $form_meta['last_update_by'] . " " . formulize_formatDateTime($form_meta['last_update']) . "</p>";
                    } else {
                        $breakHTML .= _formulize_FD_NEWENTRY . "</p>";
                    }
                    $breakHTML .= "</td><td width=50% style=\"vertical-align: bottom;\">";
                    if (strstr($currentURL, "printview.php") or !formulizePermHandler::user_can_edit_entry($fid, $uid, $entry)) {
                        $breakHTML .= "<p>";
                    } else {
                        // get save and button button options
                        $save_button_text = "";
                        $done_button_text = "";
                        if (is_array($button_text)) {
                            $save_button_text = $button_text[1];
                            $done_button_text = $button_text[0];
                        } else {
                            $done_button_text = $button_text;
                        }
                        if (!$done_button_text and !$allDoneOverride) {
                            $done_button_text = _formulize_INFO_DONE1 . _formulize_DONE . _formulize_INFO_DONE2;
                        } elseif ($done_button_text != "{NOBUTTON}" and !$allDoneOverride) {
                            $done_button_text = _formulize_INFO_DONE1 . $done_button_text . _formulize_INFO_DONE2;
                            // check to see if the user is allowed to modify the existing entry, and if they're not, then we have to draw in the all done button so they have a way of getting back where they're going
                        } elseif ($entry and formulizePermHandler::user_can_edit_entry($fid, $uid, $entry) or !$entry) {
                            $done_button_text = "";
                        } else {
                            $done_button_text = _formulize_INFO_DONE1 . _formulize_DONE . _formulize_INFO_DONE2;
                        }
                        $nosave = false;
                        if (!$save_button_text and formulizePermHandler::user_can_edit_entry($fid, $uid, $entry)) {
                            $save_button_text = _formulize_INFO_SAVEBUTTON;
                        } elseif ($save_button_text != "{NOBUTTON}" and formulizePermHandler::user_can_edit_entry($fid, $uid, $entry)) {
                            $save_button_text = _formulize_INFO_SAVE1 . $save_button_text . _formulize_INFO_SAVE2;
                        } else {
                            $save_button_text = _formulize_INFO_NOSAVE;
                            $nosave = true;
                        }
                        $breakHTML .= "<p class='no-print'>" . $save_button_text;
                        if ($done_button_text) {
                            $breakHTML .= "<br>" . $done_button_text;
                        }
                    }
                    $breakHTML .= "</p></td></tr></table>";
                    $form->insertBreak($breakHTML, "even");
                } elseif ($profileForm) {
                    // if we have a profile form, put the profile fields at the top of the form, populated based on the DB values from the _users table
                    $form = addProfileFields($form, $profileForm);
                }
            }
            if ($titleOverride == "1" and !$firstform) {
                // set onetooneTitle flag to 1 when function invoked to force drawing of the form title over again
                $title = trans(getFormTitle($this_fid));
                $form->insertBreak("<table><th>{$title}</th></table>", "");
            }
            // if this form has a parent, then determine the $parentLinks
            if ($go_back['form'] and !$parentLinks[$this_fid]) {
                $parentLinks[$this_fid] = getParentLinks($this_fid, $frid);
            }
            formulize_benchmark("Before Compile Elements.");
            $form = compileElements($this_fid, $form, $formulize_mgr, $prevEntry, $entries[$this_fid][0], $go_back, $parentLinks[$this_fid], $owner_groups, $groups, $overrideValue, $elements_allowed, $profileForm, $frid, $mid, $sub_entries, $sub_fids, $member_handler, $gperm_handler, $title, $screen, $printViewPages, $printViewPageTitles);
            formulize_benchmark("After Compile Elements.");
        }
        // end of for each fids
        if (!is_object($form)) {
            exit("Error: the form cannot be displayed.  Does the current group have permission to access the form?");
        }
        // DRAW IN THE SPECIAL UI FOR A SUBFORM LINK (ONE TO MANY)
        if (count($sub_fids) > 0) {
            // if there are subforms, then draw them in...only once we have a bonafide entry in place already
            // draw in special params for this form, but only once per page
            global $formulize_subformHiddenFieldsDrawn;
            if ($formulize_subformHiddenFieldsDrawn != true) {
                $formulize_subformHiddenFieldsDrawn = true;
                $form->addElement(new XoopsFormHidden('target_sub', ''));
                $form->addElement(new XoopsFormHidden('target_sub_instance', ''));
                $form->addElement(new XoopsFormHidden('numsubents', 1));
                $form->addElement(new XoopsFormHidden('del_subs', ''));
                $form->addElement(new XoopsFormHidden('goto_sub', ''));
                $form->addElement(new XoopsFormHidden('goto_sfid', ''));
            }
            foreach ($sub_fids as $subform_id) {
                // only draw in the subform UI if the subform hasn't been drawn in previously, courtesy of a subform element in the form.
                // Subform elements are recommended since they provide 1. specific placement, 2. custom captions, 3. direct choice of form elements to include
                if (in_array($subform_id, $sfidsDrawn) or $elements_allowed or !($scheck = security_check($subform_id, "", $uid, $owner, $groups, $mid, $gperm_handler)) and !$viewallforms) {
                    // no entry passed so this will simply check whether they have permission for the form or not
                    continue;
                }
                $subUICols = drawSubLinks($subform_id, $sub_entries, $uid, $groups, $frid, $mid, $fid, $entry);
                unset($subLinkUI);
                if (isset($subUICols['single'])) {
                    $form->insertBreak($subUICols['single'], "even");
                } else {
                    $subLinkUI = new XoopsFormLabel($subUICols['c1'], $subUICols['c2']);
                    $form->addElement($subLinkUI);
                }
            }
        }
        // draw in proxy box if necessary (only if they have permission and only on new entries, not on edits)
        if (!strstr($_SERVER['PHP_SELF'], "formulize/printview.php")) {
            if ($gperm_handler->checkRight("add_proxy_entries", $fid, $groups, $mid) and !$entries[$fid][0]) {
                $form = addOwnershipList($form, $groups, $member_handler, $gperm_handler, $fid, $mid);
            } elseif ($entries[$fid][0] and $gperm_handler->checkRight("update_entry_ownership", $fid, $groups, $mid)) {
                $form = addOwnershipList($form, $groups, $member_handler, $gperm_handler, $fid, $mid, $entries[$fid][0]);
            }
        }
        // draw in the submitbutton if necessary
        if (!$formElementsOnly and formulizePermHandler::user_can_edit_entry($fid, $uid, $entry)) {
            $form = addSubmitButton($form, _formulize_SAVE, $go_back, $currentURL, $button_text, $settings, $temp_entries[$this_fid][0], $fids, $formframe, $mainform, $entry, $profileForm, $elements_allowed, $allDoneOverride, $printall, $screen);
        }
        if (!$formElementsOnly) {
            // add flag to indicate that the form has been submitted
            $form->addElement(new XoopsFormHidden('form_submitted', "1"));
            if ($go_back['form']) {
                // if this is set, then we're doing a subform, so put in a flag to prevent the parent from being drawn again on submission
                $form->addElement(new XoopsFormHidden('sub_fid', $fid));
                $form->addElement(new XoopsFormHidden('sub_submitted', $entries[$fid][0]));
                $form->addElement(new XoopsFormHidden('go_back_form', $go_back['form']));
                $form->addElement(new XoopsFormHidden('go_back_entry', $go_back['entry']));
            } else {
                // drawing a main form...put in the scroll position flag
                $form->addElement(new XoopsFormHidden('yposition', 0));
            }
            // saving message
            print "<div id=savingmessage style=\"display: none; position: absolute; width: 100%; right: 0px; text-align: center; padding-top: 50px;\">\n";
            global $xoopsConfig;
            if (file_exists(XOOPS_ROOT_PATH . "/modules/formulize/images/saving-" . $xoopsConfig['language'] . ".gif")) {
                print "<img src=\"" . XOOPS_URL . "/modules/formulize/images/saving-" . $xoopsConfig['language'] . ".gif\">\n";
            } else {
                print "<img src=\"" . XOOPS_URL . "/modules/formulize/images/saving-english.gif\">\n";
            }
            print "</div>\n";
            drawJavascript($nosave);
            if (count($GLOBALS['formulize_renderedElementHasConditions']) > 0) {
                drawJavascriptForConditionalElements($GLOBALS['formulize_renderedElementHasConditions'], $entries, $sub_entries);
            }
            print $form->addElement(new xoopsFormHidden('save_and_leave', 0));
            // lastly, put in a hidden element, that will tell us what the first, primary form was that we were working with on this form submission
            $form->addElement(new XoopsFormHidden('primaryfid', $fids[0]));
        }
        global $formulize_governingElements;
        global $formulize_oneToOneElements;
        global $formulize_oneToOneMetaData;
        if (!is_array($formulize_governingElements)) {
            $formulize_governingElements = array();
        }
        if (!is_array($formulize_oneToOneElements)) {
            $oneToOneElements = array();
        }
        if (!is_array($oneToOneMetaData)) {
            $oneToOneMetaData = array();
        }
        if (count($GLOBALS['formulize_renderedElementHasConditions']) > 0) {
            $governingElements1 = compileGoverningElementsForConditionalElements($GLOBALS['formulize_renderedElementHasConditions'], $entries, $sub_entries);
            foreach ($governingElements1 as $key => $value) {
                $oneToOneElements[$key] = false;
            }
            $formulize_governingElements = mergeGoverningElements($formulize_governingElements, $governingElements1);
        }
        // add in any onetoone elements that we need to deal with at the same time (in case their joining key value changes on the fly)
        if (count($fids) > 1) {
            $i = 1;
            while ($i <= count($fids)) {
                $relationship_handler = xoops_getmodulehandler('frameworks', 'formulize');
                $relationship = $relationship_handler->get($frid);
                foreach ($relationship->getVar('links') as $thisLink) {
                    if ($thisLink->getVar('form1') == $fids[$i]) {
                        $keyElement = $thisLink->getVar('key2');
                        break;
                    } elseif ($thisLink->getVar('form2') == $fids[$i]) {
                        $keyElement = $thisLink->getVar('key1');
                        break;
                    }
                }
                // prepare to loop through elements for the rendered entry, or 'new', if there is no rendered entry
                $entryToLoop = isset($entries[$fids[$i]][0]) ? $entries[$fids[$i]][0] : null;
                if (!$entryToLoop and isset($GLOBALS['formulize_renderedElementsForForm'][$fids[$i]]['new'])) {
                    $entryToLoop = 'new';
                }
                foreach ($GLOBALS['formulize_renderedElementsForForm'][$fids[$i]][$entryToLoop] as $renderedMarkupName => $thisElement) {
                    $GLOBALS['formulize_renderedElementHasConditions'][$renderedMarkupName] = $thisElement;
                    $governingElements2 = _compileGoverningElements($entries, _getElementObject($keyElement), $renderedMarkupName);
                    foreach ($governingElements2 as $key => $value) {
                        $formulize_oneToOneElements[$key] = true;
                        $formulize_oneToOneMetaData[$key] = array('onetoonefrid' => $frid, 'onetoonefid' => $fid, 'onetooneentries' => urlencode(serialize($entries)), 'onetoonefids' => urlencode(serialize($fids)));
                    }
                    $formulize_governingElements = mergeGoverningElements($formulize_governingElements, $governingElements2);
                }
                $i++;
            }
        }
        if (count($formulize_governingElements) > 0 and !$formElementsOnly) {
            // render this once at the end of rendering the main form!
            drawJavascriptForConditionalElements($GLOBALS['formulize_renderedElementHasConditions'], $formulize_governingElements, $formulize_oneToOneElements, $formulize_oneToOneMetaData);
        }
        $idForForm = $formElementsOnly ? "" : "id=\"formulizeform\"";
        // when rendering disembodied forms, don't use the master id!
        print "<div {$idForForm}>" . $form->render() . "</div><!-- end of formulizeform -->";
        // note, security token is included in the form by the xoops themeform render method, that's why there's no explicity references to the token in the compiling/generation of the main form object
        // floating save button
        if ($printall != 2 and $formulizeConfig['floatSave'] and !strstr($currentURL, "printview.php") and !$formElementsOnly) {
            print "<div id=floattest></div>";
            if ($done_text != "{NOBUTTON}" or $save_text != "{NOBUTTON}") {
                print "<div id=floatingsave>";
                if ($subButtonText == _formulize_SAVE) {
                    if ($save_text) {
                        $subButtonText = $save_text;
                    }
                    if ($subButtonText != "{NOBUTTON}") {
                        print "<input type='button' name='submitx' id='submitx' class=floatingsavebuttons onclick=javascript:validateAndSubmit(); value='" . _formulize_SAVE . "' >";
                        print "<input type='button' name='submit_save_and_leave' id='submit_save_and_leave' class=floatingsavebuttons onclick=javascript:validateAndSubmit('leave'); value='" . _formulize_SAVE_AND_LEAVE . "' >";
                    }
                }
                if (($button_text != "{NOBUTTON}" and !$done_text or isset($done_text) and $done_text != "{NOBUTTON}") and !$allDoneOverride) {
                    if ($done_text) {
                        $button_text = $done_text_temp;
                    }
                    print "<input type='button' class=floatingsavebuttons onclick=javascript:verifyDone(); value='" . _formulize_DONE . "' >";
                }
                print "</div>";
            }
        }
        // end floating save button
        // if we're in Drupal, include the main XOOPS js file, so the calendar will work if present...
        // assumption is that the calendar javascript has already been included by the datebox due to no
        // $xoopsTpl being in effect in Drupal -- this assumption will fail if Drupal is displaying a pageworks
        // page that uses the $xoopsTpl, for instance.  (Date select box file itself checks for $xoopsTpl)
        global $user;
        static $includedXoopsJs = false;
        if (is_object($user) and !$includedXoopsJs) {
            print "<script type=\"text/javascript\" src=\"" . XOOPS_URL . "/include/xoops.js\"></script>\n";
            $includedXoopsJs = true;
        }
    }
    // end of if we're not going back to the prev page because of an all done button override
}
Пример #5
0
    $out['query'] = str_replace('"', '', $query);
    if ($query) {
        $out['hits'] = $app[SearchProvider::SEARCH_PROVIDER]($query);
    }
    /** @var $twig Twig_Environment */
    $twig = $app['twig'];
    return $twig->render('search.twig', $out);
});
/**
 * main page controller, look up and load pageName from content directory
 *
 */
$app->get('/{page}', function (Application $app, Request $request, $page) {
    // template output
    /* @var $page SimpleXMLElement */
    $out = array('next' => $app['next'], 'prev' => $app['prev'], 'current' => $app['current'], 'image' => $app['image'], 'meta' => getMetaData($page), 'permalink' => $request->getUri(), 'page' => $page, 'title' => $app['current'] == $app['homePage'] ? '' : $page->head->title, 'body' => $page->body->asXML(), 'isHome' => $app['current'] == $app['homePage']);
    /** @var $twig Twig_Environment */
    $twig = $app['twig'];
    return $twig->render('page.twig', $out);
})->value('page', $app['homePage'])->assert('page', '^(?!blog)[\\w/]+\\.html$')->convert('page', $loadPageXML);
/**
 * error controller
 */
$app->error(function (\Exception $e, $code) use($app) {
    // in development environment dump stack trace
    if ($app['debug']) {
        return;
    }
    // fetch 404
    /** @var $twig Twig_Environment */
    $twig = $app['twig'];
              </div>
              <div style="font-size: 0.95em; margin-top: 4px; color: #666666; width: 400px; white-space: nowrap; text-overflow: ellipsis; overflow: hidden;">
                <?php 
    echo $address;
    ?>
              </div>
            </td>
            <td>
              <div style="font-size: 1.45em; color: #005826; text-align: right;">
                <?php 
    echo getPrice();
    ?>
              </div>
              <div style="font-size: 0.95em; margin-top: 4px; color: #666666; text-align: right;">
                <?php 
    echo getMetaData('et_er_rent_tenure');
    ?>
              </div>
            </td>
            <td style="width: 20px;">
            </td>
            <td style="padding-left: 20px; border-left: 1px solid #eeeeee;">
              <div class="font-size-90 bold view-details-button">
                <a href="/terrerohomes/property/?p_id=<?php 
    echo get_the_ID();
    ?>
">View Details</a>
              </div>
            </td>
          </tr>
        </tbody>
Пример #7
0
function showHeaderHTML($title = " - - ", $style = "", $jScript = "", $keyWords = "", $desc = "")
{
    $str = <<<EOT
<html>
<head>
<title>{$title}</title>

EOT;
    $str .= getMetaData($keyWords, $desc) . "\n";
    if ($style != "") {
        $str .= <<<EOT
<link href="{$style}" rel="stylesheet" type="text/css">

EOT;
    }
    $str .= <<<EOT
{$jScript}
</head>
<body>
EOT;
    echo $str;
}
Пример #8
0
function importCsvProcess(&$importSet, $id_reqs, $regfid, $validateOverride)
{
    global $xoopsDB, $xoopsUser, $xoopsConfig, $myts;
    // $xoopsDB is required by q
    if (!$myts) {
        $myts =& MyTextSanitizer::getInstance();
    }
    echo "<b>** Importing</b><br><br>";
    $form_uid = "0";
    global $override_import_proxyid;
    if ($override_import_proxyid) {
        $form_proxyid = $override_import_proxyid;
    } else {
        $form_proxyid = $xoopsUser->getVar('uid');
    }
    // lock formulize_form -- note that every table we use needs to be locked, so linked selectbox lookups may fail
    if ($regfid == $importSet[4]) {
        // only lockup reg codes table if we're dealing with a profile form, in which case we assume reg codes is installed and the table exists
        $xoopsDB->query("LOCK TABLES " . $xoopsDB->prefix("formulize_" . $importSet[8]) . " WRITE, " . $xoopsDB->prefix("users") . " WRITE, " . $xoopsDB->prefix("formulize_entry_owner_groups") . " WRITE, " . $xoopsDB->prefix("reg_codes") . " WRITE, " . $xoopsDB->prefix("groups_users_link") . " WRITE, " . $xoopsDB->prefix("modules") . " READ, " . $xoopsDB->prefix("config") . " READ, " . $xoopsDB->prefix("formulize") . " READ, " . $xoopsDB->prefix("formulize_id") . " READ, " . $xoopsDB->prefix("formulize_saved_views") . " READ, " . $xoopsDB->prefix("formulize_group_filters") . " READ");
    } else {
        $xoopsDB->query("LOCK TABLES " . $xoopsDB->prefix("formulize_" . $importSet[8]) . " WRITE, " . $xoopsDB->prefix("users") . " READ, " . $xoopsDB->prefix("formulize_entry_owner_groups") . " WRITE, " . $xoopsDB->prefix("groups_users_link") . " READ, " . $xoopsDB->prefix("formulize") . " READ, " . $xoopsDB->prefix("formulize_id") . " READ, " . $xoopsDB->prefix("formulize_saved_views") . " READ, " . $xoopsDB->prefix("formulize_group_filters") . " READ");
    }
    $rowCount = 1;
    $other_values = array();
    $usersMap = array();
    $entriesMap = array();
    while (!feof($importSet[1])) {
        $row = fgetcsv($importSet[1], 99999);
        if (is_array($row) and count($row) > 1) {
            $rowCount++;
            $this_id_req = "";
            if (is_array($id_reqs)) {
                // get the id_req if necessary.  will happen regardless of position of idreq column
                $this_id_req = $row[$importSet[7]['idreqs']];
            }
            $links = count($importSet[6]);
            for ($link = 0; $link < $links; $link++) {
                if (isset($GLOBALS['formulize_ignoreColumnsOnImport'][$link])) {
                    continue;
                }
                if ($importSet[6][$link] == -1) {
                    if ($importSet[3][$link] == _formulize_DE_CALC_CREATOR) {
                        $form_uid = getUserId($row[$link]);
                    }
                }
            }
            // get the current max id_req
            if (!$this_id_req) {
                $max_id_reqq = q("SELECT MAX(entry_id) FROM " . $xoopsDB->prefix("formulize_" . $importSet[8]));
                $max_id_req = $max_id_reqq[0]["MAX(entry_id)"] + 1;
            } else {
                $max_id_req = $this_id_req;
                // get the uid and creation date too
                $member_handler =& xoops_gethandler('member');
                $this_metadata = getMetaData($this_id_req, $member_handler, $importSet[4]);
                // importSet[4] is id_form (fid)
                $this_uid = $this_metadata['created_by_uid'];
                $this_creation_date = $this_metadata['created'];
            }
            // if this is the registration form, and we're making new entries, then handle the creation of the necessary user account
            // need to get the five userprofile fields from the form, $importSet[7] contains the keys for them -- email, username, fullname, password, regcode
            if ($regfid == $importSet[4] and !is_array($id_reqs)) {
                $up_regcode = $row[$importSet[7]['regcode']];
                $up_username = $row[$importSet[7]['username']];
                $up_fullname = $row[$importSet[7]['fullname']];
                $up_password = $row[$importSet[7]['password']];
                $up_email = $row[$importSet[7]['email']];
                $tz = $xoopsConfig['default_TZ'];
                list($newid, $actkey) = createMember(array('regcode' => '', 'approval' => false, 'user_viewemail' => 0, 'uname' => $up_username, 'name' => $up_fullname, 'email' => $up_email, 'pass' => $up_password, 'timezone_offset' => $tz));
                processCode($up_regcode, $newid);
                $form_uid = $newid;
                // put in new user id here
            }
            $links = count($importSet[6]);
            $fieldValues = array();
            $newEntryId = "";
            for ($link = 0; $link < $links; $link++) {
                // used as a flag to indicate whether we're dealing with a linked selectbox or not, since if we are, that is the only case where we don't want to do HTML special chars on the value // deprecated in 3.0
                $all_valid_options = false;
                if ($importSet[6][$link] != -1) {
                    $element = $importSet[5][0][$importSet[6][$link]];
                    $id_form = $importSet[4];
                    if ($link == $links - 1) {
                        // remove some really odd line endings if present, only happens when dealing with legacy outputs of really old/odd systems
                        $row_value = str_replace(chr(19) . chr(16), "", $row[$link]);
                    } else {
                        $row_value = $row[$link];
                    }
                    if ($row_value != "") {
                        switch ($element["ele_type"]) {
                            case "select":
                                if ($importSet[5][1][$link] and !strstr($row_value, ",") and (!is_numeric($row_value) or $row_value < 10000000)) {
                                    // Linked element
                                    $linkElement = $importSet[5][1][$link];
                                    $ele_value = unserialize($element["ele_value"]);
                                    list($all_valid_options, $all_valid_options_ids) = getElementOptions($linkElement[2]['ele_handle'], $linkElement[2]['id_form']);
                                    if ($ele_value[1]) {
                                        // Multiple options
                                        $element_value = $linkElement[0] . "#*=:*" . $linkElement[1] . "#*=:*";
                                        $items = explode("\n", $row_value);
                                        $row_value = ",";
                                        foreach ($items as $item) {
                                            $item_value = trim($item);
                                            if ($optionIndex = array_search($item_value, $all_valid_options)) {
                                                $ele_id = $all_valid_options_ids[$optionIndex];
                                            } else {
                                                foreach ($all_valid_options as $optionIndex => $thisoption) {
                                                    if (trim($item_value) == trim(trans($thisoption))) {
                                                        $item_value = $thisoption;
                                                        $ele_id = $all_valid_options_ids[$optionIndex];
                                                        break;
                                                    }
                                                }
                                            }
                                            $row_value .= $ele_id . ",";
                                        }
                                    } else {
                                        // Single option
                                        if ($optionIndex = array_search($row_value, $all_valid_options)) {
                                            $ele_id = $all_valid_options_ids[$optionIndex];
                                        } else {
                                            foreach ($all_valid_options as $optionIndex => $thisoption) {
                                                if (trim($row_value) == trim(trans($thisoption))) {
                                                    $row_value = $thisoption;
                                                    $ele_id = $all_valid_options_ids[$optionIndex];
                                                    break;
                                                }
                                            }
                                        }
                                        $row_value = $ele_id;
                                    }
                                } elseif (!strstr($row_value, ",") and (!is_numeric($row_value) or $row_value < 10000000)) {
                                    // Not-Linked element
                                    $ele_value = unserialize($element["ele_value"]);
                                    // handle fullnames or usernames
                                    $temparraykeys = array_keys($ele_value[2]);
                                    if ($temparraykeys[0] === "{FULLNAMES}" or $temparraykeys[0] === "{USERNAMES}") {
                                        // ADDED June 18 2005 to handle pulling in usernames for the user's group(s) -- updated for real live use September 6 2006
                                        if ($temparraykeys[0] === "{FULLNAMES}") {
                                            $nametype = "name";
                                        }
                                        if ($temparraykeys[0] === "{USERNAMES}") {
                                            $nametype = "uname";
                                        }
                                        if (!isset($fullnamelist)) {
                                            $fullnamelistq = q("SELECT uid, {$nametype} FROM " . $xoopsDB->prefix("users") . " ORDER BY uid");
                                            static $fullnamelist = array();
                                            foreach ($fullnamelistq as $thisname) {
                                                $fullnamelist[$thisname['uid']] = $thisname[$nametype];
                                            }
                                        }
                                        if ($ele_value[1]) {
                                            // multiple
                                            $items = explode("\n", $row_value);
                                        } else {
                                            $items = array(0 => $row_value);
                                        }
                                        $numberOfNames = 0;
                                        $row_value = "";
                                        foreach ($items as $item) {
                                            if (is_numeric($item)) {
                                                $row_value .= "*=+*:" . $item;
                                                $numberOfNames++;
                                            } else {
                                                $uids = array_keys($fullnamelist, $item);
                                                // instead of matching on all values, like we used to, match only the first name found (lowest user id)
                                                // to match other users besides the first one, use a user id number instead of a name in the import spreadsheet
                                                $row_value .= "*=+*:" . $uids[0];
                                                $numberOfNames++;
                                            }
                                        }
                                        if ($numberOfNames == 1) {
                                            // single entries are not supposed to have the separator at the front
                                            $row_value = substr_replace($row_value, "", 0, 5);
                                        }
                                        break;
                                    }
                                    if ($ele_value[1]) {
                                        // Multiple options
                                        $element_value = "";
                                        $options = $ele_value[2];
                                        $items = explode("\n", $row_value);
                                        foreach ($items as $item) {
                                            $item_value = trim($item);
                                            if (!in_array($item_value, $options, true)) {
                                                // last option causes strict matching by type
                                                foreach ($options as $thisoption => $default_value) {
                                                    if (trim($item_value) == trim(trans($thisoption))) {
                                                        $item_value = $thisoption;
                                                        break;
                                                    }
                                                }
                                            }
                                            $element_value .= "*=+*:" . $item_value;
                                        }
                                        $row_value = $element_value;
                                    } else {
                                        // Single option
                                        $options = $ele_value[2];
                                        if (!in_array($row_value, $options, true)) {
                                            // last option causes strict matching by type
                                            foreach ($options as $thisoption => $default_value) {
                                                if (trim($row_value) == trim(trans($thisoption))) {
                                                    $row_value = $thisoption;
                                                    break;
                                                }
                                            }
                                        }
                                    }
                                } elseif (strstr($row_value, ",") or is_numeric($row_value) and $row_value > 10000000) {
                                    // the value is a comma separated list of linked values, so we need to add commas before and after, to adhere to the Formulize data storage spec
                                    if (substr($row_value, 0, 1) != ",") {
                                        $row_value = "," . $row_value;
                                    }
                                    if (substr($row_value, -1) != ",") {
                                        $row_value = $row_value . ",";
                                    }
                                }
                                break;
                            case "checkbox":
                                $options = unserialize($element["ele_value"]);
                                $element_value = "";
                                $items = explode("\n", $row_value);
                                foreach ($items as $item) {
                                    $item_value = trim($item);
                                    if (!in_array($item_value, $options, true)) {
                                        // last option causes strict matching by type
                                        $foundit = false;
                                        $hasother = false;
                                        foreach ($options as $thisoption => $default_value) {
                                            if (trim($item_value) == trim(trans($thisoption))) {
                                                $item_value = $thisoption;
                                                $foundit = true;
                                                break;
                                            }
                                            if (preg_match('/\\{OTHER\\|+[0-9]+\\}/', $thisoption)) {
                                                $hasother = $thisoption;
                                            }
                                        }
                                        if ($foundit) {
                                            $element_value .= "*=+*:" . $item_value;
                                        } elseif ($hasother) {
                                            $other_values[] = "INSERT INTO " . $xoopsDB->prefix("formulize_other") . " (id_req, ele_id, other_text) VALUES (\"{$max_id_req}\", \"" . $element["ele_id"] . "\", \"" . $myts->htmlSpecialChars(trim($item_value)) . "\")";
                                            $element_value .= "*=+*:" . $hasother;
                                        } elseif (!$validateOverride) {
                                            print "ERROR: INVALID TEXT FOUND FOR A CHECKBOX ITEM -- {$item_value} -- IN ROW:<BR>";
                                            print_r($row);
                                            print "<br><br>";
                                        }
                                    } else {
                                        $element_value .= "*=+*:" . $item_value;
                                    }
                                }
                                $row_value = $element_value;
                                break;
                            case "radio":
                                $options = unserialize($element["ele_value"]);
                                if (!in_array($row_value, $options, true)) {
                                    // last option causes strict matching by type
                                    $foundit = false;
                                    $hasother = false;
                                    foreach ($options as $thisoption => $default_value) {
                                        if (trim($row_value) == trim(trans($thisoption))) {
                                            $row_value = $thisoption;
                                            $foundit = true;
                                            break;
                                        }
                                        if (preg_match('/\\{OTHER\\|+[0-9]+\\}/', $thisoption)) {
                                            $hasother = $thisoption;
                                        }
                                    }
                                    if (!$foundit and $hasother) {
                                        $other_values[] = "INSERT INTO " . $xoopsDB->prefix("formulize_other") . " (id_req, ele_id, other_text) VALUES (\"{$max_id_req}\", \"" . $element["ele_id"] . "\", \"" . $myts->htmlSpecialChars(trim($row_value)) . "\")";
                                        $row_value = $hasother;
                                    } elseif (!$foundit and !$validateOverride) {
                                        print "ERROR: INVALID TEXT FOUND FOR A RADIO BUTTON ITEM -- {$row_value} -- IN ROW:<BR>";
                                        print_r($row);
                                        print "<br><br>";
                                    }
                                }
                                break;
                            case "date":
                                $row_value = date("Y-m-d", strtotime(str_replace("/", "-", $row_value)));
                                break;
                            case "yn":
                                if (!is_numeric($row_value)) {
                                    $yn_value = strtoupper($row_value);
                                    if ($yn_value == "YES") {
                                        $row_value = 1;
                                    } else {
                                        if ($yn_value == "NO") {
                                            $row_value = 2;
                                        }
                                    }
                                }
                                break;
                        }
                        // record the values for inserting as part of this record
                        // prior to 3.0 we did not do the htmlspecialchars conversion if this was a linked selectbox...don't think that's a necessary exception in 3.0 with new data structure
                        $fieldValues[$element['ele_handle']] = $myts->htmlSpecialChars($row_value);
                    }
                    // end of if there's a value in the current column
                } elseif (isset($importSet[7]['usethisentryid']) and $link == $importSet[7]['usethisentryid']) {
                    // if this is not a valid column, but it is an entry id column, then capture the entry id from the cell
                    $newEntryId = $row[$link] ? $row[$link] : "";
                }
                // end of if this is a valid column
            }
            // end of looping through $links (columns?)
            // now that we've recorded all the values, do the actual updating/inserting of this record
            if ($this_id_req) {
                // updating an entry
                $form_uid = $this_uid;
                $updateSQL = "UPDATE " . $xoopsDB->prefix("formulize_" . $importSet[8]) . " SET ";
                $start = true;
                foreach ($fieldValues as $elementHandle => $fieldValue) {
                    if (!$start) {
                        // on subsequent fields, add a comma
                        $updateSQL .= ", ";
                    }
                    $start = false;
                    $updateSQL .= "`{$elementHandle}` = '" . formulize_db_escape($fieldValue) . "'";
                }
                $updateSQL .= ", mod_datetime=NOW(), mod_uid={$form_proxyid} WHERE entry_id=" . intval($this_id_req);
                if (IMPORT_WRITE) {
                    if (!($result = $xoopsDB->queryF($updateSQL))) {
                        print "<br><b>FAILED</b> to update data, SQL: {$updateSQL}<br>" . $xoopsDB->error() . "<br>";
                    }
                }
            } else {
                // inserting a new entry
                $fields = "";
                $values = "";
                $element_handler = xoops_getmodulehandler('elements', 'formulize');
                foreach ($fieldValues as $elementHandle => $fieldValue) {
                    $fields .= ", `" . $elementHandle . "`";
                    $values .= ", '" . formulize_db_escape($fieldValue) . "'";
                    $elementObject = $element_handler->get($elementHandle);
                    if ($elementObject->getVar('ele_desc') == "Primary Key") {
                        $newEntryId = $fieldValue;
                    }
                }
                if ($form_uid == 0) {
                    $form_uid = $form_proxyid;
                }
                $entryIdFieldText = $newEntryId ? "entry_id, " : "";
                $newEntryId .= $newEntryId ? ", " : "";
                $insertElement = "INSERT INTO " . $xoopsDB->prefix("formulize_" . $importSet[8]) . " (" . $entryIdFieldText . "creation_datetime, mod_datetime, creation_uid, mod_uid" . $fields . ") VALUES (" . $newEntryId . "NOW(), NOW(), '" . intval($form_uid) . "', '" . intval($form_proxyid) . "'" . $values . ")";
                if (IMPORT_WRITE) {
                    if (!($result = $xoopsDB->queryF($insertElement))) {
                        static $duplicatesFound = false;
                        if (strstr($xoopsDB->error(), "Duplicate entry")) {
                            if (!$duplicatesFound) {
                                print "<br><b>FAILED</b> to insert <i>some</i> data.  At least one duplicate value was found in a column that does not allow duplicate values.<br>";
                                $duplicatesFound = true;
                            }
                        } else {
                            print "<br><b>FAILED</b> to insert data, SQL: {$insertElement}<br>" . $xoopsDB->error() . "<br>";
                        }
                    } else {
                        // need to record new group ownership info too
                        $usersMap[] = $form_uid;
                        $entriesMap[] = $xoopsDB->getInsertId();
                    }
                } else {
                    echo "<br>" . $insertElement . "<br>";
                }
            }
            $idToShow = $newEntryId ? $newEntryId : $max_id_req;
            //echo "line $rowCount, id $idToShow<br>";
        }
        // end of if we have contents in this row
    }
    // end of looping through each row of the file
    if (count($usersMap) > 0) {
        // if new entries were created...
        include_once XOOPS_ROOT_PATH . "/modules/formulize/class/data.php";
        $data_handler = new formulizeDataHandler($id_form);
        if (!($groupResult = $data_handler->setEntryOwnerGroups($usersMap, $entriesMap))) {
            print "ERROR: failed to write the entry ownership information to the database.<br>" . $xoopsDB->error() . "<br>";
        }
    }
    // unlock tables
    $xoopsDB->query("UNLOCK TABLES");
    // insert all the other values that were recorded
    foreach ($other_values as $other) {
        if (!($result = $xoopsDB->query($other))) {
            print "ERROR: could not insert 'other' value: {$other}<br>";
        }
    }
}
Пример #9
0
function patch30DataStructure($auto = false)
{
    global $xoopsDB;
    // check for new data structure and don't run this patch if it already has been!
    // check that patch30 has been run and don't run this patch unless it already has been!
    // check that formulize_form table exists, or else don't run the patch
    $patchCheckSql = "SHOW TABLES";
    $resultPatchCheck = $xoopsDB->queryF($patchCheckSql);
    $entryOwnerGroupFound = false;
    $formulizeFormFound = false;
    $newStructureFound = false;
    while ($table = $xoopsDB->fetchRow($resultPatchCheck)) {
        $secondPart = substr($table[0], strlen($xoopsDB->prefix("formulize_")));
        if (is_numeric($secondPart) and strstr($table[0], $xoopsDB->prefix("formulize_"))) {
            // there will be a part after "formulize_" that is numeric in the new data structure
            $newStructureFound = true;
        }
        if ($table[0] == $xoopsDB->prefix("formulize_entry_owner_groups")) {
            $entryOwnerGroupFound = true;
        }
        if ($table[0] == $xoopsDB->prefix("formulize_form")) {
            $formulizeFormFound = true;
        }
    }
    if (!$formulizeFormFound and $entryOwnerGroupFound) {
        print "<h1>It appears you have not upgraded from a previous version of Formulize.  You do not need to apply this patch unless you are upgrading from a version prior to 3.0</h1>\n";
        print "<p>If you did upgrade from a previous version, please contact <a href=mailto:formulize@freeformsolutions.ca>Freeform Solutions</a> for assistance.</p>\n";
        return;
    }
    if (!$entryOwnerGroupFound) {
        print "<h1>You must run \"patch31\" before upgrading to the 3.0 data structure.</h1>\n";
        print "<p><a href=\"" . XOOPS_URL . "/modules/formulize/admin/formindex.php?op=patch31\">Click here to run \"patch31\".</a></p>\n";
        return;
    }
    if ($newStructureFound) {
        print "<h1>You cannot run this patch after upgrading to the 3.0 data structure.</h1>";
        return;
    }
    $carryon = true;
    if (!$auto) {
        // put UI control in if not called from another function....not actually used; this patch must be invoked manually on its own.
        if (!isset($_POST['patch30datastructure'])) {
            $carryon = false;
            print "<form action=\"formindex.php?op=patch30datastructure\" method=post>";
            print "<h1>Warning: this patch completely changes the structure of the formulize data in your database.  Backup your database prior to applying this patch!</h1>";
            print "<p>This patch may take a few minutes to apply.  Your page may take that long to reload, please be patient.</p>";
            print "<p>You may need to increase the memory limit and/or max execution time in PHP, if you have a large database (100,000 records or more, depending on the size of your forms).</p>";
            print "<p>If the first version of Formulize that you installed was 3.0 or higher, you DO NOT need to apply this patch!</p>";
            print "<input type = submit name=patch30datastructure value=\"Apply Data Structure Patch for upgrading to Formulize 3.0 and higher\">";
            print "</form>";
        }
    }
    if ($carryon) {
        print "<h2>Patch Results:</h2>";
        // 1. figure out all the forms in existence
        // 2. for each one, devise the field names in its table
        // 3. create its table
        // 4. import its data from formulize_form
        include_once XOOPS_ROOT_PATH . "/modules/formulize/class/forms.php";
        include_once XOOPS_ROOT_PATH . "/modules/formulize/include/functions.php";
        $formHandler =& xoops_getmodulehandler('forms', 'formulize');
        $allFormObjects = $formHandler->getAllForms(true);
        // true flag causes all elements to be included in objects, not just elements that are being displayed, which are ignored in every other situation
        foreach ($allFormObjects as $formObjectId => $thisFormObject) {
            if ($thisFormObject->getVar('tableform')) {
                continue;
            }
            // only process actual Formulize forms
            if (!($tableCreationResult = $formHandler->createDataTable($thisFormObject))) {
                exit("Error: could not make the necessary new datatable for form " . $thisFormObject->getVar('id_form') . ".<br>" . $xoopsDB->error() . "<br>Please report this error to <a href=\"mailto:formulize@freeformsolutions.ca\">Freeform Solutions</a>.");
            }
            print "Created data table formulize_" . $thisFormObject->getVar('id_form') . ".  result: OK<br>\n";
            // map data in formulize_form into new table
            // 1. get an index of the captions to element ids
            // 2. get all the data organized by id_req
            // 3. insert the data
            $captionPlusHandlesSQL = "SELECT ele_caption, ele_handle FROM " . $xoopsDB->prefix("formulize") . " WHERE id_form = " . $thisFormObject->getVar('id_form');
            $captionPlusHandlesRes = $xoopsDB->query($captionPlusHandlesSQL);
            $captionHandleIndex = array();
            while ($captionPlusHandlesArray = $xoopsDB->fetchArray($captionPlusHandlesRes)) {
                $captionHandleIndex[str_replace("'", "`", $captionPlusHandlesArray['ele_caption'])] = $captionPlusHandlesArray['ele_handle'];
            }
            $dataSQL = "SELECT id_req, ele_caption, ele_value, ele_type FROM " . $xoopsDB->prefix("formulize_form") . " WHERE id_form = " . $thisFormObject->getVar('id_form') . " AND ele_type != \"areamodif\" AND ele_type != \"sep\" ORDER BY id_req";
            // for some reason areamodif and sep are stored in some really old data
            $dataRes = $xoopsDB->query($dataSQL);
            $prevIdReq = "";
            $insertSQL = "";
            unset($foundCaptions);
            $foundCaptions = array();
            while ($dataArray = $xoopsDB->fetchArray($dataRes)) {
                if (!isset($captionHandleIndex[$dataArray['ele_caption']])) {
                    if ($dataArray['ele_caption'] === '') {
                        print "Warning: you have data saved, with no caption specified, for entry number " . $dataArray['id_req'] . " (id_req) in form " . $thisFormObject->getVar('id_form') . ".  This data will be ignored.  Please contact <a href=\"mailto:formulize@freeformsolutions.ca\">Freeform Solutions</a> if you would like assistance cleaning this up.  This will NOT affect the upgrade to version 3.<br>";
                        continue;
                    } else {
                        print "Warning: the form " . $thisFormObject->getVar('id_form') . " does not have an element with the caption '" . $dataArray['ele_caption'] . "', but you have saved data associated with that caption.  This data will be ignored.  Please contact <a href=\"mailto:formulize@freeformsolutions.ca\">Freeform Solutions</a> if you would like assistance cleaning this up.  This will NOT affect the upgrade to version 3.<br>";
                        continue;
                    }
                }
                if ($dataArray['id_req'] != $prevIdReq) {
                    // we're on a new entry
                    unset($foundCaptions);
                    $foundCaptions = array();
                    // reset the list of captions we've found in this entry so far, since we're moving onto a different entry
                    $prevIdReq = $dataArray['id_req'];
                    // write whatever we just finished working on
                    if ($insertSQL) {
                        if (!($insertRes = $xoopsDB->query($insertSQL))) {
                            exit("Error: could not write data to the new table structure with this SQL: {$insertSQL}.<br>" . $xoopsDB->error() . "<br>Please report this error to <a href=\"mailto:formulize@freeformsolutions.ca\">Freeform Solutions</a>.");
                        }
                        $insertSQL = "";
                    }
                    // build the SQL for inserting this entry
                    $insertSQL = "INSERT INTO " . $xoopsDB->prefix("formulize_" . $thisFormObject->getVar('id_form')) . " SET entry_id = \"" . $dataArray['id_req'] . "\"";
                    $metaData = getMetaData($dataArray['id_req'], "", "", true);
                    // special last param necessary because we need to use the old meta process when doing this patch!
                    $creation_uid = $metaData['created_by_uid'];
                    $mod_uid = $metaData['last_update_by_uid'];
                    $creation_datetime = $metaData['created'] == "???" ? "" : $metaData['created'];
                    $mod_datetime = $metaData['last_update'];
                    $insertSQL .= ", creation_datetime = \"{$creation_datetime}\", mod_datetime = \"{$mod_datetime}\", creation_uid = \"{$creation_uid}\", mod_uid = \"{$mod_uid}\"";
                    // derive the owner groups and write them to the owner groups table
                    $ownerGroups = array();
                    if ($creation_uid) {
                        $member_handler =& xoops_gethandler('member');
                        $creationUser = $member_handler->getUser($creation_uid);
                        if (is_object($creationUser)) {
                            $ownerGroups = $creationUser->getGroups();
                        } else {
                            $ownerGroups[] = XOOPS_GROUP_ANONYMOUS;
                        }
                    } else {
                        $ownerGroups[] = XOOPS_GROUP_ANONYMOUS;
                    }
                    foreach ($ownerGroups as $thisGroup) {
                        $ownerInsertSQL = "INSERT INTO " . $xoopsDB->prefix("formulize_entry_owner_groups") . " (`fid`, `entry_id`, `groupid`) VALUES ('" . intval($thisFormObject->getVar('id_form')) . "', '" . intval($dataArray['id_req']) . "', '" . intval($thisGroup) . "')";
                        if (!($ownerInsertRes = $xoopsDB->query($ownerInsertSQL))) {
                            print "Error: could not write owner information to new data structure, using this SQL:<br>{$ownerInsertSQL}<br>" . $xoopsDB->error() . "<br>Please report this error to <a href=\"mailto:formulize@freeformsolutions.ca\">Freeform Solutions</a>.";
                        }
                    }
                }
                // record the caption and go through to the next one if this one already exists in this form
                if (isset($foundCaptions[$dataArray['ele_caption']])) {
                    print "Warning: you have duplicate captions, '" . $dataArray['ele_caption'] . "', in your data, at entry number " . $dataArray['id_req'] . " (id_req) in form " . $thisFormObject->getVar('id_form') . ".  Only the first value found will be copied to the new data structure.  Please contact <a href=\"mailto:formulize@freeformsolutions.ca\">Freeform Solutions</a> if you would like assistance cleaning this up.  This will NOT affect the upgrade to version 3.<br>";
                    continue;
                } else {
                    $foundCaptions[$dataArray['ele_caption']] = true;
                }
                // need to handle linked selectboxes, and convert them to a different format, and store the entry_id of the sources
                // We are going to store a comma separated list of entry_ids, with leading and trailing commas so a LIKE operator can be used to do a join in the database
                if (strstr($dataArray['ele_value'], "#*=:*")) {
                    $boxproperties = explode("#*=:*", $dataArray['ele_value']);
                    $source_ele_ids = explode("[=*9*:", $boxproperties[2]);
                    // get the id_reqs of the source ele_ids
                    $sourceIdReqSQL = "SELECT id_req FROM " . $xoopsDB->prefix("formulize_form") . " WHERE ele_id = " . implode(" OR ele_id = ", $source_ele_ids) . " ORDER BY id_req";
                    $sourceIdReqRes = $xoopsDB->query($sourceIdReqSQL);
                    $dataArray['ele_value'] = "";
                    while ($sourceIdReqArray = $xoopsDB->fetchArray($sourceIdReqRes)) {
                        $dataArray['ele_value'] .= "," . $sourceIdReqArray['id_req'];
                    }
                    if ($dataArray['ele_value']) {
                        $dataArray['ele_value'] .= ",";
                    }
                }
                if ($dataArray['ele_type'] == "date" and $dataArray['ele_value'] == "") {
                    continue;
                    // don't write in blank date values, let them get the default NULL value for the field
                }
                $insertSQL .= ", `" . $captionHandleIndex[$dataArray['ele_caption']] . "`=\"" . formulize_db_escape($dataArray['ele_value']) . "\"";
            }
            if ($insertSQL) {
                if (!($insertRes = $xoopsDB->query($insertSQL))) {
                    exit("Error: could not write data to the new table structure with this SQL: {$insertSQL}.<br>" . $xoopsDB->error() . "<br>Please report this error to <a href=\"mailto:formulize@freeformsolutions.ca\">Freeform Solutions</a>.");
                }
            }
            print "Migrated data to new data structure for form " . $thisFormObject->getVar('id_form') . ".  result: OK<br>\n";
            unset($allFormObjects[$formObjectId]);
            // attempt to free up some memory
        }
        if ($derivedResult = formulize_createDerivedValueFieldsInDB()) {
            print "Created derived value fields in database.  result: OK<br>\n";
        } else {
            print "Unable to create derived value fields in database.  result: failed.  contact <a href=\"mailto:formulize@freeformsolutions.ca\">Freeform Solutions</a> for assistance.<br>\n";
        }
        // convert the captions in the linked selectbox defintions to the handles for those elements
        // 1. lookup all elements that are linked selectboxes in the formulize table (element table) -- db query for element ids
        // 2. for each one, get the caption that is stored there -- PHP level work with element handler
        // 3. get the handle corresponding to that caption
        // 4. rewrite the ele_value[2] with the handle instead of caption
        // 5. reinsert that value into the DB
        $sql = "SELECT ele_id FROM " . $xoopsDB->prefix("formulize") . " WHERE ele_value LIKE '%#*=:*%'";
        if (!($res = $xoopsDB->query($sql))) {
            exit("Error: cound not get the element ids of the linked selectboxes.  SQL: {$sql}<br>" . $xoopsDB->error() . "<br>Please report this error to <a href=\"mailto:formulize@freeformsolutions.ca\">Freeform Solutions</a>.");
        }
        $element_handler =& xoops_getmodulehandler('elements', 'formulize');
        while ($array = $xoopsDB->fetchArray($res)) {
            $elementObject = $element_handler->get($array['ele_id']);
            $ele_value = $elementObject->getVar('ele_value');
            $parts = explode("#*=:*", $ele_value[2]);
            $sql2 = "SELECT ele_handle FROM " . $xoopsDB->prefix("formulize") . " WHERE ele_caption = '" . formulize_db_escape($parts[1]) . "' AND id_form=" . $parts[0];
            //print "$sql2<br>";
            if (!($res2 = $xoopsDB->query($sql2))) {
                exit("Error: could not get the handle for a linked selectbox source.  SQL: {$sql2}<br>" . $xoopsDB->error() . "<br>Please report this error to <a href=\"mailto:formulize@freeformsolutions.ca\">Freeform Solutions</a>.");
            }
            $array2 = $xoopsDB->fetchArray($res2);
            if ($array2['ele_handle'] == "") {
                print "Warning: a handle could not be identified for this caption: '" . $parts[1] . "', in form " . $parts[0] . "  This breaks linked selectboxes for element number " . $array['ele_id'] . ".  This is most likely caused by an old caption that was changed for the element, in an old version of Formulize.<br>Please report this error to <a href=\"mailto:formulize@freeformsolutions.ca\">Freeform Solutions</a>.<br>";
            }
            $ele_value[2] = $parts[0] . "#*=:*" . $array2['ele_handle'];
            $elementObject->setVar('ele_value', $ele_value);
            if (!($res3 = $element_handler->insert($elementObject))) {
                exit("Error: could not update the linked selectbox metadata. <br>" . $xoopsDB->error() . "<br>Please report this error to <a href=\"mailto:formulize@freeformsolutions.ca\">Freeform Solutions</a>.");
            }
            unset($parts);
            unset($elementObject);
        }
        print "Updated the linked selectbox definitions new metadata.  result: OK<br><br><b>NOTE:</b> Although the 3.0 data structure is highly optimized compared to previous versions of Formulize, there are some situations which we cannot account for automatically in the upgrade process:  if you have elements in a form and users only enter numerical data there, you should edit those elements now and give them a truly numeric data type (use the new option on the element editing page to do this).  In Formulize 3 and higher, elements that have only numbers, but which are not stored as numbers in the database, will not sort properly and some calculations will not work correctly on them either.  Unfortunately, we cannot reliably determine which numeric data type should be used for all elements, therefore you will need to make this adjustment manually.  We apologize for any inconvenience.  Please contact <a href=\"mailto:formulize@freeformsolutions.ca\">Freeform Solutions</a> if you have any questions about this process.<br><br>\n";
        print "Data migration complete.  result: OK\n";
    }
}
Пример #10
0
function getPrice()
{
    $salePrice = getMetaData('et_er_price');
    $rentPrice = getMetaData('et_er_rent_price');
    return $salePrice > 0 ? $salePrice : $rentPrice;
}
Пример #11
0
    }
}
//THEN REINDEX SURVEYS TO [0] INDEX
$surveys = array_values($surveys);
//NOW FILL OUT THE METADATA
foreach ($surveys as $index => $instrument_event) {
    $instrument_id = $instrument_event["instrument_name"];
    if (isset($instrument_arm) && $instrument_arm != $survey_arms[$instrument_id][0]) {
        $current_arm++;
    }
    $instrument_arm = $survey_arms[$instrument_id][0];
    $surveys[$index]["short_name"] = $survey_arms[$instrument_id][1];
    $surveys[$index]["instrument_arm"] = $instrument_arm;
    $surveys[$index]["survey_link"] = getSurveyLink($loggedInUser->id, $instrument_id, $instrument_arm);
    //GET TOTAL QUESTIONS PER SURVEY
    $metadata = getMetaData(array($instrument_id));
    $actual_questions = array_filter($metadata, function ($item) {
        return $item["field_type"] != "descriptive";
    });
    $has_branches = array_filter($actual_questions, function ($item) {
        return !empty($item["branching_logic"]);
    });
    $no_branches = array_filter($actual_questions, function ($item) {
        return empty($item["branching_logic"]);
    });
    $branched_fields = array_flip(array_column($has_branches, "field_name"));
    $unbranched_total = count($no_branches);
    //GET # OF COMPLETED FIELDS OF SURVEY
    $just_formnames = array_map(function ($item) {
        return $item["field_name"];
    }, $actual_questions);
Пример #12
0
function verifyFileInS3($includeThumbnail)
{
    global $expectedMaxSize;
    $bucket = $_REQUEST["bucket"];
    $key = $_REQUEST["key"];
    // If utilizing CORS, we return a 200 response with the error message in the body
    // to ensure Fine Uploader can parse the error message in IE9 and IE8,
    // since XDomainRequest is used on those browsers for CORS requests.  XDomainRequest
    // does not allow access to the response body for non-success responses.
    if (isset($expectedMaxSize) && getObjectSize($bucket, $key) > $expectedMaxSize) {
        // You can safely uncomment this next line if you are not depending on CORS
        header("HTTP/1.0 500 Internal Server Error");
        deleteObject();
        echo json_encode(array("error" => "File is too big!", "preventRetry" => true));
    } else {
        $link = getTempLink($bucket, $key);
        $metadata = getMetaData($bucket, $key);
        $size = getObjectSize($bucket, $key);
        $lastmodified = getObjectLastModified($bucket, $key);
        $response = array("link" => $link, "metadata" => $metadata, "key" => $key, "size" => $size, "lastmodified" => date('Y-m-d H:i:s', strtotime($lastmodified)));
        if ($includeThumbnail) {
            $response["thumbnailUrl"] = $link;
        }
        echo json_encode($response);
    }
}
Пример #13
0
<div id="meta-box">
	<h2>property information</h2>

	<?php 
$detailInfo = array('Property Name' => 'et_er_property_name', 'Space' => 'et_er_land_size', 'Bedroom' => 'et_er_bedroom', 'Bathroom' => 'et_er_bathroom', 'Furnishing' => 'et_er_furnishing', 'Tenure' => 'et_er_tenure', 'Date Available' => 'et_er_date_vacant');
?>

	<ul>
		<?php 
foreach ($detailInfo as $key => $value) {
    if ($value) {
        ?>
					<li class="cf">
						<label><?php 
        echo $key;
        ?>
:</label>
						<span><?php 
        echo getMetaData($value);
        ?>
</span>
					</li>			
		
				<?php 
    }
}
?>
		
	</ul>
</div>