Exemplo n.º 1
0
 public function cartSummary($item)
 {
     $view = new controllertemplate($this, $this->getForm('cartSummary'));
     $view->assign('product', $this);
     $view->assign('item', $item);
     // grab all the registrants
     $message = expUnserialize($item->extra_data);
     $view->assign('message', $message);
     return $view->render('cartSummary');
 }
Exemplo n.º 2
0
 function __construct($params = null)
 {
     global $db;
     $this->location_data = serialize($params);
     parent::__construct($db->selectValue($this->table, 'id', "location_data='" . $this->location_data . "'"));
     // treat the loc data like an id - if the location data come thru as an objec we need to look up the record
     //         if (!empty($params->src)) {
     //             echo "1";
     //             // if we hav a src, ie this controller has sources
     // parent::__construct($db->selectValue($this->table, 'id', "location_data='".$this->location_data."'"));
     //         } else {
     //             echo "2";
     //             // if we don't have a sourced controller, migh still have a config for it.
     // parent::__construct($db->selectValue($this->table, 'id'));
     //}
     $this->config = expUnserialize($this->config);
 }
 public function export()
 {
     //ob_end_clean();
     $event = new eventregistration($this->params['id']);
     $out = '"Registrant Name","Registrant Email","Registrant Phone"' . "\n";
     foreach (expUnserialize($event->registrants) as $r) {
         $out .= '"' . $r['name'] . '","' . $r['email'] . '","' . $r['phone'] . '"' . "\n";
     }
     // Open file export.csv.
     $fp = BASE . 'tmp/';
     $fn = str_replace(' ', '_', $event->title) . '.csv';
     $f = fopen($fp . $fn, 'w');
     // Put all values from $out to export.csv.
     fputs($f, $out);
     fclose($f);
     $mimetype = 'application/octet-stream;';
     header('Content-Type: ' . $mimetype);
     header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
     header('Content-Transfer-Encoding: binary');
     header('Content-Encoding:');
     header('Content-Disposition: attachment; filename="' . $fn . '";');
     // IE need specific headers
     if (EXPONENT_USER_BROWSER == 'IE') {
         header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
         header('Pragma: public');
         header('Vary: User-Agent');
     } else {
         header('Pragma: no-cache');
     }
     readfile($fp . $fn);
     exit;
 }
Exemplo n.º 4
0
 function upgrade()
 {
     global $db;
     // copy each locationref entry to the sectionref
     $srs = $db->selectObjects('sectionref', "module = 'headlineController'");
     foreach ($srs as $sr) {
         $sr->module = 'textController';
         $db->updateObject($sr, 'sectionref');
     }
     $lrs = $db->selectObjects('locationref', "module = 'headlineController'");
     foreach ($lrs as $lr) {
         $lr->module = 'textController';
         $db->updateObject($lr, 'locationref');
     }
     $gps = $db->selectObjects('grouppermission', "module = 'headlineController'");
     foreach ($gps as $gp) {
         $gp->module = 'textController';
         $db->updateObject($gp, 'grouppermission');
     }
     $ups = $db->selectObjects('userpermission', "module = 'headlineController'");
     foreach ($ups as $up) {
         $up->module = 'textController';
         $db->updateObject($up, 'userpermission');
     }
     // convert each headline module to a text module
     $modules_converted = 0;
     $cns = $db->selectObjects('container', "internal LIKE '%headlineController%'");
     foreach ($cns as $cn) {
         $cloc = expUnserialize($cn->internal);
         $cloc->mod = 'textController';
         $cn->internal = serialize($cloc);
         $cn->view = 'showall';
         $cn->action = 'showall';
         $db->updateObject($cn, 'container');
         $modules_converted += 1;
     }
     // create a text item for each headline item
     $headlines_converted = 0;
     $headlines = $db->selectObjects('headline', "1");
     foreach ($headlines as $hl) {
         $text = new text();
         $loc = expUnserialize($hl->location_data);
         $loc->mod = "text";
         $text->location_data = serialize($loc);
         $text->title = $hl->title;
         $text->poster = $hl->poster;
         $text->save();
         $text->created_at = $hl->created_at;
         $text->edited_at = $hl->edited_at;
         $text->update();
         $headlines_converted += 1;
     }
     // FIXME - remove when final
     return "TEST - We're NOT removing the locationref table nor the files yet...<br>" . $modules_converted . " Headline modules were converted.<br>" . $headlines_converted . " Headlines were converted.<br>";
     // delete headline table
     $db->dropTable('locationref');
     // check if the headline controller files are there and remove them
     $files = array(BASE . "framework/modules/definitions/headline.php", BASE . "framework/modules/models/headline.php", BASE . "framework/modules/headline/");
     // delete the files.
     $removed = 0;
     $errors = 0;
     foreach ($files as $file) {
         if (expUtil::isReallyWritable($file)) {
             unlink($file);
             $removed += 1;
         } else {
             $errors += 1;
         }
     }
     return $modules_converted . " Headline modules were converted.<br>" . $headlines_converted . " Headlines were converted.<br>" . $removed . " files were deleted.<br>" . $errors . " files could not be removed.";
 }
