Exemplo n.º 1
0
	</li>
	<?php 
    }
    ?>
	
	<?php 
    echo MM_SupportUtils::supportMenuItem($module);
    ?>
</ul>
</div>
<?php 
}
?>
		

<div style="clear: both"></div>

<div id="mm-view-container">
	<?php 
if ($module == MM_MODULE_REPORTING) {
    echo MM_TEMPLATE::generate(MM_MODULES . "/reports/{$crntPage}.php");
} else {
    echo MM_TEMPLATE::generate(MM_MODULES . "/{$module}.php");
}
?>
</div>
	
<?php 
if ($module != MM_MODULE_REPORTING && file_exists(MM_MODULES . "/{$module}.firstrun.php")) {
    echo MM_TEMPLATE::generate(MM_MODULES . "/{$module}.firstrun.php");
}
Exemplo n.º 2
0
 public function setupCorePages()
 {
     global $wpdb, $current_user;
     // Core Page Types
     $sql[] = "INSERT IGNORE INTO " . MM_TABLE_CORE_PAGE_TYPES . " (id, name, visible) VALUES ('" . MM_CorePageType::$MEMBER_HOME_PAGE . "','Member Home','1');";
     $sql[] = "INSERT IGNORE INTO " . MM_TABLE_CORE_PAGE_TYPES . " (id, name, visible) VALUES ('" . MM_CorePageType::$SAVETHESALE . "','Save the Sale','1');";
     $sql[] = "INSERT IGNORE INTO " . MM_TABLE_CORE_PAGE_TYPES . " (id, name, visible) VALUES ('" . MM_CorePageType::$ERROR . "','Error','1');";
     $sql[] = "INSERT IGNORE INTO " . MM_TABLE_CORE_PAGE_TYPES . " (id, name, visible) VALUES ('" . MM_CorePageType::$LOGIN_PAGE . "','Login','1');";
     $sql[] = "INSERT IGNORE INTO " . MM_TABLE_CORE_PAGE_TYPES . " (id, name, visible) VALUES ('" . MM_CorePageType::$FORGOT_PASSWORD . "','Forgot Password','1');";
     $sql[] = "INSERT IGNORE INTO " . MM_TABLE_CORE_PAGE_TYPES . " (id, name, visible) VALUES ('" . MM_CorePageType::$RESET_PASSWORD . "','Reset Password','1');";
     $sql[] = "INSERT IGNORE INTO " . MM_TABLE_CORE_PAGE_TYPES . " (id, name, visible) VALUES ('" . MM_CorePageType::$CHECKOUT . "','Checkout','1');";
     $sql[] = "INSERT IGNORE INTO " . MM_TABLE_CORE_PAGE_TYPES . " (id, name, visible) VALUES ('" . MM_CorePageType::$REDEEM_GIFT . "','Redeem Gift','1');";
     $sql[] = "INSERT IGNORE INTO " . MM_TABLE_CORE_PAGE_TYPES . " (id, name, visible) VALUES ('" . MM_CorePageType::$PAID_CONFIRMATION . "','Confirmation','1');";
     $sql[] = "INSERT IGNORE INTO " . MM_TABLE_CORE_PAGE_TYPES . " (id, name, visible) VALUES ('" . MM_CorePageType::$FREE_CONFIRMATION . "','Free Confirmation','0');";
     $sql[] = "INSERT IGNORE INTO " . MM_TABLE_CORE_PAGE_TYPES . " (id, name, visible) VALUES ('" . MM_CorePageType::$MY_ACCOUNT . "','My Account','1');";
     $sql[] = "INSERT IGNORE INTO " . MM_TABLE_CORE_PAGE_TYPES . " (id, name, visible) VALUES ('" . MM_CorePageType::$LOGOUT_PAGE . "','Logout','1');";
     // Default Core Pages
     $sql[] = "INSERT IGNORE INTO " . MM_TABLE_CORE_PAGES . " (id, core_page_type_id) VALUES ('1', '" . MM_CorePageType::$MEMBER_HOME_PAGE . "');";
     $sql[] = "INSERT IGNORE INTO " . MM_TABLE_CORE_PAGES . " (id, core_page_type_id) VALUES ('2', '" . MM_CorePageType::$SAVETHESALE . "');";
     $sql[] = "INSERT IGNORE INTO " . MM_TABLE_CORE_PAGES . " (id, core_page_type_id) VALUES ('3', '" . MM_CorePageType::$ERROR . "');";
     $sql[] = "INSERT IGNORE INTO " . MM_TABLE_CORE_PAGES . " (id, core_page_type_id) VALUES ('4', '" . MM_CorePageType::$LOGIN_PAGE . "');";
     $sql[] = "INSERT IGNORE INTO " . MM_TABLE_CORE_PAGES . " (id, core_page_type_id) VALUES ('5', '" . MM_CorePageType::$FORGOT_PASSWORD . "');";
     $sql[] = "INSERT IGNORE INTO " . MM_TABLE_CORE_PAGES . " (id, core_page_type_id) VALUES ('6', '" . MM_CorePageType::$CHECKOUT . "');";
     $sql[] = "INSERT IGNORE INTO " . MM_TABLE_CORE_PAGES . " (id, core_page_type_id) VALUES ('7', '" . MM_CorePageType::$PAID_CONFIRMATION . "');";
     $sql[] = "INSERT IGNORE INTO " . MM_TABLE_CORE_PAGES . " (id, core_page_type_id) VALUES ('9', '" . MM_CorePageType::$FREE_CONFIRMATION . "');";
     $sql[] = "INSERT IGNORE INTO " . MM_TABLE_CORE_PAGES . " (id, core_page_type_id) VALUES ('10', '" . MM_CorePageType::$MY_ACCOUNT . "');";
     $sql[] = "INSERT IGNORE INTO " . MM_TABLE_CORE_PAGES . " (id, core_page_type_id) VALUES ('11', '" . MM_CorePageType::$LOGOUT_PAGE . "');";
     $sql[] = "INSERT IGNORE INTO " . MM_TABLE_CORE_PAGES . " (id, core_page_type_id) VALUES ('12', '" . MM_CorePageType::$REDEEM_GIFT . "');";
     foreach ($sql as $query) {
         if ($wpdb->query($query) === false) {
             echo $query;
             return false;
         }
     }
     unset($sql);
     // Install Default Core Pages
     $templateParams = new stdClass();
     $templateParams->resourceDirectory = MM_RESOURCES_URL;
     $mm_template_base = MM_PLUGIN_ABSPATH . "/templates";
     // Member Homepage
     $corePageSql = "select count(*) as total from " . MM_TABLE_CORE_PAGES . " where core_page_type_id = '" . MM_CorePageType::$MEMBER_HOME_PAGE . "' and ref_type IS NULL and page_id IS NULL";
     $row = $wpdb->get_row($corePageSql);
     if ($row->total > 0) {
         $sql = "insert into {$wpdb->posts} (post_type, post_author, post_date, post_status,post_content, post_title, post_name) " . "\t\tvalues ('page',{$current_user->ID}, NOW(), 'publish','" . addslashes(MM_TEMPLATE::generate($mm_template_base . "/default_templates/homepage.html.php", $templateParams)) . "', '[MM_Member_Data name=\"membershipName\"] Home Page', '" . $this->getPostName('home') . "');";
         if (!$wpdb->query($sql)) {
             echo $query;
             return false;
         }
         $this->linkCorePage($wpdb->insert_id, MM_CorePageType::$MEMBER_HOME_PAGE);
     }
     // Save-the-Sale Page
     $corePageSql = "select count(*) as total from " . MM_TABLE_CORE_PAGES . " where core_page_type_id = '" . MM_CorePageType::$SAVETHESALE . "' and ref_type IS NULL and page_id IS NULL";
     $row = $wpdb->get_row($corePageSql);
     if ($row->total > 0) {
         $sql = "insert into {$wpdb->posts} (post_type, post_author, post_date, post_status,post_content, post_title, post_name) " . "\t\tvalues ('page',{$current_user->ID}, NOW(), 'publish','" . addslashes(MM_TEMPLATE::generate($mm_template_base . "/default_templates/cancel.html.php", $templateParams)) . "', 'Cancel Membership', '" . $this->getPostName('cancel') . "');";
         if (!$wpdb->query($sql)) {
             echo $query;
             return false;
         }
         $this->linkCorePage($wpdb->insert_id, MM_CorePageType::$SAVETHESALE);
     }
     // Error Page
     $corePageSql = "select count(*) as total from " . MM_TABLE_CORE_PAGES . " where core_page_type_id = '" . MM_CorePageType::$ERROR . "' and ref_type IS NULL and page_id IS NULL";
     $row = $wpdb->get_row($corePageSql);
     if ($row->total > 0) {
         $sql = "insert into {$wpdb->posts} (post_type, post_author, post_date, post_status,post_content, post_title, post_name) " . "\t\tvalues ('page',{$current_user->ID}, NOW(), 'publish','" . addslashes(MM_TEMPLATE::generate($mm_template_base . "/default_templates/error.html.php", $templateParams)) . "', 'Error', '" . $this->getPostName('mm-error') . "');";
         if (!$wpdb->query($sql)) {
             echo $query;
             return false;
         }
         $this->linkCorePage($wpdb->insert_id, MM_CorePageType::$ERROR);
     }
     // Login Page
     $corePageSql = "select count(*) as total from " . MM_TABLE_CORE_PAGES . " where core_page_type_id = '" . MM_CorePageType::$LOGIN_PAGE . "' and ref_type IS NULL and page_id IS NULL";
     $row = $wpdb->get_row($corePageSql);
     if ($row->total > 0) {
         $sql = "insert into {$wpdb->posts} (post_type, post_author, post_date, post_status,post_content, post_title, post_name) " . "\t\tvalues ('page',{$current_user->ID}, NOW(), 'publish','" . addslashes(MM_TEMPLATE::generate($mm_template_base . "/default_templates/login.html.php", $templateParams)) . "', 'Login', '" . $this->getPostName('login') . "');";
         if (!$wpdb->query($sql)) {
             echo $query;
             return false;
         }
         $this->linkCorePage($wpdb->insert_id, MM_CorePageType::$LOGIN_PAGE);
     }
     // Logout Page
     $corePageSql = "select count(*) as total from " . MM_TABLE_CORE_PAGES . " where core_page_type_id = '" . MM_CorePageType::$LOGOUT_PAGE . "' and ref_type IS NULL and page_id IS NULL";
     $row = $wpdb->get_row($corePageSql);
     if ($row->total > 0) {
         $sql = "insert into {$wpdb->posts} (post_type, post_author, post_date, post_status,post_content, post_title, post_name) " . "\t\tvalues ('page',{$current_user->ID}, NOW(), 'publish','" . addslashes(MM_TEMPLATE::generate($mm_template_base . "/default_templates/logout.html.php", $templateParams)) . "', 'Logout', '" . $this->getPostName('logout') . "');";
         if (!$wpdb->query($sql)) {
             echo $query;
             return false;
         }
         $this->linkCorePage($wpdb->insert_id, MM_CorePageType::$LOGOUT_PAGE);
     }
     // Forgot Password Page
     $corePageSql = "select count(*) as total from " . MM_TABLE_CORE_PAGES . " where core_page_type_id = '" . MM_CorePageType::$FORGOT_PASSWORD . "' and ref_type IS NULL and page_id IS NULL";
     $row = $wpdb->get_row($corePageSql);
     if ($row->total > 0) {
         $sql = "insert into {$wpdb->posts} (post_type, post_author, post_date, post_status,post_content, post_title, post_name) " . "\t\tvalues ('page',{$current_user->ID}, NOW(), 'publish','" . addslashes(MM_TEMPLATE::generate($mm_template_base . "/default_templates/forgotpassword.html.php", $templateParams)) . "', 'Forgot Password', '" . $this->getPostName('forgot-password') . "');";
         if (!$wpdb->query($sql)) {
             echo $query;
             return false;
         }
         $this->linkCorePage($wpdb->insert_id, MM_CorePageType::$FORGOT_PASSWORD);
     }
     // Reset Password Page
     // remove corrupt reset password core pages
     $removeCorruptResetPasswordSql = "DELETE FROM " . MM_TABLE_CORE_PAGES . " WHERE core_page_type_id = '" . MM_CorePageType::$RESET_PASSWORD . "' AND (page_id IS NULL || page_id = '');";
     $wpdb->query($removeCorruptResetPasswordSql);
     $corePageSql = "select id, page_id, count(*) as total from " . MM_TABLE_CORE_PAGES . " where core_page_type_id = '" . MM_CorePageType::$RESET_PASSWORD . "'";
     $row = $wpdb->get_row($corePageSql);
     // it's possible that the reset password core page isn't being installed as a result of some corrupt
     // core pages that we only partially installed (the page_id == NULL checks for that). We want to detect
     // these so that their presense doesn't keep the fully functional page from being installed.
     if ($row->total == 0 || $row->page_id == NULL) {
         // create row in mm_core_pages table
         $resetPasswordSql = "INSERT IGNORE INTO " . MM_TABLE_CORE_PAGES . " (core_page_type_id) VALUES ('" . MM_CorePageType::$RESET_PASSWORD . "');";
         if (!$wpdb->query($resetPasswordSql)) {
             echo $resetPasswordSql;
             return false;
         }
         $resetCorePageId = $wpdb->insert_id;
         // create reset password page
         $sql = "insert into {$wpdb->posts} (post_type, post_author, post_date, post_status,post_content, post_title, post_name) " . "\t\tvalues ('page',{$current_user->ID}, NOW(), 'publish','" . addslashes(MM_TEMPLATE::generate($mm_template_base . "/default_templates/resetpassword.html.php", $templateParams)) . "', 'Reset Password', '" . $this->getPostName('reset-password') . "');";
         if (!$wpdb->query($sql)) {
             echo $sql;
             return false;
         }
         // link row in mm_core_pages table to reset password page
         $this->linkCorePage($wpdb->insert_id, $resetCorePageId);
     }
     // Checkout Page
     $corePageSql = "select count(*) as total from " . MM_TABLE_CORE_PAGES . " where core_page_type_id = '" . MM_CorePageType::$CHECKOUT . "' and ref_type IS NULL and page_id IS NULL";
     $row = $wpdb->get_row($corePageSql);
     if ($row->total > 0) {
         $sql = "insert into {$wpdb->posts} (post_type, post_author, post_date, post_status,post_content, post_title, post_name) " . "\t\tvalues ('page',{$current_user->ID}, NOW(), 'publish','" . addslashes(MM_TEMPLATE::generate($mm_template_base . "/default_templates/checkout.html.php", $templateParams)) . "', 'Checkout', '" . $this->getPostName('checkout') . "');";
         if (!$wpdb->query($sql)) {
             echo $query;
             return false;
         }
         $this->linkCorePage($wpdb->insert_id, MM_CorePageType::$CHECKOUT);
     }
     // Redeem Gift Page
     $corePageSql = "select count(*) as total from " . MM_TABLE_CORE_PAGES . " where core_page_type_id = '" . MM_CorePageType::$REDEEM_GIFT . "' and ref_type IS NULL and page_id IS NULL";
     $row = $wpdb->get_row($corePageSql);
     if ($row->total > 0) {
         $sql = "insert into {$wpdb->posts} (post_type, post_author, post_date, post_status,post_content, post_title, post_name) " . "\t\tvalues ('page',{$current_user->ID}, NOW(), 'publish','" . addslashes(MM_TEMPLATE::generate($mm_template_base . "/default_templates/redeemgift.html.php", $templateParams)) . "', 'Redeem Gift', '" . $this->getPostName('redeem-gift') . "');";
         if (!$wpdb->query($sql)) {
             echo $query;
             return false;
         }
         $this->linkCorePage($wpdb->insert_id, MM_CorePageType::$REDEEM_GIFT);
     }
     // My Account Page
     $corePageSql = "select count(*) as total from " . MM_TABLE_CORE_PAGES . " where core_page_type_id = '" . MM_CorePageType::$MY_ACCOUNT . "' and ref_type IS NULL and page_id IS NULL";
     $row = $wpdb->get_row($corePageSql);
     if ($row->total > 0) {
         $sql = "insert into {$wpdb->posts} (post_type, post_author, post_date, post_status,post_content, post_title, post_name) " . "\t\tvalues ('page',{$current_user->ID}, NOW(), 'publish','" . addslashes(MM_TEMPLATE::generate($mm_template_base . "/default_templates/myaccount.html.php", $templateParams)) . "', 'My Account', '" . $this->getPostName('myaccount') . "');";
         if (!$wpdb->query($sql)) {
             echo $query;
             return false;
         }
         $this->linkCorePage($wpdb->insert_id, MM_CorePageType::$MY_ACCOUNT);
     }
     // Paid Confirmation Page
     $corePageSql = "select count(*) as total from " . MM_TABLE_CORE_PAGES . " where core_page_type_id = '" . MM_CorePageType::$PAID_CONFIRMATION . "' and ref_type IS NULL and page_id IS NULL";
     $row = $wpdb->get_row($corePageSql);
     if ($row->total > 0) {
         $sql = "insert into {$wpdb->posts} (post_type, post_author, post_date, post_status,post_content, post_title, post_name) " . "\t\tvalues ('page',{$current_user->ID}, NOW(), 'publish','" . addslashes(MM_TEMPLATE::generate($mm_template_base . "/default_templates/confirmation.html.php", $templateParams)) . "', 'Thank You', '" . $this->getPostName('confirmation') . "');";
         if (!$wpdb->query($sql)) {
             echo $query;
             return false;
         }
         $this->linkCorePage($wpdb->insert_id, MM_CorePageType::$PAID_CONFIRMATION);
     }
     return true;
 }