Page MenuHomeIn-Portal Phabricator

in-portal
No OneTemporary

File Metadata

Created
Sat, Feb 1, 8:50 PM

in-portal

This file is larger than 256 KB, so syntax highlighting was skipped.
Index: trunk/kernel/action.php
===================================================================
--- trunk/kernel/action.php (revision 287)
+++ trunk/kernel/action.php (revision 288)
@@ -1,2223 +1,2261 @@
<?php
$ro_perm = $objSession->HasSystemPermission("SYSTEM_ACCESS.READONLY");
if( defined('DEBUG_ACTIONS') && (DEBUG_ACTIONS & KERNEL_ACTIONS) == KERNEL_ACTIONS )
{
if($Action) echo '<span class="debug_text">Kernel Action [<b>'.$Action."</b>]</span><br>\n";
}
if( defined('DEBUG_ACTIONS') && (DEBUG_ACTIONS & SHOW_REQUEST) == SHOW_REQUEST )
{
// don't show debug output in tree & header of admin & while logging in
$script = basename($_SERVER['PHP_SELF']);
$skip_debug = Array('index.php','tree.php','head.php','credits.php');
if( !in_array($script, $skip_debug) )
{
echo "ScriptName: <b>$script</b> (<b>".dirname($_SERVER['PHP_SELF'])."</b>)<br><br>";
$div_height = (count($_REQUEST)+1)*26;
if($div_height > 300) $div_height = 300;
echo '<div class="debug_layer" style="height: '.$div_height.'px;">';
echo '<table border="0" cellspacing="0" cellpadding="4" class="debug_table">';
echo '<thead style="font-weight: bold;"><td>Src</td><td>Name</td><td>Value</td></thead>';
foreach($_REQUEST as $key => $value)
{
if( !is_array($value) && trim($value) == '' ) $value = '&nbsp;';
$src = isset($_GET[$key]) ? 'GE' : (isset($_POST[$key]) ? 'PO' : (isset($_COOKIE[$key]) ? 'CO' : '?') );
echo '<tr><td>'.$src.'</td><td>'.$key.'</td><td>'.print_r($value, true).'</td></tr>';
}
echo '</table></div>';
echo '<a href="javascript:self.location.reload();">Reload Frame</a>';
}
unset($script, $skip_debug);
}
switch($Action)
{
+ case "m_save_import_config":
+ // Set New Import Category
+ if( isset($_POST['categorylist']) )
+ {
+ $cat_id = $_POST['categorylist'];
+ $objSession->SetVariable('categoryid', $cat_id);
+ $cat = $objCatList->GetByResource($cat_id);
+ if(is_object($cat))
+ {
+ $navbar = $cat->Get('CachedNavbar');
+ $objSession->SetVariable('catnavbar', $navbar);
+ $objSession->SetVariable('import_category_id', $cat->UniqueId() );
+ }
+ $objSession->SetVariable('categorylist', $_POST['categorylist']);
+ }
+
+ // Set Import Admin Group
+ if( isset($_POST['grouplist1']) )
+ {
+ $group_id = $_POST['grouplist1'];
+ $group = $objGroups->GetItem($group_id);
+ $objSession->SetVariable('user_admin_names', $group->Get('Name'));
+ $objSession->SetVariable('user_admin_values', $group->Get('GroupId'));
+ $objSession->SetVariable('grouplist1', $_POST['grouplist1']);
+ }
+
+ // Set Import User Group
+ if( isset($_POST['grouplist2']) )
+ {
+ $group_id = $_POST['grouplist2'];
+ $group = $objGroups->GetItem($group_id);
+ $objSession->SetVariable('user_regular_names', $group->Get('Name'));
+ $objSession->SetVariable('user_regular_values', $group->Get('GroupId'));
+ $objSession->SetVariable('grouplist2', $_POST['grouplist2']);
+ }
+ break;
+
case "m_add_user":
$dupe_user = '';
//$user_pending = (int)$_POST["user_pending"];
//$user_enabled = (int)$_POST["user_enabled"];
$CreatedOn = DateTimestamp($_POST["user_date"],GetDateFormat());
$dob = DateTimestamp($_POST["user_dob"],GetDateFormat());
$objEditItems = new clsUserManager();
$objEditItems->SourceTable = $objSession->GetEditTable("PortalUser");
if(strlen($_POST["user_login"]))
$id = $objUsers->GetUserId($_POST["user_login"]);
else
$dob = 0;
if($id)
{
$lvErrorString = language('la_error_duplicate_username');
$dupe_user = $_POST["user_login"];
$_POST["user_login"] = '';
}
$password = md5($_POST["password"]);
$u = $objEditItems->Add_User($_POST["user_login"], $password,
$_POST["user_email"], $CreatedOn, $_POST["user_firstname"],
$_POST["user_lastname"], $_POST["status"],
$_POST["user_phone"],
$_POST["user_street"], $_POST["user_city"],
$_POST["user_state"], $_POST["user_zip"], $_POST["user_country"], $dob);
$objCustomEdit = new clsCustomDataList(); //$objSession->GetEditTable("CustomMetaData"));
$objCustomEdit->SetTable('edit');
$objCustomEdit->LoadResource($u->Get("ResourceId"));
$CustomFields = new clsCustomFieldList(6);
$DataChanged = FALSE;
foreach($_POST as $key=>$value)
{
if(substr($key,0,1)=="_")
{
$field = substr($key,1);
$cvalue = $CustomFields->GetItemByField("FieldName",$field,FALSE);
if(is_object($cvalue))
{
$objCustomEdit->SetFieldValue($cvalue->Get("CustomFieldId"),$u->Get("ResourceId"),$value);
$DataChanged = TRUE;
}
}
}
if($DataChanged) $objCustomEdit->SaveData();
$objCustomEdit->SetTable('live');
break;
case "m_edit_user":
$CreatedOn = DateTimestamp($_POST["user_date"],GetDateFormat());
$dob = DateTimestamp($_POST["user_dob"],GetDateFormat());
$objEditItems = new clsUserManager();
$objEditItems->SourceTable = $objSession->GetEditTable("PortalUser");
//$user_pending = (int)$_POST["user_pending"];
//$user_enabled = (int)$_POST["user_enabled"];
$UserId = (int)$_POST["user_id"];
//echo $UserId."<br>\n";
if(!strlen($_POST["user_login"]))
$dob = 0;
if(strlen($_POST["password"]))
{
$password = md5($_POST["password"]);
}
else
$password = "";
$u = $objEditItems->Edit_User($UserId, $_POST["user_login"], $password,
$_POST["user_email"], $CreatedOn, $_POST["user_firstname"],
$_POST["user_lastname"], $_POST["status"],
$_POST["user_phone"],
$_POST["user_street"], $_POST["user_city"],
$_POST["user_state"], $_POST["user_zip"], $_POST["user_country"],
$dob);
$objCustomEdit = new clsCustomDataList(); //$objSession->GetEditTable("CustomMetaData"));
$objCustomEdit->SetTable('edit');
$DataChanged = false;
$objCustomEdit->LoadResource($u->Get("ResourceId"));
$CustomFields = new clsCustomFieldList(6);
foreach($_POST as $key=>$value)
{
if(substr($key,0,1)=="_")
{
$field = substr($key,1);
$cvalue = $CustomFields->GetItemByField("FieldName",$field,FALSE);
if(is_object($cvalue))
{
//echo "Saving CF: (".$cvalue->Get("CustomFieldId")." ; ".$u->Get("ResourceId")." ; $value)<br>";
$objCustomEdit->SetFieldValue($cvalue->Get("CustomFieldId"),$u->Get("ResourceId"),$value);
$DataChanged = TRUE;
}
}
}
if($DataChanged)
$objCustomEdit->SaveData();
$objCustomEdit->SetTable('live');
break;
case "m_user_primarygroup":
//print_pre($_REQUEST);
if($ro_perm) break;
$users = explode(',', $_POST["userlist"]);
$GroupResourceId = $_POST['grouplist'];
$g = $objGroups->GetItemByField("ResourceId", $GroupResourceId);
$GroupId = $g->UniqueId();
if( is_array($users) )
foreach($users as $user_id)
{
$u = $objUsers->GetItemByField("ResourceId", $user_id);
$g->AddUser($u->Get("PortalUserId"), 1);
}
break;
case "m_edit_group":
$objEditItems = new clsGroupList();
$objEditItems->SourceTable = $objSession->GetEditTable("PortalGroup");
$objEditItems->Edit_Group($_POST["group_id"], $_POST["group_name"],$_POST["group_comments"]);
break;
case "m_add_group":
$objEditItems = new clsGroupList();
$objEditItems->SourceTable = $objSession->GetEditTable("PortalGroup");
$objEditItems->Add_Group($_POST["group_name"], $_POST["group_comments"],0);
break;
case "m_group_sysperm":
if($_POST["GroupEditStatus"]==0)
{
$objSession->ResetSysPermCache();
$GroupId = $_POST["GroupId"];
if($GroupId)
{
$objEditItems = new clsGroupList();
$objEditItems->SourceTable = $objSession->GetEditTable("PortalGroup");
$g = $objEditItems->GetItemByField("ResourceId",$GroupId);
if(is_object($g))
{
$PermList = explode(",",$_POST["PermList"]);
for($i=0;$i<count($PermList);$i++)
{
if(@in_array($PermList[$i],$_POST["inherit"]))
{
$value = -1;
}
else
{
$value = 0;
if(@in_array($PermList[$i],$_POST["permvalue"]))
$value = 1;
}
$g->SetSystemPermission($PermList[$i],$value);
}
}
}
}
break;
case "m_user_sysperm":
if($ro_perm) break;
if($_POST["UserEditStatus"]==0)
{
$UserId = $_POST["ItemId"];
if($UserId)
{
$objEditItems = new clsUserManager();
$objEditItems->SourceTable = $objSession->GetEditTable("PortalUser");
$u = $objEditItems->GetItemByField("ResourceId",$UserId);
unset($g);
if(is_object($u))
{
$objSession->ResetSysPermCache();
$g = $u->GetPersonalGroup(FALSE);
$PermList = explode(",",$_POST["PermList"]);
for($i=0;$i<count($PermList);$i++)
{
if(!@in_array($PermList[$i],$_POST["inherit"]))
{
if(!is_object($g))
$g = $u->GetPersonalGroup(TRUE);
$value = 0;
if(is_array($_POST["permvalue"]))
{
if(in_array($PermList[$i],$_POST["permvalue"]))
$value =1;
$g->SetSystemPermission($PermList[$i],$value);
}
else
$g->SetSystemPermission($PermList[$i],-1);
}
else
{
if(is_object($g))
$g->SetSystemPermission($PermList[$i],-1);
}
}
}
}
}
break;
case "m_approve_user":
if($ro_perm) break;
foreach($_POST["itemlist"] as $userid)
{
$user = $objUsers->GetItemByField("ResourceId",$userid);
$user->Approve();
}
$objUsers->Clear();
break;
case "m_deny_user":
if($ro_perm) break;
foreach($_POST["itemlist"] as $userid)
{
$user = $objUsers->GetItemByField("ResourceId",$userid);
$user->Deny();
}
$objUsers->Clear();
break;
case "m_delete_user":
if($ro_perm) break;
foreach($_POST["itemlist"] as $userid)
$objUsers->Delete_User($userid);
break;
case "m_delete_group":
if($ro_perm) break;
foreach($_POST["itemlist"] as $groupid)
{
$objGroups->Delete_Group($groupid);
}
break;
case "m_user_assign":
$useridlist = implode("-", $userlist);
$objSession->SetUserStatus($useridlist, "g_usergroup_status");
$g_usergroup_status = $useridlist;
break;
case "m_group_assign":
foreach($grouplist as $group)
$objGroups->Add_Users_To_Group($group);
break;
case "m_remove_group":
$adodbConnection = GetAdodbConnection();
$adodbConnection->Execute("DELETE FROM UserGroup where UserId='$UserId' AND GroupId='$GroupId'");
break;
case "m_SetVariable":
$objSession->SetPersistantVariable($_POST["fieldname"], $_POST["varvalue"]);
break;
case "m_SetSessionVariable":
$objSession->SetVariable($_POST["fieldname"], $_POST["varvalue"]);
//echo "Setting $fieldname to $varvalue<br>\n";
if($_POST["fieldname"]=="SearchType")
$objSession->SetVariable("SearchWord","");
break;
case "m_edit_permissions":
if($ro_perm) break;
if($_POST["CatEditStatus"] != -1)
{
$objSession->SetVariable('PermCache_UpdateRequired', 1);
$GroupId = $_POST["GroupId"];
$CatId = $_POST["CategoryId"];
$Module = $_POST["Module"];
$ado = GetADODBConnection();
$sql = "SELECT * FROM ".GetTablePrefix()."PermissionConfig WHERE ModuleId='$Module'";
$rs = $ado->Execute($sql);
$PermNames = array();
while($rs && !$rs->EOF)
{
$data = $rs->fields;
$PermNames[] = $data["PermissionName"];
$rs->MoveNext();
}
$inherit = array();
if(is_array($_POST["inherit"]))
{
foreach($_POST["inherit"] as $perm)
{
$inherit[$perm] = 1;
}
}
$access = array();
if(is_array($_POST["permvalue"]))
{
foreach($_POST["permvalue"] as $perm)
{
$access[$perm] = 1;
}
}
$objPermList = new clsPermList($CatId,$GroupId);
$objPermList->LoadCategory($CatId);
for($i=0;$i<count($PermNames);$i++)
{
if(!array_key_exists($PermNames[$i],$inherit))
{
$PermValue = (int)$access[$PermNames[$i]];
$Perm = $objPermList->GetPermByName($PermNames[$i]);
if($Perm)
{
$Id = $Perm->Get("PermissionId");
//echo "Editing $Id<br>\n";
$objPermList->Edit_Permission($Id,$CatId,$GroupId,$PermNames[$i],$PermValue,0);
}
else
{
//echo "Adding ".$PermNames[$i];
$objPermList->Add_Permission($CatId,$GroupId,$PermNames[$i],$PermValue,0);
}
}
else
{
$Perm = $objPermList->GetPermByName($PermNames[$i]);
if($Perm)
{
$Id = $Perm->Get("PermissionId");
$objPermList->Delete_Permission($Id);
}
}
}
//$c = $objCatList->GetItem($CatId);
//$glist = $objGroups->GetAllGroupList();
//$ViewList = $objPermList->GetGroupPermList($c,"CATEGORY.VIEW",$glist );
//$c->SetViewPerms("CATEGORY.VIEW",$ViewList,$glist);
//$c->Update();
}
break;
case "m_perm_delete_group":
$ado = GetADODBConnection();
$CatId = $_POST["CategoryId"];
foreach($_POST["itemlist"] as $groupid)
{
$g = $objGroups->GetItemByField("ResourceId",$groupid);
if(is_object($g))
{
$sql = "DELETE FROM ".GetTablePrefix()."Permissions WHERE CatId=$CatId AND GroupId=".$g->Get("GroupId");
if($objSession->HasSystemPermission("DEBUG.LIST"))
echo $sql."<br>\n";
$ado->Execute($sql);
}
}
break;
case "m_user_addto_group":
if($ro_perm) break;
$user = $_POST["UserId"];
if(is_numeric($user))
{
if(strlen($_POST["grouplist"]))
{
$groups = explode(",",$_POST["grouplist"]);
if(is_array($groups))
{
for($i=0; $i<count($groups);$i++)
{
$g = $objGroups->GetItemByField("ResourceId",$groups[$i]);
$g->AddUser($user);
}
}
else
{
$g = $objGroups->GetItem($groups);
$g->AddUser($user);
}
}
}
break;
case "m_group_add_user":
if($ro_perm) break;
$group = $_POST["GroupId"];
$EditGroups = new clsGroupList();
$EditGroups->SourceTable = $objSession->GetEditTable($objGroups->SourceTable);
$g = $EditGroups->GetItem($group);
// echo "Group: $group <br>\n";
if(is_numeric($group))
{
$users = explode(",",$_POST["userlist"]);
foreach($users as $userid)
{
$u = $objUsers->GetItemByField("ResourceId",$userid);
$g->AddUser($u->Get("PortalUserId"));
}
}
break;
case "m_group_removeuser":
if($ro_perm) break;
$group = $_POST["GroupId"];
$g = $objGroups->GetItem($group);
if($group>0)
{
foreach($_POST["itemlist"] as $user_id)
{
$u = $objUsers->GetItemByField("ResourceId",$user_id);
$g->DeleteUser($u->Get("PortalUserId"));
}
}
break;
case "m_user_removegroup":
if($ro_perm) break;
$user = $_POST["UserId"];
if($user>0)
{
foreach($_POST["itemlist"] as $groupid)
{
$g = $objGroups->GetItem($groupid);
$g->DeleteUser($user);
}
}
break;
case "m_sendmail":
$idlist = explode(",",$_POST["idlist"]);
$html = (int)$_POST["html_enable"];
$body = inp_escape($_POST["email_body"],$html);
$subject = inp_escape($_POST["email_body"],$html);
$Email = new clsEmailMessage();
$Email->Set("Subject",$subject);
$Email->Set("Template",$body);
if($html)
$Email->Set("MessageType","HTML");
if(count($idlist)>0)
{
switch($_POST["IdType"])
{
case "group":
foreach($idlist as $id)
$Email->SendToGroup($id);
break;
case "user":
foreach($idlist as $id)
$Email->SendToUser($id);
break;
}/*switch*/
}
break;
case "m_item_recount":
RunDown($m_var_list["cat"],"UpdateCacheCounts");
break;
case "m_cat_delete":
if($objSession->HasCatPermission("CATEGORY.DELETE",$objCatList->CurrentCategoryID()))
{
if(isset($_POST["catlist"]))
{
if(is_array($_POST["catlist"]))
foreach($_POST["catlist"] as $catid)
{
$objCatList->Delete_Category($catid);
}
}
}
break;
case "m_cat_cut":
if(isset($_POST["catlist"]))
{
if($objSession->HasCatPermission("CATEGORY.DELETE",$catid))
{
$objCatList->CopyToClipboard("CUT","CategoryId",$_POST["catlist"]);
}
else
$objCatList->CopyToClipboard("COPY","CategoryId",$_POST["catlist"]);
}
break;
case "m_cat_copy":
if(isset($_POST["catlist"]))
{
$objCatList->CopyToClipboard("COPY","CategoryId",$_POST["catlist"]);
}
break;
case "m_paste":
if($objCatList->ItemsOnClipboard()>0)
{
/* category's paste function populates a sparse array where array[old_id]=new_id */
$PastedCatIds = array();
$objCatList->PasteFromClipboard($objCatList->CurrentCategoryID(),"Name");
}
else
{
$clip = $objSession->GetVariable("ClipBoard");
if(strlen($clip))
{
$ClipBoard = ParseClipboard($clip);
$Action= strtolower($ClipBoard["table"])."_paste";
}
}
break;
case "m_cat_move_up":
if (isset($_POST["catlist"]))
{
foreach($_POST["catlist"] as $catid)
{
$cat =& $objCatList->GetCategory($catid);
$cat->MoveUp();
}
}
break;
case "m_cat_move_down":
if (isset($_POST["catlist"]))
{
$catlist=array_reverse($_POST["catlist"]);
foreach($catlist as $catid)
{
$cat =& $objCatList->GetCategory($catid);
$cat->MoveDown();
}
}
break;
case "m_cat_approve":
if (isset($_POST["catlist"]))
{
foreach($_POST["catlist"] as $catid)
{
$cat =& $objCatList->GetCategory($catid);
$cat->Approve();
}
}
break;
case "m_cat_decline":
if (isset($_POST["catlist"]))
{
foreach($_POST["catlist"] as $catid)
{
$cat =& $objCatList->GetCategory($catid);
// $cat->Deny();
RunDown($catid,"Deny");
}
}
break;
case "m_rel_delete":
$adodbConnection= GetADODBConnection();
$table = $objSession->GetEditTable("Relationship");
if(isset($_POST["itemlist"]))
{
if(is_array($_POST["itemlist"]))
{
foreach($_POST["itemlist"] as $id)
{
$sql = "DELETE FROM ".$table." WHERE RelationshipId=".$id;
$adodbConnection->Execute($sql);
if($objSession->HasSystemPermission("DEBUG.LIST"))
echo $sql."<br>\n";
}
}
else
{
$sql = "DELETE FROM ".$table." WHERE RelationshipId=".$_POST["itemlist"];
$adodbConnection->Execute($sql);
if($objSession->HasSystemPermission("DEBUG.LIST"))
echo $sql."<br>\n";
}
}
break;
case "m_add_relation":
if($_POST["CatEditStatus"]==0)
{
$RelList = new clsRelationshipList();
$RelList->SourceTable = $objSession->GetEditTable("Relationship");
//$r = $RelList->Add($_POST["SourceId"],$_POST["SourceType"],$_POST["TargetId"],$_POST["TargetType"],
// 0,(int)$_POST["Enabled"],$_POST["RelType"], $Rel);
$ado = GetADODBConnection();
$rs = $ado->Execute("SELECT MIN(RelationshipId) as MinValue FROM ".$RelList->SourceTable);
$NewId = $rs->fields["MinValue"]-1;
$r = $RelList->Add($_POST["SourceId"],$_POST["SourceType"],$_POST["TargetId"],$_POST["TargetType"],
0,(int)$_POST["Enabled"],$_POST["RelType"], $NewId);
$sql = "UPDATE ".$RelList->SourceTable." SET RelationshipId=".$NewId." WHERE RelationshipId=".$r->Get("RelationshipId");
if($objSession->HasSystemPermission("DEBUG.LIST"))
echo $sql."<br>\n";
$ado->Execute($sql);
}
break;
case "m_edit_relation":
if($_POST["CatEditStatus"]==0)
{
$RelList = new clsRelationshipList();
$RelList->SourceTable = $objSession->GetEditTable("Relationship");
$r = $RelList->GetItem($_POST["RelationshipId"]);
if(is_object($r))
{
$r->Set("Enabled",(int)$_POST["Enabled"]);
$r->Set("Type",(int)$_POST["RelType"]);
$r->Set("Priority",(int)$_POST["priority"]);
$r->Update();
}
}
break;
case "m_rel_move_up":
$objRelList = new clsRelationshipList();
$objRelList->SourceTable = $objSession->GetEditTable("Relationship");
if (isset($_POST["itemlist"]))
{
foreach($_POST["itemlist"] as $id)
{
$r = $objRelList->GetItem($id);
$r->MoveUp($_POST["SourceId"]);
}
}
break;
case "m_rel_move_down":
$objRelList = new clsRelationshipList();
$objRelList->SourceTable = $objSession->GetEditTable("Relationship");
if (isset($_POST["itemlist"]))
{
$itemlist=array_reverse($_POST["itemlist"]);
foreach($itemlist as $id)
{
$r = $objRelList->GetItem($id);
$r->MoveDown($_POST["SourceId"]);
}
}
break;
case "m_add_category":
if(ValidDate($_POST["cat_date"],GetDateFormat()))
{
$CreatedOn = DateTimestamp($_POST["cat_date"],GetDateFormat());
}
else
$CreatedOn = time();
$html = (int)$_POST["html_enable"];
$cat_pick = $_POST["cat_pick"];
$Status = (int)$_POST["status"];
$Hot=(int)$_POST["itemhot"];
$Pop = (int)$_POST["itempop"];
$New = (int)$_POST["itemnew"];
$objEditItems = new clsCatList();
$objEditItems->SourceTable = $objSession->GetEditTable("Category");
$cat = $objEditItems->Add($_POST["ParentId"], $_POST["cat_name"], inp_escape($_POST["cat_desc"],$html), $CreatedOn,
$cat_pick, $Status, $Hot, $New, $Pop, $_POST["Priority"],
$_POST["meta_keywords"],$_POST["meta_desc"]);
$objCustomEdit = new clsCustomDataList($objSession->GetEditTable("CustomMetaData"));
$objCustomEdit->LoadResource($cat->Get("ResourceId"));
$CustomFields = new clsCustomFieldList(1);
$DataChanged = FALSE;
foreach($_POST as $key=>$value)
{
if(substr($key,0,1)=="_")
{
$field = substr($key,1);
$cvalue = $CustomFields->GetItemByField("FieldName",$field,FALSE);
if(is_object($cvalue))
{
$objCustomEdit->SetFieldValue($cvalue->Get("CustomFieldId"),$cat->Get("ResourceId"),$value);
$DataChanged = TRUE;
}
}
}
if($DataChanged)
$objCustomEdit->SaveData();
break;
case "m_edit_category":
$CreatedOn = DateTimestamp($_POST["cat_date"],GetDateFormat());
$cat_pick = $_POST["cat_pick"];
$Status = (int)$_POST["status"];
$Hot=(int)$_POST["itemhot"];
$Pop = (int)$_POST["itempop"];
$New = (int)$_POST["itemnew"];
$html = (int)$_POST["html_enable"];
$objEditItems = new clsCatList();
$objEditItems->SourceTable = $objSession->GetEditTable("Category");
// check if name of cat isn't changed: begin
$original_cats = new clsCatList();
$original_cat = $original_cats->GetItemByField('CategoryId', $_POST['CategoryId']);
if( $original_cat->Get('Name') != $_POST['cat_name'] )
$objSession->SetVariable('PermCache_UpdateRequired', 1);
unset($original_cat, $original_cats);
// check if name of cat isn't changed: end
$cat = $objEditItems->Edit_Category($_POST["CategoryId"],inp_escape($_POST["cat_name"],$html), inp_escape($_POST["cat_desc"],$html), $CreatedOn, $cat_pick, $Status, $Hot, $New, $Pop, $_POST["Priority"], $_POST["meta_keywords"], $_POST["meta_desc"]);
$objCustomEdit = new clsCustomDataList($objSession->GetEditTable("CustomMetaData"));
$objCustomEdit->LoadResource($cat->Get("ResourceId"));
$CustomFields = new clsCustomFieldList(1);
$DataChanged = FALSE;
foreach($_POST as $key=>$value)
{
if(substr($key,0,1)=="_")
{
$field = substr($key,1);
$cvalue = $CustomFields->GetItemByField("FieldName",$field,FALSE);
if(is_object($cvalue))
{
$objCustomEdit->SetFieldValue($cvalue->Get("CustomFieldId"),$cat->Get("ResourceId"),$value);
$DataChanged = TRUE;
}
}
}
if($DataChanged)
$objCustomEdit->SaveData();
break;
case "m_edit_custom_data":
$id = $_POST["ItemId"];
$objEditData = new clsCustomDataList(); //$objSession->GetEditTable("CustomMetaData"));
$objEditData->SetTable('edit');
$ado = GetADODBConnection();
if($id && is_array($_POST["CustomData"]))
{
foreach($_POST["CustomData"] as $FieldId => $Value)
{
$sql = "SELECT count(*) as reccount FROM ".$objEditData->SourceTable." WHERE CustomFieldId=$FieldId AND ResourceId=".$_POST["ItemId"];
$rs = $ado->Execute($sql);
$intable = $rs->fields["reccount"];
if(!$intable)
{
$sql = "INSERT INTO ".$objEditData->SourceTable." (ResourceId,CustomFieldId,Value) VALUES ('".$id."','$FieldId','$Value')";
$ado->Execute($sql);
//echo $sql."<br>\n";
}
else
{
$sql = "UPDATE ".$objEditData->SourceTable." SET Value='".$Value."' WHERE CustomFieldId=$FieldId AND ResourceId=".$_POST["ItemId"];
$ado->Execute($sql);
//echo $sql."<br>\n";
}
}
}
$objEditData->SetTable('live');
break;
case "m_customfield_edit":
if($ro_perm) break;
$DataType = $_POST["DataType"];
$FieldId = $_POST["CustomFieldId"];
$FieldName = $_POST["fieldname"];
//$FieldLabel = $_POST["fieldlabel"];
if(strlen($FieldName))
{
$objCustomFields = new clsCustomFieldList($DataType);
$objCustomFields->EditField($FieldId,$DataType,$FieldName,"",(int)$_POST["generaltab"],
$_POST["heading"],$_POST["fieldprompt"],$_POST["input_type"],
$_POST["valuelist"]);
}
unset($objCustomFields);
break;
case "m_customfield_add":
if($ro_perm) break;
$DataType = $_POST["DataType"];
$FieldName = $_POST["fieldname"];
//$FieldLabel = $_POST["fieldlabel"];
if(strlen($FieldName))
{
$objCustomFields = new clsCustomFieldList($DataType);
$objCustomFields->AddField($DataType,$FieldName,"",(int)$_POST["generaltab"],
$_POST["heading"],$_POST["fieldprompt"],$_POST["input_type"],
$_POST["valuelist"]);
unset($objCustomFields);
}
break;
case "m_customfield_delete":
if($ro_perm) break;
$DataType = $_POST["DataType"];
$objCustomFields = new clsCustomFieldList($DataType);
foreach($_POST["itemlist"] as $f)
{
$objCustomFields->DeleteField($f);
//$c = $objCustomFields->GetItem($f);
//$c->Delete();
}
unset($objCustomFields);
break;
case "m_SearchConfig_Edit":
if($ro_perm) break;
$SimpleValues = $_POST["simple"];
$AdvValues = $_POST["advanced"];
$module = $_POST["module"];
$priority = $_POST["pri"];
//phpinfo(INFO_VARIABLES);
$objSearchConfig = new clsSearchConfigList($module);
foreach($objSearchConfig->Items as $i)
{
$id = $i->Get("SearchConfigId");
$objSearchConfig->EditFieldSettings($id,(int)$SimpleValues[$id],(int)$AdvValues[$id],$priority[$id]);
}
$objSearchConfig->Clear();
/* save relevence settings */
$vals = $_POST["req_increase"];
foreach($vals as $var=>$value)
{
$cfg = "SearchRel_Increase_".$var;
$objConfig->Set($cfg,$value);
}
$vals = $_POST["rel_keyword"];
foreach($vals as $var=>$value)
{
$cfg = "SearchRel_Keyword_".$var;
$objConfig->Set($cfg,$value);
}
$vals = $_POST["rel_pop"];
foreach($vals as $var=>$value)
{
$cfg = "SearchRel_Pop_".$var;
$objConfig->Set($cfg,$value);
}
$vals = $_POST["rel_rating"];
foreach($vals as $var=>$value)
{
$cfg = "SearchRel_Rating_".$var;
$objConfig->Set($cfg,$value);
}
break;
case "m_keyword_reset":
if($ro_perm) break;
$objSearchList = new clsSearchLogList();
foreach($_POST["itemlist"] as $k)
{
$c = $objSearchList->GetItem($k);
$c->Delete();
}
break;
case "m_review_add":
$post_info = GetSubmitVariable($_POST, 'EditStatus');
if($post_info['variable'] > -1)
{
$objReviews = new clsItemReviewList();
$objReviews->SourceTable = $objSession->GetEditTable("ItemReview");
$Pending = (int)$_POST["review_pending"];
$Enabled = (int)$_POST["review_enabled"];
$Status = (int)$_POST["status"];
$CreatedOn = DateTimestamp($_POST["review_date"],GetDateFormat());
$CreatedOn += SecondsSinceMidnight($_POST["review_time"]);
$html = (int)$_POST["html_enable"];
$ReviewText = inp_escape($_POST["review_body"],1);
$CreatedById = 0;
if(strlen($_POST["createdby"])>0)
{
if(strtolower($_POST["createdby"])=="root")
{
$CreatedById = -1;
}
else
{
$u = $objUsers->GetItemByField("Login",$_POST["createdby"]);
if(is_object($u))
{
$CreatedById = $u->Get("PortalUserId");
if($CreatedById<1)
{
$CreatedById = $objSession->Get("PortalUserId");
}
}
else
$CreatedById = $objSession->Get("PortalUserId");
}
}
else
$CreatedById = $objSession->Get("PortalUserId");
$r = $objReviews->AddReview($CreatedOn,$ReviewText,$Status, $IPAddress,
(int)$_POST["review_priority"], $_POST["ItemId"],$_POST["ItemType"],
$CreatedById,$html, $post_info['Module']);
$ado = GetADODBConnection();
$rs = $ado->Execute("SELECT MIN(ReviewId) as MinValue FROM ".$objReviews->SourceTable);
$NewId = $rs->fields["MinValue"]-1;
$sql = "UPDATE ".$objReviews->SourceTable." SET ReviewId=".$NewId." WHERE ReviewId=".$r->Get("ReviewId");
if($objSession->HasSystemPermission("DEBUG.LIST"))
echo $sql."<br>\n";
$ado->Execute($sql);
}
break;
case "m_review_edit":
$post_info = GetSubmitVariable($_POST, 'EditStatus');
if($post_info['variable'] > -1)
{
$objReviews = new clsItemReviewList();
$objReviews->SourceTable = $objSession->GetEditTable("ItemReview");
$Status = (int)$_POST["status"];
$CreatedOn = DateTimestamp($_POST["review_date"],GetDateFormat());
$CreatedOn += SecondsSinceMidnight($_POST["review_time"]);
$html = (int)$_POST["html_enable"];
$ReviewText = inp_escape($_POST["review_body"],1);
$ReviewId = $_POST["ReviewId"];
$CreatedById = 0;
if(strlen($_POST["createdby"])>0)
{
if(strtolower($_POST["createdby"])=="root")
{
$CreatedById = -1;
}
else
{
$u = $objUsers->GetItemByField("Login",$_POST["createdby"]);
if(is_object($u))
{
$CreatedById = $u->Get("PortalUserId");
if($CreatedById<1)
{
$CreatedById = $objSession->Get("PortalUserId");
}
}
else
$CreatedById = $objSession->Get("PortalUserId");
}
}
$r = $objReviews->EditReview($ReviewId,$CreatedOn,$ReviewText,$Status, $IPAddress,
(int)$_POST["review_priority"],$_POST["ItemId"],$_POST["ItemType"],
$CreatedById,$html, $post_info['Module']);
}
break;
case "m_review_delete":
$objReviews = new clsItemReviewList();
$objReviews->SourceTable = $objSession->GetEditTable("ItemReview");
foreach($_POST["itemlist"] as $id)
{
$objReviews->DeleteReview($id);
}
break;
case "m_review_approve":
if (isset($_POST["itemlist"]))
{
$objReviews = new clsItemReviewList();
$objReviews->SourceTable = $objSession->GetEditTable("ItemReview");
foreach($_POST["itemlist"] as $id)
{
$i = $objReviews->GetItem($id);
$i->Set("Status",1);
$i->Update();
}
}
break;
case "m_review_deny":
if (isset($_POST["itemlist"]))
{
$objReviews = new clsItemReviewList();
$objReviews->SourceTable = $objSession->GetEditTable("ItemReview");
foreach($_POST["itemlist"] as $id)
{
$i = $objReviews->GetItem($id);
$i->Set("Status",0);
$i->Update();
}
}
break;
case "m_review_move_up":
if (isset($_POST["itemlist"]))
{
$objReviews = new clsItemReviewList();
$objReviews->SourceTable = $objSession->GetEditTable("ItemReview");
foreach($_POST["itemlist"] as $id)
{
$i = $objReviews->GetItem($id);
$i->MoveUp();
}
}
break;
case "m_review_move_down":
if (isset($_POST["itemlist"]))
{
$objReviews = new clsItemReviewList();
$objReviews->SourceTable = $objSession->GetEditTable("ItemReview");
$itemlist=array_reverse($_POST["itemlist"]);
foreach($itemlist as $id)
{
$i = $objReviews->GetItem($id);
$i->MoveDown();
}
}
break;
case "m_theme_add":
$objEditItems = new clsThemeList();
$objEditItems->SourceTable = $objSession->GetEditTable("Theme");
$Primary = (int)$_POST["primary"];
if(!(int)$_POST["enabled"])
$Primary = 0;
$t = $objEditItems->AddTheme($_POST["name"],$_POST["description"],(int)$_POST["enabled"],
(int)$_POST["CacheTimeout"],$Primary);
$ado = GetADODBConnection();
$rs = $ado->Execute("SELECT MIN(ThemeId) as MinValue FROM ".$objEditItems->SourceTable);
$NewId = $rs->fields["MinValue"]-1;
$sql = "UPDATE ".$objEditItems->SourceTable." SET ThemeId=".$NewId." WHERE ThemeId=".$t->Get("ThemeId");
if($objSession->HasSystemPermission("DEBUG.LIST"))
echo $sql."<br>\n";
if ($Primary==1)
{
$objEditItems->SetPrimaryTheme($_POST["ThemeId"]);
}
$ado->Execute($sql);
break;
case "m_theme_edit":
$objEditItems = new clsThemeList();
$objEditItems->SourceTable = $objSession->GetEditTable("Theme");
$Primary = (int)$_POST["primary"];
if(!(int)$_POST["enabled"])
$Primary = 0;
$objEditItems->EditTheme($_POST["ThemeId"],$_POST["name"],$_POST["description"],
(int)$_POST["enabled"],$Primary,(int)$_POST["CacheTimeout"]);
if ($Primary==1)
{
$objEditItems->SetPrimaryTheme($_POST["ThemeId"]);
}
break;
case "m_theme_delete":
if (isset($_POST["itemlist"]))
{
$Themes = new clsThemeList();
foreach($_POST["itemlist"] as $id)
{
$Themes->DeleteTheme($id);
}
}
break;
case "m_theme_primary":
if( count($_POST['itemlist']) )
{
$ThemeId = array_shift( $_POST['itemlist'] );
$t = new clsThemeList();
$t->SetPrimaryTheme($ThemeId);
}
break;
case "m_template_edit":
$ThemeId = $_POST["ThemeId"];
$FileId = $_POST["FileId"];
$f = new clsThemeFile($FileId);
$f->Set("Description", $_POST["Description"] );
$f->Update();
$c = stripslashes($_POST["contents"]);
$f->SaveFileContents($c);
break;
case "m_template_add":
$ThemeId = $_POST["ThemeId"];
if( !is_object($f) ) $f = new clsThemeFile();
$FilePath = $_POST['name'];
if(!$FilePath)
{
$f->SetError('Template Name is required',3);
break;
}
else
{
if( substr($FilePath,1) != '/' ) $FilePath = '/'.$FilePath;
if( substr($FilePath,-3) != '.tpl' ) $FilePath .= '.tpl';
$FileName = basename($FilePath);
$FilePath = dirname($FilePath);
// test if such file not already created
$f->LoadFromDataBase( Array($FilePath,$FileName), Array('FilePath','FileName') );
if( !$f->Get('FileId') )
{
$f->Set( Array('FilePath','FileName','ThemeId', 'Description'),
Array($FilePath, $FileName,$_POST['ThemeId'], $_POST["Description"])
);
if( $f->IsWriteablePath(true) )
{
$f->Create();
$c = stripslashes($_POST["contents"]);
$f->SaveFileContents($c, true);
}
}
else
$f->SetError('Template with this name already exists',4);
}
break;
case "m_template_delete":
$dummy = new clsThemeFile();
foreach($_POST["itemlist"] as $FileId)
{
$dummy->LoadFromDatabase($FileId);
$dummy->Delete();
}
break;
case "m_lang_add":
$objEditItems = new clsLanguageList();
$objEditItems->SourceTable = $objSession->GetEditTable("Language");
$l = $objEditItems->AddLanguage($_POST["packname"],$_POST["localname"],
(int)$_POST["enabled"],(int)$_POST["primary"],
$_POST["icon"],$_POST["date_format"],$_POST["time_format"],
$_POST["decimal"],$_POST["thousand"]);
$ado = GetADODBConnection();
$rs = $ado->Execute("SELECT MIN(LanguageId) as MinValue FROM ".$objEditItems->SourceTable);
$NewId = $rs->fields["MinValue"]-1;
$sql = "UPDATE ".$objEditItems->SourceTable." SET LanguageId=".$NewId." WHERE LanguageId=".$l->Get("LanguageId");
if($objSession->HasSystemPermission("DEBUG.LIST"))
echo $sql."<br>\n";
$ado->Execute($sql);
if($_POST["importlabels"]==1 && $_POST["srcpack"]>0)
{
$sql = "SELECT * FROM ".GetTablePrefix()."Phrase WHERE LanguageId=".$_POST["srcpack"];
if($objSession->HasSystemPermission("DEBUG.LIST"))
echo $sql."<br>\n";
$rs = $ado->Execute($sql);
$plist = new clsPhraseList();
$plist->SourceTable = $objSession->GetEditTable("Phrase");
$sql = "SELECT MIN(PhraseId) as MinId FROM ".$plist->SourceTable;
$as = $ado->Execute($sql);
if($as && !$as->EOF)
{
$MinId = (int)$as->fields["MinId"];
}
else
$MinId = 0;
$MinId--;
while($rs && !$rs->EOF)
{
$data = $rs->fields;
$plist->AddPhrase($data["Phrase"],$NewId,$data["Translation"],$data["PhraseType"]);
$sql = "UPDATE ".$plist->SourceTable." SET PhraseId=$MinId WHERE PhraseId=0 LIMIT 1";
$ado->Execute($sql);
$MinId--;
$rs->MoveNext();
}
}
break;
case "m_lang_export":
include_once($pathtoroot."kernel/include/xml.php");
$Ids = $_POST["LangList"]; // language ids list to export phrases from
$phrase_types = GetVar('langtypes');
$phrase_types = ($phrase_types !== false) ? implode(',',$phrase_types) : null;
$filename=$_POST["filename"];
if(strlen($filename)>0)
{
$ExportFilename = $pathtoroot.$admin."/export/".$filename;
$ExportResult = $objLanguages->ExportPhrases($ExportFilename,$Ids, $phrase_types);
}
break;
case "m_lang_edit":
$objEditItems = new clsLanguageList();
$objEditItems->SourceTable = $objSession->GetEditTable("Language");
$objEditItems->EditLanguage($_POST["LanguageId"],$_POST["packname"],
$_POST["localname"],(int)$_POST["enabled"],
(int)$_POST["primary"], $_POST["icon"],$_POST["date_format"],
$_POST["time_format"], $_POST["decimal"],$_POST["thousand"]);
if($_POST["importlabels"]==1 && $_POST["srcpack"]>0)
{
$ado = GetADODBConnection();
$rs = $ado->Execute("SELECT * FROM ".GetTablePrefix()."Phrase WHERE LanguageId=".$_POST["srcpack"]);
$plist = new clsPhraseList();
$plist->SourceTable = $objSession->GetEditTable("Phrase");
$sql = "SELECT MIN(PhraseId) as MinId FROM ".$plist->SourceTable;
$as = $ado->Execute($sql);
if($as && !$as->EOF)
{
$MinId = (int)$as->fields["MinId"];
}
else
$MinId = 0;
$MinId--;
while($rs && !$rs->EOF)
{
$data = $rs->fields;
$plist->AddPhrase($data["Phrase"],$_POST["LanguageId"],$data["Translation"],$data["PhraseType"]);
$sql = "UPDATE ".$plist->SourceTable." SET PhraseId=$MinId WHERE PhraseId=0 LIMIT 1";
$ado->Execute($sql);
$MinId--;
$rs->MoveNext();
}
unset($plist);
}
break;
case "m_lang_delete":
if($ro_perm) break;
if (isset($_POST["itemlist"]))
{
$Phrases = new clsPhraseList();
foreach($_POST["itemlist"] as $id)
{
$objLanguages->DeleteLanguage($id);
$Phrases->DeleteLanguage($id);
}
unset($Phrases);
}
break;
case "m_lang_select":
$LangId = (int)$_POST["langselect"];
if($LangId)
{
if($objSession->Get("PortalUserId")>0)
{
//echo "$LangId";
$objSession->SetPersistantVariable("Language",$LangId);
}
$objSession->Set("Language",$LangId);
$objSession->Update();
$m_var_list_update["lang"] = $LangId;
$m_var_list["lang"] = $LangId;
}
break;
case "m_phrase_edit":
$objPhraseList = new clsPhraseList();
if((int)$_POST["direct"] != 1)
$objPhraseList->SourceTable = $objSession->GetEditTable("Phrase");
$Phrases = $_POST["name"];
foreach($Phrases as $PhraseId =>$name)
{
if($PhraseId>0)
{
$objPhraseList->EditPhrase($PhraseId,$_POST["name"][$PhraseId],$_POST["LanguageId"],$_POST["translation"][$PhraseId],$_POST["phrasetype"][$PhraseId]);
}
}
if(strlen($_POST["name"][0]) && strlen($_POST["translation"][0]) && $_POST['Action1'] == "new")
{
$r = $objPhraseList->AddPhrase($_POST["name"][0],$_POST["LanguageId"],$_POST["translation"][0],$_POST["phrasetype"][0]);
if ($r != "Error") {
$ado = GetADODBConnection();
$rs = $ado->Execute("SELECT MIN(PhraseId) as MinValue FROM ".$objPhraseList->SourceTable);
$NewId = $rs->fields["MinValue"]-1;
$sql = "UPDATE ".$objPhraseList->SourceTable." SET PhraseId=".$NewId." WHERE PhraseId=$PhraseId";
if($objSession->HasSystemPermission("DEBUG.LIST"))
echo $sql."<br>\n";
$ado->Execute($sql);
}
else {
$add_error = "Language tag with the same name already exists!";
}
}
else if ($_POST['Action1'] == "new") {
$add_error = "Fields name and translation are required!";
}
unset($objPhraseList);
break;
case "m_config_missing_phrase":
//phpinfo(INFO_VARIABLES);
$LangId = $_POST["LangId"];
$ThemeId = $_POST["ThemeId"];
if(is_array($_POST["Phrase"]))
{
$objPhraseList = new clsPhraseList();
$objPhraseList->SourceTable = $objSession->GetSessionKey()."_".$ThemeId."_labels";
foreach($_POST["Phrase"] as $p => $value)
{
if(strlen($value))
{
$obj = $objPhraseList->GetItemByField("Phrase",$p,TRUE);
if(is_object($obj))
{
if($obj->Get("Phrase")==$p)
{
$obj->Set("Translation",$value);
$obj->Update();
}
else
$objPhraseList->AddPhrase($p,$LangId,$value,1);
}
else
$objPhraseList->AddPhrase($p,$LangId,$value,1);
}
}
}
break;
case "m_phrase_delete":
if (isset($_POST["itemlist"]))
{
foreach($_POST["itemlist"] as $id)
{
$sql = "UPDATE ".$objSession->GetEditTable("Phrase")." SET LanguageId = 0 WHERE PhraseId = ".$id;
$ado = GetADODBConnection();
$ado->Execute($sql);
}
}
unset($objPhraseList);
break;
case "m_emailevent_disable":
if($ro_perm) break;
$objEvents = new clsEventList();
if (isset($_POST["itemlist"]))
{
foreach($_POST["itemlist"] as $id)
{
$m =& $objEvents->GetItem($id);
$m->Set("Enabled",0);
$m->Update();
}
}
unset($objEvents);
break;
case "m_emailevent_enable":
if($ro_perm) break;
$objEvents = new clsEventList();
if (isset($_POST["itemlist"]))
{
foreach($_POST["itemlist"] as $id)
{
$m =& $objEvents->GetItem($id);
$m->Set("Enabled",1);
$m->Update();
}
}
unset($objEvents);
break;
case "m_emailevent_frontonly":
if($ro_perm) break;
$objEvents = new clsEventList();
if (isset($_POST["itemlist"]))
{
foreach($_POST["itemlist"] as $id)
{
$m =& $objEvents->GetItem($id);
$m->Set("Enabled",2);
$m->Update();
}
}
unset($objEvents);
break;
case "m_dlid":
echo $Action.":".$DownloadId;
die();
break;
case "m_emailevent_user":
if($ro_perm) break;
$objEvents = new clsEventList();
//phpinfo(INFO_VARIABLES);
//$objEvents->SourceTable = $objSession->GetEditTable("Events");
$ids = $_POST["EventId"];
$ids = str_replace("[","",$ids);
$ids = str_replace("]","",$ids);
$ids = str_replace("\"","",$ids);
$ids = str_replace("\\","",$ids);
$idlist = explode(",",$ids);
foreach($idlist as $EventId)
{
$id = (int)stripslashes($EventId);
$e =& $objEvents->GetItem((int)$EventId);
$e->Set("FromUserId", $_POST["FromUserId"]);
$e->Update();
}
$objEvents->Clear();
unset($objEvents);
break;
case "m_emailevent_edit":
$Template = $_POST["headers"];
if(strlen($Template))
{
$Template .= "\n";
}
$Template = str_replace("\n\n","",$Template);
$Template .= "Subject: ".$_POST["subject"]."\n\n";
$Template .= $_POST["messageBody"];
$objMessages = new clsEmailMessageList();
$objMessages->SourceTable = $objSession->GetEditTable("EmailMessage");
$m =& $objMessages->GetItem($_POST["MessageId"]);
if(is_object($m))
{
if($_POST["sendhtml"]==1)
{
$m->Set("MessageType","html");
}
else
$m->Set("MessageType","text");
$m->Set("Template",$Template);
$m->Update();
}
break;
case "m_config_edit":
//phpinfo(INFO_VARIABLES);
if($ro_perm) break;
$objAdmin = new clsConfigAdmin();
$objAdmin->module = $_POST["module"];
$objAdmin->section = $_POST["section"];
if($objAdmin->section=="in-portal:configure_users")
{
if(strlen($_POST["RootPass"]) && strlen($_POST["RootPassVerify"]))
{
if($_POST["RootPass"]==$_POST["RootPassVerify"])
{
$_POST["RootPass"] = md5($_POST["RootPass"]);
}
}
else
{
$_POST["RootPass"] = $objConfig->Get("RootPass");
$_POST["RootPassVerify"] = $objConfig->Get("RootPassVerify");
}
}
$objAdmin->LoadItems(FALSE);
$objAdmin->SaveItems($_POST);
break;
case "m_mod_enable":
if($ro_perm) break;
if (isset($_POST["itemlist"]))
{
foreach($_POST["itemlist"] as $id)
{
$m =& $objModules->GetItemByField("Name",$id);
if(is_object($m))
{
$m->Set("Loaded",1);
$m->Update();
}
}
$_GET["Refresh"] = 1;
}
break;
case "m_mod_disable":
if($ro_perm) break;
if (isset($_POST["itemlist"]))
{
foreach($_POST["itemlist"] as $id)
{
if($id != "In-Portal")
{
$m =& $objModules->GetItemByField("Name",$id);
if(is_object($m))
{
$m->Set("Loaded",0);
$m->Update();
}
}
}
$_GET["Refresh"] = 1;
}
break;
case "m_img_add":
$objImageList = new clsImageList();
$objImageList->SourceTable = $objSession->GetEditTable("Images");
$LocalImage=0;
$LocalThumb=0;
$DestDir = "kernel/images/";
$UserThumbSource = (int)$_POST["imgLocalThumb"];
$LocalThumb = $UserThumbSource;
$thumb_url = !$LocalThumb? $_POST["imgThumbUrl"] : "";
if($_POST["imgSameImages"])
{
$LocalImage = $LocalThumb;
$full_url = $thumb_url;
}
else
{
$LocalImage = (int)$_POST["imgLocalFull"];
$file = $_FILES["imgFullFile"];
$full_url = $LocalImage? "" : $_POST["imgFullUrl"];
}
if((!strlen($thumb_url) && !$LocalThumb) || (!strlen($full_url) && !$LocalImage))
{
break;
}
$ado = GetADODBConnection();
$sql = "SELECT MIN(ImageId) as MinValue FROM ".$objImageList->SourceTable;
$rs = $ado->Execute($sql);
$NewId = ($rs->fields["MinValue"]<0)? $rs->fields["MinValue"]-1 : -1;
$img = $objImageList->Add($_POST["imgName"], $_POST["imgAlt"], $_POST["ResourceId"], $LocalImage, $LocalThumb, $full_url, $thumb_url, (int)$_POST["imgEnabled"], 0, (int)$_POST["imgDefault"], 0,(int)$_POST["imgSameImages"], $NewId);
$img->Set("ImageId", $NewId);
// $img->debuglevel=1;
/*
$sql = "UPDATE ".$objImageList->SourceTable." SET ImageId=".$NewId." WHERE ImageId=0";
$ado->Execute($sql);
// $img->Update();
*/
// echo "SL: $sql $NewId<BR>";
// $img->debuglevel=1;
$img->Pending=TRUE;
if($LocalImage)
{
$file = $_FILES["imgFullFile"];
if(is_array($file))
{
if($file["size"]>0)
{
$img->Set("LocalPath",$img->StoreUploadedImage($file,1, $DestDir,0));
$uploaded=1;
}
}
}
if($LocalThumb)
{
$thumb = $_FILES["imgThumbFile"];
if(is_array($thumb))
{
if($thumb["size"]>0)
{
$img->Set("ThumbPath",$img->StoreUploadedImage($thumb,1, $DestDir,1));
$uploaded=1;
}
}
}
if($uploaded==1)
$img->Update();
break;
case "m_img_edit":
$objImageList = new clsImageList();
$objImageList->SourceTable = $objSession->GetEditTable("Images");
// $img->debuglevel=1;
$img = $objImageList->GetItem($_POST["ImageId"]);
## Get original values
$LocalImage = $img->Get("LocalImage");
$LocalThumb = $img->Get("LocalThumb");
$SameImages = $img->Get("SameImages");
$ThumbPath = $img->Get("ThumbPath");
## New values
$LocalThumbN = (int)$_POST["imgLocalThumb"];
$LocalImageN = (int)$_POST["imgLocalFull"];
$FULLFile = $_FILES["imgFullFile"];
$THFile = $_FILES["imgThumbFile"];
$DestDir = "kernel/images/";
$img->Pending = FALSE;
$SameImagesN = 0;
$uploaded = 0;
## Images were the same, but not any more
if ($SameImages && !$_POST["imgSameImages"])
{
## TH was a local file
if ($LocalThumb)
{
## TH image
{
## Try to Delete OLD FULL
$img->DeleteLocalImage(FALSE, TRUE);
## FULL image select, but field EMPTY - make a copy of old TH as FULL
if ($LocalImageN && !(int)$FULLFile["size"])
{
// echo $pathToPending = $img->GetImageDir();
if (!eregi("pending/$", $pathToPending))
$pathToPending.= "pending/";
$LocalThumb_File = $img->GetFileName(1);
// echo "<b>CAN'T FIND FILE:</b> ".$pathToPending.$LocalThumb_File."<BR>";
if (file_exists($pathToPending.$LocalThumb_File))
{
$LocalThumb_FileN = eregi_replace("^th_", "", $LocalThumb_File);
$LocalThumb_FullFileN = $pathToPending.$LocalThumb_FileN;
@unlink($LocalThumb_FullFileN);
@copy($pathToPending.$LocalThumb_File, $LocalThumb_FullFileN);
$uploaded = 1;
$copied = 1;
// echo "COPING: ".$DestDir."pending/".$LocalThumb_FileN." <BR>";
}
else
{
// echo "CAN'T FIND FILE: ".$pathToPending.$LocalThumb_File."<BR>";
}
}
## Upload new FULL image
elseif ($LocalImageN && (int)$FULLFile['size'])
{
$FULL_FileToUpload = $FULLFile;
$FULL_URL = "";
// echo " Upload new FULL image";
}
## Full is URL
elseif (!$LocalImageN)
{
$img->DeleteLocalImage(FALSE, TRUE);
$FULL_URL = $_POST['imgFullUrl'];
$FULL_FileToUpload = "";
}
else
{
// echo " ## Unknow condition";
}
## Take care of Thumbnail here
if ($LocalThumbN)
{
## Delete old if NEW TH image selected
if ((int)$THFile['size'])
{
$img->DeleteLocalImage(TRUE, FALSE);
$TH_FileToUpload = $THFile;
}
else
$TH_FileToUpload = "";
}
else
{
$img->DeleteLocalImage(TRUE, FALSE);
$TH_FileToUpload = "";
$TH_URL = $_POST['imgThumbUrl'];
}
}
}
## TH was URL
else
{
## Take care of FULL image here
if ($LocalImageN && (int)$FULLFile["size"])
{
$FULL_FileToUpload = $FULLFile;
$FULL_URL = "";
}
## Full is URL (or image size 0)
else
{
$FULL_FileToUpload = "";
$FULL_URL = $_POST['imgFullUrl'];
}
## Take care of Thumbnail here
if ($LocalThumbN)
{
$TH_FileToUpload = (int)$THFile['size']? $THFile : "";
$TH_URL = "";
}
else
{
$TH_FileToUpload = "";
$TH_URL = $_POST['imgThumbUrl'];
}
}
}
## Images were the same, and still the same
elseif ($SameImages && $_POST['imgSameImages'])
{
## Take care of Thumbnail & FULL here
if ($LocalThumbN)
{
if ((int)$THFile['size'])
{
$img->DeleteLocalImage(TRUE, FALSE);
$TH_FileToUpload = $THFile;
}
else
$TH_FileToUpload = "";
$FULL_URL = $TH_URL = "";
}
else
{
$TH_FileToUpload = $FULL_FileToUpload = "";
$FULL_URL = $TH_URL = $_POST['imgThumbUrl'];
}
## Delete old FULL image
$img->DeleteLocalImage(FALSE,TRUE);
$SameImagesN = 1;
}
## Images were NOT the same, and selected as the same now
elseif (!$SameImages && $_POST["imgSameImages"])
{
## Take care of Thumbnail & FULL here
if ($LocalThumbN)
{
if ((int)$THFile['size'])
{
$img->DeleteLocalImage(TRUE, FALSE);
$TH_FileToUpload = $THFile;
}
else
$TH_FileToUpload = "";
$FULL_URL = $TH_URL = "";
}
else
{
$img->DeleteLocalImage(TRUE, FALSE);
$TH_FileToUpload = $FULL_FileToUpload = "";
$FULL_URL = $TH_URL = $_POST['imgThumbUrl'];
}
## Clean up FULL image
$img->DeleteLocalImage(FALSE, TRUE);
$SameImagesN = 1;
}
## Images were NOT the same, and selected as NOT the same
elseif (!$SameImages && !$_POST["imgSameImages"])
{
## Take care of Thumbnail
if ($LocalThumbN)
{
if ((int)$THFile['size'])
{
$img->DeleteLocalImage(TRUE, FALSE);
$TH_FileToUpload = $THFile;
}
else
$TH_FileToUpload = "";
$TH_URL = "";
}
else
{
$img->DeleteLocalImage(TRUE, FALSE);
$TH_FileToUpload = "";
$TH_URL = $_POST['imgThumbUrl'];
}
## Take care of FULL here
if ($LocalImageN)
{
if ((int)$FULLFile['size'])
{
$img->DeleteLocalImage(FALSE, TRUE);
$FULL_FileToUpload = $FULLFile;
}
else
$FULL_FileToUpload = "";
$FULL_URL = "";
}
else
{
$img->DeleteLocalImage(FALSE, TRUE);
$FULL_FileToUpload = "";
$FULL_URL = $_POST['imgFullUrl'];
}
}
## Unknow condition
else
{
;
}
$img = $objImageList->Edit($_POST["ImageId"],$_POST["imgName"], $_POST["imgAlt"], $_POST["ResourceId"], $LocalImageN, $LocalThumbN, $FULL_URL, $TH_URL, (int)$_POST["imgEnabled"], (int)$_POST["imgPriority"], (int)$_POST["imgDefault"], 0, $SameImagesN);
// echo "<B>DATA:</B> <BR> LocalImageN: $LocalImageN, LocalThumbN: $LocalThumbN, FULL_URL: $FULL_URL, TH_URL: $TH_URL, SameImagesN: $SameImagesN <BR>";
$img->Pending = TRUE;
if (!empty($FULL_FileToUpload))
{
$img->Set("LocalPath",$img->StoreUploadedImage($FULL_FileToUpload, 1, $DestDir, 0));
$uploaded = 1;
}
/*
elseif (!$LocalImageN)
{
$img->Set("LocalPath", "");
$uploaded = 1;
}
*/
if (!empty($TH_FileToUpload))
{
$img->Set("ThumbPath", $img->StoreUploadedImage($TH_FileToUpload, 1, $DestDir, 1));
$uploaded = 1;
}
if ($copied)
{
$img->Set("LocalPath", $DestDir."pending/".$LocalThumb_FileN);
$uploaded = 1;
}
if($uploaded==1)
$img->Update();
break;
case "m_img_move_up":
if (isset($_POST["itemlist"]))
{
$objImageList = new clsImageList();
$objImageList->SourceTable = $objSession->GetEditTable("Images");
foreach($_POST["itemlist"] as $id)
{
$img = $objImageList->GetItem($id);
$img->MoveUp();
}
}
break;
case "m_img_move_down":
if (isset($_POST["itemlist"]))
{
$objImageList = new clsImageList();
$objImageList->SourceTable = $objSession->GetEditTable("Images");
$itemlist=array_reverse($_POST["itemlist"]);
foreach($itemlist as $id)
{
$img = $objImageList->GetItem($id);
$img->MoveDown();
}
}
break;
case "m_img_delete":
if(isset($_POST["itemlist"]))
{
$objImageList = new clsImageList();
$objImageList->SourceTable = $objSession->GetEditTable("Images");
foreach($_POST["itemlist"] as $id)
{
$img = $objImageList->GetItem($id);
$img->Set("ResourceId", 0);
$img->Update();
//$img->Delete();
}
}
break;
case "m_restore_delete":
$bdate = $_POST["backupdate"];
if($bdate>0)
{
$BackupFile = $objConfig->Get("Backup_Path")."/dump".$bdate.".txt";
if(file_exists($BackupFile))
unlink($BackupFile);
}
break;
case "m_taglib":
include($pathtoroot."kernel/include/tag-class.php");
ParseTagLibrary();
break;
case "m_sql_query":
$SqlQuery = $_POST["sql"];
$ado = GetADODBConnection();
if(strlen($sql))
{
$SqlResult = $ado->Execute(stripslashes($SqlQuery));
$SqlError = $ado->ErrorMsg();
$SqlErrorNum = $ado->ErrorNo();
}
break;
case "m_session_delete":
if($ro_perm) break;
$ado = GetADODBConnection();
if (count($_POST['itemlist']) > 0) {
foreach($_POST["itemlist"] as $id)
{
$sql = "DELETE FROM ".GetTablePrefix()."UserSession WHERE SessionKey='$id'";
$ado->Execute($sql);
}
}
else {
$sql = "DELETE FROM ".GetTablePrefix()."UserSession WHERE Status='0'";
$ado->Execute($sql);
}
break;
case "m_add_rule":
$objEditItems = new clsBanRuleList();
$objEditItems->SourceTable = $objSession->GetEditTable("BanRules");
//$ItemType,$RuleType,$ItemField,$ItemVerb,$ItemValue,$Priority,$Status;
$objEditItems->AddRule($_POST["rule_itemtype"],$_POST["rule_type"],$_POST["rule_field"],
$_POST["rule_verb"],$_POST["rule_value"],(int)$_POST["rule_priority"],
(int)$_POST["rule_status"], $_POST['rule_error']);
break;
case "m_edit_rule":
$objEditItems = new clsBanRuleList();
$objEditItems->SourceTable = $objSession->GetEditTable("BanRules");
//$ItemType,$RuleType,$ItemField,$ItemVerb,$ItemValue,$Priority,$Status;
$objEditItems->EditRule($_POST["rule_id"],$_POST["rule_itemtype"],$_POST["rule_type"],$_POST["rule_field"],
$_POST["rule_verb"],$_POST["rule_value"],(int)$_POST["rule_priority"],
(int)$_POST["rule_status"], $_POST['rule_error']);
break;
case "m_rule_move_up":
if($ro_perm) break;
if(isset($_POST["itemlist"]))
{
foreach($_POST["itemlist"] as $id)
{
$i = $objBanList->GetItem($id);
$i->Increment("Priority");
}
}
break;
case "m_rule_move_down":
if($ro_perm) break;
if(isset($_POST["itemlist"]))
{
foreach($_POST["itemlist"] as $id)
{
$i = $objBanList->GetItem($id);
$i->Decrement("Priority");
}
}
break;
case "m_rule_delete":
if($ro_perm) break;
if(isset($_POST["itemlist"]))
{
foreach($_POST["itemlist"] as $id)
{
$i = $objBanList->GetItem($id);
$i->Delete();
}
}
break;
case "m_ban_user":
if($ro_perm) break;
if($_POST["UserEditStatus"]==1)
{
$UserId = $_POST["user_id"];
$u = $objUsers->GetItem($UserId);
if(is_object($u))
{
if((int)$_POST["ban_login"])
{
if(strlen($_POST["user_login"]))
$objBanList->AddRule(6,0,"Login",3,$_POST["user_login"],0,1);
}
if((int)$_POST["ban_email"])
{
if(strlen($_POST["user_email"]))
$objBanList->AddRule(6,0,"Email",3,$_POST["user_email"],0,1);
}
if((int)$_POST["ban_ip"])
{
if(strlen($_POST["user_ip"]))
$objBanList->AddRule(6,0,"ip",3,$_POST["user_ip"],0,1);
}
$u->Deny();
}
}
- break;
+ break;
+
}
/* image upload management */
if( isset($_POST['img']) && $_POST['img'] == 1 )
{
foreach($_FILES as $img => $FILE)
{
$name = $_POST["img_Name_$img"];
$alt = $_POST["img_Alt_$img"];
$url = $_POST["img_Url_$img"];
$res_id = $_POST["img_Res_$img"];
$relvalue = $_POST["img_Rel_$img"];
$thumb = (int)$_POST["img_Thumb_$img"];
$dest = AddSlash($_POST["img_DestDir_$img"]);
if($_POST["img_Del_$img"]=="Delete")
{
$img = $objImageList->GetImageByResource($res_id,$relvalue);
$img->Delete();
unset($img);
$objImageList->Clear();
}
else
{
if($FILE["size"]>0)
{
/* an image was uploaded */
$objImageList->HandleImageUpload($FILE,$res_id,$relvalue,$dest, $name,$alt,$thumb);
}
else
{ /* remote images handled here */
if(strlen($url)>0)
{
if($relvalue>0)
{
$img = $objImageList->GetImageByResource($res_id,$relvalue);
$img->Set("Name",$name);
$img->Set("AltName", $alt);
$img->Set("IsThumbnail",$thumb);
$img->Set("Url",$url);
$img->Update();
}
else
{
$relvalue = $objImageList->GetNextRelateValue($res_id);
$objImageList->NewRemoteImage($url,$res_id,$relvalue, $name, $alt, $thumb);
}
}
}
}
}
}
// ALL Saving Stuff From Temp Tables Heppens Here
//echo "==== BEGIN ==== <br>";
$has_perm = $objSession->HasSystemPermission("SYSTEM_ACCESS.READONLY");
//echo "PortalUserID: [".$objSession->Get("PortalUserId")."]<br>";
//echo "PermSet: [".$has_perm."]<br>";
if( !$has_perm )
{
/* category Edit */
if( GetVar('CatEditStatus') == 1 )
{
$adodbConnection = GetADODBConnection();
// $sql = "SELECT * FROM ".$objSession->GetEditTable("Category")." WHERE CategoryId=0";
$sql = "SELECT * FROM ".$objSession->GetEditTable("Category")." WHERE CategoryId=-1";
$rs = $adodbConnection->Execute($sql);
while ($rs && !$rs->EOF)
{
if($rs->fields["ParentId"]>0)
RunUp($rs->fields["ParentId"],"Increment_Count");
$rs->MoveNext();
}
$objCatList->CopyFromEditTable("CategoryId");
$objCustomDataList->CopyFromEditTable("CustomDataId");
$objCatList->Clear();
if($_REQUEST['CategoryId'] > 0) // not root category is updated
{
$objImages = new clsImageList();
$objImages->CopyFromEditTable("ImageId");
}
}
if( GetVar('CatEditStatus') == 2 )
{
$objCatList->PurgeEditTable("CategoryId");
$objCustomDataList->PurgeEditTable("CustomDataId");
if($_REQUEST['CategoryId'] > 0) // not root category is updated
{
$objImages = new clsImageList();
$objImages->PurgeEditTable("ImageId");
}
$objCatList->Clear();
}
/* User Edit */
if( GetVar('UserEditStatus') == 1 )
{
$objUsers->CopyFromEditTable("PortalUserId");
$objCustomDataList->CopyFromEditTable("CustomDataId");
$objGroups->Clear();
$objImages = new clsImageList();
$objImages->CopyFromEditTable("ImageId");
}
if( GetVar('UserEditStatus') == 2 )
{
$objGroups->PurgeEditTable("PortalUserId");
$objCustomDataList->PurgeEditTable("CustomDataId");
$objGroups->Clear();
}
/* Group Edit */
if( GetVar('GroupEditStatus') == 1 )
{
$objGroups->CopyFromEditTable("GroupId");
$objCustomDataList->CopyFromEditTable("CustomDataId");
$objGroups->Clear();
}
if( GetVar('GroupEditStatus') == 2 )
{
$objGroups->PurgeEditTable("GroupId");
$objCustomDataList->PurgeEditTable("CustomDataId");
$objGroups->Clear();
}
/* Theme Edit */
if( GetVar('ThemeEditStatus') == 1 )
{
$objThemes->CopyFromEditTable();
$objThemes->Clear();
}
if( GetVar('ThemeEditStatus') == 2 )
{
$objThemes->PurgeEditTable();
$objThemes->Clear();
}
/* Language Edit */
if( GetVar('LangEditStatus') == 1 )
{
$Messages = new clsEmailMessageList();
$Messages->CopyFromEditTable();
$Messages->Clear();
$objLanguages->CopyFromEditTable();
$objLanguages->Clear();
$Phrases = new clsPhraseList();
$Phrases->CopyFromEditTable();
$Phrases->Clear();
$Phrases->PurgeEditTable();
}
if( GetVar('LangEditStatus') == 2 )
{
$objLanguages->PurgeEditTable();
$objLanguages->Clear();
$Phrases = new clsPhraseList();
$Phrases->PurgeEditTable();
$Messages = new clsEmailMessageList();
$Messages->PurgeEditTable();
}
if( GetVar('MissingLangEditStatus') == 1 )
{
$objPhraseList = new clsPhraseList();
$objPhraseList->SourceTable = $objSession->GetSessionKey()."_".$ThemeId."_labels";
$objEditList = new clsPhraseList();
$objEditList->SourceTable = $objSession->GetEditTable("Phrase");
$ado = GetADODBConnection();
$rs = $ado->Execute("SELECT MIN(PhraseId) as MinValue FROM ".$objEditList->SourceTable);
$NewId = $rs->fields["MinValue"]-1;
$objPhraseList->Query_Item("SELECT * FROM ".$objPhraseList->SourceTable);
foreach($objPhraseList->Items as $p)
{
if(strlen($p->Get("Translation"))>0)
{
$p->tablename = $objEditList->SourceTable;
$p->Dirty();
$p->UnsetIDField();
$p->Set("PhraseId",$NewId);
$NewId--;
$p->Create();
}
}
$ado->Execute("DROP TABLE IF EXISTS ".$objPhraseList->SourceTable);
}
if( GetVar('MissingLangEditStatus') == 2 )
{
$table = $objSession->GetSessionKey()."_".$ThemeId."_labels";
$ado = GetADODBConnection();
$ado->Execute("DROP TABLE IF EXISTS ".$table);
}
/* Ban Rule Edit */
if( GetVar('RuleEditStatus') == 1 )
{
$objBanList->CopyFromEditTable("RuleId");
$objBanList->Clear();
}
if( GetVar('RuleEditStatus') == 2 )
{
$objBanList->PurgeEditTable("RuleId");
$objBanList->Clear();
}
}
elseif( defined('DEBUG_ACTIONS') )
{
if( isset($_REQUEST['Action']) && $_REQUEST['Action'] )
echo "<b>USER HAS RO-ACCESS</b> on action [<b>".$_REQUEST['Action']."</b>]<br>";
}
//echo "==== END ==== <br>";
?>
Property changes on: trunk/kernel/action.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.27
\ No newline at end of property
+1.28
\ No newline at end of property
Index: trunk/kernel/include/item.php
===================================================================
--- trunk/kernel/include/item.php (revision 287)
+++ trunk/kernel/include/item.php (revision 288)
@@ -1,975 +1,975 @@
<?php
require_once($pathtoroot."kernel/include/itemreview.php");
require_once($pathtoroot."kernel/include/itemrating.php");
class clsItem extends clsParsedItem
{
var $type;
var $Reviews;
var $Related;
var $Images;
var $PrimaryCat;
var $IsNew = FALSE;
var $IsHot = FALSE;
var $IsPop = FALSE;
var $Keywords;
var $OpenTagVar;
var $CloseTagVar;
var $AdminParser;
var $CustomFields;
var $FieldClass;
var $CustomLoaded=0;
var $ReviewSortOrder;
var $ReviewPerPageVar;
function clsItem($FullItem=FALSE)
{
$this->clsParsedItem();
if($FullItem==TRUE)
{
$this->Reviews = new clsItemReviewList();
$this->Related = new clsRelationshipList();
}
$this->Images = new clsImageList();
$this->CustomFields = array();
$this->FieldClass = new clsCustomFieldList();
}
function ClearCacheData()
{
}
/* item reviews */
function &GetItemReviews($Page=1)
{
$res_id = $this->Get("ResourceId");
$this->Reviews->itemID=$res_id;
$this->Reviews->PerPageVar = $this->ReviewPerPageVar;
$this->Reviews->Page = $Page;
$this->Reviews->GetReviewList("Status=1",$this->ReviewSortOrder);
return $this->Reviews;
}
function ReviewCount($TodayOnly=FALSE)
{
if(is_numeric($this->Get("CachedReviewsQty")) && !$TodayOnly)
return (int)$this->Get("CachedReviewsQty");
$this->Reviews->itemID=$this->Get("ResourceId");
return (int)$this->Reviews->GetItemReviewCount($TodayOnly);
}
function ReviewsLoaded()
{
if($this->Reviews->itemID==$this->Get("ResourceId"))
{
return $this->Reviews->ItemCount();
}
else
return 0;
}
function &AddReview($createdBy,$reviewText,$isPending,$ip=NULL,$ForceIP=0, $Module="")
{
$this->Reviews->itemID=$this->Get("ResourceId");
if($ip == NULL)
$ip = $_SERVER["REMOTE_ADDR"];
$CreatedOn = mktime(0,0,0,adodb_date("m"),adodb_date("d"),adodb_date("Y"));
$Status=1;
if($isPending)
$Status=2;
$AutoModule = GetModuleByAction(); // determine module name by action
//echo "Auto Module: $AutoModule<br>";
$r = $this->Reviews->AddReview($CreatedOn,$reviewText,$Status,$ip,0,$this->Get("ResourceId"),$this->type,$createdBy,0,$AutoModule);
$this->Increment("CachedReviewsQty");
return $r;
}
function ReviewIPExists($ip)
{
return ip_exists($ip,$this->Get("ResourceId"),$this->Reviews->SourceTable);
}
function DeleteReview($reviewID)
{
$r = $this->Reviews->GetReview($reviewID);
if(is_object($r))
{
$r->Delete();
$this->Decrement("CachedReviewsQty");
}
}
function DeleteReviews()
{
$res_id = $this->Get("ResourceId");
if($res_id)
{
$sql = "DELETE FROM ".GetTablePrefix()."ItemReview WHERE ResourceId=$res_id";
$this->adodbConnection->Execute($sql);
unset($this->Reviews);
$this->Reviews = new clsItemReviewList($res_id);
}
}
/* item custom fields */
function LoadCustomFields()
{
if(!$this->CustomLoaded && $this->Get("ResourceId")>0)
{
$this->FieldClass = new clsCustomFieldList();
$this->FieldClass->Type = $this->type;
$this->FieldClass->LoadFieldsAndValues($this->Get("ResourceId"));
foreach($this->FieldClass->Items as $f)
{
$this->CustomFields[$f->Get("FieldName")] = $f->HasField('Value') ? $f->Get('Value') : '';
}
$this->CustomLoaded = 1;
}
}
function SetCustomField($fieldname,$value)
{
// echo "Setting CF [<b>$fieldname</b>] = [$value]<br>";
if(!$this->CustomLoaded)
$this->LoadCustomFields();
$this->CustomFields[$fieldname] = $value;
}
function SaveCustomFields()
{
//echo "Saving CFs<br>";
if(!(int)$this->Get("ResourceId"))
return TRUE;
if(!$this->CustomLoaded)
return TRUE;
$data = new clsCustomDataList();
$data->LoadResource($this->Get("ResourceId"));
foreach($this->FieldClass->Items as $f)
{
$value = $this->CustomFields[$f->Get("FieldName")];
$data->SetFieldValue($f->Get("CustomFieldId"),$this->Get("ResourceId"),$value);
}
$data->SaveData();
unset($data);
}
function GetCustomFieldValue($fieldname,$default="")
{
if(!$this->CustomLoaded)
$this->LoadCustomFields();
if(isset($this->CustomFields[$fieldname]))
{
$ret = $this->CustomFields[$fieldname];
}
else
$ret = $default;
return $ret;
}
function DeleteCustomData()
{
$cdata = new clsCustomDataList();
$cdata->DeleteResource($this->Get("ResourceId"));
}
function Delete($RecordOnly=FALSE)
{
global $objFavorites;
if($RecordOnly==FALSE)
{
$this->DeleteReviews();
$this->DeleteRelations();
$this->DeleteCustomData();
if($this->NoResourceId==0)
{
if($this->UsingTempTable()==FALSE)
{
if(is_object($this->Images))
$this->Images->DeleteResource($this->Get("ResourceId"));
$objFavorites->DeleteItem($this->Get("ResourceId"));
}
}
}
parent::Delete();
}
/* item relationships */
function GetRelatedItems()
{
global $objConfig;
$where = "SourceId = ".$this->Get("ResourceId");
$where .= " OR (TargetId=".$this->Get("ResourceId")." AND Type=1)";
$orderBy = $objConfig->Get("Relation_Sortfield")." ".$objConfig->Get("Relation_Sortorder");
$orderBy = trim($orderBy);
$this->Related->Clear();
$res = $this->Related->LoadRelated($where,$orderBy);
return $res;
}
function &RelationObject()
{
return $this->Related;
}
function DeleteRelations()
{
$res_id = $this->Get("ResourceId");
if($res_id)
{
$sql = "DELETE FROM ".GetTablePrefix()."Relationship WHERE SourceId=$res_id OR TargetId=$res_id";
$this->adodbConnection->Execute($sql);
unset($this->Reviews);
$this->Related = new clsRelationshipList($res_id);
}
}
/* keyword highlighting for searches */
function HighlightField($field)
{
global $objConfig;
if(/*!strlen($OpenTag) || !strlen($CloseTag) ||*/ !is_array($this->Keywords))
{
//echo "Missing something<br>\n";
return $this->Get($field);
}
if(strlen($this->OpenTagVar))
$OpenTag = $objConfig->Get($this->OpenTagVar);
if(strlen($this->CloseTagVar))
$CloseTag = $objConfig->Get($this->CloseTagVar);
$k = array_merge($this->Keywords["required"],$this->Keywords["normal"]);
if(count($k))
{
$result = HighlightKeywords($k, $this->Get($field), $OpenTag, $CloseTag);
}
else
{
$result = $this->Get($field);
//echo "No Keywords<br>\n";
}
return $result;
}
function HighlightText($text)
{
global $objConfig;
if(strlen($this->OpenTagVar))
$OpenTag = $objConfig->Get($this->OpenTagVar);
if(strlen($this->CloseTagVar))
$CloseTag = $objConfig->Get($this->CloseTagVar);
if(!strlen($OpenTag) || !strlen($CloseTag) || !is_array($this->Keywords))
return $text;
$k = array_merge($this->Keywords["required"],$this->Keywords["normal"]);
if(count($k))
{
$result = HighlightKeywords($k,$text, $OpenTag, $CloseTag);
}
else
$result = $text;
return $result;
}
/* item status functions */
function Is($name)
{
$var = "m_" . $name;
return ( isset($this->$var) && $this->$var ) ? true : false;
}
function IsHotItem()
{
switch($this->Get("HotItem"))
{
case ALWAYS:
return TRUE;
break;
case NEVER:
return FALSE;
break;
case AUTO:
return $this->IsHot;
break;
}
}
function SetHotItem()
{
$this->IsHot = FALSE;
}
function IsNewItem()
{
switch($this->Get("NewItem"))
{
case ALWAYS:
return TRUE;
break;
case NEVER:
return FALSE;
break;
case AUTO:
return $this->IsNew;
break;
}
}
function SetNewItem()
{
$this->IsNew = FALSE;
}
function IsPopItem()
{
switch($this->Get("PopItem"))
{
case ALWAYS:
return TRUE;
break;
case NEVER:
return FALSE;
break;
case AUTO:
return $this->IsPop;
break;
}
}
function SetPopItem()
{
$this->IsPop = FALSE;
}
function SetFromArray($data, $dirty = false)
{
parent::SetFromArray($data, $dirty);
if(is_array($data))
{
if(array_key_exists("NewItem",$data))
{
$this->SetNewItem();
}
if(array_key_exists("HotItem",$data))
{
$this->SetHotItem();
}
if(array_key_exists("PopItem",$data))
{
$this->SetPopItem();
}
}
}
function Validate()
{
/* skeleton*/
return true;
}
function LoadFromDatabase($Id, $IdField = null) // custom IdField by Alex)
{
/* skeleton */
parent::LoadFromDatabase($Id, $IdField);
}
//Changes priority
function MoveDown()
{
$this->Decrement("Priority");
}
function MoveUp()
{
$this->Increment("Priority");
}
function CheckPermission($permissionName)
{
//Check permission and if needs approval set approval
global $objSession,$objCatList;
$perm = $this->BasePermission;
if(strlen($perm)>0)
$perm .= ".";
$perm .= $permissionName;
//get an instance of the forum category
$cat =& $objCatList->GetCategory($this->Get("CategoryId"));
if(!is_object($cat))
{
return FALSE;
}
else
{
return ($cat->HasPermission($perm,$objSession->Get("GroupId")));
}
}
function SubmitVote($voteRating, $voteNotes)
{
global $Errors;
global $REMOTE_ADDR;
if($this->rating_ip_exists($REMOTE_ADDR))
{
// $Errors->AddError("error.already_voted","","","",get_class($this),"SubmitVote");
return false;
}
$vote = new clsItemRating(NULL);
$vote->Set("ItemId",$this->UniqueId());
$vote->Set("RatingValue",$voteRating);
if(!$vote->Create())
return false;
$NumVotes = (int)$this->Get("CachedVotesQty");
$CurrentRating = (int)$this->Get("CachedRating");
$Rating = (($NumVotes * $CurrentRating) + $voteRating)/($NumVotes+1);
$this->Set("CachedRating",$Rating);
$this->Update();
$this->Increment("CachedVotesQty");
}
function rating_ip_exists($ip)
{
$count = 0;
$id = $this->Get("ResourceId");
$sql = "SELECT count(*) as DupCount FROM ItemRating WHERE IPAddress='$ip' and ItemId=$id";
$adodbConnection = GetADODBConnection();
$rs = $adodbConnection->Execute($sql);
if($rs)
{
$count = $rs->fields["DupCount"];
}
return ($count>0);
//return FALSE;
}
function PurgeRatings()
{
global $objConfig;
$expired=time()-86400*$objConfig->Get("Timeout_Rating");
$query="DELETE FROM ItemRating WHERE CreatedOn<$expired";
$this->adodbConnection->Execute($query);
}
function GetThumbnailImage()
{
if($this->Images->NumItems()==0)
$this->Images->GetResourceImages($this->Get("ResourceId"));
return $this->Images->GetResourceThumbnail($this->Get("ResourceId"));
}
function GetImage($number)
{
return $this->Images->GetImageByResource($this->Get("ResourceId"),$number);
}
function GetImageByName($name)
{
if(!is_object($this->Images))
$this->Images = new clsImageList();
return $this->Images->GetImageByName($this->Get("ResourceId"),$name);
}
function &GetDefaultImage()
{
return $this->Images->GetDefaultImage($this->Get("ResourceId"));
}
function CreatePendingCopy()
{
$OrgId = $this->IdField();
$this->Dirty();
$this->Set("OrgId",$OrgId);
$this->UnsetIdField();
$this->Set("ResourceId",0);
$this->Set("Status",-2);
$this->Create();
}
function AddFavorite($PortalUserId=NULL)
{
global $objSession, $objFavorites;
$res = FALSE;
if($objSession->HasCatPermission("FAVORITES"))
{
if(!$PortalUserId)
$PortalUserId = $objSession->Get("PortalUserId");
if($PortalUserId==$objSession->Get("PortalUserId") || $objSession->HasSystemPermission("ADMIN"))
{
$objFavorites->AddFavorite($PortalUserId,$this->Get("ResourceId"), $this->type);
$res = TRUE;
}
}
return $res;
}
function DeleteFavorite($PortalUserId=NULL)
{
global $objSession, $objFavorites;
$res = FALSE;
if($objSession->HasCatPermission("FAVORITES"))
{
if(!$PortalUserId)
$PortalUserId = $objSession->Get("PortalUserId");
//echo $PortalUserId." ".$objSession->Get("PortalUserId");
if($PortalUserId==$objSession->Get("PortalUserId") || $objSession->HasSystemPermission("ADMIN"))
{
$objFavorites->DeleteFavorite($PortalUserId,$this->Get("ResourceId"));
$res = TRUE;
}
}
return $res;
}
function IsFavorite($PortalUserId=NULL)
{
global $objSession, $objFavorites;
$res = FALSE;
if($objSession->HasCatPermission("FAVORITES"))
{
if(!$PortalUserId)
$PortalUserId = $objSession->Get("PortalUserId");
if($PortalUserId==$objSession->Get("PortalUserId") || $objSession->HasSystemPermission("ADMIN"))
{
$i = $objFavorites->GetFavoriteObject($PortalUserId,$this->Get("ResourceId"));
if(is_object($i))
{
$res = TRUE;
}
else
$res = FALSE;
}
}
return $res;
}
function CheckBanned()
{
global $objBanList;
$objBanList->LoadItemRules($this->type);
$found = FALSE;
$MatchedRule = 0;
foreach($objBanList->Items as $b)
{
$field = $b->Get("ItemField");
if($this->FieldExists($field))
{
$ThisValue = strtolower($this->Get($field));
$TestValue = strtolower($b->Get("ItemValue"));
switch($b->Get("ItemVerb"))
{
case 0: /* any */
$found = TRUE;
break;
case 1: /* is */
if($ThisValue==$TestValue)
$found = TRUE;
break;
case 2: /* is not */
if($ThisValue != $TestValue)
$found = TRUE;
break;
case 3: /* contains */
if(strstr($ThisValue,$TestValue))
$found = TRUE;
break;
case 4: /* not contains */
if(!strstr($ThisValue,$TestValue))
$found = TRUE;
break;
case 5: /* Greater Than */
if($TestValue > $ThisValue)
$found = TRUE;
break;
case 6: /* Less Than */
if($TestValue < $ThisValue)
$found = TRUE;
break;
case 7: /* exists */
if(strlen($ThisValue)>0)
$found = TRUE;
break;
case 8: /* unique */
if($this->ValueExists($field,$ThisValue))
$found = TRUE;
break;
}
}
if($found)
{
if($b->Get("RuleType")==0)
{
$MatchedRule = $b->Get("RuleId");
}
else
{
$MatchedRule = 0;
}
break;
}
}
return $MatchedRule;
}
} /* clsItem */
class clsCatItem extends clsItem
{
function clsCatItem($FullItem=FALSE)
{
$this->clsItem($FullItem);
}
function Delete($RecordOnly=FALSE)
{
global $objFavorites;
parent::Delete($RecordOnly);
if($RecordOnly==FALSE)
{
$this->RemoveFromAllCategories();
}
}
/* category membership functions */
function AssignPrimaryCategory($SourceTable)
{
+ $catid = 0;
$sql = "SELECT * FROM $SourceTable WHERE ItemResourceId=".$this->Get("ResourceId")." LIMIT 1";
$rs = $this->adodbConnection->Execute($sql);
if($rs && !$rs->EOF)
{
$catid = $rs->fields["CategoryId"];
$this->SetPrimaryCategory($catid,$SourceTable);
}
return $catid;
-
}
function GetPrimaryCategory($SourceTable = "")
{
if(is_numeric($this->PrimaryCat))
return $this->PrimaryCat;
$this->PrimaryCat="";
if( strlen($SourceTable) == 0 ) $SourceTable = GetTablePrefix()."CategoryItems";
$res_id = $this->HasField('ResourceId') ? $this->Get('ResourceId') : 0;
$sql = "SELECT * FROM $SourceTable WHERE ItemResourceId=".$res_id." AND PrimaryCat=1";
$rs = $this->adodbConnection->Execute($sql);
if($rs && !$rs->EOF)
{
$this->PrimaryCat=$rs->fields["CategoryId"];
return $this->PrimaryCat;
}
else
{
$this->AssignPrimaryCategory($SourceTable);
return $this->PrimaryCat;
}
}
function SetPrimaryCategory($CategoryId,$SourceTable = "")
{
if(strlen($SourceTable)==0)
$SourceTable = GetTablePrefix()."CategoryItems";
$rs = $this->adodbConnection->Execute('SELECT * FROM '.$SourceTable.' WHERE CategoryId='.$CategoryId.' AND ItemResourceId='.$this->Get("ResourceId"));
$this->adodbConnection->Execute("UPDATE $SourceTable SET PrimaryCat=0 WHERE ItemResourceId=".$this->Get("ResourceId"));
$this->adodbConnection->Execute("UPDATE $SourceTable SET PrimaryCat=1 WHERE CategoryId=$CategoryId AND ItemResourceId=".$this->Get("ResourceId"));
$this->PrimaryCat=$CategoryId;
}
function CategoryMemberCount($SourceTable="")
{
if(strlen($SourceTable)==0)
$SourceTable = GetTablePrefix()."CategoryItems";
$sql = "SELECT count(*) as CatCount FROM $SourceTable WHERE ItemResourceId=".$this->Get("ResourceId");
if($this->debuglevel)
echo $sql."<br>\n";
$rs = $this->adodbConnection->Execute($sql);
$count = 0;
if($rs && !$rs->EOF)
$count = $rs->fields["CatCount"];
return $count;
}
function CategoryMemberList($SourceTable="")
{
$cats = array();
if(strlen($SourceTable)==0)
$SourceTable = GetTablePrefix()."CategoryItems";
$sql = "SELECT * FROM $SourceTable WHERE ItemResourceId=".$this->Get("ResourceId");
if($this->debuglevel)
echo $sql."<br>\n";
$rs = $this->adodbConnection->Execute($sql);
while($rs && !$rs->EOF)
{
$cats[] = $rs->fields["CategoryId"];
$rs->MoveNext();
}
$catlist = implode(",",$cats);
return $catlist;
}
function AddToCategory($CatId,$SourceTable="",$PrimaryValue=NULL)
{
global $objSession, $objCatList;
if(!$SourceTable)
$SourceTable = GetTablePrefix()."CategoryItems";
if($this->type>0)
{
$Primary = 0;
if(is_numeric($PrimaryValue))
{
$Primary = $PrimaryValue;
if($Primary==1)
$this->PrimaryCat = $CatId;
}
else
{
if(!is_numeric($this->GetPrimaryCategory()))
{
$Primary =1;
$this->PrimaryCat = $CatId;
}
}
// check if not exists
$db =& $this->adodbConnection;
$sql = sprintf('SELECT * FROM %s WHERE CategoryId = %s AND ItemResourceId = %s', $SourceTable, $CatId, $this->Get("ResourceId"));
$rs = $db->Execute($sql);
if($rs->RecordCount() == 0 )
{
$sql = "INSERT INTO $SourceTable (CategoryId,ItemResourceId, PrimaryCat) VALUES ('$CatId','".$this->Get("ResourceId")."',$Primary)";
if($this->debuglevel)
echo $sql."<br>\n";
$this->adodbConnection->Execute($sql);
}
$c = $objCatList->GetCategory($CatId);
}
}
function RemoveFromCategory($CatId,$SourceTable="",$Force=0)
{
global $objSession, $objCatList;
if(strlen($SourceTable)==0)
$SourceTable = GetTablePrefix()."CategoryItems";
if($this->type>0)
{
$primary = $this->GetPrimaryCategory();
if(($primary==$CatId && $this->CategoryMemberCount($SourceTable)>1) || ($primary != $CatId) || $Force)
{
$sql = "DELETE FROM $SourceTable WHERE CategoryId=$CatId AND ItemResourceId=".$this->Get("ResourceId");
if($objSession->HasSystemPermission("DEBUG.LIST"))
echo $sql."<br>\n";
$this->adodbConnection->Execute($sql);
$c = $objCatList->GetCategory($CatId);
$c->ClearCacheData();
}
}
}
function MoveToCategory($OldCatId,$NewCatId,$SourceTable="")
{
if(strlen($SourceTable)==0)
$SourceTable = GetTablePrefix()."CategoryItems";
$sql = "UPDATE $SourceTable SET CategoryId=$NewCatId WHERE CategoryId=$OldCatId AND ItemResourceId=".$this->Get("ResourceId");
if($this->debuglevel)
echo $sql."<br>\n";
$this->adodbConnection->Execute($sql);
}
function DeleteCategoryItems($CatId,$SourceTable = "")
{
if(strlen($SourceTable)==0)
$SourceTable = GetTablePrefix()."CategoryItems";
$CatCount = $this->CategoryMemberCount($SourceTable);
if($CatCount>1)
{
$this->RemoveFromCategory($CatId,$SourceTable);
$this->ClearCacheData();
}
else
{
$this->Delete();
$sql = "DELETE FROM $SourceTable WHERE CategoryId=$CatId AND ItemResourceId=".$this->Get("ResourceId");
if($this->debuglevel)
echo $sql."<br>\n";
$this->adodbConnection->Execute($sql);
}
}
function RemoveFromAllCategories($SourceTable = "")
{
if(strlen($SourceTable)==0)
$SourceTable = GetTablePrefix()."CategoryItems";
if($this->type>0)
{
$sql = "SELECT * FROM $SourceTable WHERE ResourceId=".$this->Get("ResourceId");
$rs = $this->adodbConnection->Execute($sql);
while ($rs && !$rs->EOF)
{
$CategoryId = $rs->fields["CategoryId"];
$rs->MoveNext();
}
$sql = "DELETE FROM $SourceTable WHERE ResourceId=".$this->Get("ResourceId");
if($this->debuglevel)
echo $sql."<br>\n";
$this->adodbConnection->Execute($sql);
}
}
function CopyToNewResource($TargetCat = NULL,$NameField="Name")
{
global $objSession;
$CatList = $this->CategoryMemberList();
$Cats = explode(",",$CatList);
//echo "Target: $TargetCat<br>";
$OldId = $this->Get("ResourceId");
$this->UnsetIdField();
$this->Dirty();
if(!is_numeric($this->Get("OrgId")))
$this->UnsetField("OrgId");
$this->UnsetField("ResourceId");
if(is_numeric($TargetCat) && strlen($NameField))
{
$OldName = $this->Get($NameField);
if(substr($OldName,0,5)=="Copy ")
{
$parts = explode(" ",$OldName,4);
if($parts[2]=="of" && is_numeric($parts[1]))
{
$Name = $parts[3];
}
else
if($parts[1]=="of")
{
$Name = $parts[2]." ".$parts[3];
}
else
$Name = $OldName;
}
else
$Name = $OldName;
$Names = CategoryItemNameCount($TargetCat,$this->tablename,$NameField,$Name);
if(count($Names)>0)
{
$NameCount = count($Names);
$found = FALSE;
$NewName = "Copy of $Name";
if(!in_array("Copy of $Name",$Names))
{
$found = TRUE;
}
else
{
for($x=2;$x<$NameCount+2;$x++)
{
$NewName = "Copy ".$x." of ".$Name;
if(!in_array($NewName,$Names))
{
$found = TRUE;
break;
}
}
}
if(!$found)
{
$NameCount++;
$NewName = "Copy $NameCount of $Name";
}
$this->Set($NameField,$NewName);
}
}
$this->Create();
// copy relationships
$NewId = $this->Get("ResourceId");
$reldata = new clsRelationshipList($DestCat,$this->IdField());
$reldata->CopyToResource($OldId,$NewId);
// copy reviews
$rdata = new clsItemReviewList();
$rdata->CopyToItemId($OldId,$NewId);
unset($rdata);
// copy custom fields
$cdata = new clsCustomDataList();
$cdata->CopyResource($OldId,$NewId);
unset($cdata);
// copy images
if(is_object($this->Images))
$this->Images->CopyResource($OldId,$NewId);
$this->AddToCategory($TargetCat, '', 0); // insert (but with duplicate records check)
//echo "ok";
if(is_numeric($TargetCat))
{
if(is_array($Cats))
{
if(!in_array($TargetCat,$Cats))
{
$this->AddToCategory($TargetCat, 0); // insert
}
}
$this->SetPrimaryCategory($TargetCat); // 2 updates
}
}
}
?>
\ No newline at end of file
Property changes on: trunk/kernel/include/item.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.2
\ No newline at end of property
+1.3
\ No newline at end of property
Index: trunk/kernel/include/portaluser.php
===================================================================
--- trunk/kernel/include/portaluser.php (revision 287)
+++ trunk/kernel/include/portaluser.php (revision 288)
@@ -1,1004 +1,1000 @@
<?php
RegisterPrefix("clsPortalUser","user","kernel/include/portaluser.php");
class clsPortalUser extends clsItem
{
var $Vars; //contains the PersistantSessionData for the user
var $VarsLoaded;
var $PrimeGroup;
function clsPortalUser($UserId=NULL)
{
$this->clsParsedItem();
$this->tablename=GetTablePrefix()."PortalUser";
$this->type=6;
$this->BasePermission="USER";
$this->id_field = "PortalUserId";
$this->TagPrefix="user";
$this->Vars = array();
$VarsLoaded = FALSE;
$this->debuglevel = 0;
if(isset($UserId))
$this->LoadFromDatabase($UserId);
}
function Delete()
{
global $objGroups, $objFavorites;
$g = $objGroups->GetPersonalGroup($this->Get("Login"));
if(is_object($g))
$g->Delete();
$objFavorites->DeleteUser($this->Get("PortalUserId")); //delete favorites
parent::Delete();
}
function RemoveFromAllGroups()
{
$sql = "DELETE FROM ".GetTablePrefix()."UserGroup WHERE PortaluserId=".$this->Get("PortalUserId");
$this->adodbConnection->Execute($sql);
}
function RemoveFromGroup($GroupId)
{
$sql = "DELETE FROM ".GetTablePrefix()."UserGroup WHERE PortaluserId=".$this->Get("PortalUserId");
$sql .= " AND GroupId=$GroupId";
$this->adodbConnection->Execute($sql);
}
function PrimaryGroup($ReturnField = "GroupId")
{
global $objGroups;
$ret = "";
if(!is_object($this->PrimeGroup))
{
if((int)$this->Get("GroupId")>0)
{
$this->PrimeGroup =& $objGroups->GetItem($this->Get("GroupId"));
}
else
{
$this->PrimeGroup = new clsPortalGroup();
$sql = "SELECT * FROM ".GetTablePrefix()."UserGroup INNER JOIN ".GetTablePrefix()."PortalGroup ON (".GetTablePrefix()."UserGroup.GroupId=".GetTablePrefix()."PortalGroup.GroupId) WHERE PrimaryGroup = 1 AND PortalUserId=".$this->Get("PortalUserId");
//echo $sql;
$rs = $this->adodbConnection->Execute($sql);
if($rs && !$rs->EOF)
$this->PrimeGroup->SetFromArray($rs->fields);
}
}
$ret = $this->PrimeGroup->Get($ReturnField);
return $ret;
}
function SetPrimaryGroup($GroupId)
{
if($this->IsInGroup($GroupId))
{
$sql = "UPDATE ".GetTablePrefix()."UserGroup SET PrimaryGroup=0 WHERE PortalUserId=".$this->Get("PortalUserId");
$this->adodbConnection->Execute($sql);
$sql = "UPDATE ".GetTablePrefix()."UserGroup SET PrimaryGroup=1 WHERE GroupId=$GroupId AND PortalUserId=".$this->Get("PortalUserId");
$this->adodbConnection->Execute($sql);
}
}
function GetGroupList()
{
$ret = array();
$sql = "SELECT GroupId FROM %sUserGroup WHERE PortalUserId = %s ORDER BY PrimaryGroup";
$sql = sprintf($sql, GetTablePrefix(), $this->Get("PortalUserId"));
$ret = $this->adodbConnection->GetCol($sql);
return $ret;
}
function IsInGroup($GroupId)
{
$groups = $this->GetGroupList();
if( $groups === false ) return false;
return in_array($GroupId, $groups) ? true : false;
}
function GetPersonalGroup($CreateIfMissing = FALSE)
{
global $objGroups;
$n = "_".$this->Get("Login");
$g = $objGroups->GetItemByField("Name",$n);
if(!is_object($g) && $CreateIfMissing)
$g = $this->CreatePersonalGroup();
return $g;
}
function CreatePersonalGroup()
{
global $objGroups;
$Description = $this->Get("FirstName")." ".$this->Get("LastName");
$CreatedOn=time();
$n = "_".$this->Get("Login");
$g = $objGroups->Add_Group($n, $Description, $CreatedOn, 1, 0);
$g->Set("Personal",1);
$g->Set("System",0);
$g->Set("Enabled",1);
$g->Update();
if(is_object($g))
$g->AddUser($this->Get("PortalUserId"));
return $g;
}
function Validate()
{
global $Errors;
$dataValid = true;
if(!strlen($this->Get("Login")))
{
$Errors->AddError("error.fieldIsRequired",'Login',"","",get_class($this),"Validate");
$dataValid = false;
}
if(!strlen($this->Get("Email")))
{
$Errors->AddError("error.fieldIsRequired",'Email',"","",get_class($this),"Validate");
$dataValid = false;
}
return $dataValid;
}
function Approve()
{
$this->Set("Status", 1);
$this->Update();
$this->SendUserEventMail("USER.APPROVE",$this->Get("PortalUserId"));
$this->SendAdminEventMail("USER.APPROVE");
}
function Deny($IsBanned = 0)
{
$this->Set( Array('Status','IsBanned'), Array(0,$IsBanned) );
$this->Update();
$this->SendUserEventMail("USER.DENY",$this->Get("PortalUserId"));
$this->SendAdminEventMail("USER.DENY");
}
function HasSystemPermission($PermissionName)
{
global $objGroups;
$GroupList = $this->GetGroupList();
for($i=0;$i<count($GroupList);$i++)
{
$g = $objGroups->GetItem($GroupList[$i]);
$value = $g->HasSystemPermission($PermissionName);
if($value != -1)
break;
}
return $value;
}
function LoadPersistantVars()
{
global $objConfig;
unset($this->Vars);
$this->Vars = array();
$user_id = $this->HasField('PortalUserId') ? $this->Get('PortalUserId') : 0;
$sql = "SELECT VariableName, VariableValue FROM ".GetTablePrefix()."PersistantSessionData WHERE PortalUserId = 0 OR PortalUserId = ".$user_id." ORDER BY PortalUserId ASC";
$result = $this->adodbConnection->Execute($sql);
while ($result && !$result->EOF)
{
$data = $result->fields;
$this->Vars[$data["VariableName"]] = $data["VariableValue"];
$objConfig->Set($data["VariableName"], $data["VariableValue"], 1, 1);
$result->MoveNext();
}
$this->VarsLoaded=TRUE;
}
function SetPersistantVariable($variableName, $variableValue)
{
global $objConfig;
if(!$this->VarsLoaded)
$this->LoadPersistantVars();
$userid = $this->Get("PortalUserId");
$objConfig->Set($variableName,$variableValue,1);
$fields = array_keys($this->Vars);
if(strlen($variableValue)>0)
{
if(in_array($variableName,$fields))
{
$sql = "UPDATE ".GetTablePrefix()."PersistantSessionData SET VariableValue='$variableValue' WHERE VariableName='$variableName' AND PortalUserId=$userid";
}
else
$sql = "INSERT INTO ".GetTablePrefix()."PersistantSessionData (VariableName,VariableValue,PortalUserId) VALUES ('$variableName','$variableValue',$userid)";
}
else
$sql = "DELETE FROM ".GetTablePrefix()."PersistantSessionData WHERE VariableName='$variableName' AND PortalUserId=$userid";
$this->Vars[$variableName] = $variableValue;
// echo "<BR>SQL: $sql<BR>";
$this->adodbConnection->Execute($sql);
}
function GetPersistantVariable($variableName)
{
global $objConfig;
if(!$this->VarsLoaded)
$this->LoadPersistantVars();
$fields = array_keys($this->Vars);
if(in_array($variableName,$fields))
{
$val = $this->Vars[$variableName];
}
else
$val = $objConfig->Get($variableName);
return $val;
}
function GetAllPersistantVars()
{
if(!$this->VarsLoaded)
$this->LoadPersistantVars();
return $this->Vars;
}
function GetIcon()
{
}
function StatusIcon()
{
global $imagesURL;
$url = $imagesURL."/itemicons/icon16_user";
if($this->Get("Status")==0)
{
$url .= "_disabled";
}
else
if($this->Get("Status")==2)
{
$url .= "_pending";
}
$url .= ".gif";
return $url;
}
function IsFriend($UserId)
{
$ftable = GetTablePrefix()."Favorites";
$sql = "SELECT count(*) as FriendCount FROM $ftable WHERE PortalUserId=$UserId AND ResourceId=";
$sql .=$this->Get("ResourceId")." AND ItemTypeId=6";
$rs = $this->adodbConnection->Execute($sql);
if($rs && !$rs->EOF)
return ($rs->fields["FriendCount"]>0);
return FALSE;
}
function GetUserTime($timestamp)
{
if(is_numeric($this->Get("tz")))
{
return GetLocalTime($timestamp,$this->Get("tz"));
}
else
return GetLocalTime($timestamp);
}
function ParseObject($element)
{
global $objConfig, $objUsers, $objCatList,$objSession, $var_list_update, $var_list, $m_var_list_update;
//echo "<PRE>"; print_r($element); echo "</pre>";
if (strtolower($element->name) == 'touser') {
$this->TagPrefix = "touser";
}
$extra_attribs = ExtraAttributes($element->attributes);
if(strtolower($element->name)==$this->TagPrefix)
{
$field = strtolower($element->attributes["_field"]);
if(substr($field,0,3)=="pp_")
{
$perm = $objSession->GetPersistantVariable($field);
if($perm)
{
$field = substr($field,3);
}
else
$field = "";
}
switch($field)
{
/*
@field:user.login
@description:User's login name
*/
case "username":
case "login":
$ret = $this->Get("Login");
break;
case "firstname":
$ret = $this->Get("FirstName");
break;
case "lastname":
$ret = $this->Get("LastName");
break;
case "password":
/*
@field:user.password
@description:User password
*/
$ret = $this->Get("Password");
break;
case "email":
$ret = $this->Get("Email");
break;
case "street":
$ret = $this->Get("Street");
break;
case "city":
$ret = $this->Get("City");
break;
case "state":
$ret = $this->Get("State");
break;
case "zip":
$ret = $this->Get("Zip");
break;
case "phone":
$ret = $this->Get("Phone");
break;
case "country":
$ret = $this->Get("Country");
break;
case "primarygroup":
/*
@field:user.primarygroup
@description:Parses a field from the user's primary group
@attrib:_groupfield::group field name to parse, defaults to group name
*/
$groupfield = $element->attributes["_groupfield"];
if(!strlen($groupfield))
$groupfield="Name";
$ret = $this->PrimaryGroup($groupfield);
break;
case "date":
/*
@field:user.date
@description:Returns the date/time the user was created
@attrib:_tz:bool:Convert the date to the user's local time
@attrib:_part::Returns part of the date. The following options are available: month,day,year,time_24hr,time_12hr
*/
$d = $this->Get("CreatedOn");
if($element->attributes["_tz"])
{
$d = GetLocalTime($d,$objSession->Get("tz"));
}
$part = strtolower($element->attributes["_part"]);
if(strlen($part))
{
$ret = ExtractDatePart($part,$d);
}
else
{
if($d<=0)
{
$ret = "";
}
else
$ret = LangDate($d);
}
break;
case "dob":
/*
@field:user.dob
@description:Returns the date/time of the users date of birth
@attrib:_tz:bool:Convert the date to the user's local time
@attrib:_part::Returns part of the date. The following options are available: month,day,year,time_24hr,time_12hr
*/
$d = $this->Get("dob");
if($element->attributes["_tz"])
{
$d = GetLocalTime($d,$objSession->Get("tz"));
}
$part = strtolower($element->attributes["_part"]);
if(strlen($part))
{
$ret = ExtractDatePart($part,$d);
}
else
{
if($d<=0)
{
$ret = "";
}
else
$ret = LangDate($d);
}
break;
case "modified":
/*
@field:user.modified
@description:Returns the date/time the user was last modified
@attrib:_tz:bool:Convert the date to the user's local time
@attrib:_part::Returns part of the date. The following options are available: month,day,year,time_24hr,time_12hr
*/
$d = $this->Get("Modified");
if($d<=0)
$d = $this->Get("CreatedOn");
if($element->attributes["_tz"])
{
$d = GetLocalTime($d,$objSession->Get("tz"));
}
$part = strtolower($element->attributes["_part"]);
if(strlen($part))
{
$ret = ExtractDatePart($part,$d);
}
else
{
if($d<=0)
{
$ret = "";
}
else
$ret = LangDate($d);
}
break;
case "profile_link":
/*
@field:user.profile_link
@description:Create a link to the user's profile
@attrib:_template:tpl:template the link should point to
*/
$t = $element->attributes["_template"];
if(strlen($t))
{
$var_list_update["t"] = $t;
}
else
$var_list_update["t"] = $var_list["t"];
$ret = GetIndexURL()."?env=" . BuildEnv()."&UserId=".$this->Get("PortalUserId");
break;
case "add_friend_link":
/*
@field:user.add_friend_link
@description:link to add a user to the friends list
@attrib:_template:tpl:Template link shoukd point to
*/
if($element->attributes["_force"] || !$this->IsFriend($objSession->Get("PortalUserId")) &&
$this->Get("PortalUserId") != $objSession->Get("PortalUserId"))
{
$t = $element->attributes["_template"];
if(strlen($t))
{
$var_list_update["t"] = $t;
}
else
$var_list_update["t"] = $var_list["t"];
$action = "m_add_friend";
$ret = GetIndexURL()."?env=" . BuildEnv()."&Action=".$action."&UserId=".$this->Get("PortalUserId");
}
else
$ret = "";
break;
case "del_friend_link":
/*
@field:user.del_friend_link
@description:link to remove a user from the friends list
@attrib:_template:tpl:Template link shoukd point to
*/
if($element->attributes["_force"] || $this->IsFriend($objSession->Get("PortalUserId")) &&
$this->Get("PortalUserId") != $objSession->Get("PortalUserId"))
{
$t = $element->attributes["_template"];
if(strlen($t))
{
$var_list_update["t"] = $t;
}
else
$var_list_update["t"] = $var_list["t"];
$action = "m_del_friend";
$ret = GetIndexURL()."?env=" . BuildEnv()."&Action=".$action."&UserId=".$this->Get("PortalUserId");
}
else
$ret = "";
break;
case "icon":
$ret = $this->GetIcon();
break;
case "image":
/*
@field:user.image
@description:Return an image associated with the user
@attrib:_default:bool:If true, will return the default image if the requested image does not exist
@attrib:_name::Return the image with this name
@attrib:_thumbnail:bool:If true, return the thumbnail version of the image
@attrib:_imagetag:bool:If true, returns a complete image tag. exta html attributes are passed to the image tag
*/
$default = $element->attributes["_primary"];
$name = $element->attributes["_name"];
if(strlen($name))
{
$img = $this->GetImageByName($name);
// echo "<PRE>";print_r($img); echo "</PRE>";
}
else
{
if($default)
$img = $this->GetDefaultImage();
}
if($img)
{
if($element->attributes["_thumbnail"])
{
$url = $img->parsetag("thumb_url");
}
else
$url = $img->parsetag("image_url");
}
else
{
$url = $element->attributes["_defaulturl"];
}
if($element->attributes["_imagetag"])
{
if(strlen($url))
{
$ret = "<IMG src=\"$url\" $extra_attribs >";
}
else
$ret = "";
}
else
$ret = $url;
break;
case "custom":
/*
@field:cat.custom
@description:Returns a custom field
@attrib:_customfield::field name to return
@attrib:_default::default value
*/
$field = $element->attributes["_customfield"];
$default = $element->attributes["
"];
$ret = $this->GetPersistantVariable($field);
if(!strlen($ret))
$ret = $this->GetCustomFieldValue($field,$default);
break;
}
}
else
{
$ret = $this->parsetag($element->name);
}
return $ret;
}
function parsetag($tag)
{
global $m_var_list_update, $var_list_update, $var_list, $objConfig;
if(is_object($tag))
{
$tagname = $tag->name;
}
else
$tagname = $tag;
switch($tagname)
{
case "user_id":
return $this->Get("ResourceId");
break;
case "user_login":
return $this->Get("Login");
break;
case "user_group":
return $this->Get("PrimaryGroupName");
break;
case "user_firstname":
return $this->Get("FirstName");
break;
case "user_lastname":
return $this->Get("LastName");
break;
case "user_email":
return $this->Get("Email");
break;
case "user_date":
return LangDate($this->Get("CreatedOn"));
break;
case "user_datetime":
return LangDate($this->Get("CreatedOn"))." ".LangTime($this->Get("CreatedOn"));
break;
case "user_dob":
return LangDate($this->Get("dob"));
break;
case "user_password":
return $this->Get("Password");
break;
case "user_phone":
return $this->Get("Phone");
break;
case "user_street":
return $this->Get("Street");
break;
case "user_city":
return $this->Get("City");
break;
case "user_state":
return $this->Get("State");
break;
case "user_zip":
return $this->Get("Zip");
break;
case "user_country":
return $this->Get("Country");
break;
case "user_resourceid":
return $this->Get("ResourceId");
break;
case "user_icon":
return $this->GetIcon();
break;
case "user_profile_link":
$var_list_update["t"] = "user_profile";
$m_var_list_update["action"] = $this->Get("UserId");
$ret = GetIndexURL()."?env=" . BuildEnv();
unset($m_var_list_update["action"], $var_list_update["t"]);
return $ret;
break;
case "user_messages":
return $this->NewMessages();
break;
case "user_messages_link":
$var_list_update["t"] = "inbulletin/bb_private_msg_list";
return GetIndexURL()."?env=" . BuildEnv();
unset($var_list_update);
break;
default:
return "Undefined:$tagname";
break;
}
}
} /* class clsPortalUser*/
class clsUserManager extends clsItemList //clsItemCollection
{
/*this class wraps common user-related functions */
// var $Page;
function clsUserManager()
{
$this->clsItemCollection(); // clsItemList() // need to use this, but double limit clause being created (normal+default 0,100)
$this->classname = "clsPortalUser";
$this->SourceTable = GetTablePrefix()."PortalUser";
$this->Page = isset($_GET['lpn']) ? $_GET['lpn'] : 1;
$this->EnablePaging = true;
$this->PerPageVar = "Perpage_User";
$this->AdminSearchFields = array("Login","FirstName","LastName","Email","Street","City", "State","Zip","Country","Phone");
}
function GetPageLinkList($dest_template=NULL,$link_template=NULL,$page = "")
{
global $objConfig, $m_var_list_update, $var_list_update, $var_list;
if(!strlen($page))
$page = GetIndexURL();
$NumPages = $this->GetNumPages($objConfig->Get("Perpage_Topics"));
if(strlen($dest_template)>0)
{
$var_list_update["t"]=$dest_template;
}
else
{
$var_list_update["t"] = $var_list["t"];
}
$o = "";
if($this->Page>1)
{
$m_var_list_update["p"]=$this->Page-1;
$prev_url = $page."?env=".BuildEnv();
}
if($this->Page<$NumPages)
{
$m_var_list_update["p"]=$this->Page+1;
$next_url = $page."?env=".BuildEnv();
}
for($p=1;$p<=$NumPages;$p++)
{
$t = template($link_template);
if($p!=$this->Page)
{
$m_var_list_update["p"]=$p;
$href = $page."?env=".BuildEnv();
$t = str_replace("<%page_link%>", $href, $t);
$t = str_replace("<%page_number%>",$p,$t);
$t = str_replace("<%prev_url%>",$prev_url,$t);
$t = str_replace("<%next_url%>",$next_url,$t);
$o .= $t;
}
else
{
$o .= "<SPAN class=\"CURRENT_PAGE\">$p</SPAN>";
}
}
return $o;
}
function GetUser($ID)
{
$u = $this->GetItem($ID);
return $u;
}
function GetUserName($Id)
{
$rs = $this->adodbConnection->Execute("SELECT Login from ".$this->SourceTable." where PortalUserId=$Id");
return $rs->fields["Login"];
}
function GetUserId($Login)
{
$rs = $this->adodbConnection->Execute("SELECT PortalUserId from ".$this->SourceTable." where Login LIKE '$Login'");
return $rs->fields["PortalUserId"];
}
function GetTotalUsers()
{
return $this->UserCount("1");
}
function GetLatestUser()
{
global $Errors;
$sql = "SELECT max(CreatedOn) as LastDate FROM ".$this->SourceTable;
$result = $this->adodbConnection->Execute($sql);
if ($result === false || !is_object($result))
{
$Errors->AddError("error.DatabaseError",NULL,$adodbConnection->ErrorMsg(),"",get_class($this),"GetLatestUser");
return false;
}
$sql = "SELECT PortalUserId FROM ".$this->SourceTable." WHERE CreatedOn >= ".$result->fields["LastDate"];
$result = $this->adodbConnection->Execute($sql);
if (!rs || $rs->EOF)
{
$Errors->AddError("error.DatabaseError",NULL,$adodbConnection->ErrorMsg(),"",get_class($this),"GetLatestUser");
return false;
}
$u = $this->GetUser($result->fields["PortalUserId"]);
return $u;
}
function &Add_User($Login, $Password, $Email, $CreatedOn, $FirstName="", $LastName="", $Status=2,
$Phone="", $Street="", $City="", $State="", $Zip="", $Country="", $dob=0, $ip="", $CheckBanned=FALSE)
{
$u = new clsPortalUser(NULL);
$u->tablename = $this->SourceTable;
//echo "Creating User..<br>\n";
$u->Set(array("Login", "Password", "FirstName", "LastName", "Email", "Status",
"Phone","Street", "City", "State", "Zip", "Country", "CreatedOn","dob"),
array($Login, $Password, $FirstName, $LastName, $Email, $Status,
$Phone, $Street, $City, $State, $Zip, $Country, $CreatedOn, $dob));
- if($CheckBanned)
- {
- $BrokenRule = $u->CheckBanned();
- }
-
+
+ $BrokenRule = $CheckBanned ? $u->CheckBanned() : false;
if(!$BrokenRule)
{
$u->Create();
return $u;
-
}
return $BrokenRule;
/*md5($Password)*/
}
function &Edit_User($UserId, $Login, $Password, $Email, $CreatedOn, $FirstName="", $LastName="",
$Status=2, $Phone="", $Street="", $City="", $State="", $Zip="", $Country="", $dob=0)
{
//echo "<font color=\"red\">Editing User: [$UserId]</font><br>";
$u =& $this->GetItem($UserId);
if(!$CreatedOn)
$CreatedOn = $u->Get("CreatedOn");
// $u->debuglevel=1;
if (is_object($u))
{
$IsBanned = $u->Get('IsBanned');
if($Status == 1) $IsBanned = 0;
$u->Set(array("Login", "FirstName", "LastName", "Email", "Status",
"Phone", "Street", "City", "State", "Zip", "Country", "CreatedOn","dob","IsBanned"),
array($Login, $FirstName, $LastName, $Email, $Status,
$Phone, $Street, $City, $State, $Zip, $Country, $CreatedOn,$dob,$IsBanned));
if(strlen($Password))
$u->Set("Password",$Password);
$u->Update();
}
return $u;
}
function Delete_User($UserId)
{
$u = $this->GetItemByField("ResourceId",$UserId);
if(is_object($u))
{
$u->RemoveFromAllGroups();
$u->Delete();
}
}
function LoadUsers($where = "",$orderBy = "")
{
global $objConfig;
$this->Clear();
if($this->Page<1)
$this->Page=1;
if(is_numeric($objConfig->Get("Perpage_Users")))
{
$Start = ($this->Page-1)*$objConfig->Get("Perpage_Users");
$limit = "LIMIT ".$Start.",".$objConfig->Get("Perpage_Users");
}
else
$limit = NULL;
$where = trim($where);
$orderBy = trim($orderBy);
if(!strlen($where))
$where = "1";
$this->QueryItemCount=TableCount($this->SourceTable,$where,0);
if($this->QueryItemCount>0)
{
if ($orderBy!="")
{
$this->Query_PortalUser($where,$orderBy,$limit);
}
else
{
$this->Query_PortalUser($where,"Login DESC",$limit);
}
}
}
function Query_PortalUser($whereClause,$orderByClause="", $limitClause="")
{
global $m_var_list,$Errors, $objSession;
$resultSet = array();
$utable = $this->SourceTable;
$gtable = GetTablePrefix()."UserGroup";
$sql = "SELECT * FROM $utable LEFT JOIN $gtable ON ($utable.PortalUserId=$gtable.PortalUserId)";
if(isset($whereClause))
$sql = sprintf('%s WHERE %s',$sql,$whereClause);
if(isset($orderByClause))
if(strlen(trim($orderByClause))>0)
$sql = sprintf('%s ORDER BY %s',$sql,$orderByClause);
if(isset($limitClause))
$sql = sprintf('%s %s',$sql,$limitClause);
return $this->Query_Item($sql);
}
function Query_GroupPortalUser($whereClause,$orderByClause)
{
global $m_var_list,$objSession,$Errors;
$resultSet = array();
$table = $this->SourceTable;
$sql = "SELECT * FROM $table LEFT JOIN ".GetTablePrefix()."UserGroup USING (PortalUserId) ";
if(isset($whereClause))
$sql = sprintf('%s WHERE %s',$sql,$whereClause);
if(isset($orderByClause))
$sql = sprintf('%s ORDER BY %s',$sql,$orderByClause);
return $this->query_item($sql);
}
function UserCount($whereClause)
{
$count = TableCount($this->SourceTable,$whereClause,0);
return $count;
}
function CountActive()
{
return $this->UserCount("Status=1");
}
function CountPending()
{
return $this->UserCount("Status=2");
}
function CountDisabled()
{
return $this->UserCount("Status=0");
}
function CopyFromEditTable($idfield)
{
global $objSession;
$edit_table = $objSession->GetEditTable($this->SourceTable);
$sql = "SELECT * FROM $edit_table";
$rs = $this->adodbConnection->Execute($sql);
// echo $sql."<BR>";
while($rs && !$rs->EOF)
{
$data = $rs->fields;
$c = new $this->classname;
$c->SetFromArray($data);
$c->idfield = $idfield;
$c->Dirty();
if($c->Get($idfield)<1)
{
$old_id = $c->Get($idfield);
$c->UnsetIdField();
$c->Create();
$sql = "UPDATE ".GetTablePrefix()."UserGroup SET PortalUserId=".$c->Get("PortalUserId");
$sql .=" WHERE PortalUserId=0";
$this->adodbConnection->Execute($sql);
}
else
$c->Update();
unset($c);
$rs->MoveNext();
}
@$this->adodbConnection->Execute("DROP TABLE IF EXISTS $edit_table");
}
function PurgeEditTable()
{
parent::PurgeEditTable();
$sql = "DELETE FROM ".GetTablePrefix()."UserGroup WHERE PortalUserId=0";
$this->adodbConnection->Execute($sql);
}
} /*clsUserManager*/
?>
Property changes on: trunk/kernel/include/portaluser.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.8
\ No newline at end of property
+1.9
\ No newline at end of property
Index: trunk/kernel/include/customfield.php
===================================================================
--- trunk/kernel/include/customfield.php (revision 287)
+++ trunk/kernel/include/customfield.php (revision 288)
@@ -1,263 +1,262 @@
<?php
class clsCustomField extends clsItem
{
function clsCustomField($CustomFieldId=-1)
{
$this->clsItem();
$this->tablename=GetTablePrefix()."CustomField";
$this->type=10;
$this->BasePermission="";
$this->id_field = "CustomFieldId";
$this->NoResourceId=1; //set this to avoid using a resource ID
$this->debuglevel=0;
if($CustomFieldId>-1)
$this->LoadFromDatabase($CustomFieldId);
}
function GetAdminUI()
{
$a = new clsConfigAdminItem();
$a->name = "_".strtolower($this->Get("FieldName"));
$a->heading = $this->Get("Heading");
$a->prompt = $this->Get("Prompt");
$a->ElementType = $this->Get("ElementType");
$a->ValidationRules="";
$a->default_value = "";
$a->ValueList=$this->Get("ValueList");
if(!strlen($a->ElementType))
$a->ElementType="text";
if(!strlen($a->prompt))
$a->prompt = "lu_fieldcustom__".strtolower($this->Get("FieldName"));
return $a;
}
function parsetag($tag)
{
if(is_object($tag))
{
$tagname = $tag->name;
}
else
$tagname = $tag;
switch($tagname)
{
case "fieldlabel":
return $this->Get("FieldLabel");
break;
case "fieldname":
return $this->Get("FieldName");
break;
case "customfieldid":
return $this->Get("CustomFieldId");
default:
return "Undefined:$tagname";
break;
}
}
}
class clsCustomFieldList extends clsItemCollection
{
var $Type;
function clsCustomFieldList($type=-1,$table="CustomField")
{
$this->clsItemCollection();
$this->Type=$type;
$this->classname = "clsCustomField";
if($table=="CustomField")
$table = GetTablePrefix().$table;
$this->SourceTable = $table;
if($this->Type>0)
$this->LoadFields();
}
function LoadFields()
{
$this->Clear();
$sql = "SELECT * FROM ".$this->SourceTable." WHERE Type=".$this->Type;
if($this->debuglevel > 1)
echo $sql."<br>\n";
$rs = $this->adodbConnection->Execute($sql);
while($rs && !$rs->EOF)
{
$data = $rs->fields;
$this->AddItemFromArray($data);
$rs->MoveNext();
}
}
function LoadFieldsAndValues($ResourceId)
{
$this->Clear();
$table = $this->SourceTable;
$DataTable = GetTablePrefix()."CustomMetaData";
$sql = "SELECT $table.*,$DataTable.Value as Value, $DataTable.CustomDataId as CustomDataId FROM ".$table." LEFT JOIN $DataTable ON ";
$sql .= "(".$table.".CustomFieldId=$DataTable.CustomFieldId AND $DataTable.ResourceId=$ResourceId) WHERE Type=".$this->Type;
- if((int)$_GLOBALS["debuglevel"])
- echo $sql."<br>\n";
+ if( isset($GLOBALS["debuglevel"]) && $GLOBALS["debuglevel"]) echo $sql."<br>\n";
$rs = $this->adodbConnection->Execute($sql);
while($rs && !$rs->EOF)
{
$data = $rs->fields;
$this->AddItemFromArray($data);
$rs->MoveNext();
}
}
function GetFieldUIList($GeneralTab=FALSE)
{
$ret = new clsConfigAdmin();
if($this->NumItems()>0)
{
foreach($this->Items as $field)
{
if($GeneralTab==TRUE && $field->Get("OnGeneralTab")==1 || !$GeneralTab)
{
$ui = $field->GetAdminUI();
array_push($ret->Items,$ui);
}
}
}
return $ret;
}
function GetFieldNames()
{
$res = array();
foreach($this->Items as $f)
$res[] = $f->Get("FieldName");
return $res;
}
function SaveFields()
{
foreach($this->Items as $i)
{
if($i->Get("CustomFieldId"))
{
$i->Update();
}
else
$i->Create();
}
}
function Query_CustomField($where=NULL,$orderby=NULL,$limit=NULL)
{
$this->Clear();
$sql = "SELECT * FROM ".$this->SourceTable;
if(isset($where))
$sql = sprintf('%s WHERE %s',$sql,$where);
if(isset($orderby) && strlen(trim($orderby))>0)
$sql = sprintf('%s ORDER BY %s',$sql,$orderby);
if(isset($limit) && strlen(trim($limit)))
$sql .= " ".$limit;
// $sql."<br>";
$this->Query_Item($sql);
return $this->Items;
}
function AddField($Type,$FieldName,$FieldLabel,$ShowGeneral=0,$Heading="", $Prompt="",
$ElementType="",$ValueList="")
{
global $objItemTypes,$objSearchConfig,$objLanguages;
//if(!is_numeric($Type))
// {
$f = new clsCustomField();
$f->tablename = $this->SourceTable;
$f->Set(array("Type","FieldName","FieldLabel","OnGeneralTab","Heading","Prompt",
"ElementType","ValueList"),
array($Type,$FieldName,$FieldLabel,$ShowGeneral,$Heading,$Prompt,
$ElementType,$ValueList));
$f->Create();
$Item = $objItemTypes->GetItem($Type);
if(is_object($Item))
{
//$Table = $Item->Get("SourceTable");
$Table = GetTablePrefix()."CustomField";
$Header = "la_text_".strtolower($Item->Get("ItemName"));
$Module = $Item->Get("Module");
$Desc = $FieldLabel;
if(!is_object($objSearchConfig))
{
$objSearchConfig = new clsSearchConfigList();
}
$NextOrder = $objSearchConfig->GetNextDisplayOrder($Module);
$desc = "lu_fieldcustom__".strtolower($FieldName);
if(!strlen($FieldLabel))
{
$FieldLabel = $FieldName;
}
$l = $objLanguages->GetPrimary();
$phrases = new clsPhraseList();
$phrases->AddPhrase($desc,$l,$FieldLabel,2);
$dtable = GetTablePrefix()."CustomMetaData";
$Join = "($dtable.ResourceId={Table}.ResourceId)";
$objSearchConfig->AddSearchField($Table,$FieldName,$Module,0,0,$FieldLabel,$desc,$Header,$NextOrder,0,"text",$Join,$f->Get("CustomFieldId"));
}
return $f;
//}
//else
// return FALSE;
}
function EditField($FieldId,$Type,$FieldName,$FieldLabel,$ShowGeneral=0,$Heading="", $Prompt="",
$ElementType="",$ValueList="")
{
$f = $this->GetItem($FieldId);
$f->Set(array("Type","FieldName","FieldLabel","OnGeneralTab","Heading","Prompt",
"ElementType","ValueList"),
array($Type,$FieldName,$FieldLabel,$ShowGeneral,$Heading,$Prompt,
$ElementType,$ValueList));
$f->Update();
return $f;
}
function DeleteField($FieldId)
{
global $objItemTypes, $objSearchConfig;
//echo "<pre>"; print_r($objSearchConfig); echo "</pre>";
$f = $this->GetItem($FieldId);
$Type = $f->Get("Type");
$Item = $objItemTypes->GetItem($Type);
$Module = $Item->Get("Module");
if(is_object($Item))
{
//$table = $Item->Get("TableName");
$table = GetTablePrefix()."CustomField";
if(!is_object($objSearchConfig))
{
$objSearchConfig = new clsSearchConfigList($Module);
}
if (is_object($objSearchConfig)) {
$s = $objSearchConfig->GetItemByName($table,$f->Get("FieldName"));
//echo "$table ".$f->Get("FieldName")."<pre>"; print_r($s); echo "</pre>";
if(is_object($s))
{
$s->Delete();
}
}
}
$f->Delete();
}
}/*clsCustomFieldList*/
?>
Property changes on: trunk/kernel/include/customfield.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.2
\ No newline at end of property
+1.3
\ No newline at end of property
Index: trunk/kernel/admin/include/toolbar/inlink_inport.php
===================================================================
--- trunk/kernel/admin/include/toolbar/inlink_inport.php (nonexistent)
+++ trunk/kernel/admin/include/toolbar/inlink_inport.php (revision 288)
@@ -0,0 +1,94 @@
+<?php
+ // import scripts definitions: begin
+ global $import_scripts, $var, $objSession, $ro_perm;
+ $import_scripts = GetImportScripts();
+
+ // import scripts definitions: end
+ $ro_perm = $objSession->HasSystemPermission("SYSTEM_ACCESS.READONLY");
+?>
+
+<script language="javascript" type="text/javascript">
+
+<?php
+ if(!$ro_perm)
+ {
+?>
+ function ImportRedirect(form, import_id)
+ {
+ if( import_id === false ) return false;
+ var frm = document.getElementById(form);
+ frm.import_id.value = import_id;
+ frm.submit();
+ }
+
+ function CheckFinalForm(form)
+ {
+ // checks if all required fields are filled
+ var frm = document.getElementById(form);
+ <?php
+ $required = Array('user_admin','user_regular','init_cat');
+ $import_script = GetImportScript( $objSession->GetVariable('ImportScriptID') );
+ if( ($import_script !== false) && strlen($import_script['required_fields']) > 0 )
+ {
+ $script_required = explode(',', $import_script['required_fields']);
+ $required = array_merge($required, $script_required);
+ }
+ echo "var required_fields = Array('".implode("','", $required)."');\n";
+ ?>
+ var form_is_valid = true;
+ if(frm)
+ {
+ var i = 0;
+ var field_count = required_fields.length;
+ for(i = 0; i < field_count; i++)
+ form_is_valid &= frm.elements[ required_fields[i] ].value.length ? true : false;
+ }
+ else
+ return false;
+ return form_is_valid;
+ }
+
+ function import_submit(formname,formaction,action)
+ {
+ f = document.getElementById(formname);
+ if(f)
+ {
+ f.action = formaction;
+ f.Action.value = (action.length>0) ? action : 'Import';
+ f.submit();
+ }
+ }
+
+ function SetPercent(step_id, new_percent, additional, time_str)
+ {
+ var step_element = document.getElementById(step_id);
+ step_element.innerHTML = new_percent;
+
+ var add_element = document.getElementById(step_id+'_additional');
+ add_element.innerHTML = additional;
+
+ var time_element = document.getElementById('total_time');
+ time_element.innerHTML = time_str;
+ }
+
+<?php
+ }
+?>
+
+ function ChoiseMade(form, radio_name)
+ {
+ // checks if user has selected enabled radio button
+ var frm = document.getElementById(form);
+ if(frm)
+ {
+ var i = 0;
+ var element_count = frm.elements.length;
+ for(i = 0; i < element_count; i++)
+ if(frm[i].type == 'radio' && frm[i].name == radio_name)
+ if(frm[i].checked == true)
+ return frm[i].value;
+
+ return false;
+ }
+ }
+</script>
\ No newline at end of file
Property changes on: trunk/kernel/admin/include/toolbar/inlink_inport.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.1
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: trunk/kernel/frontaction.php
===================================================================
--- trunk/kernel/frontaction.php (revision 287)
+++ trunk/kernel/frontaction.php (revision 288)
@@ -1,859 +1,857 @@
<?php
if( defined('DEBUG_ACTIONS') && (DEBUG_ACTIONS & FRONT_KERNEL_ACTIONS) == FRONT_KERNEL_ACTIONS )
{
if($Action) echo '<span class="debug_text">Front, Kernel Action [<b>'.$Action."</b>]</span><br>\n";
}
if( defined('DEBUG_ACTIONS') && (DEBUG_ACTIONS & FRONT_SHOW_REQUEST) == FRONT_SHOW_REQUEST )
{
// don't show debug output in tree & header of admin & while logging in
$script = basename($_SERVER['PHP_SELF']);
echo '<table width="100%" cellspacing="0" cellpadding="5"><tr><td>';
echo "<div class=\"debug_text\">ScriptName: <b>$script</b> (<b>".dirname($_SERVER['PHP_SELF'])."</b>)</div><br>";
echo '<table border="0" cellspacing="0" cellpadding="4" class="debug_table">';
echo '<thead style="font-weight: bold;"><td>Src</td><td>Name</td><td>Value</td></thead>';
foreach($_REQUEST as $key => $value)
{
if( !is_array($value) && trim($value) == '' ) $value = '&nbsp;';
$src = isset($_GET[$key]) ? 'GE' : (isset($_POST[$key]) ? 'PO' : (isset($_COOKIE[$key]) ? 'CO' : '?') );
echo '<tr><td>'.$src.'</td><td>'.$key.'</td><td>'.print_r($value, true).'</td></tr>';
}
echo '</table>';
echo '</td></tr></table>';
unset($script);
}
- switch($Action)
- {
- case "m_login":
- // if($objSession->ValidSession())
- // $objSession->Logout();
- //echo $objSession->GetSessionKey()."<br>\n";
+switch($Action)
+{
+ case "m_login":
+ // if($objSession->ValidSession()) $objSession->Logout();
if ($objConfig->Get("CookieSessions") == 1 && $_COOKIE["CookiesTest"] != "1") {
$FormError["login"]["login_user"] = language("lu_cookies_error");
}
else {
$MissingCount = SetMissingDataErrors("login");
if($MissingCount==2)
{
$FormError["login"]["login_user"]= language("lu_ferror_loginboth");
unset($FormError["login"]["login_password"]);
}
if($MissingCount==0)
{
if($_POST["login_user"]=="root")
{
$FormError["login"]["login_user"]= language("lu_access_denied");
}
else
{
if ($objSession->Login($_POST["login_user"], md5($_POST["login_password"])) == FALSE)
{
$FormError["login"]["login_password"] = language("lu_incorrect_login");
}
else
{
if(!headers_sent() && ($_POST["usercookie"]==1 || $_GET["usercookie"]==1))
{
$c = $_POST["login_user"]."|";
$pw = $_POST["login_password"];
if(strlen($pw)<31)
$pw = md5($pw);
$c .= $pw;
setcookie("login",$c,time()+2592000);
}
$dest = $_POST["dest"];
if(!strlen($dest))
$dest = $_GET["dest"];
if(!strlen($dest))
$dest = $_POST["DestTemplate"];
if(!strlen($dest))
$dest = $_GET["DestTemplate"];
if(strlen($dest))
{
$var_list["t"] = $dest;
//header("Location: ../../index.php?env=" . BuildEnv());
}
// echo "DEST: ".$t; die();
}
}
}
}
break;
case "m_forgotpw":
$MissingCount = SetMissingDataErrors("forgotpw");
if($MissingCount==0)
{
$username = $_POST["username"];
$email = $_POST["email"];
$found = FALSE;
if(strlen($username))
{
$u = $objUsers->GetItemByField("Login",$username);
if(is_object($u))
$found = ($u->Get("Login")==$username && $u->Get("Status")==1) && strlen($u->Get("Password"));
}
else if(strlen($email))
{
$u = $objUsers->GetItemByField("Email",$email);
if(is_object($u))
$found = ($u->Get("Email")==$email && $u->Get("Status")==1) && strlen($u->Get("Password"));
}
if($found)
{
$newpw = makepassword();
$u->Set("Password",$newpw);
$u->Update();
$u->SendUserEventMail("USER.PSWD",$u->Get("PortalUserId"));
$u->SendAdminEventMail("USER.PSWD");
$u->Set("Password",md5($newpw));
$u->Update();
$u->Clean();
}
else
{
if(!strlen($username) && !strlen($email))
{
$FormError["forgotpw"]["username"] = language("lu_ferror_forgotpw_nodata");
$MissingCount++;
}
else
{
if(strlen($username))
$FormError["forgotpw"]["username"] = language("lu_ferror_unknown_username");
if(strlen($email))
$FormError["forgotpw"]["email"] = language("lu_ferror_unknown_email");
$MissingCount++;
}
if(strlen($_GET["error"]))
$var_list["t"] = $_GET["error"];
}
}
else
if(strlen($_GET["error"]))
$var_list["t"] = $_GET["error"];
break;
case "m_subscribe_confirm":
$t = "";
$SubscribeAddress = $_POST["subscribe_email"];
if(!ValidEmail($SubscribeAddress)&& strlen($SubscribeAddress))
{
$t = $_GET["Error"];
$SubscribeError = "lu_invalid_emailaddress";
}
else
{
if((int)$objConfig->Get("User_SubscriberGroup")>0)
{
$g = $objGroups->GetItem($objConfig->Get("User_SubscriberGroup"));
if(is_object($g))
{
$email = $_POST["subscribe_email"];
if(strlen($email)>0)
{
$u = $objUsers->GetItemByField("Email",$email);
if(is_object($u))
{
if($u->CheckBanned())
{
$t = $_GET["Error"];
$SubscribeError ="lu_subscribe_banned";
}
else
{
if($u->IsInGroup($g->Get("GroupId")))
{
$t = $_GET["Unsubscribe"];
}
else
$t = $_GET["Subscribe"];
}
}
else
$t = $_GET["Subscribe"];
}
else
{
$t = $_GET["Error"];
$SubscribeError ="lu_subscribe_no_address";
}
}
else
{
$t = $_GET["Error"];
$SubscribeError ="lu_subscribe_unknown_error";
}
}
}
if(strlen($t))
{
$var_list["t"] = $t;
$var_list_update["t"] = $t;
}
break;
case "m_subscribe":
//phpinfo(INFO_VARIABLES);
if($_POST["buttons"][0]==language("lu_button_yes"))
{
$SubscribeAddress = $_POST["subscribe_email"];
if(strlen($SubscribeAddress)>0)
{
if(ValidEmail($SubscribeAddress))
{
$GroupId = (int)$objConfig->Get("User_SubscriberGroup");
if ($GroupId)
{
$g = $objGroups->GetItem($GroupId);
$u = $objUsers->GetItemByField("Email",$SubscribeAddress);
if(is_object($u))
{
if(strtolower($u->Get("Email"))==strtolower($SubscribeAddress))
{
$bExists = TRUE;
}
else
$bExists = FALSE;
}
if($bExists)
{
$g->AddUser($u->Get("PortalUserId"));
}
else
{
$u = new clsPortalUser(NULL);
$u->Set("Email",$SubscribeAddress);
$u->Set("ip",$_SERVER['REMOTE_ADDR']);
$u->Set("CreatedOn",date("U"));
$u->Set("Status",1);
if(!$u->CheckBanned())
{
$u->Create();
$g->AddUser($u->Get("PortalUserId"),1);
}
else
$SubscribeResult = "lu_subscribe_banned";
}
$SubscribeResult = "lu_subscribe_success";
$u->SendUserEventMail("USER.SUBSCRIBE",$u->Get("PortalUserId"));
$u->SendAdminEventMail("USER.SUBSCRIBE");
if(strlen($_GET["Subscribe"])>0)
$var_list["t"] = $_GET["Subscribe"];
}
}
else
{
$SubscribeResult = "lu_invalid_emailaddress";
}
}
else
$SubscribeResult = "lu_subscribe_missing_address";
}
if(!strlen($SubscribeResult))
$SubscribeResult = "lu_subscribe_success";
break;
case "m_unsubscribe":
if($_POST["buttons"][0]==language("lu_button_yes"))
{
$MissingCount = SetMissingDataErrors("m_unsubscribe");
if($MissingCount==0)
{
$email = $_POST["subscribe_email"];
$u = $objUsers->GetItemByField("Email",$email);
if(is_object($u))
{
if(strtolower($u->Get("Email"))==strtolower($email))
{
$GroupId = (int)$objConfig->Get("User_SubscriberGroup");
if($u->PrimaryGroup()==$GroupId)
{
$u_gorup_list = $u->GetGroupList();
if (count($u_gorup_list) > 1) {
$u->RemoveFromGroup($GroupId);
}
else {
$u->RemoveFromAllGroups();
$u->Delete();
}
}
else
{
$u->RemoveFromGroup($GroupId);
}
}
}
if(strlen($_GET["Subscribe"])>0)
$var_list["t"] = $_GET["Subscribe"];
}
}
break;
case "m_logout":
// $objSession->Logout();
//unset($objSession);
//$objSession = new clsUserSession();
// $var_list_update["t"] = "index";
// setcookie("login","",time()-3600);
break;
case "m_register":
$MissingCount = SetMissingDataErrors("m_register");
if(!$objConfig->Get("User_Password_Auto"))
{
if(($_POST["password"] != $_POST["passwordverify"]) || !strlen($_POST["passwordverify"]))
{
$MissingCount++;
$FormError["m_register"]["passwordverify"] = language("lu_ferror_pswd_mismatch");
}
}
if(strlen($_POST["password"])>30)
{
// echo "VAR: ".$_POST["password"]; die();
$MissingCount++;
$FormError["m_register"]["password"] = language("lu_ferror_pswd_toolong");
}
if (strlen($_POST['password']) < $objConfig->Get("Min_Password"))
{
$MissingCount++;
$FormError["m_register"]["password"] = language("lu_ferror_pswd_tooshort");
}
$u = $objUsers->GetItemByField("Login",$_POST["username"]);
if(is_object($u))
{
if($u->Get("Login")==$_POST["username"])
{
$MissingCount++;
$FormError["m_register"]["username"] = language("lu_user_exists");
}
}
if (strlen($_POST['username']) < $objConfig->Get("Min_UserName"))
{
$MissingCount++;
$FormError["m_register"]["username"] = language("lu_ferror_username_tooshort");
}
if(!$MissingCount)
{
$CreatedOn = adodb_date("U");
$GroupId = $objConfig->Get("User_NewGroup");
$Status=0;
/* determine the status of new users */
switch ($objConfig->Get("User_Allow_New"))
{
case "1":
$Status=1;
break;
case "3":
$Status=2;
break;
}
/* set Destination template */
$var_list["t"] = strlen($_GET["dest"])? $_GET["dest"] : "index";
if($Status>0)
{
if($objConfig->Get("User_Password_Auto"))
{
$password = makepassword();
}
else
$password = $_POST["password"];
$_POST["dob"] = $_POST["dob_month"]."/".$_POST["dob_day"]."/".$_POST["dob_year"];
$dob = DateTimestamp($_POST["dob"],GetDateFormat());
$ip = $_SERVER['REMOTE_ADDR'];
$u = &$objUsers->Add_User($_POST["username"], md5($password), $_POST["email"], $CreatedOn, $_POST["firstname"], $_POST["lastname"], $Status, $_POST["phone"], $_POST["street"], $_POST["city"], $_POST["state"], $_POST["zip"], $_POST["country"], $dob, $ip, TRUE);
if(!is_object($u))
{
$RuleId=$u;
$r = $objBanList->GetItem($RuleId);
$err = $r->Get("ErrorTag");
if(strlen($err))
{
$FormError["m_register"][$r->Get("ItemField")] = language($err);
$MissingCount++;
}
}
else
{
$u->Set("Password",$password);
$u->Clean();
if($GroupId>0)
{
$g = $objGroups->GetItem($GroupId);
$g->AddUser($u->Get("PortalUserId"),1);
}
$custom = $_POST["custom"];
if(is_array($custom))
{
for($x=0;$x<count($custom);$x++)
{
$u->SetCustomField($custom[$x],$_POST[$custom[$x]]);
}
$u->SaveCustomFields();
}
if($Status==1)
{
if($objConfig->Get("User_Password_Auto"))
{
$u->SendUserEventMail("USER.VALIDATE",$u->Get("PortalUserId"));
$u->SendAdminEventMail("USER.VALIDATE");
}
else
{
$doLoginNow = true;
$u->SendUserEventMail("USER.ADD",$u->Get("PortalUserId"));
$u->SendAdminEventMail("USER.ADD");
}
}
else
{
$u->SendUserEventMail("USER.ADD.PENDING",$u->Get("PortalUserId"));
$u->SendAdminEventMail("USER.ADD.PENDING");
}
if ($doLoginNow)
$objSession->Login($_POST["username"], md5($password));
}
}
}
break;
case "m_add_friend":
$id = $_GET["UserId"];
$userid = $objSession->Get("PortalUserId");
if($id!=$userid)
{
$u =& $objUsers->GetItem($id);
$u->AddFavorite($userid);
}
break;
case "m_del_friend":
$id = $_GET["UserId"];
$userid = $objSession->Get("PortalUserId");
$u =& $objUsers->GetItem($id);
$u->DeleteFavorite();
break;
case "m_acctinfo":
// phpinfo(INFO_VARIABLES);
$MissingCount = SetMissingDataErrors("m_acctinfo");
$UserId = $_GET["UserId"];
if($UserId != $objSession->Get("PortalUserId"))
{
$MissingCount++;
$FormError["m_acctinfo"]["UserId"] = language("lu_ferror_m_profile_userid");
}
if(strlen($_POST["password"])>0)
{
if(($_POST["password"] != $_POST["passwordverify"]) || !strlen($_POST["passwordverify"]))
{
$MissingCount++;
$FormError["m_acctinfo"]["passwordverify"] = language("lu_ferror_pswd_mismatch");
}
if(strlen($_POST["password"])>30)
{
// echo "VAR: ".$_POST["password"]; die();
$MissingCount++;
$FormError["m_acctinfo"]["password"] = language("lu_ferror_pswd_toolong");
}
if (strlen($_POST['password']) < $objConfig->Get("Min_Password"))
{
$MissingCount++;
$FormError["m_acctinfo"]["password"] = language("lu_ferror_pswd_tooshort");
}
}
if(!$MissingCount)
{
/* save profile */
$u =& $objUsers->GetItem($UserId);
$status = $u->Get("Status");
$_POST["dob"] = $_POST["dob_month"]."/".$_POST["dob_day"]."/".$_POST["dob_year"];
$dob = DateTimestamp($_POST["dob"], GetDateFormat());
if(strlen($_POST["password"])>0)
{
$password = md5($_POST["password"]);
}
else
$password = "";
$objUsers->Edit_User($UserId, $_POST["username"], $password, $_POST["email"], 0,
$_POST["firstname"], $_POST["lastname"], $status, $_POST["phone"],
$_POST["street"], $_POST["city"], $_POST["state"], $_POST["zip"],
$_POST["country"], $dob);
}
break;
case "m_profile":
$userid = $objSession->Get("PortalUserId");
if($userid>0)
{
$u = $objUsers->GetItem($userid);
foreach($_POST as $field=>$value)
{
if(substr($field,0,3)=="pp_")
{
$objSession->SetPersistantVariable($field,$value);
}
}
}
break;
case "m_set_lang":
$lang = $_GET["lang"];
$LangId = 0;
if(strlen($lang))
{
$l = $objLanguages->GetItemByField("PackName",$lang);
if(is_object($l))
{
$LangId = $l->Get("LanguageId");
}
}
if($LangId)
{
if($objSession->Get("PortalUserId")>0)
{
$objSession->SetPersistantVariable("Language",$LangId);
}
$objSession->Set("Language",$LangId);
$objSession->Update();
$m_var_list_update["lang"] = $LangId;
$m_var_list["lang"] = $LangId;
}
break;
case "m_set_theme":
$id = $_POST["ThemeId"];
if(!is_numeric($id))
$id = $_GET["ThemeId"];
if($id)
{
$objSession->SetThemeName($id);
$m_var_list["t"] = "index";
$m_var_list_update["theme"] = $id;
$m_var_list["theme"] = $id;
unset($CurrentTheme);
}
break;
case "m_sort_cats":
$objSession->SetVariable("Category_Sortfield",$_POST["cat_field_sort"]);
$objSession->SetVariable("Category_Sortorder",$_POST["cat_sort_order"]);
break;
case "m_add_cat_confirm":
// phpinfo(INFO_VARIABLES);
$perm = 0;
$CategoryId=$objCatList->CurrentCategoryID();
if ($objSession->HasCatPermission("CATEGORY.ADD.PENDING"))
$perm = 2;
if ($objSession->HasCatPermission("CATEGORY.ADD"))
$perm = 1;
if ($perm == 0)
{
$MissingCount++;
$FormError["m_addcat"]["name"] = language("lu_ferror_no_access");
}
else
{
$MissingCount = SetMissingDataErrors("m_addcat");
if(is_array($_FILES))
{
foreach($_FILES as $field => $file)
{
$allowed = TRUE;
if(strlen($_POST["imagetypes"][$field]))
{
$types = explode(",",strtolower($_POST["imagetypes"][$field]));
if(is_array($types))
{
if(count($types)>0)
{
$path_parts = pathinfo($file["name"]);
$ext = $path_parts["extension"];
$allowed = in_array($ext,$types);
if(!$allowed)
{
$MissingCount++;
$FormError["m_addcat"][$field] = language("lu_ferror_wrongtype");
}
}
}
}
$maxsize = (int)$_POST["maxsize"][$field];
if($maxsize>0 && $allowed && $file["size"]>$maxsize)
{
$allowed = FALSE;
$MissingCount++;
$FormError["m_addcat"][$field] = language("lu_ferror_toolarge");
}
}
}
if($MissingCount==0)
{
$CreatedOn = date("U");
$name = $_POST["name"];
$desc = $_POST["description"];
$metadesc = $_POST["meta_description"];
$keywords = $_POST["meta_keywords"];
$parent = $objCatList->CurrentCategoryID();
$cat =& $objCatList->Add($parent, $name, inp_escape($desc,0), $CreatedOn,
0, $perm, 2, 2, 2, 0, $keywords,$metadesc);
$cat->UpdateCachedPath();
$cat->Update();
$cat->UpdateACL();
$objCatList->UpdateMissingCacheData();
if(strlen($_GET["Confirm"]))
{
$var_list["t"] = $_GET["Confirm"];
}
else
$var_list["t"] = $_GET["DestTemplate"];
}
}
break;
case "m_front_review_add":
if($objSession->InSpamControl($_POST["ItemId"]))
{
$StatusMessage["review"] = language("la_Review_AlreadyReviewed");
}
else
{
$objReviews = new clsItemReviewList();
$Status = $objConfig->Get("Review_DefaultStatus");
$CreatedOn = adodb_date("U");
$html = (int)$objConfig->Get("Review_Html");
$ReviewText = inp_escape($_POST["review_text"],$html);
$r = $objReviews->AddReview($CreatedOn,$ReviewText,$Status, $IPAddress,
0, $_POST["ItemId"], $_POST["ItemType"], $objSession->Get("PortalUserId"));
foreach($ItemTypes as $type=>$id)
{
if($id==$_POST["ItemType"])
{
$ValName = $type."_ReviewDelay_Value";
$IntName = $type."_ReviewDelay_Interval";
break;
}
}
if(strlen($ValName) && strlen($IntName))
{
$exp_secs = $objConfig->Get($ValName) * $objConfig->Get($IntName);
$objSession->AddToSpamControl($_POST["ItemId"],$exp_secs);
if(is_object($r))
{
if($Status)
{
$StatusMessage["review"] = language("la_Review_Added");
}
else
$StatusMessage["review"] = language("la_Review_Pending");
}
else
$StatusMessage["review"] = language("la_Review_Error");
}
else
$StatusMessage["error"] = language("la_ConfigError_Review");
}
break;
case "m_suggest_email":
$cutoff = time()+(int)$objConfig->Get("Suggest_MinInterval");
$email = $_POST["suggest_email"];
if (strlen($email))
{
if(ValidEmail($email))
{
$sql = "SELECT * FROM ".GetTablePrefix()."SuggestMail WHERE email='".inp_escape($email,0)."' and sent<".$cutoff;
$adodbConnection = GetADODBConnection();
$rs = $adodbConnection->Execute($sql);
$rs = false;
if($rs && !$rs->EOF)
{
if(strlen($_GET["Error"])>0)
$var_list["t"] = $_GET["Error"];
$suggest_result = "$email ".language("lu_already_suggested ")." ".LangDate($rs->fields["sent"]);
}
else
{
$Event =& $objMessageList->GetEmailEventObject("USER.SUGGEST");
if(is_object($Event))
{
if($Event->Get("Enabled")=="1")
{
$Event->Item = $this;
$Event->SendToAddress($email);
$sql = "INSERT INTO ".GetTablePrefix()."SuggestMail (email,sent) VALUES ('".inp_escape($email,0)."','".time()."')";
$rs = $adodbConnection->Execute($sql);
$suggest_result=language("lu_suggest_success")." ".$email;
}
}
$e =& $objMessageList->GetEmailEventObject("USER.SUGGEST",1);
if($e->Get("Enabled")==1)
$e->SendAdmin();
if(strlen($_GET["Confirm"])>0)
$var_list["t"] = $_GET["Confirm"];
}
}
else
{
if(strlen($_GET["Error"])>0)
$var_list["t"] = $_GET["Error"];
$suggest_result=language("lu_invalid_emailaddress");
}
}
else
{
if(strlen($_GET["Error"])>0)
$var_list["t"] = $_GET["Error"];
$suggest_result=language("lu_suggest_no_address");
}
break;
case "m_simple_search":
$keywords = $_POST["keywords"];
$type = $objItemTypes->GetTypeByName("Category");
$objSearch = new clsSearchResults("Category","clsCategory");
if(strlen($keywords))
{
$objSearchList = new clsSearchLogList();
$objSearchList->UpdateKeyword($keywords,0);
$objSearch->SetKeywords($keywords);
$objSearch->AddSimpleFields();
if(is_numeric($objConfig->Get("SearchRel_Pop_category")))
$objSearch->PctPop = ($objConfig->Get("SearchRel_Pop_category")/100);
if(is_numeric($objConfig->Get("SearchRel_Keyword_category")))
$objSearch->PctRelevance = ($objConfig->Get("SearchRel_Keyword_category")/100);
if(is_numeric($objConfig->Get("SearchRel_Rating_article")))
$objSearch->PctRating = ($objConfig->Get("SearchRel_Rating_category")/100);
//echo "Searching On $keywords<br>\n";
$objSearch->PerformSearch(1,$SortOrder,TRUE);
$SearchPerformed = TRUE;
//$objSearch->SetRelevence($type->Get("ItemType"), "CategoryId");
//echo "Finished Setting Category Relevence<br>\n";
}
else
{
if(strlen($_GET["Error"])>0)
$var_list["t"] = $_GET["Error"];
$MissingCount = SetMissingDataErrors("m_simplesearch");
$MissingCount++;
$FormError["m_simplesearch"]["keywords"] = language("lu_no_keyword");
}
break;
case "m_adv_search":
if( !is_object($objSearchConfig) ) $objSearchConfig = new clsSearchConfigList();
switch($_GET["type"])
{
case 1: /* category */
//echo "Searching for categories<br>";
$objAdvSearch = new clsAdvancedSearchResults("Category","clsCategory");
foreach($objSearchConfig->Items as $field)
{
$fld = $field->Get("FieldName");
$Verb = $_POST["verb"][$field->Get("FieldName")];
if(!strlen($Verb) && $field->Get("FieldType")=="boolean")
{
if($_POST["value"][$field->Get("FieldName")]!=-1)
{
$Value = $_POST["value"][$field->Get("FieldName")];
$Verb = "is";
}
}
else
{
$Value = $_POST["value"][$field->Get("FieldName")];
}
switch( $_POST["andor"][$field->Get("FieldName")])
{
case 1:
$Conjuction = "AND";
break;
case 2:
$Conjuction = "OR";
break;
default:
$Conjuction = "";
break;
}
if(strlen($Verb)>0 && $Verb!="any")
{
//echo "Adding CAT SearchField: [".$field->Get("TableName")."]; [".$field->Get("FieldName")."]; [$Verb]; [$Value]; [$Conjuction]<br>";
$objAdvSearch->AddAdvancedField($field->Get("TableName"),$field->Get("FieldName"),$Verb,$Value,$Conjuction);
}
}
$objAdvSearch->PerformSearch(1,NULL,TRUE);
break;
}
break;
case "m_id":
echo $Action.":".$DownloadId;
die();
break;
- case "m_simple_subsearch":
+ case "m_simple_subsearch":
$keywords = $_POST["keywords"];
$type = $objItemTypes->GetTypeByName("Category");
$objSearch = new clsSearchResults("Category","clsCategory");
if(strlen($keywords))
{
$objSearchList = new clsSearchLogList();
$objSearchList->UpdateKeyword($keywords,0);
$objSearch->SetKeywords($keywords);
$objSearch->AddSimpleFields();
if(is_numeric($objConfig->Get("SearchRel_Pop_category")))
$objSearch->PctPop = ($objConfig->Get("SearchRel_Pop_category")/100);
if(is_numeric($objConfig->Get("SearchRel_Keyword_category")))
$objSearch->PctRelevance = ($objConfig->Get("SearchRel_Keyword_category")/100);
if(is_numeric($objConfig->Get("SearchRel_Rating_article")))
$objSearch->PctRating = ($objConfig->Get("SearchRel_Rating_category")/100);
$SearchResultIdList = $objSearch->Result_IdList();
if(count($SearchResultIdList)>0)
{
$objSearch->PerformSearch(1,$SortOrder,TRUE,$SearchResultIdList);
//$objSearch->SetRelevence($type->Get("ItemType"), "CategoryId");
}
$SearchPerformed = TRUE;
- }
- else {
+ }
+ else {
$MissingCount = SetMissingDataErrors("m_simplesearch");
$MissingCount++;
$FormError["m_simplesearch"]["keywords"] = language("lu_no_keyword");
- }
- break;
- }
+ }
+ break;
+}
?>
Property changes on: trunk/kernel/frontaction.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.9
\ No newline at end of property
+1.10
\ No newline at end of property
Index: trunk/admin/users/adduser_groups.php
===================================================================
--- trunk/admin/users/adduser_groups.php (revision 287)
+++ trunk/admin/users/adduser_groups.php (revision 288)
@@ -1,323 +1,323 @@
<?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(!strlen($pathtoroot))
{
$path=dirname(realpath($_SERVER['SCRIPT_FILENAME']));
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(!strlen($pathtoroot))
$pathtoroot = ".".$pathchar;
}
else
{
$pathtoroot = ".".$pathchar;
}
}
$sub = substr($pathtoroot,strlen($pathchar)*-1);
if($sub!=$pathchar)
{
$pathtoroot = $pathtoroot.$pathchar;
}
//echo $pathtoroot;
require_once($pathtoroot."kernel/startup.php");
//admin only util
$rootURL="http://".ThisDomain().$objConfig->Get("Site_Path");
$admin = $objConfig->Get("AdminDirectory");
if(!strlen($admin))
$admin = "admin";
$localURL=$rootURL."kernel/";
$adminURL = $rootURL.$admin;
$imagesURL = $adminURL."/images";
//$pathtolocal = $pathtoroot."in-news/";
require_once ($pathtoroot.$admin."/include/elements.php");
require_once ($pathtoroot."kernel/admin/include/navmenu.php");
//require_once ($pathtolocal."admin/include/navmenu.php");
require_once($pathtoroot.$admin."/toolbar.php");
require_once($pathtoroot.$admin."/listview/listview.php");
$m = GetModuleArray();
foreach($m as $key=>$value)
{
$path = $pathtoroot. $value."admin/include/parser.php";
if(file_exists($path))
{
include_once($path);
}
}
unset($objEditItems);
$objEditItems = new clsUserManager();
$objEditItems->SourceTable = $objSession->GetEditTable("PortalUser");
$objEditItems->EnablePaging = FALSE;
//Multiedit init
$en = GetVar('en');
$objEditItems->Query_Item("SELECT * FROM ".$objEditItems->SourceTable);
$itemcount=$objEditItems->NumItems();
$c = $objEditItems->GetItemByIndex($en);
if($itemcount>1)
{
if ($en+1 == $itemcount)
$en_next = -1;
else
$en_next = $en+1;
if ($en == 0)
$en_prev = -1;
else
$en_prev = $en-1;
}
$action = "m_edit_user";
/* -------------------------------------- Section configuration ------------------------------------------- */
$section = 'in-portal:edituser_groups';
$sec = $objSections->GetSection($section);
$envar = "env=" . BuildEnv() . "&en=$en";
$SortFieldVar = "UserGroup_SortOrder";
$SortOrderVar = "UserGroup_SortOrder";
$DefaultSortField = "Name";
$PerPageVar = "Perpage_Groups";
$CurrentPageVar = "Page_Groups";
$CurrentFilterVar = "Group_View";
$ListForm = "edituser";
$CheckClass = "GroupChecks";
$title = prompt_language("la_Text_Editing")." ".prompt_language("la_Text_User")." '".$c->Get("Login")."' - ".prompt_language("la_tab_Groups");
/* ------------------------------------- Configure the toolbar ------------------------------------------- */
$objListToolBar = new clsToolBar();
$objListToolBar->Set("section",$section);
$objListToolBar->Set("load_menu_func","");
$objListToolBar->Set("CheckClass",$CheckClass);
$objListToolBar->Set("CheckForm",$ListForm);
$objListToolBar->Add("img_save", "la_Save","#","swap('img_save','toolbar/tool_select_f2.gif');", "swap('img_save', 'toolbar/tool_select.gif');","do_edit_save('save_edit_buttons','UserEditStatus','".$admin."/users/user_list.php',1);","tool_select.gif");
$objListToolBar->Add("img_cancel", "la_Cancel","#","swap('img_cancel','toolbar/tool_cancel_f2.gif');", "swap('img_cancel', 'toolbar/tool_cancel.gif');","do_edit_save('save_edit_buttons','UserEditStatus','".$admin."/users/user_list.php',2);","tool_cancel.gif");
if($itemcount == 1) $objListToolBar->Add("divider");
if ( isset($en_prev) || isset($en_next) )
{
$url = $RootUrl.$admin."/users/adduser_groups.php";
$StatusField = "UserEditStatus";
$form = "edituser";
MultiEditButtons($objListToolBar,$en_next,$en_prev,$form,$StatusField,$url,$sec->Get("OnClick"),'','la_PrevUser','la_NextUser');
$objListToolBar->Add("divider");
}
$listImages = array();
$objListToolBar->Add("new_group", "la_ToolTip_AddToGroup","","swap('new_group','toolbar/tool_usertogroup_f2.gif');",
"swap('new_group', 'toolbar/tool_usertogroup.gif');",
"OpenGroupSelector('$envar&source=adduser_groups&UserId=".$c->Get("PortalUserId")."&destform=group&destfield=grouplist');",
"tool_usertogroup.gif");
$objListToolBar->Add("user_del","la_ToolTip_DeleteFromGroup","#", "if (GroupChecks.itemChecked()) swap('user_del','toolbar/tool_delete_f2.gif');",
"if (GroupChecks.itemChecked()) swap('user_del', 'toolbar/tool_delete.gif');","if (GroupChecks.itemChecked()) GroupChecks.check_submit('adduser_groups', 'm_user_removegroup');",
"tool_delete.gif",FALSE,TRUE);
$listImages[] = "GroupChecks.addImage('user_del','$imagesURL/toolbar/tool_delete.gif','$imagesURL/toolbar/tool_delete_f3.gif',1); ";
$objListToolBar->Add("divider");
$objListToolBar->Add("user_print", "la_ToolTip_Print","#","swap('user_print','toolbar/tool_print_f2.gif');",
"swap('user_print', 'toolbar/tool_print.gif');","window.print();","tool_print.gif");
$objListToolBar->Add("viewmenubutton", "la_ToolTip_View","#","swap('viewmenubutton','toolbar/tool_view_f2.gif'); ",
"swap('viewmenubutton', 'toolbar/tool_view.gif');",
"ShowViewMenu();","tool_view.gif");
$objListToolBar->AddToInitScript($listImages);
$order = $objConfig->Get($SortOrderVar);
$GroupList = $c->GetGroupList();
$objGroups->Clear();
/* ----------------------------------------- Set the View Filter ---------------------------------------- */
/* bit place holders for category view menu */
$Bit_Pending=4;
$Bit_Disabled=2;
$Bit_Valid=1;
$Bit_All = 7;
$FilterLabels = array();
$FilterLabels[0] = admin_language("la_Text_Enabled");
$FilterLabels[1] = admin_language("la_Text_Disabled");
$FilterLabels[2] = admin_language("la_Text_Pending");
/* determine current view menu settings */
$GroupView = $objConfig->Get($CurrentFilterVar);
if(!is_numeric($GroupView))
{
$GroupView = $Bit_All; //Set all bits ON
$GroupFilter = "";
}
else
{
if($GroupView & $Bit_Valid)
$Status[] = 1;
if($GroupView & $Bit_Disabled)
$Status[] = 0;
if($GroupView & $Bit_Pending)
$Status[] = 2;
if(count($Status)>0)
{
$GroupFilter = "Status IN (".implode(",",$Status).")";
}
else
$GroupFilter = "Status = -1";
}
$order = $objConfig->Get($SortOrderVar);
$SearchWords = $objSession->GetVariable("GroupSearchWord");
if(strlen($SearchWords))
{
- $where = " AND Personal=0 AND ". $objGroups->AdminSearchWhereClause($SearchWords);
+ $where = " AND ". $objGroups->AdminSearchWhereClause($SearchWords);
}
else
- $where = " AND Personal=0 ";
+ $where = '';
if(strlen($GroupFilter))
$where .= " AND $GroupFilter ";
/* ------------------------------------ Build the SQL statement to populate the list ---------------------------*/
$orderBy = trim($objConfig->Get($SortFieldVar)." ".$order);
if(strlen($orderBy))
$orderBy = " ORDER BY ".$orderBy;
$sql = "SELECT g.GroupId as GroupId, g.name as GroupName, count(u.PortalUserId) as UserCount FROM ".GetTablePrefix()."PortalGroup as g ";
$sql .="INNER JOIN ".GetTablePrefix()."UserGroup as u ON g.GroupId=u.GroupId WHERE u.PortalUserId=".$c->Get("PortalUserId")." $where GROUP BY g.name".$orderBy;
if($objSession->HasSystemPermission("DEBUG.LIST"))
echo htmlentities($sql,ENT_NOQUOTES)."<br>\n";
-
+//echo "SQL: $sql<br>";
$objGroups->Query_Item($sql);
/* ---------------------------------------- Configure the list view ---------------------------------------- */
$objListView = new clsListView($objListToolBar,$objGroups);
$objListView->IdField = "GroupId";
$objListView->ColumnHeaders->Add("GroupName", admin_language("la_prompt_GroupName"),1,0,$order,"width=\"50%\"",$SortFieldVar,$SortOrderVar,"GroupName");
$objListView->ColumnHeaders->Add("UserCount",admin_language("la_prompt_UserCount"),1,0,$order,"width=\"50%\"",$SortFieldVar,$SortOrderVar,"UserCount");
$objListView->ColumnHeaders->SetSort($objConfig->Get("Group_SortField"),$order);
$objListView->PrintToolBar = FALSE;
$objListView->SearchBar = TRUE;
$objListView->SearchKeywords = $SearchWords;
$objListView->SearchAction="m_group_search";
$objListView->CurrentPageVar = $CurrentPageVar;
$objListView->PerPageVar = $PerPageVar;
$objListView->CheckboxName = "itemlist[]";
$objListView->TotalItemCount = $itemcount;
$objListView->ConfigureViewMenu($SortFieldVar,$SortOrderVar,$DefaultSortField,
$CurrentFilterVar,$GroupView,$Bit_All);
foreach($FilterLabels as $Bit=>$Label)
{
$objListView->AddViewMenuFilter($Label,$Bit);
}
$objListToolBar->AddToInitScript("fwLoadMenus();");
$h = "\n\n<SCRIPT Language=\"JavaScript1.2\">\n".$objListView->GetViewMenu($imagesURL)."\n</SCRIPT>\n";
int_header($objListToolBar,NULL, $title,NULL,$h);
?>
<FORM method="POST" ACTION="" NAME="edituser" ID="edituser">
<?php
$objListView->PageLinks = $objListView->PrintPageLinks(); /* call this before we slice! */
$objListView->SliceItems();
print $objListView->PrintList();
?>
<input type="hidden" name="Action" value="">
<INPUT TYPE="HIDDEN" NAME="UserId" VALUE="<?php echo $c->Get("PortalUserId"); ?>">
</FORM>
<FORM NAME="save_edit_buttons" ID="save_edit_buttons" method="POST" ACTION="">
<tr <?php int_table_color(); ?>>
<td colspan="5">
<input type=hidden NAME="Action" VALUE="save_user_edit">
<input type="hidden" name="UserEditStatus" VALUE="0">
</td>
</tr>
</FORM>
<FORM NAME="group" ID="group" METHOD="POST" ACTION="<?php echo $_SERVER["PHP_SELF"]."?".$envar; ?>">
<INPUT TYPE="hidden" NAME="grouplist">
<input TYPE="hidden" NAME="Action" VALUE="m_user_addto_group">
<INPUT TYPE="HIDDEN" NAME="UserId" VALUE="<?php echo $c->Get("PortalUserId"); ?>">
</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>
<FORM ID="ListSearchForm" NAME="ListSearchForm" method="POST" action="<?php echo $_SERVER["PHP_SELF"]."?env=".BuildEnv(); ?>">
<INPUT TYPE="HIDDEN" NAME="Action" VALUE="">
<INPUT TYPE="HIDDEN" NAME="list_search">
</FORM>
<script src="<?php echo $adminURL; ?>/listview/listview.js"></script>
<script>
initSelectiorContainers();
<?php echo $objListToolBar->Get("CheckClass").".setImages();"; ?>
</script>
<!-- END CODE-->
<?php int_footer(); ?>
Property changes on: trunk/admin/users/adduser_groups.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.2
\ No newline at end of property
+1.3
\ No newline at end of property
Index: trunk/admin/include/elements.php
===================================================================
--- trunk/admin/include/elements.php (revision 287)
+++ trunk/admin/include/elements.php (revision 288)
@@ -1,607 +1,612 @@
<?php
##############################################################
##In-portal :: Administration Interfaces :: Common Elements ##
##############################################################
## 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($is_install) ) $is_install = false;
if(!$is_install)
{
if (!admin_login())
{
if(!headers_sent()) {
setcookie("sid"," ",time()-3600);
echo "Test";
}
$objSession->Logout();
header("Location: ".$adminURL."/login.php");
die();
//require_once($pathtoroot."admin/login.php");
}
}
global $admin,$pathtoroot, $objConfig;
if(!strlen($admin))
{
$admin = $objConfig->Get("AdminDirectory");
if(!strlen($admin))
{
$admin = "admin";
}
}
require_once($pathtoroot.$admin."/include/sections.php");
$envar = "env=" . BuildEnv();
/* this function loads the javascript for each module's toolbar */
function load_module_javascript($sectionname)
{
global $adminURL, $pathtoroot;
echo "<SCRIPT LANGUAGE=JavaScript1.2 src=\"".$adminURL."/browse/fw_menu.js\"></SCRIPT>\n";
echo "<SCRIPT LANGUAGE=JavaScript1.2 src=\"".$adminURL."/include/tabs.js\"></SCRIPT>\n";
echo "<script language=\"JavaScript1.2\" src=\"$adminURL/include/checkarray.js\"></script>\n";
global $objConfig, $ItemTabs;
$m = GetModuleArray("admin");
echo "<!-- ".count($m)."-->";
foreach($m as $key=>$value)
{
$path = $pathtoroot. $value."admin/include/toolbar/".$sectionname.".php";
if(file_exists($path))
{
echo "\n<!-- $path -->\n";
include_once($path);
}
else
echo "\n<!-- $path not found -->\n";
}
}
function load_module_styles()
{
global $objConfig, $ItemTabs,$rootURL,$pathtoroot;
$m = GetModuleArray("admin");
echo "<!-- module styles (".count($m).")-->";
foreach($m as $key=>$value)
{
$path = $pathtoroot.$value."admin/include/style.css";
if(file_exists($path))
{
$inc = $rootURL.$value."admin/include/style.css";
print "<link rel=\"stylesheet\" type=\"text/css\" href=\"$inc\">\n";
}
}
}
//***********************************
//Page Header
function int_header($toolbar=NULL,$NavBarText=NULL,$ExtraTitle=NULL,$onLoad=NULL, $ExtraHead=NULL)
{
global $pathtoroot;
global $pathtolocal;
global $section;
global $objSections;
global $rootURL;
global $localURL;
global $adminURL;
global $envar;
global $admin;
global $metatag;
$style_sheet_global = $adminURL."/include/style.css";
$style_sheet_local = $localURL."admin/include/style.css";
$ExtraTitle = htmlentities($ExtraTitle);
if (is_object($toolbar))
{
if(file_exists($pathtolocal."admin/include/toolbar.php"))
require_once ($pathtolocal."admin/include/toolbar.php");
//Aray of the preloaded elems
//$int_toolbar_preload = array();
print "<html><head><title>In-portal</title>\n";
if(strlen($metatag))
{
print $metatag."\n";
}
else
{
print "<meta http-equiv=\"content-type\" content=\"text/html;charset=iso-8859-1\">\n";
print "<meta http-equiv=\"Pragma\" content=\"no-cache\">\n";
}
print "<link rel=\"stylesheet\" type=\"text/css\" href=\"$style_sheet_global\">\n";
load_module_styles();
require_once($pathtoroot.$admin."/include/mainscript.php");
//require_once($pathtolocal."admin/include/script.js");
print $ExtraHead;
$sectionname = explode(":", $section);
$sectionname = $sectionname[sizeof($sectionname)-1];
load_module_javascript($sectionname);
if(is_object($toolbar))
print $toolbar->GetInitScript();
print "</head><body topmargin=\"0\" leftmargin=\"8\" marginheight=\"8\" marginwidth=\"8\" bgcolor=\"#FFFFFF\"";
//*** Preload toolbar images
if(strlen($onLoad))
{
print $onLoad;
}
else
print " ONLOAD=\"clear_list_checkboxes();\"";
//*** Preload toolbar images
if(is_object($toolbar))
{
if (strlen($toolbar->Get("CheckClass")))
{
print $toolbar->onLoadString().">";
}
else
print " >";
$menufunc = $toolbar->Get("load_menu_func");
if (strlen($menufunc))
{
print "<script language=\"JavaScript1.2\">$menufunc</script>";
}
}
else
print " >";
}
else
{
print "<html><head><title>In-Portal </title>";
print "<meta http-equiv=\"content-type\" content=\"text/html;charset=iso-8859-1\">";
print "<meta http-equiv=\"Pragma\" content=\"no-cache\">";
print "<link rel=\"stylesheet\" type=\"text/css\" href=\"$style_sheet_global\">";
load_module_styles();
require_once ($pathtoroot.$admin."/include/mainscript.php");
//require_once ($pathtolocal."admin/include/script.js");
$sectionname = explode(":", $section);
$sectionname = $sectionname[sizeof($sectionname)-1];
load_module_javascript($sectionname);
print "</head><body topmargin=\"0\" leftmargin=\"8\" marginheight=\"8\" marginwidth=\"8\" bgcolor=\"#FFFFFF\">";
}
if(strlen($section)>0)
{
$objSections->SetCurrentSection($section);
$sec = $objSections->GetCurrentSection();
if ($sec->Get("notitle") != 1) print $objSections->page_title();
print $objSections->page_tabs($envar);
if ($sec->Get("nonavbar") != 1) //Section Navigatior
print $objSections->section_header($envar,$NavBarText,$ExtraTitle);
//Toolbar if appropriate
if ( isset($sections[$section]) && ($sections[$section]['toolbar']==1) || ( is_object($toolbar) ) )
print $toolbar->Build();
}
}//Page Header
// HELP Page Header
function int_help_header()
{
global $pathtoroot;
global $pathtolocal;
global $section;
global $objSections;
global $rootURL;
global $localURL;
global $adminURL;
global $envar;
global $admin;
global $metatag;
$style_sheet_global = $adminURL."/include/style.css";
$style_sheet_local = $localURL."admin/include/style.css";
$ExtraTitle = htmlentities($ExtraTitle);
// TOOLBAR:
print "<html><head><title>In-Portal - Help</title>";
print "<meta http-equiv=\"content-type\" content=\"text/html;charset=iso-8859-1\">";
print "<meta http-equiv=\"Pragma\" content=\"no-cache\">";
print "<link rel=\"stylesheet\" type=\"text/css\" href=\"$style_sheet_global\">";
load_module_styles();
require_once ($pathtoroot.$admin."/include/mainscript.php");
print "</head><body topmargin=\"0\" leftmargin=\"8\" marginheight=\"8\" marginwidth=\"8\" bgcolor=\"#FFFFFF\">";
if(strlen($section)>0)
{
$objSections->SetCurrentSection($section);
$sec = $objSections->GetCurrentSection();
if ($sec->Get("notitle") != 1) print $objSections->page_title();
if ($sec->Get("nonavbar") != 1) //Section Navigatior
print $objSections->section_header($envar,$NavBarText,$ExtraTitle, true);
}
}// HELP Page Header
function int_SectionHeader($toolbar=NULL,$onLoad=NULL,$NavBarText=NULL,$ExtraTitle=NULL)
{
global $pathtoroot;
global $pathtolocal;
global $section, $sections;
global $objSections;
global $rootURL;
global $adminURL,$admin;
global $localURL;
global $envar;
global $b_topmargin;
if (!isset($b_topmargin))
$b_topmargin = 8;
$sectionname = explode(":", $section);
$sectionname = $sectionname[sizeof($sectionname)-1];
load_module_javascript($sectionname);
if(is_object($toolbar))
print $toolbar->GetInitScript();
print "</head><body topmargin=\"$b_topmargin\" leftmargin=\"8\" marginheight=\"$b_topmargin\" marginwidth=\"8\" bgcolor=\"#FFFFFF\"";
//*** Preload toolbar images
if(strlen($onLoad))
{
print $onLoad;
}
else
print " onload=\"if (clear_checkboxes) clear_checkboxes();\"";
print ">";
global $b_header_addon;
if (isset($b_header_addon)) echo $b_header_addon;
if(strlen($section)>0)
{
$objSections->SetCurrentSection($section);
$sec = $objSections->GetCurrentSection();
if ($sec->Get("notitle")!=1)
print $objSections->page_title();
print $objSections->page_tabs($envar);
//Section Navigatior
if ($sec->Get("nonavbar")!=1)
{
if (is_null($ExtraTitle))
$ExtraTitle = "";
print $objSections->section_header($envar,$NavBarText,$ExtraTitle);
}
//Toolbar if appropriate
if( isset($sections[$section]) )
if($sections[$section]['toolbar'] == 1 || (is_object($toolbar)) )
print $toolbar->Build();
}
}//Section Page Header
//***********************************
//SubSection Title
function int_subsection_title($caption)
{
int_table_color(1);
print <<<END
<!-- Subsection Title -->
<tr class="subsectiontitle">
<td colspan="5">$caption</td>
</tr>
END;
}
function int_subsection_title_install($caption)
{
int_table_color(1);
print <<<END
<!-- Subsection Title -->
<tr class="subsectiontitle">
<td colspan="3">$caption</td>
</tr>
END;
}
function int_subsection_title_ret($caption)
{
int_table_color_ret(1);
$o = "<!-- Subsection Title --><tr class=\"subsectiontitle\"><td colspan=\"5\">$caption</td></tr>";
return $o;
}
//SubSection Title
//***********************************
//Table Alternating colors
-function int_table_color($reset_color=0)
+function int_table_color($reset_color=0, $return_result = false)
{
static $colorset;
if($reset_color)
{ $colorset="table_color2";
return;
}
if ($colorset == "table_color1")
$colorset = "table_color2";
else
$colorset = "table_color1";
- print "class=\"".$colorset."\"";
+ $ret = "class=\"".$colorset."\"";
+ if($return_result)
+ return $ret;
+ else
+ print $ret;
+
}//Table Alternating colors
//Table Alternating colors with return
function int_table_color_ret($reset_color=0)
{
static $colorset;
if($reset_color)
{ $colorset="table_color2";
return;
}
if ($colorset == "table_color1")
$colorset = "table_color2";
else
$colorset = "table_color1";
return "class=\"".$colorset."\"";
}//Table Alternating colors
//***********************************
//Hint
function int_hint($caption)
{
global $imagesURL;
print <<<END
<table width="100%" border="0" cellspacing="0" cellpadding="2">
<tr>
<td>
<span class="hint"><img src="$imagesURL/smicon7.gif" width="14" height="14" align="absmiddle">$caption</span>
<td>
</tr>
</table>
END;
}//Hint
function int_hint_red($caption)
{
global $imagesURL;
print <<<END
<table width="100%" border="0" cellspacing="0" cellpadding="2">
<tr>
<td>
<span class="hint_red">$caption</span>
<td>
</tr>
</table>
END;
}//Hint
//***********************************
//Navigation String
function int_nav($caption)
{
global $pathtoroot;
global $imagespath;
print <<<END
<table width="100%" border="0" cellspacing="0" cellpadding="2" bgcolor="#f0f0f0">
<tr>
<td><b class="text"><span class="navbar"><a class="navbar" href="">$caption</a></span></b></td>
</tr>
</table>
END;
}//Navigation String
//***********************************
//Print Out Images
function int_img($img)
{
global $images;
global $pathtoroot;
global $imagesURL;
$src = $imagesURL."/".$images[$img]['file'];
$alt = $images[$img]['alt'];
$width = $images[$img]['width'];
$height = $images[$img]['height'];
$name = $img;
//Set ID if needed
if ($img == 'img:tool:view')
$id = "ID=\"viewbutton\"";
print "<img alt=\"$alt\" name=\"$name\" src=\"$src\" width=\"$width\" height=\"$height\" $id border=\"0\" align=\"absmiddle\">";
}//Print Out Images
//***********************************
//Page Footer
function int_footer()
{
global $objSession;
if($objSession->HasSystemPermission("DEBUG.INFO"))
{
//phpinfo();
}
print <<<END
</body>
</html>
END;
}//Page Footer
function HomeEnv()
{
global $m_var_list_update;
$m_var_list_update["cat"]=0;
return BuildEnv();
}
function UpEnv()
{
global $m_var_list_update,$objCatList;
$current = $objCatList->CurrentCat();
$parent = $current->Get("ParentId");
$m_var_list_update["cat"]=$parent;
return BuildEnv();
}
function ModuleInclude($file)
{
global $pathtoroot;
$m = GetModuleArray();
foreach($m as $key=>$value)
{
$path = $pathtoroot.$value.$file;
if(file_exists($path))
{
echo "<!-- $path -->";
@include_once($path);
}
}
}
function MultiEditButtons(&$ToolBar,$next,$prev,$Form,$StatusField, $url,$onClick, $ExtraVar="", $prev_phrase = 'Phrase Not Passed', $next_phrase = 'Phrase Not Passed')
{
global $adminURL;
$ToolBar->Add("divider");
if($prev>-1)
{
$MouseOver="swap('moveleft','toolbar/tool_prev_f2.gif');";
$MouseOut="swap('moveleft', 'toolbar/tool_prev.gif');";
$var="env=".BuildEnv()."&en=$prev&lpn=".GetVar('lpn');
if (strlen($ExtraVar))
$var.= $ExtraVar;
if ($onClick != 'LangSubmitMove') {
$link = "javascript:edit_submit('$Form','$StatusField','$url',0,'$var');";
}
else {
$link = "javascript:$onClick('$url', '$prev')";
}
$ToolBar->Add("moveleft",$prev_phrase,$link,$MouseOver,$MouseOut,"","toolbar/tool_prev.gif");
}
else
{
$MouseOver="";
$MouseOut="";
//$onClick="";
$link="#";
$ToolBar->Add("moveleft",$prev_phrase,"#","","","","toolbar/tool_prev_f3.gif");
}
if($next>-1)
{
$MouseOver="swap('moveright','toolbar/tool_next_f2.gif');";
$MouseOut="swap('moveright', 'toolbar/tool_next.gif');";
$var="env=".BuildEnv()."&en=$next".( isset($_REQUEST['lpn']) ? '&lpn='.$_REQUEST['lpn'] : '');
if (strlen($ExtraVar))
$var.= $ExtraVar;
if ($onClick != 'LangSubmitMove') {
$link = "javascript:edit_submit('$Form','$StatusField','$url',0,'$var');";
}
else {
$link = "javascript:$onClick('$url', '$next')";
}
$ToolBar->Add("moveright",$next_phrase,$link,$MouseOver,$MouseOut,"","toolbar/tool_next.gif");
}
else
{
$ToolBar->Add("moveright",$next_phrase,"#","","","","toolbar/tool_next_f3.gif");
}
}
function InsertButtons(&$ToolBar, $Buttons = Array(), $params = Array() )
{
foreach($Buttons as $button)
switch($button)
{
case 'save':
$ToolBar->Add( "img_save", "la_Save", "#",
"swap('img_save','toolbar/tool_select_f2.gif');",
"swap('img_save', 'toolbar/tool_select.gif');",
"edit_submit('".$params['form']."','".$params['status_field']."','".$params['url']."',1,'&lpn=".$_REQUEST['lpn']."');","tool_select.gif");
break;
case 'cancel':
$ToolBar->Add( "img_cancel", "la_Cancel", "#",
"swap('img_cancel','toolbar/tool_cancel_f2.gif');",
"swap('img_cancel', 'toolbar/tool_cancel.gif');",
"edit_submit('".$params['form']."','".$params['status_field']."','".$params['url']."',2,'&lpn=".$_REQUEST['lpn']."');","tool_cancel.gif");
break;
case 'edit':
break;
case 'delete':
break;
}
}
function GetTitle($item_phrase, $tab_phrase, $id)
{
// gets correct caption for editing windows with tabs
//echo "In: $item_phrase, $tab_phrase, $id";
$is_new = ($_REQUEST['new'] == 1) ? 1 : 0;
$text = $is_new ? 'la_Text_Adding' : 'la_Text_Editing';
$text = admin_language($text).' '.admin_language($item_phrase);
if($is_new == 0) $text .= ' #'.$id;
$text .= ' - '.admin_language($tab_phrase);
return $text;
}
function MarkFields($form_name)
{
// mark specified form fields as required
?> <script language="JavaScript">MarkAsRequired(document.getElementById("<?php echo $form_name; ?>"));</script> <?php
}
?>
Property changes on: trunk/admin/include/elements.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.3
\ No newline at end of property
+1.4
\ No newline at end of property
Index: trunk/admin/import/inlinkimport2.php
===================================================================
--- trunk/admin/import/inlinkimport2.php (revision 287)
+++ trunk/admin/import/inlinkimport2.php (revision 288)
@@ -1,153 +1,135 @@
<?php
if(!strlen($pathtoroot))
{
$path=dirname(realpath($_SERVER['SCRIPT_FILENAME']));
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(!strlen($pathtoroot))
$pathtoroot = ".".$pathchar;
}
else
{
$pathtoroot = ".".$pathchar;
}
}
$sub = substr($pathtoroot,strlen($pathchar)*-1);
if($sub!=$pathchar)
{
$pathtoroot = $pathtoroot.$pathchar;
}
//echo $pathtoroot;
//echo $pathtoroot;
require_once($pathtoroot."kernel/startup.php");
$rootURL="http://".ThisDomain().$objConfig->Get("Site_Path");
$admin = $objConfig->Get("AdminDirectory");
if(!strlen($admin))
$admin = "admin";
$localURL=$rootURL."kernel/";
$adminURL=$rootURL.$admin;
$imagesURL = $adminURL."/images";
//admin only util
$pathtolocal = $pathtoroot."kernel/";
require_once ($pathtoroot.$admin."/include/elements.php");
require_once ($pathtoroot."kernel/admin/include/navmenu.php");
require_once ($pathtolocal."admin/include/navmenu.php");
require_once($pathtoroot.$admin."/toolbar.php");
-//Set Section
-$section = "in-portal:inlink_inport";
-//Set Environment Variable
-$envar = "env=" . BuildEnv();
-
-$formaction = $adminURL."/import/import.php?".$envar;
- $sec = $objSections->GetSection($section);
- $objCatToolBar = new clsToolBar();
-
-if (true)
-{
+ //Set Section
+ $section = "in-portal:inlink_inport";
- if(true)
- {
- $MouseOver="swap('moveleft','toolbar/tool_prev_f2.gif');";
- $MouseOut="swap('moveleft', 'toolbar/tool_prev.gif');";
-
- $var="?env=".BuildEnv()."&en=$en_prev";
- $link=$adminURL."/import/inlinkimport1.php".$var;
-
- $objCatToolBar->Add("moveleft",admin_language("la_ToolTip_Previous")." ".admin_language("la_Text_Step"),$link,$MouseOver,$MouseOut,"","tool_prev.gif");
- }
-
- if(true)
- {
- $MouseOver="if (document.inlinkimport2.choose[0].checked) swap('moveright','toolbar/tool_next_f2.gif');";
- $MouseOut="if (document.inlinkimport2.choose[0].checked) swap('moveright', 'toolbar/tool_next.gif');";
-
+ //Set Environment Variable
+ $envar = "env=" . BuildEnv();
+ $var = '?env='.BuildEnv();
+
+ $sec = $objSections->GetSection($section);
+ $objCatToolBar = new clsToolBar();
+
+ // Previous Button
+ $MouseOver="swap('moveleft','toolbar/tool_prev_f2.gif');";
+ $MouseOut="swap('moveleft', 'toolbar/tool_prev.gif');";
+ $link = $adminURL.'/import/inlinkimport1.php'.$var;
+ $objCatToolBar->Add('moveleft','la_ToolTip_PreviousStep', $link, $MouseOver, $MouseOut,'','tool_prev.gif');
+
+ // Next Button
+ $MouseOver = "if( ChoiseMade('import_form','choose') !== false ) swap('moveright','toolbar/tool_next_f2.gif');";
+ $MouseOut = "if( ChoiseMade('import_form','choose') !== false ) swap('moveright', 'toolbar/tool_next.gif');";
+
+ if($ro_perm)
+ {
+ $click_url = $adminURL."/import/inlinkimport1.php".$var;
+ $onClick = "if( ChoiseMade('import_form','choose') ) document.location= '$click_url'; ";
+ }
+ else
+ {
+ $click_url = $adminURL."/import/inlinkimport3.php".$var;
+ $onClick = "ImportRedirect('import_form', ChoiseMade('import_form','choose'), '$click_url');";
+ }
+ $objCatToolBar->Add("moveright",'la_ToolTip_NextStep','#',$MouseOver,$MouseOut,$onClick,"tool_next_f3.gif");
+
+ // header
+ $title = admin_language("la_performing_import")." - ".admin_language("la_Step")." 2";
+ int_header($objCatToolBar,NULL,$title);
- $var="?env=".BuildEnv()."&en=$en_next";
- $ro_perm = $objSession->HasSystemPermission("SYSTEM_ACCESS.READONLY");
- $script_name = $ro_perm ? 'inlinkimport1' : 'inlinkimport3';
- $link2=$adminURL."/import/".$script_name.".php".$var;
-
- $onClick="if (document.inlinkimport2.choose[0].checked) document.location= '$link2'; ";
-
- $link="#";
- $objCatToolBar->Add("moveright",admin_language("la_ToolTip_Next")." ".admin_language("la_Text_Step"),$link,$MouseOver,$MouseOut,$onClick,"tool_next_f3.gif");
- }
-
- $title = admin_language("la_performing_import")." - ".admin_language("la_Step")." 2";
-
- int_header($objCatToolBar,NULL,$title);
-}
?>
-
+<form name="import_form" id="import_form" method="post" action="<?php echo $click_url; ?>">
+ <input type="hidden" name="import_id" id="import_id" value="">
<table width="100%" border="0" cellspacing="0" cellpadding="4" class="tableborder">
-<form name="inlinkimport2" METHOD="POST" action="<?php echo $_SERVER["PHP_SELF"]."?".$envar; ?>">
-<?php int_subsection_title("Import Source"); ?>
- <TR <?php echo int_table_color(); ?>>
- <td >
- <span class=\"text\">
- Select the program you are importing the data from:
- </span>
- </td>
- </TR>
- <tr <?php echo int_table_color(); ?>>
- <td >
- <span class=\"small\">
- </span>
- <input type="radio" name="choose" id="ch1" value="1" onclick="swap('moveright', 'toolbar/tool_next.gif')"><span class=\"text\"><label for="ch1">Intechnic In-Link 2.x</label></span> <br />
- <input type="radio" name="choose" id="ch2" value="2" onclick="swap('moveright', 'toolbar/tool_next.gif')" disabled="true"><span class=\"text\"><label for="ch2">Gossamer Threads Links 2.x</label></span> <br />
- <input type="radio" name="choose" id="ch3" value="3" onclick="swap('moveright', 'toolbar/tool_next.gif')" disabled="true"><span class=\"text\"><label for="ch3">Gossamer Threads Links 2.x SQL version</label></span> <br />
- <input type="radio" name="choose" id="ch4" value="4" onclick="swap('moveright', 'toolbar/tool_next.gif')" disabled="true"><span class=\"text\"><label for="ch4">Sentrwaweb Index u 3.x</label></span> <br />
-
- </td>
- </tr>
- <tr>
- <td>
- </td>
- </tr>
-</FORM>
-</TABLE>
+
+ <?php int_subsection_title("Import Source"); ?>
+ <tr <?php echo int_table_color(); ?>>
+ <td><span class="text">Select the program you are importing the data from:</span></td>
+ </tr>
+ <tr <?php echo int_table_color(); ?>>
+ <td>
+ <?php
+ foreach($import_scripts as $id => $iscript)
+ echo '<input type="radio" name="choose" id="ch'.$id.'" value="'.$id.'" onclick="swap(\'moveright\', \'toolbar/tool_next.gif\')"'.(!$iscript['enabled'] ? ' disabled="true"' : '').'><span class="text"><label for="ch'.$id.'">'.$iscript['label'].'</label></span><br />'."\n";
+ ?>
+ </td>
+ </tr>
+</table>
+</form>
<?php
int_footer();
?>
\ No newline at end of file
Property changes on: trunk/admin/import/inlinkimport2.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.2
\ No newline at end of property
+1.3
\ No newline at end of property
Index: trunk/admin/import/inlinkimport3.php
===================================================================
--- trunk/admin/import/inlinkimport3.php (revision 287)
+++ trunk/admin/import/inlinkimport3.php (revision 288)
@@ -1,177 +1,155 @@
<?php
if(!strlen($pathtoroot))
{
$path=dirname(realpath($_SERVER['SCRIPT_FILENAME']));
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(!strlen($pathtoroot))
$pathtoroot = ".".$pathchar;
}
else
{
$pathtoroot = ".".$pathchar;
}
}
$sub = substr($pathtoroot,strlen($pathchar)*-1);
if($sub!=$pathchar)
{
$pathtoroot = $pathtoroot.$pathchar;
}
//echo $pathtoroot;
//echo $pathtoroot;
require_once($pathtoroot."kernel/startup.php");
$rootURL="http://".ThisDomain().$objConfig->Get("Site_Path");
$admin = $objConfig->Get("AdminDirectory");
if(!strlen($admin))
$admin = "admin";
$localURL=$rootURL."kernel/";
$adminURL=$rootURL.$admin;
$imagesURL = $adminURL."/images";
//admin only util
$pathtolocal = $pathtoroot."kernel/";
require_once ($pathtoroot.$admin."/include/elements.php");
require_once ($pathtoroot."kernel/admin/include/navmenu.php");
require_once ($pathtolocal."admin/include/navmenu.php");
require_once($pathtoroot.$admin."/toolbar.php");
-//Set Section
-$section = "in-portal:inlink_inport";
-//Set Environment Variable
-$envar = "env=" . BuildEnv();
-
-$formaction = $adminURL."/import/import.php?".$envar;
- $sec = $objSections->GetSection($section);
- $objCatToolBar = new clsToolBar();
+ //Set Section
+ $section = "in-portal:inlink_inport";
-if (true)
-{
+ //Set Environment Variable
+ $envar = "env=" . BuildEnv();
+ $var = "?env=".BuildEnv();
- if(true)
- {
- $MouseOver="swap('moveleft','toolbar/tool_prev_f2.gif');";
- $MouseOut="swap('moveleft', 'toolbar/tool_prev.gif');";
- $var="?env=".BuildEnv()."&en=$en_prev";
- $link=$adminURL."/import/inlinkimport2.php".$var;
-
- $objCatToolBar->Add("moveleft",admin_language("la_ToolTip_Previous")." ".admin_language("la_Text_Step"),$link,$MouseOver,$MouseOut,"","tool_prev.gif");
- }
-
- if(true)
- {
- $MouseOver="swap('moveright','toolbar/tool_next_f2.gif');";
- $MouseOut="swap('moveright', 'toolbar/tool_next.gif');";
-
-
- $var="?env=".BuildEnv()."&en=$en_next";
- $link2=$adminURL."/import/inlinkimport4.php".$var;
-
- $onClick="document.inlinkimport3.submit(); ";
-
- $link="#";
- $objCatToolBar->Add("moveright",admin_language("la_ToolTip_Next")." ".admin_language("la_Text_Step"),$link,$MouseOver,$MouseOut,$onClick,"tool_next.gif");
- }
+
+ if( isset($_POST['import_id']) ) $objSession->SetVariable('ImportScriptID', $_POST['import_id']);
+ $import_script = GetImportScript( $objSession->GetVariable('ImportScriptID') );
+
+
+ $sec = $objSections->GetSection($section);
+ $objCatToolBar = new clsToolBar();
- $title = admin_language("la_performing_import")." - ".admin_language("la_Step")." 3";
+ // Previous Button
+ $MouseOver = "swap('moveleft','toolbar/tool_prev_f2.gif');";
+ $MouseOut = "swap('moveleft', 'toolbar/tool_prev.gif');";
+ $link = $adminURL."/import/inlinkimport2.php".$var;
+ $objCatToolBar->Add("moveleft",admin_language("la_ToolTip_Previous")." ".admin_language("la_Text_Step"),$link,$MouseOver,$MouseOut,"","tool_prev.gif");
+
+ // Next Button
+ $MouseOver = "swap('moveright','toolbar/tool_next_f2.gif');";
+ $MouseOut = "swap('moveright', 'toolbar/tool_next.gif');";
+ $link2 = $adminURL."/import/inlinkimport4.php".$var;
+ $onClick = "document.import_form.submit();";
+ $objCatToolBar->Add("moveright",admin_language("la_ToolTip_Next")." ".admin_language("la_Text_Step"),'#',$MouseOver,$MouseOut,$onClick,"tool_next.gif");
- int_header($objCatToolBar,NULL,$title);
-}
+ // Header
+ $title = admin_language("la_performing_import")." - ".admin_language("la_Step")." 3";
+ int_header($objCatToolBar,NULL,$title);
?>
+<form name="import_form" METHOD="POST" action='<?php echo $adminURL."/import/inlinkimport4.php".$var ; ?>' >
+<input type="hidden" name="Action" value="checkconn">
<table width="100%" border="0" cellspacing="0" cellpadding="4" class="tableborder">
-<form name="inlinkimport3" METHOD="POST" action='<?php echo $adminURL."/import/inlinkimport4.php".$var ; ?>' >
-<?php int_subsection_title(admin_language("la_Text_DatabaseSettings")); ?>
- <TR <?php echo int_table_color(); ?>>
- <td width=\"60%\" valign=\"top\"><span class=\"text\"><?php echo admin_language("la_prompt_InlinkSqlType"); ?></span></td>
- </TD>
-
- <TD>
- <SELECT NAME="inlink_sql_type" style="width: 197px">
- <OPTION VALUE="mysql" <?php /*if($g_DBType=="mysql")*/ echo "SELECTED"; ?>>MySQL</OPTION>
- <!--<OPTION VALUE="mssql" <?php if($g_DBType=="mssql") echo "SELECTED"; ?>>MS-SQL Server</OPTION>
- <OPTION VALUE="pgsql" <?php if($g_DBType=="pgsql") echo "SELECTED"; ?>>pgSQL</OPTION>-->
- </SELECT>
- <!--<INPUT type="text" name="inlink_sql_type" class="text" size="30" value='<?php echo $objSession->GetVariable("import_inlink_sql_type"); ?>'>-->
- </TD>
- </TR>
- <TR <?php echo int_table_color(); ?>>
- <td width=\"60%\" valign=\"top\"><span class=\"text\"><?php echo admin_language("la_prompt_InlinkServer"); ?></span></td>
- </TD>
-
- <TD>
- <INPUT type="text" name="inlink_server" class="text" size="30" value='<?php echo $objSession->GetVariable("import_inlink_server"); ?>'>
- </TD>
- </TR>
- <TR <?php echo int_table_color(); ?>>
- <td width=\"60%\" valign=\"top\"><span class=\"text\"><?php echo admin_language("la_prompt_InlinkDbName"); ?></span></td>
- </TD>
-
- <TD>
- <INPUT type="text" name="inlink_db" class="text" size="30" value='<?php echo $objSession->GetVariable("import_inlink_db"); ?>'>
- </TD>
- </TR>
- <TR <?php echo int_table_color(); ?>>
- <td width=\"60%\" valign=\"top\"><span class=\"text\"><?php echo admin_language("la_prompt_InlinkDbUsername"); ?></span></td>
- <TD>
- <INPUT type="text" name="inlink_user" class="text" size="30" value='<?php echo $objSession->GetVariable("import_inlink_user"); ?>'>
- </TD>
-
- </TR>
- <TR <?php echo int_table_color(); ?>>
- <td width=\"60%\" valign=\"top\"><span class=\"text\"><?php echo admin_language("la_prompt_InlinkDbPass"); ?></span></td>
- <TD >
- <INPUT type="password" name="inlink_pass" class="text" size="30" value='<?php echo $objSession->GetVariable("import_inlink_pass"); ?>'>
- </TD>
- </TR>
- <input TYPE="hidden" NAME="Action" VALUE="checkconn">
- <tr>
- <td COLSPAN="2">
- <SPAN class="error"><?php echo $objSession->GetVariable("error_importing"); ?></SPAN>
- </td>
- </tr>
-</FORM>
-</TABLE>
+ <?php int_subsection_title(admin_language("la_Text_DatabaseSettings").' - '.$import_script['label']); ?>
+ <tr <?php echo int_table_color(); ?>>
+ <td width="60%" valign="top"><span class="text"><?php echo $import_script['field_prefix'].' '.admin_language("la_prompt_InlinkSqlType"); ?></span></td>
+ <td>
+ <select name="inlink_sql_type" style="width: 197px;">
+ <option value="mysql" selected>MySQL</option>
+ </select>
+ </td>
+ </tr>
+ <tr <?php echo int_table_color(); ?>>
+ <td width="60%" valign="top"><span class="text"><?php echo $import_script['field_prefix'].' '.admin_language("la_prompt_InlinkServer"); ?></span></td>
+ <td>
+ <input type="text" name="inlink_server" class="text" size="30" value="<?php echo $objSession->GetVariable("import_inlink_server"); ?>">
+ </td>
+ </tr>
+ <tr <?php echo int_table_color(); ?>>
+ <td width="60%" valign="top"><span class="text"><?php echo $import_script['field_prefix'].' '.admin_language("la_prompt_InlinkDbName"); ?></span></td>
+ <td>
+ <input type="text" name="inlink_db" class="text" size="30" value="<?php echo $objSession->GetVariable("import_inlink_db"); ?>">
+ </td>
+ </tr>
+ <tr <?php echo int_table_color(); ?>>
+ <td width="60%" valign="top"><span class="text"><?php echo $import_script['field_prefix'].' '.admin_language("la_prompt_InlinkDbUsername"); ?></span></td>
+ <td>
+ <input type="text" name="inlink_user" class="text" size="30" value="<?php echo $objSession->GetVariable("import_inlink_user"); ?>">
+ </td>
+ </tr>
+ <tr <?php echo int_table_color(); ?>>
+ <td width="60%" valign="top"><span class="text"><?php echo $import_script['field_prefix'].' '.admin_language("la_prompt_InlinkDbPass"); ?></span></td>
+ <td>
+ <input type="password" name="inlink_pass" class="text" size="30" value="<?php echo $objSession->GetVariable("import_inlink_pass"); ?>">
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2"><span class="error"><?php echo $objSession->GetVariable("error_importing"); ?></span></td>
+ </tr>
+</table>
+</form>
<?php
int_footer();
?>
\ No newline at end of file
Property changes on: trunk/admin/import/inlinkimport3.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.1
\ No newline at end of property
+1.2
\ No newline at end of property
Index: trunk/admin/import/inlinkimport4.php
===================================================================
--- trunk/admin/import/inlinkimport4.php (revision 287)
+++ trunk/admin/import/inlinkimport4.php (revision 288)
@@ -1,215 +1,203 @@
<?php
if(!strlen($pathtoroot))
{
$path=dirname(realpath($_SERVER['SCRIPT_FILENAME']));
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(!strlen($pathtoroot))
$pathtoroot = ".".$pathchar;
}
else
{
$pathtoroot = ".".$pathchar;
}
}
$sub = substr($pathtoroot,strlen($pathchar)*-1);
if($sub!=$pathchar)
{
$pathtoroot = $pathtoroot.$pathchar;
}
//echo $pathtoroot;
//echo $pathtoroot;
require_once($pathtoroot."kernel/startup.php");
$rootURL="http://".ThisDomain().$objConfig->Get("Site_Path");
$admin = $objConfig->Get("AdminDirectory");
if(!strlen($admin))
$admin = "admin";
$localURL=$rootURL."kernel/";
$adminURL = $rootURL.$admin;
$imagesURL = $adminURL."/images";
//admin only util
$pathtolocal = $pathtoroot."kernel/";
require_once ($pathtoroot.$admin."/include/elements.php");
require_once ($pathtoroot."kernel/admin/include/navmenu.php");
require_once ($pathtolocal."admin/include/navmenu.php");
require_once($pathtoroot.$admin."/toolbar.php");
-//Set Section
-$section = "in-portal:inlink_inport";
-//Set Environment Variable
-$envar = "env=" . BuildEnv();
-
-$formaction = $adminURL."/import/import.php?".$envar;
-$sec = $objSections->GetSection($section);
-$objCatToolBar = new clsToolBar();
-$formaction = "import.php?".$envar;
-
-//check if the previous input is correct
-if( $_POST["Action"]=="checkconn")
-{
- $objSession->SetVariable("import_inlink_sql_type",$_POST["inlink_sql_type"]);
- $objSession->SetVariable("import_inlink_server",$_POST["inlink_server"]);
- $objSession->SetVariable("import_inlink_db",$_POST["inlink_db"]);
- $objSession->SetVariable("import_inlink_user",$_POST["inlink_user"]);
- $objSession->SetVariable("import_inlink_pass",$_POST["inlink_pass"]);
-
- $objSession->SetVariable("error_importing","");
-
- $inlink_sql_type=$objSession->GetVariable("import_inlink_sql_type");
- $inlink_server=$objSession->GetVariable("import_inlink_server");
- $inlink_db=$objSession->GetVariable("import_inlink_db");
- $inlink_user=$objSession->GetVariable("import_inlink_user");
- $inlink_pass=$objSession->GetVariable("import_inlink_pass");
-
+
+ //Set Section
+ $section = "in-portal:inlink_inport";
+
+ //Set Environment Variable
+ $envar = "env=" . BuildEnv();
+
+ $sec = $objSections->GetSection($section);
+ $objCatToolBar = new clsToolBar();
- $linkconn = ADONewConnection($inlink_sql_type);
+ //check if the previous input is correct
+ if( $_POST["Action"] == 'checkconn')
+ {
+ // save supplied connection info
+ $objSession->SetVariable("import_inlink_sql_type", $_POST["inlink_sql_type"]);
+ $objSession->SetVariable("import_inlink_server", $_POST["inlink_server"]);
+ $objSession->SetVariable("import_inlink_db", $_POST["inlink_db"]);
+ $objSession->SetVariable("import_inlink_user", $_POST["inlink_user"]);
+ $objSession->SetVariable("import_inlink_pass", $_POST["inlink_pass"]);
+ $objSession->SetVariable("error_importing", '');
+
+
+ $inlink_sql_type = $objSession->GetVariable("import_inlink_sql_type");
+ $inlink_server = $objSession->GetVariable("import_inlink_server");
+ $inlink_db = $objSession->GetVariable("import_inlink_db");
+ $inlink_user = $objSession->GetVariable("import_inlink_user");
+ $inlink_pass = $objSession->GetVariable("import_inlink_pass");
+
+ // check supplied connection
+ $linkconn = ADONewConnection($inlink_sql_type);
+ if(!$linkconn->PConnect($inlink_server, $inlink_user, $inlink_pass, $inlink_db) || $inlink_server =="" || $inlink_db=="")
+ {
+ $objSession->SetVariable("error_importing","Error: The connection to the DB failed please check your settings");
+ header("Location:inlinkimport3.php?".$envar);
+ }
+ unset($linkconn);
+ }
- if(!$linkconn->PConnect($inlink_server, $inlink_user, $inlink_pass, $inlink_db) || $inlink_server =="" || $inlink_db=="")
- {
- // echo "Database connection failed. DB Type: $sql_type, DB Server: $inlink_server, DB User: $inlink_user, DB Name: $inlink_db"; //fatal;
- $objSession->SetVariable("error_importing","Error: The connection to the DB failed please check your settings");
- header("Location:inlinkimport3.php?".$envar);
- //$linkconn->ErrorMsg();
- }
- unset($linkconn);
-}
-//if it is not then we redirect the user back to the page with a message of what went wrong.
-if (true)
-{
+ $import_script = GetImportScript( $objSession->GetVariable('ImportScriptID') );
- if(true)
- {
-
- $MouseOver="swap('moveleft','toolbar/tool_prev_f2.gif');";
- $MouseOut="swap('moveleft', 'toolbar/tool_prev.gif');";
- $var="?env=".BuildEnv()."&en=$en_prev";
- $link=$adminURL."/import/inlinkimport3.php".$var;
+ $var = "?env=".BuildEnv();
+ // Previous Button
+ $MouseOver = "swap('moveleft','toolbar/tool_prev_f2.gif');";
+ $MouseOut = "swap('moveleft', 'toolbar/tool_prev.gif');";
+ $link = $adminURL."/import/inlinkimport3.php".$var;
$objCatToolBar->Add("moveleft",admin_language("la_ToolTip_Previous")." ".admin_language("la_Text_Step"),$link,$MouseOver,$MouseOut,"","tool_prev.gif");
- }
-
- if(true)
- {
- $MouseOver="swap('moveright','toolbar/tool_next_f2.gif');";
- $MouseOut="swap('moveright', 'toolbar/tool_next.gif');";
- $var="?env=".BuildEnv()."&en=$en_next";
- $link=$adminURL."/import/inlinkimport4.php".$var;
-
- $onClick="if(document.inlinkimport4.user_admin.value=='' || document.inlinkimport4.user_regular.value=='' || document.inlinkimport4.init_cat.value=='' || document.inlinkimport4.link_image.value =='') alert('Please fill in all of the fields'); else import_submit('inlinkimport4','$formaction','');";
- $link="#";
- $objCatToolBar->Add("moveright",admin_language("la_ToolTip_Next")." ".admin_language("la_Text_Step"),$link,$MouseOver,$MouseOut,$onClick,"tool_next.gif");
- }
-
- $title = admin_language("la_performing_import")." - ".admin_language("la_Step")." 4";
+ // Next Button
+ $MouseOver = "swap('moveright','toolbar/tool_next_f2.gif');";
+ $MouseOut = "swap('moveright', 'toolbar/tool_next.gif');";
+ $formaction = $adminURL.'/import/'.$import_script['url'].'.php?'.$envar;
+ $link = $adminURL."/import/inlinkimport4.php".$var;
+ $onClick = "if( !CheckFinalForm('import_form') ) alert('Please fill in all of the fields'); else import_submit('import_form','$formaction',''); ";
+ $objCatToolBar->Add("moveright",admin_language("la_ToolTip_Next")." ".admin_language("la_Text_Step"),'#',$MouseOver,$MouseOut,$onClick,"tool_next.gif");
- int_header($objCatToolBar,NULL,$title);
-}
+ // Header
+ $title = admin_language("la_performing_import")." - ".admin_language("la_Step")." 4";
+ int_header($objCatToolBar,NULL,$title);
+
?>
+<form id="import_form" name="import_form" method="post" action="<?php echo $_SERVER["PHP_SELF"]."?".$envar; ?>">
+ <input type="hidden" name="Action" value="m_save_import_config">
<table width="100%" border="0" cellspacing="0" cellpadding="4" class="tableborder">
-<form id="inlinkimport4" name="inlinkimport4" METHOD="POST" action="<?php echo $_SERVER["PHP_SELF"]."?".$envar; ?>">
-<?php int_subsection_title("Matching Fields - Intechnic In-Portal "); ?>
- <TR <?php echo int_table_color(); ?>>
- <td width=\"60%\" valign=\"top\"><span class=\"text\"><?php echo admin_language("la_prompt_AdminId"); ?> </span></td>
- <TD>
- <b><?php echo $objSession->GetVariable("user_admin_names"); ?></b>
- <INPUT TYPE="hidden" NAME="user_admin" size="15" class="text" value='<?php echo $objSession->GetVariable("user_admin_values"); ?>'>
- <a href="#"><img src="../images/icon_users_sm.gif" style="cursor:hand" border="0" ONCLICK="OpenGroupSelector('<?php echo $envar; ?>&en=0&destform=inlinkimport4&destfield=grouplist1&Selector=radio');"></a>
-
- <INPUT TYPE="hidden" NAME="grouplist1">
-
- </TD>
- </TR>
- <TR <?php echo int_table_color(); ?>>
- <td width=\"60%\" valign=\"top\"><span class=\"text\"><?php echo admin_language("la_prompt_RegUserId"); ?> </span></td>
- <TD>
- <b><?php echo $objSession->GetVariable("user_regular_names"); ?></b>
- <INPUT TYPE="hidden" NAME="user_regular" size="15" class="text" value='<?php echo $objSession->GetVariable("user_regular_values"); ?>'>
- <a href="#"><img src="../images/icon_users_sm.gif" style="cursor:hand" border="0" ONCLICK="OpenGroupSelector('<?php echo $envar; ?>&en=0&destform=inlinkimport4&destfield=grouplist2&Selector=radio');"></a>
-
-
- <INPUT TYPE="hidden" NAME="grouplist2">
- </TD>
- </TR>
- <TR <?php echo int_table_color(); ?>>
- <td width=\"60%\" valign=\"top\"><span class=\"text\"><?php echo admin_language("la_prompt_InitImportCat"); ?>
- <?php
- $catid = $objSession->GetVariable("categoryid");
- if($catid>0)
- {
- $c = $objCatList->GetItemByField("ResourceId",$catid);
- $path = prompt_language($objConfig->Get("Root_Name")). "&gt;".$c->GetCachedNavBar();
- }
- else
- $path = prompt_language($objConfig->Get("Root_Name"));
+ <?php int_subsection_title("Matching Fields - Intechnic In-Portal "); ?>
+<!-- script common fields: begin -->
+ <tr <?php echo int_table_color(); ?>>
+ <td width="60%" valign="top"><span class="text"><?php echo admin_language("la_prompt_AdminId"); ?></span></td>
+ <td>
+ <b><?php echo $objSession->GetVariable("user_admin_names"); ?></b>
+ <input type="hidden" name="user_admin" size="15" class="text" value="<?php echo $objSession->GetVariable("user_admin_values"); ?>">
+ <input type="hidden" name="grouplist1" value="<?php echo $objSession->GetVariable('grouplist1'); ?>">
+ <a href="#"><img src="../images/icon_users_sm.gif" style="cursor:hand;" border="0" onclick="OpenGroupSelector('<?php echo $envar; ?>&en=0&destform=import_form&destfield=grouplist1&Selector=radio');"></a>
+ </td>
+ </tr>
+ <tr <?php echo int_table_color(); ?>>
+ <td width="60%" valign="top"><span class="text"><?php echo admin_language("la_prompt_RegUserId"); ?></span></td>
+ <td>
+ <b><?php echo $objSession->GetVariable("user_regular_names"); ?></b>
+ <input type="hidden" name="user_regular" size="15" class="text" value="<?php echo $objSession->GetVariable("user_regular_values"); ?>">
+ <input type="hidden" name="grouplist2" value="<?php echo $objSession->GetVariable('grouplist2'); ?>">
+ <a href="#"><img src="../images/icon_users_sm.gif" style="cursor:hand;" border="0" onclick="OpenGroupSelector('<?php echo $envar; ?>&en=0&destform=import_form&destfield=grouplist2&Selector=radio');"></a>
+ </td>
+ </tr>
+ <tr <?php echo int_table_color(); ?>>
+ <td width="60%" valign="top"><span class="text"><?php
+ echo admin_language("la_prompt_InitImportCat");
+ $catid = $objSession->GetVariable('categoryid');
+ $path = prompt_language($objConfig->Get("Root_Name"));
+ if($catid > 0)
+ {
+ $c = $objCatList->GetItemByField('ResourceId', $catid);
+ $path .= "&gt;".$c->GetCachedNavBar();
+ }
?>
- </td>
- <TD >
- <B><?php echo $path; ?></B>
- <INPUT TYPE="HIDDEN" NAME="init_cat" size="15" class="text" value='<?php echo $objSession->GetVariable("categoryid"); ?>'>
- <a href="#"><img src="<?php echo $imagesURL; ?>/folder.gif" style="cursor:hand" border="0" ONCLICK="OpenCatSelector('<?php echo $envar; ?>&source=inlinkimport4&continue_sess=1&destform=inlinkimport4&destfield=categorylist&Selector=radio');"></a>
-
-
- <INPUT TYPE="hidden" NAME="categorylist">
-
- </TD>
- </TR>
- <TR <?php echo int_table_color(); ?>>
- <td width=\"60%\" valign=\"top\"><span class=\"text\"><?php echo admin_language("la_prompt_Import_ImageName"); ?></span></td>
- <TD >
- <INPUT type="text" name="link_image" class="text" size="30" value='<?php echo $objSession->GetVariable("link_image"); ?>'>
- </TD>
- </TR>
- <input TYPE="hidden" NAME="Action" VALUE="l_import_config">
- <tr>
- <td>
- </td>
- </tr>
-</FORM>
-</TABLE>
+ </td>
+ <td>
+ <b><?php echo $path; ?></b>
+ <input type="hidden" name="init_cat" size="15" class="text" value="<?php echo $objSession->GetVariable("categoryid"); ?>">
+ <a href="#"><img src="<?php echo $imagesURL; ?>/folder.gif" style="cursor:hand;" border="0" ONCLICK="OpenCatSelector('<?php echo $envar; ?>&source=inlinkimport4&continue_sess=1&destform=import_form&destfield=categorylist&Selector=radio');"></a>
+ <input type="hidden" name="categorylist" value="<?php echo $objSession->GetVariable('categorylist'); ?>">
+ </td>
+ </tr>
+<!-- script common fields: end -->
+<!-- script spefific fields: begin -->
+<?php
+ if( $import_script['id'] == 'in-link' )
+ {
+?>
+ <tr <?php echo int_table_color(); ?>>
+ <td width="60%" valign="top"><span class="text"><?php echo admin_language("la_prompt_Import_ImageName"); ?></span></td>
+ <td>
+ <input type="text" name="link_image" class="text" size="30" value="<?php echo $objSession->GetVariable("link_image"); ?>">
+ </td>
+ </tr>
+<?php
+ }
+?>
+<!-- script spefific fields: end -->
+</table>
+</form>
<?php
int_footer();
?>
Property changes on: trunk/admin/import/inlinkimport4.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.2
\ No newline at end of property
+1.3
\ No newline at end of property
Index: trunk/admin/import/phpbb_import.php
===================================================================
--- trunk/admin/import/phpbb_import.php (nonexistent)
+++ trunk/admin/import/phpbb_import.php (revision 288)
@@ -0,0 +1,427 @@
+<?php
+if(!strlen($pathtoroot))
+{
+ $path=dirname(realpath($_SERVER['SCRIPT_FILENAME']));
+ 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(!strlen($pathtoroot))
+ $pathtoroot = ".".$pathchar;
+ }
+ else
+ {
+ $pathtoroot = ".".$pathchar;
+ }
+}
+
+$sub = substr($pathtoroot,strlen($pathchar)*-1);
+if($sub!=$pathchar)
+{
+ $pathtoroot = $pathtoroot.$pathchar;
+}
+//echo $pathtoroot;
+//echo $pathtoroot;
+require_once($pathtoroot."kernel/startup.php");
+$rootURL="http://".ThisDomain().$objConfig->Get("Site_Path");
+
+$admin = $objConfig->Get("AdminDirectory");
+if(!strlen($admin))
+ $admin = "admin";
+
+$localURL=$rootURL."kernel/";
+$imagesURL = $rootURL."admin/images";
+$adminURL = $rootURL.$admin;
+
+//admin only util
+$pathtolocal = $pathtoroot."kernel/";
+require_once ($pathtoroot."admin/include/elements.php");
+require_once ($pathtoroot."kernel/admin/include/navmenu.php");
+require_once ($pathtolocal."admin/include/navmenu.php");
+require_once($pathtoroot."admin/toolbar.php");
+//Set Section
+$section = "in-portal:inlink_inport";
+//Set Environment Variable
+$envar = "env=" . BuildEnv();
+
+$sec = $objSections->GetSection($section);
+$title = admin_language("la_performing_import")." - ".admin_language("la_Step")." 4";
+int_header(null,NULL,$title);
+
+
+$import_steps = Array();
+$import_steps[] = Array('id' => 'users', 'caption' => 'Users, avatars'); // users + avatars
+$import_steps[] = Array('id' => 'user_banlist', 'caption' => 'Users Banrules'); // banned users
+$import_steps[] = Array('id' => 'cats', 'caption' => 'Categories');
+$import_steps[] = Array('id' => 'forums', 'caption' => 'Forums');
+$import_steps[] = Array('id' => 'topics', 'caption' => 'Topics');
+$import_steps[] = Array('id' => 'posts', 'caption' => 'Posts');
+$import_steps[] = Array('id' => 'smiles', 'caption' => 'Smiles');
+
+error_reporting(E_ALL);
+ini_set('display_errors',1);
+ini_set('max_execution_time', 0);
+ini_set('memory_limit', '250M');
+
+function PrintStep($step_rec)
+{
+ echo '
+ <tr '.int_table_color(0, true).'>
+ <td width="30%">&nbsp;</td>
+ <td width="35%" valign="top"><span class="text">'.$step_rec['caption'].'</span></td>
+ <td width="5%">
+ <span id="'.$step_rec['id'].'" class="text">0</span>%&nbsp;(<span id="'.$step_rec['id'].'_additional" class="text"></span>)
+ </td>
+ <td width="30%">&nbsp;</td>
+ </tr>';
+
+}
+
+function echof($s) // not in use
+{
+ echo $s;
+ flush();
+}
+
+?>
+
+<form id="import_form" action="" method="post">
+<table width="100%" border="0" cellspacing="0" cellpadding="4" class="tableborder">
+ <?php
+ foreach($import_steps as $import_step) PrintStep($import_step);
+ int_subsection_title( admin_language("la_performing_import").' - 965 %' );
+ ?>
+ <tr <?php echo int_table_color(); ?>>
+ <td colspan="4">Script Running: <span id="total_time">0</span> s</td>
+ </tr>
+
+
+ </table>
+</form>
+<?php
+ int_footer(); echo "\n";
+
+ define('DT_USER', 6); // user data type
+ $bb_prefix = $objSession->GetVariable('bb_prefix'); // may be phpBB uses prefix
+ $sql_type = $objSession->GetVariable("import_inlink_sql_type");
+ $db_server = $objSession->GetVariable("import_inlink_server");
+ $db_name = $objSession->GetVariable("import_inlink_db");
+ $db_user = $objSession->GetVariable("import_inlink_user");
+ $db_pass = $objSession->GetVariable("import_inlink_pass");
+ $import_category_id = $objSession->GetVariable('import_category_id');
+
+ $user_admin = $objSession->GetVariable("user_admin_values");
+ $user_regular = $objSession->GetVariable("user_regular_values");
+
+ //$admin_group =& new clsPortalGroup($user_admin);
+ $user_group =& new clsPortalGroup($user_regular);
+
+
+
+
+ // made connection to source database
+ $db =& ADONewConnection($sql_type);
+ $db->PConnect($db_server, $db_user, $db_pass, $db_name);
+
+ // get connection to destination database
+ $dst_db =& GetADODBConnection();
+
+ // if connection error occured, then say this
+ if(!$db)
+ {
+ echo "Database connection failed. DB Type: $sql_type, DB Server: $inlink_server, DB User: $inlink_user, DB Name: $inlink_db"; //fatal;
+ echo $db->ErrorMsg();
+ exit;
+ }
+
+ $begin_time = microtime();
+ // connection made, so begin import
+
+ // create custom fields for in-bulletin users (and show them on general tab)
+ $user_fields = new clsCustomFieldList(DT_USER);
+ $user_fields_created = $user_fields->GetFieldNames();
+ $uf_defs = Array( 'user_msn' => 'user_msnm', 'user_icq' => 'user_icq', 'user_aim' => 'user_aim',
+ 'user_yahoo' => 'user_yim', 'user_website' => 'user_website',
+ 'user_occupation' => 'user_occ', 'user_interests' => 'user_interests');
+
+ $pesistant_vars = Array('my_signature' => 'user_sig', 'bb_posts' => 'user_posts',
+ 'smileys' => 'user_allowsmile', 'bbcode' => 'user_allowbbcode',
+ 'bb_signatures' => 'user_attachsig');
+
+ foreach($uf_defs as $pending_uf => $no_in_use)
+ if( !in_array($pending_uf, $user_fields_created) ) // don't create one customfield twice :)
+ $user_fields->AddField(DT_USER, $pending_uf, '', 1, 'la_bb', 'la_'.$pending_uf, 'text', '');
+
+ // get users
+ $cache['users'] = Array();
+ $sql = 'SELECT * FROM '.$bb_prefix.'users ORDER BY user_id';
+ $rs = $db->Execute($sql);
+ InitCounter('users', $rs->RecordCount() );
+
+ // Create Anonymous User
+ $user =& $objUsers->Add_User('Guest', '', 'anonymous@user.com', time(), '', '', 1, '', '', '', '', '', '');
+ $cache['users'][ -1 ] = $user->UniqueId();
+ $cache['users'][ 0 ] = $user->UniqueId();
+ unset($user);
+
+ while(!$rs->EOF)
+ {
+ $rec =& $rs->fields;
+ $address = explode(',', $rec['user_from']); // state, country
+ foreach($address as $id => $addr_part) $address[$id] = trim($addr_part);
+ $user_state = isset( $address[0] ) ? $address[0] : '';
+ $user_country = isset( $address[1] ) ? $address[1] : '';
+
+ $user =& $objUsers->Add_User($rec['username'], $rec['user_password'], $rec['user_email'], $rec['user_regdate'],
+ '', '', $rec['user_active'], '', '', '', $user_state, '', $user_country);
+
+ $user_id = $user->UniqueId();
+
+ // set user pesistant variables (why not custom fields)
+ foreach($pesistant_vars as $dst_field => $src_field)
+ SetPersistantVariable($user_id, $dst_field, $rec[$src_field]);
+
+ // set user custom fields
+ foreach($uf_defs as $dst_field => $src_field)
+ $user->SetCustomField($dst_field, $rec[$src_field]);
+ $user->SaveCustomFields();
+
+ // add user to user_group specified (in import step 3)
+ $user_group->AddUser($user_id, 1);
+
+ // add created user to cache
+ $cache['users'][ $rec['user_id'] ] = Array('new_id' => $user_id, 'username' => $rec['username']);
+ $processed['users']++;
+ unset($user);
+ SetStepPercent('users');
+ $rs->MoveNext();
+ }
+ //unset($objUsers);
+
+ // get ban rules
+ $sql = 'SELECT * FROM '.$bb_prefix.'banlist ORDER BY ban_id';
+ $rs = $db->Execute($sql);
+ $banrule_priority = 1;
+ InitCounter('user_banlist', $rs->RecordCount() );
+ while(!$rs->EOF)
+ {
+ $rec =& $rs->fields;
+ if( $rec['ban_userid'] )
+ {
+ $tmp =& $objBanList->AddRule(DT_USER, 0, 'Login',1, $cache['users'][ $rec['ban_userid'] ]['username'], $banrule_priority, 1);
+ unset($tmp);
+ $banrule_priority++;
+ }
+
+ if( $rec['ban_ip'] )
+ {
+ $tmp =& $objBanList->AddRule(DT_USER, 0, 'ip',1, DecodeIP( $rec['ban_ip'] ), $banrule_priority, 1);
+ unset($tmp);
+ $banrule_priority++;
+ }
+
+ if( $rec['ban_email'] )
+ {
+ $tmp =& $objBanList->AddRule(DT_USER, 0, 'Email',1, $rec['ban_email'], $banrule_priority, 1);
+ unset($tmp);
+ $banrule_priority++;
+ }
+ $processed['user_banlist']++;
+ SetStepPercent('user_banlist');
+ $rs->MoveNext();
+ }
+ unset($objBanList);
+
+ // get categories
+ $cache['cats'] = Array();
+ $sql = 'SELECT * FROM '.$bb_prefix.'categories ORDER BY cat_order';
+ $rs = $db->Execute($sql);
+ InitCounter('cats', $rs->RecordCount() );
+ while(!$rs->EOF)
+ {
+ $rec =& $rs->fields;
+ $category =& $objCatList->Add( $import_category_id, $rec['cat_title'], $rec['cat_title'], time(),
+ 0, 1, 2, 2, 2, $rec['cat_order'] / 10, '', '');
+ $cache['cats'][ $rec['cat_id'] ] = Array( 'new_id' => $category->UniqueId() );
+ $processed['cats']++;
+ SetStepPercent('cats');
+ unset($category);
+ $rs->MoveNext();
+ }
+
+ // get forums
+ $cache['forums'] = Array();
+ $sql = 'SELECT * FROM '.$bb_prefix.'forums ORDER BY cat_id';
+ $rs = $db->Execute($sql);
+ InitCounter('forums', $rs->RecordCount() );
+ while(!$rs->EOF)
+ {
+ $rec =& $rs->fields;
+ $category =& $objCatList->Add( $cache['cats'][ $rec['cat_id'] ]['new_id'], $rec['forum_name'],
+ $rec['forum_desc'], time(), 0, 1, 2, 2, 2, $rec['forum_order'], '', '');
+ $cache['forums'][ $rec['forum_id'] ] = Array( 'new_id' => $category->UniqueId() );
+ $processed['forums']++;
+ SetStepPercent('forums');
+ unset($category);
+ $rs->MoveNext();
+ }
+ //unset($objCatList);
+
+ // get topics
+ $cache['topics'] = Array();
+ $sql = 'SELECT * FROM '.$bb_prefix.'topics ORDER BY forum_id';
+ $rs = $db->Execute($sql);
+ InitCounter('topics', $rs->RecordCount() );
+ while(!$rs->EOF)
+ {
+ $rec =& $rs->fields;
+ $rec['topic_replies'] = $rec['topic_replies'] > 0 ? $rec['topic_replies'] : 0;
+ $topic =& $objTopicList->Add_Topic( $rec['topic_title'], $cache['forums'][ $rec['forum_id'] ]['new_id'],
+ 1, 0, 0, $rec['topic_time'], GetUserID( $rec['topic_poster'] ),
+ Array('Posts' => $rec['topic_replies'], 'Views' => $rec['topic_views']) );
+
+ $cache['topics'][ $rec['topic_id'] ] = Array( 'new_id' => $topic->UniqueId() );
+ $processed['topics']++;
+ SetStepPercent('topics');
+ unset($topic);
+ $rs->MoveNext();
+ }
+ unset($objTopicList);
+
+ // get posts
+ $cache['posts'] = Array();
+ $sql = 'SELECT * FROM '.$bb_prefix.'posts p LEFT JOIN '.$bb_prefix.'posts_text pt ON pt.post_id = p.post_id ORDER BY topic_id';
+ $rs = $db->Execute($sql);
+ InitCounter('posts', $rs->RecordCount() + $total['topics'] ); // update each topic info too
+ while(!$rs->EOF)
+ {
+ $rec =& $rs->fields;
+ $post =& new clsPosting();
+ $post->Set( Array('IPAddress', 'PosterAlias', 'Subject', 'PostingText', 'CreatedOn', 'CreatedById', 'TopicId' ),
+ Array(
+ DecodeIP( $rec['poster_ip'] ),
+ GetUserName( $rec['poster_id'] ),
+ $rec['post_subject'],
+ $rec['post_text'],
+ $rec['post_time'],
+ GetUserID( $rec['poster_id'] ),
+ $cache['topics'][ $rec['topic_id'] ]['new_id'] )
+ );
+ $post->Create();
+ $cache['posts'][ $rec['post_id'] ] = Array( 'new_id' => $post->UniqueId() );
+ $processed['posts']++;
+ SetStepPercent('posts');
+ unset($post);
+ $rs->MoveNext();
+ }
+
+ // set lastpostid for each topic
+ $sql = 'SELECT topic_id, MAX(post_time) AS pt, post_id FROM '.$bb_prefix.' posts GROUP BY topic_id ORDER BY post_time DESC';
+ $rs = $db->Execute($sql);
+ $update_sql = 'UPDATE '.GetTablePrefix().'Topic SET LastPostId = %s, LastPostDate = %s';
+ while(!$rs->EOF)
+ {
+ $rec =& $rs->fields;
+ $tmp = sprintf($update_sql, $cache['posts'][ $rec['post_id'] ]['new_id'], $rec['pt']);
+ $db->Execute($tmp);
+ $processed['posts']++;
+ SetStepPercent('posts');
+ $rs->MoveNext();
+ }
+
+
+// functions used
+
+function SetPersistantVariable($user_id, $var_name, $var_value)
+{
+ global $dst_db;
+ $sql_template = "REPLACE INTO ".GetTablePrefix()."PersistantSessionData (PortalUserId, VariableName, VariableValue) VALUES (%s,'%s','%s')";
+ $dst_db->Execute( sprintf($sql_template, $user_id, $var_name, $var_value) );
+}
+
+function SetStepPercent($step_id, $new_percent = false)
+{
+ if($new_percent === false)
+ {
+ global $total, $processed, $progress_display;
+ $new_percent = ($processed[$step_id] / $total[$step_id]) * 100;
+ $new_percent = round($new_percent, 1);
+ if( $processed[$step_id] % $progress_display[$step_id] != 0 ) return false;
+ }
+ $time_runs = microtime() - $GLOBALS['begin_time'];
+ echo '<script language="javascript">SetPercent(\''.$step_id.'\', '.$new_percent.',\''.($processed[$step_id].'_of_'.$total[$step_id]).'\',\''.$time_runs.'\');</script>';
+ flush();
+}
+
+function DecodeIP($ip)
+{
+ $i = 0;
+ $ip_len = strlen($ip);
+ $ip_parts = Array();
+ while($i < $ip_len)
+ {
+ $ip_parts[] = hexdec( substr($ip, $i, 2) );
+ $i += 2;
+ }
+ return implode('.', $ip_parts);
+}
+
+function GetUserID($old_user_id)
+{
+ global $cache;
+ return $cache['users'][ $old_user_id ]['new_id'];
+}
+
+function GetUserName($old_user_id)
+{
+ global $cache;
+ return $cache['users'][ $old_user_id ]['username'];
+}
+
+function InitCounter($step_id, $total_count)
+{
+ global $processed, $total, $progress_display;
+ $processed[$step_id] = 0;
+ $total[$step_id] = $total_count;
+ $progress_display[$step_id] = ceil($total[$step_id] / 10); // display progress in 1 of 10 times requested
+
+
+}
+
+?>
\ No newline at end of file
Property changes on: trunk/admin/import/phpbb_import.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.1
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property

Event Timeline