Exemplo n.º 5
0
 function addToCart($params)
 {
     global $db, $order;
     if (isset($params['registrants'])) {
         // save the order item
         for ($x = 0; $x < count($params['registrants']); $x++) {
             $ed[$x]['name'] = $params['registrants'][$x];
             $ed[$x]['email'] = $params['registrant_emails'][$x];
             $ed[$x]['phone'] = $params['registrant_phones'][$x];
         }
         // if the item is in the cart already use it, if not we'll create a new one
         $item = $order->isItemInCart($params['product_id'], $params['product_type']);
         if (empty($item->id)) {
             $item = new orderitem($params);
         }
         // if we already have this event in our cart then we need to merge the registrants
         $registrants = array();
         if (!empty($item->extra_data)) {
             $registrants = expUnserialize($item->extra_data);
         }
         $registrants = array_merge($registrants, $ed);
         $item->quantity = count($registrants);
         $item->extra_data = serialize($registrants);
         $item->save();
         return true;
     } else {
         return false;
     }
 }
Exemplo n.º 6
0
 private function mergeReturnCount($merge_array = array())
 {
     if ($this->return_count != "") {
         $retArray = expUnserialize($this->return_count);
     } else {
         $retArray = array();
     }
     if (!is_array($merge_array)) {
         $merge_array = expUnserialize($merge_array);
     }
     if (count($merge_array)) {
         foreach ($merge_array as $retCount) {
             $retArray[] = $retCount;
         }
     }
     return serialize($retArray);
 }
Exemplo n.º 7
0
 function getPaymentMethod($billingmethod)
 {
     $ret = expUnserialize($billingmethod->billing_options);
     return $ret->cc_type;
 }
Exemplo n.º 8
0
 function getPaymentStatus($billingmethod)
 {
     $ret = expUnserialize($billingmethod->billing_options);
     return $ret->result->payment_status;
 }
Exemplo n.º 9
0
 public function __construct($params = array())
 {
     parent::__construct($params);
     $this->loc = expUnserialize($this->location_data);
 }
 public function fix_database()
 {
     global $db;
     print_r("<h1>" . gt("Attempting to Fix the Exponent Database") . "</h1>");
     print_r("<h3>" . gt("Some Error Conditions can NOT be repaired by this Procedure") . "!</h3><br>");
     print_r("<pre>");
     // upgrade sectionref's that have lost their originals
     print_r("<b>" . gt("Searching for sectionrefs that have lost their originals") . "</b><br><br>");
     $sectionrefs = $db->selectObjects('sectionref', "is_original=0");
     if (count($sectionrefs)) {
         print_r(gt("Found") . ": " . count($sectionrefs) . " " . gt("copies (not originals)") . "<br>");
     } else {
         print_r(gt("None Found: Good") . "!<br>");
     }
     foreach ($sectionrefs as $sectionref) {
         if ($db->selectObject('sectionref', "module='" . $sectionref->module . "' AND source='" . $sectionref->source . "' AND is_original='1'") == null) {
             // There is no original for this sectionref so change it to the original
             $sectionref->is_original = 1;
             $db->updateObject($sectionref, "sectionref");
             print_r(gt("Fixed") . ": " . $sectionref->module . " - " . $sectionref->source . "<br>");
         }
     }
     print_r("</pre>");
     print_r("<pre>");
     // upgrade sectionref's that point to missing sections (pages)
     print_r("<b>" . gt("Searching for sectionrefs pointing to missing sections/pages") . " <br>" . gt("to fix for the Recycle Bin") . "</b><br><br>");
     $sectionrefs = $db->selectObjects('sectionref', "refcount!=0");
     $found = 0;
     foreach ($sectionrefs as $sectionref) {
         if ($db->selectObject('section', "id='" . $sectionref->section . "'") == null) {
             // There is no section/page for sectionref so change the refcount
             $sectionref->refcount = 0;
             $db->updateObject($sectionref, "sectionref");
             print_r(gt("Fixed") . ": " . $sectionref->module . " - " . $sectionref->source . "<br>");
             $found += 1;
         }
     }
     if (!$found) {
         print_r(gt("None Found: Good") . "!<br>");
     }
     print_r("</pre>");
     print_r("<pre>");
     // delete sectionref's that have empty sources since they are dead
     print_r("<b>" . gt("Searching for unassigned modules (no source)") . "</b><br><br>");
     $sectionrefs = $db->selectObjects('sectionref', 'source=""');
     if ($sectionrefs != null) {
         print_r(gt("Removing") . ": " . count($sectionrefs) . " " . gt("empty sectionrefs (no source)") . "<br>");
         $db->delete('sectionref', 'source=""');
     } else {
         print_r(gt("No Empties Found: Good") . "!<br>");
     }
     print_r("<pre>");
     // add missing sectionrefs based on existing containers (fixes aggregation problem)
     print_r("<b>" . gt("Searching for missing sectionrefs based on existing containers") . "</b><br><br>");
     $containers = $db->selectObjects('container', 1);
     foreach ($containers as $container) {
         $iloc = expUnserialize($container->internal);
         if ($db->selectObject('sectionref', "module='" . $iloc->mod . "' AND source='" . $iloc->src . "'") == null) {
             // There is no sectionref for this container.  Populate sectionref
             $newSecRef = null;
             $newSecRef->module = $iloc->mod;
             $newSecRef->source = $iloc->src;
             $newSecRef->internal = '';
             $newSecRef->refcount = 1;
             $newSecRef->is_original = 1;
             if ($container->external != "N;") {
                 $eloc = expUnserialize($container->external);
                 $section = $db->selectObject('sectionref', "module='containermodule' AND source='" . $eloc->src . "'");
                 if (!empty($section)) {
                     $newSecRef->section = $section->id;
                     $db->insertObject($newSecRef, "sectionref");
                     print_r(gt("Missing sectionref for container replaced") . ": " . $iloc->mod . " - " . $iloc->src . " - PageID #" . $section->id . "<br>");
                 } else {
                     print_r(gt("Cant' find the container page for container") . ": " . $iloc->mod . " - " . $iloc->src . "<br>");
                 }
             }
         }
     }
     print_r("</pre>");
 }
