示例#1
0
 public function executeDetails($request)
 {
     $this->relationship = array_merge($this->relationship, RelationshipApi::getDetails($this->relationship['id'], $this->relationship['category_id']));
     $this->entity1 = EntityApi::get($this->relationship['entity1_id']);
     $this->entity2 = EntityApi::get($this->relationship['entity2_id']);
     return 'Xml';
 }
示例#2
0
文件: ImagesApi.php 项目: romeo14/pow
 public static function getAllImages($imageOfId, $entityId)
 {
     $models = Images::model()->findAll('image_of_id=:imageOfId AND entity_id=:entityId', array(':imageOfId' => $imageOfId, ':entityId' => $entityId));
     $result = false;
     $entityName = EntityApi::getTypeById($entityId);
     foreach ($models as $model) {
         $result[] = ImageUtils::getImageUrl($entityName, $imageOfId, $model->filename);
     }
     return $result;
 }
示例#3
0
 static function getEntities($ids, $options = array())
 {
     $db = Doctrine_Manager::connection();
     $sql = 'SELECT ' . LsApi::generateSelectQuery(array('e' => 'Entity')) . ' FROM entity e WHERE e.id IN (' . implode(',', $ids) . ') AND e.is_deleted = 0';
     $stmt = $db->execute($sql);
     if (@$options['details']) {
         $entities = array();
         foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $entity) {
             $entities[] = array_merge($entity, EntityApi::getDetails($entity['id']));
         }
         return $entities;
     } else {
         return $stmt->fetchAll(PDO::FETCH_ASSOC);
     }
 }
 static function getEntityPatterns($id)
 {
     //clear this entity
     $patterns = array(self::getEntityPattern($id));
     //also clear related entities
     $db = Doctrine_Manager::connection();
     $sql = 'SELECT entity1_id, entity2_id FROM relationship r WHERE (entity1_id = ? OR entity2_id = ?) AND r.is_deleted = 0';
     $stmt = $db->execute($sql, array($id, $id));
     foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
         $relatedId = $row['entity1_id'] == $id ? $row['entity2_id'] : $row['entity1_id'];
         foreach (array('relationships', 'board', 'boards', 'related') as $part) {
             $patterns[] = '/entity/' . $relatedId . '/' . $part . '*';
         }
     }
     //also clear lists it's on
     $sql = 'SELECT le.list_id FROM ls_list_entity le WHERE le.entity_id = ?';
     $stmt = $db->execute($sql, array($id));
     foreach ($stmt->fetchAll(PDO::FETCH_COLUMN) as $listId) {
         $patterns[] = '/list/' . $listId . '/entities*';
     }
     //also clear parent entity, if any
     $entity = EntityApi::get($id);
     if ($parentId = $entity['parent_id']) {
         $patterns[] = '/entity/' . $parentId . '/child-orgs*';
     }
     return $patterns;
 }
示例#5
0
 public function actionAllwheels()
 {
     $userId = Yii::app()->user->id;
     $userId = 2;
     $wheelDetails = array();
     $allWheels = WheelApi::getWheelsByUserId($userId);
     $i = 0;
     foreach ($allWheels as $allWheel) {
         $wheelArray[$i++] = $allWheel->id;
     }
     $wheelImages = ImagesApi::getPrimaryImageForWheels($wheelArray);
     $wheelDefaultImage = ImageUtils::getDefaultImage('wheel');
     if ($allWheels) {
         foreach ($allWheels as $wheel) {
             $color = ColorApi::getColorById($wheel->color_id);
             $make = MakeApi::getMakeById($wheel->make_id);
             $model = ModelApi::getModelById($wheel->model_id);
             $entityId = EntityApi::getIdByType('WHEEL');
             $wheelRate = FeedbackApi::getRating($wheel->id, $entityId, 'WHEEL');
             $wheelRides = RidesApi::getCountOfWheelRides($wheel->id);
             $wheelPals = WheelApi::getNoOfPalsMetByWheelId($wheel->id);
             $wheelEcoMiles = RidesApi::getEcoMilesDrivenByWheel($wheel->id);
             $wheelRidesCount = 0;
             $wheelNotification = RidesApi::getUpcomingWheelRides($wheel->id);
             if ($wheelNotification) {
                 $wheelRidesCount = count($wheelNotification);
             }
             $wheelDetails[$wheel->id] = array('color' => $color->color, 'make' => $make->make, 'model' => $model->model, 'rate' => round($wheelRate), 'wheelRides' => $wheelRides, 'wheelPals' => $wheelPals[0]['palcnt'], 'wheelEcoMiles' => $wheelEcoMiles, 'wheelRidesCount' => $wheelRidesCount);
         }
     }
     $this->render('allwheels', array('allWheels' => $allWheels, 'wheelDetails' => $wheelDetails, 'wheelImages' => $wheelImages, 'wheelDefaultImage' => $wheelDefaultImage));
 }
