Page MenuHomeIn-Portal Phabricator

in-portal
No OneTemporary

File Metadata

Created
Sat, Feb 1, 6:52 PM

in-portal

Index: trunk/kernel/action.php
===================================================================
--- trunk/kernel/action.php (revision 103)
+++ trunk/kernel/action.php (revision 104)
@@ -1,2166 +1,2164 @@
<?php
if( defined('DEBUG_ACTIONS') && (DEBUG_ACTIONS & KERNEL_ACTIONS) == KERNEL_ACTIONS )
{
echo "Kernel Action $Action<br>\n";
echo '<b>REQUEST:</b>';
print_pre($_REQUEST);
}
- switch($Action)
- {
- case "m_add_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;
- $dob = 0;
- if($id)
- {
- $lvErrorString = "la_error_duplicate_username";
- }
- else
- {
- $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)=="_")
+ switch($Action)
+ {
+ 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 = "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)
{
- $field = substr($key,1);
- $cvalue = $CustomFields->GetItemByField("FieldName",$field,FALSE);
-
- if(is_object($cvalue))
+ if(substr($key,0,1)=="_")
{
- $objCustomEdit->SetFieldValue($cvalue->Get("CustomFieldId"),$u->Get("ResourceId"),$value);
- $DataChanged = TRUE;
+ $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;
+ }
+ if($DataChanged) $objCustomEdit->SaveData();
+ $objCustomEdit->SetTable('live');
+
+
+ break;
case "m_edit_user":
- //phpinfo(INFO_VARIABLES);
$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;
- echo "Loading CF by USER_RID: ".$u->Get("ResourceId")."<br>";
-
$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 Value of CF [CF_ID: ".$cvalue->Get("CustomFieldId")."; RID: ".$u->Get("ResourceId")."; NEW_VAL: ".$value."]<br>";
+ //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);
$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($_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":
foreach($_POST["itemlist"] as $userid)
{
$user = $objUsers->GetItemByField("ResourceId",$userid);
$user->Approve();
}
$objUsers->Clear();
break;
case "m_deny_user":
foreach($_POST["itemlist"] as $userid)
{
$user = $objUsers->GetItemByField("ResourceId",$userid);
$user->Deny();
}
$objUsers->Clear();
break;
case "m_delete_user":
foreach($_POST["itemlist"] as $userid)
$objUsers->Delete_User($userid);
break;
case "m_delete_group":
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"]);
//echo "Setting $fieldname to $varvalue<br>\n";
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($_POST["CatEditStatus"] != -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":
$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":
$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":
$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":
$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");
$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();
- $ado->debug = 1;
+
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":
$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":
$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":
$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":
$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":
$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(is_array($_POST["itemlist"]))
{
$ThemeId = (int)$_POST["itemlist"][0];
}
else
(int)$ThemeId = $_POST["itemlist"];
if($ThemeId)
{
$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 (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":
$objPhraseList = new clsPhraseList();
$objPhraseList->SourceTable = $objSession->GetEditTable("Phrase");
if (isset($_POST["itemlist"]))
{
foreach($_POST["itemlist"] as $id)
{
$objPhraseList->DeletePhrase($id);
}
}
unset($objPhraseList);
break;
case "m_emailevent_disable":
$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":
$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":
$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":
$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);
$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 (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 (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($SqlQuery);
$SqlError = $ado->ErrorMsg();
$SqlErrorNum = $ado->ErrorNo();
}
break;
case "m_session_delete":
//if(isset($_POST["itemlist"]))
//{
$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(isset($_POST["itemlist"]))
{
foreach($_POST["itemlist"] as $id)
{
$i = $objBanList->GetItem($id);
$i->Increment("Priority");
}
}
break;
case "m_rule_move_down":
if(isset($_POST["itemlist"]))
{
foreach($_POST["itemlist"] as $id)
{
$i = $objBanList->GetItem($id);
$i->Decrement("Priority");
}
}
break;
case "m_rule_delete":
if(isset($_POST["itemlist"]))
{
foreach($_POST["itemlist"] as $id)
{
$i = $objBanList->GetItem($id);
$i->Delete();
}
}
break;
case "m_ban_user":
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;
}
/* 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
if( ! $objSession->HasSystemPermission("SYSTEM_ACCESS.READONLY") )
{
/* 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 ".$objPhraseList->SourceTable);
}
if( GetVar('MissingLangEditStatus') == 2 )
{
$table = $objSession->GetSessionKey()."_".$ThemeId."_labels";
$ado = GetADODBConnection();
$ado->Execute("DROP TABLE ".$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>";
}
?>
Property changes on: trunk/kernel/action.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.5
\ No newline at end of property
+1.6
\ No newline at end of property
Index: trunk/kernel/include/custommetadata.php
===================================================================
--- trunk/kernel/include/custommetadata.php (revision 103)
+++ trunk/kernel/include/custommetadata.php (revision 104)
@@ -1,260 +1,273 @@
<?php
class clsCustomMetaData extends clsItem
{
// var $m_CustomDataId;
// var $m_ResourceId;
// var $m_CustomFieldId;
// var $m_Value;
var $FieldName;
function clsCustomMetaData($CustomDataId=-1,$table="CustomMetaData")
{
$this->clsItem();
$this->tablename=GetTablePrefix()."CustomMetaData";
$this->type=12;
$this->BasePermission="";
$this->id_field = "CustomDataId";
$this->NoResourceId=1; //set this to avoid using a resource ID
if(isset($CustomDataId))
$this->LoadFromDatabase($CustomDataId);
}
function Validate()
{
global $Errors;
$dataValid = true;
if(!strlen($this->Get("ResourceId")))
{
$Errors->AddError("error.fieldIsRequired",'ResourceId',"","",get_class($this),"Validate");
$dataValid = false;
}
return $dataValid;
}
function SetFieldName($name)
{
$this->FieldName = $name;
}
function GetFieldName()
{
return $this->FieldName;
}
function Save()
{
if(is_numeric($this->Get("CustomDataId")))
{
$this->Update();
}
else
$this->Create();
}
/*
function LoadFromDatabase($Id)
{
global $objSession, $Errors;
if(!isset($Id))
{
$Errors->AddError("error.AppError",NULL,'Internal error: LoadFromDatabase id',"",get_class($this),"LoadFromDatabase");
return false;
}
$sql = sprintf("SELECT * FROM ".$this->SourceTable." WHERE CustomDataId = '%s'",$Id);
$result = $this->adodbConnection->Execute($sql);
if ($result === false)
{
$Errors->AddError("error.DatabaseError",NULL,$this->adodbConnection->ErrorMsg(),"",get_class($this),"LoadFromDatabase");
return false;
}
$data = $result->fields;
$this->SetFromArray($data);
$this->Clean();
return true;
}
*/
} /*clsCustomMetaData*/
class clsCustomDataList extends clsItemCollection
{
function clsCustomDataList($table="")
{
$this->clsItemCollection();
$this->classname = "clsCustomMetaData";
if(!strlen($table))
$table = GetTablePrefix()."CustomMetaData";
- $this->SourceTable = $table;
+ $this->SetTable('live', $table);
}
function LoadResource($ResourceId)
{
$sql = "SELECT * FROM ".$this->SourceTable." WHERE ResourceId=".$ResourceId;
$this->Query_Item($sql);
return $this->Items;
}
function DeleteResource($ResourceId)
{
$sql = "DELETE FROM ".$this->SourceTable." WHERE ResourceID=".$ResourceId;
$this->adodbConnection->Execute($ResourceId);
}
function &SetFieldValue($FieldId,$ResourceId,$Value)
{
- $d =& $this->GetDataItem($FieldId);
+ // so strange construction used, because in normal
+ // way it doesn't work at all (gets item copy not
+ // pointer)
+ $index = $this->GetDataItem($FieldId, true);
+
+ if($index !== false)
+ $d =& $this->Items[$index];
+ else
+ $d = null;
+
if(is_object($d))
{
$d->Set("Value",$Value);
if(!strlen($Value))
{
for($x=0;$x<count($this->Items);$x++)
{
if($this->Items[$x]->Get("CustomFieldId")==$FieldId &&
$this->Items[$x]->Get("ResourceId")==$ResourceId)
{
$this->Items[$x]->Set("CustomFieldId",0);
break;
}
}
$d->Delete();
}
}
else
{
if(strlen($Value)>0)
{
$d = new clsCustomMetaData();
$d->Set("CustomFieldId",$FieldId);
$d->Set("ResourceId",$ResourceId);
$d->Set("Value",$Value);
array_push($this->Items,$d);
}
}
+ $this->ShowItems();
return $d;
}
- function &GetDataItem($id)
+ function &GetDataItem($id, $return_index = false)
{
+ // $id - custom field id to find
+ // $return_index - return index to items, not her.
$found = false;
- for($i=0;$i<$this->NumItems();$i++)
+ $index = false;
+ for($i = 0; $i < $this->NumItems(); $i++)
{
$d =& $this->GetItemRefByIndex($i);
if($d->Get("CustomFieldId")==$id)
{
$found=TRUE;
break;
}
}
- return ($found) ? $d : false;
+ return $found ? ($return_index ? $i : $d) : false;
}
function SaveData()
{
foreach($this->Items as $f)
{
$FieldId = $f->Get("CustomFieldId");
$value = $f->Get("Value");
$ResId = $f->Get("ResourceId");
$DataId = $f->Get("CustomDataId");
if(is_numeric($DataId))
{
$sql = "UPDATE ".$this->SourceTable." SET Value='".$value."' WHERE CustomFieldId='$FieldId' AND ResourceId='$ResId'";
$this->adodbConnection->Execute($sql);
}
else
{
if($FieldId>0)
{
$sql = "INSERT INTO ".$this->SourceTable." (ResourceId,CustomFieldId,Value) VALUES ('".$ResId."','$FieldId','$value')";
$this->adodbConnection->Execute($sql);
}
}
}
$rs = $this->adodbConnection->Execute("SELECT * FROM ".$this->SourceTable." WHERE CustomDataId=0 ");
while($rs && !$rs->EOF)
{
$m = $this->adodbConnection->Execute("SELECT MIN(CustomDataId) as MinValue FROM ".$this->SourceTable);
$NewId = $m->fields["MinValue"]-1;
$sql = "UPDATE ".$this->SourceTable." SET CustomDataId=$NewId WHERE ResourceId=".$rs->fields["ResourceId"]." AND ";
$sql .= "CustomFieldId=".$rs->fields["CustomFieldId"];
$this->adodbConnection->Execute($sql);
$rs->MoveNext();
}
}
function CopyToEditTable($idfield, $idlist)
{
global $objSession;
$edit_table = $objSession->GetEditTable($this->SourceTable);
@$this->adodbConnection->Execute("DROP TABLE $edit_table");
if(is_array($idlist))
{
$list = implode(",",$idlist);
}
else
$list = $idlist;
$query = "SELECT * FROM ".$this->SourceTable." WHERE $idfield IN ($list)";
$insert = "CREATE TABLE ".$edit_table." ".$query;
if((int)$GLOBALS["debuglevel"])
echo $insert;
$this->adodbConnection->Execute($insert);
$this->SourceTable = $edit_table;
$this->SaveData();
}
function CopyFromEditTable($ResourceId)
{
global $objSession;
$edit_table = $objSession->GetEditTable($this->SourceTable);
$idlist = array();
//$this->adodbConnection->Execute($sql);
$sql = "SELECT * FROM $edit_table";
$this->Clear();
$rs = $this->adodbConnection->Execute($sql);
while($rs && !$rs->EOF)
{
$data = $rs->fields;
$c = $this->AddItemFromArray($data);
if(strlen($data["Value"])>0)
{
$c->Dirty();
if($data["CustomDataId"]>0)
{
$c->Update();
}
else
{
$c->UnsetIdField();
$c->Create();
}
$idlist[] = $c->Get("CustomDataId");
}
else
{
$sql = "DELETE FROM ".$this->SourceTable." WHERE ResourceId=".$data["ResourceId"]." AND CustomFieldId=".$data["CustomFieldId"];
//echo $sql."<br>\n";
$this->adodbConnection->Execute($sql);
}
$rs->MoveNext();
}
@$this->adodbConnection->Execute("DROP TABLE $edit_table");
}
} /* clsCustomDataList */
?>
Property changes on: trunk/kernel/include/custommetadata.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/kernel/include/customfield.php
===================================================================
--- trunk/kernel/include/customfield.php (revision 103)
+++ trunk/kernel/include/customfield.php (revision 104)
@@ -1,262 +1,263 @@
<?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((int)$GLOBALS["debuglevel"])
- echo $sql."<br>\n";
- $rs = $this->adodbConnection->Execute($sql);
+ 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";
$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.1
\ No newline at end of property
+1.2
\ No newline at end of property
Index: trunk/admin/users/adduser_custom.php
===================================================================
--- trunk/admin/users/adduser_custom.php (revision 103)
+++ trunk/admin/users/adduser_custom.php (revision 104)
@@ -1,238 +1,234 @@
<?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";
require_once ($pathtoroot.$admin."/include/elements.php");
require_once ($pathtoroot."kernel/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 = (int)$_GET["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";
$envar = "env=" . BuildEnv() . "&en=$en";
$section = 'in-portal:edituser_custom';
$title = prompt_language("la_Text_Editing")." ".prompt_language("la_Text_User")." '".$c->Get("Login")."' - ".prompt_language("la_tab_Custom");
$formaction = $adminURL."/user/adduser_custom.php?".$envar;
//Display header
$sec = $objSections->GetSection($section);
$objListToolbar = new clsToolBar();
$objListToolbar->Add("img_save", "la_Save","#","swap('img_save','toolbar/tool_select_f2.gif');", "swap('img_save', 'toolbar/tool_select.gif');","edit_submit('edituser','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');","edit_submit('edituser','UserEditStatus','".$admin."/users/user_list.php',2);","tool_cancel.gif");
if ( isset($en_prev) || isset($en_next) )
{
$url = $RootUrl.$admin."/users/adduser_custom.php";
$StatusField = "UserEditStatus";
$form = "edituser";
MultiEditButtons($objListToolbar,$en_next,$en_prev,$form,$StatusField,$url,$sec->Get("OnClick"),'','la_PrevUser','la_NextUser');
}
int_header($objListToolbar,NULL,$title);
?>
<form ID="edituser" name="edituser" action="" method=POST>
<?php
$objCustomFields = new clsCustomFieldList(6);
$field_list = $objCustomFieldList->Query_CustomField("Type=6");
$objCustomDataList->SourceTable = $objSession->GetEditTable("CustomMetaData");
$objCustomDataList->LoadResource($c->Get("ResourceId"));
for($i=0;$i<$objCustomFields->NumItems(); $i++)
{
$field =& $objCustomFields->GetItemRefByIndex($i);
$fieldid = $field->Get("CustomFieldId");
$f = $objCustomDataList->GetDataItem($fieldid);
$fieldname = "CustomData[$fieldid]";
if(is_object($f))
{
$val_field = "<input type=\"text\" tabindex=\"".($i+1)."\" VALUE=\"".$f->Get("Value")."\" name=\"$fieldname\">";
$field->Set("Value", $val_field);
$field->Set("DataId",$f->Get("CustomDataId"));
}
else
{
$val_field = "<input type=\"text\" tabindex=\"".($i+1)."\" VALUE=\"\" name=\"$fieldname\">";
$field->Set("Value", $val_field);
$field->Set("DataId",0);
}
}
$objCustomFields->SortField = $objConfig->Get("CustomData_LV_Sortfield");;
$objCustomFields->SortItems($objConfig->Get("CustomData_LV_Sortorder")!="desc");
$objListView = new clsListView($objListToolbar,$objCustomFields);
$objListView->IdField = "DataId";
$order = $objConfig->Get("CustomData_LV_Sortfield");
$SortOrder=0;
if($objConfig->Get("CustomData_LV_Sortorder")=="asc")
$SortOrder=1;
$objListView->ColumnHeaders->Add("FieldName",admin_language("la_ColHeader_FieldName"),1,0,$order,"width=\"30%\"","CustomData_LV_Sortfield","CustomData_LV_Sortorder","FieldName");
$objListView->ColumnHeaders->Add("FieldLabel",admin_language("la_ColHeader_FieldLabel"),1,0,$order,"width=\"30%\"","CustomData_LV_Sortfield","CustomData_LV_Sortorder","FieldLabel");
$objListView->ColumnHeaders->Add("Value",admin_language("la_ColHeader_Value"),1,0,$order,"width=\"40%\"","CustomData_LV_Sortfield","CustomData_LV_Sortorder","Value");
$objListView->ColumnHeaders->SetSort($objConfig->Get("CustomData_LV_Sortfield"), $objConfig->Get("CustomData_LV_Sortorder"));
$objListView->PrintToolBar = FALSE;
$objListView->checkboxes = FALSE;
$objListView->PageURL = "javascript:page_submit('edituser','".$adminURL."/users/adduser_custom.php',0,'{TargetPage}');";
$objListView->CurrentPageVar = "Page_CustomData";
$objListView->PerPageVar = "Perpage_CustomData";
//$objListView->CheckboxName = "itemlist[]";
for($i=0;$i<count($objCustomFields->Items);$i++)
{
$objListView->RowIcons[] = $imagesURL."/itemicons/icon16_custom.gif";
}
$objListView->PageLinks = $objListView->PrintPageLinks();
$objListView->SliceItems();
print $objListView->PrintList();
?>
<input type="hidden" name="ItemId" value="<?php echo $c->Get("ResourceId"); ?>">
<input type="hidden" name="Action" value="m_edit_custom_data">
<input type="hidden" name="UserEditStatus" VALUE="0">
</FORM>
<FORM method="POST" NAME="save_edit" ID="save_edit">
<tr <?php int_table_color(); ?>>
<td colspan="3">
</td>
</tr>
</FORM>
<!-- CODE FOR VIEW MENU -->
<form ID="viewmenu" method="post" action="<?php echo $_SERVER["PHP_SELF"]."?".$envar; ?>" name="viewmenu">
<input type="hidden" name="fieldname" value="">
<input type="hidden" name="varvalue" value="">
<input type="hidden" name="varvalue2" value="">
<input type="hidden" name="Action" value="">
</form>
-<script src="<?php echo $adminURL; ?>/listview/listview.js"></script>
-<script>
-initSelectiorContainers();
-<?php //echo $objListToolbar->Get("CheckClass").".setImages();"; ?>
-</script>
+
<?php int_footer(); ?>
Property changes on: trunk/admin/users/adduser_custom.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/users/adduser.php
===================================================================
--- trunk/admin/users/adduser.php (revision 103)
+++ trunk/admin/users/adduser.php (revision 104)
@@ -1,374 +1,375 @@
<?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");
unset($objEditItems);
$objEditItems = new clsUserManager();
$objEditItems->SourceTable = $objSession->GetEditTable("PortalUser");
$objEditItems->EnablePaging = FALSE;
$objCustomFields = new clsCustomFieldList(6);
$objRelList = new clsRelationshipList();
$objImages = new clsImageList();
//$objUserGroupsList = new clsUserGroupList();
//Multiedit init
if ($_GET["new"] == 1)
{
$c = new clsPortalUser(NULL);
$c->Set("CreatedOn", time());
$c->Set("Status", 2);
$en = 0;
$action = "m_add_user";
$objUsers->CreateEmptyEditTable("PortalUserId");
$objRelList->CreateEmptyEditTable("RelationshipId");
$objCustomDataList->CreateEmptyEditTable("CustomDataId");
$objImages->CreateEmptyEditTable("ResourceId");
//$objUserGroupsList->CreateEmptyEditTable("PortalUserId");
}
else
{
$en = (int)$_GET["en"];
if (isset($_POST["itemlist"]))
{
$objUsers->CopyToEditTable("ResourceId",$_POST["itemlist"]);
}
$objEditItems->Query_Item("SELECT * FROM ".$objEditItems->SourceTable);
$first=1;
foreach($objEditItems->Items as $u)
{
$objItemTypes->BuildUserItemTable($u->Get("PortalUserId"),$first);
$first=0;
}
if(isset($_POST["itemlist"]))
{
/* make a copy of the relationship records */
$ids = $objEditItems->GetResourceIDList();
$objRelList->CopyToEditTable("SourceId",$ids);
$objCustomDataList->CopyToEditTable("ResourceId",$ids);
$objImages->CopyToEditTable("ResourceId",$ids);
//$objUserGroupsList->CopyToEditTable("PortalUserId", $ids);
}
$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";
}
$envar = "env=" . BuildEnv() . "&en=$en";
$section = 'in-portal:edituser_general';
if (strlen($c->Get("Login")))
$editing_title = "'".$c->Get("Login")."' ";
else
$editing_title = "";
$title = prompt_language("la_Text_Editing")." ".prompt_language("la_Text_User")." $editing_title- ".prompt_language("la_tab_General");
//Display header
$sec = $objSections->GetSection($section);
$objCatToolBar = new clsToolBar();
$objCatToolBar->Add("img_save", "la_Save","#","swap('img_save','toolbar/tool_select_f2.gif');", "swap('img_save', 'toolbar/tool_select.gif');","edit_submit('edituser','UserEditStatus','".$admin."/users/user_list.php',1);","tool_select.gif");
$objCatToolBar->Add("img_cancel", "la_Cancel","#","swap('img_cancel','toolbar/tool_cancel_f2.gif');", "swap('img_cancel', 'toolbar/tool_cancel.gif');","edit_submit('edituser','UserEditStatus','".$admin."/users/user_list.php',2);","tool_cancel.gif");
if ( isset($en_prev) || isset($en_next) )
{
$url = $RootUrl.$admin."/users/adduser.php";
$StatusField = "UserEditStatus";
$form = "edituser";
MultiEditButtons($objCatToolBar,$en_next,$en_prev,$form,$StatusField,$url,$sec->Get("OnClick"),'','la_PrevUser','la_NextUser');
}
int_header($objCatToolBar,NULL,$title);
?>
<table width="100%" border="0" cellspacing="0" cellpadding="4" class="tableborder">
<form ID="edituser" name="edituser" action="" method=POST>
<?php int_subsection_title(prompt_language("la_Text_User")); ?>
<tr <?php int_table_color(); ?>>
<td valign="top"><span id="prompt_user_login" class="text"><?php echo prompt_language("la_prompt_Usermame"); ?></span></td>
<td>
- <input type="text" tabindex="1" name="user_login" ID="user_login" class="text" ValidationType="exists" size="20" value="<?php echo $c->parsetag("user_login"); ?>">
+ <input type="text" tabindex="1" name="user_login" ID="user_login" class="text" ValidationType="exists" size="20" value="<?php echo $dupe_user ? $dupe_user : $c->parsetag("user_login"); ?>">
+ <span class="validation_error"><?php if( isset($dupe_user) && $dupe_user ) echo admin_language($lvErrorString); ?></span>
</td>
<td></td>
</tr>
<tr <?php int_table_color(); ?>>
<td valign="top"><span ID="prompt_password" class="text"><?php echo prompt_language("la_prompt_Password"); ?></span></td>
<td>
<input type="password" id="password" tabindex="2" name="password" class="text" ValidationType="password" size="20" value="">
<?php if(!$_GET["new"]) echo prompt_language("la_password_info"); ?>
</td>
<td></td>
</tr>
<tr <?php int_table_color(); ?>>
<td valign="top"><span ID="prompt_password_verify" class="text"><?php echo prompt_language("la_prompt_PasswordRepeat"); ?></span></td>
<td>
<input type="password" id="password_verify" tabindex="4" name="password_verify" class="text" size="20" value="">
</td>
<td></td>
</tr>
<?php int_subsection_title(prompt_language("la_prompt_PersonalInfo")); ?>
<tr <?php int_table_color(); ?>>
<td valign="top"><span id="prompt_user_firstname" class="text"><?php echo prompt_language("la_prompt_FirstName"); ?></span></td>
<td>
<input type="text" name="user_firstname" class="text" tabindex="5" size="30" value="<?php echo $c->parsetag("user_firstname"); ?>">
</td>
<td></td>
</tr>
<tr <?php int_table_color(); ?>>
<td valign="top"><span id="prompt_user_lastname" class="text"><?php echo prompt_language("la_prompt_LastName"); ?></span></td>
<td>
<input type="text" name="user_lastname" class="text" tabindex="6" size="30" value="<?php echo $c->parsetag("user_lastname"); ?>">
</td>
<td></td>
</tr>
<tr <?php int_table_color(); ?>>
<td valign="top"><span ID="prompt_user_email" class="text"><?php echo prompt_language("la_prompt_Email"); ?></span></td>
<td>
<input type="text" ValidationType="exists" name="user_email" tabindex="7" ID="user_email" class="text" size="30" value="<?php echo $c->parsetag("user_email"); ?>">
</td>
<td><span class="text">&nbsp;</span></td>
</tr>
<tr <?php int_table_color(); ?>>
<td valign="top"><SPAN id="prompt_user_dob" class="text"><?php echo prompt_language("la_prompt_birthday"); ?></SPAN></td>
<td>
<input type="text" ValidationType="date,exists" tabindex="8" name="user_dob" id="user_dob_selector" datepickerIcon="<?php echo $adminURL; ?>/images/ddarrow.gif" class="text" size="20" value="<?php echo $c->parsetag("user_dob"); ?>">
<span class="small"><?php echo prompt_language("la_prompt_DateFormat"); ?></span></td>
<td></td>
</tr>
<tr <?php int_table_color(); ?>>
<td valign="top"><span id="prompt_user_phone" class="text"><?php echo prompt_language("la_prompt_Phone"); ?></span></td>
<td>
<input type="text" name="user_phone" tabindex="9" class="text" size="30" value="<?php echo $c->parsetag("user_phone"); ?>">
</td>
<td><span class="text">&nbsp;</span></td>
</tr>
<tr <?php int_table_color(); ?>>
<td valign="top"><span id="prompt_user_street" class="text"><?php echo prompt_language("la_prompt_Street"); ?></span></td>
<td>
<input type="text" name="user_street" tabindex="10" class="text" size="40" value="<?php echo $c->parsetag("user_street"); ?>">
</td>
<td><span class="text">&nbsp;</span></td>
</tr>
<tr <?php int_table_color(); ?>>
<td valign="top"><span id="prompt_user_city" class="text"><?php echo prompt_language("la_prompt_City"); ?></span></td>
<td>
<input type="text" name="user_city" class="text" tabindex="11" size="30" value="<?php echo $c->parsetag("user_city"); ?>">
</td>
<td><span class="text">&nbsp;</span></td>
</tr>
<tr <?php int_table_color(); ?>>
<td valign="top"><span id="prompt_user_state" class="text"><?php echo prompt_language("la_prompt_State"); ?></span></td>
<td>
<input type="text" name="user_state" class="text" tabindex="12" size="20" value="<?php echo $c->parsetag("user_state"); ?>">
</td>
<td><span class="text">&nbsp;</span></td>
</tr>
<tr <?php int_table_color(); ?>>
<td valign="top"><span id="prompt_user_zip" class="text"><?php echo prompt_language("la_prompt_Zip"); ?></span></td>
<td>
<input type="text" name="user_zip" class="text" size="15" tabindex="13" value="<?php echo $c->parsetag("user_zip"); ?>">
</td>
<td><span class="text">&nbsp;</span></td>
</tr>
<tr <?php int_table_color(); ?>>
<td valign="top"><span id="prompt_user_country" class="text"><?php echo prompt_language("la_prompt_Country"); ?></span></td>
<td>
<input type="text" name="user_country" class="text" tabindex="14" size="30" value="<?php echo $c->parsetag("user_country"); ?>">
</td>
<td><span class="text">&nbsp;</span></td>
</tr>
<?php int_subsection_title(prompt_language("la_prompt_Properties")); ?>
<tr <?php int_table_color(); ?>>
<td valign="top"><span id="prompt_status" class="text"><?php echo prompt_language("la_prompt_Status"); ?></span></td>
<td>
<input type="radio" name="status" class="text" tabindex="15" value="1" <?php if($c->Get("Status") == 1) echo "checked"; ?>><?php echo prompt_language("la_val_Active"); ?>
<input type="radio" name="status" class="text" tabindex="15" value="2" <?php if($c->Get("Status") == 2) echo "checked"; ?>><?php echo prompt_language("la_val_Pending"); ?>
<input type="radio" name="status" class="text" tabindex="15" value="0" <?php if($c->Get("Status") == 0) echo "checked"; ?>><?php echo prompt_language("la_val_Disabled"); ?>
</td>
<td class="text">&nbsp;</td>
</tr>
<tr <?php int_table_color(); ?>>
<td valign="top"><SPAN id="prompt_user_date" class="text"><?php echo prompt_language("la_prompt_CreatedOn"); ?></SPAN></td>
<td>
<input type="text" name="user_date" id="user_date_selector" tabindex="16" datepickerIcon="<?php echo $adminURL; ?>/images/ddarrow.gif" class="text" size="20" value="<?php echo $c->parsetag("user_date"); ?>">
<span class="small"><?php echo prompt_language("la_prompt_DateFormat"); ?></span></td>
<td></td>
</tr>
<?php
$CustomFieldUI = $objCustomFields->GetFieldUIList(TRUE);
if($CustomFieldUI->NumItems()>0)
{
$objCustomDataList->SetTable('edit');
if((int)$c->Get("ResourceId")>0)
$objCustomDataList->LoadResource($c->Get("ResourceId"));
$headings = $CustomFieldUI->GetHeadingList();
//echo "<PRE>";print_r($objCustomFields); echo "</PRE>";
for($i=0;$i<=count($headings);$i++)
{
$h = $headings[$i];
if(strlen($h))
{
int_subsection_title(prompt_language($h));
$Items = $CustomFieldUI->GetHeadingItems($h);
foreach($Items as $f)
{
$n = substr($f->name,1);
$cfield = $objCustomFields->GetItemByField("FieldName",$n,FALSE);
if(is_object($cfield))
{
$cv = $objCustomDataList->GetDataItem($cfield->Get("CustomFieldId"));
if(is_object($cv))
{
$f->default_value = $cv->Get("Value");
}
}
print "<tr ".int_table_color_ret().">\n";
print " <td valign=\"top\"><span class=\"text\">".$f->GetPrompt()."</span></td>\n";
print " <td nowrap>".$f->ItemFormElement()."</TD>";
if(is_object($f->NextItem))
{
$n = $f->NextItem;
print " <td>".$n->ItemFormElement()."</TD>";
}
else
print " <td><span class=\"text\">&nbsp;</span></td>\n";
print "</tr>\n";
}
}
}
$objCustomDataList->SetTable('live');
}
?>
<tr <?php int_table_color(); ?>>
<td colspan="3">
<input type="hidden" name="Action" value="<?php echo $action; ?>">
<input type="hidden" name="user_id" value="<?php echo $c->Get("PortalUserId"); ?>">
<input type="hidden" name="UserEditStatus" VALUE="0">
</td>
</tr>
</td>
</tr>
</table>
</form>
<script src="<?php echo $adminURL; ?>/include/calendar.js"></script>
<SCRIPT language="JavaScript">
initCalendar("user_date_selector", CalDateFormat);
initCalendar("user_dob_selector", CalDateFormat);
</SCRIPT>
<?php
MarkFields('edituser');
int_footer();
?>
\ No newline at end of file
Property changes on: trunk/admin/users/adduser.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/tabs.js
===================================================================
--- trunk/admin/include/tabs.js (revision 103)
+++ trunk/admin/include/tabs.js (revision 104)
@@ -1,261 +1,261 @@
//parses input tags looking for validation attributes
function DataIsValid(f)
{
var ValType = '';
var span_id = '';
var form_result = true;
var field_result = true;
var j = 0;
for (var i = 0; i < f.elements.length; i++)
{
ValType = '';
Field = f.elements[i];
ValType = Field.getAttribute('ValidationType');
if(ValType)
{
ValType = TransformValidationType(ValType); // for capability with old forms
span_id = 'prompt_' + Field.name;
span = document.getElementById(span_id);
if(span)
{
field_result = true;
ValType = ValType.split(',');
j = 0;
while(j < ValType.length)
{
//alert('Validating ['+Field.name+'] as ['+ValType[j]+']');
if(ValType[j] == 'password')
{
var repasswd = document.getElementById(Field.name + '_verify');
if(repasswd)
{
field_result &= ValidateField(Field.value, ValType[j], repasswd.value);
document.getElementById('prompt_' + Field.name + '_verify').className = field_result ? 'text' : 'validation_error';
}
}
else
field_result &= ValidateField(Field.value, ValType[j]);
j++;
}
span.className = field_result ? 'text' : 'validation_error';
form_result &= field_result;
}
}
}
return form_result;
}
function TransformValidationType(OldType)
{
// replace old validation types with new
// on the fly in case if we have some forms
// that still use old validation types
var NewType = '';
switch(OldType)
{
case 'optional_date':
NewType = 'date';
break;
default:
NewType = OldType;
break;
}
return NewType;
}
function ValidateField(FieldValue, ValidateAs, RePasswdValue)
{
// validate FieldValue based on ValidateAs rule specified;
// in case if password field compare it with RePasswdValue
var result = true;
switch(ValidateAs)
{
case 'exists': // field is required
if(FieldValue.length == 0) result = false;
break;
case 'integer': // field must be integer number
result = ValidateNumber(FieldValue, ValidateAs);
break;
case 'password': // validate as password field
result = (FieldValue == RePasswdValue) || (FieldValue.length == 0);
break;
case 'date': // text must be a formatted date
result = ValidDate(FieldValue);
break;
case 'time': // text must be a formatted time
result = ValidTime(FieldValue);
break;
}
return result;
}
function MarkAsRequired(f)
{
var ValType = '';
var span_id = '';
var result = true;
for (var i = 0; i < f.elements.length; i++)
{
ValType = '';
Field = f.elements[i];
ValType = Field.getAttribute('ValidationType');
if(ValType)
{
ValType = ValType.split(',');
if( InArray(ValType,'exists') !== false )
{
span_id = 'prompt_' + Field.name;
span = document.getElementById(span_id);
span.innerHTML = span.innerHTML + '<span class="error">*</span>';
}
}
}
}
function InArray(aArray, aValue)
{
// checks if element in array
var k = 0;
while(k < aArray.length)
{
if(aArray[k] == aValue) return k;
k++;
}
return false;
}
//Used to submit the form when a tab is clicked on
function edit_submit(formname, status_field, targetURL, save_value, env_str, new_target)
{
var full_env = env;
if(env_str != null) full_env += env_str;
if(full_env.substr(0,3)!="env")
full_env = 'env='+full_env;
-
+
f = document.getElementById(formname);
if(f)
{
var valid = false;
if(save_value != 2 && save_value !=-1)
{
valid = DataIsValid(f);
}
else
{
var a = f.Action;
if(a)
{
a.value='';
}
}
if(valid || save_value==2 || save_value==-1)
{
f.action = rootURL + targetURL + '?' + full_env;
if(status_field.length>0)
{
f.elements[status_field].value = save_value; //0= stay in temp, 1=save to perm, 2 = purge no save
}
if(new_target != null && typeof(new_target) != 'undefined') f.target = new_target;
f.submit();
}
else
if(!valid)
alert(ErrorMsg);
}
else
alert('Form '+formname+' was not found.');
}
//Used when the save or cancel buttin is hit
function do_edit_save(formname, status_field, targetURL, save_value,env_str)
{
var full_env = env;
if(env_str != null) full_env += env_str;
if(full_env.substr(0,3)!="env")
full_env = 'env='+full_env;
f = document.getElementById(formname);
if(f)
{
f.action = rootURL + targetURL + '?' + full_env;
//alert(f.action);
if(status_field.length>0)
{
f.elements[status_field].value = save_value; //0= stay in temp, 1=save to perm, 2 = purge no save
}
f.submit();
}
else
alert('Form '+formname+' was not found.');
}
function jump_to_url(targetURL,env_str)
{
var full_env = env;
if(env_str != null) full_env += env_str;
if(full_env.substr(0,3)!="env")
full_env = 'env='+full_env;
document.location = rootURL + targetURL + '?' + full_env;
}
// -------------------------------------------------------------------------------------------------------------
function submit_form(formname, status_field, targetURL, save_value,env_str)
{
// by Alex, submits form.
var full_env = env;
if(env_str != null) full_env += env_str;
if(full_env.substr(0,3)!="env")
full_env = 'env='+full_env;
f = document.getElementById(formname);
if(f)
{
var valid = false;
if(save_value != 2 && save_value !=-1)
{
valid = DataIsValid(f);
}
else
{
var a = f.Action;
if(a)
{
a.value='';
}
}
if(valid || save_value==2 || save_value==-1)
{
f.action = rootURL + targetURL + '?' + full_env;
if(status_field.length>0)
{
f.elements[status_field].value = save_value; //0= stay in temp, 1=save to perm, 2 = purge no save
}
f.submit();
}
else
if(!valid)
alert(ErrorMsg);
}
else
alert('Form '+formname+' was not found.');
}
\ No newline at end of file
Property changes on: trunk/admin/include/tabs.js
___________________________________________________________________
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/listview/listview.php
===================================================================
--- trunk/admin/listview/listview.php (revision 103)
+++ trunk/admin/listview/listview.php (revision 104)
@@ -1,471 +1,473 @@
<?php
require($pathtoroot.$admin."/listview/columnheader.php");
require($pathtoroot.$admin."/listview/viewmenu.php");
class clsListView
{
var $Formatters = Array(); // formatters to apply while printing list
var $ColumnHeaders;
var $ToolBar;
var $ListItems;
var $PageLinkTemplate;
var $PerPageVar;
var $CurrentPageVar;
var $CurrentPage;
var $TotalItemCount;
var $SortField;
var $SortOrder;
var $IdField;
var $PrintToolBar=TRUE;
var $ShowColumnHeaders=TRUE;
var $checkboxes=TRUE;
var $SelectorType;
var $CheckboxName;
var $CheckArray;
var $RowIcons;
var $SearchBar=FALSE;
var $SearchKeywords;
var $SearchAction;
var $SearchDropdownId="";
var $PageLinks;
var $extra_env;
var $PriorityField;
var $PageURL;
var $ViewMenu;
var $JSCheckboxName;
function clsListView($ToolBar=NULL,$ListItems=NULL)
{
$this->SetToolBar($ToolBar);
$this->SetListItems($ListItems);
$this->ColumnHeaders = new clsColumnHeaderList();
$this->CurrentPage=1;
$this->CheckboxName = "itemlist[]";
$this->SelectorType="checkbox";
$this->RowIcons = array();
$this->PageLinks = "";
$this->SearchAction = "";
$this->extra_env="";
$this->PriorityField="Priority";
$this->TotalItemCount = 0;
if (!is_null($ToolBar))
$this->JSCheckboxName = $ToolBar->Get("CheckClass");
$this->SetFormatters(); // for setting custom formatters
}
function SetToolbar($ToolBar)
{
$this->ToolBar=$ToolBar;
if(is_object($this->ToolBar))
$this->CheckArray=$this->ToolBar->Get("CheckClass");
}
function GetPage()
{
// get current page
$this->RefreshPageVar();
return $this->CurrentPage;
}
function GetLimitSQL()
{
return GetLimitSQL($this->GetPage(), $this->GetPerPage() );
}
function SetListItems($ListItems)
{
$this->ListItems = $ListItems;
}
function SetIDfield($field)
{
$this->IdField = $field;
}
function SetSort($SortField,$SortOrderVariable)
{
$this->ColumnHeaders->SetSort($SortField,$SortOrder);
}
function SetRowIcon($index,$url)
{
$this->RowIcons[$index] = $url;
}
function ConfigureViewMenu($SortFieldVar,$SortOrderVar,$DefaultSort,$FilterVar,$FilterValue,$FilterMax)
{
global $objConfig;
//$FilterVal = $this->CurrentFilter;
//$fMax = $this->Filtermax;
//$sOrder = $this->CurrentSortOrder;
//$sOrderVar = $this->OrderVar;
//$sField = $this->CurrentSortField;
//$sDefault = $this->DefaultSortField;
$this->ViewMenu = new clsViewMenu();
$this->ViewMenu->PerPageVar = $this->PerPageVar;
$this->ViewMenu->PerPageValue = (int)$objConfig->Get($this->PerPageVar);
if($this->ViewMenu->PerPageValue==0)
$this->ViewMenu->PerPageValue = 20;
$this->ViewMenu->CurrentSortField = $objConfig->Get($SortFieldVar);
$this->ViewMenu->CurrentSortOrder = $objConfig->get($SortOrderVar);
$this->ViewMenu->SortVar = $SortFieldVar;
$this->ViewMenu->OrderVar = $SortOrderVar;
$this->ViewMenu->CurrentFilter= $FilterValue;
$this->ViewMenu->FilterVar = $FilterVar;
$this->ViewMenu->FilterMax = $FilterMax;
foreach($this->ColumnHeaders->Columns as $col)
{
$this->ViewMenu->AddSortField($col->field,$col->label,$DefaultSort==$col->field);
}
}
function AddViewMenuFilter($Label,$Bit)
{
if(is_object($this->ViewMenu))
$this->ViewMenu->AddFilterField($Label,$Bit);
}
function GetViewMenu($imagesURL)
{
if(is_object($this->ViewMenu))
{
$this->ViewMenu->CheckboxName = $this->JSCheckboxName;
return $this->ViewMenu->GetViewMenuJS($imagesURL);
}
else
return "";
}
function SetFormatters()
{
// for setting custom formatters
// abstract
}
function SetFormatter($field, $type, $params)
{
// by Alex
// all params after 2nd are formmater type specific
$this->Formatters[$field]['type'] = $type;
switch($type)
{
case FT_OPTION:
$this->Formatters[$field]['options'] = $params;
break;
}
}
function PrintItem($index)
{
if( !isset($this->ListItems->Items[$index]) ) return '';
$li = $this->ListItems->Items[$index];
$o = "";
$first=1;
if(is_object($li))
{
// ==== new by Alex: begin ====
$li->Formatters =& $this->Formatters;
// ==== new by Alex: end ====
$id_field = $this->IdField;
$row_id = $li->Get($id_field);
if(is_numeric($li->Get($this->PriorityField)))
{
$Priority = (int)$li->Get($this->PriorityField);
}
else
$Priority=0;
$o = "<TR ".int_table_color_ret()." ID=\"$row_id\">\n";
foreach($this->ColumnHeaders->Columns as $col)
{
$width="";
$ColId = $row_id."_col_".$col->field;
if($first==1)
{
if(strlen($col->width))
{
$width = $col->width;
}
$o .= "<TD $width valign=\"top\" class=\"text\">";
if($this->checkboxes)
{
$onclick = "onclick=\"if (this.checked) {".$this->CheckArray.".addCheck('$row_id');} else {".$this->CheckArray.".removeCheck('$row_id');}\"";
$onclicksrc = "onclicksrc=\"if (this.checked) {".$this->CheckArray.".addCheck('$row_id');} else {".$this->CheckArray.".removeCheck('$row_id');}\"";
$o .= "<input rowId='".$row_id."' checkArrayName='".$this->CheckArray."' isSelector=\"true\" type=\"".$this->SelectorType."\" name=\"".$this->CheckboxName."\" value=\"$row_id\" $onclick $onclicksrc>";
}
if(isset($this->RowIcons[$index]))
{
$url = $this->RowIcons[$index];
if(strlen($url))
$o .= "<img src=\"".$url."\"> ";
}
$first=0;
}
else
{
if(strlen($col->width))
{
$o .= "<TD ".$col->width.">";
}
else
$o .= "<TD>";
}
if($Priority!=0)
{
$o .= "<span class=\"priority\"><sup>$Priority</sup></span>";
$Priority=0;
}
$o .= "<SPAN ID=\"$ColId\">".stripslashes($li->GetFormatted($col->field))."</SPAN></TD>\n";
}
$o .= "</TR>\n";
}
return $o;
}
function PrintItems()
{
$o = '';
$numitems = $this->ListItems->NumItems();
for($index=0;$index<=$numitems;$index++)
{
$o .= $this->PrintItem($index);
}
return $o;
}
function TotalPageNumbers()
{
if($this->PerPage>0)
{
$ret = $this->ListItems->NumItems() / $this->PerPage;
$ret = (int)$ret;
}
else
$ret = 1;
return $ret;
}
function GetPerPage()
{
global $objConfig;
$PerPage = $objConfig->Get($this->PerPageVar);
if($PerPage < 1)
{
if( defined('DEBUG_MODE') ) echo 'PerPage Variable [<b>'.$this->PerPageVar.'</b>] not defined in Config<br>';
$PerPage = 20;
//$objConfig->Set($this->PerPageVar,20);
//$objConfig->Save();
}
return $PerPage;
}
function GetAdminPageLinkList($url)
{
global $objConfig;
$PerPage = $this->GetPerPage();
if($this->TotalItemCount>0)
{
$NumPages = ceil($this->TotalItemCount / $PerPage);
}
else
$NumPages = ceil($this->ListItems->NumItems() / $PerPage);
if($NumPages<1)
$NumPages =1;
//echo $this->CurrentPage." of ".$NumPages." Pages";
$o = "";
if($this->CurrentPage>$NumPages)
$this->CurrentPage=$NumPages;
$StartPage = $this->CurrentPage - 5;
if($StartPage<1)
$StartPage=1;
$EndPage = $StartPage+9;
if($EndPage>$NumPages)
{
$EndPage = $NumPages;
$StartPage = $EndPage-10;
if($StartPage<1)
$StartPage=1;
}
$o .= "<b class=\"text\">".admin_language("la_Page")."</b> ";
if($StartPage>1)
{
$target = $this->CurrentPage-10;
$prev_url = str_replace("{TargetPage}",$target,$url);
$o .= "<A HREF=\"$prev_url\" class=\"NAV_URL\"><<</A>";
}
for($p=$StartPage;$p<=$EndPage;$p++)
{
if($p!=$this->CurrentPage)
{
$href = str_replace("{TargetPage}",$p,$url);
$o .= " <A HREF=\"$href\" class=\"NAV_URL\">$p</A> ";
}
else
{
$o .= " <SPAN class=\"CURRENT_PAGE\">$p</SPAN> ";
}
}
if($EndPage<$NumPages-1)
{
$target = $this->CurrentPage+10;
$next_url = str_replace("{TargetPage}",$target,$url);
$o .= "<A HREF=\"$next_url\" class=\"NAV_URL\"> &gt;&gt;</A>";
}
return $o;
}
function SliceItems()
{
global $objConfig;
$PerPage = (int)$objConfig->Get($this->PerPageVar);
if($PerPage<1)
$PerPage=20;
$NumPages = ceil($this->ListItems->NumItems() / $PerPage);
if($NumPages>1)
{
$Start = ($this->CurrentPage-1)*$PerPage;
$this->ListItems->Items = array_slice($this->ListItems->Items,$Start,$PerPage);
}
}
function RefreshPageVar()
{
global $objSession;
if( (int)GetVar('lpn') > 0)
{
$this->CurrentPage = $_GET["lpn"];
$objSession->SetVariable($this->CurrentPageVar,$this->CurrentPage);
}
else
$this->CurrentPage = $objSession->GetVariable($this->CurrentPageVar);
$this->ListItems->Page = $this->CurrentPage;
}
function PrintPageLinks()
{
- global $imagesURL,$objSession,$lvErrorString;
+ global $imagesURL, $objSession, $lvErrorString;
+
if(strlen($this->PageLinks)>0)
{
return $this->PageLinks;
}
$this->RefreshPageVar();
if($this->CurrentPage<1)
$this->CurrentPage = 1;
if(!strlen($this->PageURL))
{
$this->PageURL = $_SERVER["PHP_SELF"]."?env=".BuildEnv();
if(strlen($this->extra_env))
$this->PageURL .= "&".$this->extra_env;
$this->PageURL .= "&lpn={TargetPage}";
}
$cols = $this->ColumnHeaders->Count();
$o = "<TABLE cellSpacing=0 cellPadding=2 width=\"100%\" class=\"pagenav\"><tbody><TR >\n";
+
if(strlen($lvErrorString))
{
$o .= "<TD STYLE=\"border-bottom: 1px solid #000000;\" colspan=2><span class=\"validation_error\">$lvErrorString</SPAN></TD></TR><TR>";
}
if($this->SearchBar==FALSE)
{
$o .= "<TD colspan=2>";
$o .= $this->GetAdminPageLinkList($this->PageURL);
$o .= "</TD>\n";
}
else
{
$val = str_replace(","," ", $this->SearchKeywords);
$o .= "<TD>";
$o .= $this->GetAdminPageLinkList($this->PageURL)."</TD>";
$o .= "<TD align=\"right\" valign=\"top\">".admin_language("la_prompt_Search");
$o .= " <INPUT TYPE=\"TEXT\" ID=\"ListSearchWord\" NAME=\"ListSearchWord\" VALUE=\"$val\">";
$o .= " <IMG align=\"middle\" height=24 width=24 name=\"imgSearch\" ID=\"imgSearch\" src=\"$imagesURL/itemicons/icon16_search.gif\" ";
$o .= " onMouseOut=\"swap('imgSearch', '$imagesURL/itemicons/icon16_search.gif');\" ";
$o .= " onMouseOver=\"swap('imgSearch','$imagesURL/itemicons/icon16_search_f2.gif');\" ";
$o .= " onClick=\"Submit_ListSearch('".$this->SearchAction."');\">";
$o .= " <IMG align=\"middle\" height=24 width=24 name=\"imgResetSearch\" ID=\"imgResetSearch\" src=\"$imagesURL/itemicons/icon16_search_reset.gif\" ";
$o .= " onMouseOut=\"swap('imgResetSearch', '$imagesURL/itemicons/icon16_search_reset.gif');\" ";
$o .= " onMouseOver=\"swap('imgResetSearch','$imagesURL/itemicons/icon16_search_reset_f2.gif');\" ";
$o .= " onClick=\"Submit_ListSearch('".$this->SearchAction."_reset');\">";
if(strlen($this->SearchDropdownId)>0)
{
$o .= " <IMG height=16 width=16 name=\"imgSearchDropDown\" src=\"$imagesURL/itemicons/icon16_search_dropdown.gif\" ";
$o .= " onMouseOut=\"swap('imgResetDropDown', '$imagesURL/itemicons/icon16_search_dropdown.gif');\" ";
$o .= " onMouseOver=\"swap('imgResetDropDown','$imagesURL/itemicons/icon16_search_dropdown.gif');\" ";
$o .= " onClick=\"ListSearch_PopUp('".$this->SearchDropdownId."');\">";
}
$o .= "</TD>";
}
$o .= "</TR></TABLE>";
return $o;
}
function PrintJavaScriptInit()
{
$o = '';
if($this->checkboxes)
{
$o = "<script language=\"javascript\">\n";
$o .="<!--\n";
foreach($this->ListItems->Items as $li)
{
$o .= $this->CheckArray.".CheckList[".$this->CheckArray.".CheckList.length] = '".$li->Get($this->IdField)."';\n";
}
$o .= $this->CheckArray.".setImages();\n";
$o .="//-->\n";
$o .="</script>";
}
return $o;
}
function PrintList()
{
global $objSession;
if((int)$this->CurrentPage<1)
$this->CurrentPage=1;
$o = "\n";
if(is_object($this->ToolBar))
{
if($this->PrintToolBar)
$o .= $this->ToolBar->Build();
}
$o .= $this->PrintPageLinks();
$o .= "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"4\" class=\"tableborder\">\n";
if($this->ShowColumnHeaders)
{
$o .= $this->ColumnHeaders->PrintColumns();
}
if($this->ListItems->NumItems()>0)
{
$o .= $this->PrintItems();
}
$o .= "</TABLE>";
if($this->ListItems->NumItems()>0)
$o .= $this->PrintJavaScriptInit();
return $o;
}
}
Property changes on: trunk/admin/listview/listview.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.1
\ No newline at end of property
+1.2
\ No newline at end of property

Event Timeline