Exemplo n.º 11
0
/**
 * Smarty {icon} function plugin
 *
 * Type:     function<br>
 * Name:     icon<br>
 * Purpose:  create an icon type link
 *
 * @param         $params
 * @param \Smarty $smarty
 * @return bool
 */
function smarty_function_icon($params, &$smarty)
{
    $loc = $smarty->getTemplateVars('__loc');
    if (isset($params['record'])) {
        $record = $params['record'];
        $params['id'] = $record->id;
    }
    if ($record && empty($params['id'])) {
        $params['id'] = $record->id;
    }
    // setup the link params
    if (!isset($params['controller'])) {
        if (!isset($params['module'])) {
            $params['module'] = $loc->mod;
        }
        if (expModules::controllerExists($params['module'])) {
            $params['controller'] = expModules::getControllerName($params['module']);
            unset($params['module']);
        }
    }
    // guess the src if it is not set
    if (!isset($params['src'])) {
        if ($record) {
            $modloc = expUnserialize($record->location_data);
            $params['src'] = $modloc->src;
        } else {
            if (!empty($params['controller']) || @call_user_func(array($loc->mod, 'hasSources'))) {
                $params['src'] = $loc->src;
            }
        }
    }
    if (!is_object($smarty->getTemplateVars('config')) && !empty($smarty->getTemplateVars('config')->noeditagg) && $smarty->getTemplateVars('__loc')->src != $params['src']) {
        return;
    }
    if (!isset($params['int'])) {
        $params['int'] = $loc->int;
    }
    // attempt to translate the alt, text, & title
    if (!empty($params['alt'])) {
        $params['alt'] = gt($params['alt']);
    }
    if (!empty($params['text'])) {
        $params['text'] = gt($params['text']);
    }
    if (!empty($params['title'])) {
        $params['title'] = gt($params['title']);
    }
    // figure out whether to use the edit icon or text, alt tags, etc.
    $alt = empty($params['alt']) ? '' : $params['alt'];
    $class = empty($params['class']) && empty($params['img']) ? $params['action'] : $params['class'];
    $text = empty($params['text']) ? '' : $params['text'];
    $title = empty($params['title']) ? empty($text) ? ucfirst($class) . ' ' . gt('this') . ' ' . $smarty->getTemplateVars('modelname') . ' ' . gt('item') : $text : $params['title'];
    if (!empty($params['hash'])) {
        $hash = $params['hash'];
        unset($params['hash']);
    }
    if (empty($params['img']) && empty($params['text'])) {
        $img = gt(ucfirst($class));
    } else {
        if (!empty($params['img'])) {
            $img = '<img src="' . ICON_RELATIVE . $params['img'] . '" title="' . $title . '" alt="' . $alt . '"' . XHTML_CLOSING . '>';
        }
    }
    $linktext = $img . $text;
    // we need to unset these vars before we pass the params array off to makeLink
    unset($params['alt']);
    unset($params['title']);
    unset($params['text']);
    unset($params['img']);
    unset($params['class']);
    unset($params['record']);
    unset($params['record']);
    $onclick = $params['onclick'];
    unset($params['onclick']);
    //eDebug($params);
    if (!empty($params['action'])) {
        echo '<a href="' . expCore::makeLink($params) . '" title="' . $title . '" class="' . $class . '"';
        if ($params['action'] == "delete" && empty($onclick)) {
            echo ' onclick="return confirm(\'' . gt('Are you sure you want to delete this') . ' ' . $smarty->getTemplateVars('modelname') . ' ' . gt('item') . '?\');"';
        }
        if (!empty($onclick)) {
            echo ' onclick="' . $onclick . '"';
        }
        echo '>' . $linktext . '</a>';
    } else {
        echo $linktext;
    }
}
Exemplo n.º 12
0
 function getCVVMatched($billingmethod)
 {
     $ret = expUnserialize($billingmethod->billing_options);
     return $ret->result->CVV2MATCH;
 }
