Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F772699
in-portal
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Feb 1, 3:43 PM
Size
132 KB
Mime Type
text/x-diff
Expires
Mon, Feb 3, 3:43 PM (1 d, 4 h)
Engine
blob
Format
Raw Data
Handle
556004
Attached To
rINP In-Portal
in-portal
View Options
Index: trunk/kernel/action.php
===================================================================
--- trunk/kernel/action.php (revision 17)
+++ trunk/kernel/action.php (revision 18)
@@ -1,2125 +1,2132 @@
<?php
/*
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->LoadResource($u->Get("ResourceId"));
$CustomFields = new clsCustomFieldList(6);
$DataChanged = FALSE;
foreach($_POST as $key=>$value)
{
if(substr($key,0,1)=="_")
{
$field = substr($key,1);
$cvalue = $CustomFields->GetItemByField("FieldName",$field,FALSE);
if(is_object($cvalue))
{
$objCustomEdit->SetFieldValue($cvalue->Get("CustomFieldId"),$u->Get("ResourceId"),$value);
$DataChanged = TRUE;
}
}
}
if($DataChanged)
$objCustomEdit->SaveData();
}
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->LoadResource($u->Get("ResourceId"));
$CustomFields = new clsCustomFieldList(6);
$DataChanged = FALSE;
foreach($_POST as $key=>$value)
{
if(substr($key,0,1)=="_")
{
$field = substr($key,1);
$cvalue = $CustomFields->GetItemByField("FieldName",$field,FALSE);
if(is_object($cvalue))
{
$objCustomEdit->SetFieldValue($cvalue->Get("CustomFieldId"),$u->Get("ResourceId"),$value);
$DataChanged = TRUE;
}
}
}
if($DataChanged)
$objCustomEdit->SaveData();
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"));
$ado = GetADODBConnection();
if($id && is_array($_POST["CustomData"]))
{
foreach($_POST["CustomData"] as $FieldId => $Value)
{
$sql = "SELECT count(*) as reccount FROM ".$objEditData->SourceTable." WHERE CustomFieldId=$FieldId AND ResourceId=".$_POST["ItemId"];
$rs = $ado->Execute($sql);
$intable = $rs->fields["reccount"];
if(!$intable)
{
$sql = "INSERT INTO ".$objEditData->SourceTable." (ResourceId,CustomFieldId,Value) VALUES ('".$id."','$FieldId','$Value')";
$ado->Execute($sql);
//echo $sql."<br>\n";
}
else
{
$sql = "UPDATE ".$objEditData->SourceTable." SET Value='".$Value."' WHERE CustomFieldId=$FieldId AND ResourceId=".$_POST["ItemId"];
$ado->Execute($sql);
//echo $sql."<br>\n";
}
}
}
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"];
$filename=$_POST["filename"];
if(strlen($filename)>0)
{
$ExportFilename = $pathtoroot.$admin."/export/".$filename;
$ExportResult = $objLanguages->ExportPhrases($ExportFilename,$Ids);
}
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);
}
}
}
}
}
}
/* 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();
- $objImages = new clsImageList();
- $objImages->CopyFromEditTable("ImageId");
+
+ 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");
- $objImages = new clsImageList();
- $objImages->PurgeEditTable("ImageId");
+ 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();
}
?>
Property changes on: trunk/kernel/action.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/image.php
===================================================================
--- trunk/kernel/include/image.php (revision 17)
+++ trunk/kernel/include/image.php (revision 18)
@@ -1,1122 +1,1130 @@
<?php
class clsImage extends clsParsedItem
{
var $Pending;
function clsImage($id=NULL)
{
global $objSession;
$this->clsParsedItem();
$this->tablename = GetTablePrefix()."Images";
$this->Pending = FALSE;
$this->id_field = "ImageId";
$this->type=-30;
$this->TagPrefix = "image";
$this->NoResourceId=1;
if($id)
$this->LoadFromDatabase($id);
//$this->SetDebugLevel(0);
}
function GetFileName($thumb = 0)
{
global $pathtoroot;
if($thumb)
{
$p = $this->Get("ThumbPath");
}
else
{
$p = $this->Get("LocalPath");
if(!strlen($p) && $this->Get("SameImages"))
{
$p = $this->Get("ThumbPath");
}
}
if(strlen($p))
{
$parts = pathinfo($pathtoroot.$p);
$filename = $parts["basename"];
}
else
$filename = "";
return $filename;
}
function GetImageDir()
{
global $pathtoroot;
$p = $this->Get("ThumbPath");
if(strlen($p))
{
$parts = pathinfo($pathtoroot.$p);
$d = $parts["dirname"]."/";
}
if($this->Pending)
$d .= "pending/";
return $d;
}
function Delete()
{
$this->DeleteLocalImage();
parent::Delete();
}
function LoadFromDatabase($Id)
{
global $Errors;
if(!isset($Id))
{
$Errors->AddError("error.AppError",NULL,'Internal error: LoadFromDatabase id',"",get_class($this),"LoadFromDatabase");
return false;
}
$sql = sprintf("SELECT * FROM ".$this->tablename." WHERE ImageId = '%s'",$Id);
$result = $this->adodbConnection->Execute($sql);
if ($result === false || $result->EOF)
{
$Errors->AddError("error.DatabaseError",NULL,$this->adodbConnection->ErrorMsg(),"",get_class($this),"LoadFromDatabase");
return false;
}
$data = $result->fields;
$this->SetFromArray($data);
$this->Clean();
return true;
}
function LoadFromResource($Id,$ImageIndex)
{
global $Errors;
if(!isset($Id) || !isset($ImageIndex))
{
$Errors->AddError("error.AppError",NULL,'Internal error: LoadFromDatabase id',"",get_class($this),"LoadFromResource");
return false;
}
$sql = sprintf("SELECT * FROM ".$this->tablename." WHERE ResourceId = '%s'AND ImageIndex = '%s'",$Id,$ImageIndex);
$result = $this->adodbConnection->Execute($sql);
if ($result === false || $result->EOF)
{
// $Errors->AddError("error.DatabaseError",NULL,$this->adodbConnection->ErrorMsg(),"",get_class($this),"LoadFromResource");
return false;
}
$data = $result->fields;
$this->SetFromArray($data);
return true;
}
function LocalImageExists()
{
global $objConfig, $pathtoroot;
$result=FALSE;
if($this->Get("LocalImage")==1 && $this->Get("SameImages")==0)
{
//$imagepath = $pathtoroot.$this->Get("LocalPath");
$imagepath = $this->GetImageDir().$this->GetFileName();
// echo "PATH: ".$this->GetImageDir()."; FILE: ".$this->GetFileName()."<BR>";
if(strlen($imagepath)>0)
{
$result = file_exists($imagepath);
}
}
return $result;
}
function LocalThumbExists()
{
$result=FALSE;
global $objConfig, $pathtoroot;
if($this->Get("LocalThumb")==1)
{
//$imagepath = $pathtoroot.$this->Get("ThumbPath");
$imagepath = $this->GetImageDir().$this->GetFileName(1);
if(strlen($imagepath)>0)
{
$result = file_exists($imagepath);
}
}
return $result;
}
function DeleteLocalImage($Thumb=TRUE,$Full=TRUE)
{
global $pathtoroot;
if($Full)
{
if($this->LocalImageExists())
{
$filename = $this->GetImageDir().$this->GetFileName();
// echo "FULL: $filename<BR>\n";
@unlink($filename);
}
}
if($Thumb)
{
if($this->LocalThumbExists())
{
$filename = $this->GetImageDir().$this->GetFileName(1);
// echo "THUMB: $filename<BR>\n";
@unlink($filename);
}
}
}
function StoreUploadedImage($file, $rewrite_name=1,$DestDir,$IsThumb=0,$IsUpload=TRUE)
{
/* move the uploaded image to its final location and update the LocalPath property */
/* returns the destination filename on success */
global $objConfig,$pathtoroot;
$Dest_Dir = $DestDir;
if($this->Pending)
$Dest_Dir .= "pending/";
if(((int)$file["error"]==0) && (substr($file["type"],0,6)=="image/"))
{
$parts = pathinfo($file["name"]);
$ext = strtolower($parts["extension"]);
if((int)$_GLOBALS["debuglevel"])
echo "Processing ".$file["tmp_name"]."<br>\n";
if($rewrite_name==1)
{
if($IsThumb)
$filename = "th_";
$filename .= $this->Get("ResourceId")."_".$this->Get("ImageIndex").".".$ext;
}
else
{
$filename = $file["name"];
}
$destination = $pathtoroot.$Dest_Dir.$filename;
if((int)$_GLOBALS["debuglevel"])
echo $file["tmp_name"]."=>".$destination."<br>\n";
if(IsUpload==TRUE)
{
$result = @move_uploaded_file($file["tmp_name"],$destination);
}
else
$result = copy($file["tmp_name"],$destination);
if($result)
{
return $Dest_Dir.$filename;
}
else
return "";
}
else
return "";
}
function CopyToPending()
{
global $pathtoroot;
$ThumbPath = (strlen($this->Get("ThumbPath"))>0) ? $pathtoroot.$this->Get("ThumbPath") : '';
$FullPath = strlen($this->Get("LocalPath")) ? $pathtoroot.$this->Get("LocalPath") : '';
$dest = $this->GetImageDir()."pending/";
// echo "DESTIN DIR: $dest<BR>";
// echo "THUMB PATH: $ThumbPath <BR>";
if(strlen($ThumbPath))
{
if(file_exists($ThumbPath))
{
$p = pathinfo($ThumbPath);
$d = $dest.$p["basename"];
if(file_exists($d))
unlink($d);
copy($ThumbPath,$d);
}
}
if(strlen($FullPath))
{
if(file_exists($FullPath))
{
$p = pathinfo($FullPath);
$d = $dest.$p["basename"];
if(file_exists($d))
unlink($d);
copy($FullPath,$d);
}
}
}
function CopyFromPending()
{
global $pathtoroot,$pathchar;
$ThumbPath = $this->Get("ThumbPath");
$FullPath = $this->Get("LocalPath");
// $src = $this->GetImageDir()."pending/";
$src = $this->GetImageDir();
if(strlen($ThumbPath))
{
if(strpos($ThumbPath,"pending/"))
{
if(file_exists($pathtoroot.$ThumbPath))
{
$path = pathinfo($pathtoroot.$ThumbPath);
$p = explode("/",$ThumbPath);
unset($p[count($p)-2]);
$d = $pathtoroot.implode("/",$p);
if(file_exists($d))
unlink($d);
copy($pathtoroot.$ThumbPath,$d);
unlink($pathtoroot.$ThumbPath);
}
}
}
if(strlen($FullPath))
{
if(file_exists($pathtoroot.$FullPath))
{
if(strpos($FullPath,"pending/"))
{
$path = pathinfo($pathtoroot.$FullPath);
$p = explode("/",$FullPath);
unset($p[count($p)-2]);
$d = $pathtoroot.implode("/",$p);
if(file_exists($d))
unlink($d);
copy($pathtoroot.$FullPath,$d);
unlink($pathtoroot.$FullPath);
}
}
}
}
function DeleteFromPending()
{
$ThumbPath = $pathtoroot.$this->Get("ThumbPath");
$FullPath = $pathtoroot.$this->Get("LocalPath");
$src = $this->GetImageDir()."pending/";
$p = pathinfo($ThumbPath);
$d = $src.$p["basename"];
if(file_exists($d))
@unlink($d);
$p = pathinfo($FullPath);
$d = $src.$p["basename"];
if(file_exists($d))
@unlink($d);
}
function RenameFiles($OldResId,$NewResId)
{
global $pathtoroot;
if($this->Pending)
{
$ThumbPath = $this->GetImageDir().$this->GetFileName(TRUE);
}
else
$ThumbPath = $pathtoroot.$this->Get("ThumbPath");
$parts = pathinfo($ThumbPath);
$ext = $parts["extension"];
$pending="";
if($this->Pending)
{
$pending="pending/";
$FullPath = $this->GetImageDir().$this->GetFileName(FALSE);
}
else
$FullPath = $pathtoroot.$this->Get("LocalPath");
$NewThumb = $pathtoroot."kernel/images/".$pending."th_$NewResId_".$this->Get("ImageIndex").".$ext";
$NewFull = $pathtoroot."kernel/images/".$pending."$NewResId_".$this->Get("ImageIndex").".$ext";
if(file_exists($ThumbPath))
{
@rename($ThumbPath,$NewThumb);
}
if(file_exists($FullPath))
{
@rename($FullPath,$NewFull);
}
}
function ReplaceImageFile($file)
{
global $objConfig;
if($file["error"]==0)
{
$this->DeleteLocalImage();
move_uploaded_file($file,$this->Get("LocalPath"));
}
}
function FullURL($ForceNoThumb=FALSE,$Default="kernel/images/noimage.gif")
{
global $rootURL, $objConfig,$pathtoroot;
if($this->Get("SameImages") && !$ForceNoThumb)
return $this->ThumbURL();
if(strlen($this->Get("Url")))
return $this->Get("Url");
if($this->Get("LocalImage")=="1")
{
$url = $this->Get("LocalPath");
//$url = $this->GetImageDir().$this->GetFileName();
if(file_exists($pathtoroot.$url))
{
if(strlen($url))
{
$url = $rootURL.$url;
return $url;
}
else
{
if(strlen($Default))
$url = $rootURL.$Default;
return $url;
}
}
else
{
if(strlen($Default))
{
return $rootURL.$Default;
}
else
return "";
}
}
else
{
if(strlen($Default))
{
return $rootURL.$Default;
}
else
return "";
}
}
function ThumbURL()
{
global $rootURL, $pathtoroot, $objConfig;
if(strlen($this->Get("ThumbUrl")))
return $this->Get("ThumbUrl");
if($this->Get("LocalThumb")=="1")
{
$url = $this->Get("ThumbPath");
//$url = $this->GetImageDir().$this->GetFileName();
if(file_exists($pathtoroot.$url))
{
if(strlen($url))
{
$url = $rootURL.$url;
}
else
$url = $rootURL."kernel/images/noimage.gif";
return $url;
}
else
return $rootURL."kernel/images/noimage.gif";
}
else
return $rootURL."kernel/images/noimage.gif";
}
function ParseObject($element)
{
$extra_attribs = ExtraAttributes($element->attributes);
if(strtolower($element->name)==$this->TagPrefix)
{
$field = strtolower($element->attributes["_field"]);
switch($field)
{
case "name":
$ret = $this->Get("Name");
break;
case "alt":
$ret = $this->Get("AltName");
break;
case "full_url":
$ret = $this->FullURL();
break;
case "thumb_url":
$ret = $this->ThumbURL();
break;
}
}
else
$ret = $element->Execute();
return $ret;
}
function parsetag($tag)
{
if(is_object($tag))
{
$tagname = $tag->name;
}
else
$tagname = $tag;
switch($tagname)
{
case "image_name":
$ret = $this->Get("Name");
break;
case "image_alt":
$ret = $this->Get("AltName");
break;
case "image_url":
$ret = $this->FullURL();
break;
case "thumb_url":
$ret = $this->ThumbURL();
break;
}
return $ret;
}
//Changes priority
function MoveUp()
{
$this->Increment("Priority");
}
function MoveDown()
{
$this->Decrement("Priority");
}
function GetMaxPriority()
{
$SourceId = $this->Get("ResourceId");
$sql = "SELECT MAX(Priority) as p from ".$this->tablename."WHERE ResourceId=$SourceId";
$result = $this->adodbConnection->Execute($sql);
return $result->fields["p"];
}
function GetMinPriority()
{
$SourceId = $this->Get("ResourceId");
$sql = "SELECT MIN(Priority) as p from ".$this->tablename."WHERE ResourceId=$SourceId";
$result = $this->adodbConnection->Execute($sql);
return $result->fields["p"];
}
function UpdatePriority()
{
$SourceId = $this->Get("ResourceId");
$sql = "SELECT MAX(Priority) as p from ".$this->tablename."WHERE ReourceId=$SourceId";
$result = $this->adodbConnection->Execute($sql);
$this->Set("Priority", $result->fields["p"]+1);
}
}
class clsImageList extends clsItemCollection
{
var $Page;
var $PerPageVar;
function clsImageList()
{
$this->clsItemCollection();
$this->PerPageVar = "Perpage_Images";
$this->SourceTable = GetTablePrefix()."Images";
$this->classname = "clsImage";
}
function LoadImages($where="",$orderBy = "")
{
global $objConfig;
$this->Clear();
if($this->Page<1)
$this->Page=1;
if(is_numeric($objConfig->Get("Perpage_Images")))
{
$Start = ($this->Page-1)*$objConfig->Get("Perpage_Images");
$limit = "LIMIT ".$Start.",".$objConfig->Get("Perpage_Images");
}
else
$limit = NULL;
$this->QueryItemCount=TableCount("Images",$where,0);
//echo $this->QueryItemCount."<br>\n";
if(strlen(trim($orderBy))>0)
{
$orderBy = "Priority DESC, ".$orderBy;
}
else
$orderBy = "Priority DESC";
return $this->Query_Images($where,$orderBy,$limit);
}
function Query_Images($whereClause,$orderByClause=NULL,$limit=NULL)
{
global $objSession, $Errors;
$sql = "SELECT * FROM ".$this->SourceTable;
if(isset($whereClause))
$sql = sprintf('%s WHERE %s',$sql,$whereClause);
if(isset($orderByClause) && strlen(trim($orderByClause))>0)
$sql = sprintf('%s ORDER BY %s',$sql,$orderByClause);
if(isset($limit) && strlen(trim($limit)))
$sql .= " ".$limit;
//echo $sql;
return $this->Query_Item($sql);
}
function &Add($Name, $Alt, $ResourceId, $LocalImage, $LocalThumb,
$Url, $ThumbUrl, $Enabled=1, $Priority=0, $DefaultImg=0, $ImageIndex=0,
$SameImages=0, $ImageId=-999)
{
if($DefaultImg==1)
{
$sql = "UPDATE ".$this->SourceTable." SET DefaultImg=0 WHERE ResourceId=$ResourceId";
$this->adodbConnection->Execute($sql);
}
$img = new clsImage();
$img->tablename = $this->SourceTable;
$img->Set(array("Name","AltName","ResourceId","LocalImage","LocalThumb",
"Url","ThumbUrl","Enabled","Priority","DefaultImg","ImageIndex","SameImages"),
array($Name,$Alt,$ResourceId,$LocalImage,$LocalThumb,
$Url,$ThumbUrl,$Enabled,$Priority,$DefaultImg,$ImageIndex,$SameImages));
if ($ImageId != -999)
{
$img->Set("ImageId", $ImageId);
}
if((int)$ImageIndex==0)
$img->Set("ImageIndex",$this->GetNextImageIndex($ResourceId));
$img->Create();
array_push($this->Items,$img);
return $img;
}
function Edit($ImageId,$Name, $Alt, $ResourceId, $LocalImage, $LocalThumb,
$Url, $ThumbUrl, $Enabled=1, $Priority=0, $DefaultImg=0, $ImageIndex=0,
$SameImages=0)
{
$img = $this->GetItem($ImageId);
if((int)$ImageIndex==0)
$ImageIndex = $img->Get("ImageIndex");
if(!strlen($ThumbUrl) && !$LocalThumb)
$ThumbUrl = $img->Get("ThumbUrl");
$img->Set(array("Name","AltName","ResourceId","LocalImage","LocalThumb",
"Url","ThumbUrl","Enabled","Priority","DefaultImg","ImageIndex","SameImages"),
array($Name, $Alt, $ResourceId, $LocalImage, $LocalThumb,
$Url, $ThumbUrl, $Enabled, $Priority, $DefaultImg, $ImageIndex,$SameImages));
if((int)$ImageIndex==0)
$img->Set("ImageIndex",$this->GetNextImageIndex($ResourceId));
$img->Update();
if($DefaultImg==1)
{
$sql = "UPDATE ".$this->SourceTable." SET DefaultImg=0 WHERE ResourceId=".$ResourceId." AND ImageId !=$ImageId";
$this->adodbConnection->Execute($sql);
}
array_push($this->Items,$img);
return $img;
}
function Delete_Image($ImageId)
{
$i = $this->GetItem($ImageId);
$i->Delete();
}
function DeleteResource($ResourceId)
{
$this->Clear();
$images = $this->Query_Images("ResourceId=".$ResourceId);
if(is_array($images))
{
foreach($images as $i)
{
$i->Delete();
}
}
}
function LoadResource($ResourceId)
{
$sql = "SELECT * FROM ".$this->SourceTable." WHERE ResourceId=$ResourceId";
$this->Query_Item($sql);
}
function CopyResource($SourceId,$DestId)
{
global $pathtoroot;
$this->Clear();
$this->LoadResource($SourceId);
foreach($this->Items as $i)
{
if($i->Get("LocalThumb"))
{
$f = $pathtoroot.$i->Get("ThumbPath");
if(file_exists($f))
{
$p = pathinfo($f);
$dir = $p["dirname"];
$ext = $p["extension"];
$newfile = $dir."/th_".$DestId."_".$i->Get("ImageIndex").".".$ext;
if(file_exists($newfile))
@unlink($newfile);
// echo $f." -> ".$newfile;
copy($f,$newfile);
}
}
if($i->Get("LocalImage"))
{
$f = $pathtoroot.$i->Get("LocalPath");
if(file_exists($f))
{
$p = pathinfo($f);
$dir = $p["dirname"];
$ext = $p["extension"];
$newfile = $dir."/".$DestId."_".$i->Get("ImageIndex").".".$ext;
if(file_exists($newfile))
@unlink($newfile);
// echo $f." -> ".$newfile;
copy($f,$newfile);
}
}
}
parent::CopyResource($SourceId,$DestId);
$this->Clear();
$this->LoadResource($DestId);
foreach($this->Items as $img)
{
if($img->Get("LocalThumb"))
{
$f = str_replace("th_$SourceId","th_$DestId",$img->Get("ThumbPath"));
$img->Set("ThumbPath",$f);
}
if($img->Get("LocalImage"))
{
$f = str_replace("/".$SourceId."_","/".$DestId."_",$img->Get("LocalPath"));
$img->Set("LocalPath",$f);
}
$img->Update();
}
}
function GetImageByResource($ResourceId,$Index)
{
$found=FALSE;
if($this->NumItems()>0)
{
foreach($this->Items as $i)
{
if($i->Get("ResourceID")==$ResourceId and ($i->Get("ImageIndex")==$Index))
{
$found=TRUE;
break;
}
}
}
if(!$found)
{
$i = NULL;
$i = new clsImage();
if($i->LoadFromResource($ResourceId,$Index))
{
array_push($this->Items, $i);
}
else
unset($i);
}
if(is_object($i))
{
return $i;
}
else
return FALSE;
}
function &GetDefaultImage($ResourceId)
{
$sql = "SELECT * FROM ".$this->SourceTable." WHERE ResourceId=$ResourceId AND DefaultImg=1";
$rs = $this->adodbConnection->Execute($sql);
if($rs && ! $rs->EOF)
{
$data = $rs->fields;
$img= new clsImage();
$img->SetFromArray($data);
$img->Clean();
return $img;
}
else
return FALSE;
}
function HandleImageUpload($FILE,$ResourceId,$RelatedTo,$DestDir, $Name="",$AltName="",$IsThumb=0)
{
global $objConfig;
$img = $this->GetImageByResource($ResourceId,$RelatedTo);
if(is_object($img) && $RelatedTo>0)
{
$img->Set("LocalImage",1);
$img->Set("Name",$Name);
$img->Set("AltName",$AltName);
$img->Set("IsThumbnail",$IsThumb);
$dest = $img->StoreUploadedImage($FILE,1,$DestDir);
if(strlen($dest))
{
$img->Set("Url", $objConfig->Get("Site_Path").$dest);
$img->Update();
}
}
else
{
$img=$this->NewLocalImage($ResourceId,$RelatedTo,$Name,$AltName,$IsThumb,$FILE,$DestDir);
}
return $img;
}
function GetResourceImages($ResourceId)
{
$sql = "SELECT * FROM ".$this->SourceTable." WHERE ResourceId=".$ResourceId;
$rs = $this->adodbConnection->Execute($sql);
while($rs && !$rs->EOF)
{
$img = new clsImage();
$img->LoadFromResource($ResourceId,$rs->fields["RelatedTo"]);
array_push($this->Images,$img);
$rs->MoveNext();
}
}
function GetResourceThumbnail($ResourceId)
{
$found=FALSE;
foreach($this->Images as $img)
{
if($img->Get("ResourceId")==$ResourceId && $img->Get("IsThumbnail")==1)
{
$found=TRUE;
break;
}
}
if($found)
{
return $img;
}
else
return FALSE;
}
function &GetImageByName($ResourceId,$name)
{
$found = FALSE;
foreach($this->Items as $img)
{
if($img->Get("ResourceId")==$ResourceId && $img->Get("Name")==$name)
{
$found=TRUE;
break;
}
}
if($found)
{
return $img;
}
else
{
$sql = "SELECT * FROM ".$this->SourceTable." WHERE ResourceId=$ResourceId AND Name LIKE '$name'";
//echo $sql;
$rs = $this->adodbConnection->Execute($sql);
if($rs && !$rs->EOF)
{
$img = $this->AddItemFromArray($rs->fields);
return $img;
}
else
return FALSE;
}
}
function CopyToPendingFiles()
{
$sql = "SELECT * FROM ".$this->SourceTable;
$this->Clear();
$this->Query_Item($sql);
foreach($this->Items as $i)
{
if(strlen($i->Get("LocalImage")) || strlen($i->Get("LocalThumb")))
{
$i->CopyToPending();
}
}
}
function CopyFromPendingFiles($edit_table)
{
$sql = "SELECT * FROM ".$edit_table;
$this->Clear();
$this->Query_Item($sql);
foreach($this->Items as $i)
{
## Delete original Images
$OrgImage = new clsImage($i->Get("ImageId"));
$OrgImage->DeleteLocalImage();
if($i->Get("LocalImage") || $i->Get("LocalThumb"))
{
$i->CopyFromPending();
$t = $i->Get("LocalPath");
$p = pathinfo($t);
$p_arr = explode("/", $p['dirname']);
if (eregi("pending", $p_arr[count($p_arr)-1]))
{
unset($p_arr[count($p_arr)-1]);
$p['dirname'] = implode("/", $p_arr);
$LocalPath = $p['dirname']."/".$p['basename'];
$i->Set("LocalPath", $LocalPath);
}
$t = $i->Get("ThumbPath");
$p = pathinfo($t);
$p_arr = explode("/", $p['dirname']);
if (eregi("pending", $p_arr[count($p_arr)-1]))
{
unset($p_arr[count($p_arr)-1]);
$p['dirname'] = implode("/", $p_arr);
$ThumbPath = $p['dirname']."/".$p['basename'];
$i->Set("ThumbPath", $ThumbPath);
}
$i->tablename = $edit_table;
$update = 1;
}
## Empty the fields if are not used
if (!$i->Get("LocalImage"))
{
$i->Set("LocalPath", "");
$update = 1;
}
if (!$i->Get("LocalThumb"))
{
$i->Set("ThumbPath", "");
$update = 1;
}
if ($update)
$i->Update();
}
}
function DeletePendingFiles($edit_table)
{
$sql = "SELECT * FROM ".$edit_table;
$this->Clear();
$this->Query_Item($sql);
foreach($this->Items as $i)
{
$i->DeleteFromPending();
}
}
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($objSession->HasSystemPermission("DEBUG.LIST"))
echo htmlentities($insert,ENT_NOQUOTES)."<br>\n";
$this->adodbConnection->Execute($insert);
$this->SourceTable = $edit_table;
$this->CopyToPendingFiles();
$this->UpdateFilenamesToPendings();
}
function UpdateFilenamesToPendings()
{
global $objSession;
$edit_table = $this->SourceTable;
$sql = "SELECT * FROM ".$edit_table." WHERE (LocalPath!='' AND LocalPath IS NOT NULL) OR (ThumbPath!='' AND ThumbPath IS NOT NULL)";
$this->Clear();
$this->Query_Item($sql);
foreach($this->Items as $i)
{
$set = "";
$ImageId = $i->Get("ImageId");
## Update Local Image Path -> add "pending/" to PATH
if (strlen($i->Get("LocalPath")))
{
$p = pathinfo($i->Get("LocalPath"));
if (!eregi("/pending $", $p['dirname']))
{
$LocalPath = $p['dirname']."/pending/".$p['basename'];
$set = "SET LocalPath='$LocalPath'";
}
}
// echo "LocalImage: ".$i->Get("LocalImage").", PATH: ".$i->Get("LocalPath")."<BR>";
## Update Local Thumb Path -> add "pending/" to PATH
if (strlen($i->Get("ThumbPath")))
{
$p = pathinfo($i->Get("ThumbPath"));
if (!eregi("/pending $", $p['dirname']))
{
$LocalThumb = $p['dirname']."/pending/".$p['basename'];
if (strlen($set))
$set.= ", ThumbPath='$LocalThumb'";
else
$set = "SET ThumbPath='$LocalThumb'";
}
}
// echo "LocalThumb: ".$i->Get("LocalThumb").", PATH: ".$i->Get("ThumbPath")."<BR>";
if (strlen($set))
{
$sql = "UPDATE $edit_table $set WHERE ImageId=$ImageId";
if($objSession->HasSystemPermission("DEBUG.LIST"))
echo htmlentities($sql,ENT_NOQUOTES)."<br>\n";
$this->adodbConnection->Execute($sql);
}
}
}
function CopyFromEditTable($idfield)
{
global $objSession;
- $edit_table = $objSession->GetEditTable($this->SourceTable);
+ $edit_table = $objSession->GetEditTable($this->SourceTable);
+ $dummy =& $this->GetDummy();
+ if( !$dummy->TableExists($edit_table) )
+ {
+ echo 'ERROR: Table "<b>'.$edit_table.'</b>" missing (class: <b>'.get_class($this).'</b>)<br>';
+ //exit;
+ return;
+ }
+
$rs = $this->adodbConnection->Execute("SELECT * FROM $edit_table WHERE ResourceId=0");
while($rs && !$rs->EOF)
{
$id = $rs->fields["ImageId"];
if($id>0)
{
$img = $this->GetItem($id);
$img->Delete();
}
$rs->MoveNext();
}
$this->adodbConnection->Execute("DELETE FROM $edit_table WHERE ResourceId=0");
$this->CopyFromPendingFiles($edit_table);
parent::CopyFromEditTable($idfield);
}
function PurgeEditTable($idfield)
{
global $objSession;
$edit_table = $objSession->GetEditTable($this->SourceTable);
$this->DeletePendingFiles($edit_table);
@$this->adodbConnection->Execute("DROP TABLE $edit_table");
}
function GetNextImageIndex($ResourceId)
{
$sql = "SELECT MAX(ImageIndex) as MaxVal FROM ".$this->SourceTable." WHERE ResourceId=".$ResourceId;
$rs = $this->adodbConnection->Execute($sql);
if($rs)
{
$val = (int)$rs->fields["MaxVal"];
$val++;
}
return $val;
}
function GetMaxPriority($ResourceId)
{
$sql = "SELECT MAX(Priority) as p from ".$this->SourceTable."WHERE ResourceId=$ResourceId";
$result = $this->adodbConnection->Execute($sql);
return $result->fields["p"];
}
function GetMinPriority($ResourceId)
{
$sql = "SELECT MIN(Priority) as p from ".$this->SourceTable."WHERE ResourceId=$ResourceId";
$result = $this->adodbConnection->Execute($sql);
return $result->fields["p"];
}
} /*clsImageList*/
?>
Property changes on: trunk/kernel/include/image.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/category/addcategory_permissions.php
===================================================================
--- trunk/admin/category/addcategory_permissions.php (revision 17)
+++ trunk/admin/category/addcategory_permissions.php (revision 18)
@@ -1,273 +1,274 @@
<?php
##############################################################
##In-portal ##
##############################################################
## In-portal ##
## Intechnic Corporation ##
## All Rights Reserved, 1998-2002 ##
## ##
## No portion of this code may be copied, reproduced or ##
## otherwise redistributed without proper written ##
## consent of Intechnic Corporation. Violation will ##
## result in revocation of the license and support ##
## privileges along maximum prosecution allowed by law. ##
##############################################################
if(!strlen($pathtoroot))
{
$path=dirname(realpath($_SERVER['SCRIPT_FILENAME']));
if(strlen($path))
{
/* determine the OS type for path parsing */
$pos = strpos($path,":");
if ($pos === false)
{
$gOS_TYPE="unix";
$pathchar = "/";
}
else
{
$gOS_TYPE="win";
$pathchar="\\";
}
$p = $path.$pathchar;
/*Start looking for the root flag file */
while(!strlen($pathtoroot) && strlen($p))
{
$sub = substr($p,strlen($pathchar)*-1);
if($sub==$pathchar)
{
$filename = $p."root.flg";
}
else
$filename = $p.$pathchar."root.flg";
if(file_exists($filename))
{
$pathtoroot = $p;
}
else
{
$parent = realpath($p.$pathchar."..".$pathchar);
if($parent!=$p)
{
$p = $parent;
}
else
$p = "";
}
}
if(!strlen($pathtoroot))
$pathtoroot = ".".$pathchar;
}
else
{
$pathtoroot = ".".$pathchar;
}
}
$sub = substr($pathtoroot,strlen($pathchar)*-1);
if($sub!=$pathchar)
{
$pathtoroot = $pathtoroot.$pathchar;
}
//echo $pathtoroot;
require_once($pathtoroot."kernel/startup.php");
//admin only util
$rootURL="http://".ThisDomain().$objConfig->Get("Site_Path");
$admin = $objConfig->Get("AdminDirectory");
if(!strlen($admin))
$admin = "admin";
$localURL=$rootURL."kernel/";
$adminURL = $rootURL.$admin;
$imagesURL = $adminURL."/images";
//$pathtolocal = $pathtoroot."in-news/";
require_once ($pathtoroot.$admin."/include/elements.php");
require_once ($pathtoroot."kernel/admin/include/navmenu.php");
//require_once ($pathtolocal."admin/include/navmenu.php");
require_once($pathtoroot.$admin."/toolbar.php");
require_once($pathtoroot.$admin."/listview/listview.php");
$m = GetModuleArray();
foreach($m as $key=>$value)
{
$path = $pathtoroot. $value."admin/include/parser.php";
if(file_exists($path))
{
include_once($path);
}
}
unset($objEditItems);
$objEditItems = new clsCatList();
$objEditItems->SourceTable = $objSession->GetEditTable("Category");
//Multiedit init
$en = (int)$_GET["en"];
$objEditItems->Query_Item("SELECT * FROM ".$objEditItems->SourceTable);
$itemcount=$objEditItems->NumItems();
if(isset($_GET["en"]))
{
$c = $objEditItems->GetItemByIndex($en);
}
if(!is_object($c))
{
$c = new clsCategory($m_var_list["cat"]);
$c->Set("CategoryId",$m_var_list["cat"]);
}
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_category";
/* -------------------------------------- Section configuration ------------------------------------------- */
$envar = "env=" . BuildEnv() . "&en=$en";
$section = 'in-portal:editcategory_permissions';
$sec =& $objSections->GetSection($section);
if($c->Get("CategoryId")==0)
{
$sec->Set("left",NULL);
$sec->Set("right",NULL);
}
if($c->Get("CategoryId")!=0)
{
$title = admin_language("la_Text_Editing")." ".admin_language("la_Text_Category")." '".$c->Get("Name")."' - ".admin_language("la_tab_Permissions");
}
else
$title = admin_language("la_Text_Editing")." ".admin_language("la_Text_Root")." ".admin_language("la_Text_Category")." - ".admin_language("la_tab_Permissions");
$SortFieldVar = "GroupPerm_SortField";
$SortOrderVar = "GroupPerm_SortOrder";
$DefaultSortField = "FullName";
$PerPageVar = "Perpage_Grouplist";
$CurrentPageVar = "Page_Grouplist";
$CurrentFilterVar = "CatImg_View";
$ListForm = "permlistform";
$CheckClass = "PermChecks";
/* ------------------------------------- Configure the toolbar ------------------------------------------- */
$saveURL = $admin."/category/category_maint.php";
$objListToolBar = new clsToolBar();
$objListToolBar->Add("img_save", "la_Save","#","swap('img_save','toolbar/tool_select_f2.gif');", "swap('img_save', 'toolbar/tool_select.gif');","do_edit_save('save_edit_buttons','CatEditStatus','$saveURL',1);","tool_select.gif");
$objListToolBar->Add("img_cancel", "la_Cancel","#","swap('img_cancel','toolbar/tool_cancel_f2.gif');", "swap('img_cancel', 'toolbar/tool_cancel.gif');","do_edit_save('save_edit_buttons','CatEditStatus','".$admin."/browse.php',2);","tool_cancel.gif");
if($itemcount == 1) $objListToolBar->Add("divider");
$objListToolBar->Set("section",$section);
$objListToolBar->Set("load_menu_func","");
$objListToolBar->Set("CheckClass",$CheckClass);
$objListToolBar->Set("CheckForm",$ListForm);
if ( isset($en_prev) || isset($en_next) )
{
$url = $RootUrl.$admin."/category/addcategory_permissions.php";
$StatusField = "CatEditStatus";
$form = "category";
MultiEditButtons($objListToolBar,$en_next,$en_prev,$form,$StatusField,$url,$sec->Get("OnClick"),'','la_PrevCategory','la_NextCategory');
$objListToolBar->Add("divider");
}
$listImages = array();
//$img, $alt, $link, $onMouseOver, $onMouseOut, $onClick
$objListToolBar->Add("new_perm", "la_ToolTip_New_Permission","#","swap('new_perm','toolbar/tool_new_permission_f2.gif');",
"swap('new_perm', 'toolbar/tool_new_permission.gif');",
"OpenGroupSelector('$envar&source=addcategory_permissions&CatId=".$c->Get("CategoryId")."&destform=popup&destfield=itemlist');",
"tool_new_permission.gif");
$objListToolBar->Add("perm_edit","Edit","#", "if (PermChecks.itemChecked()) swap('perm_edit','toolbar/tool_edit_f2.gif');",
"if (PermChecks.itemChecked()) swap('perm_edit', 'toolbar/tool_edit.gif');","if (PermChecks.itemChecked()) PermChecks.check_submit('addpermission_modules', '');",
"tool_edit.gif",TRUE,TRUE);
$listImages[] = "PermChecks.addImage('perm_edit','$imagesURL/toolbar/tool_edit.gif','$imagesURL/toolbar/tool_edit_f3.gif',1); ";
$objListToolBar->Add("perm_del","Delete","#", "if (PermChecks.itemChecked()) swap('perm_del','toolbar/tool_delete_f2.gif');",
"if (PermChecks.itemChecked()) swap('perm_del', 'toolbar/tool_delete.gif');","if (PermChecks.itemChecked()) PermChecks.check_submit('addcategory_permissions', 'm_perm_delete_group');",
"tool_delete.gif",FALSE,TRUE);
$listImages[] = "PermChecks.addImage('perm_del','$imagesURL/toolbar/tool_delete.gif','$imagesURL/toolbar/tool_delete_f3.gif',1); ";
$objListToolBar->Add("divider");
$objListToolBar->AddToInitScript($listImages);
/* ------------------------------------ Build the SQL statement to populate the list ---------------------------*/
$objGroupList = new clsGroupList();
$order = $objConfig->Get("Group_SortOrder");
$objGroupList->Clear();
$sql = "SELECT ResourceId, g.name as Name, ELT(g.Personal+1,'Group ','User ') as UserGroup FROM ".GetTablePrefix()."Permissions as p ";
-$sql .="LEFT JOIN ".GetTablePrefix()."PortalGroup as g ON p.GroupId=g.GroupId WHERE p.CatId=".$c->Get("CategoryId")." GROUP BY Name";
+$sql .="LEFT JOIN ".GetTablePrefix()."PortalGroup as g ON p.GroupId=g.GroupId WHERE p.CatId=".(int)$c->Get("CategoryId")." GROUP BY Name";
//$sql = "SELECT GroupId, count(*) as PermCount FROM ".GetTablePrefix()."Permissions WHERE CatId=".$c->Get("CategoryId")." GROUP BY GroupId";
$objGroupList->Query_Item($sql);
if($objSession->HasSystemPermission("DEBUG.LIST"))
echo htmlentities($sql,ENT_NOQUOTES)."<br>\n";
/* ---------------------------------------- Configure the list view ---------------------------------------- */
$objListView = new clsListView($objListToolBar,$objGroupList);
$objListView->IdField = "ResourceId";
$objListView->PageLinkTemplate = $pathtoroot. "admin/templates/user_page_link.tpl";
$objListView->ColumnHeaders->Add("Name",admin_language("la_prompt_Name"),1,0,$order,"width=\"20%\"",$SortFieldVar,$SortOrderVar,"Name");
$objListView->ColumnHeaders->Add("UserGroup",admin_language("la_Colheader_GroupType"),1,0,$order,"width=\"30%\"",$SortFieldVar,$SortOrderVar,"UserGroup");
$objListView->ColumnHeaders->SetSort($objConfig->Get($SortFieldVar),$order);
$objListView->PrintToolBar = FALSE;
$objListView->CurrentPageVar = $CurrentPageVar;
$objListView->PerPageVar = $PerPageVar;
$objListView->CheckboxName = "itemlist[]";
int_header($objListToolBar,NULL,$title);
if ($objSession->GetVariable("HasChanges") == 1) {
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="toolbar">
<tr>
<td valign="top">
<?php int_hint_red(admin_language("la_Warning_Save_Item")); ?>
</td>
</tr>
</table>
<?php } ?>
<FORM method="POST" ACTION="" NAME="<?php echo $ListForm; ?>" ID="<?php echo $ListForm; ?>">
<?php
print $objListView->PrintList();
?>
<input type="hidden" name="Action" value="">
<INPUT TYPE="hidden" NAME="CategoryId" VALUE="<?php echo $c->Get("CategoryId"); ?>">
</FORM>
<FORM NAME="save_edit_buttons" ID="save_edit_buttons" method="POST" ACTION="">
- <input type=hidden NAME="Action" VALUE="save_category_edit">
+ <input type="hidden" NAME="Action" VALUE="save_category_edit">
+ <INPUT TYPE="hidden" NAME="CategoryId" VALUE="<?php echo $c->Get("CategoryId"); ?>">
<input type="hidden" name="CatEditStatus" VALUE="0">
</FORM>
<FORM NAME="popup" ID="popup" METHOD="POST" ACTION="addpermission_modules.php?<?php echo $envar; ?>">
<INPUT TYPE="hidden" NAME="itemlist">
</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>
<!-- END CODE-->
<?php int_footer(); ?>
Property changes on: trunk/admin/category/addcategory_permissions.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/category/addcategory.php
===================================================================
--- trunk/admin/category/addcategory.php (revision 17)
+++ trunk/admin/category/addcategory.php (revision 18)
@@ -1,374 +1,381 @@
<?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);
+if($_REQUEST['item'])
+{
+ // smulate like normal edit button pressed
+ $tmp_cat =& $objCatList->GetItemByField('ResourceId', $_REQUEST['item']);
+ $_POST['catlist'][] = $tmp_cat->UniqueId();
+}
+
$objEditItems = new clsCatList();
$objEditItems->SourceTable = $objSession->GetEditTable("Category");
$objCustomFields = new clsCustomFieldList(1);
$objCustomDataList = new clsCustomDataList();
$objRelList = new clsRelationshipList();
$objImages = new clsImageList();
//Multiedit init
if ($_GET["new"] == 1)
{
$c = new clsCategory(NULL);
$c->Set("CreatedOn", time());
$c->Set("EndOn", time());
$c->Set("ParentId",$objCatList->CurrentCategoryID());
$c->Set("NewItem",2); //auto
$c->Set("Status",2); //pending
$en = 0;
$action = "m_add_category";
$objCatList->CreateEmptyEditTable("CategoryId");
$objRelList->CreateEmptyEditTable("RelationshipId");
$objCustomDataList->CreateEmptyEditTable("CustomDataId");
$objImages->CreateEmptyEditTable("ResourceId");
$TitleVerb = prompt_language("la_Text_Adding");
}
else
{
if(isset($_POST["catlist"]))
{
$cats = $_POST["catlist"];
$objCatList->CopyToEditTable("CategoryId",$cats);
$objEditItems->Query_Item("SELECT * FROM ".$objEditItems->SourceTable);
/* make a copy of the relationship records */
$ids = $objEditItems->GetResourceIDList();
$objRelList->CopyToEditTable("SourceId", $ids);
$objCustomDataList->CopyToEditTable("ResourceId",$ids);
$objImages->CopyToEditTable("ResourceId", $ids);
$c = $objEditItems->GetItemByIndex(0);
$itemcount=$objEditItems->NumItems();
$en = 0;
}
else
{
if($_GET["item"])
{
/*shortcut to edit link */
$objCatList->CopyToEditTable("ResourceId",$_GET["item"]);
$backurl = $_GET["return"];
}
//Multiedit init
$en = (int)$_GET["en"];
$objEditItems->Query_Item("SELECT * FROM ".$objEditItems->SourceTable);
//$ids = $objEditItems->GetResourceIDList();
//$objRelList->CopyToEditTable("SourceId", $ids);
//$objCustomDataList->CopyToEditTable("ResourceId",$ids);
//$objImages->CopyToEditTable("ResourceId", $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_category";
$TitleVerb = prompt_language("la_Text_Editing");
}
$envar = "env=" . BuildEnv() . "&en=$en";
$section = 'in-portal:editcategory_general';
if (strlen($c->Get("Name")))
$editing_category_title = "'".$c->Get("Name")."' ";
else
$editing_category_title = "";
$title = $TitleVerb." ".prompt_language("la_Text_Category")." $editing_category_title- ".prompt_language("la_tab_General");
//$saveURL = $admin."/browse.php";
$saveURL = $admin."/category/category_maint.php";
$cancelURL = $admin."/browse.php";
//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('category','CatEditStatus','$saveURL',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('category','CatEditStatus','$cancelURL',2,'');","tool_cancel.gif");
if ( isset($en_prev) || isset($en_next) )
{
$url = $RootUrl.$admin."/category/addcategory.php";
$StatusField = "CatEditStatus";
$form = "category";
MultiEditButtons($objCatToolBar,$en_next,$en_prev,$form,$StatusField,$url,$sec->Get("OnClick"),'','la_PrevCategory','la_NextCategory');
}
int_header($objCatToolBar,NULL,$title);
if ($objSession->GetVariable("HasChanges") == 1) {
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="toolbar">
<tr>
<td valign="top">
<?php int_hint_red(admin_language("la_Warning_Save_Item")); ?>
</td>
</tr>
</table>
<?php } ?>
<table width="100%" border="0" cellspacing="0" cellpadding="4" class="tableborder">
<form ID="category" name="category" action="" method=POST>
<tr <?php int_table_color(1); ?>>
<td valign="top" colspan="3"><?php echo prompt_language("la_prompt_Enable_HTML"); ?>
<input type="checkbox" name="html_enable" value="1" checked>
<br>
<?php int_hint(prompt_language("la_Warning_Enable_HTML")); ?>
</td>
</tr>
<?php int_subsection_title(prompt_language("la_Text_Category")); ?>
<?php if( $c->Get("CategoryId") > 0 ) { ?>
<tr <?php int_table_color(); ?>>
<td valign="top"><span class="text"><?php echo prompt_language("la_prompt_CategoryId"); ?></span></td>
<td valign="top"><span class="text"><?php echo $c->Get("CategoryId"); ?></span></td>
<td><span class="text"> </span></td>
</tr>
<?php } ?>
<tr <?php int_table_color(); ?>>
<td valign="top"><span ID="prompt_cat_name" class="text"><?php echo prompt_language("la_prompt_Name"); ?></span></td>
<td>
<input type="text" name="cat_name" ValidationType="exists" tabindex="1" class="text" size="30" value="<?php echo $c->parsetag("cat_name"); ?>">
</td>
<td></td>
</tr>
<tr <?php int_table_color(); ?>>
<td valign="top"><span ID="prompt_cat_desc" class="text"><?php echo prompt_language("la_prompt_Description"); ?></span>
<br />
<a href="#">
<img src="<?php echo $rootURL; ?>admin/icons/icon24_link_editor.gif" style="cursor:hand" border="0"
ONCLICK="document.forms[0].elements[0].checked=true; OpenEditor('§ion=<?php echo $section; ?>','category','cat_desc');">
</a>
</td>
<td>
<textarea name="cat_desc" tabindex="2" ValidationType="exists" cols="60" rows="5" class="text"><?php echo inp_textarea_unescape($c->parsetag("cat_desc")); ?></textarea>
</td>
<td></td>
</tr>
<?php int_subsection_title(prompt_language("la_tab_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" tabindex="3" name="status" class="text" value="1" <?php if($c->Get("Status") == 1) echo "checked"; ?>><?php echo prompt_language("la_val_Active"); ?>
<input type="radio" tabindex="3" name="status" class="text" value="2" <?php if($c->Get("Status") == 2) echo "checked"; ?>><?php echo prompt_language("la_val_Pending"); ?>
<input type="radio" tabindex="3" name="status" class="text" value="0" <?php if($c->Get("Status") == 0) echo "checked"; ?>><?php echo prompt_language("la_val_Disabled"); ?>
</td>
<td class="text"> </td>
</tr>
<tr <?php int_table_color(); ?>>
<td valign="top"><span id="prompt_itemnew" class="text"><?php echo prompt_language("la_prompt_New"); ?></span></td>
<td>
<input type="radio" tabindex="4" name="itemnew" class="text" value="2" <?php if($c->Get("NewItem") == 2) echo "checked"; ?>><?php echo prompt_language("la_val_Auto"); ?>
<input type="radio" tabindex="4" name="itemnew" class="text" value="1" <?php if($c->Get("NewItem") == 1) echo "checked"; ?>><?php echo prompt_language("la_val_Always"); ?>
<input type="radio" tabindex="4" name="itemnew" class="text" value="0" <?php if($c->Get("NewItem") == 0) echo "checked"; ?>><?php echo prompt_language("la_val_Never"); ?>
</td>
<td class="text"> </td>
</tr>
<tr <?php int_table_color(); ?>>
<td valign="top"><span id="prompt_cat_pick" class="text"><?php echo prompt_language("la_prompt_EditorsPick"); ?></span></td>
<td>
<input type="checkbox" tabindex="5" name="cat_pick" class="text" value="1" <?php if($c->Get("EditorsPick") == 1) echo "checked"; ?>>
</td>
<td class="text"> </td>
</tr>
<TR <?php int_table_color(); ?> >
<TD><span id="prompt_Priority" class="text"><?php echo prompt_language("la_prompt_Priority"); ?></span></TD>
<TD><input type=text SIZE="5" tabindex="6" NAME="Priority" VALUE="<?php echo $c->Get("Priority"); ?>"></TD>
<TD> </TD>
</TR>
<tr <?php int_table_color(); ?>>
<td valign="top" ID="prompt_cat_date" class="text"> <?php echo prompt_language("la_prompt_CreatedOn"); ?> </td>
<td>
<input type="text" ValidationType="date,exists" tabindex="7" name="cat_date" id="cat_date_selector" datepickerIcon="../images/ddarrow.gif" class="text" size="20" value="<?php echo $c->parsetag("cat_date"); ?>">
<span class="small"><?php echo prompt_language("la_prompt_DateFormat"); ?></span></td>
<td></td>
</tr>
<?php int_subsection_title(prompt_language("la_Sectionheader_MetaInformation")); ?>
<tr <?php int_table_color(); ?>>
<td valign="top"><span id="prompt_meta_keywords" class="text"><?php echo prompt_language("la_prompt_MetaKeywords"); ?></span></td>
<td>
<input type="text" name="meta_keywords" tabindex="8" class="text" size="30" value="<?php echo $c->parsetag("cat_metakeywords"); ?>">
</td>
<td class="text"> </td>
</tr>
<tr <?php int_table_color(); ?>>
<td valign="top"><span id="prompt_meta_desc" class="text"><?php echo prompt_language("la_prompt_MetaDescription"); ?></span></td>
<td>
<textarea name="meta_desc" tabindex="9" cols="60" rows="2" class="text"><?php echo inp_textarea_unescape($c->parsetag("cat_metadesc")); ?></textarea>
</td>
<td class="text"> </td>
</tr>
<?php
$CustomFieldUI = $objCustomFields->GetFieldUIList(TRUE);
if($CustomFieldUI->NumItems()>0)
{
$objCustomDataList->SourceTable = $objSession->GetEditTable("CustomMetaData");
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\" class=\"text\">".$f->GetPrompt()."</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\"> </span></td>\n";
print "</tr>\n";
}
}
}
}
?>
<input type="hidden" name="ParentId" value="<?php echo $c->Get("ParentId"); ?>">
<input type="hidden" name="CategoryId" value="<?php echo $c->parsetag("cat_id"); ?>">
<input type="hidden" name="Action" value="<?php echo $action; ?>">
<input type="hidden" name="CatEditStatus" VALUE="0">
</FORM>
</table>
<script src="<?php echo $adminURL; ?>/include/calendar.js"></script>
<SCRIPT language="JavaScript">
initCalendar("cat_date_selector", CalDateFormat);
</SCRIPT>
<FORM method="POST" NAME="save_edit" ID="save_edit">
<input type="hidden" name="CatEditStatus" VALUE="0">
</FORM>
<?php
MarkFields('category');
int_footer();
?>
Property changes on: trunk/admin/category/addcategory.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
Log In to Comment