<?php 

$lldocroot = defined('SITEROOT') ? SITEROOT : $_SERVER['DOCUMENT_ROOT'];
if(file_exists($lldocroot . "/dap/dap-config.php")) include_once ($lldocroot . "/dap/dap-config.php"); // dap config call
 
	try{
		$customFieldsList = Dap_CustomFields::loadUserFacingCustomFields();  // get dap custom fields.
	}
	catch (PDOException $e) {
		return ERROR_DB_OPERATION;
	} catch (Exception $e) {
		return ERROR_GENERAL;
	} 
	$session = Dap_Session::getSession();
	$user = $session->getUser();
		
	if($user){
		$userId = $user->getId();
	}
	$productList = null;
		
	if( isset($user) ) {
		$productList = Dap_Product::loadProducts("","A");
	} 
	$pluginurl =  plugin_dir_url(__FILE__);
 
?>

 <div id="dap_shortcode_popup" style="display:block;" class="popup_div_outer">

    <div class="dap-outer live-links-outer" id="dap_shortcode_popup_inner">
    <div class="container dap-outer-div" id="dap_shortcode_popup_button_inn">
     <h3 class="mb-4 border-bottom pb-2"><i class="fa fa-users" aria-hidden="true"></i> DAP Shortcode
      <a href="<?= admin_url('admin.php?page=dap_memberpages'); ?>" title="Back to Member Pages" class="member_backicon">Return to Member Pages</a>
      </h3>
     
     
     <h2 class="head_memb "><i class="fa fa-cog" aria-hidden="true"></i> Content Protection Options</h2>
 
 
			 <table width="100%" cellpadding="2" cellspacing="2" class="dap_table_page_select">
				<tr>
					<td colspan="2" class="dap_shortcode_popup_heading"><h4 class="mainheading">Show Content based on Logged-In Status</h4>
					<img src="<?php echo $pluginurl; ?>includes/images/dividers.png" alt="..." class="divider"></td>
				</tr>
				<tr>
					<td valign="top"> Is User Logged-in <div class="tool-tip">
                      <i class="fa fa-info-circle" aria-hidden="true">
                      </i>
                      <div class="toll-tip-desc">Show this content only to logged-in members
                      </div>
                    </div></td>
					<td valign="top" >
						<select  name="isloggedin" id="isloggedin" class="dap_cls_common">
							<option value="0" selected="selected">Select</option>
							<option value="Y" >Yes</option>
							<option value="N">No</option>
						</select>
					</td>
				</tr>
				<tr>
					<td colspan="2" class="dap_shortcode_popup_heading"><h4 class="mainheading">Show Content based on Product Access</h4>
					<img src="<?php echo $pluginurl; ?>includes/images/dividers.png" alt="..." class="divider"></td>
				</tr>
				<tr>
					<td valign="top"> Has Access To (uses OR rule) <div class="tool-tip">
                      <i class="fa fa-info-circle" aria-hidden="true">
                      </i>
                      <div class="toll-tip-desc">Show content only if the user has access to at least one of the selected products. <br> 
                      (Uses "OR" rule).
                    </div> </div></td>
					<td valign="top" >
						<select style=""  id="hasaccessto" style=" width: 55% !important;" name="hasaccessto" multiple="multiple" class="">
							  <option value="0" selected="selected">Select Product(s)</option>
							  <option value="0" >ANY</option>
								<?php foreach ($productList as $prod) {
									echo '<option value="'.$prod->getId().'">'.$prod->getName().'</option>';
								} ?> 
						</select>
					</td>
				</tr>
				
				<tr>
					<td valign="top"> Has Access To (uses AND rule) <div class="tool-tip">
                      <i class="fa fa-info-circle" aria-hidden="true">
                      </i>
                      <div class="toll-tip-desc">Show content only if the user has access to ALL of the selected products. <br> 
                      (Uses "AND" rule).
                    </div> </div></td>
					<td valign="top" >
						<select style=""  id="hasaccesstoand" style=" width: 55% !important;" name="hasaccesstoand" multiple="multiple" class="">
							  <option value="0" selected="selected">Select Product(s)</option>
								<?php foreach ($productList as $prod) {
									echo '<option value="'.$prod->getId().'">'.$prod->getName().'</option>';
								} ?>
						</select>
					</td>
				</tr>
                
				<tr>
					<td valign="top"> Has No Access To <div class="tool-tip">
                      <i class="fa fa-info-circle" aria-hidden="true">
                      </i>
                      <div class="toll-tip-desc">Show content only if the user does NOT have access to ALL of the selected products. <br> 
                      (Uses "AND" rule). <br>
					For e.g.  [DAP hasAccessTo="2" hasNoAccessTo="1,3" ]<br>This message will appear only to active (current) users of product 2 but don't have access to 1 and 3.<br> The "no access to" could be because user never purchased the product (no user>>product row in dap manage >> members page)<br> OR because  their access to the product has expired (row exists in dap manage >> members page but access end date has expired). [/DAP]
                   
                    </div> </div></td>
					<td valign="top" >
						<select style=""  id="hasnoaccessto" style=" width: 55% !important;" name="hasnoaccessto" multiple="multiple" class="">
							<option value="0" selected="selected">Select Product(s)</option>
							<option value="0">NONE</option>
								<?php foreach ($productList as $prod) {
									echo '<option value="'.$prod->getId().'">'.$prod->getName().'</option>';
								} ?>	 
						</select>
					</td>
				</tr>
				
				<tr>
					<td valign="top"> Has Expired Access To <div class="tool-tip">
                      <i class="fa fa-info-circle" aria-hidden="true">
                      </i>
                      <div class="toll-tip-desc">Show content only if the user's access to ALL of the selected products has expired. <br> 
                      (Uses AND rule). This message will only be displayed if the user has access to the product (user -> product row exists in manage members page but access end date has EXPIRED).  It won't be displayed if the user>>product row does not exist in manage -> members page. 