Exemplo n.º 13
0
 public function getFormattedExtraData($style = 'list')
 {
     $ret = '';
     if ($style == 'list') {
         $ret = '<ul>';
         foreach (expUnserialize($this->extra_data) as $key => $item) {
             $ret .= "<li>{$key} : {$item}</li>";
         }
         $ret .= '<ul>';
     }
     return $ret;
 }
Exemplo n.º 14
0
 function showOptions($bm)
 {
     return expUnserialize($bm);
 }
Exemplo n.º 15
0
 function export_user_input_report()
 {
     global $order;
     $out = '"ITEM_NAME","QUANTITY","PERSONALIZATION"' . chr(13) . chr(10);
     //eDebug($this->params,true);
     $order_ids = array();
     if (isset($this->params['applytoall']) && $this->params['applytoall'] == 1) {
         $obs = expSession::get('order_export_values');
         foreach ($obs as $ob) {
             $order_ids[] = $ob->id;
         }
     } else {
         foreach ($this->params['act-upon'] as $order_id) {
             $order_ids[] = $order_id;
         }
     }
     $order_ids = array_unique($order_ids);
     $orders_string = implode(',', $order_ids);
     $orders = $order->find('all', 'id IN (' . $orders_string . ')');
     //eDebug($orders,true);
     $pattern = '/\\(.*\\)/i';
     $items = array();
     $top = array();
     foreach ($orders as $order) {
         //eDebug($order,true);
         foreach ($order->orderitem as $oi) {
             // eDebug($oi,true);
             $item = array();
             if ($oi->user_input_fields == '' || $oi->user_input_fields == 'a:0:{}') {
                 continue;
             } else {
                 $item['user_input_data'] = expUnserialize($oi->user_input_fields);
             }
             $model = preg_replace($pattern, '', preg_replace('/\\s/', '', $oi->products_model));
             $item['model'] = $model;
             //$item['name'] = strip_tags($oi->products_name);
             $item['qty'] = $oi->quantity;
             $items[] = $item;
         }
     }
     unset($item);
     foreach ($items as $item) {
         $line = '';
         //$line = $this->outputField("SMC Inventory - Laurie");
         $line .= $this->outputField($item['model']);
         //$line.= $this->outputField($item['name']);
         $line .= $this->outputField($item['qty']);
         $ui = array();
         $uiInfo = '';
         foreach ($item['user_input_data'] as $tlArray) {
             foreach ($tlArray as $ifKey => $if) {
                 $uiInfo .= $ifKey . '=' . $if . " | ";
             }
         }
         $line .= $this->outputField(strtoupper(substr_replace($uiInfo, '', strrpos($uiInfo, ' |'), strlen(' |'))), '');
         $line .= chr(13) . chr(10);
         $out .= $line;
     }
     //eDebug($out,true);
     $this->download($out, 'Inventory_Export_' . time() . '.csv', 'application/csv');
     // [firstname] => Fred [middlename] => J [lastname] => Dirkse [organization] => OIC Group, Inc. [address1] => PO Box 1111 [address2] => [city] => Peoria [state] => 23 [zip] => 61653 [country] => [phone] => 309-555-1212 begin_of_the_skype_highlighting              309-555-1212      end_of_the_skype_highlighting  [email] => fred@oicgroup.net [shippingcalculator_id] => 4 [option] => 01 [option_title] => 8-10 Day [shipping_cost] => 5.95
 }
