示例#1
0
/**
 *  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;
}
示例#2
0
 /**
  * Modify Function to the Blocks Admin
  * @author Jason Judge
  * @param $blockinfo array containing title,content
  */
 public function modify(array $data = array())
 {
     $data = $this->getContent();
     // Get a list of all pages for the drop-downs.
     // Get the tree of all pages, without the DD for speed.
     $data['all_pages'] = xarMod::apiFunc('publications', 'user', 'getpagestree', array('dd_flag' => false, 'key' => 'pid'));
     // Implode the names for each page into a path for display.
     // TODO: move this into getpagestree
     foreach ($data['all_pages']['pages'] as $key => $page) {
         $data['all_pages']['pages'][$key]['slash_separated'] = '/' . implode('/', $page['namepath']);
     }
     // Get the descriptions together for the current root ids.
     // TODO: we could prune the 'add root page' list so it only includes
     // the pages which are not yet under one of the selected root pages.
     // That would just be an extra little usability touch.
     $data['root_ids'] = array_flip($data['root_ids']);
     foreach ($data['root_ids'] as $key => $value) {
         if (isset($data['all_pages']['pages'][$key])) {
             $data['root_ids'][$key] = $data['all_pages']['pages'][$key]['slash_separated'];
         } else {
             $data['root_ids'][$key] = xarML('Unknown');
         }
     }
     $data['prune_ids'] = array_flip($data['prune_ids']);
     foreach ($data['prune_ids'] as $key => $value) {
         if (isset($data['all_pages']['pages'][$key])) {
             $data['prune_ids'][$key] = $data['all_pages']['pages'][$key]['slash_separated'];
         } else {
             $data['prune_ids'][$key] = xarML('Unknown');
         }
     }
     //            $vars['bid'] = $blockinfo['bid'];
     return $data;
 }
示例#3
0
function calendar_admin_add_event()
{
    // Security check
    if (!xarSecurityCheck('Admincalendar')) {
        return;
    }
    // Generate a one-time authorisation code for this operation
    $data = xarMod::apiFunc('calendar', 'admin', 'get_calendars');
    $data['authid'] = xarSecGenAuthKey();
    $data['default_cal'] = unserialize(xarModVars::get('calendar', 'default_cal'));
    // Variables from phpIcalendar config.inc.php
    $data['updatebutton'] = xarVarPrepForDisplay(xarML('Create event'));
    //TODO: should I include this stuff? --amoro
    /*    $hooks = xarModCallHooks('module', 'modifyconfig', 'calendar',
            array('module' => 'calendar'));
        if (empty($hooks)) {
            $data['hooks'] = '';
        } elseif (is_array($hooks)) {
            $data['hooks'] = join('', $hooks);
        } else {
            $data['hooks'] = $hooks;
        }
    */
    // Return the template variables defined in this function
    return $data;
}
示例#4
0
/**
 * 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;
}
示例#5
0
/**
 *  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;
    }
}
示例#6
0
/**
 * 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;
}
示例#7
0
/**
 *  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;
}
示例#8
0
function wurfl_admin_modifyconfig()
{
    // Security Check
    if (!xarSecurityCheck('AdminWurfl')) {
        return;
    }
    if (!xarVarFetch('phase', 'str:1:100', $phase, 'modify', XARVAR_NOT_REQUIRED, XARVAR_PREP_FOR_DISPLAY)) {
        return;
    }
    if (!xarVarFetch('tab', 'str:1:100', $data['tab'], 'general', XARVAR_NOT_REQUIRED)) {
        return;
    }
    $data['module_settings'] = xarMod::apiFunc('base', 'admin', 'getmodulesettings', array('module' => 'wurfl'));
    $data['module_settings']->setFieldList('items_per_page, use_module_alias, module_alias_name, enable_short_urls');
    $data['module_settings']->getItem();
    switch (strtolower($phase)) {
        case 'modify':
        default:
            switch ($data['tab']) {
                case 'general':
                    break;
                case 'tab2':
                    break;
                case 'tab3':
                    break;
                default:
                    break;
            }
            break;
        case 'update':
            // Confirm authorisation code
            if (!xarSecConfirmAuthKey()) {
                return;
            }
            switch ($data['tab']) {
                case 'general':
                    $isvalid = $data['module_settings']->checkInput();
                    if (!$isvalid) {
                        return xarTplModule('wurfl', 'admin', 'modifyconfig', $data);
                    } else {
                        $itemid = $data['module_settings']->updateItem();
                    }
                    break;
                case 'tab2':
                    break;
                case 'tab3':
                    break;
                default:
                    break;
            }
            xarController::redirect(xarModURL('wurfl', 'admin', 'modifyconfig', array('tab' => $data['tab'])));
            // Return
            return true;
            break;
    }
    $data['authid'] = xarSecGenAuthKey();
    return $data;
}
示例#9
0
/**
 * @returns int (calendar id on success, false on failure)
 */
