示例#1
0
function dplink_init()
{
    pnModSetVar('dplink', 'url', '/dotproject');
    pnModSetVar('dplink', 'use_window', 0);
    pnModSetVar('dplink', 'use_postwrap', 0);
    return true;
}
示例#2
0
/**
 * Update 123FlashChat Settings
 *
 * @author Tree Florian
 * @return mixed true if successful, false if unsuccessful, error string otherwise
 */
function FlashChatBridge_admin_updateconfig()
{
    // Security check
    if (!SecurityUtil::checkPermission('FlashChatBridge::', '::', ACCESS_ADMIN)) {
        return LogUtil::registerPermissionError();
    }
    // get settings from form - do before authid check
    $settings = FormUtil::getPassedValue('settings', null, 'POST');
    // if this form wasnt posted to redirect back
    if ($settings === NULL) {
        return pnRedirect(pnModURL('Settings', 'admin', 'modifyconfig'));
    }
    /*
        // confirm the forms auth key
        if (!SecurityUtil::confirmAuthKey()) {
            return LogUtil::registerAuthidError();
        }
    */
    $lastchar = substr($settings['client_path'], -1);
    if ($lastchar != "\\" && $lastchar != "/" && $settings['client_path'] != "") {
        $settings['client_path'] = $settings['client_path'] . "/";
    }
    $settings['server_data_path'] = str_replace("\\", "/", $settings['server_data_path']);
    $lastchar = substr($settings['server_data_path'], -1);
    if ($lastchar != "\\" && $lastchar != "/" && $settings['client_path'] != "") {
        $settings['server_data_path'] = $settings['server_data_path'] . "/";
    }
    $settings['active_chat_standard'] = $settings['active_chat_standard'] == 1 ? 1 : 0;
    $settings['active_chat_html'] = $settings['active_chat_html'] == 1 ? 1 : 0;
    $settings['active_chat_avatar'] = $settings['active_chat_avatar'] == 1 ? 1 : 0;
    $settings['active_chat_live'] = $settings['active_chat_live'] == 1 ? 1 : 0;
    $settings['active_chat_pocket'] = $settings['active_chat_pocket'] == 1 ? 1 : 0;
    $settings['active_chat_lite'] = $settings['active_chat_lite'] == 1 ? 1 : 0;
    $settings['active_chat_banner'] = $settings['active_chat_banner'] == 1 ? 1 : 0;
    // Write the vars
    //$configvars = pnModGetVar('FlashChatBridge');
    foreach ($settings as $key => $value) {
        pnModSetVar('FlashChatBridge', $key, $value);
    }
    //$configvars = pnModGetVar('FlashChatBridge');
    // Let any other modules know that the modules configuration has been updated
    pnModCallHooks('module', 'updateconfig', 'FlashChatBridge', array('module' => 'FlashChatBridge'));
    return pnRedirect(pnModURL('FlashChatBridge', 'admin', 'modifyconfig'));
}
示例#3
0
 /**
  * Install the TimeIt module.
  *
  * @return boolean
  */
 function install()
 {
     // create the socialNetwork table
     try {
         DoctrineUtil::createTablesFromModels('TimeIt');
     } catch (Exception $e) {
         LogUtil::registerError($e->getMessage());
         return false;
     }
     // add module vars
     pnModSetVar('TimeIt', 'monthtoday', '#FF3300');
     pnModSetVar('TimeIt', 'monthon', '');
     pnModSetVar('TimeIt', 'monthoff', '#d4d2d2');
     pnModSetVar('TimeIt', 'rssatomitems', 20);
     pnModSetVar('TimeIt', 'notifyEvents', 0);
     pnModSetVar('TimeIt', 'notifyEventsEmail', pnUserGetVar('email', 2));
     pnModSetVar('TimeIt', 'itemsPerPage', 25);
     pnModSetVar('TimeIt', 'filterByPermission', 0);
     pnModSetVar('TimeIt', 'popupOnHover', 0);
     pnModSetVar('TimeIt', 'colorCats', 1);
     pnModSetVar('TimeIt', 'googleMapsApiKey', '');
     pnModSetVar('TimeIt', 'mapViewType', 'googleMaps');
     pnModSetVar('TimeIt', 'mapHeight', 320);
     pnModSetVar('TimeIt', 'mapWidth', 480);
     pnModSetVar('TimeIt', 'colorCatsProp', 'Main');
     pnModSetVar('TimeIt', 'hideTimeItAddress', 0);
     pnModSetVar('TimeIt', 'defaultCalendar', 1);
     pnModSetVar('TimeIt', 'firstWeekDay', 1);
     pnModSetVar('TimeIt', 'defalutCatColor', 'silver');
     pnModSetVar('TimeIt', 'truncateTitle', 30);
     pnModSetVar('TimeIt', 'enablecategorization', 1);
     pnModSetVar('TimeIt', 'userdeletionMode', 'anonymize');
     // or delete
     pnModSetVar('TimeIt', 'dateformat', 'datebrief');
     pnModSetVar('TimeIt', 'defaultPrivateCalendar', 0);
     pnModSetVar('TimeIt', 'sortMode', 'byname');
     // or bysortvalue
     return true;
 }
示例#4
0
function FlashChatBridge_init()
{
    $host = pnServerGetVar('HTTP_HOST');
    $protocol = pnServerGetProtocol();
    $adress = pnServerGetVar('SERVER_ADDR');
    $server = $protocol . '://' . $host;
    pnModSetVar('FlashChatBridge', 'width', 800);
    pnModSetVar('FlashChatBridge', 'height', 600);
    pnModSetVar('FlashChatBridge', 'autosize', 0);
    pnModSetVar('FlashChatBridge', 'client_path', $server . ':35555/');
    pnModSetVar('FlashChatBridge', 'server_data_path', 'somewhere/123flashchat/server/data/');
    pnModSetVar('FlashChatBridge', 'init_room', 1);
    pnModSetVar('FlashChatBridge', 'client_type', "standard");
    pnModSetVar('FlashChatBridge', 'active_chat_standard', 1);
    pnModSetVar('FlashChatBridge', 'init_host', $adress);
    pnModSetVar('FlashChatBridge', 'init_port', '51127');
    pnModSetVar('FlashChatBridge', 'init_host_s', $adress);
    pnModSetVar('FlashChatBridge', 'init_port_s', '');
    pnModSetVar('FlashChatBridge', 'init_host_h', $adress);
    pnModSetVar('FlashChatBridge', 'init_port_h', '');
    return true;
}
示例#5
0
/**
 * initialise the template module
 * This function is only ever called once during the lifetime of a particular
 * module instance
 */