Exemplo n.º 16
0
 function validateDiscount()
 {
     global $order, $user;
     $retMessage = "";
     if (!$this->isAvailable()) {
         return gt("This discount code you entered is currently unavailable.");
     }
     //check discounts rules
     //.5 isExpired
     //1. uses per coupon
     //2. uses per customer
     //4. check group requirements
     //-1 = 'ALL LOGGED IN USERS'
     //-2 => 'ALL NON-LOGGED IN USERS'
     $required_groups = expUnserialize($this->group_ids);
     if (count($required_groups)) {
         $users_groups = $user->getGroupMemberships();
         if ($user->isLoggedIn()) {
             $loggedInGroup->id = "-2";
             $users_groups[] = $loggedInGroup;
         }
         $inARequiredGroup = false;
         foreach ($users_groups as $ug) {
             if (in_array($ug->id, $required_groups)) {
                 $inARequiredGroup = true;
             }
         }
         //eDebug($required_groups);
         //eDebug($users_groups);
         if (!$inARequiredGroup) {
             return gt("This discount is not available to your user group.");
         }
     }
     //5. check minimum order amount
     if ($order->subtotal < $this->minimum_order_amount) {
         $retMessage = gt("You must purchase a minimum of") . " \$" . $this->minimum_order_amount . " " . gt("to use this coupon code.");
     }
     //check rules of products in cart
     //FJD TODO: not yet implemeneted
     return $retMessage;
 }
Exemplo n.º 17
0
 function edit_order_item()
 {
     $oi = new orderitem($this->params['id'], true, true);
     //oi->options = expUnserialize($oi->options);
     $oi->user_input_fields = expUnserialize($oi->user_input_fields);
     $oi->product = new product($oi->product->id, true, true);
     if ($oi->product->parent_id != 0) {
         $parProd = new product($oi->product->parent_id);
         //$oi->product->optiongroup = $parProd->optiongroup;
         $oi->product = $parProd;
     }
     $oi->selectedOpts = array();
     if (!empty($oi->opts)) {
         foreach ($oi->opts as $opt) {
             $option = new option($opt[0]);
             $og = new optiongroup($option->optiongroup_id);
             if (!is_array($oi->selectedOpts[$og->id])) {
                 $oi->selectedOpts[$og->id] = array($option->id);
             } else {
                 array_push($oi->selectedOpts[$og->id], $option->id);
             }
         }
     }
     //eDebug($oi->selectedOpts);
     assign_to_template(array('oi' => $oi));
 }
Exemplo n.º 18
0
 public function show()
 {
     global $template;
     expHistory::set('viewable', $this->params);
     $id = isset($this->params['title']) ? $this->params['title'] : $this->params['id'];
     $blog = new blog($id);
     // since we are probably getting here via a router mapped url
     // some of the links (tags in particular) require a source, we will
     // populate the location data in the template now.
     $loc = expUnserialize($blog->location_data);
     assign_to_template(array('__loc' => $loc, 'record' => $blog));
 }
