<?php
##############################################################
##In-portal													##
##############################################################
##					      In-portal							##
##					Intechnic Corporation					##
##			   All Rights Reserved, 1998-2002				##
##															##	
##	No portion of this code may be copied, reproduced or	##	
##	   otherwise redistributed without proper written		##
##	  consent of Intechnic Corporation.  Violation will		##
##	   result in revocation of the license and support		##
##	 privileges along maximum prosecution allowed by law.	##
##############################################################
if( !(isset($pathtoroot) && $pathtoroot) )
{
  $path=dirname(realpath(__FILE__));
  if(strlen($path))
  {
    /* determine the OS type for path parsing */
    $pos = strpos($path,":");
    if ($pos === false)
    {
      $gOS_TYPE="unix";
      $pathchar = "/";
    }
    else
    {
      $gOS_TYPE="win";
      $pathchar="\\";
    }
    $p = $path.$pathchar;
    /*Start looking for the root flag file */
    while(!strlen($pathtoroot) && strlen($p))
    {
      $sub = substr($p,strlen($pathchar)*-1);
      if($sub==$pathchar)
      {
        $filename = $p."root.flg";
      }
      else
        $filename = $p.$pathchar."root.flg";
      if(file_exists($filename))
      {
        $pathtoroot = $p;
      }
      else
      {
        $parent = realpath($p.$pathchar."..".$pathchar);
	if($parent!=$p)
	{
	  $p = $parent;
	}
	else
	  $p = "";
      }
    }
    if( !(isset($pathtoroot) && $pathtoroot) )
      $pathtoroot = ".".$pathchar;
  }
  else
  {
    $pathtoroot = ".".$pathchar;
  }
}

$sub = substr($pathtoroot,strlen($pathchar)*-1);
if($sub!=$pathchar)
{
  $pathtoroot = $pathtoroot.$pathchar;
}

require_once($pathtoroot."kernel/startup.php");
$rootURL="http://".ThisDomain().$objConfig->Get("Site_Path");
$admin = $objConfig->Get("AdminDirectory");
if(!strlen($admin))
    $admin = "admin";

$adminURL = $rootURL.$admin;
$imagesURL = $adminURL."/images"; 
$cssURL = $adminURL."/include";
$browseURL = $adminURL."/browse";

$pathtolocal = $pathtoroot."kernel/";
require_once ($pathtoroot.$admin."/include/elements.php");
require_once ($pathtoroot."kernel/admin/include/navmenu.php");
require_once($pathtoroot.$admin."/browse/toolbar.php");
require_once($pathtoroot.$admin."/listview/listview.php");

//Multiedit init
$en = (int)GetVar('en');

$ids=GetVar('reviewlist');
$objEditItems = new clsItemReviewList();
$objEditItems->CopyToEditTable(null,$ids);
$objEditItems->SetTable('edit');

if($ids)
{
	$ReviewId=is_array($ids)?array_shift($ids):$ids;
	$Rev = $objEditItems->GetItem($ReviewId);
	$action = 'm_review_direct_edit';
}

$envar = "env=" . BuildEnv() . "&en=$en";

/*$m = GetModuleArray();
foreach($m as $key => $value)
{
    $path = $pathtoroot.$value."admin/include/parser.php";
    if( file_exists($path) ) include_once($path);
}

$module_info=$objModules->ExecuteFunction('GetModuleInfo','review_section');
$section = $module_info[$Rev->Get('Module')]; */

$section='in-portal:editreview_direct';

$ado = &GetADODBConnection();


/**
 * Returns username by user id specified
 *
 * @param int $user_id
 * @return string
 * @access public
 */
function getUsernameByID($user_id)
{
	global $objUsers;
	if(!($user_id>0) || !$user_id) return 'root';
	$u = $objUsers->GetUser($user_id);
	return $u->Get('Login');
}