示例#6
0
 public function executeFindConnections()
 {
     $request = $this->getRequest();
     if ($id2 = $request->getParameter('id2')) {
         if (!($this->entity2 = EntityApi::get($id2))) {
             $this->forward404();
         }
         $page = $this->page;
         $num = $request->getParameter('num', 10);
         $options = array('cat_ids' => $request->getParameter('cat_ids', '1'));
         //get all chains
         $chains = SearchApi::getEntitiesChains($this->entity['id'], $id2, $options);
         $offset = ($page - 1) * $num;
         $flat_chains = array();
         foreach ($chains as $degree => $ary) {
             foreach ($ary as $ids) {
                 $flat_chains[] = $ids;
             }
         }
         $page_chains = array_slice($flat_chains, $offset, $num);
         $full_chains = array();
         foreach ($page_chains as $ids) {
             $full = array();
             $chain = SearchApi::buildRelationshipChain($ids, explode(',', $options['cat_ids']));
             foreach ($chain as $id => $rels) {
                 $entity = EntityApi::get($id);
                 $entity['Relationships'] = count($rels) ? BatchApi::getRelationships($rels, array()) : array();
                 $full[] = $entity;
             }
             $full_chains[] = $full;
         }
         // foreach ($page_chains as $degree => $ary)
         // {
         //   foreach ($ary as $ids)
         //   {
         //     if ($count == $page)
         //     {
         //       $chain = SearchApi::buildRelationshipChain($ids, explode(',', $options['cat_ids']));
         //       break 2;
         //     }
         //     $count++;
         //   }
         // }
         // count total number of chains
         // $total = 0;
         // foreach ($chains as $degree => $ary)
         // {
         //   $total += count($ary);
         // }
         if ($total = count($flat_chains)) {
             $chainAry = array_fill(0, $total, null);
             array_splice($chainAry, $offset, $num, $full_chains);
             $this->chain_pager = new LsDoctrinePager($chainAry, $page, $num);
         }
         // get entities for chain
         // if ($chain)
         // {
         //   $this->entities = array();
         //   foreach ($chain as $id => $rels)
         //   {
         //     $entity = EntityApi::get($id);
         //     $entity['Relationships'] = count($rels) ? BatchApi::getRelationships($rels, array()) : array();
         //     $this->entities[] = $entity;
         //   }
         //   $chainAry = array_fill(0, $total, null);
         //   $chainAry[$page-1] = $this->entities;
         //   $this->chain_pager = new LsDoctrinePager($chainAry, $page, $num);
         // }
     } else {
         //form submission, display matching persons
         if ($request->hasParameter('q')) {
             $num = $request->getParameter('num', 10);
             $page = $request->getParameter('page', 1);
             if (!($terms = $request->getParameter('q'))) {
                 $this->entity_pager = new LsDoctrinePager(array(), $page, $num);
             } else {
                 switch (sfConfig::get('app_search_engine')) {
                     case 'sphinx':
                         $this->entity_pager = EntityTable::getSphinxPager($terms, $page, $num);
                         break;
                     case 'lucene':
                         $ary = EntityTable::getLuceneArray($terms, null);
                         $this->entity_pager = new LsDoctrinePager($ary, $page, $num);
                         break;
                     case 'mysql':
                     default:
                         $terms = explode(' ', $terms);
                         $q = EntityTable::getSimpleSearchQuery($terms);
                         $this->entity_pager = new Doctrine_Pager($q, $page, $num);
                         break;
                 }
             }
         }
     }
 }