Exemplo n.º 19
0
 /** exdoc
  * Checks to see if the given group has been given a specific permission on a location.
  * Returns true if the permission is granted, false if it is not.
  *
  * @param Group $group The group to check
  * @param string $permission The name of the permission to check
  * @param Object $location The location to check on.
  * @param bool $explicitOnly
  *
  * @return bool
  *
  * @node Subsystems:expPermissions
  */
 public static function checkGroup($group, $permission, $location, $explicitOnly = false)
 {
     global $db, $module_scope;
     if ($group == null) {
         return false;
     }
     // check for explicit group permission
     $explicit = $db->selectObject("grouppermission", "gid=" . $group->id . " AND module='" . $location->mod . "' AND source='" . $location->src . "' AND internal='" . $location->int . "' AND permission='{$permission}'");
     if ($explicitOnly || $explicit) {
         return !empty($explicit);
     }
     // exit recursive calls for globally scoped modules
     $module_scope['error'] = false;
     if (!empty($module_scope[$location->src][$location->mod]->scope)) {
         // is this the main container?
         $rLoc = $db->selectObject("sectionref", "source='" . $location->src . "' AND module='" . $location->mod . "'");
         if (!empty($rLoc) && $rLoc->refcount == 1000 && $module_scope[$location->src][$location->mod]->scope == 'global') {
             $module_scope['error'] = true;
             return false;
         }
     }
     // check for inherited container permission
     $perms = array();
     $perms[] = $permission;
     // account for old-style container perms
     $perms[] = 'administrate';
     if ($permission == 'post' || $permission == 'create') {
         $perms[] = 'add_module';
     } elseif ($permission == 'edit') {
         $perms[] = 'add_module';
         $perms[] = 'edit_module';
     } elseif ($permission == 'delete') {
         $perms[] = 'delete_module';
     } elseif ($permission == 'configure') {
         $perms[] = 'order_modules';
     }
     foreach ($perms as $perm) {
         $tmpLoc->mod = $location->mod;
         $tmpLoc->src = $location->src;
         $tmpLoc->int = $location->int;
         $tmpLoc->mod = !strpos($tmpLoc->mod, "Controller") && !strpos($tmpLoc->mod, "module") ? $tmpLoc->mod . "Controller" : $tmpLoc->mod;
         $cLoc = expUnserialize($db->selectValue('container', 'external', 'internal=\'' . serialize($tmpLoc) . '\''));
         if (!empty($cLoc) && $db->selectObject("grouppermission", "gid=" . $group->id . " AND module='" . $cLoc->mod . "' AND source='" . $cLoc->src . "' AND internal='" . $cLoc->int . "' AND permission='{$perm}'")) {
             return true;
         }
         if (!empty($cLoc)) {
             if (self::checkGroup($group, $perm, $cLoc)) {
                 return true;
             }
         }
     }
     if (@$module_scope['error'] == true) {
         $module_scope['error'] = false;
         return false;
     }
     // if this is the global sidebar, then exit since we don't care about page permissions
     $module_scope['error'] = false;
     if (!empty($module_scope[$location->src][$location->mod]->scope)) {
         // is this the main container?
         $rLoc = $db->selectObject("sectionref", "source='" . $location->src . "' AND module='" . $location->mod . "'");
         if (!empty($rLoc) && $rLoc->refcount == 1000 && @$module_scope[$location->src][$location->mod]->scope == 'global') {
             $module_scope['error'] = true;
             return false;
         }
     }
     // check for inherited 'manage' permission from its page
     if ($location->mod != 'navigationmodule') {
         $tmpLoc->mod = $location->mod;
         $tmpLoc->src = $location->src;
         $tmpLoc->int = $location->int;
         $tmpLoc->mod = !strpos($tmpLoc->mod, "Controller") && !strpos($tmpLoc->mod, "module") ? $tmpLoc->mod . "Controller" : $tmpLoc->mod;
         foreach ($db->selectObjects('sectionref', "is_original=1 AND module='" . $tmpLoc->mod . "' AND source='" . $tmpLoc->src . "'") as $secref) {
             if (self::checkGroup($group, 'manage', expCore::makeLocation('navigationmodule', '', $secref->section))) {
                 return true;
             }
         }
     } else {
         // check for recursive inherited page permission
         $page = $db->selectObject("section", "id=" . $location->int);
         if (!empty($page->parent)) {
             // first check for specific 'view' permission
             if (self::checkGroup($group, $permission, expCore::makeLocation('navigationmodule', '', $page->parent))) {
                 return true;
             }
             // otherwise check for 'super' permission
             if (self::checkGroup($group, 'manage', expCore::makeLocation('navigationmodule', '', $page->parent))) {
                 return true;
             }
         }
     }
     return false;
 }
