function __construct()
 {
     global $_zp_authority, $_userAddressFields;
     $firstTime = false;
     $tablecols = db_list_fields('administrators');
     foreach ($tablecols as $key => $datum) {
         if ($datum['Field'] == 'custom_data') {
             $firstTime = true;
             enableExtension('userAddressFields', true);
             break;
         }
     }
     parent::constructor('userAddressFields', self::fields());
     if ($firstTime) {
         //	migrate the custom data user data
         $result = query('SELECT * FROM ' . prefix('administrators') . ' WHERE `valid`!=0');
         if ($result) {
             while ($row = db_fetch_assoc($result)) {
                 $custom = getSerializedArray($row['custom_data']);
                 if (!empty($custom)) {
                     $sql = 'UPDATE ' . prefix('administrators') . ' SET ';
                     foreach ($custom as $field => $val) {
                         $sql .= '`' . $field . '`=' . db_quote($val) . ',';
                     }
                     setupQuery($sql);
                 }
             }
             db_free_result($result);
         }
         setupQuery('ALTER TABLE ' . prefix('administrators') . ' DROP `custom_data`');
     }
     $cloneid = bin2hex(FULLWEBPATH);
     if (OFFSET_PATH == 2 && isset($_SESSION['admin'][$cloneid])) {
         $user = unserialize($_SESSION['admin'][$cloneid]);
         $user2 = $_zp_authority->getAnAdmin(array('`user`=' => $user->getUser(), '`pass`=' => $user->getPass(), '`valid`=' => 1));
         if ($user2) {
             foreach (userAddressFields::fields() as $field) {
                 $user2->set($field['name'], $user->get($field['name']));
             }
             $user2->save();
         }
     }
 }
/**
 * Prints a form for posting comments
 *
 * @param bool $showcomments defaults to true for showing list of comments
 * @param string $addcommenttext alternate text for "Add a comment:"
 * @param bool $addheader set true to display comment count header
 * @param string $comment_commententry_mod use to add styles, classes to the comment form div
 * @param bool $desc_order default false, set to true to change the comment order to descending ( = newest to oldest)
 */