示例#7
0
 public function actionView($id)
 {
     Yii::beginProfile('view_profile');
     //$session = Yii::app()->session;
     $wheelsImages = array();
     $wheelImages = array();
     $lastRide = array();
     $user = UserApi::getUserById($id);
     if (!$user) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     $userAge = UserApi::getAge($user->dob);
     $userAddress = "";
     if ($user->city_id) {
         $userAddress = DbUtils::getAddress($user->city_id);
     }
     $imageUserId = array($id);
     $image = ImagesApi::getPrimaryImageForUsers($imageUserId);
     if ($image) {
         $userImage = $image[$id];
     } else {
         $userImage = ImageUtils::getDefaultImage('user');
     }
     $userWheelDefault = ImageUtils::getDefaultImage('wheel');
     $userRides = RidesApi::getCountOfUserRides($id);
     $userEcoMiles = RidesApi::getEcoMilesDrivenByUser($id);
     $userWheel = WheelApi::getWheelsCount($id);
     $userPalsCount = UserPalsApi::getPalsCount($id);
     $entityId = EntityApi::getIdByType("user");
     $driverRating = round(FeedbackApi::getRating($id, $entityId, 'DRIVER'));
     $passengerRating = round(FeedbackApi::getRating($id, $entityId, 'PASSENGER'));
     $userPals = UserPalsApi::getAllPals($id);
     $userPalDefaultImage = ImageUtils::getDefaultImage('user');
     $lastRide = RidesApi::getLastRide($id);
     $lastRideWheel = WheelApi::getWheelById($lastRide[0]['wheel_id']);
     $userWheels = WheelApi::getWheelsByUserId($id);
     $favoriteWheel = WheelApi::getFavouriteWheel($id);
     $userFeedback = FeedbackApi::getAllFeedback($id, $entityId);
     $favWheelDetail = "";
     $wheelMake = "";
     $wheelModel = "";
     $wheelColor = "";
     $wheelRides = "";
     $wheelEcoMiles = "";
     $wheelPals = "";
     $wheelPalCnt = "";
     if ($favoriteWheel) {
         $favWheelDetail = WheelApi::getWheelById($favoriteWheel[0]["wheel_id"]);
         $wheelMake = MakeApi::getMakeById($favWheelDetail->make_id);
         $wheelModel = ModelApi::getModelById($favWheelDetail->model_id);
         $wheelColor = ColorApi::getColorById($favWheelDetail->color_id);
         $wheelRides = RidesApi::getCountOfWheelRides($favWheelDetail->id);
         $wheelImage = ImagesApi::getPrimaryImageForWheels(array($favoriteWheel[0]["wheel_id"]));
         if (!$wheelImage) {
             $wheelImage = $userWheelDefault;
         }
         $wheelEcoMiles = RidesApi::getEcoMilesDrivenByWheel($favWheelDetail->id);
         $wheelPals = WheelApi::getNoOfPalsMetByWheelId($favWheelDetail->id);
         $wheelPalCnt = $wheelPals[0]['palcnt'];
     }
     $i = 0;
     if ($userFeedback) {
         foreach ($userFeedback as $feedback) {
             $fromUserProfile = UserApi::getUserById($feedback->from_user_id);
             $fromUserIds[$i] = $feedback->from_user_id;
             $userName = UserApi::getNameByUserId($fromUserProfile->id);
             $userFeedbackDetails[$i++] = array('from_id' => $feedback->from_user_id, 'userName' => $userName, 'feedback' => $feedback->feedback);
         }
     }
     $i = 0;
     $j = 0;
     $userPalList = "";
     $palScrollLabel = "";
     $mergeArray = array_merge($userPals, $fromUserIds);
     $userIdList = array_unique($mergeArray);
     $userImages = ImagesApi::getPrimaryImageForUsers($userIdList);
     $imageArrayIndex = array_keys($userImages);
     $imageArrayIndexSize = count($imageArrayIndex);
     //var_dump($userPals);
     // var_dump($fromUserIds);die();
     if ($userPals) {
         foreach ($userPals as $userPal) {
             $userPalList[$i++] = userapi::getUserById($userPal);
         }
     }
     if ($userIdList) {
         foreach ($userIdList as $userId) {
             for ($j = 0; $j < $imageArrayIndexSize; $j++) {
                 $palsImages[$userId] = '';
                 if ($imageArrayIndex[$j] == $userId) {
                     $palsImages[$userId] = $userImages[$userId];
                     break;
                 }
             }
             if ($palsImages[$userId] == '') {
                 $palsImages[$userId] = $userPalDefaultImage;
             }
         }
     }
     if ($userWheels) {
         foreach ($userWheels as $wheel) {
             $wheelIds[$wheel->id] = $wheel->id;
         }
         if ($wheelIds) {
             $wheelImages = ImagesApi::getPrimaryImageForWheels($wheelIds);
             if ($wheelImages) {
                 $imageArrayIndex = array_keys($wheelImages);
                 $imageArrayIndexSize = count($imageArrayIndex);
                 foreach ($wheelIds as $wheelId) {
                     for ($j = 0; $j < $imageArrayIndexSize; $j++) {
                         $wheelsImages[$wheelId] = '';
                         if ($imageArrayIndex[$j] == $wheelId) {
                             $wheelsImages[$wheelId] = $wheelImages[$wheelId];
                             break;
                         }
                     }
                     if ($wheelsImages[$wheelId] == '') {
                         $wheelsImages[$wheelId] = $userWheelDefault;
                     }
                 }
             }
         }
     }
     /*$palCntArray=ceil($userPalsCount/3);
         $l=0;
         if($userPalsCount>2){
         
         for($i=0;$i<$palCntArray-1;$i++){
             $palScroll[$i]=array($userPalList[$l],$userPalList[$l+1],$userPalList[$l+2]);
             $l=$l+3;
             }
             
         }
         while($l<$userPalsCount)
         {
         $palScroll[$palCntArray-1]=array($userPalList[$l]);
         $l++;
         }
         $palScrollLabel=$palScroll[0];
         }
         
         
       
        $k=1;
       if (isset($_POST['ajxbtn'])){
               if($k < $palCntArray) 
                $palScrollLabel=$palScroll[$k];
                $k++; 
           }
       */
     $this->render('view', array('user' => $user, 'userAddress' => $userAddress, 'userPalsCount' => $userPalsCount, 'userAge' => $userAge, 'userImage' => $userImage, 'userEcoMiles' => $userEcoMiles, 'userPals' => $userPals, 'userRides' => $userRides, 'userWheel' => $userWheel, 'driverRating' => $driverRating, 'passengerRating' => $passengerRating, 'userPalList' => $userPalList, 'favWheelDetail' => $favWheelDetail, 'wheelMake' => $wheelMake, 'wheelColor' => $wheelColor, 'wheelModel' => $wheelModel, 'wheelRides' => $wheelRides, 'wheelEcoMiles' => $wheelEcoMiles, 'wheelPalCnt' => $wheelPalCnt, 'palScrolls' => $palScrollLabel, 'palImages' => $palsImages, 'userFeedbackDetails' => $userFeedbackDetails, 'wheelsImages' => $wheelsImages, 'userWheels' => $userWheels, 'wheelImage' => $wheelImage, 'lastRide' => $lastRide, 'lastRideWheel' => $lastRideWheel));
     Yii::endProfile('view_profile');
 }