function calendar_adminapi_create_calendars($args)
{
    extract($args);
    // argument check
    if (!isset($calname)) {
        $msg = xarML('Calendar name not specified', 'admin', 'create', 'calendar');
        throw new Exception($msg);
    }
    // TODO: should I move these two issets to the admin function
    // admin/create_calendars.php? --amoro
    if (!isset($mod_id)) {
        $module = xarController::$request->getInfo();
        $mod_id = xarMod::getRegID($module[0]);
    }
    if (!isset($role_id)) {
        $role_id = xarSession::getVar('role_id');
    }
    // Load up database details.
    $dbconn = xarDB::getConn();
    $xartable = xarDB::getTables();
    $caltable = $xartable['calendars'];
    // Insert instance details.
    $nextId = $dbconn->GenId($caltable);
    $query = 'INSERT INTO ' . $caltable . ' (
              xar_id,
              xar_role_id,
              xar_mod_id,
              xar_name
            ) VALUES (?, ?, ?, ?)';
    $result =& $dbconn->Execute($query, array($nextId, $role_id, $mod_id, $calname));
    if (!$result) {
        return;
    }
    // Get ID of row inserted.
    $calendid = $dbconn->PO_Insert_ID($caltable, 'xar_id');
    // If not database type also add file info
    // Allow duplicate files here, to make it easier to delete them
    // WARNING: if somebody changes this you should also change the
    // delete function to avoid major dataloss!!! --amoro
    if ($addtype != 'db') {
        $filestable = $xartable['calfiles'];
        $cal_filestable = $xartable['calendars_files'];
        $nextID = $dbconn->GenId($filestable);
        $query = 'INSERT INTO ' . $filestable . ' (
                  xar_id,
                  xar_path
                ) VALUES (?, ?)';
        $result =& $dbconn->Execute($query, array($nextID, $fileuri));
        // Get ID of row inserted.
        $fileid = $dbconn->PO_Insert_ID($filestable, 'xar_id');
        $query = 'INSERT INTO ' . $cal_filestable . ' (
                      xar_calendars_id,
                      xar_files_id
                    ) VALUES (?, ?)';
        $result =& $dbconn->Execute($query, array($calendid, $fileid));
    }
    return $calendid;
}
示例#10
0
function publications_admin_templates_page($args)
{
    if (!xarSecurityCheck('AdminPublications')) {
        return;
    }
    extract($args);
    if (!xarVarFetch('confirm', 'int', $confirm, 0, XARVAR_NOT_REQUIRED)) {
        return;
    }
    if (!xarVarFetch('ptid', 'id', $data['ptid'], 0, XARVAR_NOT_REQUIRED)) {
        return;
    }
    if (!xarVarFetch('itemid', 'id', $data['itemid'], 0, XARVAR_NOT_REQUIRED)) {
        return;
    }
    if (!xarVarFetch('file', 'str', $data['file'], 'summary', XARVAR_NOT_REQUIRED)) {
        return;
    }
    if (!xarVarFetch('source_data', 'str', $data['source_data'], '', XARVAR_NOT_REQUIRED)) {
        return;
    }
    if (empty($data['itemid']) || empty($data['ptid'])) {
        return xarResponse::NotFound();
    }
    $pubtypeobject = DataObjectMaster::getObject(array('name' => 'publications_types'));
    $pubtypeobject->getItem(array('itemid' => $data['ptid']));
    $pubtype = explode('_', $pubtypeobject->properties['name']->value);
    $pubtype = isset($pubtype[1]) ? $pubtype[1] : $pubtype[0];
    $data['object'] = DataObjectMaster::getObject(array('name' => $pubtypeobject->properties['name']->value));
    $basepath = sys::code() . "modules/publications/xartemplates/objects/" . $pubtype;
    $sourcefile = $basepath . "/" . $data['file'] . "_" . $data['itemid'] . ".xt";
    $overridepath = "themes/" . xarModVars::get('themes', 'default_theme') . "/modules/publications/objects/" . $pubtype;
    $overridefile = $overridepath . "/" . $data['file'] . "-" . $data['itemid'] . ".xt";
    // If we are saving, write the file now
    if ($confirm && !empty($data['source_data'])) {
        xarMod::apiFunc('publications', 'admin', 'write_file', array('file' => $overridefile, 'data' => $data['source_data']));
    }
    // Let the template know what kind of file this is
    if (file_exists($overridefile)) {
        $data['filetype'] = 'theme';
        $filepath = $overridefile;
        $data['writable'] = is_writable($overridefile);
    } else {
        $data['filetype'] = 'module';
        $filepath = $sourcefile;
        $data['writable'] = is_writeable_dir($overridepath);
    }
    $data['source_data'] = trim(xarMod::apiFunc('publications', 'admin', 'read_file', array('file' => $filepath)));
    // Initialize the template
    if (empty($data['source_data'])) {
        $data['source_data'] = '<xar:template xmlns:xar="http://xaraya.com/2004/blocklayout">';
        $data['source_data'] .= "\n";
        $data['source_data'] .= "\n" . '</xar:template>';
    }
    $data['files'] = array(array('id' => 'summary', 'name' => 'summary display'), array('id' => 'detail', 'name' => 'detail display'));
    return $data;
}
示例#11
0
function calendar_admin_viewevents($args)
{
    if (!xarSecurityCheck('EditCalendar')) {
        return;
    }
    $data['object'] = xarMod::apiFunc('dynamicdata', 'user', 'getobjectlist', array('name' => 'calendar_event'));
    $data['object']->getItems();
    return xarTplModule('calendar', 'admin', 'view', $data);
}
示例#12
0
文件: year.php 项目: godboko/modules
function calendar_user_year()
{
    $data = xarMod::apiFunc('calendar', 'user', 'getUserDateTimeInfo');
    $Year = new Calendar_Year($data['cal_year']);
    $Year->build();
    // TODO: find a better way to handle this
    $data['Year'] =& $Year;
    $data['cal_sdow'] = CALENDAR_FIRST_DAY_OF_WEEK;
    return $data;
}
示例#13
0
/**
 *  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;
}
示例#14
0
function calendar_adminapi_hookcreate($data)
{
    if (!isset($data['extrainfo']) || !is_array($data['extrainfo'])) {
        $data['extrainfo'] = array();
    }
    // When called via hooks, modname will be empty, but we get it from the
    // extrainfo or the current module
    if (empty($data['module'])) {
        if (!empty($data['extrainfo']['module'])) {
            $data['module'] = $data['extrainfo']['module'];
        } else {
            $data['module'] = xarMod::getName();
        }
    }
    $data['module_id'] = xarMod::getID($data['module']);
    if (empty($data['module_id'])) {
        throw new IDNotFoundException("module id for " . $data['modname']);
    }
    if (!isset($data['itemtype']) || !is_numeric($data['itemtype'])) {
        if (isset($data['extrainfo']['itemtype']) && is_numeric($data['extrainfo']['itemtype'])) {
            $data['itemtype'] = $data['extrainfo']['itemtype'];
        } else {
            $data['itemtype'] = 0;
        }
    }
    if (!isset($data['itemid']) || !is_numeric($data['itemid'])) {
        if (isset($data['extrainfo']['item_id']) && is_numeric($data['extrainfo']['item_id'])) {
            $data['itemid'] = $data['extrainfo']['item_id'];
        } else {
            $data['itemid'] = 0;
        }
    }
    $data['extrainfo']['module_id'] = $data['module_id'];
    $data['extrainfo']['itemtype'] = $data['itemtype'];
    $data['extrainfo']['item_id'] = $data['itemid'];
    $data['extrainfo']['name'] = isset($data['extrainfo']['name']) ? $data['extrainfo']['name'] : xarML('Unknown Event');
    $data['extrainfo']['start_time'] = isset($data['extrainfo']['start_time']) ? $data['extrainfo']['start_time'] : time();
    $data['extrainfo']['duration'] = isset($data['extrainfo']['duration']) ? $data['extrainfo']['duration'] : 60;
    $data['extrainfo']['end_time'] = isset($data['extrainfo']['end_time']) ? $data['extrainfo']['end_time'] : $data['extrainfo']['start_time'] + $data['extrainfo']['duration'];
    $data['extrainfo']['recurring_code'] = isset($data['extrainfo']['recurring_code']) ? $data['extrainfo']['recurring_code'] : 0;
    $data['extrainfo']['recurring_span'] = isset($data['extrainfo']['recurring_span']) ? $data['extrainfo']['recurring_span'] : 0;
    $data['extrainfo']['start_location'] = isset($data['extrainfo']['start_location']) ? $data['extrainfo']['start_location'] : null;
    $data['extrainfo']['end_location'] = isset($data['extrainfo']['end_location']) ? $data['extrainfo']['end_location'] : null;
    $data['extrainfo']['object_id'] = isset($data['extrainfo']['object_id']) ? $data['extrainfo']['object_id'] : 0;
    $data['extrainfo']['role_id'] = isset($data['extrainfo']['role_id']) ? $data['extrainfo']['role_id'] : xarSession::getVar('role_id');
    $data['extrainfo']['return_link'] = isset($data['extrainfo']['return_link']) ? $data['extrainfo']['return_link'] : '';
    $data['extrainfo']['state'] = isset($data['extrainfo']['state']) ? $data['extrainfo']['state'] : 3;
    $data['extrainfo']['timestamp'] = isset($data['extrainfo']['timestamp']) ? $data['extrainfo']['timestamp'] : time();
    $data['extrainfo']['itemid'] = 0;
    $object = DataObjectMaster::getObject(array('name' => 'calendar_event'));
    $item = $object->createItem($data['extrainfo']);
    return $data['extrainfo'];
}
示例#15
0
function publications_admin_stylesheet_type($args)
{
    if (!xarSecurityCheck('AdminPublications')) {
        return;
    }
    extract($args);
    if (!xarVarFetch('confirm', 'int', $confirm, 0, XARVAR_NOT_REQUIRED)) {
        return;
    }
    if (!xarVarFetch('ptid', 'id', $data['ptid'], xarModVars::get('publications', 'defaultpubtype'), XARVAR_NOT_REQUIRED)) {
        return;
    }
    if (!xarVarFetch('file', 'str', $data['file'], '', XARVAR_NOT_REQUIRED)) {
        return;
    }
    if (!xarVarFetch('source_data', 'str', $data['source_data'], '', XARVAR_NOT_REQUIRED)) {
        return;
    }
    $pubtypeobject = DataObjectMaster::getObject(array('name' => 'publications_types'));
    $pubtypeobject->getItem(array('itemid' => $data['ptid']));
    $pubtype = explode('_', $pubtypeobject->properties['name']->value);
    $pubtype = isset($pubtype[1]) ? $pubtype[1] : $pubtype[0];
    $data['object'] = DataObjectMaster::getObject(array('name' => $pubtypeobject->properties['name']->value));
    $basepath = sys::code() . "modules/publications/xarstyles";
    $sourcefile = $basepath . "/" . $data['file'] . ".css";
    $overridepath = "themes/" . xarModVars::get('themes', 'default_theme') . "/modules/publications/style";
    $overridefile = $overridepath . "/" . $data['file'] . ".css";
    // If we are saving, write the file now
    if ($confirm && !empty($data['file']) && !empty($data['source_data'])) {
        xarMod::apiFunc('publications', 'admin', 'write_file', array('file' => $overridefile, 'data' => $data['source_data']));
    }
    // Let the template know what kind of file this is
    if (empty($data['file'])) {
        $data['filetype'] = 'empty';
        $filepath = '';
        $data['writable'] = 0;
    } elseif (file_exists($overridefile)) {
        $data['filetype'] = 'theme';
        $filepath = $overridefile;
        $data['writable'] = is_writable($overridefile);
    } elseif (file_exists($sourcefile)) {
        $data['filetype'] = 'module';
        $filepath = $sourcefile;
        $data['writable'] = is_writeable_dir($overridepath);
    } else {
        $data['filetype'] = 'unknown';
        $filepath = $overridefile;
        $data['writable'] = is_writeable_dir($overridepath);
    }
    $data['source_data'] = trim(xarMod::apiFunc('publications', 'admin', 'read_file', array('file' => $filepath)));
    return $data;
}
示例#16
0
/**
 * 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;
}
示例#17
0
/**
 * Check a user agent identiication against the requesting device
 *
 */