$user_id=is_numeric($Rev->Get("CreatedById"))?$Rev->Get('CreatedById'):$objSession->Get('PortalUserId');
$login_name=getUsernameByID($user_id);
		
$title = GetTitle('la_text_Review','la_tab_General',$Rev->UniqueId());

$objListToolBar = new clsToolBar();
$objListToolBar->Add("img_save", "la_Save","#","swap('img_save','toolbar/tool_select_f2.gif');", "swap('img_save', 'toolbar/tool_select.gif');","edit_submit('review','ReviewEditStatus','admin/reviews.php',1);",$imagesURL."/toolbar/tool_select.gif");
$objListToolBar->Add("img_cancel", "la_Cancel","#","swap('img_cancel','toolbar/tool_cancel_f2.gif');", "swap('img_cancel', 'toolbar/tool_cancel.gif');","edit_submit('review','ReviewEditStatus','admin/reviews.php',-1);",$imagesURL."/toolbar/tool_cancel.gif");
int_header($objListToolBar,NULL,$title);
if ($objSession->GetVariable("HasChanges") == 1) {
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="toolbar">
  <tr>
    <td valign="top">
      <?php int_hint_red(admin_language("la_Warning_Save_Item")); ?>
    </td>
  </tr>
</table>
<?php } ?>
<TABLE cellSpacing="0" cellPadding="2" width="100%" class="tableborder">
<FORM ID="review" NAME="review" method="POST" ACTION="">