示例#8
0
 public function executeAddresses($request)
 {
     $this->setResponseFormat(array('json'));
     $this->data = EntityApi::getAddresses($this->entity['id']);
     return $this->renderText(json_encode($this->data));
 }
示例#9
0
 static function getRelatedOrgSummary($entity)
 {
     $orgNames = array();
     $options = array('cat_ids' => implode(',', array(RelationshipTable::POSITION_CATEGORY, RelationshipTable::MEMBERSHIP_CATEGORY)), 'order' => 1);
     $orgs = EntityApi::getRelated($entity['id'], $options);
     foreach ($orgs as $id => $org) {
         $orgNames[] = $org['name'];
     }
     return '(' . implode('; ', $orgNames) . ')';
 }
示例#10
0
 public function executeEntitiesChains($request)
 {
     $options = $this->getParams(array('cat_ids', 'page'));
     $id1 = $request->getParameter('id1');
     $id2 = $request->getParameter('id2');
     if (!isset($options['cat_ids'])) {
         $options['cat_ids'] = '1';
     }
     $this->chains = SearchApi::getEntitiesChains($id1, $id2, $options);
     $this->chain = null;
     $page = isset($options['page']) ? $options['page'] : 1;
     $count = 1;
     foreach ($this->chains as $degree => $ary) {
         foreach ($ary as $ids) {
             if ($count == $page) {
                 $this->chain = SearchApi::buildRelationshipChain($ids, $options['cat_ids']);
                 break 2;
             }
             $count++;
         }
     }
     if ($this->chain) {
         $this->entities = array();
         foreach ($this->chain as $id => $rels) {
             $this->entities[$id] = EntityApi::get($id);
             $this->entities[$id]['relationship_ids'] = implode(',', $rels);
         }
     }
     return 'Xml';
 }