</div>
                    </div></td>
					<td valign="top" >
						<select style=""  id="hasexpiredaccessto" style=" width: 55% !important;" name="hasexpiredaccessto" multiple="multiple" class="">
							<option value="0" selected="selected">Select Product(s)</option>
							<option value="0" >ANY</option>
								<?php foreach ($productList as $prod) {
									echo '<option value="'.$prod->getId().'">'.$prod->getName().'</option>';
								} ?> 
						</select>
					</td>
				</tr>
                
                <tr>
					<td valign="top"> NEVER had Access To <div class="tool-tip">
                      <i class="fa fa-info-circle" aria-hidden="true">
                      </i>
                      <div class="toll-tip-desc">Show content only if the user never had access to ALL of the selected products. <br> 
                      (Uses AND Rule). This message will only be displayed if the user does NOT have access to ALL of the selected products in manage >> members page (user -> product row DOES NOT EXIST in manage>>members page). The message won't be displayed if the user>>product row exists in manage -> members page. 
</div>
                    </div></td>
					<td valign="top" >
						<select style=""  id="neverhadaccessto" style=" width: 55% !important;" name="neverhadaccessto" multiple="multiple" class="">
							<option value="0" selected="selected">Select Product(s)</option>
								<?php foreach ($productList as $prod) {
									echo '<option value="'.$prod->getId().'">'.$prod->getName().'</option>';
								} ?>
						</select>
					</td>
				</tr>
				
				
				<tr>
					<td colspan="2" class="dap_shortcode_popup_heading"><h4 class="mainheading">Error Message Template </h4>
					<img src="<?php echo $pluginurl; ?>includes/images/dividers.png" alt="..." class="divider"></td>
				</tr>
				<tr>
					<td valign="top"> Select an Error Message Template  <div class="tool-tip">
                      <i class="fa fa-info-circle" aria-hidden="true">
                      </i>
                      <div class="toll-tip-desc">This determines the error message to be displayed if user DOES NOT have access to the content being protected. Values can be SHORT, LONG or NO ERROR (empty). <br><br>
                      You can set the SHORT and LONG error messages in DAP Admin >> Setup >> Templates page. If you don't want any error messages to be displayed, and want the protected content to silently disappear completely (if user does not have access to it), then select "NO ERROR".
                      </div>
                    </div></td>
					<td valign="top" >
						<select  name="errmsgtemplate" id="errmsgtemplate" class="dap_cls_common">
							<option value="0" selected="selected">NO ERROR</option>
							<option value="SHORT" >SHORT</option>
							<option value="LONG">LONG</option>
						</select>
					</td>
				</tr>
				<tr>
					<td colspan="2" class="dap_shortcode_popup_heading"><h4 class="mainheading">Member-Specific Content</h4>
					<img src="<?php echo $pluginurl; ?>includes/images/dividers.png" alt="..." class="divider"></td>
				</tr>
				
				<tr>
					<td valign="top">DAP User ID <div class="tool-tip">
                      <i class="fa fa-info-circle" aria-hidden="true">
                      </i>
                      <div class="toll-tip-desc">You can now protect a piece of content so that only a specific DAP user can see it.
                      </div>
                    </div></td>
					<td valign="top" >
						<input type="text" name="userid" id="userid" value=""> 
					</td>
				</tr>
				<tr>
					<td colspan="2" class="dap_shortcode_popup_heading"><h4 class="mainheading">In-Page Dripping</h4>
					<img src="<?php echo $pluginurl; ?>includes/images/dividers.png" alt="..." class="divider"></td>
				</tr>
				
				
				<tr>
					<td valign="top"> Start Day <div class="tool-tip">
                      <i class="fa fa-info-circle" aria-hidden="true">
                      </i>
                      <div class="toll-tip-desc">Show content after the specified "start day" and stop showing it after the "end day".<br><br> 
					 Negative Days:<br>
