Exemplo n.º 1
0
 public function executeMassiveAdd($request)
 {
     $this->massive_form = new MassiveForm();
     if (!$request->getParameter('filename')) {
         $this->redirect('operation/upload');
     } else {
         if ($request->isMethod('post')) {
             $this->massive_form->bind($request->getParameter('massive'));
             if ($this->massive_form->isValid()) {
                 $filename = sfConfig::get('sf_root_dir') . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . $request->getParameter('filename');
                 $org_id = $request->getParameter('org_id');
                 $list_id = $request->getParameter('list_id');
                 $category_id = $request->getParameter('category_id');
                 $relationship_description = $request->getParameter('relationship_description');
                 $source_url = $request->getParameter('massive[source]');
                 $source_name = $request->getParameter('massive[name]');
                 $q = LsQuery::getByModelAndFieldsQuery('Relationship', array('category_id' => $category_id, 'description1' => $relationship_description))->fetchOne();
                 if (!$category_id && !$org_id || $category_id && !$relationship_description || $category_id && $q) {
                     $scraper = new MassAddScraper(false, false, sfContext::getInstance()->getConfiguration(), $this->getUser());
                     $scraper->setShowTime(false);
                     $scraper->disableBeep();
                     $scraper->setOptions($filename, $source_url, $source_name, $list_id, $org_id, $category_id, $relationship_description);
                     $scraper->run();
                     $errors = $scraper->getErrors();
                     $edits = $scraper->getEdits();
                     $this->filename = $request->getParameter('filename');
                     $this->original = $request->getParameter('original');
                     $this->getUser()->setAttribute('edits', $edits);
                     $this->getUser()->setAttribute('errors', $errors);
                     $this->redirect('operation/massiveReview');
                 } else {
                     $this->getUser()->setFlash('notice', 'Problems with relationship section. If org is set, make sure category is set.  Also, title/description must already exist in db for specific category.');
                 }
             }
         }
     }
     $this->filename = $request->getParameter('filename');
     $this->original = $request->getParameter('original');
     $this->org = isset($org_id) ? Doctrine::getTable('Entity')->find($org_id) : null;
     $this->list = isset($list_id) ? Doctrine::getTable('LsList')->find($list_id) : null;
     $this->category_id = isset($category_id) ? $category_id : null;
     $this->categories = RelationshipCategoryTable::getByExtensionsQuery('Person', 'Org')->execute();
 }
Exemplo n.º 2
0
<?php

include_partial('relationship/header', array('relationship' => $relationship, 'show_actions' => true));
?>


<?php 
include_partial('relationship/rightcol', array('relationship' => $relationship));
?>


<?php 
if (!cache('main', 86400)) {
    ?>

<div class="relationship-main">
<?php 
    include_partial('relationship/' . strtolower(RelationshipCategoryTable::getNameById($relationship['category_id'])) . 'view', array('relationship' => $relationship, 'current' => $current));
    ?>
</div>

<?php 
    cache_save();
}
Exemplo n.º 3
0
 public function getCategoryDefaultDescription()
 {
     if ($name = RelationshipCategoryTable::getDefaultDescriptionById($this->category_id)) {
         return $name;
     }
     if ($category = $this->getCategory()) {
         return $category->default_description;
     }
     return null;
 }
Exemplo n.º 4
0
 static function getNameByRelationshipAndEntities($relationship, $entity1, $entity2)
 {
     //return generic name if components are missing
     if (!$entity1['name'] || !$entity2['name'] || !$relationship['category_id']) {
         return 'Relationship';
     }
     $categoryName = RelationshipCategoryTable::getNameById($relationship['category_id']);
     return $categoryName . ': ' . $entity1['name'] . ', ' . $entity2['name'];
 }
Exemplo n.º 5
0
 public function executeToolbarCategories($request)
 {
     $this->checkToolbarCredentials();
     $ext1 = $request->getParameter('ext1');
     $ext2 = $request->getParameter('ext2');
     $this->categories = RelationshipCategoryTable::getByExtensionsQuery($ext1, $ext2)->select('c.name')->fetchArray();
 }
Exemplo n.º 6
0
 public function executeAddRelationshipCategory($request)
 {
     $this->checkEntity($request, false, false);
     $this->entity2 = Doctrine::getTable('Entity')->find($request->getParameter('entity2_id'));
     $this->forward404Unless($this->entity2);
     $ext1 = $this->entity->getPrimaryExtension();
     $ext2 = $this->entity2->getPrimaryExtension();
     $this->categories = RelationshipCategoryTable::getByExtensionsQuery($ext1, $ext2)->execute();
     $this->reference_form = new ReferenceForm();
     $rel = new Relationship();
     $rel->Entity1 = $this->entity;
     $rel->Entity2 = $this->entity2;
     $this->reference_form->setSelectObject($rel);
     if ($request->isMethod('post')) {
         $refParams = $request->getParameter('reference');
         $this->reference_form->bind($refParams);
         if ($this->reference_form->isValid()) {
             //lobbying will need to be handled seperately
             if ($request->getParameter('category_id') == RelationshipTable::LOBBYING_CATEGORY) {
                 switch ($request->getParameter('lobbying_scenario')) {
                     case 'direct':
                         $r = new Relationship();
                         $r->Entity1 = $this->entity;
                         $r->Entity2 = $this->entity2;
                         $r->setCategory('Lobbying');
                         break;
                     case 'direct_reverse':
                         $r = new Relationship();
                         $r->Entity1 = $this->entity2;
                         $r->Entity2 = $this->entity;
                         $r->setCategory('Lobbying');
                         break;
                     case 'service':
                         $r = new Relationship();
                         $r->Entity1 = $this->entity;
                         $r->Entity2 = $this->entity2;
                         $r->setCategory('Transaction');
                         $r->description1 = 'Lobbying Client';
                         $r->description2 = $this->entity2['primary_ext'] == 'Org' ? 'Lobbying Firm' : 'Lobbyist';
                         break;
                     case 'service_reverse':
                         $r = new Relationship();
                         $r->Entity1 = $this->entity2;
                         $r->Entity2 = $this->entity;
                         $r->setCategory('Transaction');
                         $r->description1 = 'Lobbying Client';
                         $r->description2 = $this->entity['primary_ext'] == 'Org' ? 'Lobbying Firm' : 'Lobbyist';
                         break;
                     default:
                         $request->setError('lobbying_scenario', "You must pick a type of lobbying relationship to create");
                         return sfView::SUCCESS;
                         break;
                 }
                 $r->saveWithRequiredReference($refParams);
                 LsCache::clearRelationshipCacheById($r->id);
                 $this->redirect($r->getInternalUrl('edit', array('ref' => 'auto')));
             }
             if ($category = Doctrine::getTable('RelationshipCategory')->find($request->getParameter('category_id'))) {
                 //save relationship and reference
                 $r = new Relationship();
                 $r->Entity1 = $this->entity;
                 $r->Entity2 = $this->entity2;
                 $r->setCategory($category->name);
                 $r->switchEntityOrderIfNecessary();
                 $r->saveWithRequiredReference($refParams);
                 LsCache::clearRelationshipCacheById($r->id);
                 //redirect to edit page
                 $this->redirect($r->getInternalUrl('edit', array('ref' => 'auto')));
             } else {
                 $request->setError('category_id', "You must select a category");
             }
         } else {
             if (!($categoryId = $request->getParameter('category_id'))) {
                 $request->setError('category_id', "You must select a category");
             }
         }
     }
 }