Exemplo n.º 1
0
 function userForm()
 {
     // make sure we have some billing options saved.
     //if (empty($this->opts)) return false;
     //exponent_javascript_toFoot('creditcard',"",null,'', URL_FULL.'framework/core/subsystems/forms/js/AuthorizeNet.validate.js');
     //$opts->first_name = isset($this->opts->first_name) ? $this->opts->first_name : null;
     //$opts->last_name = isset($this->opts->last_name) ? $this->opts->last_name : null;
     $this->opts = expSession::get('billing_options');
     $opts->cc_type = isset($this->opts->cc_type) ? $this->opts->cc_type : null;
     $opts->cc_number = isset($this->opts->cc_number) ? $this->opts->cc_number : null;
     $opts->exp_month = isset($this->opts->exp_month) ? $this->opts->exp_month : null;
     $opts->exp_year = isset($this->opts->exp_year) ? $this->opts->exp_year : null;
     $opts->cvv = isset($this->opts->cvv) ? $this->opts->cvv : null;
     $form = '';
     /* FIXME: hard coded options!!
     	  	if ($config_object->accept_amex) $cards["AmExCard"] = "American Express";
     		if ($config_object->accept_discover) $cards["DiscoverCard"] = "Discover";
     		if ($config_object->accept_mastercard) $cards["MasterCard"] = "MasterCard";
     		if ($config_object->accept_visa) $cards["VisaCard"] = "Visa";
     		*/
     //$fname = new textcontrol($opts->first_name);
     //$lname = new textcontrol($opts->last_name);
     /*
     $cardtypes = new dropdowncontrol($opts->cc_type,$this->getAvailableCards());
     $cardnumber = new textcontrol($opts->cc_number,20,false,20,"integer", true);
     $expiration = new monthyearcontrol($opts->exp_month, $opts->exp_year);
     $cvv = new textcontrol($opts->cvv,4,false,4,"integer", true);
     $cvvhelp = new htmlcontrol("<a href='http://en.wikipedia.org/wiki/Card_Verification_Value' target='_blank'>What's this?</a>");
     */
     $cardtypes = new dropdowncontrol("", $this->getAvailableCards());
     $cardnumber = new textcontrol("", 20, false, 20, "integer", true);
     $expiration = new monthyearcontrol("", "");
     $cvv = new textcontrol("", 4, false, 4, "integer", true);
     //$cvvhelp = new htmlcontrol("<a href='http://en.wikipedia.org/wiki/Card_Verification_Value' target='_blank'>What's this?</a>");
     $cardtypes->id = "cc_type";
     $cardnumber->id = "cc_number";
     $expiration->id = "expiration";
     $cvv->id = "cvv";
     $cvv->size = 5;
     //$cvvhelp->id = "cvvhelp";
     //$form .= $fname->toHTML("First Name", "first_name");
     //$form .= $lname->toHTML("Last Name", "last_name");
     $form .= $cardtypes->toHTML("Card Type", "cc_type");
     $form .= $cardnumber->toHTML("Card #", "cc_number");
     //$form .= "<strong class=\"example\">Example: 1234567890987654</strong>";
     $form .= $expiration->toHTML("Expiration", "expiration");
     $form .= $cvv->toHTML("CVV # <br /><a href='http://en.wikipedia.org/wiki/Card_Verification_Value' target='_blank'>What's this?</a>", 'cvv');
     //$form .= $cvvhelp->toHTML('', 'cvvhelp');
     //$form .= "<a class=\"exp-ecom-link-dis continue\" href=\"#\" id=\"checkoutnow\"><strong><em>Continue Checkout</em></strong></a>";
     //$form .= '<input id="cont-checkout" type="submit" value="Continue Checkout">';
     return $form;
 }
Exemplo n.º 2
0
 static function delete($object, $rerank = false)
 {
     if ($object == null) {
         return false;
     }
     $internal = unserialize($object->internal);
     global $db;
     $section = expSession::get("last_section");
     $secref = $db->selectObject("sectionref", "module='" . $internal->mod . "' AND source='" . $internal->src . "' AND internal='" . $internal->int . "' AND section={$section}");
     if ($secref) {
         $secref->refcount -= 1;
         $db->updateObject($secref, "sectionref", "module='" . $internal->mod . "' AND source='" . $internal->src . "' AND internal='" . $internal->int . "' AND section={$section}");
     }
     // Fix ranks
     if ($rerank) {
         $db->decrement("container", "rank", 1, "external='" . $object->external . "' AND rank > " . $object->rank);
     }
 }
Exemplo n.º 3
0
/**
 * Smarty {permissions} block plugin
 *
 * Type:     block<br>
 * Name:     permissions<br>
 * Purpose:  Set up a permissions block
 *
 * @param $params
 * @param $content
 * @param \Smarty $smarty
 * @param $repeat
 * @return string
 */
function smarty_block_permissions($params, $content, &$smarty, &$repeat)
{
    if ($content) {
        global $user, $css_core;
        if (empty($_GET['recymod'])) {
            $uilevel = 99;
            if (expSession::exists("uilevel")) {
                $uilevel = expSession::get("uilevel");
            }
            if (empty($css_core['admin-global'])) {
                expCSS::pushToHead(array("corecss" => "admin-global"));
            }
            if (isset($uilevel) && $uilevel == UILEVEL_PREVIEW || !$user->isLoggedIn()) {
                $cntnt = "";
            } else {
                $cntnt = isset($uilevel) && $uilevel == UILEVEL_PREVIEW || !$user->isLoggedIn() ? "" : $content;
            }
            return $cntnt;
        }
    }
}
Exemplo n.º 4
0
 function show($view, $loc = null)
 {
     global $db;
     // require_once(BASE."framework/core/subsystems/forms/baseform.php");
     // require_once(BASE."framework/core/subsystems/forms/form.php");
     if (defined('PREVIEW_READONLY') && !defined('SELECTOR')) {
         // Pass
     } else {
         $f = null;
         $f = $db->selectObject("formbuilder_form", "location_data='" . serialize($loc) . "'");
         if (!$f) {
             //Create a form if it's missing...
             $f->name = "New Form";
             $f->description = "";
             $f->location_data = serialize($loc);
             $f->table_name = "";
             $f->is_email = 0;
             $f->is_saved = 0;
             $f->submitbtn = gt('Submit');
             $f->resetbtn = gt('Reset');
             $f->response = gt('Your form has been submitted');
             $f->subject = gt('Submitted form from site');
             $frmid = $db->insertObject($f, "formbuilder_form");
             //Create Default Report;
             $rpt->name = gt('Default Report');
             $rpt->description = "";
             $rpt->location_data = $f->location_data;
             $rpt->text = "";
             $rpt->column_names = "";
             $rpt->form_id = $frmid;
             $db->insertObject($rpt, "formbuilder_report");
             $f->id = $frmid;
         }
         $floc = unserialize($f->location_data);
         $controls = $db->selectObjects("formbuilder_control", "form_id=" . $f->id);
         $controls = expSorter::sort(array('array' => $controls, 'sortby' => 'rank', 'order' => 'ASC'));
         $form = new form();
         $data = expSession::get('formmodule_data_' . $f->id);
         foreach ($controls as $c) {
             $ctl = unserialize($c->data);
             $ctl->_id = $c->id;
             $ctl->_readonly = $c->is_readonly;
             if (!empty($data[$c->name])) {
                 $ctl->default = $data[$c->name];
             }
             $form->register($c->name, $c->caption, $ctl);
         }
         $form->register("submit", "", new buttongroupcontrol($f->submitbtn, $f->resetbtn, ""));
         //$form->meta("action","submit_form");
         $form->meta("action", "confirm_form");
         $form->meta("m", $floc->mod);
         $form->meta("s", $floc->src);
         $form->meta("i", $floc->int);
         $form->meta("id", $f->id);
         $formmsg = '';
         $form->location(expCore::makeLocation("formbuilder", $floc->src, $floc->int));
         if (count($controls) == 0) {
             $form->controls['submit']->disabled = true;
             $formmsg .= gt('This form is blank. Select "Edit Form" to add input fields.') . '<br>';
         }
         if ($f->is_saved == 0 && $f->is_email == 0) {
             $form->controls['submit']->disabled = true;
             $formmsg .= gt('There are no actions assigned to this form. Select "Edit Form Settings" then select "Email Form" and/or "Save to Database".');
         }
         $count = $db->countObjects("formbuilder_" . $f->table_name);
         $template = new template("formmodule", $view, $loc);
         $template->assign("moduletitle", $f->name);
         $template->assign("description", $f->description);
         if ($formmsg) {
             flash('notice', $formmsg);
         }
         $template->assign("form_html", $form->toHTML($f->id));
         $template->assign("form", $f);
         $template->assign("count", $count);
         $template->register_permissions(array("administrate", "editform", "editformsettings", "editreport", "viewdata", "editdata", "deletedata"), $loc);
         $template->output();
     }
 }
Exemplo n.º 5
0
 public static function flushQueue($name)
 {
     $flash = expSession::get('flash');
     unset($flash[$name]);
     expSession::set('flash', $flash);
 }
Exemplo n.º 6
0
 static function wrapOutput($modclass, $view, $loc = null, $title = '')
 {
     global $db;
     if (defined('SOURCE_SELECTOR') && strtolower($modclass) != 'containermodule') {
         $container = null;
         $mod = new $modclass();
         ob_start();
         if (expModules::controllerExists($modclass)) {
             $action = $db->selectValue('container', 'action', "internal='" . serialize($loc) . "'");
             renderAction(array('controller' => $modclass, 'action' => $action, 'view' => $view));
         } else {
             $mod->show($view, $loc, $title);
         }
         $container->output = ob_get_contents();
         ob_end_clean();
         $source_select = expSession::get('source_select');
         $c_view = $source_select['view'];
         $c_module = $source_select['module'];
         $clickable_mods = $source_select['showmodules'];
         if (!is_array($clickable_mods)) {
             $clickable_mods = null;
         }
         $dest = $source_select['dest'];
         $template = new template($c_module, $c_view, $loc);
         if ($dest) {
             $template->assign('dest', $dest);
         }
         $container->info = array('module' => $mod->name(), 'source' => $loc->src, 'hasContent' => $mod->hasContent(), 'hasSources' => $mod->hasSources(), 'hasViews' => $mod->hasViews(), 'class' => $modclass, 'clickable' => $clickable_mods == null || in_array($modclass, $clickable_mods));
         $template->assign('container', $container);
         $template->output();
     } else {
         call_user_func(array($modclass, 'show'), $view, $loc, $title);
     }
 }