Note:  "startday" and "endday" can also be a negative number.<br>
For eg., [DAP hasAccessTo="2" startDay="-6" endDay="-3"]Howdy[/DAP] <br><br> This basically means, the message "Howdy" will be shown starting 6 days before the "Access End Date" of the user’s access to the product with Id "2" (specified in hasAccessTo). So you can use this to display a special message – or specially priced offer (buy button) –  for those whose access has not yet expired. Last day (same day of access end date) is day 0. Day before that is -1.
                      </div>
                    </div></td>
					<td valign="top" >
						<input type="number" name="startday" id="startday" value=""> 
					</td>
				</tr>
				<tr>
					<td valign="top"> End Day <div class="tool-tip">
                      <i class="fa fa-info-circle" aria-hidden="true">
                      </i>
                      <div class="toll-tip-desc">Show content after the specified "start day" and stop showing it after the "end day". <br><br> 
So say you set start day = 2, then only logged-in members who are on day 2 of their membership to a specific product, can see that content. For e.g. [DAP hasAccessTo="2" startday="1"] This message will appear to you only to users of Product 2, on Day 1 and no further[/DAP] (REQUIRED: hasAccessTo)
                      </div>
                    </div></td>
					<td valign="top" >
						<input type="number" name="endday" id="endday" value=""> 
					</td>
				</tr>
				<tr>
					<td valign="top"> Start Date <div class="tool-tip">
                      <i class="fa fa-info-circle" aria-hidden="true">
                      </i>
                      <div class="toll-tip-desc">You can also specify actual dripping "dates" (instead of "days") by using "startdate" and "enddate" in the shortcodes to make the contents stop being shown after a certain end "date".<br> <br> 
