当前位置: 首页>>代码示例>>PHP>>正文


PHP log_warn函数代码示例

本文整理汇总了PHP中log_warn函数的典型用法代码示例。如果您正苦于以下问题:PHP log_warn函数的具体用法?PHP log_warn怎么用?PHP log_warn使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了log_warn函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: log

 public function log($level, &$message) {
     switch ($level) {
         case LogHelper::LEVEL_DEBUG:
             log_debug($message);
             break;
         case LogHelper::LEVEL_INFO:
             log_info($message);
             break;
         case LogHelper::LEVEL_NOTICE:
             log_notice($message);
             break;
         case LogHelper::LEVEL_WARNING:
             log_warn($message);
             break;
         case LogHelper::LEVEL_ERROR:
             log_error($message);
             break;
         case LogHelper::LEVEL_CRITICAL:
             log_critical($message);
             break;
         case LogHelper::LEVEL_ALERT:
             log_alert($message);
             break;
         case LogHelper::LEVEL_EMERGENCY:
             log_emergency($message);
             break;
     }
 }
开发者ID:reisystems-india,项目名称:GovDashboard-Community,代码行数:28,代码来源:Log4DrupalMessageListener.php

示例2: __construct

 /**
  * @param bool $forcefull Force generation of a full sitemap (non-daily)
  */
 public function __construct($forcefull = false)
 {
     $this->directory = get_config('dataroot') . 'sitemaps/';
     // on the first of the month, or if forced, generate the full sitemap
     if (date("d") == 1 || $forcefull === true) {
         $this->date_to_check = null;
         $remove = 'sitemap_*.xml';
     } else {
         // otherwise limit to 'yesterday'
         $this->date_to_check = date("Y-m-d", strtotime('yesterday'));
         $remove = 'sitemap_' . date('Ymd') . '_*.xml';
     }
     // remove any sitemaps we're about to replace
     if (!($oldsitemaps = glob($this->directory . $remove))) {
         $oldsitemaps = array();
     }
     if ($oldcompressed = glob($this->directory . $remove . '.gz')) {
         $oldsitemaps = array_merge($oldsitemaps, $oldcompressed);
     }
     foreach ($oldsitemaps as $sitemap) {
         if (!unlink($sitemap)) {
             log_warn(sprintf("Failed to remove sitemap: %s, please check directory and file permissions.", basename($sitemap)));
         }
     }
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:28,代码来源:sitemap.php

示例3: xmldb_search_elasticsearch_upgrade

function xmldb_search_elasticsearch_upgrade($oldversion = 0)
{
    if ($oldversion < 2015012800) {
        // Adding indices on the table search_elasticsearch_queue
        $table = new XMLDBTable('search_elasticsearch_queue');
        $index = new XMLDBIndex('itemidix');
        $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('itemid'));
        add_index($table, $index);
    }
    if ($oldversion < 2015060900) {
        log_debug('Add "status" and "lastprocessed" columns to search_elasticsearch_queue table');
        $table = new XMLDBTable('search_elasticsearch_queue');
        $field = new XMLDBField('status');
        $field->setAttributes(XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL, null, null, null, 0);
        add_field($table, $field);
        $table = new XMLDBTable('search_elasticsearch_queue');
        $field = new XMLDBField('lastprocessed');
        $field->setAttributes(XMLDB_TYPE_DATETIME);
        add_field($table, $field);
        $table = new XMLDBTable('search_elasticsearch_queue');
        $index = new XMLDBIndex('statusix');
        $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('status'));
        add_index($table, $index);
    }
    if ($oldversion < 2015072700) {
        log_debug('Adding ability to search by "Text" blocks in elasticsearch');
        // Need to add the 'block_instance' to the default types to index for elasticsearch
        // Note: the $cfg->plugin_search_elasticsearch_types can be overriding this
        // We don't want to run the re-indexing now as that will take ages for large sites
        // It should be run from the  Extensions -> Elasticsearch -> Configuration page
        if ($types = get_field('search_config', 'value', 'plugin', 'elasticsearch', 'field', 'types')) {
            $types = explode(',', $types);
            if (!in_array('block_instance', $types)) {
                $types[] = 'block_instance';
            }
            $types = implode(',', $types);
            update_record('search_config', array('value' => $types), array('plugin' => 'elasticsearch', 'field' => 'types'));
            log_warn(get_string('newindextype', 'search.elasticsearch', 'block_instance'), true, false);
        }
    }
    if ($oldversion < 2015100800) {
        log_debug('Adding ability to search by collection in elasticsearch');
        // The code for this existed since the beginning but 'collection' was not
        // added to the $cfg->plugin_search_elasticsearch_types
        // We don't want to run the re-indexing now as that will take ages for large sites
        // It should be run from the  Extensions -> Elasticsearch -> Configuration page
        if ($types = get_field('search_config', 'value', 'plugin', 'elasticsearch', 'field', 'types')) {
            $types = explode(',', $types);
            if (!in_array('collection', $types)) {
                $types[] = 'collection';
            }
            $types = implode(',', $types);
            update_record('search_config', array('value' => $types), array('plugin' => 'elasticsearch', 'field' => 'types'));
            log_warn(get_string('newindextype', 'search.elasticsearch', 'collection'), true, false);
        }
    }
    return true;
}
开发者ID:sarahjcotton,项目名称:mahara,代码行数:58,代码来源:upgrade.php

