public function addIdentifiers($num, $people_ref, $order_by = 0)
 {
     $options = array('referenced_relation' => 'identifications', 'people_type' => 'identifier', 'order_by' => $order_by, 'people_ref' => $people_ref);
     $val = new CataloguePeople();
     $val->fromArray($options);
     $val->setRecordId($this->getObject()->getId());
     $form = new IdentifiersForm($val);
     $this->embeddedForms['newIdentifier']->embedForm($num, $form);
     //Re-embedding the container
     $this->embedForm('newIdentifier', $this->embeddedForms['newIdentifier']);
 }
 /**
  * Get Distincts Sub Type of properties
  * filter by type if one given
  * @param string $type a type
  * @return array an Array of sub-types in keys/values
  */
 public function getDistinctSubType($type = null)
 {
     if ($type == "author") {
         return CataloguePeople::getAuthorTypes();
     }
     $q = $this->createDistinct('CataloguePeople INDEXBY sub_type', 'people_sub_type', 'sub_type', '');
     if (!is_null($type)) {
         $q->addWhere('people_type = ?', $type);
     }
     $results = $q->fetchArray();
     if (count($results)) {
         $results = array_combine(array_keys($results), array_keys($results));
     }
     return $results;
 }
 public function configure()
 {
     unset($this['referenced_relation']);
     $this->widgetSchema['people_type'] = new sfWidgetFormInputHidden();
     $this->widgetSchema['people_ref'] = new sfWidgetFormInputHidden();
     $this->validatorSchema['people_ref'] = new sfValidatorInteger(array('required' => false));
     $this->widgetSchema['record_id'] = new sfWidgetFormInputHidden();
     $this->validatorSchema['record_id'] = new sfValidatorInteger();
     $types = CataloguePeople::getTypes();
     $this->widgetSchema['order_by'] = new sfWidgetFormInputHidden();
     $this->validatorSchema['order_by'] = new sfValidatorInteger();
     $this->widgetSchema['people_sub_type'] = new sfWidgetFormChoice(array('choices' => $types, 'expanded' => true, 'multiple' => true, 'renderer_options' => array('formatter' => array('ActorsForm', 'RenderInLine'))));
     $this->validatorSchema['people_sub_type'] = new sfValidatorChoice(array('choices' => array_keys($types), 'required' => false, 'multiple' => true));
     $people_id = $this->getObject()->getPeopleRef();
     if ($people_id) {
         $people = Doctrine::getTable('People')->find($this->getObject()->getPeopleRef());
         $this->widgetSchema['people_ref']->setLabel($people->getFormatedName());
     } else {
         $this->widgetSchema['people_ref']->setAttribute('class', 'hidden_record');
         $this->validatorSchema['people_sub_type']->addOption('required', false);
     }
 }
<?php