function template_init()
{
    // Get datbase setup - note that both pnDBGetConn() and pnDBGetTables()
    // return arrays but we handle them differently.  For pnDBGetConn()
    // we currently just want the first item, which is the official
    // database handle.  For pnDBGetTables() we want to keep the entire
    // tables array together for easy reference later on
    list($dbconn) = pnDBGetConn();
    $pntable = pnDBGetTables();
    // It's good practice to name the table and column definitions you
    // are getting - $table and $column don't cut it in more complex
    // modules
    $templatetable = $pntable['template'];
    $templatecolumn =& $pntable['template_column'];
    // Create the table - the formatting here is not mandatory, but it does
    // make the SQL statement relatively easy to read.  Also, separating out
    // the SQL statement from the Execute() command allows for simpler
    // debug operation if it is ever needed
    $sql = "CREATE TABLE {$templatetable} (\n            {$templatecolumn['tid']} int(10) NOT NULL auto_increment,\n            {$templatecolumn['name']} varchar(32) NOT NULL default '',\n            {$templatecolumn['number']} int(5) NOT NULL default 0,\n            PRIMARY KEY(pn_tid))";
    $dbconn->Execute($sql);
    // Check for an error with the database code, and if so set an
    // appropriate error message and return
    if ($dbconn->ErrorNo() != 0) {
        pnSessionSetVar('errormsg', _CREATETABLEFAILED);
        return false;
    }
    // Set up an initial value for a module variable.  Note that all module
    // variables should be initialised with some value in this way rather
    // than just left blank, this helps the user-side code and means that
    // there doesn't need to be a check to see if the variable is set in
    // the rest of the code as it always will be
    pnModSetVar('Template', 'bold', 0);
    pnModSetVar('Template', 'itemsperpage', 10);
    // Initialisation successful
    return true;
}
示例#6
0
  top.restoreSession();
  theForm.submit();
 }

</script>

<?php 
// this is my proposed setting in the globals config file so we don't
// need to mess with altering the pn database AND the config file
//pnModSetVar(__POSTCALENDAR__, 'pcFirstDayOfWeek', $GLOBALS['schedule_dow_start']);
// build a day-of-week (DOW) list so we may properly build the calendars later in this code
$DOWlist = array();
$tmpDOW = pnModGetVar(__POSTCALENDAR__, 'pcFirstDayOfWeek');
// bound check and auto-correction
if ($tmpDOW < 0 || $tmpDOW > 6) {
    pnModSetVar(__POSTCALENDAR__, 'pcFirstDayOfWeek', '0');
    $tmpDOW = 0;
}
while (count($DOWlist) < 7) {
    array_push($DOWlist, $tmpDOW);
    $tmpDOW++;
    if ($tmpDOW > 6) {
        $tmpDOW = 0;
    }
}
// A_CATEGORY is an ordered array of associative-array categories.
// Keys of interest are: id, name, color, desc, event_duration.
//
// echo "<!-- A_CATEGORY = "; print_r($this->_tpl_vars['A_CATEGORY']); echo " -->\n"; // debugging
// echo "<!-- A_EVENTS = "; print_r($this->_tpl_vars['A_EVENTS']); echo " -->\n"; // debugging
$A_CATEGORY =& $this->_tpl_vars['A_CATEGORY'];
示例#7
0
function postcalendar_admin_updateconfig()
{
    if (!PC_ACCESS_ADMIN) {
        return _POSTCALENDAR_NOAUTH;
    }
    list($pcTime24Hours, $pcEventsOpenInNewWindow, $pcUseInternationalDates, $pcFirstDayOfWeek, $pcDayHighlightColor, $pcUsePopups, $pcAllowDirectSubmit, $pcListHowManyEvents, $pcDisplayTopics, $pcEventDateFormat, $pcTemplate, $pcAllowSiteWide, $pcAllowUserCalendar, $pcTimeIncrement, $pcUseCache, $pcCacheLifetime, $pcDefaultView, $pcNotifyAdmin, $pcNotifyEmail) = pnVarCleanFromInput('pcTime24Hours', 'pcEventsOpenInNewWindow', 'pcUseInternationalDates', 'pcFirstDayOfWeek', 'pcDayHighlightColor', 'pcUsePopups', 'pcAllowDirectSubmit', 'pcListHowManyEvents', 'pcDisplayTopics', 'pcEventDateFormat', 'pcTemplate', 'pcAllowSiteWide', 'pcAllowUserCalendar', 'pcTimeIncrement', 'pcUseCache', 'pcCacheLifetime', 'pcDefaultView', 'pcNotifyAdmin', 'pcNotifyEmail');
    // make sure we enter something into the DB
    if (!isset($pcTime24Hours)) {
        $pcTime24Hours = '0';
    }
    if (!isset($pcEventsOpenInNewWindow)) {
        $pcEventsOpenInNewWindow = '0';
    }
    if (!isset($pcUseInternationalDates)) {
        $pcUseInternationalDates = '0';
    }
    if (!isset($pcFirstDayOfWeek)) {
        $pcFirstDayOfWeek = '0';
    }
    if (!isset($pcUsePopups)) {
        $pcUsePopups = '0';
    }
    if (!isset($pcAllowDirectSubmit)) {
        $pcAllowDirectSubmit = '0';
    }
    if (!isset($pcDisplayTopics)) {
        $pcDisplayTopics = '0';
    }
    if (!isset($pcTemplate)) {
        $pcTemplate = 'default';
    }
    if (!isset($pcAllowSiteWide)) {
        $pcAllowSiteWide = '0';
    }
    if (!isset($pcAllowUserCalendar)) {
        $pcAllowUserCalendar = '0';
    }
    if (!isset($pcUseCache)) {
        $pcUseCache = '0';
    }
    if (!isset($pcDefaultView)) {
        $pcDefaultView = 'month';
    }
    if (empty($pcCacheLifetime)) {
        $pcCacheLifetime = '3600';
    }
    if (empty($pcDayHighlightColor)) {
        $pcDayHighlightColor = '#EEEEEE';
    }
    if (empty($pcListHowManyEvents)) {
        $pcListHowManyEvents = '15';
    }
    if (empty($pcEventDateFormat)) {
        $pcEventDateFormat = '%Y-%m-%d';
    }
    if (empty($pcTimeIncrement)) {
        $pcTimeIncrement = '15';
    }
    if (empty($pcNotifyAdmin)) {
        $pcNotifyAdmin = '0';
    }
    if (empty($pcNotifyEmail)) {
        $pcNotifyEmail = pnConfigGetVar('adminmail');
    }
    // delete the old vars - we're doing this because PostNuke variable
    // handling sometimes has old values in the $GLOBALS we need to clear
    pnModDelVar(__POSTCALENDAR__, 'pcTime24Hours');
    pnModDelVar(__POSTCALENDAR__, 'pcEventsOpenInNewWindow');
    pnModDelVar(__POSTCALENDAR__, 'pcUseInternationalDates');
    pnModDelVar(__POSTCALENDAR__, 'pcFirstDayOfWeek');
    pnModDelVar(__POSTCALENDAR__, 'pcDayHighlightColor');
    pnModDelVar(__POSTCALENDAR__, 'pcUsePopups');
    pnModDelVar(__POSTCALENDAR__, 'pcAllowDirectSubmit');
    pnModDelVar(__POSTCALENDAR__, 'pcListHowManyEvents');
    pnModDelVar(__POSTCALENDAR__, 'pcDisplayTopics');
    pnModDelVar(__POSTCALENDAR__, 'pcEventDateFormat');
    pnModDelVar(__POSTCALENDAR__, 'pcTemplate');
    pnModDelVar(__POSTCALENDAR__, 'pcAllowSiteWide');
    pnModDelVar(__POSTCALENDAR__, 'pcAllowUserCalendar');
    pnModDelVar(__POSTCALENDAR__, 'pcTimeIncrement');
    pnModDelVar(__POSTCALENDAR__, 'pcDefaultView');
    pnModDelVar(__POSTCALENDAR__, 'pcUseCache');
    pnModDelVar(__POSTCALENDAR__, 'pcCacheLifetime');
    pnModDelVar(__POSTCALENDAR__, 'pcNotifyAdmin');
    pnModDelVar(__POSTCALENDAR__, 'pcNotifyEmail');
    // set the new variables
    pnModSetVar(__POSTCALENDAR__, 'pcTime24Hours', $pcTime24Hours);
    pnModSetVar(__POSTCALENDAR__, 'pcEventsOpenInNewWindow', $pcEventsOpenInNewWindow);
    pnModSetVar(__POSTCALENDAR__, 'pcUseInternationalDates', $pcUseInternationalDates);
    pnModSetVar(__POSTCALENDAR__, 'pcFirstDayOfWeek', $pcFirstDayOfWeek);
    pnModSetVar(__POSTCALENDAR__, 'pcDayHighlightColor', $pcDayHighlightColor);
    pnModSetVar(__POSTCALENDAR__, 'pcUsePopups', $pcUsePopups);
    pnModSetVar(__POSTCALENDAR__, 'pcAllowDirectSubmit', $pcAllowDirectSubmit);
    pnModSetVar(__POSTCALENDAR__, 'pcListHowManyEvents', $pcListHowManyEvents);
    pnModSetVar(__POSTCALENDAR__, 'pcDisplayTopics', $pcDisplayTopics);
    pnModSetVar(__POSTCALENDAR__, 'pcEventDateFormat', $pcEventDateFormat);
    pnModSetVar(__POSTCALENDAR__, 'pcTemplate', $pcTemplate);
    pnModSetVar(__POSTCALENDAR__, 'pcAllowSiteWide', $pcAllowSiteWide);
    pnModSetVar(__POSTCALENDAR__, 'pcAllowUserCalendar', $pcAllowUserCalendar);
    pnModSetVar(__POSTCALENDAR__, 'pcTimeIncrement', $pcTimeIncrement);
    pnModSetVar(__POSTCALENDAR__, 'pcDefaultView', $pcDefaultView);
    pnModSetVar(__POSTCALENDAR__, 'pcUseCache', $pcUseCache);
    pnModSetVar(__POSTCALENDAR__, 'pcCacheLifetime', $pcCacheLifetime);
    pnModSetVar(__POSTCALENDAR__, 'pcNotifyAdmin', $pcNotifyAdmin);
    pnModSetVar(__POSTCALENDAR__, 'pcNotifyEmail', $pcNotifyEmail);
    $tpl = new pcSmarty();
    $tpl->clear_all_cache();
    return postcalendar_admin_modifyconfig('<center>' . _PC_UPDATED . '</center>');
}
示例#8
0
function mediashare_upgrade_to_2_1_1()
{
    pnModSetVar('mediashare', 'defaultAlbumTemplate', 'Lightbox');
    pnModAPILoad('mediashare', 'admin', true);
    if (!pnModAPIFunc('mediashare', 'admin', 'setTemplateGlobally', array('template' => 'Lightbox'))) {
        return false;
    }
    return true;
}
示例#9
0
文件: pninit.php 项目: grlf/eyedock
/**
 * Module initialization.
 * 
 * @return  true on successful module initialization, else false.
 */
