Пример #1
0
  function test_is_absolute_true()
  {
    $this->assertTrue(fs :: is_absolute('/test'));

    if(sys :: is_win32())
      $this->assertTrue(fs :: is_absolute('c:/test'));
  }
Пример #2
0
/**
 * 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;
}
Пример #3
0
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;
}
Пример #4
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;
}
Пример #5
0
function error($description, $error_place = '', $params = array())
{
    if (defined('DEVELOPER_ENVIROMENT')) {
        trigger_error('error', E_USER_WARNING);
        echo $description . '<br>' . $error_place . '<br><pre>';
        print_r($params);
        echo '</pre>';
    }
    debug::write_error($description, $error_place, $params);
    rollback_user_transaction();
    if (debug::is_console_enabled()) {
        echo debug::parse_html_console();
    } else {
        $message = '';
        if ($user_id = user::get_id()) {
            $message .= "user id:\t{$user_id}\nlogin:\t\t" . user::get_login() . "\ne-mail:\t\t" . user::get_email() . "\n";
        }
        $message .= "ip:\t\t" . sys::client_ip() . "\nrequest:\t" . REQUEST_URI . "\nerror:\t\t{$title}\ndescription:\t{$msg}";
        $mail = new mime_mail();
        $mail->set_body($message);
        $mail->build_message();
        $mail->send('developer', DEVELOPER_EMAIL, '', WEBSITE_EMAIL, $_SERVER['HTTP_HOST'] . ' internal error!');
    }
    ob_end_flush();
    exit;
}
Пример #6
0
 function write($log_file_data, $string)
 {
     $log_dir = $log_file_data[0];
     $log_name = $log_file_data[1];
     $file_name = $log_dir . $log_name;
     if (!is_dir($log_dir)) {
         fs::mkdir($log_dir, 0775, true);
     }
     $oldumask = @umask(0);
     $file_existed = @file_exists($file_name);
     $log_file = @fopen($file_name, 'a');
     if ($log_file) {
         $time = strftime("%b %d %Y %H:%M:%S", strtotime('now'));
         $notice = '[ ' . $time . " ]\n";
         $user =& user::instance();
         if (($user_id = $user->get_id()) != DEFAULT_USER_ID) {
             $notice .= '[ ' . $user_id . ' ] [ ' . $user->get_login() . ' ] [ ' . $user->get_email() . ' ] ';
         }
         $notice .= '[' . sys::client_ip() . '] [' . (isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '') . "]\n" . $string . "\n\n";
         @fwrite($log_file, $notice);
         @fclose($log_file);
         if (!$file_existed) {
             @chmod($file_name, 0664);
         }
         @umask($oldumask);
         $result = true;
     } else {
         @umask($oldumask);
         $result = false;
         debug::write_error("Cannot open log file '{$file_name}' for writing\n" . "The web server must be allowed to modify the file.\n" . "File logging for '{$file_name}' is disabled.", __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, false);
     }
     return $result;
 }
Пример #7
0
 public function load()
 {
     $this->headline = Language::DirectTranslate("plugin_menulistwidget_menus");
     if (Cache::contains("menu", "widget_" . $_GET['dir'])) {
         $this->content = Cache::getData("menu", "widget_" . $_GET['dir']);
     } else {
         if (!isset($_GET['dir']) || substr($_GET['dir'], 0, 1) == '.') {
             $_GET['dir'] = "";
         }
         $template = new Template();
         $template->load("plugin_menulistwidget_menulist");
         $newmenuurl = UrlRewriting::GetUrlByAlias("admin/newmenu");
         $template->assign_var("NEWMENUURL", $newmenuurl);
         $menus = sys::getMenues($_GET['dir']);
         foreach ($menus as $menu) {
             $index = $template->add_loop_item("MENUS");
             $template->assign_loop_var("MENUS", $index, "ID", $menu->id);
             $template->assign_loop_var("MENUS", $index, "TITLE", $menu->name);
             $template->assign_loop_var("MENUS", $index, "PAGES", $menu->count);
             $editurl = UrlRewriting::GetUrlByAlias("admin/editmenu", "menu=" . $menu->id);
             $template->assign_loop_var("MENUS", $index, "EDITURL", $editurl);
             $deleteurl = UrlRewriting::GetUrlByAlias("admin/deletemenu", "menu=" . $menu->id);
             $template->assign_loop_var("MENUS", $index, "DELETEURL", $deleteurl);
         }
         if (!$menus) {
             $template->assign_var("NOMENUS", Language::DirectTranslate("plugin_menulistwidget_no_menus"));
         } else {
             $template->assign_var("NOMENUS", "");
         }
         $this->content = $template->getCode();
         Cache::setData("menu", "widget_" . $_GET['dir'], $this->content);
     }
 }
Пример #8
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;
}
Пример #9
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_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;
}
Пример #10
0
/**
 * 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;
}
Пример #11
0
  function test_is_absolute_true()
  {
    $this->assertTrue(fs :: is_absolute('/test'));

    if(sys :: os_type() == 'win32')
      $this->assertTrue(fs :: is_absolute('c:/test'));
  }
Пример #12
0
 function process_row($row, $line)
 {
     $data = array("folder" => $this->_folder);
     if (DEBUG) {
         print_r(array($line, $row));
     }
     foreach ($row as $key => $val) {
         if (isset($this->_fields[$this->_headers[$key]])) {
             $data[$this->_fields[$this->_headers[$key]]] = $val;
         }
     }
     if (DEBUG) {
         print_r($data);
     }
     $id = !empty($data["id"]) ? $data["id"] : -1;
     if ($this->_validate_only) {
         $result = $this->_sgsml->validate($data, $id);
     } else {
         $result = $this->_sgsml->update($data, $id);
     }
     sys::$db_queries = array();
     // reduce memory usage
     if (empty($result)) {
         // validate
         $this->out(".");
     } else {
         if (is_array($result)) {
             $message = sprintf("{t}line{/t} %s: %s", $line, self::err_to_str($result));
             $this->_errors[] = $message;
             $this->out("<span style='color:red; font-weight:bold;'>{t}Error{/t}:</span> " . q($message) . ", ");
         } else {
             $this->out("#" . $line . ": " . q($result) . ", ");
         }
     }
 }
Пример #13
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;
}
Пример #14
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;
    }
}
Пример #15
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;
}
Пример #16
0
/**
 *  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;
}
Пример #17
0
 function test_mkdir_windows()
 {
     if (sys::os_type() != 'win32') {
         return;
     }
     dir::mkdir(VAR_DIR . '/./tmp\\../tmp/wow////hey/', 0777, true);
     $this->assertTrue(is_dir(VAR_DIR . '/tmp/wow/hey/'));
 }
Пример #18
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;
}
 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');
 }
 function tearDown()
 {
   if(sys :: exec_mode() != 'cli')
   {
     $_SERVER['REQUEST_URI'] = $this->old_request_uri;
     $_GET = $this->old_get;
     $_POST = $this->old_post;
     $_FILES = $this->old_files;
   }
 }
Пример #21
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;
}
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;
}
Пример #23
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;
}
Пример #24
0
 /**
  *
  * @return string 
  */
 public function getCode()
 {
     $res = "<select name=\"" . $this->name . "\" style=\"" . $this->style . "\">";
     foreach (sys::getAllMenues() as $menue) {
         if ($menue->id == $this->value) {
             $res .= "<option value=\"" . $menue->id . "\" selected=\"1\">" . $menue->name . "</option>";
         } else {
             $res .= "<option value=\"" . $menue->id . "\">" . $menue->name . "</option>";
         }
     }
     $res .= "</select>";
     return $res;
 }
	function _determine_options()
	{
    if (sys :: os_type() == "win32")
      $this->ext = '.exe';
    
    $this->_determine_read_types();
    $this->_determine_write_types();
    
    if (sizeof($this->read_types) == 0)
      $this->library_installed = false;
    else
      $this->library_installed = true;
  }