function printCommentForm($showcomments = true, $addcommenttext = NULL, $addheader = true, $comment_commententry_mod = '', $desc_order = false)
{
    global $_zp_gallery_page, $_zp_current_admin_obj, $_zp_current_comment, $_zp_captcha, $_zp_authority, $_zp_HTML_cache, $_zp_current_image, $_zp_current_album, $_zp_current_page, $_zp_current_article;
    if (getOption('email_new_comments')) {
        $email_list = $_zp_authority->getAdminEmail();
        if (empty($email_list)) {
            setOption('email_new_comments', 0);
        }
    }
    if (is_null($addcommenttext)) {
        $addcommenttext = '<h3>' . gettext('Add a comment:') . '</h3>';
    }
    switch ($_zp_gallery_page) {
        case 'album.php':
            if (!getOption('comment_form_albums')) {
                return;
            }
            $obj = $_zp_current_album;
            break;
        case 'image.php':
            if (!getOption('comment_form_images')) {
                return;
            }
            $obj = $_zp_current_image;
            break;
        case 'pages.php':
            if (!getOption('comment_form_pages')) {
                return;
            }
            $obj = $_zp_current_page;
            break;
        case 'news.php':
            if (!getOption('comment_form_articles') || !is_NewsArticle()) {
                return;
            }
            $obj = $_zp_current_article;
            break;
        default:
            return;
            break;
    }
    $comments_open = $obj->getCommentsAllowed();
    ?>
	<!-- printCommentForm -->
	<div id="commentcontent">
		<?php 
    $num = getCommentCount();
    if ($showcomments) {
        if ($num == 0) {
            if ($addheader) {
                echo '<h3 class="empty">' . gettext('No Comments') . '</h3>';
            }
            $display = '';
        } else {
            if ($addheader) {
                echo '<h3>' . sprintf(ngettext('%u Comment', '%u Comments', $num), $num) . '</h3>';
            }
            if (getOption('comment_form_toggle')) {
                ?>
					<div id="comment_toggle"><!-- place holder for toggle button --></div>
					<script type="text/javascript">
						// <!-- <![CDATA[
						function toggleComments(hide) {
							if (hide) {
								$('div.comment').hide();
								$('.Pagination').hide();
								$('#comment_toggle').html('<button class="button buttons" onclick="toggleComments(false);"><?php 
                echo gettext('show comments');
                ?>
</button>');
							} else {
								$('div.comment').show();
								$('.Pagination').show();
								$('#comment_toggle').html('<button class="button buttons" onclick="toggleComments(true);"><?php 
                echo gettext('hide comments');
                ?>
</button>');
							}
						}
						$(document).ready(function () {
							toggleComments(window.location.hash.search(/#zp_comment_id_/));
						});
						// ]]> -->
					</script>
					<?php 
                $display = ' style="display:none"';
            } else {
                $display = '';
            }
        }
        $hideoriginalcomments = '';
        if (getOption('comment_form_pagination') && COMMENTS_PER_PAGE < $num) {
            $hideoriginalcomments = ' style="display:none"';
            // hide original comment display to be replaced by jQuery pagination
        }
        if (getOption('comment_form_pagination') && COMMENTS_PER_PAGE < $num) {
            ?>
				<div class="Pagination"></div><!-- this is the jquery pagination nav placeholder -->
				<div id="Commentresult"></div>
				<?php 
        }
        ?>
			<div id="comments"<?php 
        echo $hideoriginalcomments;
        ?>
>
				<?php 
        while (next_comment($desc_order)) {
            if (!getOption('comment_form_showURL')) {
                $_zp_current_comment['website'] = '';
            }
            ?>
					<div class="comment" <?php 
            echo $display;
            ?>
>
						<div class="commentinfo">
							<h4 id="zp_comment_id_<?php 
            echo $_zp_current_comment['id'];
            ?>
"><?php 
            printCommentAuthorLink();
            ?>
: <?php 
            echo gettext('on');
            ?>
 <?php 
            echo getCommentDateTime();
            printEditCommentLink(gettext('Edit'), ', ', '');
            ?>
</h4>
						</div><!-- class "commentinfo" -->
						<div class="commenttext"><?php 
            echo html_encodeTagged(getCommentBody(), false);
            ?>
</div><!-- class "commenttext" -->
					</div><!-- class "comment" -->
					<?php 
        }
        ?>
			</div><!-- id "comments" -->
			<?php 
    }
    if (getOption('comment_form_pagination') && COMMENTS_PER_PAGE < $num) {
        ?>
			<div class="Pagination"></div><!-- this is the jquery pagination nav placeholder -->
			<?php 
    }
    ?>
		<!-- Comment Box -->
		<?php 
    if ($comments_open) {
        if (MEMBERS_ONLY_COMMENTS && !zp_loggedin(POST_COMMENT_RIGHTS)) {
            echo gettext('Only registered users may post comments.');
        } else {
            $disabled = array('name' => '', 'website' => '', 'anon' => '', 'private' => '', 'comment' => '', 'street' => '', 'city' => '', 'state' => '', 'country' => '', 'postal' => '');
            $stored = array_merge(array('email' => '', 'custom' => ''), $disabled, getCommentStored());
            $custom = getSerializedArray($stored['custom']);
            foreach ($custom as $key => $value) {
                if (!empty($value)) {
                    $stored[$key] = $value;
                }
            }
            foreach ($stored as $key => $value) {
                $disabled[$key] = false;
            }
            if (zp_loggedin()) {
                if (extensionEnabled('userAddressFields')) {
                    $address = userAddressFields::getCustomData($_zp_current_admin_obj);
                    foreach ($address as $key => $value) {
                        if (!empty($value)) {
                            $disabled[$key] = true;
                            $stored[$key] = $value;
                        }
                    }
                }
                $name = $_zp_current_admin_obj->getName();
                if (!empty($name)) {
                    $stored['name'] = $name;
                    $disabled['name'] = ' disabled="disabled"';
                } else {
                    $user = $_zp_current_admin_obj->getUser();
                    if (!empty($user)) {
                        $stored['name'] = $user;
                        $disabled['name'] = ' disabled="disabled"';
                    }
                }
                $email = $_zp_current_admin_obj->getEmail();
                if (!empty($email)) {
                    $stored['email'] = $email;
                    $disabled['email'] = ' disabled="disabled"';
                }
                if (!empty($address['website'])) {
                    $stored['website'] = $address['website'];
                    $disabled['website'] = ' disabled="disabled"';
                }
            }
            $data = zp_apply_filter('comment_form_data', array('data' => $stored, 'disabled' => $disabled));
            $disabled = $data['disabled'];
            $stored = $data['data'];
            foreach ($data as $check) {
                foreach ($check as $v) {
                    if ($v) {
                        $_zp_HTML_cache->disable();
                        //	shouldn't cache partially filled in pages
                        break 2;
                    }
                }
            }
            if (!empty($addcommenttext)) {
                echo $addcommenttext;
            }
            ?>
				<div id="commententry" <?php 
            echo $comment_commententry_mod;
            ?>
>
					<?php 
            $theme = getCurrentTheme();
            $form = getPlugin('comment_form/comment_form.php', $theme);
            require $form;
            ?>
				</div><!-- id="commententry" -->
				<?php 
        }
    } else {
        ?>
			<div id="commententry">
				<h3><?php 
        echo gettext('Closed for comments.');
        ?>
</h3>
			</div><!-- id="commententry" -->
			<?php 
    }
    ?>
	</div><!-- id="commentcontent" -->
	<?php 
    if (getOption('comment_form_rss') && getOption('RSS_comments')) {
        ?>
		<br clear="all" />
		<?php 
        if (class_exists('RSS')) {
            switch ($_zp_gallery_page) {
                case "image.php":
                    printRSSLink("Comments-image", "", gettext("Subscribe to comments"), "");
                    break;
                case "album.php":
                    printRSSLink("Comments-album", "", gettext("Subscribe to comments"), "");
                    break;
                case "news.php":
                    printRSSLink("Comments-news", "", gettext("Subscribe to comments"), "");
                    break;
                case "pages.php":
                    printRSSLink("Comments-page", "", gettext("Subscribe to comments"), "");
                    break;
            }
        }
    }
    ?>
	<!-- end printCommentForm -->
	<?php 
}
 static function post_processor()
 {
     global $admin_e, $admin_n, $user, $_zp_authority, $_zp_captcha, $_zp_gallery, $_notify, $_link, $_message;
     //Handle registration
     if (isset($_POST['username']) && !empty($_POST['username'])) {
         $_notify = 'honeypot';
         // honey pot check
     }
     if (getOption('register_user_captcha')) {
         if (isset($_POST['code'])) {
             $code = sanitize($_POST['code'], 3);
             $code_ok = sanitize($_POST['code_h'], 3);
         } else {
             $code = '';
             $code_ok = '';
         }
         if (!$_zp_captcha->checkCaptcha($code, $code_ok)) {
             $_notify = 'invalidcaptcha';
         }
     }
     $admin_n = trim(sanitize($_POST['admin_name']));
     if (empty($admin_n)) {
         $_notify = 'incomplete';
     }
     if (isset($_POST['admin_email'])) {
         $admin_e = trim(sanitize($_POST['admin_email']));
     } else {
         $admin_e = trim(sanitize($_POST['user'], 0));
     }
     if (!is_valid_email_zp($admin_e)) {
         $_notify = 'invalidemail';
     }
     $pass = trim(sanitize($_POST['pass'], 0));
     $user = trim(sanitize($_POST['user'], 0));
     if (empty($pass)) {
         $_notify = 'empty';
     } else {
         if (!empty($user) && !empty($admin_n) && !empty($admin_e)) {
             if (isset($_POST['disclose_password']) || $pass == trim(sanitize($_POST['pass_r']))) {
                 $currentadmin = $_zp_authority->getAnAdmin(array('`user`=' => $user, '`valid`>' => 0));
                 if (is_object($currentadmin)) {
                     $_notify = 'exists';
                 } else {
                     if ($_zp_authority->getAnAdmin(array('`email`=' => $admin_e, '`valid`=' => '1'))) {
                         $_notify = 'dup_email';
                     }
                 }
                 if (empty($_notify)) {
                     $userobj = $_zp_authority->newAdministrator('');
                     $userobj->transient = false;
                     $userobj->setUser($user);
                     $userobj->setPass($pass);
                     $userobj->setName($admin_n);
                     $userobj->setEmail($admin_e);
                     $userobj->setRights(0);
                     $userobj->setObjects(NULL);
                     $userobj->setGroup('');
                     $userobj->setCustomData('');
                     $userobj->setLanguage(getUserLocale());
                     if (extensionEnabled('userAddressFields')) {
                         $addresses = getOption('register_user_address_info');
                         $userinfo = register_user::getUserInfo(0);
                         $_comment_form_save_post = serialize($userinfo);
                         if ($addresses == 'required') {
                             if (!isset($userinfo['street']) || empty($userinfo['street'])) {
                                 $userobj->transient = true;
                                 $userobj->msg .= ' ' . gettext('You must supply the street field.');
                             }
                             if (!isset($userinfo['city']) || empty($userinfo['city'])) {
                                 $userobj->transient = true;
                                 $userobj->msg .= ' ' . gettext('You must supply the city field.');
                             }
                             if (!isset($userinfo['state']) || empty($userinfo['state'])) {
                                 $userobj->transient = true;
                                 $userobj->msg .= ' ' . gettext('You must supply the state field.');
                             }
                             if (!isset($userinfo['country']) || empty($userinfo['country'])) {
                                 $userobj->transient = true;
                                 $userobj->msg .= ' ' . gettext('You must supply the country field.');
                             }
                             if (!isset($userinfo['postal']) || empty($userinfo['postal'])) {
                                 $userobj->transient = true;
                                 $userobj->msg .= ' ' . gettext('You must supply the postal code field.');
                             }
                         }
                         zp_setCookie('reister_user_form_addresses', $_comment_form_save_post);
                         userAddressFields::setCustomData($userobj, $userinfo);
                     }
                     zp_apply_filter('register_user_registered', $userobj);
                     if ($userobj->transient) {
                         if (empty($_notify)) {
                             $_notify = 'filter';
                         }
                     } else {
                         $userobj->save();
                         if (MOD_REWRITE) {
                             $verify = '?verify=';
                         } else {
                             $verify = '&verify=';
                         }
                         $_link = PROTOCOL . "://" . $_SERVER['HTTP_HOST'] . register_user::getLink() . $verify . bin2hex(serialize(array('user' => $user, 'email' => $admin_e)));
                         $_message = sprintf(get_language_string(getOption('register_user_text')), $_link, $admin_n, $user, $pass);
                         $_notify = zp_mail(get_language_string(gettext('Registration confirmation')), $_message, array($user => $admin_e));
                         if (empty($_notify)) {
                             $_notify = 'accepted';
                         }
                     }
                 }
             } else {
                 $_notify = 'mismatch';
             }
         } else {
             $_notify = 'incomplete';
         }
     }
 }
Exemple #4
0
    {
        return parent::_zenpageItemSave($custom, $object, self::fields());
    }
    static function zenpageItemEdit($html, $object)
    {
        return parent::_zenpageItemEdit($html, $object, self::fields());
    }
    static function register()
    {
        parent::_register('userAddressFields', self::fields());
    }
    static function adminNotice($tab, $subtab)
    {
        parent::_adminNotice($tab, $subtab, 'userAddressFields');
    }
    static function getCustomData($obj)
    {
        return parent::_getCustomData($obj, self::fields());
    }
    static function setCustomData($obj, $values)
    {
        parent::_setCustomData($obj, $values);
    }
}
if (OFFSET_PATH == 2) {
    // setup call: add the fields into the database
    setOptionDefault('zp_plugin_userAddressFields', $plugin_is_filter);
    new userAddressFields();
} else {
    userAddressFields::register();
}