public static function getAssetPicker($userinfo, $registry)
 {
     //see if this user has an album we can use for background images.
     $albums = vB_dB_Assertor::instance()->assertQuery('CustomProfileAlbums', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_STORED, 'userid' => $userinfo['userid']));
     $album = $albums->current();
     $album_select = '';
     while ($albums->valid()) {
         $album_select .= "<option value=\"" . $album['albumid'] . "\">" . $album['title'] . "</option>\n";
         $album = $albums->next();
     }
     require_once DIR . '/includes/class_xml.php';
     $xml = new vB_XML_Builder_Ajax('text/xml');
     if (empty($album_select)) {
         $xml->add_group('error');
         $xml->add_tag('phrase', 'need_public_album_text');
     } else {
         $xml->add_group('content');
         $template = vB_Template::create('memberinfo_assetpicker');
         $template->register('album_select', $album_select);
         $phrase = new vB_Phrase('profilefield', 'select_album_to_view');
         $template->register('select_album_to_view', $phrase);
         $body = $template->render();
         $template = vB_Template::create('memberinfo_assetpicker_footer');
         $footer = $template->render();
         $header = new vB_Phrase('profilefield', 'asset_picker');
         //Now format this as an xml array.
         $xml->add_tag('body', $body);
         $xml->add_tag('header', $header);
         $xml->add_tag('footer', $footer);
     }
     $xml->close_group();
     $xml->print_xml();
 }
예제 #2
0
 /**
  * Private
  * Verifies that fetch_table_info() has been called for a valid table and sets current error condition to none
  * .. in other words verify that fetchTableInfo returns true before proceeding on
  *
  * @param	void
  *
  * @return	void
  */
 function init_table_info()
 {
     global $vbulletin;
     // need registry!
     if (!$this->init) {
         $this->fetch_table_info();
     }
     if (!$this->init) {
         $message = '<strong>vB_Database_Alter</strong>: fetch_table_info() has not been called successfully.<br />' . $this->fetch_error_message();
         if ($vbulletin->GPC['ajax']) {
             require_once DIR . '/includes/class_xml.php';
             $xml = new vB_XML_Builder_Ajax('text/xml');
             $xml->add_tag('error', $message);
             $xml->print_xml();
         } else {
             echo $message;
             exit;
         }
     }
     $this->set_error();
 }
예제 #3
0
 /**
  * Renders the view to a string and returns it.
  *
  * @return string
  */
 public function render($send_content_headers = false)
 {
     require_once DIR . '/includes/class_xml.php';
     $xml = new vB_XML_Builder_Ajax('text/xml');
     $xml->add_group('container');
     $xml->add_tag('success', 1);
     if ($this->content) {
         $xml->add_tag('html', $this->content->render());
     }
     $xml->add_tag('title', $this->title);
     $xml->add_tag('status', $this->status);
     $xml->add_tag('message', $this->feedback);
     if (sizeof($this->errors)) {
         $xml->add_group('errors');
         foreach ($this->errors as $error) {
             $xml->add_tag('error', $error['message'], array('errcode' => $error['code']));
         }
         $xml->close_group();
     }
     if (sizeof($this->urls)) {
         $xml->add_group('urls');
         foreach ($this->urls as $type => $url) {
             $xml->add_tag('url', $url, array('type' => $type));
         }
         $xml->close_group();
     }
     $xml->close_group();
     if ($send_content_headers and !vB::contentHeadersSent()) {
         $xml->send_content_type_header();
         $xml->send_content_length_header();
         vB::contentHeadersSent(true);
     }
     return $xml->fetch_xml();
 }
