Get("PortalUserId"); $link =& $objLinkList->GetItem($id); $link->AddFavorite($userid); $cat_id = $link->GetPrimaryCategory(); UpdateCategoryCount("Link", $cat_id, $objLinkList->CacheListType("favorites")); break; case "l_del_favorite": $id = $l_var_list["id"]; $userid = $objSession->Get("PortalUserId"); $link =& $objLinkList->GetItem($id); $link->DeleteFavorite($userid); $cat_id = $link->GetPrimaryCategory(); UpdateCategoryCount("Link", $cat_id, $objLinkList->CacheListType("favorites")); break; case "l_add_review": //phpinfo(INFO_VARIABLES); $perm = 0; $CategoryId=$objCatList->CurrentCategoryID(); if ($objSession->HasCatPermission("LINK.REVIEW.PENDING")) $perm = 2; if ($objSession->HasCatPermission("LINK.REVIEW")) $perm = 1; //echo "Perm: $perm
\n"; if ($perm == 0) { $MissingCount++; $FormError["l_addreview"]["review"] = language("lu_ferror_no_access"); } else { $id = $l_var_list["id"]; $link =& $objLinkList->GetItem($id); $value = $objSession->InSpamControl($link->Get("ResourceId"),"Review"); //if($link->ReviewIPExists($_SERVER["REMOTE_ADDR"])) if ($value) { $MissingCount++; $FormError["l_addreview"]["review"] = language("lu_ferror_review_duplicate"); } else { $CreatedOn = adodb_date("U"); $ReviewText = inp_striptags($_POST["review"]); $id = $l_var_list["id"]; $userid = $objSession->Get("PortalUserId"); $ValName = "link_ReviewDelay_Value"; $IntName = "link_ReviewDelay_Interval"; $exp_secs = $objConfig->Get($ValName) * $objConfig->Get($IntName); $objSession->AddToSpamControl($link->Get("ResourceId"),$exp_secs,"Review"); $link->AddReview($userid,$ReviewText,($perm==2),$_SERVER["REMOTE_ADDR"]); if(strlen($_GET["Confirm"])) { $var_list["t"] = $_GET["Confirm"]; } else $var_list["t"] = $_GET["DestTemplate"]; } } break; case "l_rate_link": //phpinfo(); if ($objSession->HasCatPermission("LINK.RATE")) $perm = 1; if ($perm == 0) { $MissingCount++; $FormError["l_rate"]["review"] = language("lu_ferror_no_access"); } else { $MissingCount = SetMissingDataErrors("l_rate"); $id = $l_var_list["id"]; $link =& $objLinkList->GetItem($id); $value = $objSession->InSpamControl($link->Get("ResourceId"),"Rating"); if($value) { $MissingCount++; $FormError["l_rate"]["review"] = language("lu_rating_alreadyvoted"); if(strlen($_GET["Duplicate"])) { $var_list["t"] = $_GET["Duplicate"]; } else $var_list["t"] = $_GET["DestTemplate"]; } if($MissingCount==0) { $ValName = "link_RatingDelay_Value"; $IntName = "link_RatingDelay_Interval"; $exp_secs = $objConfig->Get($ValName) * $objConfig->Get($IntName); $objSession->AddToSpamControl($link->Get("ResourceId"),$exp_secs,"Rating"); $vote = $_POST["rating"]; $link->SubmitVote($vote,""); if(strlen($_GET["Confirm"])) { $var_list["t"] = $_GET["Confirm"]; } else $var_list["t"] = $_GET["DestTemplate"]; } } break; case "l_sort_links": if(is_numeric($_POST["Perpage_Links"])) { $objSession->SetPersistantVariable("Perpage_Links",$_POST["Perpage_Links"]); } else { $objSession->SetPersistantVariable("Perpage_Links", $objConfig->Get("Perpage_Links")); } if (strlen($_POST["Link_SortField"])) { $objSession->SetPersistantVariable("Link_SortField",$_POST["Link_SortField"]); $objSession->SetPersistantVariable("Link_SortField2",""); } if (strlen($_POST["Link_SortOrder"])) { $objSession->SetPersistantVariable("Link_SortOrder",$_POST["Link_SortOrder"]); $objSession->SetPersistantVariable("Link_SortOrder2",""); } $l_var_list["p"] = 1; $objLinkList->Page = 1; DeleteModuleTagCache('inlink'); break; case "l_add_link_confirm": if(GetVar('item_action')) { $item_action = GetVar('item_action'); if (is_array($item_action)) { list($id, $label) = each($item_action); } if ( isset($item_action['enter']) || (isset($item_action['new']) && $_POST['new_suggest_cat']==0) ) { // enter into selected category if ($_POST['new_suggest_cat'] > 0) { // deeplevel++ $_POST['suggest_cat_id'] = $_POST['new_suggest_cat']; } else { // deeplevel-- $db =& GetADODBConnection(); $_POST['suggest_cat_id'] = $db->GetOne('SELECT ParentId FROM '.$objCatList->SourceTable.' WHERE CategoryId='.$_POST['suggest_cat_id']); } } elseif ( isset($item_action['new']) ) { // add selected category to suggested list if ($_POST['new_suggest_cat'] != $objCatList->CurrentCategoryID()) { $new_cat_id = $_POST['new_suggest_cat']; $_POST['cat_ids'][$new_cat_id] = $new_cat_id; } } elseif ($id) { unset($_POST['cat_ids'][$id]); } break; } $perm = 0; $CategoryId = $objCatList->CurrentCategoryID(); if ($objSession->HasCatPermission('LINK.ADD.PENDING')) { $perm = 2; } if ($objSession->HasCatPermission('LINK.ADD')) { $perm = 1; } if ($perm == 0) { $MissingCount++; $FormError["l_addlink"]["name"] = language("lu_ferror_no_access"); } else { $CreatedOn = adodb_mktime(); $name = inp_striptags($_POST["name"]); $desc = inp_striptags($_POST["description"]); $url = inp_striptags($_POST["url"]); $MissingCount = SetMissingDataErrors("l_addlink"); if (is_array($_FILES)) { foreach ($_FILES as $field => $file) { $allowed = true; if (strlen($_POST["imagetypes"][$field])) { $types = explode(",",strtolower($_POST["imagetypes"][$field])); if (is_array($types)) { if (count($types)>0) { $path_parts = pathinfo($file["name"]); $ext = $path_parts["extension"]; $allowed = in_array($ext,$types); if (!$allowed) { $MissingCount++; $FormError["l_addlink"][$field] = language("lu_ferror_wrongtype"); } } } } $maxsize = (int)$_POST["maxsize"][$field]; if ($maxsize > 0 && $allowed && $file["size"] > $maxsize) { $allowed = false; $MissingCount++; $FormError["l_addlink"][$field] = language("lu_ferror_toolarge"); } } } if ($MissingCount == 0) { $ExpireInterval = $objConfig->Get("link_Expire_Interval") * $objConfig->Get("link_Expire_Value"); $Expire = $ExpireInterval > 0 && $perm == 1 ? $CreatedOn + $ExpireInterval : 0; $link = $objLinkList->Add_Link( $CategoryId,$name,$desc, $url, $CreatedOn, $Expire, $perm, 0,2,2,2,$objSession->Get("PortalUserId"),0,0,0); $LinkResourceId = $link->Get("ResourceId"); $objCustomFields = new clsCustomFieldList(1); $field_list = $objCustomFields->Query_CustomField("Type=".$link->type); for ($i = 0; $i < $objCustomFields->NumItems(); $i++) { $field = & $objCustomFields->GetItemRefByIndex($i); $fieldid= $field->Get("CustomFieldId"); $fname = $field->Get("FieldName"); if(isset($_POST[$fname])) $objCustomDataList->SetFieldValue($fieldid,$LinkResourceId,$_POST[$fname]); elseif(isset($_POST[strtolower($fname)])) $objCustomDataList->SetFieldValue($fieldid,$LinkResourceId,$_POST[strtolower($fname)]); } $objCustomDataList->SaveData(); $link->AddToCategory($CategoryId); // suggest to multiple cats: begin if (getArrayValue($_POST,'cat_ids')) { foreach ($_POST['cat_ids'] as $suggest_cat_id) { $link->AddToCategory($suggest_cat_id); } } // suggest to multiple cats: end if (!GetVar('cat_ids')) { SetVar('cat_ids', Array($CategoryId) ); } else { SetVar('cat_ids', array_merge(Array($CategoryId), GetVar('cat_ids')) ); } UpdateCategoryCount("Link",$_POST['cat_ids'],'_'); UpdateCategoryCount("Link",$_POST['cat_ids'],$objLinkList->CacheListType("myitems")); /* handle any image uploads */ if (is_array($_FILES)) { foreach ($_FILES as $field => $file) { if ($file["size"] > 0) { $imgname = $_POST["imagename"][$field]; $thumb = $_POST["isthumb"][$field]; $IsDefault = (int)$_POST["imgdefault"][$field]; if ($thumb) { $LocalThumb=1; } else { $LocalImage=1; } $img = $objImageList->GetImageByName($LinkResourceId,$imgname); if (!is_object($img)) { $img =& $objImageList->Add($imgname, "", $LinkResourceId, $LocalImage, $LocalThumb, "", "", 1, 0, $IsDefault, 0,0); } if ($thumb) { $img->Set("LocalThumb",1); $url = $img->StoreUploadedImage($file, 1,"kernel/images/",$thumb); $img->Set("ThumbPath",$url); } else { $img->Set("LocalImage",1); $url = $img->StoreUploadedImage($file, 1,"kernel/images/",$thumb); $img->Set("LocalPath",$url); } $img->Update(); } } } $var_list["t"] = $_GET[ strlen($_GET["Confirm"]) ? 'Confirm' : 'DestTemplate']; if( GetVar('listing_type') ) { $application =& kApplication::Instance(); $application->SetVar('success_template', $var_list['t']); $link_fields = Array( $link->UniqueId() => Array('ListingTypeId' => GetVar('listing_type') ) ); $application->SetVar('l', $link_fields); $enhancement_event = new kEvent('ls:OnRequestEnhancement'); $application->HandleEvent($enhancement_event); if (($enhancement_event->status == erSUCCESS) && strlen($enhancement_event->redirect) ) { $application->Redirect($enhancement_event->redirect, Array('DestTemplate' => $_GET['DestTemplate']) ); } } } } break; case "l_edit_link": $perm = 0; $CategoryId=$objCatList->CurrentCategoryID(); $OrgLink = $objLinkList->GetItem($l_var_list["id"]); $PermCat = $OrgLink->GetPrimaryCategory(); if ($objSession->HasCatPermission("LINK.MODIFY.PENDING",$PermCat)) $perm = 2; if ($objSession->HasCatPermission("LINK.MODIFY",$PermCat)) $perm = 1; if($objSession->Get("PortalUserId")==$OrgLink->Get("CreatedById") && $perm != 1) { if ($objSession->HasCatPermission("LINK.OWNER.MODIFY.PENDING",$PermCat)) $perm = 2; if ($objSession->HasCatPermission("LINK.OWNER.MODIFY",$PermCat)) $perm = 1; } $link = $OrgLink; if($perm == 2 && !$link->Get('OrgId')) { $CatList = $link->CategoryMemberList(); $PrimaryCat = $link->GetPrimaryCategory(); $link->Dirty(); $link->Set("OrgId",$OrgLink->Get("LinkId")); $link->UnsetIdField(); //$link->Set("ResourceId",0); $link->Set("Status",-2); //$link->Create(); //echo "ok"; $link->CopyToNewResource($PrimaryCat); //$objCustomFields = new clsCustomFieldList(1); //$objCustomFields->CopyResource($OrgLink->Get("ResourceId"),$link->Get("ResourceId")); //unset($objCustomFields); $link->AddToCategory($PrimaryCat,"",1); for($x=0;$xAddToCategory($CatList[$x]); } } } //echo "perm: $perm"; if ($perm == 0) { $MissingCount++; $FormError["editlink"]["name"] = language("lu_ferror_no_access"); } else { $name = $_POST["name"]; $desc = $_POST["description"]; $url = $_POST["url"]; $MissingCount = SetMissingDataErrors("editlink"); if(is_array($_FILES)) { foreach($_FILES as $field => $file) { $allowed = TRUE; if(strlen($_POST["imagetypes"][$field])) { $types = explode(",",strtolower($_POST["imagetypes"][$field])); if(is_array($types)) { if(count($types)>0) { $path_parts = pathinfo($file["name"]); $ext = $path_parts["extension"]; $allowed = in_array($ext,$types); if(!$allowed) { $MissingCount++; $FormError["editlink"][$field] = language("lu_ferror_wrongtype"); } } } } $maxsize = (int)$_POST["maxsize"][$field]; if($maxsize>0 && $allowed && $file["size"]>$maxsize) { $allowed = FALSE; $MissingCount++; $FormError["editlink"][$field] = language("lu_ferror_toolarge"); } } } if($MissingCount==0) { $link->Set("Name",$name); $link->Set("Url",$url); $link->Set("Description",$desc); $ExpireInterval = $objConfig->Get("link_ExpireMod_Value") * $objConfig->Get("link_ExpireMod_Interval"); if($ExpireInterval>0) $link->Set("Expire",adodb_date("U")+$ExpireInterval); $link->Update(); if($perm==1) { $link->SendUserEventMail("LINK.MODIFY",$link->Get("ModifiedById")); $link->SendAdminEventMail("LINK.MODIFY"); } else { $link->SendUserEventMail("LINK.MODIFY.PENDING",$link->Get("ModifiedById")); $link->SendAdminEventMail("LINK.MODIFY.PENDING"); } $LinkResourceId= $link->Get("ResourceId"); $objCustomFields = new clsCustomFieldList(1); $field_list = $objCustomFields->Query_CustomField("Type=".$link->type); $objCustomDataList->LoadResource($LinkResourceId); for($i=0;$i<$objCustomFields->NumItems(); $i++) { $field = & $objCustomFields->GetItemRefByIndex($i); $fieldid= $field->Get("CustomFieldId"); $fname = $field->Get("FieldName"); if(isset($_POST[$fname])) $objCustomDataList->SetFieldValue($fieldid,$LinkResourceId,$_POST[$fname]); elseif(isset($_POST[strtolower($fname)])) $objCustomDataList->SetFieldValue($fieldid,$LinkResourceId,$_POST[strtolower($fname)]); } $objCustomDataList->SaveData(); //if($perm==2) //$link->AddToCategory($CategoryId); /* handle any image uploads */ if(is_array($_FILES)) { foreach($_FILES as $field => $file) { if($file["size"]>0) { $imgname = $_POST["imagename"][$field]; $thumb = $_POST["isthumb"][$field]; $IsDefault = (int)$_POST["imgdefault"][$field]; if($thumb) { $LocalThumb=1; } else $LocalImage=1; $img = $objImageList->GetImageByName($LinkResourceId,$imgname); if(!is_object($img)) { $img =& $objImageList->Add($imgname, "", $LinkResourceId, $LocalImage, $LocalThumb, "", "", 1, 0, $IsDefault, 0,0); } if($thumb) { $img->Set("LocalThumb",1); $url = $img->StoreUploadedImage($file, 1,"kernel/images/",$thumb); $img->Set("ThumbPath",$url); } else { $img->Set("LocalImage",1); $url = $img->StoreUploadedImage($file, 1,"kernel/images/",$thumb); $img->Set("LocalPath",$url); } $img->Update(); } } } $application->SetVar('l_id', ''); if(strlen($_GET["Confirm"])) { $var_list["t"] = $_GET["Confirm"]; } else { $var_list["t"] = $_GET["DestTemplate"]; } } } break; case "l_delete_link": $link = $objLinkList->GetItem($l_var_list["id"]); $catid = $link->GetPrimaryCategory(); if($objSession->HasCatPermission("LINK.DELETE",$catid) || ($objSession->Get("PortalUserId")==$link->Get("CreatedById") && $objSession->HasCatPermission("LINK.OWNER.DELETE",$catid))) { $link->Delete(); } UpdateCategoryCount("Link", $catid, $objLinkList->GetListTypes()); break; case "m_simple_search": $type = $objItemTypes->GetTypeByName("Link"); $keywords = trim($_POST["keywords"]); $length = $objConfig->Get('Search_MinKeyword_Length'); $isExact = (substr($keywords, 0, 2) == '\"' && substr($keywords, strlen($keywords) - 2, 2) == '\"'); if ($isExact) { $performSearch = (strlen(trim(str_replace('\"', '', $keywords))) >= $length); } else { $key_arr = explode(' ', $keywords); /*foreach($key_arr as $value) { if (strlen($value) < $length) { $keywords = str_replace(' '.$value, '', $keywords); $keywords = str_replace($value.' ', '', $keywords); } }*/ //$keywords = str_replace(' ', ' ', $keywords); $performSearch = (strlen($keywords) >= $length); } if ($performSearch) { $objLinkSearch = new clsSearchResults("Link",$objLinkList->classname); $objLinkSearch->SetKeywords($keywords); $objLinkSearch->AddSimpleFields(); if(is_numeric($objConfig->Get("SearchRel_Pop_links"))) $objLinkSearch->PctPop = ($objConfig->Get("SearchRel_Pop_links")/100); if(is_numeric($objConfig->Get("SearchRel_Keyword_links"))) $objLinkSearch->PctRelevance = ($objConfig->Get("SearchRel_Keyword_links")/100); if(is_numeric($objConfig->Get("SearchRel_Rating_links"))) $objLinkSearch->PctRating = ($objConfig->Get("SearchRel_Rating_links")/100); $objLinkSearch->PerformSearch($type->Get("ItemType"),$SortOrder,FALSE); //$objLinkSearch->SetRelevence($type->Get("ItemType"), "LinkId"); //echo "Finished Setting Link Relevence
\n"; } break; case "m_adv_search": switch($_GET["type"]) { case 4: /* link */ //echo "Searching Links
"; $objAdvSearch = new clsAdvancedSearchResults("Link",$objLinkList->classname, $_GET["type"]); foreach($objSearchConfig->Items as $field) { $fld = $field->Get("FieldName"); $Verb = $_POST["verb"][$fld]; if(!strlen($Verb) && $field->Get("FieldType")=="boolean") { if($_POST["value"][$field->Get("FieldName")]!=-1) { $Value = $_POST["value"][$fld]; $Verb = "is"; } } else { $Value = $_POST["value"][$fld]; } switch( $_POST["andor"][$fld]) { case 1: $Conjuction = "AND"; break; case 2: $Conjuction = "OR"; break; default: $Conjuction = ""; break; } if (strlen($Value) && $Verb=="any") { $Verb = 'contains'; } if(strlen($Value) && strlen($Verb)>0 && $Verb!="any") { //echo "Adding LINK SearchField: [".$field->Get("TableName")."]; [".$field->Get("FieldName")."]; [$Verb]; [$Value]; [$Conjuction]
"; $objAdvSearch->AddAdvancedField($field->Get("TableName"),$field->Get("FieldName"),$Verb,$Value,$Conjuction); } } $objAdvSearch->PerformSearch(4,NULL,TRUE); break; } break; case "m_simple_subsearch": $keywords = $_POST["keywords"]; $type = $objItemTypes->GetTypeByName("Link"); if(strlen($keywords)) { $objLinkSearch = new clsSearchResults("Link",$objLinkList->classname); $objLinkSearch->SetKeywords($keywords); $objLinkSearch->AddSimpleFields(); //$SearchResultIdList = $objLinkSearch->Result_IdList(); if(is_numeric($objConfig->Get("SearchRel_Pop_links"))) $objLinkSearch->PctPop = ($objConfig->Get("SearchRel_Pop_links")/100); if(is_numeric($objConfig->Get("SearchRel_Keyword_links"))) $objLinkSearch->PctRelevance = ($objConfig->Get("SearchRel_Keyword_links")/100); if(is_numeric($objConfig->Get("SearchRel_Rating_links"))) $objLinkSearch->PctRating = ($objConfig->Get("SearchRel_Rating_links")/100); if(count($SearchResultIdList)>0) { $objLinkSearch->PerformSearch($type->Get("ItemType"),$SortOrder,FALSE,$SearchResultIdList); //$objLinkSearch->SetRelevence($type->Get("ItemType"), "LinkId"); } } break; } ?>