<?php int_subsection_title("Review"); ?>
  <tr <?php int_table_color(); ?>> 
    <td valign="top" colspan="3"><?php echo prompt_language("la_prompt_Enable_HTML"); ?> 
      <input type="checkbox" ID="html_enable" tabindex="1" name="html_enable" value="1" <?php if($Rev->Get("TextFormat")==1) echo "CHECKED"; ?>>
      <br>
      <?php int_hint(prompt_language("la_Warning_Enable_HTML")); ?>
    </td>
  </tr>
  <tr <?php int_table_color(); ?>> 
    <td valign="top"><span class="text"><?php echo prompt_language("la_prompt_ReviewId"); ?></span></td>
    <td> 
       <span class="text"><?php echo $Rev->Get("ReviewId"); ?></span>
    </td>
    <td><span class="text">&nbsp;</span></td>
  </tr>

      <tr <?php int_table_color(); ?>> 
    <td valign="top"><span class="text" id="prompt_createdby"><?php echo prompt_language("la_prompt_CreatedBy"); ?></span></td>
    <td> 
       <span class="text">
     		<input type="text" tabindex="1" ValidationType="exists" name="createdby" class="text" size="40" value="<?php echo inp_textarea_unescape($login_name); ?>">      
     		<a href="#">
          		 <img src="<?php echo $imagesURL; ?>/icon24_link_user.gif" style="cursor:hand" border="0"
         		 ONCLICK="OpenUserSelector('','','<?php echo $envar; ?>&Selector=radio&destform=review&destfield=createdby&IdField=Login');">
         	</a>       
       </span>
    </td>
    <td><span class="text">&nbsp;</span></td>
  </tr>


  <tr <?php int_table_color(); ?>> 
    <td valign="top"><SPAN id="prompt_review_body" class="text"><?php echo prompt_language("la_prompt_ReviewText");  ?></SPAN><br>
    <a href="#">
         <img src="<?php echo $imagesURL; ?>/icon24_link_editor.gif" style="cursor:hand" border="0"
             ONCLICK="document.getElementById('html_enable').checked = true; OpenEditor('&section=<?php echo $section; ?>','link','review_body');">
         </a>   
       </td>
    <td> 
      <textarea rows="8" tabindex="2" ValidationType="exists" name="review_body" cols="70" class="text"><?php echo inp_textarea_unescape(inp_htmlize($Rev->parsetag("review_text"))); ?></textarea>
    </td>
    <td></td>
  </tr>

  <?php int_subsection_title("General"); ?>

  <tr <?php int_table_color(); ?>> 
    <td valign="top" class="text"><?php echo prompt_language("la_prompt_Status"); ?></td>
    <td> 
      <input type="radio" tabindex="3" name="status" class="text" value="1" <?php if($Rev->Get("Status") == 1) echo "checked"; ?>><?php echo prompt_language("la_val_Active"); ?>
      <input type="radio" tabindex="3" name="status" class="text" value="2" <?php if($Rev->Get("Status") == 2) echo "checked"; ?>><?php echo prompt_language("la_val_Pending"); ?>
      <input type="radio" tabindex="3" name="status" class="text" value="0" <?php if($Rev->Get("Status") == 0) echo "checked"; ?>><?php echo prompt_language("la_val_Disabled"); ?>
     </td>
    <td class="text">&nbsp;</td>
  </tr>

  <tr <?php int_table_color(); ?>> 
    <td valign="top" class="text"><?php echo prompt_language("la_prompt_Priority"); ?></td>
    <td> 
        <input type="text" tabindex="4" name="review_priority" class="text" size="3" value="<?php echo $Rev->Get("Priority"); ?>">
    </td>
    <td class="text">&nbsp;</td>
  </tr>

  <tr <?php int_table_color(); ?>> 
    <td valign="top"><SPAN ID="prompt_review_date" class="text"><?php echo prompt_language("la_prompt_CreatedOn"); ?></SPAN></td>
    <td> 
      <input type="text" name="review_date" tabindex="5" id="review_date_id" datepickerIcon="<?php echo $adminURL; ?>/images/ddarrow.gif" class="text" size="20" value="<?php echo $Rev->parsetag("review_created_date"); ?>">
      <span class="small"><?php echo prompt_language("la_prompt_DateFormat"); ?></span></td>
    <td></td>
  </tr>
  <tr <?php int_table_color(); ?>> 
    <td valign="top"><SPAN id="prompt_review_time" class="text"><?php echo prompt_language("la_prompt_CreatedOn_Time"); ?></SPAN></td>
    <td> 
      <input type="text" tabindex="6" name="review_time" class="text" size="20" value="<?php echo $Rev->parsetag("review_created_time"); ?>">
      <span class="small"><?php echo prompt_language("la_prompt_TimeFormat"); ?></span></td>
    <td></td>
  </tr>
    <INPUT TYPE="hidden" NAME="CreatedById" value = "<?php echo $Rev->Get("CreatedById"); ?>">
    <input type="hidden" name="ReviewId" value ="<?php echo $Rev->Get("ReviewId"); ?>">
    <input type="hidden" name="ItemId" value ="<?php echo $Rev->Get("ItemId"); ?>">
    <input type="hidden" name="ItemType" value ="<?php echo $Rev->Get("ItemType"); ?>">
    <input type="hidden" name="Action" value="<?php echo $action; ?>">
    <input type="hidden" name="ReviewEditStatus" VALUE="0">
</FORM>
</TABLE>
<FORM NAME="save_edit_buttons" ID="save_edit_buttons" method="POST" ACTION="">
    <input type=hidden NAME="Action" VALUE="save_cat_edit">
    <input type="hidden" name="ReviewEditStatus" VALUE="0">
</FORM>
<!-- CODE FOR VIEW MENU -->
<form method="post" action="<?php echo $_SERVER["PHP_SELF"]."?".$envar; ?>" name="viewmenu">
<input type="hidden" name="fieldname" value="">
<input type="hidden" name="varvalue" value="">
<input type="hidden" name="varvalue2" value="">
<input type="hidden" name="Action" value="">
</form>
<script src="<?php echo $adminURL; ?>/include/calendar.js"></script>
<SCRIPT language="JavaScript">
    initCalendar("review_date_id", CalDateFormat);
    MarkAsRequired(document.getElementById("review"));
</SCRIPT>  

<!-- END CODE-->
<?php int_footer(); ?>