function Meds_init()
{
    // Get database connection and tables references.
    $dbconn =& pnDBGetConn(true);
    $pntable =& pnDBGetTables();
    // Assign table/columns used in this module.
    $company_table =& $pntable['rx_company'];
    $company_field =& $pntable['rx_company_column'];
    $preserve_table =& $pntable['rx_preserve'];
    $preserve_field =& $pntable['rx_preserve_column'];
    $chem_table =& $pntable['rx_chem'];
    $chem_field =& $pntable['rx_chem_column'];
    $moa_table =& $pntable['rx_moa'];
    $moa_field =& $pntable['rx_moa_column'];
    $meds_table =& $pntable['rx_meds'];
    $meds_field =& $pntable['rx_meds_column'];
    // Start a new data object.
    $dict =& NewDataDictionary($dbconn);
    // Get table creation options.
    $options =& pnDBGetTableOptions();
    // Initialize a variable to hold the modules' table/columns schema.
    $schema = array();
    // Adding another table/columns to $schema.
    $schema[$preserve_table] = "\n            {$preserve_field['pres_id']}    I       AUTO PRIMARY,\n            {$preserve_field['name']}       C(48)   NOT NULL DEFAULT '',\n            {$preserve_field['comments']}   X2\n            ";
    // Adding a first table/columns to $schema.
    $schema[$company_table] = "\n            {$company_field['comp_id']}     I       AUTO PRIMARY,\n            {$company_field['name']}        C(48)   NOT NULL DEFAULT '',\n            {$company_field['phone']}       C(15)   NOT NULL DEFAULT '',\n            {$company_field['street']}      C(96)   NOT NULL DEFAULT '',\n            {$company_field['city']}        C(48)   NOT NULL DEFAULT '',\n            {$company_field['state']}       C(2)    NOT NULL DEFAULT '',\n            {$company_field['zip']}         C(12)   NOT NULL DEFAULT '',\n            {$company_field['email']}       C(64)   NOT NULL DEFAULT '',\n            {$company_field['url']}         C(64)   NOT NULL DEFAULT '',\n            {$company_field['comments']}    X2\n            ";
    // Adding another table/columns to $schema.
    $schema[$chem_table] = "\n            {$chem_field['chem_id']}        I       AUTO PRIMARY,\n            {$chem_field['name']}           C(48)   NOT NULL DEFAULT '',\n            {$chem_field['moa_id']}         I(6)    DEFAULT NULL\n            ";
    // Adding another table/columns to $schema.
    $schema[$moa_table] = "\n            {$moa_field['moa_id']}          I       AUTO PRIMARY,\n            {$moa_field['name']}            C(48)   NOT NULL DEFAULT '',\n            {$moa_field['comments']}        X2\n            ";
    // Loop through $schema array.
    foreach ($schema as $table => $fields) {
        // Assemble each SQL array to CREATE the populated, optioned table.
        $sqlarray = $dict->CreateTableSQL($table, $fields, $options);
        // Run SQL query, checking for errors along the way.
        if ($dict->ExecuteSQLArray($sqlarray) != 2) {
            pnSessionSetVar('errormsg', $table . ' - ' . mysql_error());
            return false;
        }
        // If no error was encountered in the table creation loop, each table now
        // needs an index for better performance. Since all the tables don't have
        // an identical field to use as an index, a single assigment won't do for
        // all iterations of the loop.  To deal with this, a switch() is used and
        // the indexes defined on a case by case basis.
        switch ($table) {
            case $preserve_table:
                $index_alias = 'PreserveIndex';
                break;
            case $company_table:
                $index_alias = 'CompanyIndex';
                break;
            case $chem_table:
                $index_alias = 'ChemIndex';
                break;
            case $moa_table:
                $index_alias = 'MOAIndex';
                break;
            default:
                pnSessionSetVar('errormsg', $index_alias . ' - ' . mysql_error());
                $failure = true;
                break;
        }
        if ($failure) {
            return;
        }
        $index_field = 'pn_name';
        // Create an array of SQL to INDEX the table
        $sqlarray = $dict->CreateIndexSQL($index_alias, $table, $index_field);
        // Run each INDEX query, checking for errors along the way.
        if ($dict->ExecuteSQLArray($sqlarray) != 2) {
            pnSessionSetVar('errormsg', $table . ' - ' . mysql_error());
            return false;
        }
    }
    // This table requires an "enum" column type, which cannot be
    // handled with the data dictionary object.  This table will have
    // to be built the old way (a la the "Template" module.)
    $sql = "CREATE TABLE {$meds_table} (\n             {$meds_field['med_id']}                int(10)         NOT NULL auto_increment,\n             {$meds_field['trade']}                 varchar(48)     NOT NULL DEFAULT '',\n             {$meds_field['comp_id']}               int(4)          DEFAULT NULL,\n             {$meds_field['medType1']}              varchar(48)     DEFAULT NULL,\n             {$meds_field['medType2']}              varchar(48)     DEFAULT NULL,\n             {$meds_field['preg']}                  char(1)         NOT NULL DEFAULT '',\n             {$meds_field['schedule']}              varchar(4)      NOT NULL DEFAULT '',\n             {$meds_field['generic']}               enum('yes','no','unknown') DEFAULT NULL,\n             {$meds_field['image1']}                varchar(48)     NOT NULL DEFAULT '',\n             {$meds_field['image2']}                varchar(48)     NOT NULL DEFAULT '',\n             {$meds_field['dose']}                  text,\n             {$meds_field['peds']}                  varchar(32)     DEFAULT NULL,\n             {$meds_field['ped_text']}              varchar(8)      DEFAULT NULL,\n             {$meds_field['nurse']}                 varchar(96)     NOT NULL DEFAULT '',\n             {$meds_field['pres_id1']}              int(4)          DEFAULT NULL,\n             {$meds_field['pres_id2']}              int(4)          DEFAULT NULL,\n             {$meds_field['comments']}              text,\n             {$meds_field['rxInfo']}                varchar(200)    DEFAULT NULL,\n             {$meds_field['med_url']}               varchar(200)    NOT NULL DEFAULT '',\n             {$meds_field['updated']}               varchar(10)     NOT NULL DEFAULT '',\n             {$meds_field['display']}               enum('true','false') DEFAULT 'true',\n             {$meds_field['conc1']}                 varchar(20)     DEFAULT NULL,\n             {$meds_field['chem_id1']}              int(4)          DEFAULT NULL,\n             {$meds_field['moa_id1']}               int(4)          DEFAULT NULL,\n             {$meds_field['conc2']}                 varchar(20)     DEFAULT NULL,\n             {$meds_field['chem_id2']}              int(4)          DEFAULT NULL,\n             {$meds_field['moa_id2']}               int(4)          DEFAULT NULL,\n             {$meds_field['conc3']}                 varchar(20)     DEFAULT NULL,\n             {$meds_field['chem_id3']}              int(4)          DEFAULT NULL,\n             {$meds_field['moa_id3']}               int(4)          DEFAULT NULL,\n             {$meds_field['conc4']}                 varchar(20)     DEFAULT NULL,\n             {$meds_field['chem_id4']}              int(4)          DEFAULT NULL,\n             {$meds_field['moa_id4']}               int(4)          DEFAULT NULL,\n             {$meds_field['form1']}                 enum('capsule','gel','intravenous','ointment','solution','emulsion','suspension','syrup','tablet','unknown','other') DEFAULT NULL,\n             {$meds_field['size1']}                 varchar(20)     NOT NULL DEFAULT '',\n             {$meds_field['cost1']}                 varchar(20)     NOT NULL DEFAULT '',\n             {$meds_field['form2']}                 enum('capsule','gel','intravenous','ointment','solution','emulsion','suspension','syrup','tablet','unknown','other') DEFAULT NULL,\n             {$meds_field['size2']}                 varchar(20)     NOT NULL DEFAULT '',\n             {$meds_field['cost2']}                 varchar(20)     NOT NULL DEFAULT '',\n             {$meds_field['form3']}                 enum('capsule','gel','intravenous','ointment','solution','emulsion','suspension','syrup','tablet','unknown','other') DEFAULT NULL,\n             {$meds_field['size3']}                 varchar(20)     NOT NULL DEFAULT '',\n             {$meds_field['cost3']}                 varchar(20)     NOT NULL DEFAULT '',\n             {$meds_field['form4']}                 enum('capsule','gel','intravenous','ointment','solution','emulsion','suspension','syrup','tablet','unknown','other') DEFAULT NULL,\n             {$meds_field['size4']}                 varchar(20)     NOT NULL DEFAULT '',\n             {$meds_field['cost4']}                 varchar(20)     NOT NULL DEFAULT '',\n             PRIMARY KEY({$meds_field['med_id']}))";
    // Execute SQL.
    $dbconn->Execute($sql);
    // Check for any db errors.
    if ($dbconn->ErrorNo() != 0) {
        pnSessionSetVar('errormsg', '<strong>' . $meds_table . '</strong> - ' . mysql_error());
        return false;
    }
    // Create the SQL to create a table index.
    $sqlarray = $dict->CreateIndexSQL('MedsIndex', $meds_table, 'pn_trade');
    // Run SQL query and check for database error.
    if ($dict->ExecuteSQLArray($sqlarray) != 2) {
        // Set a detailed error message.
        pnSessionSetVar('errormsg', '<strong>' . $meds_table . '</strong> - ' . mysql_error());
        // Report failure.
        return false;
    }
    // Set a default number for per-page meds.
    pnModSetVar('Meds', 'per_page', (int) 10);
    // --------------------------------------------------
    //  POPULATE TABLES WITH DATA
    // --------------------------------------------------
    // Define the path/file that holds the SQL inserts.
    $inserts = dirname(__FILE__) . '/pnSQL/inserts.sql';
    // Check if such a file exists and...
    if (@file_exists($inserts)) {
        // ...if so, get all INSERTs from file into an easily queryable array and then...
        $sqlarray = file($inserts);
        // ...run each INSERT query, checking for errors along the way.
        if ($dict->ExecuteSQLArray($sqlarray) != 2) {
            pnSessionSetVar('errormsg', 'Error Inserting Default Data - ' . mysql_error());
            return false;
        }
    }
    // Installation success.
    return true;
}
示例#10
0
function dplink_admin_updateconfig()
{
    // Get parameters from whatever input we need.
    $_loc = pnVarCleanFromInput('url');
    $_window = pnVarCleanFromInput('use_window');
    $_wrap = pnVarCleanFromInput('use_postwrap');
    // Confirm authorisation code.
    if (!pnSecConfirmAuthKey()) {
        pnSessionSetVar('errormsg', _BADAUTHKEY);
        pnRedirect(pnModURL('dplink', 'admin', ''));
        return true;
    }
    // Update module variables.
    pnModSetVar('dplink', 'url', $_loc);
    pnModSetVar('dplink', 'use_window', $_window);
    pnModSetVar('dplink', 'use_postwrap', $_wrap);
    // This function generated no output, and so now it is complete we redirect
    // the user to an appropriate page for them to carry on their work
    pnRedirect('admin.php');
    // Return
    return true;
}
示例#11
0
/**
* set a configuration variable
*
* @param name $ the name of the variable
* @param value $ the value of the variable
* @return bool true on success, false on failure
*/
function pnConfigSetVar($name, $value = '')
{
    $name = isset($name) ? (string) $name : '';
    // The database parameter are not allowed to change
    if (empty($name) || $name == 'dbtype' || $name == 'dbhost' || $name == 'dbuname' || $name == 'dbpass' || $name == 'dbname' || $name == 'system' || $name == 'prefix' || $name == 'encoded') {
        return false;
    }
    // set the variable
    if (pnModSetVar(_PN_CONFIG_MODULE, $name, @serialize($value))) {
        // Update my vars
        $GLOBALS['pnconfig'][$name] = $value;
        return true;
    }
    return false;
}
示例#12
0
/**
 * This is a standard function to update the configuration parameters of the
 * module given the information passed back by the modification form
 */