Пример #26
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;
}
Пример #27
0
 function login()
 {
     if (isset($_POST['user']) && !empty($_POST['user']) && isset($_POST['password']) && !empty($_POST['password'])) {
         $user = $_POST['user'];
         $password = $_POST['password'];
         if ($user == 'hci' && $password == '123') {
             sys::redirect(BASEDOMAIN . '/main');
         } else {
             sys::redirect(BASEDOMAIN);
         }
     } else {
         sys::redirect(BASEDOMAIN);
     }
 }
Пример #28
0
/**
 *  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;
}
Пример #29
0
function start_user_session()
{
  if (user_session_has_started())
    return false;

  if(defined('SESSION_USE_DB') && constant('SESSION_USE_DB'))
    _register_session_functions();

  if(sys :: exec_mode() != 'cli')
    @session_start();

  $GLOBALS['session_has_started'] = true;
  return true;
}
Пример #30
0
function start_user_session()
{
    $has_started =& $GLOBALS['session_is_started'];
    if (isset($has_started) && $has_started) {
        return false;
    }
    if (defined('SESSION_USE_DB') && constant('SESSION_USE_DB')) {
        _register_session_db_functions();
    }
    if (sys::exec_mode() != 'cli') {
        @session_start();
    }
    $has_started = true;
    return true;
}