/** * utility function to pass individual item links to a caller * * @param $args['itemids'] array of item ids to get * @return array Array containing the itemlink(s) for the item(s). */ function publications_userapi_getitemlinks($args) { $itemlinks = array(); sys::import('xaraya.structures.query'); $xartable = xarDB::getTables(); $q = new Query('SELECT', $xartable['publications']); $q->addfield('id'); $q->addfield('title'); $q->addfield('description'); $q->addfield('pubtype_id'); $q->in('state', array(3, 4)); if (!empty($args['itemids'])) { $itemids = explode(',', $args['itemids']); $q->in('id', $itemids); } $q->addorder('title'); $q->run(); $result = $q->output(); if (empty($result)) { return $itemlinks; } foreach ($result as $item) { if (empty($item['title'])) { $item['title'] = xarML('Display Publication'); } $itemlinks[$item['id']] = array('url' => xarModURL('publications', 'user', 'display', array('id' => $item['id'])), 'title' => $item['title'], 'label' => $item['description']); } return $itemlinks; }
/** * Get products */ function shop_userapi_getproducts($args) { $startnum = 1; extract($args); if (!xarSecurityCheck('ViewShop')) { return; } if (!isset($items_per_page)) { $items_per_page = xarModVars::get('shop', 'items_per_page'); } $data['items_per_page'] = $items_per_page; // Load the DD master object class. This line will likely disappear in future versions sys::import('modules.dynamicdata.class.objects.master'); sys::import('modules.dynamicdata.class.properties.master'); // Get the object we'll be working with. Note this is a so called object list $mylist = DataObjectMaster::getObjectList(array('name' => 'shop_products')); $data['sort'] = xarMod::ApiFunc('shop', 'admin', 'sort', array('sortfield_fallback' => 'id', 'ascdesc_fallback' => 'ASC')); // We have some filters for the items $filters = array('startnum' => $startnum, 'status' => DataPropertyMaster::DD_DISPLAYSTATE_ACTIVE, 'sort' => $data['sort']); if (isset($where)) { $filters['where'] = $where; } // Get the items $products = $mylist->getItems($filters); // return the products $data['products'] = $products; // Return the template variables defined in this function return $data; }
/** * View the cart */ function shop_user_viewcart() { // If the user returns to the cart after taking other steps, unset any errors from earlier in the session. xarSession::delVar('errors'); sys::import('modules.dynamicdata.class.objects.master'); $subtotals = array(); $products = array(); $total = 0; // May want to display cust info with the cart... $cust = xarMod::APIFunc('shop', 'user', 'customerinfo'); $data['cust'] = $cust; $shop = xarSession::getVar('shop'); foreach ($shop as $pid => $val) { // If this post variable is set, we must need to update the quantity if (isset($_POST['qty' . $pid])) { unset($qty_new); // Have to unset this since we're in a foreach if (!xarVarFetch('qty' . $pid, 'isset', $qty_new, NULL, XARVAR_DONT_SET)) { return; } if ($qty_new == 0) { unset($shop[$pid]); } else { $shop[$pid]['qty'] = $qty_new; } } // If the quantity hasn't been set to zero, add it to the $products array... if (isset($shop[$pid])) { // Commas in the quantity seem to mess up our math $products[$pid]['qty'] = str_replace(',', '', $shop[$pid]['qty']); // Get the product info $object = DataObjectMaster::getObject(array('name' => 'shop_products')); $some_id = $object->getItem(array('itemid' => $pid)); $values = $object->getFieldValues(); $products[$pid]['title'] = xarVarPrepForDisplay($values['title']); $products[$pid]['price'] = $values['price']; $subtotal = $values['price'] * $products[$pid]['qty']; $subtotals[] = $subtotal; // so we can use array_sum() to add it all up if (substr($subtotal, 0, 1) == '.') { $subtotal = '0' . $subtotal; } $products[$pid]['subtotal'] = number_format($subtotal, 2); } } xarSession::setVar('shop', $shop); $total = array_sum($subtotals); // Add a zero to the front of the number if it starts with a decimal... if (substr($total, 0, 1) == '.') { $total = '0' . $total; } $total = number_format($total, 2); xarSession::setVar('products', $products); // update the session variable $data['products'] = $products; // don't want too much session stuff in the templates xarSession::setVar('total', $total); $data['total'] = $total; return $data; }
/** * Publications Module * * @package modules * @subpackage publications module * @category Third Party Xaraya Module * @version 2.0.0 * @copyright (C) 2011 Netspan AG * @license GPL {@link http://www.gnu.org/licenses/gpl.html} * @author Marc Lutolf <*****@*****.**> */ function publications_adminapi_delete($args) { // Get arguments from argument array extract($args); // Argument check if (!isset($itemid)) { $msg = xarML('Invalid #(1) for #(2) function #(3)() in module #(4)', 'publication ID', 'admin', 'delete', 'Publications'); throw new BadParameterException(null, $msg); } $ids = !is_array($itemid) ? explode(',', $itemid) : $itemid; if (!isset($deletetype)) { $deletetype = 0; } sys::import('xaraya.structures.query'); $table = xarDB::getTables(); switch ($deletetype) { case 0: default: $q = new Query('UPDATE', $table['publications']); $q->addfield('state', 0); break; case 10: $q = new Query('DELETE', $table['publications']); break; } $q->in('id', $ids); if (!$q->run()) { return false; } return true; }
/** * Initialize WURFL * */ function wurfl_init($args = array()) { if (!isset($args['mode'])) { $args['mode'] = 'performance'; } sys::import('modules.wurfl.xarincludes.WURFL.Application'); $resourcesDir = sys::code() . 'modules/wurfl/xarincludes/resources'; $persistenceDir = $resourcesDir . '/storage/persistence'; $cacheDir = $resourcesDir . '/storage/cache'; // Create WURFL Configuration $wurflConfig = new WURFL_Configuration_InMemoryConfig(); // Set location of the WURFL File $wurflConfig->wurflFile($resourcesDir . '/wurfl.xml'); // Set the match mode for the API ('performance' or 'accuracy') $wurflConfig->matchMode($args['mode']); // Setup WURFL Persistence $wurflConfig->persistence('file', array('dir' => $persistenceDir)); // Setup Caching $wurflConfig->cache('file', array('dir' => $cacheDir, 'expiration' => 36000)); // Create a WURFL Manager Factory from the WURFL Configuration $wurflManagerFactory = new WURFL_WURFLManagerFactory($wurflConfig); // Create a WURFL Manager /* @var $wurflManager WURFL_WURFLManager */ $wurflManager = $wurflManagerFactory->create(); return $wurflManager; }
function calendar_userapi_getUserDateTimeInfo() { // dates come in as YYYYMMDD xarVarFetch('cal_date', 'str:4:8', $cal_date, xarLocaleFormatDate('%Y%m%d')); $data = array(); $data['cal_date'] =& $cal_date; if (!preg_match('/([\\d]{4,4})([\\d]{2,2})?([\\d]{2,2})?/', $cal_date, $match)) { $year = xarLocaleFormateDate('Y'); $month = xarLocaleFormateDate('m'); $day = xarLocaleFormateDate('d'); } else { $year = $match[1]; if (isset($match[2])) { $month = $match[2]; } else { $month = '01'; } if (isset($match[3])) { $day = $match[3]; } else { $day = '01'; } } //$data['selected_date'] = (int) $year.$month.$day; $data['cal_day'] = (int) $day; $data['cal_month'] = (int) $month; $data['cal_year'] = (int) $year; //$data['selected_timestamp'] = gmmktime(0,0,0,$month,$day,$year); sys::import('xaraya.structures.datetime'); $today = new XarDateTime(); $usertz = xarModUserVars::get('roles', 'usertimezone', xarSession::getVar('role_id')); $useroffset = $today->getTZOffset($usertz); $data['now'] = getdate(time() + $useroffset); return $data; }
/** * Publications Module * * @package modules * @subpackage publications module * @category Third Party Xaraya Module * @version 2.0.0 * @copyright (C) 2011 Netspan AG * @license GPL {@link http://www.gnu.org/licenses/gpl.html} * @author Marc Lutolf <*****@*****.**> */ function publications_user_view_pages($args) { extract($args); if (!xarSecurityCheck('ManagePublications')) { return; } // Accept a parameter to allow selection of a single tree. xarVarFetch('contains', 'id', $contains, 0, XARVAR_NOT_REQUIRED); $data = xarMod::apiFunc('publications', 'user', 'getpagestree', array('key' => 'index', 'dd_flag' => false, 'tree_contains_pid' => $contains)); if (empty($data['pages'])) { // TODO: pass to template. return $data; //xarML('NO PAGES DEFINED'); } else { $data['pages'] = xarMod::apiFunc('publications', 'tree', 'array_maptree', $data['pages']); } $data['contains'] = $contains; // Check modify and delete privileges on each page. // EditPage - allows basic changes, but no moving or renaming (good for sub-editors who manage content) // AddPage - new pages can be added (further checks may limit it to certain page types) // DeletePage - page can be renamed, moved and deleted if (!empty($data['pages'])) { // Bring in the access property for security checks sys::import('modules.dynamicdata.class.properties.master'); $accessproperty = DataPropertyMaster::getProperty(array('name' => 'access')); $accessproperty->module = 'publications'; $accessproperty->component = 'Page'; foreach ($data['pages'] as $key => $page) { $thisinstance = $page['name'] . ':' . $page['ptid']['name']; // Do we have admin access? $args = array('instance' => $thisinstance, 'level' => 800); $adminaccess = $accessproperty->check($args); // Decide whether this page can be modified by the current user /*try { $args = array( 'instance' => $thisinstance, 'group' => $page['access']['modify_access']['group'], 'level' => $page['access']['modify_access']['level'], ); } catch (Exception $e) { $args = array(); }*/ $data['pages'][$key]['edit_allowed'] = $adminaccess || $accessproperty->check($args); /* // Decide whether this page can be deleted by the current user try { $args = array( 'instance' => $thisinstance, 'group' => $page['access']['delete_access']['group'], 'level' => $page['access']['delete_access']['level'], ); } catch (Exception $e) { $args = array(); }*/ $data['pages'][$key]['delete_allowed'] = $adminaccess || $accessproperty->check($args); } } return $data; }
/** * Modify a customer */ function shop_admin_modifycustomer() { if (!xarVarFetch('itemid', 'id', $data['itemid'], NULL, XARVAR_DONT_SET)) { return; } if (!xarVarFetch('confirm', 'bool', $data['confirm'], false, XARVAR_NOT_REQUIRED)) { return; } $objectname = 'shop_customers'; $data['objectname'] = $objectname; // Check if we still have no id of the item to modify. if (empty($data['itemid'])) { $msg = xarML('Invalid #(1) for #(2) function #(3)() in module #(4)', 'item id', 'admin', 'modify', 'shop'); throw new Exception($msg); } if (!xarSecurityCheck('AdminShop', 1, 'Item', $data['itemid'])) { return; } sys::import('modules.dynamicdata.class.objects.master'); $object = DataObjectMaster::getObject(array('name' => $objectname)); $data['object'] = $object; $data['label'] = $object->label; $object->getItem(array('itemid' => $data['itemid'])); $values = $object->getFieldValues(); foreach ($values as $name => $value) { $data[$name] = xarVarPrepForDisplay($value); } $rolesobject = DataObjectMaster::getObject(array('name' => 'roles_users')); $rolesobject->getItem(array('itemid' => $data['itemid'])); if ($data['confirm']) { // Check for a valid confirmation key if (!xarSecConfirmAuthKey()) { return xarTplModule('privileges', 'user', 'errors', array('layout' => 'bad_author')); } // Get the data from the form $isvalid = $object->checkInput(); if (!$isvalid) { // Bad data: redisplay the form with the data we picked up and with error messages return xarTplModule('shop', 'admin', 'modifycustomer', $data); } elseif (isset($data['preview'])) { // Show a preview, same thing as the above essentially return xarTplModule('shop', 'admin', 'modifycustomer', $data); } else { $first_name = $object->properties['first_name']->getValue(); $last_name = $object->properties['last_name']->getValue(); $rolesobject->properties['name']->setValue($first_name . ' ' . $last_name); $rolesobject->updateItem(); $object->updateItem(); // Jump to the next page xarResponse::redirect(xarModURL('shop', 'admin', 'modifycustomer', array('itemid' => $data['itemid']))); return $data; } } else { // Get that specific item of the object $object->getItem(array('itemid' => $data['itemid'])); } // Return the template variables defined in this function return $data; }
/** * Create a new customer */ function shop_user_newcustomer() { if (!xarVarFetch('objectid', 'id', $data['objectid'], NULL, XARVAR_DONT_SET)) { return; } if (!xarVarFetch('returnurl', 'str', $returnurl, NULL, XARVAR_NOT_REQUIRED)) { return; } sys::import('modules.dynamicdata.class.objects.master'); $rolesobject = DataObjectMaster::getObject(array('name' => 'roles_users')); $data['properties'] = $rolesobject->properties; // Check if we are in 'preview' mode from the input here - the rest is handled by checkInput() // Here we are testing for a button clicked, so we test for a string if (!xarVarFetch('preview', 'str', $data['preview'], NULL, XARVAR_DONT_SET)) { return; } // Check if we are submitting the form // Here we are testing for a hidden field we define as true on the template, so we can use a boolean (true/false) if (!xarVarFetch('confirm', 'bool', $data['confirm'], false, XARVAR_NOT_REQUIRED)) { return; } if ($data['confirm']) { // Check for a valid confirmation key. The value is automatically gotten from the template if (!xarSecConfirmAuthKey()) { return xarTplModule('privileges', 'user', 'errors', array('layout' => 'bad_author')); } // Get the data from the form and see if it is all valid // Either way the values are now stored in the object $isvalid = $rolesobject->properties['email']->checkInput(); $isvalid2 = $rolesobject->properties['password']->checkInput(); if (!$isvalid || !$isvalid2) { // Bad data: redisplay the form with the data we picked up and with error messages return xarTplModule('shop', 'user', 'newcustomer', $data); } else { $email = $rolesobject->properties['email']->getValue(); $password = $rolesobject->properties['password']->getValue(); $rolesobject->properties['name']->setValue($email); $rolesobject->properties['email']->setValue($email); $rolesobject->properties['uname']->setValue($email); $rolesobject->properties['password']->setValue($password); $rolesobject->properties['state']->setValue(3); $authmodule = (int) xarMod::getID('shop'); $rolesobject->properties['authmodule']->setValue($authmodule); $uid = $rolesobject->createItem(); $custobject = DataObjectMaster::getObject(array('name' => 'shop_customers')); $custobject->createItem(array('id' => $uid)); if (isset($returnurl)) { xarMod::APIFunc('authsystem', 'user', 'login', array('uname' => $email, 'pass' => $password)); xarResponse::redirect($returnurl); } else { xarResponse::redirect(xarModURL('shop')); } // Always add the next line even if processing never reaches it return true; } } // Return the template variables defined in this function return $data; }
/** * Factory method that allows the creation of new objects * @version $Id: factory.php,v 1.5 2003/06/24 21:30:30 roger Exp $ * @param string $class the name of the object to create * @return object the created object */ function &calendar_userapi_factory($class) { static $calobject; static $icalobject; static $eventobject; static $importobject; static $exportobject; static $alarmobject; static $modinfo; if (!isset($modinfo)) { $modInfo =& xarMod::getInfo(xarMod::getRegID('calendar')); } switch (strtolower($class)) { case 'calendar': if (!isset($calobject)) { sys::import("modules.{$modInfo['osdirectory']}.class.calendar"); $calobject =& new Calendar(); } return $calobject; break; case 'ical_parser': if (!isset($icalobject)) { sys::import("modules.{$modInfo['osdirectory']}.class.ical_parser"); $icalobject =& new iCal_Parser(); } return $icalobject; break; case 'event': if (!isset($eventobject)) { sys::import("modules.{$modInfo['osdirectory']}.class.event"); $eventobject =& new Event(); } return $eventobject; break; /* case 'import': break; case 'export': break; case 'alarm': break; */ /* case 'import': break; case 'export': break; case 'alarm': break; */ default: return; break; } }
public static function loadJPGraph() { // load jpgraph function sys::import('jpgraph.src.jpgraph'); sys::import('jpgraph.src.jpgraph_bar'); sys::import('jpgraph.src.jpgraph_flags'); sys::import('jpgraph.src.jpgraph_pie'); sys::import('jpgraph.src.jpgraph_line'); }
/** * List the product attributes */ function shop_admin_attributes() { if (!xarVarFetch('startnum', 'isset', $data['startnum'], NULL, XARVAR_DONT_SET)) { return; } if (!xarVarFetch('user_id', 'isset', $user_id, NULL, XARVAR_DONT_SET)) { return; } $objectname = 'shop_attributes'; $data['objectname'] = $objectname; // Security check - important to do this as early as possible to avoid // potential security holes or just too much wasted processing if (!xarSecurityCheck('AdminShop')) { return; } $data['items_per_page'] = xarModVars::get('shop', 'items_per_page'); // Load the DD master object class. This line will likely disappear in future versions sys::import('modules.dynamicdata.class.objects.master'); // Get the object label for the template $object = DataObjectMaster::getObject(array('name' => $objectname)); $data['label'] = $object->label; // Get the fields to display in the admin interface $config = $object->configuration; if (!empty($config['adminfields'])) { $data['adminfields'] = $config['adminfields']; } else { $data['adminfields'] = array_keys($object->getProperties()); } // Get the object we'll be working with. Note this is a so called object list $mylist = DataObjectMaster::getObjectList(array('name' => $objectname)); // Load the DD master property class. This line will likely disappear in future versions sys::import('modules.dynamicdata.class.properties.master'); $data['sort'] = xarMod::ApiFunc('shop', 'admin', 'sort', array('sortfield_fallback' => 'ID', 'ascdesc_fallback' => 'ASC')); // We have some filters for the items $filters = array('startnum' => $data['startnum'], 'status' => DataPropertyMaster::DD_DISPLAYSTATE_ACTIVE, 'sort' => $data['sort']); if (isset($user_id)) { $filters['where'] = 'user_id eq ' . $user_id; } // Get the items $items = $mylist->getItems($filters); if (isset($user_id)) { // Get the object we'll be working with. Note this is a so called object list $mylist2 = DataObjectMaster::getObjectList(array('name' => 'shop_customers')); $filters = array(); if (isset($user_id)) { $filters['where'] = 'ID eq ' . $user_id; } $items2 = $mylist2->getItems($filters); $data['fname'] = $items2[$user_id]['FirstName']; $data['lname'] = $items2[$user_id]['LastName']; } $data['mylist'] = $mylist; // Return the template variables defined in this function return $data; }
function ws_proccess($search, $getParams, $controller, $postParams, $jsonItems, $start, $limit) { $GLOBALS["Webi_PageTime"] = microtime(true); include 'lib/bootstrap.php'; /* Load Webi Core */ sys::import('webi.core'); wbCore::init(); $_GET['jsonItems'] = $jsonItems; if (!empty($getParams)) { $getParams =& wbUtil::jsonDecode($getParams); } else { $getParams = array(); } if (json_decode($postParams) > 0) { $postParams = json_decode($postParams); } else { $postParams = array(); } $controller =& wbUtil::jsonDecode($controller); $type = $controller['type']; if (!empty($getParams)) { foreach ($getParams as $key => $value) { $_GET[$key] = $value; } } if (!empty($postParams)) { foreach ($postParams as $key => $value) { $_POST[$key] = $value; } } $_GET['module'] = $controller['module']; $_GET['class'] = $controller['class']; $_GET['method'] = $controller['method']; list($module, $class, $method) = wbRequest::getController(); $callback = wbRequest::getVarClean('callback'); if (!wbModule::isAvailable($module, $class, $type)) { header("HTTP/1.1 400 Bad Request"); return; } try { $result = wbModule::call($module, $class, $method, array(), $type); } catch (Exception $e) { $result = array('items' => array(), 'total' => 0, 'success' => false, 'message' => $e->getMessage()); } $return = array(); $return['success'] = $result['success']; $return['message'] = $result['message']; $return['total'] = (int) $result['total']; $return['data'] = $result['items']; $return['current'] = (int) $result['current']; $return['rowCount'] = (int) $result['rowCount']; $return = base64_encode(serialize($return)); return $return; }
/** * Show some predefined form field in a template * * @param $args array containing the definition of the field (object, itemid, property, value, ...) * @return string containing the HTML (or other) text to output in the BL template */ function publications_userapi_fieldoutput($args) { extract($args); if (!isset($object) || !isset($itemid) || !isset($field)) { return ''; } sys::import('modules.dynamicdata.class.objects.master'); $object = DataObjectMaster::getObject(array('name' => $object)); $itemid = xarMod::apiFunc('publications', 'user', 'gettranslationid', array('id' => $itemid)); $object->getItem(array('itemid' => $itemid)); $field = $object->properties[$field]->getValue(); return $field; }
/** * Create a new product */ function shop_admin_newproduct() { // See if the current user has the privilege to add an item. We cannot pass any extra arguments here if (!xarSecurityCheck('Addshop')) { return; } if (!xarVarFetch('objectid', 'id', $data['objectid'], NULL, XARVAR_DONT_SET)) { return; } $objectname = 'shop_products'; $data['objectname'] = $objectname; // Load the DD master object class. This line will likely disappear in future versions sys::import('modules.dynamicdata.class.objects.master'); $object = DataObjectMaster::getObject(array('name' => $objectname)); $data['label'] = $object->label; $data['object'] = $object; // Check if we are in 'preview' mode from the input here - the rest is handled by checkInput() // Here we are testing for a button clicked, so we test for a string if (!xarVarFetch('preview', 'str', $data['preview'], NULL, XARVAR_DONT_SET)) { return; } // Check if we are submitting the form // Here we are testing for a hidden field we define as true on the template, so we can use a boolean (true/false) if (!xarVarFetch('confirm', 'bool', $data['confirm'], false, XARVAR_NOT_REQUIRED)) { return; } if ($data['confirm']) { // Check for a valid confirmation key. The value is automatically gotten from the template if (!xarSecConfirmAuthKey()) { return xarTplModule('privileges', 'user', 'errors', array('layout' => 'bad_author')); } // Get the data from the form and see if it is all valid // Either way the values are now stored in the object $isvalid = $data['object']->checkInput(); if (!$isvalid) { // Bad data: redisplay the form with the data we picked up and with error messages return xarTplModule('shop', 'admin', 'newproduct', $data); } elseif (isset($data['preview'])) { // Show a preview, same thing as the above essentially return xarTplModule('shop', 'admin', 'newproduct', $data); } else { $itemid = $data['object']->createItem(); // Jump to the next page xarResponse::redirect(xarModURL('shop', 'admin', 'products')); return true; } } // Return the template variables defined in this function return $data; }
function display(array $data = array()) { $data = parent::display($data); if (!defined('CALENDAR_ROOT')) { define('CALENDAR_ROOT', xarModVars::get('calendar', 'pearcalendar_root')); } include_once CALENDAR_ROOT . 'Month/Weekdays.php'; include_once CALENDAR_ROOT . 'Decorator/Textual.php'; sys::import("modules.calendar.class.Calendar.Decorator.Xaraya"); // Build the month $data['content'] = xarMod::apiFunc('calendar', 'user', 'getuserdatetimeinfo'); $data['content']['MonthCal'] = new Calendar_Month_Weekdays($data['content']['cal_year'], $data['content']['cal_month'], CALENDAR_FIRST_DAY_OF_WEEK); $data['content']['MonthCal']->build(); return $data; }
/** * Get all product attributes */ function shop_adminapi_getattributes() { $objectname = 'shop_attributes'; sys::import('modules.dynamicdata.class.objects.master'); // Get the object we'll be working with. Note this is a so called object list $mylist = DataObjectMaster::getObjectList(array('name' => $objectname)); // We have some filters for the items $filters = array('status' => DataPropertyMaster::DD_DISPLAYSTATE_ACTIVE); // Get the items $items = $mylist->getItems($filters); foreach ($items as $item) { $id = $item['id']; $array[$id] = $item['name'] . ' (ID: ' . $item['id'] . ')'; } return $array; }
public static function loadModel($module, $class) { $className = self::getRealClassName($class); if (class_exists($className)) { return $className; } try { sys::import(self::MODULES_DIR . '.' . $module . '.' . self::MODELS_DIR . '.' . $class); } catch (Exception $e) { throw new Exception('Model does not exist. Trying to load <b>' . $class . '</b> in ' . $module); } if (!class_exists($className)) { throw new ClassNotExistException('Class ' . $class . ' does not exist in Module ' . $module); } return $className; }
/** * Start the checkout process -- user can create account or log into existing account */ function shop_user_start() { // Redirects at the start of the user functions are just a way to make sure someone isn't where they don't need to be if (xarUserIsLoggedIn()) { xarResponse::redirect(xarModURL('shop', 'user', 'viewcart')); return true; } $shop = xarSession::getVar('shop'); if (empty($shop)) { xarResponse::redirect(xarModURL('shop', 'user', 'main')); return true; } sys::import('modules.dynamicdata.class.objects.master'); sys::import('modules.dynamicdata.class.properties.master'); $rolesobject = DataObjectMaster::getObject(array('name' => 'roles_users')); $properties = $rolesobject->properties; $data['properties'] = $properties; $isvalid = $rolesobject->properties['email']->checkInput(); $isvalid2 = $rolesobject->properties['password']->checkInput(); if ($isvalid && $isvalid2) { if (!xarSecConfirmAuthKey()) { // right time to do this?? return xarTplModule('privileges', 'user', 'errors', array('layout' => 'bad_author')); } // Create the role and the customer object and then log in $email = $rolesobject->properties['email']->getValue(); $password = $rolesobject->properties['password']->getValue(); $values['name'] = $email; $values['email'] = $email; $values['uname'] = $email; $values['password'] = $password; $values['state'] = 3; $rolesobject->setFieldValues($values, 1); $uid = $rolesobject->createItem(); $custobject = DataObjectMaster::getObject(array('name' => 'shop_customers')); $custobject->createItem(array('id' => $uid)); $name = 'dd_' . $properties['password']->id; $vals = $properties['password']->fetchValue($name); $pass = $vals[1][0]; $res = xarMod::APIFunc('authsystem', 'user', 'login', array('uname' => $email, 'pass' => $pass)); xarResponse::redirect(xarModURL('shop', 'user', 'shippingaddress')); return true; } else { // We don't yet have a valid email or password for registration... return xarTplModule('shop', 'user', 'start', $data); } }
/** * Get just one set of attributes */ function shop_adminapi_getproductattributes($args) { extract($args); $objectname = 'shop_attributes'; sys::import('modules.dynamicdata.class.objects.master'); // Get the object we'll be working with. Note this is a so called object list $mylist = DataObjectMaster::getObjectList(array('name' => $objectname)); // We have some filters for the items $filters = array('status' => DataPropertyMaster::DD_DISPLAYSTATE_ACTIVE); $filters['where'] = 'id eq ' . $id; // Get the items $items = $mylist->getItems($filters); foreach ($items as $item) { $attributes = $item['options']; } return $attributes; }
/** * Given an itemid, get the publication type * CHECKME: use get in place of this function? */ function publications_userapi_getitempubtype($args) { if (empty($args['itemid'])) { throw new MissingParameterException('itemid'); } sys::import('xaraya.structures.query'); $xartables = xarDB::getTables(); $q = new Query('SELECT', $xartables['publications']); $q->addfield('pubtype_id'); $q->eq('id', $args['itemid']); if (!$q->run()) { return; } $result = $q->row(); if (empty($result)) { return 0; } return $result['pubtype_id']; }
/** * Given an itemid, get the publication type * CHECKME: use get in place of this function? */ function publications_userapi_getpubtypeaccess($args) { if (empty($args['name'])) { throw new MissingParameterException('name'); } sys::import('xaraya.structures.query'); $xartables = xarDB::getTables(); $q = new Query('SELECT', $xartables['publications_types']); $q->addfield('access'); $q->eq('name', $args['name']); if (!$q->run()) { return; } $result = $q->row(); if (empty($result)) { return "a:0:{}"; } return $result['access']; }
/** * Get the information of the requesting device * */ function wurfl_userapi_get_device($args) { sys::import('modules.wurfl.wurfl_init'); $wurflManager = wurfl_init($args); if (empty($args['ua'])) { $requestingDevice = $wurflManager->getDeviceForHttpRequest($_SERVER); } else { $requestingDevice = $wurflManager->getDeviceForUserAgent($args['ua']); } return $requestingDevice; $capabilities = xarSession::getVar(wurfl_requesting_device); if (empty($capabilities)) { sys::import('modules.wurfl.wurfl_config_standard'); $requestingDevice = $wurflManager->getDeviceForUserAgent($_SERVER); $capabilities = $requestingDevice->getCapability; xarSession::getVar(wurfl_requesting_device, $capabilities); } return $requestingDevice; }
/** * get the number of publications per publication type * @param $args['state'] array of requested status(es) for the publications * @return array array(id => count), or false on failure */ function publications_userapi_getpubcount($args) { if (!empty($args['state'])) { $statestring = 'all'; } else { if (is_array($args['state'])) { sort($args['state']); $statestring = join('+', $args['state']); } else { $statestring = $args['state']; } } if (xarVarIsCached('Publications.PubCount', $statestring)) { return xarVarGetCached('Publications.PubCount', $statestring); } $pubcount = array(); $dbconn = xarDB::getConn(); $tables = xarDB::getTables(); sys::import('xaraya.structures.query'); $q = new Query('SELECT', $tables['publications']); $q->addfield('pubtype_id'); $q->addfield('COUNT(state) AS count'); $q->addgroup('pubtype_id'); if (!empty($args['state'])) { } else { if (is_array($args['state'])) { $q->in('state', $args['state']); } else { $q->eq('state', $args['state']); } } // $q->qecho(); if (!$q->run()) { return; } $pubcount = array(); foreach ($q->output() as $key => $value) { $pubcount[$value['pubtype_id']] = $value['count']; } xarVarSetCached('Publications.PubCount', $statestring, $pubcount); return $pubcount; }
/** * Call a test page * */ function wurfl_admin_test() { if (!xarSecurityCheck('ManageWurfl')) { return; } sys::import('modules.wurfl.wurfl_init'); $wurflManager = wurfl_init(); $data['wurflInfo'] = $wurflManager->getWURFLInfo(); if (!xarVarFetch('ua', 'str', $data['ua'], '', XARVAR_NOT_REQUIRED)) { return; } if (!xarVarFetch('mode', 'str', $data['mode'], 'performance', XARVAR_NOT_REQUIRED)) { return; } $data['requestingDevice'] = xarMod::apiFunc('wurfl', 'user', 'get_device', array('ua' => $data['ua'], 'mode' => $data['mode'])); if (empty($data['ua'])) { $data['ua'] = $_SERVER['HTTP_USER_AGENT']; } return $data; }
/** * Get the items currently in the cart */ function shop_userapi_getcartproducts($args) { sys::import('modules.dynamicdata.class.objects.master'); $total = 0; $shop = xarSession::getVar('shop'); if (empty($shop)) { return; } foreach ($shop as $pid => $val) { // if this post variable is set, we must need to update the quantity if (isset($_POST['qty' . $pid])) { unset($qty_new); if (!xarVarFetch('qty' . $pid, 'isset', $qty_new, NULL, XARVAR_DONT_SET)) { return; } $shop[$pid]['qty'] = $qty_new; } $products[$pid]['qty'] = $shop[$pid]['qty']; $object = DataObjectMaster::getObject(array('name' => 'shop_products')); $some_id = $object->getItem(array('itemid' => $pid)); $values = $object->getFieldValues(); $products[$pid]['title'] = xarVarPrepForDisplay($values['title']); $price = $values['price']; if (substr($price, 0, 1) == '.') { $price = '0' . $price; } $products[$pid]['price'] = $price; $subtotal = $values['price'] * $products[$pid]['qty']; $subtotals[] = $subtotal; $products[$pid]['subtotal'] = number_format($subtotal, 2); } xarSession::setVar('shop', $shop); $total = array_sum($subtotals); $total = number_format($total, 2); if (substr($total, 0, 1) == '.') { $total = '0' . $total; } $productinfo['products'] = $products; $productinfo['total'] = $total; return $productinfo; }
/** * Display a product */ function shop_user_product($args) { if (!xarVarFetch('itemid', 'id', $itemid, NULL, XARVAR_DONT_SET)) { return; } extract($args); if (!empty($objectid)) { $itemid = $objectid; } if (empty($itemid)) { $msg = xarML('Invalid #(1) for #(2) function #(3)() in module #(4)', 'item id', 'user', 'display', 'shop'); throw new Exception($msg); } // Make sure user has read privileges for the item if (!xarSecurityCheck('ReadShop', 1, 'Item', $itemid)) { return; } // Load the DD master object class. This line will likely disappear in future versions sys::import('modules.dynamicdata.class.objects.master'); // Get the object definition we'll be working with $object = DataObjectMaster::getObject(array('name' => 'shop_products')); $data['object'] = $object; //We don't really have the item until we call getItem() $some_id = $object->getItem(array('itemid' => $itemid)); //Make sure we got something if (!isset($some_id) || $some_id != $itemid) { return; } //Get the property names and values for the item with the getFieldValues() method $values = $object->getFieldValues(); $data['itemid'] = $itemid; //$values is an associative array of property names and values, so... foreach ($values as $name => $value) { $data[$name] = xarVarPrepForDisplay($value); } $data['editurl'] = ''; if (xarSecurityCheck('EditShop', 1)) { $data['editurl'] = xarModURL('shop', 'admin', 'modify', array('itemid' => $itemid, 'name' => 'shop_products')); } return xarTplModule('shop', 'user', 'product', $data); }
/** * Get customer info */ function shop_userapi_customerinfo($args) { $values = array(); if (xarUserIsLoggedIn()) { $id = xarUserGetVar('id'); } extract($args); if (isset($id)) { sys::import('modules.dynamicdata.class.objects.master'); $custobject = DataObjectMaster::getObject(array('name' => 'shop_customers')); $some_id = $custobject->getItem(array('itemid' => $id)); if (!$some_id) { //This user must have a role but no customer account. This probably happened because a web admin uninstalled the shop module, deleting all the customer accounts but not deleting the associated roles. Let's re-create the customer record with just the id so we don't get snagged later $id = $custobject->createItem(array('id' => $id)); $custobject->getItem(array('itemid' => $id)); } $values = $custobject->getFieldValues(); return $values; } else { return; } }
public static function init($config = array()) { //-- todo : load log handler here // load system config sys::import('webi.config'); wbConfig::init(); // load variables handler, server/request/response utilities sys::import('webi.server'); // load template, page handler sys::import('webi.template'); sys::import('webi.htmlElementWidget'); //wbPage::init(); // load database sys::import('webi.db'); /*$dbConnParams = array( 'name' => wbConfig::get('DB.name'), 'user' => wbConfig::get('DB.user'), 'password' => wbConfig::get('DB.password'), 'host' => wbConfig::get('DB.host'), 'type' => wbConfig::get('DB.type'), ); wbDB::init($dbConnParams);*/ // load session handler /*sys::import('webi.sessions'); wbSession::init();*/ //-- todo : load language system // load utilities function sys::import('webi.utils'); // load module handler sys::import('webi.modules'); sys::import('webi.crud.AbstractTable'); //-- todo : load users and security system /*sys::import('webi.users'); wbUser::init(); sys::import('webi.security');*/ return true; }
public function includes($timeframe) { switch ($timeframe) { case 'week': include_once CALENDAR_ROOT . 'Week.php'; sys::import("modules.calendar.class.Calendar.Decorator.event"); sys::import("modules.calendar.class.Calendar.Decorator.weekevent"); break; case 'month': include_once CALENDAR_ROOT . 'Month/Weekdays.php'; include_once CALENDAR_ROOT . 'Day.php'; sys::import("modules.calendar.class.Calendar.Decorator.event"); sys::import("modules.calendar.class.Calendar.Decorator.monthevent"); break; case 'year': include_once CALENDAR_ROOT . 'Year.php'; sys::import("modules.calendar.class.Calendar.Decorator.event"); sys::import("modules.calendar.class.Calendar.Decorator.monthevent"); sys::import("modules.calendar.class.Calendar.Decorator.yearevent"); break; } sys::import("modules.calendar.class.Calendar.Decorator.Xaraya"); }