Exemplo n.º 20
0
 function edit()
 {
     global $db;
     //Make sure that the view is the edit.tpl and not any ajax views
     if (isset($this->params['view']) && $this->params['view'] == 'edit') {
         expHistory::set('editable', $this->params);
     }
     // first we need to figure out what type of ecomm product we are dealing with
     if (!empty($this->params['id'])) {
         // if we have an id lets pull the product type from the products table.
         $product_type = $db->selectValue('product', 'product_type', 'id=' . $this->params['id']);
     } else {
         if (empty($this->params['product_type'])) {
             redirect_to(array('controller' => 'store', 'action' => 'picktype'));
         }
         $product_type = $this->params['product_type'];
     }
     if (!empty($this->params['id'])) {
         $record = new $product_type($this->params['id']);
         if (!empty($this->user_input_fields) && !is_array($record->user_input_fields)) {
             $record->user_input_fields = expUnserialize($record->user_input_fields);
         }
     } else {
         $record = new $product_type();
         $record->user_input_fields = array();
     }
     //        if (!empty($this->params['parent_id']))
     // get the product options and send them to the form
     $editable_options = array();
     //$og = new optiongroup();
     $mastergroups = $db->selectExpObjects('optiongroup_master', null, 'optiongroup_master');
     //eDebug($mastergroups,true);
     foreach ($mastergroups as $mastergroup) {
         // if this optiongroup_master has already been made into an option group for this product
         // then we will grab that record now..if not, we will make a new one.
         $grouprec = $db->selectArray('optiongroup', 'optiongroup_master_id=' . $mastergroup->id . ' AND product_id=' . $record->id);
         //if ($mastergroup->id == 9) eDebug($grouprec,true);
         //eDebug($grouprec);
         if (empty($grouprec)) {
             $grouprec['optiongroup_master_id'] = $mastergroup->id;
             $grouprec['title'] = $mastergroup->title;
             $group = new optiongroup($grouprec);
         } else {
             $group = new optiongroup($grouprec['id']);
         }
         $editable_options[$group->title] = $group;
         if (empty($group->option)) {
             foreach ($mastergroup->option_master as $optionmaster) {
                 $opt = new option(array('title' => $optionmaster->title, 'option_master_id' => $optionmaster->id), false, false);
                 $editable_options[$group->title]->options[] = $opt;
             }
         } else {
             if (count($group->option) == count($mastergroup->option_master)) {
                 $editable_options[$group->title]->options = $group->option;
             } else {
                 // check for any new options or deleted since the last time we edited this product
                 foreach ($mastergroup->option_master as $optionmaster) {
                     $opt_id = $db->selectValue('option', 'id', 'option_master_id=' . $optionmaster->id . " AND product_id=" . $record->id);
                     if (empty($opt_id)) {
                         $opt = new option(array('title' => $optionmaster->title, 'option_master_id' => $optionmaster->id), false, false);
                     } else {
                         $opt = new option($opt_id);
                     }
                     $editable_options[$group->title]->options[] = $opt;
                 }
             }
         }
         //eDebug($editable_options[$group->title]);
     }
     //die();
     uasort($editable_options, array("optiongroup", "sortOptiongroups"));
     // get the shipping options and their methods
     $shipping = new shipping();
     foreach ($shipping->available_calculators as $calcid => $name) {
         $calc = new $name($calcid);
         $shipping_services[$calcid] = $calc->title;
         $shipping_methods[$calcid] = $calc->availableMethods();
     }
     #        eDebug($shipping_services);
     #        eDebug($shipping_methods);
     if ($this->params['product_type'] == "product" || $this->params['product_type'] == "childProduct") {
         //if new record and it's a child, then well set the child rank to be at the end
         if (empty($record->id) && $record->isChild()) {
             $record->child_rank = $db->max('product', 'child_rank', null, 'parent_id=' . $record->parent_id) + 1;
         }
         //eDebug($record,true);
     }
     $view = '';
     $parent = null;
     if (isset($this->params['parent_id']) && empty($record->id)) {
         //NEW child product
         $view = 'edit';
         $parent = new $product_type($this->params['parent_id'], false, true);
         $record->parent_id = $this->params['parent_id'];
     } elseif (!empty($record->id) && $record->parent_id != 0) {
         //EDIT child product
         $view = 'edit';
         $parent = new $product_type($record->parent_id, false, true);
     } else {
         $view = 'edit';
     }
     assign_to_template(array('record' => $record, 'parent' => $parent, 'form' => $record->getForm($view), 'optiongroups' => $editable_options, 'shipping_services' => isset($shipping_services) ? $shipping_services : '', 'shipping_methods' => isset($shipping_methods) ? $shipping_methods : '', 'product_types' => isset($this->config['product_types']) ? $this->config['product_types'] : ''));
 }
Exemplo n.º 21
0
 /**
  * module customized function to circumvent going to previous page
  * @return void
  */
 function saveconfig()
 {
     // unset some unneeded params
     unset($this->params['module']);
     unset($this->params['controller']);
     unset($this->params['src']);
     unset($this->params['int']);
     unset($this->params['id']);
     unset($this->params['action']);
     unset($this->params['PHPSESSID']);
     // setup and save the config
     $config = new expConfig($this->loc);
     $config->update(array('config' => $this->params));
     // update our object config
     $this->config = expUnserialize($config->config);
     //        flash('message', 'Migration Configuration Saved');
     //        expHistory::back();
     if (isset($this->params['fix_database'])) {
         $this->fix_database();
     }
     echo '<h2>' . gt('Migration Configuration Saved') . '</h2><br />';
     echo '<p>' . gt('We\'ve successfully connected to the Old database') . '</p><br />';
     echo "<a class=\"awesome " . BTN_SIZE . " " . BTN_COLOR . "\" href=\"" . expCore::makeLink(array('controller' => 'migration', 'action' => 'manage_users')) . "\">" . gt('Next Step -> Migrate Users & Groups') . "</a>";
 }
Exemplo n.º 22
0
 public function edit_discount()
 {
     $id = empty($this->params['id']) ? null : $this->params['id'];
     $discount = new discounts($id);
     //grab all user groups
     $group = new group();
     //create two 'default' groups:
     $groups = array(-1 => 'ALL LOGGED IN USERS', -2 => 'ALL NON-LOGGED IN USERS');
     //loop our groups and append them to the array
     // foreach ($group->find() as $g){
     //this is a workaround for older code. Use the previous line if possible:
     $allGroups = group::getAllGroups();
     if (count($allGroups)) {
         foreach ($allGroups as $g) {
             $groups[$g->id] = $g->name;
         }
     }
     //find our selected groups for this discount already
     // eDebug($discount);
     $selected_groups = array();
     if (!empty($discount->group_ids)) {
         $selected_groups = expUnserialize($discount->group_ids);
     }
     if ($discount->minimum_order_amount == "") {
         $discount->minimum_order_amount = 0;
     }
     if ($discount->discount_amount == "") {
         $discount->discount_amount = 0;
     }
     if ($discount->discount_percent == "") {
         $discount->discount_percent = 0;
     }
     // get the shipping options and their methods
     $shipping = new shipping();
     foreach ($shipping->available_calculators as $calcid => $name) {
         $calc = new $name($calcid);
         $shipping_services[$calcid] = $calc->title;
         $shipping_methods[$calcid] = $calc->availableMethods();
     }
     assign_to_template(array('discount' => $discount, 'groups' => $groups, 'selected_groups' => $selected_groups, 'shipping_services' => $shipping_services, 'shipping_methods' => $shipping_methods));
 }