include dirname(__FILE__) . '/../../bootstrap/functional.php';
$browser = new DarwinTestFunctional(new sfBrowser());
$browser->loadData($configuration)->login('root', 'evil');
$vernacular_names = new VernacularNames();
$vernacular_names->setCommunity('French');
$vernacular_names->setReferencedRelation('taxonomy');
$vernacular_names->setRecordId(4);
$vernacular_names->name = 'Faux con';
$vernacular_names->save();
$personId = Doctrine::getTable('People')->findOneByFamilyNameAndGivenName('Root', 'Evil')->getId();
$catalogue_people = new CataloguePeople();
$catalogue_people->setReferencedRelation('taxonomy');
$catalogue_people->setRecordId(4);
$catalogue_people->setPeopleType('authors');
$catalogue_people->setPeopleSubType('Main authors');
$catalogue_people->setPeopleRef($personId);
$catalogue_people->save();
$browser->info('2 - Recombined')->get('/widgets/reloadContent?widget=relationRecombination&category=catalogue_taxonomy&eid=4')->with('response')->begin()->isStatusCode(200)->checkElement('table tbody tr', 1)->checkElement('table tbody tr td:first a.link_catalogue', '/recombinus/')->checkElement('img', 3)->end();
$items = Doctrine::getTable('CatalogueRelationships')->getRelationsForTable('taxonomy', 4, 'current_name');
$browser->get('/catalogue/deleteRelated?table=catalogue_relationships&id=' . $items[0]['id'])->with('response')->begin()->isStatusCode(200)->end();
$browser->info('3 - Comment')->get('/widgets/reloadContent?widget=comment&category=catalogue_taxonomy&eid=4')->with('response')->begin()->isStatusCode(200)->checkElement('table tr', 2)->checkElement('table tr:last a.link_catalogue', '/taxon information/')->checkElement('table tr:last td:nth-child(2)', '/This is bullshit/')->end()->info('4 - Properties')->get('/widgets/reloadContent?widget=properties&category=catalogue_taxonomy&eid=4')->with('response')->begin()->isStatusCode(200)->checkElement('table tbody tr', 2)->checkElement('table tbody tr:first td:first', '/physical measurement/')->checkElement('table tbody tr:last td:first', '/protection status/')->end()->info('5 - Vernacular Names')->get('/widgets/reloadContent?widget=vernacularNames&category=catalogue_taxonomy&eid=4')->with('response')->begin()->isStatusCode(200)->checkElement('table tbody tr', 1)->checkElement('table tbody tr:first td:first', '/French/')->checkElement('table tbody tr:first td::nth-child(2)', '/Faux con/')->end()->info('6 - Synonymies')->get('/widgets/reloadContent?widget=synonym&category=catalogue_taxonomy&eid=4')->with('response')->begin()->isStatusCode(200)->checkElement('table.catalogue_table tbody table[alt="homonym"]', 1)->checkElement('table.catalogue_table tbody table[alt="synonym"]', 1)->checkElement('table.catalogue_table tbody table[alt="synonym"] tbody tr', 2)->checkElement('table.catalogue_table tbody table[alt="synonym"] tbody td:first[class="handle"]', 1)->checkElement('table.catalogue_table tbody table[alt="synonym"] tbody td:nth-child(2)', '/Duchesnus Brulus 1912/')->checkElement('table.catalogue_table tbody table[alt="synonym"] tbody tr:first td:nth-child(3)[class="basio_cell"]', 1)->checkElement('table.catalogue_table tbody table[alt="synonym"] tbody tr:first td:nth-child(4)[class="widget_row_delete"]', 1)->end();
$items = Doctrine::getTable('ClassificationSynonymies')->findOneByReferencedRelationAndRecordId('taxonomy', 4);
$browser->info('8 - Synonymies after a delete')->get('/synonym/delete?id=' . $items['id'])->with('response')->begin()->isStatusCode(200)->matches('/ok/')->end()->get('/widgets/reloadContent?widget=synonym&category=catalogue_taxonomy&eid=4')->with('response')->begin()->isStatusCode(200)->checkElement('table.catalogue_table tbody table[alt="homonym"]', 1)->checkElement('table.catalogue_table tbody table[alt="synonym"]', 0)->end()->info('9 - People related')->get('/widgets/reloadContent?widget=cataloguePeople&category=catalogue_taxonomy&eid=4')->with('response')->begin()->isStatusCode(200)->checkElement('table[class="widget_sub_table"] tbody td:first[class="handle"]', 1)->checkElement('table[class="widget_sub_table"] tbody td:nth-child(2)', '/Root Evil/')->checkElement('table[class="widget_sub_table"] tbody td:nth-child(3)[class="catalogue_people_sub_type"]', 1)->checkElement('table[class="widget_sub_table"] tbody td:last[class="widget_row_delete"]', 1)->end()->click('table[class="widget_sub_table"] tbody td:last[class="widget_row_delete"] > a')->with('response')->begin()->isStatusCode(200)->matches('/ok/')->end()->get('/widgets/reloadContent?widget=cataloguePeople&category=catalogue_taxonomy&eid=4')->with('response')->begin()->isStatusCode(200)->checkElement('table[class="widget_sub_table"]', 0)->end();
 public function addActorsReceiver($num, $people_ref, $order_by = 0)
 {
     if (!isset($this['newActorsReceiver'])) {
         $this->loadEmbedActorsReceiver();
     }
     $options = array('referenced_relation' => 'loans', 'people_ref' => $people_ref, 'people_type' => 'receiver', 'order_by' => $order_by);
     $val = new CataloguePeople();
     $val->fromArray($options);
     $val->setRecordId($this->getObject()->getId());
     $form = new ActorsForm($val);
     $this->embeddedForms['newActorsReceiver']->embedForm($num, $form);
     //Re-embedding the container
     $this->embedForm('newActorsReceiver', $this->embeddedForms['newActorsReceiver']);
 }
