Пример #1
0
        ?>
						</div>

						<?php 
        do_action('bbp_theme_after_reply_form_subscription');
        ?>
					<?php 
    }
    ?>

					<?php 
    if (bbp_allow_revisions() && bbp_is_reply_edit()) {
        ?>

					 <?php 
        if (MY_USER_EDIT_LOG_OPTION || user_can($user, 'administrator') || array_key_exists('administrator', $my_uroles) || lti_site_admin() || array_key_exists('bbp_moderator', $my_uroles) || array_key_exists('bbp_keymaster', $my_uroles) || array_key_exists('bbp_blocked', $my_uroles)) {
            ?>

						<?php 
            do_action('bbp_theme_before_reply_form_revisions');
            ?>

						<div class="bbp-form">
							<div class="checkbox">
								<input name="bbp_log_reply_edit" id="bbp_log_reply_edit" type="checkbox" value="1" <?php 
            bbp_form_reply_log_edit();
            ?>
 tabindex="<?php 
            bbp_tab_index();
            ?>
" />
Пример #2
0
/**
 * 
 * Create table to store the consumers ands passwords if not exists
 */
function lti_maybe_create_db()
{
    global $wpdb;
    get_lti_hash();
    // initialise the remote login hash
    $wpdb->ltitable = $wpdb->base_prefix . 'lti_consumer';
    if (lti_site_admin()) {
        $created = 0;
        if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->ltitable}'") != $wpdb->ltitable) {
            $wpdb->query("CREATE TABLE IF NOT EXISTS `{$wpdb->ltitable}` (\r\n\t\t\t\tconsumer_key varchar(255) NOT NULL,\r\n\t\t\t\t  name varchar(45) NOT NULL,\r\n\t\t\t\t  secret varchar(32) NOT NULL,\r\n\t\t\t\t  lti_version varchar(12) DEFAULT NULL,\r\n\t\t\t\t  consumer_name varchar(255) DEFAULT NULL,\r\n\t\t\t\t  consumer_version varchar(255) DEFAULT NULL,\r\n\t\t\t\t  consumer_guid varchar(255) DEFAULT NULL,\r\n\t\t\t\t  css_path varchar(255) DEFAULT NULL,\r\n\t\t\t\t  protected tinyint(1) NOT NULL,\r\n\t\t\t\t  enabled tinyint(1) NOT NULL,\r\n\t\t\t\t  enable_from datetime DEFAULT NULL,\r\n\t\t\t\t  enable_until datetime DEFAULT NULL,\r\n\t\t\t\t  last_access date DEFAULT NULL,\r\n\t\t\t\t  custom_username_parameter varchar(255) DEFAULT NULL,\r\n\t\t\t\t  has_custom_username_parameter decimal(1,0) default 0,\r\n\t\t\t\t  created datetime NOT NULL,\r\n\t\t\t\t  updated datetime NOT NULL,\r\n\t\t\t\t  PRIMARY KEY (consumer_key)\r\n\t\t\t\t) ENGINE=InnoDB DEFAULT CHARSET=latin1;");
            $wpdb->query("CREATE TABLE IF NOT EXISTS `" . $wpdb->base_prefix . "lti_context` (\r\n\t\t\t\t\t\t  consumer_key varchar(255) NOT NULL,\r\n\t\t\t\t\t\t  context_id varchar(255) NOT NULL,\r\n\t\t\t\t\t\t  lti_context_id varchar(255) DEFAULT NULL,\r\n\t\t\t\t\t\t  lti_resource_id varchar(255) DEFAULT NULL,\r\n\t\t\t\t\t\t  title varchar(255) NOT NULL,\r\n\t\t\t\t\t\t  settings text,\r\n\t\t\t\t\t\t  primary_consumer_key varchar(255) DEFAULT NULL,\r\n\t\t\t\t\t\t  primary_context_id varchar(255) DEFAULT NULL,\r\n\t\t\t\t\t\t  share_approved tinyint(1) DEFAULT NULL,\r\n\t\t\t\t\t\t  created datetime NOT NULL,\r\n\t\t\t\t\t\t  updated datetime NOT NULL,\r\n\t\t\t\t\t\t  PRIMARY KEY (consumer_key, context_id)\r\n\t\t\t\t\t\t) ENGINE=InnoDB DEFAULT CHARSET=latin1;");
            $wpdb->query("CREATE TABLE IF NOT EXISTS `" . $wpdb->base_prefix . "lti_user` (\r\n\t\t\t\t\t\t  consumer_key varchar(255) NOT NULL,\r\n\t\t\t\t\t\t  context_id varchar(255) NOT NULL,\r\n\t\t\t\t\t\t  user_id varchar(255) NOT NULL,\r\n\t\t\t\t\t\t  lti_result_sourcedid varchar(255) NOT NULL,\r\n\t\t\t\t\t\t  created datetime NOT NULL,\r\n\t\t\t\t\t\t  updated datetime NOT NULL,\r\n\t\t\t\t\t\t  PRIMARY KEY (consumer_key, context_id, user_id)\r\n\t\t\t\t\t\t) ENGINE=InnoDB DEFAULT CHARSET=latin1;");
            $wpdb->query("CREATE TABLE IF NOT EXISTS `" . $wpdb->base_prefix . "lti_nonce` (\r\n\t\t\t\t\t\t  consumer_key varchar(255) NOT NULL,\r\n\t\t\t\t\t\t  value varchar(32) NOT NULL,\r\n\t\t\t\t\t\t  expires datetime NOT NULL,\r\n\t\t\t\t\t\t  PRIMARY KEY (consumer_key, value)\r\n\t\t\t\t\t\t) ENGINE=InnoDB DEFAULT CHARSET=latin1;");
            $wpdb->query("CREATE TABLE IF NOT EXISTS `" . $wpdb->base_prefix . "lti_share_key` (\r\n\t\t\t\t\t\t  share_key_id varchar(32) NOT NULL,\r\n\t\t\t\t\t\t  primary_consumer_key varchar(255) NOT NULL,\r\n\t\t\t\t\t\t  primary_context_id varchar(255) NOT NULL,\r\n\t\t\t\t\t\t  auto_approve tinyint(1) NOT NULL,\r\n\t\t\t\t\t\t  expires datetime NOT NULL,\r\n\t\t\t\t\t\t  PRIMARY KEY (share_key_id)\r\n\t\t\t\t\t\t) ENGINE=InnoDB DEFAULT CHARSET=latin1;");
            $wpdb->query("ALTER TABLE " . $wpdb->base_prefix . "lti_context\r\n  ADD CONSTRAINT " . $wpdb->base_prefix . "lti_context_consumer_FK1 FOREIGN KEY (consumer_key)\r\n   REFERENCES " . $wpdb->base_prefix . "lti_consumer (consumer_key);");
            $wpdb->query("ALTER TABLE " . $wpdb->base_prefix . "lti_context\r\n  ADD CONSTRAINT " . $wpdb->base_prefix . "lti_context_context_FK1 FOREIGN KEY (primary_consumer_key, primary_context_id)\r\n   REFERENCES " . $wpdb->base_prefix . "lti_context (consumer_key, context_id);");
            $wpdb->query("ALTER TABLE " . $wpdb->base_prefix . "lti_user\r\n  ADD CONSTRAINT " . $wpdb->base_prefix . "lti_user_context_FK1 FOREIGN KEY (consumer_key, context_id)\r\n   REFERENCES " . $wpdb->base_prefix . "lti_context (consumer_key, context_id);");
            $wpdb->query("ALTER TABLE " . $wpdb->base_prefix . "lti_nonce\r\n  ADD CONSTRAINT " . $wpdb->base_prefix . "lti_nonce_consumer_FK1 FOREIGN KEY (consumer_key)\r\n   REFERENCES " . $wpdb->base_prefix . "lti_consumer (consumer_key);");
            $wpdb->query("ALTER TABLE " . $wpdb->base_prefix . "lti_share_key\r\n  ADD CONSTRAINT " . $wpdb->base_prefix . "lti_share_key_context_FK1 FOREIGN KEY (primary_consumer_key, primary_context_id)\r\n   REFERENCES " . $wpdb->base_prefix . "lti_context (consumer_key, context_id);");
            $created = 1;
        }
        if ($created) {
            ?>
 <div id="message" class="updated fade"><p><strong><?php 
            _e('LTI database tables created.', 'wordpress-mu-lti');
            ?>
</strong></p></div> <?php 
        }
    }
}
Пример #3
0
function set_admin_specific_cookie($user_login, $user, $userroles = NULL)
{
    //if(current_user_can('administrator')){
    // I get the role from $user instead of using current_user_can, because current_user_can may not be set yet
    // I actually tried current_user_can and it didn't seem to work here
    error_log(print_r($user, true));
    error_log(print_r($user->roles, true));
    if (!is_null($userroles)) {
        error_log(print_r($userroles, true));
        error_log("is moderator" . array_key_exists('bbp_moderator', $userroles));
    } else {
        error_log("user roles is null");
    }
    //if(!isset($_COOKIE['disable_my_cache'])){
    //}
    // http://wordpress.stackexchange.com/questions/43528/how-to-get-a-buddypress-user-profile-link-and-a-certain-user-profile-field-for-t
    error_log("domain:" . bp_core_get_user_domain($user->ID));
    //if(!isset($_COOKIE['uname'])){
    setcookie('uname', $user->user_login, 0, '/');
    //}
    // $userroles gets passed in from LTI because $user->roles is often not set yet when this function is called from LTI.
    // $user->roles is properly set when this function is called from admin-login
    $my_uroles = $userroles;
    if (is_null($my_uroles)) {
        $my_uroles = $user->roles;
    }
    if (user_can($user, 'administrator') || array_key_exists('administrator', $my_uroles) || lti_site_admin() || array_key_exists('bbp_moderator', $my_uroles) || array_key_exists('bbp_keymaster', $my_uroles) || array_key_exists('bbp_blocked', $my_uroles)) {
        error_log("oritgigo admin or bbp moderator");
        error_log(var_dump($_COOKIE));
        if (!isset($_COOKIE['disable_my_cache'])) {
            error_log("oritgigo empty cookie");
            setcookie('disable_my_cache', 1, 0, '/');
        }
    } else {
        // If the user is not an admin and the disable_my_cache cookie is there, remove it!
        if (isset($_COOKIE['disable_my_cache'])) {
            error_log("The user is not an admin, oritgigo clear existing cookie: disable_my_cache " . is_admin());
            setcookie('disable_my_cache', 0, time() - 3600, '/');
            unset($_COOKIE['disable_my_cache']);
        }
    }
}