function template_admin_updateconfig()
{
    // Get parameters from whatever input we need.  All arguments to this
    // function should be obtained from pnVarCleanFromInput(), getting them
    // from other places such as the environment is not allowed, as that makes
    // assumptions that will not hold in future versions of PostNuke
    $bold = pnVarCleanFromInput('bold');
    // Confirm authorisation code.  This checks that the form had a valid
    // authorisation code attached to it.  If it did not then the function will
    // proceed no further as it is possible that this is an attempt at sending
    // in false data to the system
    if (!pnSecConfirmAuthKey()) {
        pnSessionSetVar('errormsg', _BADAUTHKEY);
        pnRedirect(pnModURL('Template', 'admin', 'view'));
        return true;
    }
    // Update module variables.  Note that depending on the HTML structure used
    // to obtain the information from the user it is possible that the values
    // might be unset, so it is important to check them all and assign them
    // default values if required
    if (!isset($bold)) {
        $bold = 0;
    }
    pnModSetVar('template', 'bold', $bold);
    if (!isset($itemsperpage)) {
        $itemsperpage = 10;
    }
    pnModSetVar('template', 'itemsperpage', $itemsperpage);
    // This function generated no output, and so now it is complete we redirect
    // the user to an appropriate page for them to carry on their work
    pnRedirect(pnModURL('Template', 'admin', 'view'));
    // Return
    return true;
}
示例#13
0
/**
 * Update the configuration
 *
 * This is a standard function to update the configuration parameters of the
 * module given the information passed back by the modification form
 * Modify configuration
 *
 * @author       Jim McDonald
 * @param        bold           print items in bold
 * @param        itemsperpage   number of items per page
 */