示例4: Dwoo_Plugin_theme_path

/**
 * Dwoo {theme_path} function plugin
 *
 * Type:     function<br>
 * Name:     theme_path<br>
 * Date:     June 22, 2006<br>
 * Purpose:  Fetch the image according to the theme hierarchy
 * @author   Catalyst IT Ltd
 * @version  1.0
 * @return Internationalized string
 */
function Dwoo_Plugin_theme_path(Dwoo $dwoo, $location, $pluginlocation = null)
{
    global $THEME;
    log_warn("The dwoo modifier theme_path is deprecated: please use theme_url");
    $plugintype = $pluginname = '';
    if ($pluginlocation) {
        list($plugintype, $pluginname) = explode('/', $pluginlocation);
    }
    return $THEME->get_url($location, false, $plugintype, $pluginname);
}
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:21,代码来源:function.theme_path.php

示例5: pieform_element_wysiwyg

/**
 * Renders a textarea, but with extra javascript to turn it into a wysiwyg
 * textarea.
 *
 * @todo support resizable.
 *
 * @param array   $element The element to render
 * @param Pieform $form    The form to render the element for
 * @return string          The HTML for the element
 */
function pieform_element_wysiwyg(Pieform $form, $element)
{
    global $_PIEFORM_WYSIWYGS;
    $_PIEFORM_WYSIWYGS[] = $form->get_name() . '_' . $element['name'];
    if (is_html_editor_enabled()) {
        if (!$form->get_property('elementclasses')) {
            $element['class'] = isset($element['class']) && $element['class'] !== '' ? $element['class'] . ' wysiwyg' : 'wysiwyg';
        }
    }
    $rows = $cols = $style = '';
    if (isset($element['height'])) {
        $style .= 'height:' . $element['height'] . ';';
        $rows = intval($element['height'] > 0) ? ceil(intval($element['height']) / 10) : 1;
    } elseif (isset($element['rows'])) {
        $rows = $element['rows'];
    } else {
        log_warn('No value for rows or height specified for textarea ' . $element['name']);
    }
    if (isset($element['width'])) {
        $style .= 'width:' . $element['width'] . ';';
        $cols = intval($element['width'] > 0) ? ceil(intval($element['width']) / 10) : 1;
    } elseif (isset($element['cols'])) {
        $cols = $element['cols'];
    } else {
        log_warn('No value for cols or width specified for textarea ' . $element['name']);
    }
    $element['style'] = isset($element['style']) ? $style . $element['style'] : $style;
    if (is_html_editor_enabled()) {
        $value = Pieform::hsc($form->get_value($element));
    } else {
        // Replace <br>s as added by wysiwyg editor or nl2br with a newline
        $value = preg_replace("#<br />\\s#", "\n", $form->get_value($element));
        // As placed in the value by the wysiwyg editor
        $value = str_replace('</p><p>', "\n\n", $value);
        // Find the last </p> and replace with newlines
        $value = preg_replace('#</p>\\s#', "\n", $value);
        $value = strip_tags($value);
    }
    return '<textarea' . ($rows ? ' rows="' . $rows . '"' : '') . ($cols ? ' cols="' . $cols . '"' : '') . $form->element_attributes($element, array('maxlength', 'size')) . '>' . $value . '</textarea>';
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:50,代码来源:wysiwyg.php

示例6: denyregistration_submit

function denyregistration_submit(Pieform $form, $values)
{
    global $USER, $SESSION;
    if (isset($values['message']) && !empty($values['message'])) {
        $message = get_string('registrationdeniedmessagereason', 'auth.internal', $values['firstname'], get_config('sitename'), $values['message'], display_name($USER));
    } else {
        $message = get_string('registrationdeniedmessage', 'auth.internal', $values['firstname'], get_config('sitename'), display_name($USER));
    }
    try {
        delete_records('usr_registration', 'email', $values['email']);
        $user = (object) $values;
        $user->admin = 0;
        $user->staff = 0;
        email_user($user, $USER, get_string('registrationdeniedemailsubject', 'auth.internal', get_config('sitename')), $message);
    } catch (EmailException $e) {
        log_warn($e);
        die_info(get_string('registrationdeniedunsuccessful', 'admin'));
    } catch (SQLException $e) {
        log_warn($e);
        die_info(get_string('registrationdeniedunsuccessful', 'admin'));
    }
    $SESSION->add_ok_msg(get_string('registrationdeniedsuccessful', 'admin'));
    redirect('/admin/users/pendingregistrations.php?institution=' . $values['institution']);
}
开发者ID:kienv,项目名称:mahara,代码行数:24,代码来源:actionregistration.php

示例7: watchlist_process_notifications

/**
 * is called by the cron-job to process the notifications stored into
 * watchlist_queue.
 */
function watchlist_process_notifications()
{
    $delayMin = get_config('watchlistnotification_delay');
    $comparetime = time() - $delayMin * 60;
    $sql = "SELECT usr, view, MAX(changed_on) AS time\n            FROM {watchlist_queue}\n            GROUP BY usr, view";
    $results = get_records_sql_array($sql, array());
    if (false === $results) {
        return;
    }
    foreach ($results as $viewuserdaterow) {
        if ($viewuserdaterow->time > date('Y-m-d H:i:s', $comparetime)) {
            continue;
        }
        // don't send a notification if only blockinstances are referenced
        // that were deleted (block exists but corresponding
        // block_instance doesn't)
        $sendnotification = false;
        $blockinstance_ids = get_column('watchlist_queue', 'block', 'usr', $viewuserdaterow->usr, 'view', $viewuserdaterow->view);
        if (is_array($blockinstance_ids)) {
            $blockinstance_ids = array_unique($blockinstance_ids);
        }
        $viewuserdaterow->blocktitles = array();
        // need to check if view has an owner, group or institution
        $view = get_record('view', 'id', $viewuserdaterow->view);
        if (empty($view->owner) && empty($view->group) && empty($view->institution)) {
            continue;
        }
        // ignore root pages, owner = 0, this account is not meant to produce content
        if (isset($view->owner) && empty($view->owner)) {
            continue;
        }
        foreach ($blockinstance_ids as $blockinstance_id) {
            if (empty($blockinstance_id)) {
                // if no blockinstance is given, assume that the form itself
                // was changed, e.g. the theme, or a block was removed
                $sendnotification = true;
                continue;
            }
            require_once get_config('docroot') . 'blocktype/lib.php';
            try {
                $block = new BlockInstance($blockinstance_id);
            } catch (BlockInstanceNotFoundException $exc) {
                // maybe the block was deleted
                continue;
            }
            $blocktype = $block->get('blocktype');
            $title = '';
            // try to get title rendered by plugin-class
            safe_require('blocktype', $blocktype);
            if (class_exists(generate_class_name('blocktype', $blocktype))) {
                $title = $block->get_title();
            } else {
                log_warn('class for blocktype could not be loaded: ' . $blocktype);
                $title = $block->get('title');
            }
            // if no title was given to the blockinstance, try to get one
            // from the artefact
            if (empty($title)) {
                $configdata = $block->get('configdata');
                if (array_key_exists('artefactid', $configdata)) {
                    try {
                        $artefact = $block->get_artefact_instance($configdata['artefactid']);
                        $title = $artefact->get('title');
                    } catch (Exception $exc) {
                        log_warn('couldn\'t identify title of blockinstance ' . $block->get('id') . $exc->getMessage());
                    }
                }
            }
            // still no title, maybe the default-name for the blocktype
            if (empty($title)) {
                $title = get_string('title', 'blocktype.' . $blocktype);
            }
            // no title could be retrieved, so let's tell the user at least
            // what type of block was changed
            if (empty($title)) {
                $title = '[' . $blocktype . '] (' . get_string('nonamegiven', 'activity') . ')';
            }
            $viewuserdaterow->blocktitles[] = $title;
            $sendnotification = true;
        }
        // only send notification if there is something to talk about (don't
        // send notification for example when new blockelement was aborted)
        if ($sendnotification) {
            try {
                $watchlistnotification = new ActivityTypeWatchlistnotification($viewuserdaterow, false);
                $watchlistnotification->notify_users();
            } catch (ViewNotFoundException $exc) {
                // Seems like the view has been deleted, don't do anything
            } catch (SystemException $exc) {
                // if the view that was changed doesn't have an owner
            }
        }
        delete_records('watchlist_queue', 'usr', $viewuserdaterow->usr, 'view', $viewuserdaterow->view);
    }
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:99,代码来源:activity.php

示例8: mahara_http_request

function mahara_http_request($config)
{
    $ch = curl_init();
    // standard curl_setopt stuff; configs passed to the function can override these
    curl_setopt($ch, CURLOPT_TIMEOUT, 60);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_MAXREDIRS, 5);
    curl_setopt_array($ch, $config);
    if ($proxy_address = get_config('proxyaddress')) {
        curl_setopt($ch, CURLOPT_PROXY, $proxy_address);
        if ($proxy_authmodel = get_config('proxyauthmodel') && ($proxy_credentials = get_config('proxyauthcredentials'))) {
            // todo: actually do something with $proxy_authmodel
            curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxy_credentials);
        }
    }
    if (strpos($config[CURLOPT_URL], 'https://') === 0) {
        if ($cainfo = get_config('cacertinfo')) {
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
            curl_setopt($ch, CURLOPT_CAINFO, $cainfo);
        }
    }
    $result = new StdClass();
    $result->data = curl_exec($ch);
    $result->info = curl_getinfo($ch);
    $result->error = curl_error($ch);
    $result->errno = curl_errno($ch);
    if ($result->errno) {
        log_warn('Curl error: ' . $result->errno . ': ' . $result->error);
    }
    curl_close($ch);
    return $result;
}
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:33,代码来源:web.php