function wurfl_userapi_check_device($args = array())
{
    if (empty($args['agent'])) {
        $args['agent'] = 'generic';
    }
    if (empty($args['mode'])) {
        $args['mode'] = 'performance';
    }
    $requestingDevice = xarMod::apiFunc('wurfl', 'user', 'get_device', array('mode' => $args['mode']));
    $device_id = $requestingDevice->id;
    $check = preg_match("/" . $args['agent'] . "/i", $device_id);
    return $check;
}
示例#18
0
function calendar_admin_view_calendars()
{
    // Security check
    if (!xarSecurityCheck('Admincalendar')) {
        return;
    }
    // Generate a one-time authorisation code for this operation
    $data['authid'] = xarSecGenAuthKey();
    $data['default_cal'] = unserialize(xarModVars::get('calendar', 'default_cal'));
    // Return the template variables defined in this function
    $data['calendars'] = xarMod::apiFunc('calendar', 'user', 'getall');
    return $data;
}
示例#19
0
function calendar_userapi_getMonthNameLong($args)
{
    extract($args);
    unset($args);
    if (!isset($month)) {
        $month = date('m');
    }
    // make sure we have a valid month value
    if (!xarVarValidate('int:1:12', $month)) {
        return;
    }
    $c = xarMod::apiFunc('calendar', 'user', 'factory', 'calendar');
    return $c->MonthLong($month);
}
示例#20
0
function calendar_admin_create_calendars()
{
    // Get parameters
    // TODO HELPNEEDED here: how do I handle this (e.g. missing calname should return a
    // message
    if (!xarVarFetch('add_calendar', 'isset', $add_calendar)) {
        return;
    }
    if (!xarVarFetch('calname', 'str:1:', $calname)) {
        return;
    }
    if (!xarVarFetch('addtype', 'str:1:', $addtype)) {
        return;
    }
    if (!xarVarFetch('location', 'str:1:', $location, '', XARVAR_NOT_REQUIRED)) {
        return;
    }
    if (!xarVarFetch('uri', 'str:1:', $uri, '', XARVAR_NOT_REQUIRED)) {
        return;
    }
    // Confirm Auth Key
    if (!xarSecConfirmAuthKey()) {
        return;
    }
    // Security Check
    // TODO
    //    if(!xarSecurityCheck('AddCalendar', 0, 'Calendar')) {return;}
    // Check if module name has already been used.
    $checkname = xarMod::apiFunc('calendar', 'user', 'get', array('calname' => $calname));
    if (!empty($checkname)) {
        $msg = xarML('Calendar name "#(1)" already exists. Please go back and enter a
                      different name', $calname);
        throw new Exception($msg);
    }
    if ($addtype == 'db') {
        $fileuri = 'a';
    } elseif ($addtype == 'file') {
        $fileuri = $location;
    } elseif ($addtype == 'uri') {
        $fileuri = $uri;
    }
    // Pass to API
    $calid = xarMod::apiFunc('calendar', 'admin', 'create_calendars', array('calname' => $calname, 'fileuri' => $fileuri, 'addtype' => $addtype));
    if (!$calid) {
        return;
    }
    // Go on and edit the new instance
    xarController::redirect(xarModURL('calendar', 'admin', 'add_calendars', array('calid' => $calid, 'calname' => $calname)));
}
示例#21
0
function shop_adminapi_handlepgresponse($args)
{
    extract($args);
    $pg = xarModVars::get('shop', 'payment_gateway');
    $trans_id = false;
    $pg_response = xarSession::getVar('pg_response');
    switch ($pg) {
        case 1:
            // demo mode
            $trans_id = rand(1000, 99999999);
            // fake trans id
            break;
        case 2:
            // authorize.net
            $response = xarMod::APIFunc('shop', 'admin', 'authorizenet', $transfields);
            if ($response[1] == 1) {
                $trans_id = $response[7];
            } else {
                $num = $response[1];
                $authorizenet_codes = array(1 => 'Approved', 2 => 'Declined', 3 => 'Error', 4 => 'Held for Review');
                $msg = $response[4];
                $msg .= ' Response code: ' . $authorizenet_codes[$num];
                $pg_response['msg'] = $msg;
            }
            break;
        case 3:
            // paypal web payments pro
            $args['transfields'] = $transfields;
            $args['methodName_'] = 'DoDirectPayment';
            $response = xarMod::APIFunc('shop', 'admin', 'paypal', $args);
            if ($response['ACK'] == 'Success') {
                $trans_id = $response['TRANSACTIONID'];
            } else {
                $msg = $response['ACK'];
                $msg .= '. Response: ' . urldecode($response['L_LONGMESSAGE0']);
                $pg_response['msg'] = $msg;
            }
            break;
        case 4:
            // something else
            // your code
            break;
    }
    if (isset($pg_response)) {
        xarSession::setVar('pg_response', $pg_response);
    }
    $response['trans_id'] = $trans_id;
    return $response;
}
示例#22
0
 public function display()
 {
     $data = $this->getContent();
     // Setup featured item
     if ($data['fillerid'] > 0) {
         $fillerid = xarMod::apiFunc('publications', 'user', 'gettranslationid', array('id' => $data['fillerid']));
         $ptid = xarMod::apiFunc('publications', 'user', 'getitempubtype', array('itemid' => $data['fillerid']));
         $pubtypeobject = DataObjectMaster::getObject(array('name' => 'publications_types'));
         $pubtypeobject->getItem(array('itemid' => $ptid));
         $data['object'] = DataObjectMaster::getObject(array('name' => $pubtypeobject->properties['name']->value));
         $data['object']->getItem(array('itemid' => $data['fillerid']));
         return $data;
     }
     return;
 }
示例#23
0
文件: month.php 项目: godboko/modules
 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;
 }