Exemplo n.º 7
0
 function status_export()
 {
     global $db;
     //eDebug($this->params);
     //$sql = "SELECT * INTO OUTFILE '" . BASE . "tmp/export.csv' FIELDS TERMINATED BY ','  FROM exponent_product WHERE 1 LIMIT 10";
     //is | parent_id | SKU |WAREHOUSE LOCATION | Title | Vendor/Manufacturer | Product Status | Notes
     $out = '"id","parent_id","model","warehouse_location","title","vendor","product_status","notes"' . chr(13) . chr(10);
     if (isset($this->params['applytoall']) && $this->params['applytoall'] == 1) {
         $sql = expSession::get('product_export_query');
         //eDebug($sql);
         //expSession::set('product_export_query','');
         $prods = $db->selectArraysBySql($sql);
         //eDebug($prods);
     } else {
         foreach ($this->params['act-upon'] as $prod) {
             $prods[] = array('id' => $prod);
         }
     }
     $stats = new product_status();
     $stats = $stats->find('all');
     $statuses = array();
     foreach ($stats as $stat) {
         $statuses[$stat->id] = $stat->title;
     }
     eDebug($statuses);
     set_time_limit(0);
     $baseProd = new product();
     //$p = new product($pid['id'], false, false);
     //id | parent_id | SKU |WAREHOUSE LOCATION | Title | Vendor/Manufacturer | Product Status | Notes
     foreach ($prods as $pid) {
         $except = array('crosssellItem', 'optiongroup', 'childProduct');
         $p = $baseProd->find('first', 'id=' . $pid['id'], null, null, null, true, true, $except, true);
         /*if(count($p->expSimpleNote))
           {
               eDebug($p,true);
           }
           else
           {
               continue;
           }*/
         $out .= $this->outputField($p->id);
         $out .= $this->outputField($p->parent_id);
         $out .= $this->outputField($p->model);
         $out .= $this->outputField($p->warehouse_location);
         $out .= $this->outputField($p->title);
         $out .= $this->outputField($p->company->title);
         $out .= $this->outputField($statuses[$p->product_status_id]);
         $noteString = '';
         foreach ($p->expSimpleNote as $note) {
             $noteString .= "(" . $note->name . " - " . date('M d Y H:i A', $note->created_at) . ") " . $note->body . "||";
         }
         $out .= $this->outputField($noteString, '') . chr(13) . chr(10);
         $cps = $baseProd->find('all', 'parent_id=' . $p->id, null, null, null, true, true, $except, true);
         foreach ($cps as $cp) {
             $out .= $this->outputField($cp->id);
             $out .= $this->outputField($cp->parent_id);
             $out .= $this->outputField($cp->model);
             $out .= $this->outputField($cp->warehouse_location);
             $out .= $this->outputField($cp->title);
             $out .= $this->outputField($cp->company->title);
             $out .= $this->outputField($statuses[$cp->product_status_id]);
             $noteString = '';
             foreach ($cp->expSimpleNote as $note) {
                 $noteString .= "(" . $note->name . " - " . date('M d Y H:i A', $note->created_at) . ") " . $note->body . "||";
             }
             $out .= $this->outputField($noteString, '') . chr(13) . chr(10);
         }
     }
     //eDebug($out,true);
     $outFile = 'tmp/product_export_' . time() . '.csv';
     $outHandle = fopen(BASE . $outFile, 'w');
     fwrite($outHandle, $out);
     fclose($outHandle);
     echo "<br/><br/>Download the file here: <a href='" . PATH_RELATIVE . $outFile . "'>Product Export</a>";
     /*eDebug(BASE . "tmp/export.csv");
       $db->sql($sql);
       eDebug($db->error());*/
     /*OPTIONALLY ENCLOSED BY '" . '"' . 
       "' ESCAPED BY '\\'
       LINES TERMINATED BY '" . '\\n' .
       "' */
 }
Exemplo n.º 8
0
 function showallSubcategories()
 {
     global $db;
     expHistory::set('viewable', $this->params);
     $parent = isset($_REQUEST['cat']) ? $_REQUEST['cat'] : expSession::get('last_ecomm_category');
     $category = new storeCategory($parent);
     $categories = $category->getEcomSubcategories();
     $ancestors = $category->pathToNode();
     assign_to_template(array('categories' => $categories, 'ancestors' => $ancestors, 'category' => $category));
 }
Exemplo n.º 9
0
<?php