function Example_admin_updateconfig()
{
    // Security check - important to do this as early as possible to avoid
    // potential security holes or just too much wasted processing
    if (!pnSecAuthAction(0, 'Example::', '::', ACCESS_ADMIN)) {
        return pnVarPrepHTMLDisplay(_MODULENOAUTH);
    }
    // Get parameters from whatever input we need.  All arguments to this
    // function should be obtained from pnVarCleanFromInput(), getting them
    // from other places such as the environment is not allowed, as that makes
    // assumptions that will not hold in future versions of PostNuke
    list($bold, $itemsperpage) = pnVarCleanFromInput('bold', 'itemsperpage');
    // Confirm authorisation code.  This checks that the form had a valid
    // authorisation code attached to it.  If it did not then the function will
    // proceed no further as it is possible that this is an attempt at sending
    // in false data to the system
    if (!pnSecConfirmAuthKey()) {
        pnSessionSetVar('errormsg', pnVarPrepHTMLDisplay(_BADAUTHKEY));
        return pnRedirect(pnModURL('Example', 'admin', 'view'));
    }
    // Update module variables.  Note that depending on the HTML structure used
    // to obtain the information from the user it is possible that the values
    // might be empty, so it is important to check them all and assign them
    // default values if required.
    // ** Please note pnVarCleanFromInput will always return a set variable, even
    // it's empty so isset() checking is not appropriate.
    if (empty($bold)) {
        $bold = false;
    }
    pnModSetVar('Example', 'bold', (bool) $bold);
    if (empty($itemsperpage)) {
        $itemsperpage = 10;
    }
    // make sure $itemsperpage is a positive integer
    if (!is_integer($itemsperpage) || $itemsperpage < 1) {
        pnSessionSetVar('errormsg', pnVarPrepForDisplay(_EXAMPLEITEMSPERPAGE));
        $itemsperpage = (int) $itemsperpage;
        if ($itemsperpage < 1) {
            $itemsperpage = 25;
        }
    }
    pnModSetVar('Example', 'itemsperpage', $itemsperpage);
    // The configuration has been changed, so we clear all caches for
    // this module.
    $pnRender =& new pnRender('Example');
    // Please note that by using clear_cache without any parameter,
    // we clear all cached pages for this module.
    $pnRender->clear_cache();
    // the module configuration has been updated successfuly
    pnSessionSetVar('statusmsg', _CONFIGUPDATED);
    // Let any other modules know that the modules configuration has been updated
    pnModCallHooks('module', 'updateconfig', 'Example', array('module' => 'Example'));
    // This function generated no output, and so now it is complete we redirect
    // the user to an appropriate page for them to carry on their work
    return pnRedirect(pnModURL('Example', 'admin', 'view'));
}
示例#14
0
/**
 *	Upgrades an old install of PostCalendar
 *
 *	This function is used to upgrade an old version
 *	of PostCalendar.  It is accessed via the PostNuke
 *	Admin interface and should not be called directly.
 *
 *	@return boolean	true/false
 *	@param  string	$oldversion Version we're upgrading
 *	@access  public
 *	@author  Roger Raymond <*****@*****.**>
 *	@copyright	The PostCalendar Team 2002
 */