$author->setOrderBy(1);
$author->save();
$t->info('ML Duchesne as Author associated');
$catpeo = Doctrine::getTable('CataloguePeople')->findForTableByType('taxonomy', $taxon->getId());
$t->is(count($catpeo['author']), 2, 'With author key: "2" record.');
$t->is($catpeo['author'][0]->getPeople()->getGivenName(), 'Poilux', 'Type author and first person well associated to "Poilux"');
$t->is($catpeo['author'][1]->getPeople()->getGivenName(), 'ML', 'Type author and second person well associated to "ML"');
$t->info('Interverting order of "Poilux Duchesne" and "ML Duchesne"');
$catpeo = Doctrine_Query::create()->from('CataloguePeople c')->orderBy('referenced_relation ASC, order_by ASC, id ASC')->execute();
Doctrine::getTable('CataloguePeople')->changeOrder($catpeo[1]->getReferencedRelation(), $catpeo[1]->getRecordId(), 'author', array($catpeo[3]->getId(), $catpeo[1]->getId()));
$catpeo = Doctrine::getTable('CataloguePeople')->findForTableByType('taxonomy', $taxon->getId());
$t->is($catpeo['author'][0]->getPeople()->getGivenName(), 'ML', 'Type author and first person well associated to "ML"');
$t->is($catpeo['author'][1]->getPeople()->getGivenName(), 'Poilux', 'Type author and second person well associated to "Poilux"');
$t->info('Testing the getPeopleRelated method');
$specimen = Doctrine::getTable('Specimens')->findOneByTaxonRef($taxon->getId());
$identification = new Identifications();
$identification->setReferencedRelation('specimens');
$identification->setRecordId($specimen->getId());
$identification->setNotionConcerned('taxonomy');
$identification->setValueDefined('Joli Test');
$identification->save();
$identifier = new CataloguePeople();
$identifier->setReferencedRelation('identifications');
$identifier->setRecordId($identification->getId());
$identifier->setPeopleRef($person1->getId());
$identifier->setPeopleType('identifier');
$identifier->save();
$identifiers = Doctrine::getTable('CataloguePeople')->getPeopleRelated('identifications', 'identifier', $identification->getId());
$t->is($identifiers->count(), 1, '"One" identifier effectively created');
$t->is($identifiers[0]->getPeopleType(), 'identifier', 'New person created in catalogue people is well "identifier"');
$t->is($identifiers[0]->getPeople()->getGivenName(), 'Poilux', '"Poilux" is well the identifier created');
 public function setUp()
 {
     parent::setUp();
     $this->hasOne('Loans', array('local' => 'record_id', 'foreign' => 'id'));
 }
<?php

include dirname(__FILE__) . '/../../bootstrap/Doctrine.php';
$t = new lime_test(3, new lime_output_color());
$t->info('getAuthorTypes test');
$catPeo = new CataloguePeople();
$types = $catPeo->getAuthorTypes();
$t->is(count($types), 6, 'There are "6" differents types');
$t->is($types['Main Author'], 'Main Author', 'First type is well "Main Author"');
$t->is($types['Related'], 'Related', 'Last type is well "Related"');