示例#24
0
文件: dayis.php 项目: godboko/modules
/**
 *  Wrapper for the dayIs method of the calendar class
 *  @author Roger Raymond <*****@*****.**>
 *  @version $Id: dayis.php,v 1.2 2003/06/24 21:23:06 roger Exp $
 *  @param int $day 0 - 6 [Sun - Sat]
 *  @param int $date valid date YYYYMMDD
 *  @return bool true/false depending on day looking for and the date
 */
function calendar_userapi_dayIs($args)
{
    extract($args);
    unset($args);
    // make sure we have a valid day value
    if (!xarVarValidate('int:0:7', $day)) {
        return;
    }
    // TODO: Revisit this later and make a new validator for it
    // make sure we have a valid date
    if (!xarVarValidate('int::', $date)) {
        return;
    }
    $c = xarMod::apiFunc('calendar', 'user', 'factory', 'calendar');
    return $c->dayIs($day, $date);
}
示例#25
0
文件: start.php 项目: godboko/modules
/**
 *  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);
    }
}
示例#26
0
function calendar_userapi_getmonthstructure($args = array())
{
    extract($args);
    unset($args);
    if (!isset($month)) {
        return;
    }
    if (!isset($year)) {
        return;
    }
    xarVarValidate('int:1:12', $month);
    xarVarValidate('int::', $year);
    xarVarFetch('cal_sdow', 'int:0:6', $cal_sdow, 0);
    $c = xarMod::apiFunc('calendar', 'user', 'factory', 'calendar');
    $c->setStartDayOfWeek($cal_sdow);
    // echo the content to the screen
    return $c->getCalendarMonth($year . $month);
}
示例#27
0
function calendar_admin_add_calendars()
{
    // Security check
    //    if (!xarSecurityCheck('AddCalendar',0,'Calendar')) return;
    if (!xarVarFetch('calid', 'int:0:', $calid, '0', XARVAR_NOT_REQUIRED)) {
        return;
    }
    if (!xarVarFetch('calname', 'str', $calname, '', XARVAR_NOT_REQUIRED)) {
        return;
    }
    $data = xarMod::apiFunc('calendar', 'admin', 'get_calendars');
    // Generate a one-time authorisation code for this operation
    $data['authid'] = xarSecGenAuthKey();
    $data['default_cal'] = unserialize(xarModVars::get('calendar', 'default_cal'));
    $data['addbutton'] = xarVarPrepForDisplay(xarML('Add calendar'));
    $data['message'] = xarVarPrepForDisplay(xarML('Created calendar with name "#(1)", ID #(2)', $calname, $calid));
    $data['calid'] = $calid;
    return $data;
}
示例#28
0
文件: test.php 项目: godboko/modules
/**
 * 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;
}
示例#29
0
function calendar_user_submit()
{
    xarVarFetch('cal_sdow', 'int:0:6', $cal_sdow, 0);
    xarVarFetch('cal_date', 'int::', $cal_date, 0);
    $c = xarMod::apiFunc('calendar', 'user', 'factory', 'calendar');
    $c->setStartDayOfWeek($cal_sdow);
    $data = xarMod::apiFunc('calendar', 'user', 'getUserDateTimeInfo');
    $data['cal_sdow'] =& $c->getStartDayOfWeek();
    $data['shortDayNames'] =& $c->getShortDayNames($c->getStartDayOfWeek());
    $data['mediumDayNames'] =& $c->getMediumDayNames($c->getStartDayOfWeek());
    $data['longDayNames'] =& $c->getLongDayNames($c->getStartDayOfWeek());
    $data['calendar'] =& $c;
    // return the event data
    xarVarFetch('event_id', 'int::', $event_id, 0);
    $e = xarMod::apiFunc('calendar', 'user', 'factory', 'event');
    $e->buildEvent($event_id);
    // remember to pass in the existing array so it can be appended too
    $e->getEventDataForBL($data);
    // echo the content to the screen
    return $data;
}
示例#30
0
文件: week.php 项目: godboko/modules
function calendar_user_week()
{
    $data = xarMod::apiFunc('calendar', 'user', 'getUserDateTimeInfo');
    $WeekEvents = new Calendar_Week($data['cal_year'], $data['cal_month'], $data['cal_day'], CALENDAR_FIRST_DAY_OF_WEEK);
    $start_time = $WeekEvents->thisWeek;
    $end_time = $WeekEvents->nextWeek;
    $q = new Query('SELECT');
    $a[] = $q->plt('start_time', $start_time);
    $a[] = $q->pge('start_time + duration', $start_time);
    $b[] = $q->plt('start_time', $end_time);
    $b[] = $q->pge('start_time + duration', $end_time);
    $c[] = $q->pgt('start_time', $start_time);
    $c[] = $q->ple('start_time + duration', $end_time);
    $d[] = $q->pqand($a);
    $d[] = $q->pqand($b);
    $d[] = $q->pqand($c);
    $q->qor($d);
    $q->eq('role_id', xarSession::getVar('role_id'));
    $data['conditions'] = $q;
    return $data;
}