function postcalendar_upgrade($oldversion)
{
    /**
     *	Until PostNuke fixes the bugs
     *	with the module upgrade we are
     *	going to have to do it ourselves.
     *
     *	Please do not use the Modules admin
     *	to upgrade PostCalendar.  Use the
     *	link provided in the PostCalendar
     *	Admin section.
     */
    $pcModInfo = pnModGetInfo(pnModGetIDFromName(__POSTCALENDAR__));
    $pcDir = pnVarPrepForOS($pcModInfo['directory']);
    list($dbconn) = pnDBGetConn();
    $pntable = pnDBGetTables();
    $events_table = $pntable['postcalendar_events'];
    $cat_table = $pntable['postcalendar_categories'];
    switch ($oldversion) {
        case '3.0':
        case '3.01':
        case '3.02':
        case '3.03':
        case '3.04':
            // we need the Date_Calc class
            require_once "modules/{$pcDir}/pnincludes/Date/Calc.php";
            // Update PostCalendar Variables
            pnModSetVar(__POSTCALENDAR__, 'pcTime24Hours', pnModGetVar(__POSTCALENDAR__, 'time24hours'));
            pnModSetVar(__POSTCALENDAR__, 'pcEventsOpenInNewWindow', pnModGetVar(__POSTCALENDAR__, 'eventsopeninnewwindow'));
            pnModSetVar(__POSTCALENDAR__, 'pcUseInternationalDates', pnModGetVar(__POSTCALENDAR__, 'useinternationaldates'));
            pnModSetVar(__POSTCALENDAR__, 'pcFirstDayOfWeek', pnModGetVar(__POSTCALENDAR__, 'firstdayofweek'));
            pnModSetVar(__POSTCALENDAR__, 'pcDayHighlightColor', pnModGetVar(__POSTCALENDAR__, 'dayhighlightcolor'));
            pnModSetVar(__POSTCALENDAR__, 'pcUsePopups', pnModGetVar(__POSTCALENDAR__, 'usepopups'));
            pnModSetVar(__POSTCALENDAR__, 'pcDisplayTopics', pnModGetVar(__POSTCALENDAR__, 'displaytopics'));
            pnModSetVar(__POSTCALENDAR__, 'pcAllowDirectSubmit', '0');
            pnModSetVar(__POSTCALENDAR__, 'pcListHowManyEvents', pnModGetVar(__POSTCALENDAR__, 'listhowmanyevents'));
            pnModSetVar(__POSTCALENDAR__, 'pcTimeIncrement', '15');
            pnModSetVar(__POSTCALENDAR__, 'pcAllowSiteWide', '0');
            pnModSetVar(__POSTCALENDAR__, 'pcAllowUserCalendar', '1');
            pnModSetVar(__POSTCALENDAR__, 'pcEventDateFormat', '%Y-%m-%d');
            pnModSetVar(__POSTCALENDAR__, 'pcTemplate', 'default');
            pnModSetVar(__POSTCALENDAR__, 'pcUseCache', '1');
            pnModSetVar(__POSTCALENDAR__, 'pcCacheLifetime', '3600');
            pnModSetVar(__POSTCALENDAR__, 'pcDefaultView', 'month');
            pnModSetVar(__POSTCALENDAR__, 'pcSafeMode', '0');
            // alter the events table and change some old columns
            $sql = "ALTER TABLE {$events_table}\n                    ADD pc_catid int(11) default '0' NOT NULL,\n\t\t\t\t\tADD pc_duration bigint(20) default '0' NOT NULL,\n                    ADD pc_sharing int(11) default '0' NOT NULL,\n                    ADD pc_language varchar(30) default '',\n\t\t\t\t\tCHANGE pc_eid pc_eid int(11) unsigned NOT NULL auto_increment,\n                    CHANGE pc_location pc_location text,\n                    CHANGE pc_conttel pc_conttel varchar(50),\n                    CHANGE pc_contname pc_contname varchar(150),\n                    CHANGE pc_contemail pc_contemail varchar(255),\n                    CHANGE pc_website pc_website varchar(255),\n                    CHANGE pc_fee pc_fee varchar(50),\n                    CHANGE pc_recurrspec pc_recurrspec text default ''\n                    ";
            $dbconn->Execute($sql);
            if ($dbconn->ErrorNo() != 0) {
                die('event table alter error : ' . $dbconn->ErrorMsg());
                return false;
            }
            // create the new categories table
            $sql = "CREATE TABLE {$cat_table} (\n                    pc_catid int(11) unsigned NOT NULL auto_increment,\n                    pc_catname varchar(100) NOT NULL default 'Undefined',\n                    pc_catcolor varchar(50) NOT NULL default '#EEEEEE',\n                    pc_catdesc text default '',\n                    PRIMARY KEY(pc_catid)\n                    )";
            $dbconn->Execute($sql);
            if ($dbconn->ErrorNo() != 0) {
                die('cat table create error : ' . $dbconn->ErrorMsg());
                return false;
            }
            // insert the current hardcoded categories into the new categories table
            $category1 = pnVarPrepForStore(pnModGetVar(__POSTCALENDAR__, 'category1'));
            $category2 = pnVarPrepForStore(pnModGetVar(__POSTCALENDAR__, 'category2'));
            $category3 = pnVarPrepForStore(pnModGetVar(__POSTCALENDAR__, 'category3'));
            $category4 = pnVarPrepForStore(pnModGetVar(__POSTCALENDAR__, 'category4'));
            $category5 = pnVarPrepForStore(pnModGetVar(__POSTCALENDAR__, 'category5'));
            $inserts = array("INSERT INTO {$cat_table} (pc_catid,pc_catname,pc_catcolor) VALUES ('1','{$category1}','#EEEEEE')", "INSERT INTO {$cat_table} (pc_catid,pc_catname,pc_catcolor) VALUES ('2','{$category2}','#00ff00')", "INSERT INTO {$cat_table} (pc_catid,pc_catname,pc_catcolor) VALUES ('3','{$category3}','#0000ff')", "INSERT INTO {$cat_table} (pc_catid,pc_catname,pc_catcolor) VALUES ('4','{$category4}','#ffffff')", "INSERT INTO {$cat_table} (pc_catid,pc_catname,pc_catcolor) VALUES ('5','{$category5}','#ffcc00')");
            foreach ($inserts as $insert) {
                $dbconn->Execute($insert);
                if ($dbconn->ErrorNo() != 0) {
                    die('cat table insert error : ' . $dbconn->ErrorMsg());
                    return false;
                }
            }
            // update the current events to reflect the category system change
            $updates = array("UPDATE {$events_table} SET pc_catid = 1 WHERE pc_barcolor = 'r' ", "UPDATE {$events_table} SET pc_catid = 2 WHERE pc_barcolor = 'g' ", "UPDATE {$events_table} SET pc_catid = 3 WHERE pc_barcolor = 'b' ", "UPDATE {$events_table} SET pc_catid = 4 WHERE pc_barcolor = 'w' ", "UPDATE {$events_table} SET pc_catid = 5 WHERE pc_barcolor = 'y' ");
            foreach ($updates as $update) {
                $dbconn->Execute($update);
                if ($dbconn->ErrorNo() != 0) {
                    die('event table update error : ' . $dbconn->ErrorMsg());
                    return false;
                }
            }
            // alter the events table and drop the old barcolor column
            $sql = "ALTER TABLE {$events_table} DROP pc_barcolor";
            $dbconn->Execute($sql);
            if ($dbconn->ErrorNo() != 0) {
                die('cat table alter error : ' . $dbconn->ErrorMsg());
                return false;
            }
            // remove the old vars as they are no longer needed
            pnModDelVar(__POSTCALENDAR__, 'category1');
            pnModDelVar(__POSTCALENDAR__, 'category2');
            pnModDelVar(__POSTCALENDAR__, 'category3');
            pnModDelVar(__POSTCALENDAR__, 'category4');
            pnModDelVar(__POSTCALENDAR__, 'category5');
            pnModDelVar(__POSTCALENDAR__, 'time24hours');
            pnModDelVar(__POSTCALENDAR__, 'eventsopeninnewwindow');
            pnModDelVar(__POSTCALENDAR__, 'useinternationaldates');
            pnModDelVar(__POSTCALENDAR__, 'firstdayofweek');
            pnModDelVar(__POSTCALENDAR__, 'dayhighlightcolor');
            pnModDelVar(__POSTCALENDAR__, 'displaytopics');
            pnModDelVar(__POSTCALENDAR__, 'usepopups');
            pnModDelVar(__POSTCALENDAR__, 'listhowmanyevents');
            pnModDelVar(__POSTCALENDAR__, 'allowdirectsubmit');
            pnModDelVar(__POSTCALENDAR__, 'showeventsinyear');
            //======================================================
            //  now, ideally, we will convert old events to the new
            //  style. this consists of reconfiguring the repeating
            //  events vars.
            //
            //  we need to establish the current repeating
            //  conditions and convert them to the new system
            //======================================================
            //  old repeating defines
            //======================================================
            @define('_EVENT_NONE', -1);
            @define('_EVENT_DAILY', 0);
            @define('_EVENT_WEEKLY', 1);
            @define('_EVENT_MONTHLY', 2);
            @define('_EVENT_YEARLY', 3);
            @define('_RECUR_SAME_DAY', 0);
            @define('_RECUR_SAME_DATE', 1);
            //======================================================
            //  new repeating defines
            //  $recurrspec['event_repeat']
            //======================================================
            @define('NO_REPEAT', 0);
            @define('REPEAT', 1);
            @define('REPEAT_ON', 2);
            //======================================================
            //  $recurrspec['event_repeat_freq']
            //======================================================
            @define('REPEAT_EVERY', 1);
            @define('REPEAT_EVERY_OTHER', 2);
            @define('REPEAT_EVERY_THIRD', 3);
            @define('REPEAT_EVERY_FOURTH', 4);
            //======================================================
            //  $recurrspec['event_repeat_freq_type']
            //======================================================
            @define('REPEAT_EVERY_DAY', 0);
            @define('REPEAT_EVERY_WEEK', 1);
            @define('REPEAT_EVERY_MONTH', 2);
            @define('REPEAT_EVERY_YEAR', 3);
            //======================================================
            //  $recurrspec['event_repeat_on_num']
            //======================================================
            @define('REPEAT_ON_1ST', 1);
            @define('REPEAT_ON_2ND', 2);
            @define('REPEAT_ON_3RD', 3);
            @define('REPEAT_ON_4TH', 4);
            @define('REPEAT_ON_LAST', 5);
            //======================================================
            //  $recurrspec['event_repeat_on_day']
            //======================================================
            @define('REPEAT_ON_SUN', 0);
            @define('REPEAT_ON_MON', 1);
            @define('REPEAT_ON_TUE', 2);
            @define('REPEAT_ON_WED', 3);
            @define('REPEAT_ON_THU', 4);
            @define('REPEAT_ON_FRI', 5);
            @define('REPEAT_ON_SAT', 6);
            //======================================================
            //  $recurrspec['event_repeat_on_freq']
            //======================================================
            @define('REPEAT_ON_MONTH', 1);
            @define('REPEAT_ON_2MONTH', 2);
            @define('REPEAT_ON_3MONTH', 3);
            @define('REPEAT_ON_4MONTH', 4);
            @define('REPEAT_ON_6MONTH', 6);
            @define('REPEAT_ON_YEAR', 12);
            //======================================================
            //  Set Sharing Paramaters
            //======================================================
            @define('SHARING_PRIVATE', 0);
            @define('SHARING_PUBLIC', 1);
            @define('SHARING_BUSY', 2);
            @define('SHARING_GLOBAL', 3);
            //======================================================
            //  Here's some psuedo-code for the conversion
            //
            //  if _EVENT_NONE
            //      $rtype = NO_REPEAT
            //      $rspec = 0 for all;
            //      $duration = endTime - startTime
            //
            //  if _EVENT_DAILY
            //      $rtype = REPEAT
            //      $rspec = REPEAT_EVERY|REPEAT_EVERY_DAY
            //      $duration = endTime - startTime
            //
            //  if _EVENT_WEEKLY
            //      $rtype = REPEAT
            //      $rspec = REPEAT_EVERY|REPEAT_EVERY_WEEK
            //      $duration = endTime - startTime
            //
            //  if _EVENT_MONTHLY
            //      if _RECUR_SAME_DAY
            //          $rtype = REPEAT_ON
            //          $rspec = REPEAT_ON_NUM|REPEAT_ON_DAY|REPEAT_ON_FREQ
            //      if _RECUR_SAME_DATE
            //          $rtype = REPEAT
            //          $rspec = REPEAT_EVERY|REPEAT_EVERY_MONTH
            //      $duration = endTime - startTime
            //
            //  if _EVENT_YEARLY
            //      if _RECUR_SAME_DAY
            //          $rtype = REPEAT_ON
            //          $rspec = REPEAT_ON_NUM|REPEAT_ON_DAY|REPEAT_ON_FREQ
            //      if _RECUR_SAME_DATE
            //          $rtype = REPEAT
            //          $rspec = REPEAT_EVERY|REPEAT_EVERY_YEAR
            //      $duration = endTime - startTime
            //======================================================
            //  attempt reconfiguration
            //======================================================
            $sql = "SELECT pc_eid, pc_eventDate, pc_startTime, pc_endTime, pc_recurrtype, pc_recurrfreq\n                    FROM {$events_table}";
            $result = $dbconn->Execute($sql);
            if ($dbconn->ErrorNo() != 0) {
                die($dbconn->ErrorMsg());
                return false;
            }
            if (!isset($result)) {
                return false;
            }
            // grab the results and start the conversion
            for (; !$result->EOF; $result->MoveNext()) {
                $recurrspec = array();
                list($eid, $eventdate, $start, $end, $rtype, $rfreq) = $result->fields;
                if ($rtype == null) {
                    $rtype = _EVENT_NONE;
                }
                switch ($rtype) {
                    case _EVENT_NONE:
                        $recurrtype = NO_REPEAT;
                        $recurrspec['event_repeat_freq'] = 0;
                        $recurrspec['event_repeat_freq_type'] = 0;
                        $recurrspec['event_repeat_on_num'] = 0;
                        $recurrspec['event_repeat_on_day'] = 0;
                        $recurrspec['event_repeat_on_freq'] = 0;
                        break;
                    case _EVENT_DAILY:
                        $recurrtype = REPEAT;
                        $recurrspec['event_repeat_freq'] = REPEAT_EVERY;
                        $recurrspec['event_repeat_freq_type'] = REPEAT_EVERY_DAY;
                        $recurrspec['event_repeat_on_num'] = 0;
                        $recurrspec['event_repeat_on_day'] = 0;
                        $recurrspec['event_repeat_on_freq'] = 0;
                        break;
                    case _EVENT_WEEKLY:
                        $recurrtype = REPEAT;
                        $recurrspec['event_repeat_freq'] = REPEAT_EVERY;
                        $recurrspec['event_repeat_freq_type'] = REPEAT_EVERY_WEEK;
                        $recurrspec['event_repeat_on_num'] = 0;
                        $recurrspec['event_repeat_on_day'] = 0;
                        $recurrspec['event_repeat_on_freq'] = 0;
                        break;
                    case _EVENT_MONTHLY:
                        if ($rfreq == _RECUR_SAME_DATE) {
                            $recurrtype = REPEAT;
                            $recurrspec['event_repeat_freq'] = REPEAT_EVERY;
                            $recurrspec['event_repeat_freq_type'] = REPEAT_EVERY_MONTH;
                            $recurrspec['event_repeat_on_num'] = 0;
                            $recurrspec['event_repeat_on_day'] = 0;
                            $recurrspec['event_repeat_on_freq'] = 0;
                        } elseif ($rfreq == _RECUR_SAME_DAY) {
                            $recurrtype = REPEAT_ON;
                            list($y, $m, $d) = explode('-', $eventdate);
                            $recurrspec['event_repeat_freq'] = 0;
                            $recurrspec['event_repeat_freq_type'] = 0;
                            // event day of week
                            $edow = Date_Calc::dayOfWeek($d, $m, $y);
                            // date of first event day of week
                            $firstDay = Date_Calc::NWeekdayOfMonth(1, $edow, $m, $y, '%Y-%m-%d');
                            // find difference between 1st day and event day
                            list($y2, $m2, $d2) = explode('-', $firstDay);
                            $diff = Date_Calc::dateDiff($d, $m, $y, $d2, $m2, $y2);
                            // assuming $diff is going to be a multiple of 7
                            if ($diff > 0) {
                                $diff /= 7;
                            }
                            if ($diff > REPEAT_ON_4TH) {
                                $diff = REPEAT_ON_LAST;
                            }
                            $recurrspec['event_repeat_on_num'] = $diff;
                            $recurrspec['event_repeat_on_day'] = $edow;
                            $recurrspec['event_repeat_on_freq'] = REPEAT_ON_MONTH;
                        }
                        break;
                    case _EVENT_YEARLY:
                        if ($rfreq == _RECUR_SAME_DATE) {
                            $recurrtype = REPEAT;
                            $recurrspec['event_repeat_freq'] = REPEAT_EVERY;
                            $recurrspec['event_repeat_freq_type'] = REPEAT_EVERY_YEAR;
                            $recurrspec['event_repeat_on_num'] = 0;
                            $recurrspec['event_repeat_on_day'] = 0;
                            $recurrspec['event_repeat_on_freq'] = 0;
                        } elseif ($rfreq == _RECUR_SAME_DAY) {
                            $recurrtype = REPEAT_ON;
                            list($y, $m, $d) = explode('-', $eventdate);
                            $recurrspec['event_repeat_freq'] = 0;
                            $recurrspec['event_repeat_freq_type'] = 0;
                            // event day of week
                            $edow = Date_Calc::dayOfWeek($d, $m, $y);
                            // date of first event day of week
                            $firstDay = Date_Calc::NWeekdayOfMonth(1, $edow, $m, $y, '%Y-%m-%d');
                            // find difference between 1st day and event day
                            list($y2, $m2, $d2) = explode('-', $firstDay);
                            $diff = Date_Calc::dateDiff($d, $m, $y, $d2, $m2, $y2);
                            // assuming $diff is going to be a multiple of 7
                            if ($diff > 0) {
                                $diff /= 7;
                            }
                            if ($diff > REPEAT_ON_4TH) {
                                $diff = REPEAT_ON_LAST;
                            }
                            $recurrspec['event_repeat_on_num'] = $diff;
                            $recurrspec['event_repeat_on_day'] = $edow;
                            $recurrspec['event_repeat_on_freq'] = REPEAT_ON_YEAR;
                        }
                        break;
                }
                // ok, figure out the event's duration
                list($sh, $sm, $ss) = explode(':', $start);
                list($eh, $em, $es) = explode(':', $end);
                $stime = mktime($sh, $sm, $ss, 1, 1, 1970);
                // if the ending hour is less than the starting hour
                // assume that the event spans to the next day
                if ($eh < $sh) {
                    $etime = mktime($eh, $em, $es, 1, 2, 1970);
                } else {
                    $etime = mktime($eh, $em, $es, 1, 1, 1970);
                }
                $duration = $etime - $stime;
                // prep the vars for the sql statement
                $eid = pnVarPrepForStore($eid);
                $recurrtype = pnVarPrepForStore($recurrtype);
                $recurrspec = pnVarPrepForStore(serialize($recurrspec));
                // create our sql statement
                $updatesql = "UPDATE {$events_table} SET \n                              pc_aid = '0',\n\t\t\t\t\t\t\t  pc_recurrtype = {$recurrtype},\n                              pc_recurrspec = '{$recurrspec}',\n                              pc_duration = {$duration},\n\t\t\t\t\t\t\t  pc_sharing = " . SHARING_GLOBAL . "\n                              WHERE pc_eid = {$eid}";
                // execute our sql statement
                $dbconn->Execute($updatesql);
                if ($dbconn->ErrorNo() != 0) {
                    die($dbconn->ErrorMsg());
                    return false;
                }
                // next event please
            }
            // all done, proceed with next upgrade step if available/necessary
            return postcalendar_upgrade('3.1');
            break;
        case '3.1':
        case '3.1.1':
        case '3.1.2':
        case '3.1.3':
        case '3.1.4':
            return postcalendar_upgrade('3.9.0');
            break;
        case '3.9.0':
        case '3.9.1':
        case '3.9.2':
            // ading pcSafeMode
            pnModSetVar(__POSTCALENDAR__, 'pcSafeMode', '0');
            return postcalendar_upgrade('3.9.3');
            break;
        case '3.9.3':
        case '3.9.3.1':
            // adding indexes
            $sql = "ALTER TABLE {$events_table} \n\t\t\t\t\tADD INDEX basic_event (pc_catid,pc_aid,pc_eventDate,pc_endDate,pc_eventstatus,pc_sharing,pc_topic)";
            $dbconn->Execute($sql);
            if ($dbconn->ErrorNo() != 0) {
                die($dbconn->ErrorMsg());
                return false;
            }
            // adding indexes
            $sql = "ALTER TABLE {$cat_table} \n\t\t\t\t\tADD INDEX basic_cat (pc_catname, pc_catcolor)";
            $dbconn->Execute($sql);
            if ($dbconn->ErrorNo() != 0) {
                die($dbconn->ErrorMsg());
                return false;
            }
            return postcalendar_upgrade('3.9.4');
            break;
        case '3.9.4':
        case '3.9.5':
        case '3.9.6':
        case '3.9.7':
            return postcalendar_upgrade('3.9.8');
            break;
        case '3.9.8':
            pnModDelVar(__POSTCALENDAR__, 'pcSafeMode');
            pnModSetVar(__POSTCALENDAR__, 'pcNotifyAdmin', '0');
            pnModSetVar(__POSTCALENDAR__, 'pcNotifyEmail', pnConfigGetVar('adminmail'));
            break;
        case '3.9.9':
            break;
    }
    // if we get this far - load the userapi and clear the cache
    if (!pnModAPILoad(__POSTCALENDAR__, 'user')) {
        return false;
    }
    $tpl =& new pcSmarty();
    $tpl->clear_all_cache();
    $tpl->clear_compiled_tpl();
    return true;
}
示例#15
0
文件: pnadmin.php 项目: grlf/eyedock
/**
 * Update module config.
 */