示例9: check_upgrades

/**
 * This function checks core and plugins for which need to be upgraded/installed
 *
 * @param string $name The name of the plugin to check. If no name is specified,
 *                     all plugins are checked.
 * @return array of objects
 */
function check_upgrades($name = null)
{
    $pluginstocheck = plugin_types();
    $toupgrade = array();
    $installing = false;
    $disablelogin = false;
    require 'version.php';
    if (isset($config->disablelogin) && !empty($config->disablelogin)) {
        $disablelogin = true;
    }
    // check core first...
    if (empty($name) || $name == 'core') {
        try {
            $coreversion = get_config('version');
        } catch (Exception $e) {
            $coreversion = 0;
        }
        if (empty($coreversion)) {
            if (is_mysql()) {
                // Show a more informative error message if using mysql with skip-innodb
                global $db;
                $result = $db->Execute("SHOW VARIABLES LIKE 'have_innodb'");
                if ($result->fields['Value'] != 'YES') {
                    throw new ConfigSanityException("Mahara requires InnoDB tables.  Please ensure InnoDB tables are enabled in your MySQL server.");
                }
            }
            $core = new StdClass();
            $core->install = true;
            $core->to = $config->version;
            $core->torelease = $config->release;
            $toupgrade['core'] = $core;
            $installing = true;
        } else {
            if ($config->version > $coreversion) {
                $corerelease = get_config('release');
                if (isset($config->minupgradefrom) && isset($config->minupgraderelease) && $coreversion < $config->minupgradefrom) {
                    throw new ConfigSanityException("Must upgrade to {$config->minupgradefrom} " . "({$config->minupgraderelease}) first " . " (you have {$coreversion} ({$corerelease})");
                }
                $core = new StdClass();
                $core->upgrade = true;
                $core->from = $coreversion;
                $core->fromrelease = $corerelease;
                $core->to = $config->version;
                $core->torelease = $config->release;
                $toupgrade['core'] = $core;
            }
        }
    }
    // If we were just checking if the core needed to be upgraded, we can stop here
    if ($name == 'core') {
        $toupgrade['core']->disablelogin = $disablelogin;
        return $toupgrade['core'];
    }
    $plugins = array();
    if (!empty($name)) {
        try {
            $bits = explode('.', $name);
            $pt = $bits[0];
            $pn = $bits[1];
            $pp = null;
            if ($pt == 'blocktype' && strpos($pn, '/') !== false) {
                $bits = explode('/', $pn);
                $pp = get_config('docroot') . 'artefact/' . $bits[0] . '/blocktype/' . $bits[1];
            }
            validate_plugin($pt, $pn, $pp);
            $plugins[] = explode('.', $name);
        } catch (InstallationException $_e) {
            log_warn("Plugin {$pt} {$pn} is not installable: " . $_e->GetMessage());
        }
    } else {
        foreach ($pluginstocheck as $plugin) {
            $dirhandle = opendir(get_config('docroot') . $plugin);
            while (false !== ($dir = readdir($dirhandle))) {
                if (strpos($dir, '.') === 0) {
                    continue;
                }
                if (!is_dir(get_config('docroot') . $plugin . '/' . $dir)) {
                    continue;
                }
                try {
                    validate_plugin($plugin, $dir);
                    $plugins[] = array($plugin, $dir);
                } catch (InstallationException $_e) {
                    log_warn("Plugin {$plugin} {$dir} is not installable: " . $_e->GetMessage());
                }
                if ($plugin == 'artefact') {
                    // go check it for blocks as well
                    $btlocation = get_config('docroot') . $plugin . '/' . $dir . '/blocktype';
                    if (!is_dir($btlocation)) {
                        continue;
                    }
                    $btdirhandle = opendir($btlocation);
                    while (false !== ($btdir = readdir($btdirhandle))) {
//.........这里部分代码省略.........
开发者ID:Br3nda,项目名称:mahara,代码行数:101,代码来源:upgrade.php

示例10: request_user_authorise

 /**
  * Grab a delegate object for auth stuff
  */
 public function request_user_authorise($token, $remotewwwroot)
 {
     global $USER, $SESSION;
     $this->must_be_ready();
     $peer = get_peer($remotewwwroot);
     if ($peer->deleted != 0 || $this->config['theyssoin'] != 1) {
         throw new XmlrpcClientException('We don\'t accept SSO connections from ' . institution_display_name($peer->institution));
     }
     $client = new Client();
     $client->set_method('auth/mnet/auth.php/user_authorise')->add_param($token)->add_param(sha1($_SERVER['HTTP_USER_AGENT']))->send($remotewwwroot);
     $remoteuser = (object) $client->response;
     if (empty($remoteuser) or !property_exists($remoteuser, 'username')) {
         // Caught by land.php
         throw new AccessDeniedException();
     }
     $create = false;
     $update = false;
     if ('1' == $this->config['updateuserinfoonlogin']) {
         $update = true;
     }
     // Retrieve a $user object. If that fails, create a blank one.
     try {
         $user = new User();
         if (get_config('usersuniquebyusername')) {
             // When turned on, this setting means that it doesn't matter
             // which other application the user SSOs from, they will be
             // given the same account in Mahara.
             //
             // This setting is one that has security implications unless
             // only turned on by people who know what they're doing. In
             // particular, every system linked to Mahara should be making
             // sure that same username == same person.  This happens for
             // example if two Moodles are using the same LDAP server for
             // authentication.
             //
             // If this setting is on, it must NOT be possible to self
             // register on the site for ANY institution - otherwise users
             // could simply pick usernames of people's accounts they wished
             // to steal.
             if ($institutions = get_column('institution', 'name', 'registerallowed', '1')) {
                 log_warn("usersuniquebyusername is turned on but registration is allowed for an institution. " . "No institution can have registration allowed for it, for security reasons.\n" . "The following institutions have registration enabled:\n  " . join("\n  ", $institutions));
                 throw new AccessDeniedException();
             }
             if (!get_config('usersallowedmultipleinstitutions')) {
                 log_warn("usersuniquebyusername is turned on but usersallowedmultipleinstitutions is off. " . "This makes no sense, as users will then change institution every time they log in from " . "somewhere else. Please turn this setting on in Site Options");
                 throw new AccessDeniedException();
             }
             $user->find_by_username($remoteuser->username);
         } else {
             $user->find_by_instanceid_username($this->instanceid, $remoteuser->username, true);
         }
         if ($user->get('suspendedcusr')) {
             die_info(get_string('accountsuspended', 'mahara', strftime(get_string('strftimedaydate'), $user->get('suspendedctime')), $user->get('suspendedreason')));
         }
     } catch (AuthUnknownUserException $e) {
         if (!empty($this->config['weautocreateusers'])) {
             $institution = new Institution($this->institution);
             if ($institution->isFull()) {
                 $institution->send_admin_institution_is_full_message();
                 throw new XmlrpcClientException('SSO attempt from ' . $institution->displayname . ' failed - institution is full');
             }
             $user = new User();
             $create = true;
         } else {
             log_debug("User authorisation request from {$remotewwwroot} failed - " . "remote user '{$remoteuser->username}' is unknown to us and auto creation of users is turned off");
             return false;
         }
     }
     /*******************************************/
     if ($create) {
         $user->passwordchange = 1;
         $user->active = 1;
         $user->deleted = 0;
         //TODO: import institution's expiry?:
         //$institution = new Institution($peer->institution);
         $user->expiry = null;
         $user->expirymailsent = 0;
         $user->lastlogin = time();
         $user->firstname = $remoteuser->firstname;
         $user->lastname = $remoteuser->lastname;
         $user->email = $remoteuser->email;
         $imported = array('firstname', 'lastname', 'email');
         //TODO: import institution's per-user-quota?:
         //$user->quota              = $userrecord->quota;
         $user->authinstance = empty($this->config['parent']) ? $this->instanceid : $this->parent;
         db_begin();
         $user->username = get_new_username($remoteuser->username);
         $user->id = create_user($user, array(), $this->institution, $this, $remoteuser->username);
         $locked = $this->import_user_settings($user, $remoteuser);
         $locked = array_merge($imported, $locked);
         /*
          * We need to convert the object to a stdclass with its own
          * custom method because it uses overloaders in its implementation
          * and its properties wouldn't be visible to a simple cast operation
          * like (array)$user
          */
         $userobj = $user->to_stdclass();
//.........这里部分代码省略.........
开发者ID:rboyatt,项目名称:mahara,代码行数:101,代码来源:lib.php

示例11: init_theme

 /**
  * Given a theme name, reads in all config and sets fields on this object
  */
 private function init_theme($themename, $themedata)
 {
     // A little anonymous function to retrieve *only* the $theme variable from
     // the themeconfig.php file
     $getthemeconfig = function ($themename) {
         $themeconfigfile = get_config('docroot') . 'theme/' . $themename . '/themeconfig.php';
         if (is_readable($themeconfigfile)) {
             require get_config('docroot') . 'theme/' . $themename . '/themeconfig.php';
             return $theme;
         } else {
             return false;
         }
     };
     $themeconfig = $getthemeconfig($themename);
     if (!$themeconfig) {
         // We can safely assume that the default theme is installed, users
         // should never be able to remove it
         $themename = 'default';
         $themeconfig = $getthemeconfig($themename);
     }
     $this->basename = $themename;
     foreach (get_object_vars($themeconfig) as $key => $value) {
         $this->{$key} = $value;
     }
     if (!isset($this->displayname)) {
         $this->displayname = $this->basename;
     }
     // Local theme overrides come first
     $this->templatedirs[] = get_config('docroot') . 'local/theme/templates/';
     // Then the current theme
     $this->templatedirs[] = get_config('docroot') . 'theme/' . $this->basename . '/templates/';
     $this->inheritance[] = $this->basename;
     // 'raw' is the default parent theme
     // (If a theme has no parent, it should set $themeconfig->parent = false)
     if (!isset($themeconfig->parent)) {
         $themeconfig->parent = 'raw';
     }
     $currentthemename = $this->basename;
     while ($themeconfig->parent !== false) {
         // Now go through the theme hierarchy assigning variables from the
         // parent themes
         $parentthemename = $themeconfig->parent;
         $parentthemeconfig = $getthemeconfig($parentthemename);
         // If the parent theme is missing, short-circuit to the "raw" theme
         if (!$parentthemeconfig) {
             log_warn("Theme \"{$currentthemename}\" has missing parent theme \"{$parentthemename}\".");
             $parentthemename = 'raw';
             $parentthemeconfig = $getthemeconfig($parentthemename);
         }
         $currentthemename = $parentthemename;
         $themeconfig = $parentthemeconfig;
         foreach (get_object_vars($themeconfig) as $key => $value) {
             if (!isset($this->{$key}) || !$this->{$key}) {
                 $this->{$key} = $value;
             }
         }
         $this->templatedirs[] = get_config('docroot') . 'theme/' . $currentthemename . '/templates/';
         $this->inheritance[] = $currentthemename;
         if (!isset($themeconfig->parent)) {
             $themeconfig->parent = 'raw';
         }
     }
     if (!empty($themedata->headerlogo)) {
         $this->headerlogo = $themedata->headerlogo;
     }
     if (!empty($themedata->stylesheets)) {
         $this->addedstylesheets = $themedata->stylesheets;
     }
 }
开发者ID:sarahjcotton,项目名称:mahara,代码行数:72,代码来源:web.php

示例12: parse_xhtmlish_content

 /**
  * given some content that might be html or xhtml, try to coerce it to xhtml and return it.
  *
  * @param string $content some html or xhtmlish content
  *
  * @return xhtml content or false for unmodified text content
  */
 public static function parse_xhtmlish_content($content, $viewid = null)
 {
     $dom = new DomDocument();
     $topel = $dom->createElement('tmp');
     $tmp = new DomDocument();
     if (strpos($content, '<') === false && strpos($content, '>') === false) {
         return false;
     }
     if (@$tmp->loadXML('<div>' . $content . '</div>')) {
         $topel->setAttribute('type', 'xhtml');
         $content = $dom->importNode($tmp->documentElement, true);
         $content->setAttribute('xmlns', 'http://www.w3.org/1999/xhtml');
         $topel->appendChild($content);
         // if that fails, it could still be html
         // DomDocument::loadHTML() parses the input as iso-8859-1 if no
         // encoding is declared. Since we are only loading a HTML fragment
         // there is no  encoding declared which results in garbled output
         // since the content is actually in utf-8. To work around this
         // we force the encoding by appending an xml declaration.
         // see http://php.net/manual/de/domdocument.loadhtml.php#95251
     } else {
         if (@$tmp->loadHTML('<?xml encoding="UTF-8"><div>' . $content . '</div>')) {
             $xpath = new DOMXpath($tmp);
             $elements = $xpath->query('/html/body/div');
             if ($elements->length != 1) {
                 if ($viewid) {
                     log_warn("Leap2a export: invalid html found in view {$viewid}");
                 }
                 if ($elements->length < 1) {
                     return false;
                 }
             }
             $ourelement = $elements->item(0);
             $content = $dom->importNode($ourelement, true);
             $content->setAttribute('xmlns', 'http://www.w3.org/1999/xhtml');
             $topel->appendChild($content);
         } else {
             return false;
             // wtf is it then?
         }
     }
     $dom->appendChild($topel->firstChild);
     return $dom->saveXML($dom->documentElement);
 }
开发者ID:sarahjcotton,项目名称:mahara,代码行数:51,代码来源:lib.php

示例13: get_installed_plugins_paths

/**
 * Returns all directories of installed plugins except for local
 * from the current codebase.
 *
 * This is relatively slow and not fully cached, use with care!
 *
 * @return array ('plugintkey' => path, ...)
 * For example, array (
 *     'artefact.blog' => $CFG->docroot . 'artefact/blog',
 *     'blocktype.blog' => $CFG->docroot . 'artefact/blog/blocktype/blog',
 *     ...
 * )
 */
function get_installed_plugins_paths()
{
    $versions = array();
    // All installed plugins
    $plugins = array();
    foreach (plugin_types_installed() as $plugin) {
        $dirhandle = opendir(get_config('docroot') . $plugin);
        while (false !== ($dir = readdir($dirhandle))) {
            if (strpos($dir, '.') === 0 || 'CVS' == $dir) {
                continue;
            }
            if (!is_dir(get_config('docroot') . $plugin . '/' . $dir)) {
                continue;
            }
            try {
                validate_plugin($plugin, $dir);
                $plugins[] = array($plugin, $dir);
            } catch (InstallationException $_e) {
                log_warn("Plugin {$plugin} {$dir} is not installable: " . $_e->GetMessage());
            }
            if ($plugin === 'artefact') {
                // go check it for blocks as well
                $btlocation = get_config('docroot') . $plugin . '/' . $dir . '/blocktype';
                if (!is_dir($btlocation)) {
                    continue;
                }
                $btdirhandle = opendir($btlocation);
                while (false !== ($btdir = readdir($btdirhandle))) {
                    if (strpos($btdir, '.') === 0 || 'CVS' == $btdir) {
                        continue;
                    }
                    if (!is_dir(get_config('docroot') . $plugin . '/' . $dir . '/blocktype/' . $btdir)) {
                        continue;
                    }
                    $plugins[] = array('blocktype', $dir . '/' . $btdir);
                }
            }
        }
    }
    $pluginpaths = array();
    foreach ($plugins as $plugin) {
        $plugintype = $plugin[0];
        $pluginname = $plugin[1];
        $pluginpath = "{$plugin['0']}/{$plugin['1']}";
        $pluginkey = "{$plugin['0']}.{$plugin['1']}";
        if ($plugintype == 'blocktype' && strpos($pluginname, '/') !== false) {
            $bits = explode('/', $pluginname);
            $pluginpath = 'artefact/' . $bits[0] . '/blocktype/' . $bits[1];
        }
        $pluginpaths[$pluginkey] = get_config('docroot') . $pluginpath;
    }
    return $pluginpaths;
}
开发者ID:kienv,项目名称:mahara,代码行数:66,代码来源:mahara.php

示例14: update_active_flag

 public static function update_active_flag($event, $user)
 {
     if (!isset($user['id'])) {
         log_warn("update_active_flag called without a user id");
     }
     if ($user['id'] === 0 || $user['id'] === '0') {
         return;
     }
     $active = true;
     // ensure we have everything we need
     $user = get_user($user['id']);
     $inactivetime = get_config('defaultaccountinactiveexpire');
     if ($user->suspendedcusr) {
         $active = false;
     } else {
         if ($user->expiry && $user->expiry < time()) {
             $active = false;
         } else {
             if ($inactivetime) {
                 $lastactive = max($user->lastlogin, $user->lastaccess, $user->ctime);
                 if ($lastactive && $lastactive + $inactivetime < time()) {
                     $active = false;
                 }
             } else {
                 if ($user->deleted) {
                     $active = false;
                 }
             }
         }
     }
     if ($active != $user->active) {
         set_field('usr', 'active', (int) $active, 'id', $user->id);
     }
 }
开发者ID:janaece,项目名称:globalclassroom4_clean-old,代码行数:34,代码来源:lib.php

示例15: define

define('TITLE', '');
require dirname(dirname(__FILE__)) . '/init.php';
require_once get_config('docroot') . 'artefact/lib.php';
require_once get_config('docroot') . 'import/lib.php';
require_once get_config('docroot') . 'export/lib.php';
require_once get_config('docroot') . 'lib/activity.php';
require_once get_config('docroot') . 'lib/file.php';
// This is here for debugging purposes, it allows us to fake the time to test
// cron behaviour
$realstart = time();
$fake = isset($argv[1]);
$start = $fake ? strtotime($argv[1]) : $realstart;
log_info('---------- cron running ' . date('r', $start) . ' ----------');
raise_memory_limit('128M');
if (!is_writable(get_config('dataroot'))) {
    log_warn("Unable to write to dataroot directory.");
}
// for each plugin type
foreach (plugin_types() as $plugintype) {
    $table = $plugintype . '_cron';
    // get list of cron jobs to run for this plugin type
    $now = $fake ? time() - ($realstart - $start) : time();
    $jobs = get_records_select_array($table, 'nextrun < ? OR nextrun IS NULL', array(db_format_timestamp($now)), '', 'plugin,callfunction,minute,hour,day,month,dayofweek,' . db_format_tsfield('nextrun'));
    if ($jobs) {
        // for each cron entry
        foreach ($jobs as $job) {
            if (!cron_lock($job, $start, $plugintype)) {
                continue;
            }
            // If some other cron instance ran the job while we were messing around,
            // skip it.
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:31,代码来源:cron.php


注:本文中的log_warn函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。