##################################################
#
# Copyright (c) 2004-2011 OIC Group, Inc.
# Written and Designed by James Hunt
#
# This file is part of Exponent
#
# Exponent is free software; you can redistribute
# it and/or modify it under the terms of the GNU
# General Public License as published by the Free
# Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# GPL: http://www.gnu.org/licenses/gpl.txt
#
##################################################
if (!defined('EXPONENT')) {
    exit('');
}
echo json_encode(expSession::get($_REQUEST['var']));
Exemplo n.º 10
0
#
# Exponent is free software; you can redistribute
# it and/or modify it under the terms of the GNU
# General Public License as published by the Free
# Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# GPL: http://www.gnu.org/licenses/gpl.txt
#
##################################################
/** @define "BASE" "../../../../.." */
if (!defined('EXPONENT')) {
    exit('');
}
$dest_dir = expSession::get('dest_dir');
$files = expSession::get('files_data');
if (!file_exists(BASE . 'files')) {
    mkdir(BASE . 'files', 0777);
}
$filecount = 0;
foreach (array_keys($files) as $file) {
    expFile::copyDirectoryStructure($dest_dir . '/files/' . $file, BASE . 'files/' . $file);
    copy($dest_dir . '/files/' . $file, BASE . 'files/' . $file);
    $filecount += 1;
}
expSession::un_set('dest_dir');
expSession::un_set('files_data');
expFile::removeDirectory($dest_dir);
$template = new template('importer', '_files_final');
$template->assign('file_count', $filecount);
$template->output();
Exemplo n.º 11
0
#
# GPL: http://www.gnu.org/licenses/gpl.txt
#
##################################################
if (!defined('EXPONENT')) {
    exit('');
}
// PERM CHECK
$source_select = array();
$module = "containermodule";
$view = "_sourcePicker";
$clickable_mods = null;
// Show all
$dest = null;
if (expSession::is_set("source_select") && defined('SOURCE_SELECTOR')) {
    $source_select = expSession::get("source_select");
    $view = $source_select["view"];
    $module = $source_select["module"];
    $clickable_mods = $source_select["showmodules"];
    $dest = $source_select['dest'];
}
expSession::clearAllUsersSessionCache('containermodule');
$orphans = array();
foreach ($db->selectObjects("sectionref", "module='" . preg_replace('/[^A-Za-z0-9_]/', '', $_GET['module']) . "' AND refcount=0") as $orphan) {
    $obj = null;
    $loc = expCore::makeLocation($orphan->module, $orphan->source, $orphan->internal);
    if (class_exists($orphan->module)) {
        $modclass = $orphan->module;
        $mod = new $modclass();
        if (class_exists($modclass)) {
            ob_start();
Exemplo n.º 12
0
 public function clearCart()
 {
     global $order;
     $sessAr = expSession::get('verify_shopper');
     if (isset($sessAr)) {
         order::setCartCookie($order);
         $orig_path = $sessAr['orig_path'];
         expSession::un_set('verify_shopper');
         redirect_to($orig_path);
     } else {
         expHistory::back();
     }
 }
Exemplo n.º 13
0
/**
 * Smarty {control} function plugin
 *
 * Type:     function<br>
 * Name:     control<br>
 * Purpose:  create a form control
 *
 * @param         $params
 * @param \Smarty $smarty
 */
function smarty_function_control($params, &$smarty)
{
    global $db, $user;
    if (isset($params['type']) && isset($params['name']) || $params['type'] == 'buttongroup' || $params['type'] == 'antispam') {
        //    || $params['type'] == 'captcha' || $params['type'] == 'recaptcha' || $params['type'] == 'antispam') {
        //	  || $params['type'] == 'recaptcha' || $params['type'] == 'antispam') {
        // if a label wasn't passed in then we need to set one.
        //if (empty($params['label'])) $params['label'] = $params['name'];
        //Figure out which type of control to use. Also, some controls need some special setup.  We handle that here.
        if ($params['type'] == 'popupdatetimecontrol') {
            //FIXME this control does not exist due ot missing library files
            $control = new popupdatetimecontrol(null, "", false);
        } elseif ($params['type'] == 'yuidatetimecontrol') {
            $edittext = isset($params['edit_text']) ? $params['edit_text'] : 'Change Date/Time';
            $showdate = true;
            if (isset($params['show_date']) && $params['show_date'] == false) {
                $showdate = false;
            }
            $showtime = true;
            if (isset($params['show_time']) && $params['show_time'] == false) {
                $showtime = false;
            }
            $control = new yuidatetimecontrol($params['value'], $edittext, $showdate, $showtime);
            if (empty($params['value'])) {
                $params['value'] = time();
            }
        } elseif ($params['type'] == 'yuicalendarcontrol') {
            $control = new yuicalendarcontrol($params['value']);
            if (empty($params['value'])) {
                $params['value'] = time();
            }
        } elseif ($params['type'] == 'datetimecontrol' || $params['type'] == 'datetime') {
            if (empty($params['value'])) {
                $params['value'] = time();
            }
            $showdate = isset($params['showdate']) ? $params['showdate'] : true;
            $showtime = isset($params['showtime']) ? $params['showtime'] : true;
            $control = new datetimecontrol($params['value'], $showdate, $showtime);
        } elseif ($params['type'] == 'monthyear') {
            $control = new monthyearcontrol($params['month'], $params['year']);
        } elseif ($params['type'] == 'buttongroup') {
            $submit = isset($params['submit']) ? $params['submit'] : null;
            $reset = isset($params['reset']) ? $params['reset'] : null;
            $cancel = isset($params['cancel']) ? $params['cancel'] : null;
            $returntype = isset($params['returntype']) ? $params['returntype'] : null;
            $control = new buttongroupcontrol($submit, $reset, $cancel, null, $returntype);
        } elseif ($params['type'] == 'files') {
            if (!empty($params['olduploader'])) {
                $control = new uploadcontrol();
            } else {
                $subtype = isset($params['subtype']) ? $params['subtype'] : null;
                $control = new filemanagercontrol($subtype);
                $control->limit = isset($params['limit']) ? $params['limit'] : 10;
                $control->value = $params['value'];
            }
        } elseif ($params['type'] == 'tags') {
            $collections = isset($params['collections']) ? $params['collections'] : array();
            $subtype = isset($params['subtype']) ? $params['subtype'] : null;
            $control = new tagpickercontrol($collections, $subtype);
        } elseif ($params['type'] == 'dropdown') {
            $control = new dropdowncontrol($params['default']);
            $control->type = "select";
            $control->default = $params['default'];
            $control->include_blank = isset($params['includeblank']) ? $params['includeblank'] : false;
            $control->multiple = isset($params['multiple']) ? true : false;
            if (isset($params['from']) && isset($params['to'])) {
                for ($i = $params['from']; $i <= $params['to']; $i++) {
                    $control->items[$i] = isset($params['zeropad']) ? sprintf("%02d", $i) : $i;
                }
            } elseif (isset($params['frommodel']) || isset($params['items']) && isset($params['key'])) {
                $key = isset($params['key']) ? $params['key'] : 'id';
                $display = isset($params['display']) ? $params['display'] : 'title';
                $order = isset($params['orderby']) ? $params['orderby'] : $display;
                $dir = isset($params['dir']) ? $params['dir'] : 'ASC';
                if (isset($params['frommodel'])) {
                    $model = new $params['frommodel']();
                    $where = empty($params['where']) ? null : $params['where'];
                    $params['items'] = $db->selectObjects($model->tablename, $where, $order . ' ' . $dir);
                }
                foreach ($params['items'] as $item) {
                    $control->items[$item->{$key}] = $item->{$display};
                }
                $noitems = gt("-- No items found --");
                if (count($control->items) < 1) {
                    $control->items = array(0 => $noitems);
                }
            } else {
                if (is_array($params['items'])) {
                    $control->items = $params['items'];
                    if (!empty($params['values'])) {
                        $control->items = array_combine($params['values'], $control->items);
                    }
                } elseif (is_string($params['items'])) {
                    $delimiter = isset($params['delimiter']) ? $params['delimiter'] : ',';
                    $items = explode($delimiter, $params['items']);
                    if (!empty($params['values'])) {
                        $values = is_array($params['values']) ? $params['values'] : explode($delimiter, $params['values']);
                    } else {
                        $values = $items;
                    }
                    $control->items = array_combine($values, $items);
                } else {
                    $control->items = array();
                }
            }
        } elseif ($params['type'] == 'radiogroup') {
            $control = new radiogroupcontrol();
            // differentiate it from the old school forms
            $control->newschool = true;
            $control->default = $params['default'];
            $control->cols = $params['columns'];
            // get the items to use as the radio button labels
            $items = is_array($params['items']) ? $params['items'] : explode(',', $params['items']);
            // check if we have a list of values.  if not we can assume they are passed in via the items
            // array as the keys.
            if (isset($params['values'])) {
                $values = is_array($params['values']) ? $params['values'] : explode(',', $params['values']);
                $control->items = array_combine($values, $items);
            } else {
                $control->items = $items;
                //array_combine($items, $items);
            }
        } elseif ($params['type'] == 'radio') {
            $control = new radiocontrol();
            $control->value = $params['value'];
            $control->newschool = true;
        } elseif ($params['type'] == 'textarea') {
            $control = new texteditorcontrol();
            if (isset($params['module'])) {
                $control->module = $params['module'];
            }
            if (isset($params['rows'])) {
                $control->rows = $params['rows'];
            }
            if (isset($params['cols'])) {
                $control->cols = $params['cols'];
            }
            //if (isset($params['toolbar'])) $control->toolbar = $params['toolbar'];
        } elseif ($params['type'] == 'editor' || $params['type'] == 'html') {
            if (SITE_WYSIWYG_EDITOR == "ckeditor") {
                $control = new ckeditorcontrol();
                $control->toolbar = empty($params['toolbar']) ? '' : $params['toolbar'];
            } else {
                $control = new htmleditorcontrol();
                if (isset($params['module'])) {
                    $control->module = $params['module'];
                }
                if (isset($params['rows'])) {
                    $control->rows = $params['rows'];
                }
                if (isset($params['cols'])) {
                    $control->cols = $params['cols'];
                }
                $control->height = $params['height'] ? $params['height'] : "600px";
                if (isset($params['toolbar'])) {
                    $control->toolbar = $params['toolbar'];
                }
            }
        } elseif ($params['type'] == 'listbuilder') {
            $default = isset($params['default']) ? $params['default'] : array();
            $source = isset($params['source']) ? $params['source'] : array();
            $control = new listbuildercontrol($default, $source);
            echo $control->controlToHTML($params['name']);
            return;
        } elseif ($params['type'] == 'list') {
            $control = new listcontrol();
        } elseif ($params['type'] == 'antispam') {
            //eDebug(ANTI_SPAM_CONTROL, true);
            if (SITE_USE_ANTI_SPAM && ANTI_SPAM_CONTROL == 'recaptcha') {
                // make sure we have the proper config.
                if (!defined('RECAPTCHA_PUB_KEY')) {
                    echo '<h2 style="color:red">' . gt('reCaptcha configuration is missing the public key.') . '</h2>';
                    return;
                }
                if ($user->isLoggedIn() && ANTI_SPAM_USERS_SKIP == 1) {
                    // skip it for logged on users based on config
                } else {
                    // include the library and show the form control
                    require_once BASE . 'external/recaptchalib.php';
                    echo recaptcha_get_html(RECAPTCHA_PUB_KEY, $error);
                    echo '<p>' . gt('Fill out the above security question to submit your form.') . '</p>';
                }
                return;
            } elseif (ANTI_SPAM_CONTROL == 0) {
                return;
            }
        } elseif ($params['type'] == 'user') {
            $control = new dropdowncontrol();
            $control->include_blank = isset($params['includeblank']) ? $params['includeblank'] : false;
            $control->items = $db->selectDropdown('user', 'username');
        } elseif ($params['type'] == 'state') {
            //old use:  if (empty($params['all_us_territories'])) {
            /*$regions = $db->select
                  $not_states = array(3,6,7,8,9,10,11,17,20,30,46,50,52,60);
              } else {
                  $not_states = array();
              }*/
            //if(!empty($params['exclude'])) $not_states = array_merge($not_states,explode(',',$params['exclude']));
            if ($db->tableExists('geo_region')) {
                $c = $db->selectObject('geo_country', 'is_default=1');
                if (empty($c->id)) {
                    $country = 223;
                } else {
                    $country = $c->id;
                }
                $control = new dropdowncontrol();
                if (isset($params['multiple'])) {
                    $control->multiple = true;
                    $control->items[-1] = 'ALL United States';
                }
                /*if (isset($params['add_other'])) {                   
                      $control->items[-2] = '-- Specify State Below --';
                  }*/
                $states = $db->selectObjects('geo_region', 'country_id=' . $country . ' AND active=1 ORDER BY rank, name ASC');
                foreach ($states as $state) {
                    // only show the US states unless the theme says to show all us territories
                    //if (!in_array($state->id, $not_states)) {
                    $control->items[$state->id] = isset($params['abbv']) ? $state->code : $state->name;
                    //}
                }
                //if(!count($states)) $control->items[-2] = '-- Specify State Below --';
                if (isset($params['add_other'])) {
                    $control->items[-2] = '-- Specify State Below --';
                } else {
                    $control->include_blank = isset($params['includeblank']) ? $params['includeblank'] : false;
                }
                // sanitize the default value. can accept as id, code abbrv or full name,
                if (!empty($params['value']) && !is_numeric($params['value']) && !is_array($params['value'])) {
                    $params['value'] = $db->selectValue('geo_region', 'id', 'name="' . $params['value'] . '" OR code="' . $params['value'] . '"');
                }
            } else {
                echo "NO TABLE";
                exit;
            }
        } elseif ($params['type'] == 'country') {
            //old - pre address configuration
            //if(!empty($params['exclude'])) $not_countries = explode(',',$params['exclude']);
            //else $not_countries = array();
            if ($db->tableExists('geo_country')) {
                $control = new dropdowncontrol();
                $control->include_blank = isset($params['includeblank']) ? $params['includeblank'] : false;
                if (isset($params['multiple'])) {
                    $control->multiple = true;
                    //$control->items[-1] = 'ALL United States';
                }
                if ($params['show_all']) {
                    $countries = $db->selectObjects('geo_country', null, 'name ASC');
                } else {
                    $countries = $db->selectObjects('geo_country', 'active=1', 'name ASC');
                }
                foreach ($countries as $country) {
                    //if (!in_array($country->id, $not_countries)) {
                    $control->items[$country->id] = isset($params['abbv']) ? $country->iso_code_3letter : $country->name;
                    //}
                }
                // sanitize the default value. can accept as id, code abbrv or full name,
                if (!empty($params['value']) && !is_numeric($params['value']) && !is_array($params['value'])) {
                    $params['value'] = $db->selectValue('geo_country', 'id', 'name="' . $params['value'] . '" OR code="' . $params['value'] . '"');
                }
            } else {
                echo "NO TABLE";
                exit;
            }
        } elseif ($params['type'] == 'quantity') {
            $value = isset($params['value']) ? $params['value'] : null;
            $min = isset($params['min']) ? $params['min'] : 0;
            $max = isset($params['max']) ? $params['max'] : 99999;
            $control = new quantitycontrol($value, $min, $max);
        } elseif ($params['type'] == 'checkbox') {
            $value = isset($params['value']) ? $params['value'] : null;
            $control = new checkboxcontrol($value);
            $control->postfalse = isset($params['postfalse']) ? 1 : 0;
            $control->newschool = true;
            $control->value = isset($params['value']) ? $params['value'] : 1;
        } elseif ($params['type'] == 'tagtree') {
            $control = new tagtreecontrol($params);
        } elseif ($params['type'] == 'filedisplay-types') {
            $control = new dropdowncontrol();
            $control->include_blank = '-- This modules does not use files --';
            $control->items = get_filedisplay_views();
        } elseif ($params['type'] == 'calendar') {
            $control = new calendarcontrol();
        } elseif ($params['type'] == 'text') {
            $control = new genericcontrol($params['type']);
            $control->size = $params['size'] ? $params['size'] : "40";
        } elseif ($params['type'] == 'autocomplete') {
            $control = new autocompletecontrol();
            $control->schema = "'" . str_replace(",", "','", $params['schema']) . "'";
            $control->value = $params['value'];
            $control->controller = empty($params['controller']) ? "search" : $params['controller'];
            $control->action = empty($params['action']) ? "autocomplete" : $params['action'];
            $control->searchmodel = empty($params['searchmodel']) ? "text" : $params['searchmodel'];
            $control->searchoncol = empty($params['searchoncol']) ? "title" : $params['searchoncol'];
            $control->jsinject = empty($params['jsinject']) ? "" : $params['jsinject'];
        } else {
            $control = new genericcontrol($params['type']);
        }
        //eDebug($smarty->getTemplateVars('formError'));
        //Add the optional params in specified
        if (isset($params['class'])) {
            $control->class = $params['class'];
        }
        if (isset($params['required'])) {
            $control->required = true;
        }
        // Let see if this control should be checked
        if (isset($params['checked'])) {
            // if we have a control group the values will probably be coming in an array
            if (is_array($params['checked'])) {
                // check if its in the array
                if (in_array($params['value'], $params['checked'])) {
                    $control->checked = true;
                } elseif (is_object(current($params['checked']))) {
                    foreach ($params['checked'] as $obj) {
                        if ($obj->id == $params['value']) {
                            $control->checked = true;
                        }
                    }
                }
            } elseif ($params['value'] == $params['checked']) {
                $control->checked = true;
            } elseif (is_bool($params['checked'])) {
                $control->checked = $params['checked'];
            } elseif ($params['checked'] == 1) {
                $control->checked = 1;
            }
        }
        if (expSession::is_set('last_POST')) {
            $post = expSession::get('last_POST');
            $post_errors = expSession::get('last_post_errors');
            // flag this field as having errors if it failed validation
            if (is_array($post_errors) && in_array($params['name'], $post_errors)) {
                $control->class .= ' field-error';
            }
            if ($params['type'] == 'checkbox') {
                $realname = str_replace('[]', '', $params['name']);
                $control->default = $params['value'];
                if (!empty($post[$realname])) {
                    if (is_array($post[$realname])) {
                        if (in_array($params['value'], $post[$realname])) {
                            $control->checked = true;
                        }
                    } else {
                        $control->checked = true;
                    }
                }
            } elseif (isset($params['multiple'])) {
                $realname = str_replace('[]', '', $params['name']);
                if (!empty($post[$realname])) {
                    $control->default = $post[$realname];
                }
            } else {
                if (!empty($post[$params['name']])) {
                    $control->default = $post[$params['name']];
                }
            }
        } elseif (isset($params['value'])) {
            // if this field is filtered than lets go ahead and format the data before we stick it in the field.
            if ($params['filter'] == 'money') {
                $params['value'] = expCore::getCurrencySymbol('USD') . number_format($params['value'], 2, '.', ',');
            } elseif ($params['filter'] == 'integer') {
                $params['value'] = number_format($params['value'], 0, '.', ',');
            }
            $control->default = $params['value'];
        }
        //if (isset($params['value'])) $control->default = $params['value'];
        if (isset($params['caption'])) {
            $control->caption = $params['caption'];
        }
        if (isset($params['size'])) {
            $control->size = $params['size'];
        }
        if (isset($params['nowrap'])) {
            $control->nowrap = "nowrap";
        }
        if (isset($params['flip'])) {
            $control->flip = $params['flip'];
        }
        if (isset($params['disabled']) && $params['disabled'] != false) {
            $control->disabled = true;
        }
        if (isset($params['maxlength'])) {
            $control->maxlength = $params['maxlength'];
        }
        if (isset($params['tabindex'])) {
            $control->tabindex = $params['tabindex'];
        }
        if (isset($params['accesskey'])) {
            $control->accesskey = $params['accesskey'];
        }
        if (isset($params['filter'])) {
            $control->filter = $params['filter'];
        }
        if (isset($params['onclick'])) {
            $control->onclick = $params['onclick'];
        }
        if (isset($params['onchange'])) {
            $control->onchange = $params['onchange'];
        }
        if (isset($params['readonly']) && $params['readonly'] != false) {
            $control->readonly = true;
        }
        if (isset($params['ajaxaction'])) {
            $control->ajaxaction = $params['ajaxaction'];
        }
        if (isset($params['loadjsfile'])) {
            $control->loadjsfile = $params['loadjsfile'];
        }
        if (isset($params['default_date'])) {
            $control->default_date = $params['default_date'];
        }
        if (isset($params['default_hour'])) {
            $control->default_hour = $params['default_hour'];
        }
        if (isset($params['default_min'])) {
            $control->default_min = $params['default_min'];
        }
        if (isset($params['default_ampm'])) {
            $control->default_ampm = $params['default_ampm'];
        }
        $control->name = $params['name'];
        $badvals = array("[", "]", ",", " ", "'", "\"", "&", "#", "%", "@", "!", "\$", "(", ")", "{", "}");
        //$newid = str_replace($badvals, "", $params['name']);
        $control->id = isset($params['id']) && $params['id'] != "" ? $params['id'] : "";
        //echo $control->id;
        /*$labelclass = isset($params['labelclass']) ? ' '.$params['labelclass'] : '';
                
                //container for the controll set, including labelSpan and input
                if($params['type']!='hidden') echo '<label id="'.$control->id.'Control" class="control">'; 
        
        
                //Write out the label for this control if the user specified a label and there is no label position or position is set to left
                if ( (isset($params['label'])) && (!isset($params['labelpos']) || $params['labelpos'] == 'left') ) {
                    echo '<span class="label'.$labelclass.'">'.$params['label'].'</span>';
                }
                */
        // attempt to translate the label
        if (!empty($params['label'])) {
            $params['label'] = gt($params['label']);
        }
        //write out the control itself...and then we're done.
        if (isset($params['model'])) {
            echo $control->toHTML($params['label'], $params['model'] . '[' . $params['name'] . ']');
        } else {
            echo $control->toHTML($params['label'], $params['name']);
        }
        /*
        //Write out the label for this control if the user specified a label and position is set to right
        if (isset($params['label']) && $params['labelpos'] == 'right') {
            echo '<span class="label'.$labelclass.'">'.$params['label'].'</span>';
        }
        
        //close the control container div
        if($params['type']!='hidden'){ echo '</label>'; }
        */
    } else {
        echo "Both the 'type' and 'name' parameters are required for the control plugin to function";
    }
}
Exemplo n.º 14
0
 /**
  * expHistory Constructor
  *
  * The constructor will grab the users history from the session.  If it is not present in the session
  * it will be initialized and saved later.
  *
  * @return \expHistory
  */
 public function __construct()
 {
     /** exdoc
      * Flow Type Specifier : None
      * Old flow subsystem code
      * @node Subsystems:Flow
      */
     define('SYS_FLOW_NONE', 0);
     /** exdoc
      * Flow Type Specifier : Public Access
      * Old flow subsystem code
      * @node Subsystems:Flow
      */
     define('SYS_FLOW_PUBLIC', 1);
     /** exdoc
      * Flow Type Specifier : Protected Access
      * Old flow subsystem code
      * @node Subsystems:Flow
      */
     define('SYS_FLOW_PROTECTED', 2);
     /** exdoc
      * Flow Type Specifier : Sectional Page
      * Old flow subsystem code
      * @node Subsystems:Flow
      */
     define('SYS_FLOW_SECTIONAL', 1);
     /** exdoc
      * Flow Type Specifier : Action Page
      * Old flow subsystem code
      * @node Subsystems:Flow
      */
     define('SYS_FLOW_ACTION', 2);
     $history = expSession::get('history');
     if (empty($history)) {
         $this->history = array('viewable' => array(), 'editable' => array(), 'manageable' => array(), 'lasts' => array('not_editable' => array()));
     } else {
         $this->history = $history;
     }
 }
 public function toggle_mobile()
 {
     if (!expSession::is_set('mobile')) {
         // account for FORCE_MOBILE initial state
         expSession::set('mobile', MOBILE);
     }
     expSession::set('mobile', !expSession::get('mobile'));
     expTheme::removeSmartyCache();
     expHistory::back();
 }
Exemplo n.º 16
0
 /**
  * method to redirect to a login if needed
  */
 public static function loginredirect()
 {
     global $user;
     global $router;
     ob_start();
     if ($user->isLoggedIn()) {
         header('Location: ' . expSession::get('redirecturl'));
     } else {
         //expSession::set('redirecturl', expHistory::getLastNotEditable());
         expSession::set('redirecturl', expHistory::getLast());
         expSession::set('redirecturl_error', makeLink(array('controller' => 'login', 'action' => 'loginredirect')));
         //			expHistory::flowSet(SYS_FLOW_PUBLIC,SYS_FLOW_ACTION);
         expHistory::set('viewable', $router->params);
     }
     redirect_to(array('controller' => 'login', 'action' => 'showlogin'));
 }
Exemplo n.º 17
0
 public function getSection()
 {
     if (expTheme::inAction()) {
         if (isset($_REQUEST['section'])) {
             $section = $this->url_type == "sef" ? $this->getPageByName($_REQUEST['section']) : $_REQUEST['section'];
         } else {
             $section = expSession::is_set('last_section') ? expSession::get('last_section') : SITE_DEFAULT_SECTION;
         }
     } else {
         $section = isset($_REQUEST['section']) ? $_REQUEST['section'] : SITE_DEFAULT_SECTION;
     }
     return $section;
 }
/**
 * Smarty {sessions_get} function plugin
 *
 * Type:     function<br>
 * Name:     chain<br>
 * Purpose:  get and assign sessions variables
 *
 * @param         $params
 * @param \Smarty $smarty
 * @return bool
 */
function smarty_function_sessions_get($params, &$smarty)
{
    $smarty->assign($params['var'], expSession::get($params['var']));
}
Exemplo n.º 19
0
     $container->title = '';
     $container->rank = $_GET['rank'];
     $container->is_private = 0;
 } else {
     $container->internal = unserialize($container->internal);
     $secref = $db->selectObject('sectionref', "module='" . $container->internal->mod . "' AND source='" . $container->internal->src . "'");
 }
 expSession::clearAllUsersSessionCache('containermodule');
 $template = new template('containermodule', '_form_edit', $loc);
 //	$template->assign('rerank', (isset($_GET['rerank']) ? 1 : 0) );
 $template->assign('rerank', isset($_GET['rerank']) ? $_GET['rerank'] : 0);
 $template->assign('container', $container);
 $template->assign('locref', $secref);
 $template->assign('is_edit', isset($container->id) ? 1 : 0);
 $template->assign('can_activate_modules', $user->is_acting_admin);
 $template->assign('current_section', expSession::get('last_section'));
 $haveclass = false;
 $mods = array();
 //$modules_list = (isset($container->id) ? expModules::modules_list() : exponent_modules_listActive());
 $modules_list = expModules::getActiveModulesAndControllersList();
 if (!count($modules_list)) {
     // No active modules
     $template->assign('nomodules', 1);
 } else {
     $template->assign('nomodules', 0);
 }
 //sort($modules_list);
 $js_init = '<script type="text/javascript">';
 foreach ($modules_list as $moduleclass) {
     $module = new $moduleclass();
     $mod = null;
Exemplo n.º 20
0
 /** exdoc
  * Calls the necessary methods to show a specific module
  *
  * @param string $module The classname of the module to display
  * @param string $view The name of the view to display the module with
  * @param string $title The title of the module (support is view-dependent)
  * @param string $source The source of the module.
  * @param bool $pickable Whether or not the module is pickable in the Source Picker.
  * @param null $section
  * @param bool $hide_menu
  * @param array $params
  * @return
  * @node Subsystems:Theme
  */
 public static function showModule($module, $view = "Default", $title = "", $source = null, $pickable = false, $section = null, $hide_menu = false, $params = array())
 {
     if (!AUTHORIZED_SECTION && $module != 'navigationmodule' && $module != 'loginController') {
         return;
     }
     global $db, $sectionObj, $module_scope;
     // Ensure that we have a section
     //FJD - changed to $sectionObj
     if ($sectionObj == null) {
         $section_id = expSession::get('last_section');
         if ($section_id == null) {
             $section_id = SITE_DEFAULT_SECTION;
         }
         $sectionObj = $db->selectObject('section', 'id=' . $section_id);
         //$section->id = $section_id;
     }
     if ($module == "loginController" && defined('PREVIEW_READONLY') && PREVIEW_READONLY == 1) {
         return;
     }
     //		if (expSession::is_set("themeopt_override")) {
     //			$config = expSession::get("themeopt_override");
     //			if (in_array($module,$config['ignore_mods'])) return;
     //		}
     $loc = expCore::makeLocation($module, $source . "");
     if (empty($module_scope[$source][$module]->scope)) {
         $module_scope[$source][$module]->scope = 'global';
     }
     // make sure we've added this module to the sectionref table
     if ($db->selectObject("sectionref", "module='{$module}' AND source='" . $loc->src . "'") == null) {
         $secref = null;
         $secref->module = $module;
         $secref->source = $loc->src;
         $secref->internal = "";
         $secref->refcount = 1000;
         if ($sectionObj != null) {
             $secref->section = $sectionObj->id;
         }
         $secref->is_original = 1;
         $db->insertObject($secref, 'sectionref');
     }
     $iscontroller = expModules::controllerExists($module);
     if (defined('SELECTOR') && call_user_func(array($module, "hasSources"))) {
         containermodule::wrapOutput($module, $view, $loc, $title);
     } else {
         if (is_callable(array($module, "show")) || $iscontroller) {
             // FIXME: we are checking here for a new MVC style controller or an old school module. We only need to perform
             // this check until we get the old modules all gone...until then we have the check and a lot of code duplication
             // in the if blocks below...oh well, that's life.
             if (!$iscontroller) {
                 if (!$hide_menu && $loc->mod != "containermodule" && (call_user_func(array($module, "hasSources")) || $db->tableExists($loc->mod . "_config"))) {
                     $container->permissions = array('administrate' => expPermissions::check('administrate', $loc) ? 1 : 0, 'configure' => expPermissions::check('configure', $loc) ? 1 : 0);
                     if ($container->permissions['administrate'] || $container->permissions['configure']) {
                         $container->randomizer = mt_rand(1, ceil(microtime(1)));
                         $container->view = $view;
                         $container->info['class'] = $loc->mod;
                         $container->info['module'] = call_user_func(array($module, "name"));
                         $container->info['source'] = $loc->src;
                         $container->info['hasConfig'] = $db->tableExists($loc->mod . "_config");
                         $template = new template('containermodule', '_hardcoded_module_menu', $loc);
                         $template->assign('container', $container);
                         $template->output();
                     }
                 }
             } else {
                 // if we hit here we're dealing with a controller...not a module
                 if (!$hide_menu) {
                     $controller = expModules::getController($module);
                     $container->permissions = array('administrate' => expPermissions::check('administrate', $loc) ? 1 : 0, 'configure' => expPermissions::check('configure', $loc) ? 1 : 0);
                     if ($container->permissions['administrate'] || $container->permissions['configure']) {
                         $container->randomizer = mt_rand(1, ceil(microtime(1)));
                         $container->view = $view;
                         $container->action = $params['action'];
                         $container->info['class'] = $loc->mod;
                         $container->info['module'] = $controller->displayname();
                         $container->info['source'] = $loc->src;
                         $container->info['hasConfig'] = true;
                         $template = new template('containermodule', '_hardcoded_module_menu', $loc);
                         $template->assign('container', $container);
                         $template->output();
                     }
                 }
             }
             if ($iscontroller) {
                 $params['src'] = $loc->src;
                 $params['controller'] = $module;
                 $params['view'] = $view;
                 $params['moduletitle'] = $title;
                 if (empty($params['action'])) {
                     $params['action'] = $view;
                 }
                 renderAction($params);
             } else {
                 call_user_func(array($module, "show"), $view, $loc, $title);
             }
         } else {
             echo sprintf(gt('The module "%s" was not found in the system.'), $module);
         }
     }
 }
Exemplo n.º 21
0
#
# Exponent is free software; you can redistribute
# it and/or modify it under the terms of the GNU
# General Public License as published by the Free
# Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# GPL: http://www.gnu.org/licenses/gpl.txt
#
##################################################
if (!defined('EXPONENT')) {
    exit('');
}
global $router;
$container = $db->selectObject('container', 'id=' . intval($_REQUEST['id']));
//eDebug($container);
$module_loc = unserialize($container->internal);
$clipboard_object->module = $module_loc->mod;
$clipboard_object->source = $module_loc->src;
$clipboard_object->internal = $module_loc->int;
$clipboard_object->title = $container->title;
$clipboard_object->view = $container->view;
$clipboard_object->copied_from = $db->selectValue('section', 'name', 'id=' . expSession::get('last_section'));
$clipboard_object->section_id = expSession::get('last_section');
$clipboard_object->operation = $_REQUEST['op'];
$clipboard_object->description = $db->selectValue('sectionref', 'description', 'module="' . $clipboard_object->module . '" AND source="' . $clipboard_object->source . '"');
$clipboard_object->refcount = $db->selectValue('sectionref', 'refcount', 'module="' . $clipboard_object->module . '" AND source="' . $clipboard_object->source . '"');
//eDebug($clipboard_object);
$db->insertObject($clipboard_object, 'clipboard');
flash('message', gt('Module copied to clipboard'));
expHistory::back();
Exemplo n.º 22
0
 /**
  * @param $field
  */
 public static function setErrorField($field)
 {
     $errors = expSession::get('last_post_errors');
     if (!in_array($field, $errors)) {
         $errors[] = $field;
     }
     expSession::set('last_post_errors', $errors);
 }
Exemplo n.º 23
0
 /**
  * Hack to try and determine page which help doc is assoc with
  * @static
  * @param $params
  * @return null|void
  */
 public static function getSection($params)
 {
     global $db;
     $h = new help();
     $hv = $db->selectValue('help_version', 'id', 'version=' . $params['version']);
     $help = $h->find('first', 'help_version_id=' . $hv . ' and sef_url=\'' . $params['title'] . '\'');
     $sessec = expSession::get('last_section') ? expSession::get('last_section') : 1;
     $sid = $help->section != 0 ? $help->section : $sessec;
     if (!expSession::get('last_section')) {
         expSession::set('last_section', $sid);
     }
     $section = $db->selectObject('section', 'id=' . intval($sid));
     return $section;
 }
Exemplo n.º 24
0
 function toHTML($form_id, $module = "formbuilder")
 {
     // Form validation script
     if ($this->validationScript != "") {
         $this->scripts[] = $this->validationScript;
         $this->controls["submit"]->validateJS = "validate(this.form)";
     }
     // Persistent Form Data extension
     $formError = "";
     if (expSession::is_set("last_POST")) {
         // We have cached POST data.  Use it to update defaults.
         $last_POST = expSession::get("last_POST");
         foreach (array_keys($this->controls) as $name) {
             // may need to look to control a la parseData
             $this->controls[$name]->default = @$last_POST[$name];
         }
         $formError = @$last_POST['_formError'];
         //expSession::un_set("last_POST");
     }
     global $router;
     $html = "<!-- Form Object '" . $this->name . "' -->\r\n";
     $html .= "<script type=\"text/javascript\" src=\"" . PATH_RELATIVE . "framework/core/subsystems/forms/js/inputfilters.js.php\"></script>\r\n";
     foreach ($this->scripts as $name => $script) {
         $html .= "<script type=\"text/javascript\" src=\"{$script}\"></script>\r\n";
     }
     $html .= $formError;
     $html .= "<form name=\"" . $this->name . "\" method=\"" . $this->method . "\" action=\"" . $this->action . "\" enctype=\"" . $this->enctype . "\">\r\n";
     foreach ($this->meta as $name => $value) {
         $html .= "<input type=\"hidden\" name=\"{$name}\" id=\"{$name}\" value=\"{$value}\" />\r\n";
     }
     $rank = 0;
     $even = "odd";
     foreach ($this->controlIdx as $name) {
         $even = $even == "odd" ? "even" : "odd";
         $html .= "<div class=\"formmoduleedit " . $even . " control\">";
         $html .= "<div class=\"label\">" . $this->controlLbl[$name] . "</div>";
         $html .= "<div class=\"formmoduleeditactions\">";
         if ($rank != count($this->controlIdx) - 1) {
             //$html .= '<a href="?module='.$module.'&action=order_controls&p='.$form_id.'&a='.$rank.'&b='.($rank+1).'">';
             $html .= '<a href="' . $router->makeLink(array('module' => $module, 'action' => 'order_controls', 'p' => $form_id, 'a' => $rank, 'b' => $rank + 1)) . '">';
             $html .= "<img border='0' src='" . ICON_RELATIVE . "down.png' />";
             $html .= '</a>';
         } else {
             $html .= "<img src='" . ICON_RELATIVE . "down.disabled.png' />";
         }
         $html .= "&nbsp;";
         if ($rank != 0) {
             //$html .= '<a href="?module='.$module.'&action=order_controls&p='.$form_id.'&a='.$rank.'&b='.($rank-1).'">';
             $html .= '<a href="' . $router->makeLink(array('module' => $module, 'action' => 'order_controls', 'p' => $form_id, 'a' => $rank, 'b' => $rank - 1)) . '">';
             $html .= "<img border='0' src='" . ICON_RELATIVE . "up.png' />";
             $html .= '</a>';
         } else {
             $html .= "<img src='" . ICON_RELATIVE . "up.disabled.png' />";
         }
         $html .= "&nbsp;&nbsp;";
         if (!$this->controls[$name]->_readonly) {
             //$html .= '<a href="?module='.$module.'&action=edit_control&id='.$this->controls[$name]->_id.'&form_id='.$form_id.'">';
             $html .= '<a href="' . $router->makeLink(array('module' => $module, 'action' => 'edit_control', 'id' => $this->controls[$name]->_id, 'form_id' => $form_id)) . '">';
             $html .= '<img style="border:none;" src="' . ICON_RELATIVE . 'edit.png" />';
             $html .= '</a>';
         } else {
             $html .= '<img style="border:none;" src="' . ICON_RELATIVE . 'edit.disabled.png" />';
         }
         $html .= '&nbsp;';
         if (!$this->controls[$name]->_readonly && $this->controls[$name]->_controltype != 'htmlcontrol') {
             //$html .= '<a href="?module='.$module.'&action=delete_control&id='.$this->controls[$name]->_id.'" onclick="return confirm(\'Are you sure you want to delete this control? All data associated with it will be removed from the database!\');">';
             $html .= '<a href="' . $router->makeLink(array('module' => $module, 'action' => 'delete_control', 'id' => $this->controls[$name]->_id)) . '" onclick="return confirm(\'Are you sure you want to delete this control? All data associated with it will be removed from the database!\');">';
         } else {
             $html .= '<a href="' . $router->makeLink(array('module' => $module, 'action' => 'delete_control', 'id' => $this->controls[$name]->_id)) . '" onclick="return confirm(\'Are you sure you want to delete this?\');">';
         }
         $html .= '<img style="border:none;" src="' . ICON_RELATIVE . 'delete.png" />';
         $html .= '</a>';
         $html .= "</div>";
         $html .= $this->controls[$name]->controlToHTML($name, $this->controlLbl[$name]) . "\r\n";
         $html .= "</div>";
         $rank++;
     }
     //	$html .= "<tr><td width='5%'></td><td wdith='90%'><td></td width='5%'></tr>\r\n";
     //	$html .= "</table>\r\n";
     $html .= "</form>\r\n";
     return $html;
 }
Exemplo n.º 25
0
 static function getUserCart()
 {
     global $db, $user, $router;
     $sessAr = expSession::get('verify_shopper');
     // initialize this users cart if they have ecomm installed.
     $active = $db->selectValue('modstate', 'active', 'module="storeController"');
     if (!expModules::controllerExists('cart') || empty($active)) {
         // if ecomm is turned off, no cart.
         return null;
     } else {
         if (isset($router->params['controller']) && $router->params['controller'] == 'order' && ($router->params['action'] == 'verifyReturnShopper' || $router->params['action'] == 'verifyAndRestoreCart' || $router->params['action'] == 'clearCart') && (!isset($sessAr['validated']) || $sessAr['validated'] != true)) {
             return new order();
         } else {
             // if ecomm is turned off, no cart.
             //$active = ;
             if (empty($active)) {
                 return null;
             }
             $order = new order();
             //initialize a new order object to use the find function from.
             $ticket = expSession::getTicketString();
             //get this users session ticket. this is how we track anonymous users.
             // grab the origional referrer from the session table so that we can transfer it into the cart where it will be used for reporting purposes
             // sessions are temporary so we can't report on the referrer in the session table itsef because it may not be there
             // and we can't just get the referrer ar this point becaues the user likely navigated the site a bit and we want the origional referring site
             $orig_referrer = $db->selectValue('sessionticket', 'referrer', "`ticket`='" . $ticket . "'");
             //see if we have a LIVE and ACTIVE session w/ cart and grab it if so
             $sessioncart = $order->find('first', "invoice_id='' AND sessionticket_ticket='" . $ticket . "'");
             //check to see if the user is logged in, and if so grab their existing cart
             if (!empty($user) && $user->isLoggedIn()) {
                 $usercart = $order->find('first', "invoice_id='' AND user_id=" . $user->id);
             }
             //eDebug($sessioncart);
             //eDebug($usercart);
             //enter here if we have NO ACTIVE SESSION CART -OR- We're awaiting a potential cart retore
             if (empty($sessioncart->id) || $sessAr['awaiting_choice'] == true) {
                 if (empty($usercart->id)) {
                     // no SESSION cart was found and user is not logged in...
                     //let's see if they have a cart_id cookie set and we'll snag that if so
                     //they won't have any user data, since they are "logged in" once they get to
                     //checkout, so all we're really doing here is populating a cart for return
                     //shoppers
                     $cookie_cart_id = isset($_COOKIE['cid']) ? $_COOKIE['cid'] : 0;
                     //eDebug($cookie_cart_id,true);
                     if ($cookie_cart_id) {
                         $tmpCart = new order($cookie_cart_id);
                         if ($tmpCart->id != $cookie_cart_id) {
                             //cookie set, but we gots no cart in the DB so act as if we had no cookie
                             $cart = new order();
                             $cart->update(array("sessionticket_ticket" => $ticket, 'user_id' => $user->id, 'orig_referrer' => $orig_referrer, 'return_count' => $cart->setReturnCount($orig_referrer)));
                             order::setCartCookie($cart);
                         } else {
                             $u = new user($tmpCart->user_id);
                             //1) Was Not logged in
                             if (empty($tmpCart->user_id)) {
                                 $cart = new order($cookie_cart_id);
                                 //update the session ticket and return count
                                 $cart->update(array('sessionticket_ticket' => $ticket, 'return_count' => $cart->setReturnCount($orig_referrer)));
                                 order::setCartCookie($cart);
                                 flash('message', gt('Welcome back'));
                             } else {
                                 if (!empty($tmpCart->user_id)) {
                                     //check for is admin first
                                     if ($u->isActingAdmin() || $u->isAdmin()) {
                                         //no need to restore anything.
                                         $cart = new order();
                                         $cart->update(array("sessionticket_ticket" => $ticket, 'user_id' => $user->id, 'orig_referrer' => $orig_referrer));
                                         order::setCartCookie($cart);
                                     } else {
                                         if (!empty($tmpCart->user_id) && count($tmpCart->orderitem) == 0) {
                                             //silently copy tracking data from old order and continue on
                                             $cart = new order();
                                             $cart->update(array("sessionticket_ticket" => $ticket, 'user_id' => $user->id, 'orig_referrer' => $orig_referrer, 'return_count' => $tmpCart->setReturnCount($orig_referrer)));
                                             order::setCartCookie($cart);
                                             flash('message', gt('Welcome back'));
                                         } else {
                                             if (!empty($tmpCart->user_id) && count($tmpCart->orderitem) > 0) {
                                                 //3) Was Logged in w/ NON-?real user? account
                                                 //eDebug(expUtil::right($u->username,10),true);
                                                 if ($u->isTempUser()) {
                                                     if (isset($sessAr['validated']) && $sessAr['validated']) {
                                                         //already went through validation and we're good to go
                                                         $cart = new order($sessAr['cid']);
                                                         //update the session ticket and return count
                                                         $cart->update(array('sessionticket_ticket' => $ticket, 'return_count' => $cart->mergeReturnCount($sessioncart->return_count), 'orig_referrer' => $sessioncart->orig_referrer));
                                                         order::setCartCookie($cart);
                                                         expSession::un_set('verify_shopper');
                                                         $user = new user($cart->user_id);
                                                         expSession::login($user);
                                                         //Update the last login timestamp for this user.
                                                         $user->updateLastLogin();
                                                         flash('message', gt('Welcome back') . ' ' . $sessAr['firstname'] . '! ' . gt('Your shopping cart has been restored - you may continue shopping or') . ' <a href="' . makelink(array("controller" => "cart", "action" => "checkout")) . '">checkout</a> ' . gt('at your convenience.'));
                                                     } else {
                                                         //send to verification? If user has elected to restore their cart
                                                         //eDebug($_SESSION);
                                                         if (isset($sessAr['awaiting_choice']) && $sessAr['awaiting_choice'] == true) {
                                                             /*expSession::set('verify_shopper',array('au'=>1,'orig_path'=>$router->current_url, 'firstname'=>$u->firstname, 'cid'=>$cookie_cart_id));
                                                               redirect_to(array("controller"=>"order",'action'=>'verifyReturnShopper'));                                                                     
                                                               orderController::verifyReturnShopper();*/
                                                             //just give em the sessioncart
                                                             $cart = $sessioncart;
                                                             if (count($cart->orderitem) > 0) {
                                                                 //added items to current cart, so we'll assume they do not want to restore the previous at this point
                                                                 expSession::un_set('verify_shopper');
                                                                 order::setCartCookie($cart);
                                                             } else {
                                                                 flash('message', gt('Welcome back') . ' ' . $u->firstname . '! ' . gt('We see that you have shopped with us before.') . '<br><br><a id="submit-verify" href="' . makelink(array("controller" => "order", "action" => "verifyReturnShopper")) . '" rel="nofollow">' . gt('Click Here to Restore Your Previous Shopping Cart') . '</a><br><br><a class="exp-ecom-link" href="' . makelink(array("controller" => "order", "action" => "clearCart", "id" => $cookie_cart_id)) . '">' . gt('Click Here To Start a New Shopping Cart') . '</a>');
                                                                 $sessAr['orig_path'] = $router->current_url;
                                                                 expSession::set('verify_shopper', $sessAr);
                                                             }
                                                         } else {
                                                             //first time...create a default cart, issue message, set session, rinse, repeat
                                                             $cart = new order();
                                                             $cart->update(array("sessionticket_ticket" => $ticket, 'return_count' => $cart->setReturnCount($orig_referrer)));
                                                             expSession::set('verify_shopper', array('au' => 1, 'orig_path' => $router->current_url, 'firstname' => $u->firstname, 'cid' => $cookie_cart_id, 'awaiting_choice' => true));
                                                             //order::setCartCookie($cart);
                                                             flash('message', gt('Welcome back') . ' ' . $u->firstname . '! ' . gt('We see that you have shopped with us before.') . '<br><br><a id="submit-verify" href="' . makelink(array("controller" => "order", "action" => "verifyReturnShopper")) . '" rel="nofollow">' . gt('Click Here to Restore Your Previous Shopping Cart') . '</a><br><br><a class="exp-ecom-link" href="' . makelink(array("controller" => "order", "action" => "clearCart", "id" => $cookie_cart_id)) . '">' . gt('Click Here To Start a New Shopping Cart') . '</a>');
                                                         }
                                                     }
                                                 } else {
                                                     //prompt to login and restore, otherwise reset and start fresh
                                                     //this should be all we need to do here
                                                     //redirect_to(array("controller"=>"order",'action'=>'verifyReturnShopper','au'=>'0'));
                                                     $cart = new order();
                                                     $cart->update(array("sessionticket_ticket" => $ticket, 'user_id' => $user->id, 'orig_referrer' => $orig_referrer));
                                                     order::setCartCookie($cart);
                                                     flash('message', gt('Welcome back') . ' ' . $u->firstname . '! ' . gt('If you would like to pick up where you left off, click here to login and your previous shopping cart will be restored.'));
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     } else {
                         $cart = new order();
                         $cart->update(array("sessionticket_ticket" => $ticket, 'user_id' => $user->id, 'orig_referrer' => $orig_referrer));
                         order::setCartCookie($cart);
                     }
                 } else {
                     //user is logged in, so we grab their usercart and update the session ticket only
                     //$usercart->update(array('sessionticket_ticket'=>$ticket, 'orig_referrer'=>$orig_referrer));
                     $usercart->update(array('sessionticket_ticket' => $ticket));
                     $cart = $usercart;
                 }
                 //enter here if we HAVE an ACTIVE session/cart, but the user is not logged in
             } elseif (!empty($sessioncart->id) && $user->id == 0) {
                 // the user isn't logged in yet...the session cart will do for now.
                 $cart = $sessioncart;
                 // if we hit here we've found a session cart AND a usercart because the user just logged in
                 // and had both...that means we need to merge them
             } elseif (!empty($sessioncart->id) && !empty($usercart->id)) {
                 // if we hit here we've found a session cart and a usercart...that means we need to merge them
                 // if it's not the same cart.
                 if ($sessioncart->id == $usercart->id) {
                     $cart = $sessioncart;
                 } else {
                     // if the old user cart had gone through any of the checkout process before, than we
                     // will clean that data out now and start fresh.
                     $usercart->cleanOrderitems();
                     //merge the current session cart with previously saved user cart.
                     foreach ($sessioncart->orderitem as $orderitem) {
                         $orderitem->merge(array('orders_id' => $usercart->id, 'user_id' => $user->id));
                     }
                     //if session cart HAS coupon codes, delete usercart codes and copy new code to usercart, else leave be
                     if (count($sessioncart->getOrderDiscounts())) {
                         foreach ($usercart->getOrderDiscounts() as $od) {
                             $od->delete();
                         }
                         foreach ($sessioncart->getOrderDiscounts() as $sod) {
                             $sod->orders_id = $usercart->id;
                             $sod->save();
                         }
                     }
                     $cart = new order($usercart->id);
                     $sessioncart->delete();
                 }
                 order::setCartCookie($cart);
                 expSession::un_set('verify_shopper');
                 // the user doesn't have a cart with his/her user id in it. this probably means they just
                 // logged in so we need to update the cart with the new user id information.
             } elseif (!empty($sessioncart->id) && (empty($usercart->id) && $user->isLoggedIn())) {
                 //$sessioncart->update(array('user_id'=>$user->id, 'orig_referrer'=>$orig_referrer));
                 $sessioncart->update(array('user_id' => $user->id));
                 $cart = $sessioncart;
             }
             $cart->item_count = 0;
             foreach ($cart->orderitem as $items) {
                 if ($items->product->requiresShipping && !$items->product->no_shipping) {
                     $cart->shipping_required = true;
                 }
                 if ($items->product->requiresBilling) {
                     $cart->billing_required = true;
                 }
                 $cart->item_count += $items->quantity;
             }
             $cart->lastcat = expSession::get('last_ecomm_category');
             $cart->total = $cart->getCartTotal();
             //eDebug($cart,true);
             return $cart;
         }
     }
 }
Exemplo n.º 26
0
 public function update()
 {
     global $user, $db;
     // get the id of user we are editing, if there is one
     $id = empty($this->params['id']) ? null : $this->params['id'];
     if (($user->id == $id || $user->isAdmin()) && $this->params['userkey'] != expSession::get("userkey")) {
         expHistory::back();
     }
     // make sure this user should be updating user accounts
     if (!$user->isLoggedIn() && SITE_ALLOW_REGISTRATION == 0) {
         flash('error', gt('This site does not allow user registrations'));
         expHistory::back();
     } elseif (!$user->isAdmin() && ($user->isLoggedIn() && $user->id != $id)) {
         flash('error', gt('You do not have permission to edit this user account'));
         expHistory::back();
     }
     // if this is a new user account we need to check the password.
     // the password fields wont come thru on an edit. Otherwise we will
     // just update the existing account.
     if (!empty($id)) {
         $u = new user($id);
         $u->update($this->params);
         if ($user->isAdmin()) {
             flash('message', gt('Account information for') . ' ' . $u->username . ' ' . gt('has been updated.'));
         } else {
             flash('message', gt('Thank you') . ' ' . $u->firstname . '.  ' . gt('Your account information has been updated.'));
         }
     } else {
         $u = new user($this->params);
         $ret = $u->setPassword($this->params['pass1'], $this->params['pass2']);
         if ($ret != true) {
             expValidator::failAndReturnToForm($ret, $this->params);
         }
         $u->save();
         if ($user->isAdmin()) {
             flash('message', gt('Created new user account for') . ' ' . $u->username);
         } else {
             user::login($u->username, $this->params['pass1']);
             flash('message', gt('Thank you') . ' ' . $u->firstname . '.  ' . gt('Your new account has been created.'));
         }
     }
     // update the user profiles
     if (!empty($u->id)) {
         $this->params['user_id'] = $u->id;
         // get the active profile extensions and save them out
         $active_extensions = $db->selectObjects('profileextension', 'active=1');
         foreach ($active_extensions as $pe) {
             if (is_file(BASE . $pe->classfile)) {
                 include_once BASE . $pe->classfile;
                 $ext = new $pe->classname();
                 $db->delete($ext->tablename, 'user_id=' . $u->id);
                 $ext->update($this->params);
             }
         }
     }
     // if this is a new account then we will check to see if we need to send
     // a welcome message or admin notification of new accounts.
     if (empty($id)) {
         // Calculate Group Memeberships for newly created users.  Any groups that
         // are marked as 'inclusive' automatically pick up new users.  This is the part
         // of the code that goes out, finds those groups, and makes the new user a member
         // of them.
         $memb = null;
         $memb->member_id = $u->id;
         // Also need to process the groupcodes, for promotional signup
         $code_where = '';
         if (isset($this->params['groupcode']) && $this->params['groupcode'] != '') {
             $code_where = " OR code='" . $this->params['groupcode'] . "'";
         }
         foreach ($db->selectObjects('group', 'inclusive=1' . $code_where) as $g) {
             $memb->group_id = $g->id;
             $db->insertObject($memb, 'groupmembership');
         }
         // if we added the user to any group than we need to reload their permissions
         expPermissions::load($u);
         //signup email stuff
         if (USER_REGISTRATION_SEND_WELCOME) {
             $msg = $u->firstname . ", \n\n";
             $msg .= sprintf(USER_REGISTRATION_WELCOME_MSG, $u->firstname, $u->lastname, $u->username);
             $mail = new expMail();
             $mail->quickSend(array('text_message' => $msg, 'to' => trim($u->email), 'from' => SMTP_FROMADDRESS, 'subject' => USER_REGISTRATION_WELCOME_SUBJECT));
             flash('message', gt('A welcome email has been sent to') . ' ' . $u->email);
         }
         // send and email notification to the admin of the site.
         if (USER_REGISTRATION_SEND_NOTIF && !$user->isAdmin()) {
             $msg = "When: " . date("F j, Y, g:i a") . "\n\n";
             $msg .= "Their name is: " . $u->firstname . " " . $u->lastname . "\n\n";
             $mail = new expMail();
             $mail->quickSend(array('text_message' => $msg, 'to' => trim(USER_REGISTRATION_ADMIN_EMAIL), 'from' => SMTP_FROMADDRESS, 'subject' => USER_REGISTRATION_NOTIF_SUBJECT));
         }
     }
     expHistory::back();
 }
Exemplo n.º 27
0
    return expProcessBuffer($buffer);
}
ob_start('epb');
$microtime_str = explode(' ', microtime());
$i_start = $microtime_str[0] + $microtime_str[1];
$section = expSession::is_set('last_section') ? expSession::get('last_section') : SITE_DEFAULT_SECTION;
$section = $db->selectObject('section', 'id=' . $section);
// Handle sub themes
$page = $section && $section->subtheme != '' && is_readable('themes/' . DISPLAY_THEME . '/subthemes/' . $section->subtheme . '.php') ? 'themes/' . DISPLAY_THEME . '/subthemes/' . $section->subtheme . '.php' : 'themes/' . DISPLAY_THEME . '/index.php';
if (is_readable(BASE . $page)) {
    define('PREVIEW_READONLY', 1);
    // for mods
    define('SELECTOR', 1);
    $source_select = array();
    if (expSession::is_set('source_select')) {
        $source_select = expSession::get('source_select');
    }
    $count_orig = count($source_select);
    if (isset($_REQUEST['vview'])) {
        $source_select['view'] = $_REQUEST['vview'];
    } else {
        if (!isset($source_select['view'])) {
            $source_select['view'] = '_sourcePicker';
        }
    }
    if (isset($_REQUEST['vmod'])) {
        $source_select['module'] = $_REQUEST['vmod'];
    } else {
        if (!isset($source_select['module'])) {
            $source_select['module'] = 'containermodule';
        }
Exemplo n.º 28
0
if ($db->havedb) {
    $user = new user();
    expSession::validate();
}
/* exdoc
 * The flag to use a mobile theme variation.
 */
if (!defined('MOBILE')) {
    if (defined('FORCE_MOBILE') && FORCE_MOBILE && $user->isAdmin()) {
        define('MOBILE', true);
    } else {
        define('MOBILE', expTheme::is_mobile());
    }
}
// Initialize permissions variables
$exponent_permissions_r = expSession::get("permissions");
// initialize the expRouter
$router = new expRouter();
// Initialize the navigation hierarchy
if ($db->havedb) {
    $sections = expCore::initializeNavigation();
}
/**
 * dumps the passed variable to screen, but only if in development mode
 * @param  $var the variable to dump
 * @param bool $halt if set to true will halt execution
 * @return void
 */
function eDebug($var, $halt = false)
{
    if (DEVELOPMENT) {
Exemplo n.º 29
0
 public function process()
 {
     global $db, $order, $user;
     //eDebug($order,true);
     if (!$user->isLoggedIn() && empty($this->params['nologin'])) {
         flash('message', gt("It appears that your session has expired. Please log in to continue the checkout process."));
         expHistory::back();
         //expHistory::redirecto_login(makeLink(array('module'=>'cart','action'=>'checkout'), 'secure'));
     }
     // if this error hits then something went horribly wrong or the user has tried to hit this
     // action themselves before the cart was ready or is refreshing the page after they've confirmed the
     // order.
     if (empty($order->orderitem)) {
         flash('error', gt('There are no items in your cart.'));
     }
     if (!expQueue::isQueueEmpty('error')) {
         redirect_to(array('controller' => 'store', 'action' => 'showall'));
     }
     // set the gift comments
     $order->update($this->params);
     // get the biling & shipping info
     $shipping = new shipping();
     $billing = new billing();
     // finalize the total to bill
     $order->calculateGrandTotal();
     //eDebug($order,true);
     $invNum = $order->getInvoiceNumber();
     // call the billing calculators process method - this will handle saving the billing options to the database.
     $result = $billing->calculator->process($billing->billingmethod, expSession::get('billing_options'), $this->params, $invNum);
     if (empty($result->errorCode)) {
         // if ($result->errorCode === "0" || $result->errorCode === 0)
         // {
         // save out the cart total to the database
         $billing->billingmethod->update(array('billing_cost' => $order->grand_total));
         // set the invoice number and purchase date in the order table..this finializes the order
         //$invoice_num = $db->max('orders', 'invoice_id') + 1;
         //if ($invoice_num < ecomconfig::getConfig('starting_invoice_number')) $invoice_num += ecomconfig::getConfig('starting_invoice_number');
         // get the first order status and set it for this order
         $order->update(array('invoice_id' => $invNum, 'purchased' => time(), 'updated' => time(), 'comment' => serialize($comment)));
         //$order->setDefaultStatus(); --FJD?
         //$order->setDefaultOrderType(); --FJD?
         $order->refresh();
         // run each items process callback function
         foreach ($order->orderitem as $item) {
             $product = new $item->product_type($item->product_id);
             $product->process($item, $order->order_type->affects_inventory);
         }
         $billing->calculator->postProcess($order, $this->params);
         orderController::clearCartCookie();
     } else {
         flash('error', gt('An error was encountered while processing your transaction.') . '<br /><br />' . $result->message);
         expHistory::back();
         //redirect_to(array('controller'=>'cart', 'action'=>'checkout'));
     }
     $billinginfo = $billing->calculator->userView(unserialize($billing->billingmethod->billing_options));
     if (!DEVELOPMENT) {
         // send email invoices to the admins & users if needed
         if ($order->order_type->emails_customer) {
             $invoice = renderAction(array('controller' => 'order', 'action' => 'email', 'id' => $order->id));
         }
     } else {
         flash('message', gt('Development on, skipping email sending.'));
     }
     //assign_to_template(array('order'=>$order, 'billing'=>$billing, 'shipping'=>$shipping, 'result'=>$result, 'billinginfo'=>$billinginfo));
     flash('message', gt('Your order has been submitted.'));
     redirect_to(array('controller' => 'order', 'action' => 'myOrder', 'id' => $order->id, 'tc' => 1));
 }
Exemplo n.º 30
0
# Exponent is free software; you can redistribute
# it and/or modify it under the terms of the GNU
# General Public License as published by the Free
# Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# GPL: http://www.gnu.org/licenses/gpl.txt
#
##################################################
if (!defined('EXPONENT')) {
    exit('');
}
global $user;
/////////////////////////////////////////////////////////////////////////
// FIGURE OUT IF WE"RE IN PREVIEW MODE OR NOT
/////////////////////////////////////////////////////////////////////////
$level = 99;
if (expSession::is_set('uilevel')) {
    $level = expSession::get('uilevel');
}
//if ($level == UILEVEL_PREVIEW) {
//    $preview_url = makeLink(array('module'=>'previewmodule','action'=>'normal'));
//    $preview_class = 'preview_on';
//} else {
//    $preview_url = makeLink(array('module'=>'previewmodule','action'=>'preview'));
//    $preview_class = 'preview_off';
//}
/////////////////////////////////////////////////////////////////////////
// BUILD THE MENU
/////////////////////////////////////////////////////////////////////////
return array('text' => $user->firstname . ' ' . $user->lastname, 'classname' => 'quicklink user', 'submenu' => array('id' => 'user', 'itemdata' => array(array('text' => gt("Edit My Profile"), 'url' => makeLink(array('controller' => 'users', 'action' => 'edituser', 'id' => $user->id)), 'classname' => 'edit'), array('text' => gt("Change My Password"), 'url' => makeLink(array('controller' => 'users', 'action' => 'change_password', 'ud' => $user->id)), 'classname' => 'password'), array('text' => gt("Log Out"), 'url' => makeLink(array('controller' => 'login', 'action' => 'logout')), 'classname' => 'logout'), array('text' => gt('Preview Mode'), 'text' => $level == UILEVEL_PREVIEW ? gt('Turn Preview Mode off') : gt('Turn Preview Mode on'), 'classname' => $level == UILEVEL_PREVIEW ? 'preview_on' : 'preview_off', 'url' => makeLink(array('controller' => 'administration', 'action' => 'toggle_preview'))))));