function openam_auth($user, $username, $password) { if (OPENAM_REST_ENABLED) { // Let's see if the user is already logged in the IDP $tokenId = $_COOKIE[OPENAM_COOKIE_NAME]; if (!empty($tokenId) and !is_user_logged_in()) { openam_debug("openam_auth: TOKENID:" . $tokenId); if ($_GET['action'] != 'logout' or $_GET['loggedout'] != 'yes') { $am_response = isSessionValid($tokenId); if ($am_response['valid'] or $am_response['valid' == 'true'] or $am_response['boolean'] == '1') { // Session was valid openam_debug("openam_auth: Authentication was succesful"); $amAttributes = getAttributesFromOpenAM($tokenId, $am_response[OPENAM_WORDPRESS_ATTRIBUTES_USERNAME], OPENAM_WORDPRESS_ATTRIBUTES); $usernameAttr = get_attribute_value($amAttributes, OPENAM_WORDPRESS_ATTRIBUTES_USERNAME); $mailAttr = get_attribute_value($amAttributes, OPENAM_WORDPRESS_ATTRIBUTES_MAIL); openam_debug("openam_auth: UID: " . print_r($usernameAttr, TRUE)); openam_debug("openam_auth: MAIL: " . print_r($mailAttr, TRUE)); $user = loadUser($usernameAttr, $mailAttr); remove_action('authenticate', 'wp_authenticate_username_password', 20); return $user; } } } // If no username nor password, then we are starting here if ($username != '' and $password != '') { $tokenId = authenticateWithOpenAM($username, $password); if (!$tokenId) { // User does not exist, send back an error message $user = new WP_Error('denied', __("<strong>ERROR</strong>: The combination username/password was not correct")); } elseif ($tokenId == 2) { $user = new WP_Error('denied', __("<strong>ERROR</strong>: Error when trying to reach the OpenAM")); } else { $amAttributes = getAttributesFromOpenAM($tokenId, $username, OPENAM_WORDPRESS_ATTRIBUTES); if ($amAttributes) { $usernameAttr = get_attribute_value($amAttributes, OPENAM_WORDPRESS_ATTRIBUTES_USERNAME); $mailAttr = get_attribute_value($amAttributes, OPENAM_WORDPRESS_ATTRIBUTES_MAIL); openam_debug("openam_auth: UID: " . print_r($usernameAttr, TRUE)); openam_debug("openam_auth: MAIL: " . print_r($mailAttr, TRUE)); $user = loadUser($usernameAttr, $mailAttr); remove_action('authenticate', 'wp_authenticate_username_password', 20); return $user; } } } } return; }
case 'option_text': $options[$current_option]['text'] = get_node_value($xml_elem); break; # Sets value of current option response with html code conversion # Sets value of current option response with html code conversion case 'response_supplement': $options[$current_option]['response_supplement'] = html_entity_decode(get_node_value($xml_elem)); break; default: # checks to see if node is <Option_x> if (strpos(strtolower($xml_elem['tag']), 'option_') !== FALSE) { # parse last char # sets current option placeholder # and construct option array $current_option = substr(strtolower($xml_elem['tag']), strlen('option_'), 1); $options[$current_option] = array('points' => (int) get_attribute_value($xml_elem, 'points'), 'text' => '', 'response_supplement' => ''); } break; } } elseif (in_array($xml_elem['type'], array('close'))) { switch (strtolower($xml_elem['tag'])) { # Create a new Question Group case 'question': if (isset($question) && !empty($group_link)) { # if qustion already exists save it to matrix $question['response_form'] = $options; $new_question = new Online_Quiz_Question_Multichoice(); # Sets question attributes $new_question->setAttrValue('name', $question['name']); $new_question->setAttrValue('question_text', $question['question_text']); $new_question->setAttrValue('response_form', $options);
* @author Norbert Dreszer */ $single_names = get_single_names(); $product_id = ic_get_product_id(); $attributes_number = product_attributes_number(); $table = ''; if ($attributes_number > 0 && has_product_any_attributes($product_id)) { ?> <div id="product_features" class="product-features"> <h3><?php echo $single_names['product_features']; ?> </h3> <table class="features-table"><?php for ($i = 1; $i <= $attributes_number; $i++) { $attribute_value = get_attribute_value($i, $product_id); if (!empty($attribute_value)) { ?> <tr> <td class="attribute-label-single"><?php echo get_attribute_label($i, $product_id); ?> </td> <td class="attribute-value-unit-single"><span class="attribute-value-single"><?php echo $attribute_value; ?> </span> <span class="attribute-unit-single"><?php echo get_attribute_unit($i, $product_id); ?> </span></td> </tr><?php
/** * Returns modern grid element for a given product * * @param object $post Product post object * @param string $archive_template * @return string */ function get_default_archive_theme($post, $archive_template = null) { $archive_template = isset($archive_template) ? $archive_template : get_product_listing_template(); $return = ''; if ($archive_template == 'default') { $product_id = $post->ID; $archive_price = apply_filters('archive_price_filter', '', $post); $modern_grid_settings = get_modern_grid_settings(); $image_id = get_post_thumbnail_id($product_id); $thumbnail_product = wp_get_attachment_image_src($image_id, 'modern-grid-listing'); $product_name = get_the_title(); if ($thumbnail_product) { $url = $thumbnail_product[0]; $img_class['alt'] = $product_name; $img_class['class'] = "modern-grid-image"; if (!empty($thumbnail_product[2])) { $ratio = $thumbnail_product[1] / $thumbnail_product[2]; if ($ratio <= 1.35 && $ratio > 1.2) { $img_class['class'] .= " higher"; } else { if ($ratio <= 1.15) { $img_class['class'] .= " higher rect"; } else { if ($ratio > 2) { $img_class['class'] .= " wider rect"; } } } } $image = wp_get_attachment_image($image_id, 'modern-grid-listing', false, $img_class); } else { $url = default_product_thumbnail_url(); $image = '<img class="modern-grid-image" src="' . $url . '" alt="' . $product_name . '">'; } $return = '<div class="al_archive product-' . $product_id . ' modern-grid-element ' . design_schemes('box', 0) . ' ' . product_listing_size_class($thumbnail_product) . ' ' . product_class($product_id) . '">'; $return .= '<div class="pseudo"></div>'; $return .= '<a href="' . get_permalink($product_id) . '">' . $image; $return .= '<h3 class="product-name ' . design_schemes('box', 0) . '">' . $product_name . '</h3>'; if ($modern_grid_settings['attributes'] == 1) { $attributes_number = product_attributes_number(); if ($attributes_number > 0 && has_product_any_attributes($product_id)) { $return .= '<div class="product-attributes"><table class="attributes-table">'; for ($i = 1; $i <= $attributes_number; $i++) { $attribute_value = get_attribute_value($i, $product_id); if (!empty($attribute_value)) { $return .= '<tr><td class="attribute-label-listing">' . get_attribute_label($i, $product_id) . '</td><td><span class="attribute-value-listing">' . get_attribute_value($i, $product_id) . '</span> <span class="attribute-unit-listing">' . get_attribute_unit($i, $product_id) . '</span></td></tr>'; } } $return .= '</table></div>'; } } $return .= $archive_price . '</a></div>'; } return $return; }