[DAP hasAccessTo="2" startdate="2012-01-01" enddate="2012-01-31"]This message will appear to you only to users of Product 2, on between the dates of Jan 1st, 2012 and Jan 31st, 2012 - and no further[/DAP]
                      </div>
                    </div></td>
					<td valign="top" >
						<div align="left">
							<input id="startdate" name="startdate" class="date_input" type="text" value="" size="10" maxlength="10"> <span class="plainLink"><a href="javascript:void(0)"><img src="<?php echo $pluginurl; ?>includes/images/cal.gif" width="16" height="16" border="0" class="get_datepicker" alt="Pick a date"></a> (yyyy-mm-dd)</span> 
						</div>
					</td>
				</tr>
				<tr>
					<td valign="top"> End Date <div class="tool-tip">
                      <i class="fa fa-info-circle" aria-hidden="true">
                      </i>
                      <div class="toll-tip-desc">You can also specify actual dripping "dates" (instead of "days") by using "startdate" and "enddate" in the shortcodes to make the contents stop being shown after a certain end "date".
                      </div>
                    </div></td>
					<td valign="top" >
						<input id="enddate" name="enddate" class="date_input" type="text" value="" size="10" maxlength="10"> <span class="plainLink"><a href="javascript:void(0)"><img src="<?php echo $pluginurl; ?>includes/images/cal.gif" width="16" height="16" border="0" class="get_datepicker1" alt="Pick a date"></a> (yyyy-mm-dd)</span> 
					</td>
				</tr>
				
				<tr>
					<td colspan="2" class="dap_shortcode_popup_heading"><h4 class="mainheading">Public Until / After </h4>
					<img src="<?php echo $pluginurl; ?>includes/images/dividers.png" alt="..." class="divider"></td>
				</tr>
				<tr>
					<td valign="top"> Public Until <div class="tool-tip">
                      <i class="fa fa-info-circle" aria-hidden="true">
                      </i>
                      <div class="toll-tip-desc">You can set a date UNTIL which a blog post is public (no protection or rules will be applied from any other shortcode parameters.
[DAP publicUntil="2012-12-31" hasAccessTo="1"]This message will be completely public UNTIL (and including) December 31st, 2012[/DAP]

                      </div>
                    </div></td>
					<td valign="top" >
						<input type="text" name="publicuntil" id="publicuntil" value=""> 
					</td>
				</tr>
				<tr>
					<td valign="top"> Public After <div class="tool-tip">
                      <i class="fa fa-info-circle" aria-hidden="true">
                      </i>
                      <div class="toll-tip-desc">You can set a date AFTER which a blog post will become public (no protection or rules will be applied from any other shortcode parameters.
					  [DAP publicAfter="2012-01-01" hasAccessTo="1"]This message will be completely public AFTER (and including) January 1st, 2012[/DAP]

                      </div>
                    </div></td>
					<td valign="top" >
						<input type="text" name="publicafter" id="publicafter" value=""> 
					</td>
				</tr>
				<tr>
					<td valign="top">Enter HTML Content to be displayed </br> if the Shortcode Evaluates To Success<div class="tool-tip">
                      <i class="fa fa-info-circle" aria-hidden="true">
                      </i>
                      <div class="toll-tip-desc">Leave empty if you want add the content between the shortcode start and end tag  mnaually
                      </div>
                    </div></td>
					<td valign="top" >
						<div class="div_html_cls editable_textarea" style="display:block;border:1px solid #e0e0e0;padding:8px">  </div>
					</td>
				</tr>
				
				<tr>
					<td colspan="2" class="dap_shortcode_popup_heading"><h4 class="mainheading">GDPR Status</h4>
					<img src="<?php echo $pluginurl; ?>includes/images/dividers.png" alt="..." class="divider"></td>
				</tr>
				
				<tr>
					<td valign="top">GDPR Status  </td>
					<td valign="top" >
						<select   id="gdprstatus" style=" width: 100% !important;" name="gdprstatus"  class="GDPRStatuscls">
							  <option value="0">Select</option>
							   <option value="unknown">Not Known</option>
								<option value="yes">Consent YES</option>
								<option value="no">Consent NO</option>
								<option value="notgdpruser">Not a GDPR User</option> 
						</select>
					</td>
				</tr>
				
				
			</table>
		
			  
			  <div class="shortcode_container" > 
				  <h5>Here is the DAP Shortcode</h5>
			 <textarea> </textarea>
		  </div>  
     
			<div align="center" class="btn_outer">
				<button class="button-primary next-btn" id="dapshortcodebtn">Generate Shortcode</button>
		    </div>
 

  </div>  
</div>
</div>
 