示例#11
0
 public function executeToolbar($request)
 {
     $this->checkToolbarCredentials(true);
     if ($request->isMethod('post')) {
         //if user wants to skip this relationship
         if ($request->getParameter('commit') == 'Skip') {
             $names = $this->getUser()->getAttribute('toolbar_names');
             array_shift($names);
             if (count($names)) {
                 $this->getUser()->setAttribute('toolbar_names', $names);
                 $this->redirect('relationship/toolbar');
             } else {
                 $entityId = $this->getUser()->getAttribute('toolbar_entity');
                 $entity = Doctrine::getTable('Entity')->find($entityId);
                 $this->getUser()->setAttribute('toolbar_names', null);
                 $this->getUser()->setAttribute('toolbar_ref', null);
                 $this->getUser()->setAttribute('toolbar_entity', null);
                 $this->getUser()->setAttribute('toolbar_defaults', null);
                 $this->redirect($entity->getInternalUrl());
             }
         }
         //if user wants to clear bulk queue
         if ($request->getParameter('commit') == 'Clear') {
             $entityId = $this->getUser()->getAttribute('toolbar_entity');
             $entity = Doctrine::getTable('Entity')->find($entityId);
             $this->getUser()->setAttribute('toolbar_names', null);
             $this->getUser()->setAttribute('toolbar_ref', null);
             $this->getUser()->setAttribute('toolbar_entity', null);
             $this->getUser()->setAttribute('toolbar_defaults', null);
             $this->redirect($entity->getInternalUrl());
         }
         $entity1Id = $request->getParameter('entity1_id');
         $entity2Id = $request->getParameter('entity2_id');
         $categoryName = $request->getParameter('category_name');
         $refSource = $request->getParameter('reference_source');
         $refName = $request->getParameter('reference_name');
         $categoryParams = $request->getParameter('relationship');
         $startDate = $categoryParams['start_date'];
         $endDate = $categoryParams['end_date'];
         unset($categoryParams['start_date'], $categoryParams['end_date']);
         if (!$entity1Id || !$entity2Id || !$categoryName || !$refSource || !$refName) {
             $this->forward('error', 'invalid');
         }
         if (!($entity1 = EntityApi::get($entity1Id))) {
             $this->forward('error', 'invalid');
         }
         if (!($entity2 = EntityApi::get($entity2Id))) {
             $this->forward('error', 'invalid');
         }
         $db = Doctrine_Manager::connection();
         $sql = 'SELECT name FROM relationship_category ' . 'WHERE (entity1_requirements IS NULL OR entity1_requirements = ?) ' . 'AND (entity2_requirements IS NULL OR entity2_requirements = ?)';
         $stmt = $db->execute($sql, array($entity1['primary_ext'], $entity2['primary_ext']));
         $validCategoryNames = $stmt->fetchAll(PDO::FETCH_COLUMN);
         if (!in_array($categoryName, $validCategoryNames)) {
             $request->setError('category', 'Invalid relationship; try changing the category or switching the entity order');
             //check session for bulk names
             if ($bulkEntityId = $this->getUser()->getAttribute('toolbar_entity')) {
                 if ($this->entity1 = Doctrine::getTable('Entity')->find($bulkEntityId)) {
                     if ($names = $this->getUser()->getAttribute('toolbar_names')) {
                         $this->entity2_name = array_shift($names);
                         if ($refId = $this->getUser()->getAttribute('toolbar_ref')) {
                             $this->ref = Doctrine::getTable('Reference')->find($refId);
                             $request->getParameterHolder()->set('title', $this->ref->name);
                             $request->getParameterHolder()->set('url', $this->ref->source);
                         }
                         if ($defaults = $this->getUser()->getAttribute('toolbar_defaults')) {
                             if (isset($defaults['category'])) {
                                 $this->category = $defaults['category'];
                             }
                         }
                     }
                 }
             }
             if ($createdId = $request->getParameter('created_id')) {
                 $this->created_rel = Doctrine::getTable('Relationship')->find($createdId);
             }
             return sfView::SUCCESS;
         }
         if (!preg_match('/^http(s?)\\:\\/\\/.{3,193}/i', $refSource)) {
             $this->forward('error', 'invalid');
         }
         //all's well, create relationship!
         $rel = new Relationship();
         $rel->setCategory($categoryName);
         $rel->entity1_id = $entity1['id'];
         $rel->entity2_id = $entity2['id'];
         //only set dates if valid
         if ($startDate && preg_match('#^\\d{4}-\\d{2}-\\d{2}$#', Dateable::convertForDb($startDate))) {
             $rel->start_date = Dateable::convertForDb($startDate);
         }
         if ($endDate && preg_match('#^\\d{4}-\\d{2}-\\d{2}$#', Dateable::convertForDb($endDate))) {
             $rel->end_date = Dateable::convertForDb($endDate);
         }
         $rel->fromArray($categoryParams, null, $hydrateCategory = true);
         $rel->save();
         //create reference
         $ref = new Reference();
         $ref->name = $refName;
         $ref->source = $refSource;
         $ref->object_id = $rel->id;
         $ref->object_model = 'Relationship';
         $ref->save();
         $redirect = 'relationship/toolbar?url=' . $refSource . '&title=' . $refName . '&created_id=' . $rel->id;
         //if there's a bulk queue, remove one from the start
         if ($isBulk = $request->getParameter('is_bulk')) {
             $names = $this->getUser()->getAttribute('toolbar_names');
             array_shift($names);
             if (count($names)) {
                 $this->getUser()->setAttribute('toolbar_names', $names);
                 //keep track of entity order while in queue
                 $this->getUser()->setAttribute('toolbar_switched', $request->getParameter('is_switched', 0));
                 $redirect = 'relationship/toolbar?created_id=' . $rel->id;
             } else {
                 //queue is finished; go to entity profile
                 $entityId = $this->getUser()->getAttribute('toolbar_entity');
                 $entity = Doctrine::getTable('Entity')->find($entityId);
                 $redirect = $entity->getInternalUrl();
                 $this->getUser()->setAttribute('toolbar_names', null);
                 $this->getUser()->setAttribute('toolbar_ref', null);
                 $this->getUser()->setAttribute('toolbar_entity', null);
                 $this->getUser()->setAttribute('toolbar_defaults', null);
                 $this->getUser()->setAttribute('toolbar_switched', null);
             }
         }
         LsCache::clearEntityCacheById($entity1['id']);
         LsCache::clearEntityCacheById($entity2['id']);
         $this->redirect($redirect);
     }
     //check session for bulk names
     if ($bulkEntityId = $this->getUser()->getAttribute('toolbar_entity')) {
         if ($this->entity1 = Doctrine::getTable('Entity')->find($bulkEntityId)) {
             if ($names = $this->getUser()->getAttribute('toolbar_names')) {
                 $this->entity2_name = array_shift($names);
                 if ($refId = $this->getUser()->getAttribute('toolbar_ref')) {
                     $this->ref = Doctrine::getTable('Reference')->find($refId);
                     $request->getParameterHolder()->set('title', $this->ref->name);
                     $request->getParameterHolder()->set('url', $this->ref->source);
                 }
                 if ($defaults = $this->getUser()->getAttribute('toolbar_defaults')) {
                     if (isset($defaults['category'])) {
                         $this->category = $defaults['category'];
                     }
                 }
             }
         }
         $this->is_switched = $this->getUser()->getAttribute('toolbar_switched', 0);
     }
     if ($createdId = $request->getParameter('created_id')) {
         $this->created_rel = Doctrine::getTable('Relationship')->find($createdId);
     }
     $this->setLayout($bulkEntityId ? 'layout' : 'toolbar');
 }