Exemplo n.º 23
0
 private function sendApprovalNotification($comment, $params)
 {
     if (empty($comment)) {
         return false;
     }
     /* The global constants can be overriden by passing appropriate params */
     //sure wish I could do this once in the constructor. sadly $this->params[] isn't set yet
     $require_login = empty($this->params['require_login']) ? COMMENTS_REQUIRE_LOGIN : $this->params['require_login'];
     $require_approval = empty($this->params['require_approval']) ? COMMENTS_REQUIRE_APPROVAL : $this->params['require_approval'];
     $require_notification = empty($this->params['require_notification']) ? COMMENTS_REQUIRE_NOTIFICATION : $this->params['require_notification'];
     $notification_email = empty($this->params['notification_email']) ? COMMENTS_NOTIFICATION_EMAIL : $this->params['notification_email'];
     // setup some email variables.
     $subject = gt('Notification of Comment Approval on') . ' ' . URL_BASE;
     $tos = explode(',', str_replace(' ', '', $notification_email));
     $tos[] = $comment->email;
     $tos = array_filter($tos);
     if (empty($tos)) {
         return false;
     }
     $model = new $params['content_type']($params['content_id']);
     $loc = expUnserialize($model->location_data);
     $posting = makelink(array('controller' => $params['content_type'], 'action' => 'show', 'id' => $params['content_id'], "src" => $loc->src));
     $editlink = makelink(array('controller' => 'expComment', 'action' => 'edit', 'id' => $comment->id));
     // make the email body
     $body = '<h1>' . gt('Comment Approved') . '</h1>';
     $body .= '<h2>' . gt('Posted By') . '</h2>';
     $body .= '<p>' . $comment->name . "</p>";
     $body .= '<h2>' . gt('Poster\'s Email') . '</h2>';
     $body .= '<p>' . $comment->email . '</p>';
     $body .= '<h2>' . gt('Comment') . '</h2>';
     $body .= '<p>' . $comment->body . "</p>";
     $body .= '<h3>' . gt('View posting') . '</h3>';
     $body .= '<a href="' . $posting . '">' . $posting . '</a>';
     // create the mail message
     $mail = new expMail();
     $mail->quickSend(array('html_message' => $body, 'to' => $tos, 'from' => array(trim(SMTP_FROMADDRESS) => trim(ORGANIZATION_NAME)), 'subject' => $subject));
     return true;
 }
Exemplo n.º 24
0
 /**
  * add all module items to search index
  * @return int
  */
 function addContentToSearch()
 {
     global $db, $router;
     $count = 0;
     $model = new $this->basemodel_name(null, false, false);
     $content = $db->selectArrays($model->tablename);
     foreach ($content as $cnt) {
         $origid = $cnt['id'];
         unset($cnt['id']);
         // get the location data for this content
         if (isset($cnt['location_data'])) {
             $loc = expUnserialize($cnt['location_data']);
         }
         $src = isset($loc->src) ? $loc->src : null;
         //build the search record and save it.
         $search_record = new search($cnt, false, false);
         $search_record->original_id = $origid;
         $search_record->posted = empty($cnt['created_at']) ? null : $cnt['created_at'];
         $link = str_replace(URL_FULL, '', makeLink(array('controller' => $this->baseclassname, 'action' => 'show', 'id' => $origid, 'src' => $src)));
         //	        if (empty($search_record->title)) $search_record->title = 'Untitled';
         $search_record->view_link = $link;
         $search_record->ref_module = $this->classname;
         $search_record->category = $this->searchName();
         $search_record->ref_type = $this->searchCategory();
         $search_record->save();
         $count += 1;
     }
     return $count;
 }
Exemplo n.º 25
0
 public function cartSummary($item)
 {
     $viewname = $this->getForm('cartSummary');
     if (!$viewname) {
         return null;
     }
     $options = expUnserialize($item->options);
     $view = new controllertemplate($this, $viewname);
     $view->assign('product', $this);
     $view->assign('item', $item);
     $view->assign('options', $options);
     return $view->render('cartSummary');
 }