dp13668681869 2015-10-14 22:46
浏览 7

PHP根据用户字段设置位置内的作业

Got a strange problem here on my little project, I have an account area that people can set a location so we can suggest job openings within the area they live in.

EDIT: Code indented - Sorry

The locations that do not work are "Maidstone" & "Medway". These locations are all stored in the database, When another user adds a job they can set the location the job is in and that will then add that job to the database under "State" String.

Other Locations such as Canterbury do work and the jobs that are listed under the Canterbury location show up on the users account as they should.

This php works for every location other then 2 of them which is really strange.

<?php

class SJB_Classifieds_SuggestedJobs extends SJB_Function
{
    public function execute()
    {
        $tp = SJB_System::getTemplateProcessor();
        $count_listing = SJB_Request::getVar('count_listing', 10, null, 'int');
        $current_user = SJB_UserManager::getCurrentUser();

                $properties = $current_user->getProperties();
                foreach ($properties as $property) {
                    if ($property->getType() == 'location') {
                        $fields = $property->type->child;
                        $childProperties = $fields->getProperties();
                        foreach ($childProperties as $childProperty) {
                            if (in_array($childProperty->getID(), array('State'))) {
                                $value = $childProperty->getValue();
                                switch ($childProperty->getType()) {
                                    case 'list':
                                        if ($childProperty->getID() == 'State') {
                                            $displayAS = $childProperty->display_as;
                                            $displayAS = $displayAS?$displayAS:'State';
                                            $listValues = SJB_StatesManager::getStatesNamesByCountry(false, true, $displayAS);
                                        }
                                        else
                                            $listValues = $childProperty->type->list_values;
                                        foreach ($listValues as $values) {
                                            if ($value == $values['id'])
                                                $phrase[strtolower($childProperty->getID())] = $values['caption'];
                                        }
                                        break;
                                    default:
                                        $phrase[strtolower($childProperty->getID())] = $value;
                                        break;
                                }
                            }
                        }
                    }
                }
                $phrase = array_diff($phrase, array(''));
                $phrase = implode(" ", $phrase);

                $listing_type_id = "Job";

                $request['action'] = 'search';
                $request['listing_type']['equal'] = $listing_type_id;
                $request['default_listings_per_page'] = $count_listing;
                $request['default_sorting_field'] = "activation_date";
                $request['default_sorting_order'] = "DESC";
                $request['keywords']['relevance'] = $phrase;
                $searchResultsTP = new SJB_SearchResultsTP($request, $listing_type_id, array('field'=>'keywords', 'value'=>$phrase));
                $tp = $searchResultsTP->getChargedTemplateProcessor();
            $tp->display('suggested_jobs.tpl');
        }
    }

Not sure if my problem is due to the PHP that tells which jobs to display.

Could someone just skip though the PHP and let me know if anythings wrong? I really want to work this out on my own however I'm alittle lost and if i can find out that the PHP is fine then I can figure it out some where else :)

Thanks!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向
    • ¥15 如何用python向钉钉机器人发送可以放大的图片?
    • ¥15 matlab(相关搜索:紧聚焦)
    • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
    • ¥15 路易威登官网 里边的参数逆向
    • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
    • ¥50 需求一个up主付费课程