示例#12
0
 public function executeInterlocksMap($request)
 {
     $this->checkEntity($request, false, false);
     $num = $request->getParameter("num", 6);
     $degree1_num = $request->getParameter("degree1_num", 10);
     $order1 = $this->entity['primary_ext'] == 'Person' ? 1 : 2;
     $order2 = $this->entity['primary_ext'] == 'Person' ? 2 : 1;
     $options = array('cat1_ids' => RelationshipTable::POSITION_CATEGORY . ',' . RelationshipTable::MEMBERSHIP_CATEGORY, 'order1' => $order1, 'cat2_ids' => RelationshipTable::POSITION_CATEGORY . ',' . RelationshipTable::MEMBERSHIP_CATEGORY, 'order2' => $order2, 'page' => 1, 'num' => $num);
     $interlocks = EntityApi::getSecondDegreeNetwork($this->entity['id'], $options);
     $degree1_ids = array();
     $degree2_ids = array();
     $degree1_scores = array();
     foreach ($interlocks as $i) {
         $new_degree1_ids = explode(",", $i["degree1_ids"]);
         foreach ($new_degree1_ids as $id) {
             $degree1_scores[$id] = isset($degree1_scores[$id]) ? $degree1_scores[$id] + 1 : 1;
         }
         $degree1_ids = array_merge($degree1_ids, $new_degree1_ids);
         $degree2_ids[] = $i["id"];
     }
     arsort($degree1_scores);
     $degree1_ids = array_keys($degree1_scores);
     $degree1_ids = array_slice($degree1_ids, 0, $degree1_num);
     $entity_ids = array_unique(array_merge(array($this->entity["id"]), $degree1_ids, $degree2_ids));
     $cats = array(RelationshipTable::POSITION_CATEGORY, RelationshipTable::MEMBERSHIP_CATEGORY);
     $data = EntityTable::getEntitiesAndRelsForMap($entity_ids, $cats);
     /*
     foreach ($data["entities"] as $i => $entity)
     {
       $data["entities"][$i]["url"] = preg_replace("/map$/", "interlocksMap", $entity["url"]);
     }
     */
     $entities = array();
     foreach ($data["entities"] as $e) {
         array_push($entities, $e);
     }
     $this->data = json_encode(array("entities" => $entities, "rels" => $data["rels"]));
     $this->degree1_ids = $degree1_ids;
     $this->degree2_ids = $degree2_ids;
 }