예제 #4
0
/**
* Halts execution and shows the specified message
*
* @param	string	Message to display
* @param	mixed	If specified, a redirect will be performed to the URL in this parameter
* @param	integer	If redirect is specified, this is the time in seconds to delay before redirect
* @param	string	If specified, will provide a specific URL for "Go Back". If empty, no button will be displayed!
* @param bool		If true along with redirect, 'CONTINUE' button will be used instead of automatic redirect
*/
function print_cp_message($text = '', $redirect = NULL, $delay = 1, $backurl = NULL, $continue = false)
{
    global $vbulletin, $vbphrase;
    if ($vbulletin->GPC['ajax']) {
        require_once DIR . '/includes/class_xml.php';
        $xml = new vB_XML_Builder_Ajax('text/xml');
        $xml->add_tag('error', $text);
        $xml->print_xml();
        exit;
    }
    if ($redirect) {
        if (($hashpos = strpos($redirect, '#')) !== false or ($hashpos = strpos($redirect, '%23')) !== false) {
            $hashsize = strpos($redirect, '#') !== false ? 1 : 3;
            $hash = substr($redirect, $hashpos + $hashsize);
            $redirect = substr($redirect, 0, $hashpos);
        }
        if ($session = vB::getCurrentSession()->get('sessionurl')) {
            if (strpos($redirect, $session) !== false) {
                if (strpos($redirect, '?') === false) {
                    $redirect .= '?' . $session;
                } else {
                    $redirect .= '&' . $session;
                }
            }
        }
    }
    if (!defined('DONE_CPHEADER')) {
        print_cp_header($vbphrase['vbulletin_message']);
    }
    print_form_header('', '', 0, 1, 'messageform', '65%');
    print_table_header(new vB_Phrase('global', 'vbulletin_message'));
    print_description_row("<blockquote><br />{$text}<br /><br /></blockquote>");
    if ($redirect) {
        // redirect to the new page
        if ($continue) {
            $continueurl = create_full_url(str_replace('&amp;', '&', $redirect));
            if (!empty($hash)) {
                $continueurl .= '#' . $hash;
            }
            print_table_footer(2, construct_button_code(new vB_Phrase('global', 'continue'), $continueurl));
        } else {
            print_table_footer();
            $redirect_click = create_full_url($redirect);
            if (!empty($hash)) {
                $redirect_click .= '#' . $hash;
                $redirect .= '#' . $hash;
            }
            $redirect_click = str_replace('"', '', $redirect_click);
            echo '<p align="center" class="smallfont">' . construct_phrase($vbphrase['if_you_are_not_automatically_redirected_click_here_x'], $redirect_click) . "</p>\n";
            print_cp_redirect($redirect, $delay);
        }
    } else {
        // end the table and halt
        if ($backurl === NULL) {
            $backurl = 'javascript:history.back(1)';
        }
        if (strpos($backurl, 'history.back(') !== false) {
            //if we are attempting to run a history.back(1), check we have a history to go back to, otherwise attempt to close the window.
            $back_button = '&nbsp;
				<input type="button" id="backbutton" class="button" value="' . $vbphrase['go_back'] . '" title="" tabindex="1" onclick="if (history.length) { history.back(1); } else { self.close(); }"/>
				&nbsp;
				<script type="text/javascript">
				<!--
				if (history.length < 1 || ((is_saf || is_moz) && history.length <= 1)) // safari + gecko start at 1
				{
					document.getElementById("backbutton").parentNode.removeChild(document.getElementById("backbutton"));
				}
				//-->
				</script>';
            // remove the back button if it leads back to the login redirect page
            if (strpos($vbulletin->url, 'login.php?do=login') !== false) {
                $back_button = '';
            }
        } else {
            if ($backurl !== '') {
                // regular window.location=url call
                $backurl = create_full_url($backurl);
                $backurl = str_replace(array('"', "'"), '', $backurl);
                $back_button = '<input type="button" class="button" value="' . new vB_Phrase('global', 'go_back') . '" title="" tabindex="1" onclick="window.location=\'' . $backurl . '\';"/>';
            } else {
                $back_button = '';
            }
        }
        print_table_footer(2, $back_button);
    }
    // and now terminate the script
    print_cp_footer();
}
예제 #5
0
 /**
  * This function changes the search type for settings
  * @param string $varname
  * @param array $setting
  * @return array, response
  */
 public function validateSettings($varname, $setting)
 {
     $this->checkHasAdminPermission('canadminsettings');
     require_once DIR . '/includes/class_xml.php';
     require_once DIR . '/includes/functions_file.php';
     require_once DIR . '/includes/adminfunctions_options.php';
     $response = array();
     $varname = convert_urlencoded_unicode($varname);
     $value = convert_urlencoded_unicode($setting["{$varname}"]);
     require_once DIR . '/includes/class_xml.php';
     $xml = new vB_XML_Builder_Ajax('text/xml');
     $xml->add_group('setting');
     $xml->add_tag('varname', $varname);
     $setting = vB::getDbAssertor()->getRow('setting', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_SELECT, 'varname' => $varname));
     if ($setting) {
         $raw_value = $value;
         $value = validate_setting_value($value, $setting['datatype']);
         $valid = exec_setting_validation_code($setting['varname'], $value, $setting['validationcode'], $raw_value);
     } else {
         $valid = 1;
     }
     $xml->add_tag('valid', $valid);
     $xml->close_group();
     $response['xml'] = $xml;
     $response['validate'] = true;
     return $response;
 }