function Meds_admin_update_config()
{
    // Permission check.
    if (!pnSecAuthAction(0, 'Meds::', '::', ACCESS_ADMIN)) {
        return pnVarPrepHTMLDisplay(_MODULENOAUTH);
    }
    // Clean arguments from URL.
    $per_page = pnVarCleanFromInput('per_page');
    // Confirm authorizaton to carry out this function's action.
    if (!pnSecConfirmAuthKey()) {
        pnSessionSetVar('errormsg', pnVarPrepHTMLDisplay(_BADAUTHKEY));
        return pnRedirect(pnModURL('Meds', 'admin', 'main'));
    }
    // Ensure a default.
    if (empty($per_page) || !is_numeric($per_page) || $per_page < 1) {
        $per_page = 10;
    }
    // Set the module variable.
    pnModSetVar('Meds', 'per_page', (int) $per_page);
    // Start a new output object.
    $pnRender =& new pnRender('Meds');
    // Dump module cache.
    $pnRender->clear_cache();
    // Set a status message.
    pnSessionSetVar('statusmsg', _CONFIGUPDATED);
    // Let any hooks know that something occurred.
    pnModCallHooks('module', 'updateconfig', 'Meds', array('module' => 'Meds'));
    // Redirect user.
    return pnRedirect(pnModURL('Meds', 'admin', 'main'));
}