public static function retrieveByNamespacePriority($namespace, $priority) { $c = new Criteria(); $c->add(sfLaunchingPeer::LAUNCH_NAMESPACE, $namespace); $c->add(sfLaunchingPeer::PRIORITY, $priority); return sfLaunchingPeer::doSelectOne($c); }
/** * Return the HTML code for the launch/remove link * plus the list of launched object for the namespace * * @param BaseObject $object Propel object instance to launch * @param string $namespace The namespace where the object is *launched* * @param array $options Array of HTML options to apply on the HTML list * @return string **/ function depp_launcher($object, $namespace, $options = array()) { if (is_null($object)) { sfLogger::getInstance()->debug('A NULL object cannot be launched'); return ''; } if (is_null($namespace)) { sfLogger::getInstance()->debug('A namespace must be given'); return ''; } try { $options = _parse_attributes($options); if (!isset($options['id'])) { $options = array_merge($options, array('id' => 'launching-items')); } if (!isset($options['class'])) { $options = array_merge($options, array('class' => 'vote-administration')); } $object_model = get_class($object); $object_id = $object->getPrimaryKey(); // build launch/remove link if (in_array($namespace, $object->hasBeenLaunched())) { $action_link = link_to(__('Take the launch back'), sprintf('deppLaunching/remove?item_model=%s&item_pk=%s&namespace=%s', $object_model, $object_id, $namespace)); } else { $action_link = link_to(__('Launch the object'), sprintf('deppLaunching/launch?item_model=%s&item_pk=%s&namespace=%s', $object_model, $object_id, $namespace)); } $action = content_tag('div', $action_link); $list_content = ''; $launches = sfLaunchingPeer::getAllByNamespace($namespace); foreach ($launches as $i => $l) { $l_obj_model = $l->getObjectModel(); $l_obj_id = $l->getObjectId(); $l_obj = deppPropelActAsLaunchableToolkit::retrieveLaunchableObject($l_obj_model, $l_obj_id); $l_obj_short_string = $l_obj->getShortTitle(); $l_obj_remove_action = sprintf('deppLaunching/remove?item_model=%s&item_pk=%s&namespace=%s', $l_obj_model, $l_obj_id, $namespace); $l_obj_priority_up_action = sprintf('deppLaunching/priorityUp?item_model=%s&item_pk=%s&namespace=%s', $l_obj_model, $l_obj_id, $namespace); $l_obj_priority_dn_action = sprintf('deppLaunching/priorityDn?item_model=%s&item_pk=%s&namespace=%s', $l_obj_model, $l_obj_id, $namespace); $l_obj_remove_link = link_to('<img src="/images/ico-remove_alert.png" alt="X" title="Rimuovi" />', $l_obj_remove_action, array('title' => __('Take the launch back'), 'class' => 'remove-vote')); $l_obj_priority_up_link = link_to('<img src="/images/ico-thumb-up.png" alt="+" title="Aumenta priorità" />', $l_obj_priority_up_action, array('title' => __('Increase the priority'), 'class' => 'moveup-vote')); $l_obj_priority_dn_link = link_to('<img src="/images/ico-thumb-down.png" alt="-" title="Diminuisci priorità" />', $l_obj_priority_dn_action, array('title' => __('Decrease the priority'), 'class' => 'movedown-vote')); $l_obj_actions = ""; /*if ($i > 0)*/ $l_obj_actions .= " {$l_obj_priority_up_link} "; /*if ($i < count($launches) - 1 )*/ $l_obj_actions .= " {$l_obj_priority_dn_link} "; $l_obj_actions .= " {$l_obj_remove_link} "; /*$list_content .= content_tag('tr', content_tag('td', '<input type="text" value="'. $l->getPriority().'" name="priority['. $l_obj_id.']" size="3">'. $l_obj_short_string) . content_tag('td', $l_obj_actions, array('style' => 'text-align:right; width:36px;display:inline-block;')));*/ $list_content .= content_tag('li', content_tag('span', $l_obj_actions, array('style' => 'text-align:right; width:36px;display:inline-block;float:right;')) . $l_obj_short_string, array('style' => 'cursor:move; border-bottom: 1px dotted #CCC;')); } $list = content_tag('ul', $list_content, $options); // adding javascript for drag and drop //use_javascript('/js/jquery-ui-1.8.16.sortable.min.js'); return $action . $list; } catch (Exception $e) { sfLogger::getInstance()->err('Exception catched from deppLaunching helper: ' . $e->getMessage()); } }
public function executeIndex() { $this->getResponse()->setTitle('Monitora i tuoi rappresentanti - ' . sfConfig::get('app_main_title')); $this->getResponse()->addMeta('description', 'Cosa fanno i tuoi rappresentanti? Tutte le attività parlamentari aggiornate quotidianamente.', true); deppFiltersAndSortVariablesManager::resetVars($this->getUser(), 'module', 'module', array('acts_filter', 'sf_admin/opp_atto/sort', 'votes_filter', 'sf_admin/opp_votazione/sort', 'pol_camera_filter', 'pol_senato_filter', 'sf_admin/opp_carica/sort', 'argomento/atti_filter', 'argomento_leggi/sort', 'argomento_nonleg/sort', 'monitoring_filter')); // ultime attivita' della community $this->latest_activities = CommunityNewsPeer::getLatestActivities(4); // ultime news dal parlamento $c = oppNewsPeer::getHomeNewsCriteria(); $c->addDescendingOrderByColumn(NewsPeer::DATE); $itemsperpage = 4; $pager = new deppNewsPager('News', $itemsperpage); $pager->setCriteria($c); $pager->setPage($this->getRequestParameter('page', 1)); $pager->init(); $this->pager = $pager; // atti in evidenza $this->lanci = array(); $c = new Criteria(); $c->add(sfLaunchingPeer::LAUNCH_NAMESPACE, 'home'); $c->add(sfLaunchingPeer::OBJECT_MODEL, 'OppAtto'); $c->setLimit(8); $c->addDescendingOrderByColumn(sfLaunchingPeer::PRIORITY); $evidences = sfLaunchingPeer::doSelect($c); foreach ($evidences as $evidence) { $atto = OppAttoPeer::retrieveByPk($evidence->getObjectId()); $this->lanci[] = $atto->getId(); } // post del blog $this->post_pager = sfSimpleBlogPostPeer::getTaggedPager('in evidenza', sfConfig::get('app_sfSimpleBlog_post_max_per_page', 10), $this->getRequestParameter('page', 1)); // estrae le circoscrizioni, compreso il valore 0 $this->senato_constituencies = OppCaricaPeer::getAllConstituencies('senato', false); $this->camera_constituencies = OppCaricaPeer::getAllConstituencies('camera', false); }
public static function retrieveByPKs($pks, $con = null) { if ($con === null) { $con = Propel::getConnection(self::DATABASE_NAME); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(); $criteria->add(sfLaunchingPeer::ID, $pks, Criteria::IN); $objs = sfLaunchingPeer::doSelect($criteria, $con); } return $objs; }
/** * Delete all launching for a launchable object (delete cascade emulation) * * @param BaseObject $object */ public function preDelete(BaseObject $object) { try { $c = new Criteria(); $c->add(sfLaunchingPeer::OBJECT_ID, $object->getPrimaryKey()); $ls = sfLaunchingPeer::doSelect($c); foreach ($ls as $l) { $l->delete(); } sfLaunchingPeer::resetPriorities(); } catch (Exception $e) { throw new deppPropelActAsLaunchableException('Unable to delete launchable object\'s related launchings records'); } }
$t->ok($obj1->hasBeenNegativelyLaunched($user_2_id) == true, 'hasBeenNegativelyLaunched() - obj1 was negatively launched by user 1'); $t->ok($obj1->hasBeenNegativelyLaunched($user_3_id) == false, 'hasBeenNegativelyLaunched() - obj1 was NOT negatively launched by user 1'); $t->diag('List of launched objects'); $launched_ids = sfLaunchingPeer::getAllPositivelyLaunchedIds($user_1_id); $t->ok($launched_ids[TEST_CLASS][0] == $obj1->getId(), 'sfLaunchingPeer::getAllPositivelyLaunchedIds() - is working'); $launched_ids = sfLaunchingPeer::getAllPositivelyLaunchedIds($user_2_id); $t->ok($launched_ids == array(), 'sfLaunchingPeer::getAllPositivelyLaunchedIds() - empty case scenario'); $launched_ids = sfLaunchingPeer::getAllNegativelyLaunchedIds($user_2_id); $t->ok($launched_ids[TEST_CLASS][0] == $obj1->getId(), 'sfLaunchingPeer::getAllNegativelyLaunchedIds() - is working'); $launched_ids = sfLaunchingPeer::getAllNegativelyLaunchedIds($user_1_id); $t->ok($launched_ids == array(), 'sfLaunchingPeer::getAllNegativelyLaunchedIds() - empty case scenario'); $launched_objs = sfLaunchingPeer::getAllPositivelyLaunched($user_1_id); $t->ok($launched_objs[0] == $obj1, 'sfLaunchingPeer::getAllPositivelyLaunched() - is working'); $launched_objs = sfLaunchingPeer::getAllNegativelyLaunched($user_2_id); $t->ok($launched_objs[0] == $obj1, 'sfLaunchingPeer::getAllNegativelyLaunched() - is working'); $launched_objs = sfLaunchingPeer::getAllPositivelyLaunched($user_2_id); $t->ok($launched_objs == array(), 'sfLaunchingPeer::getAllPositivelyLaunched() - empty case'); $t->diag('List of some toolkit methods'); $t->ok(deppPropelActAsLaunchableToolkit::isLaunchable(TEST_CLASS) == true, 'deppPropelActAsLaunchableToolkit::isLaunchable() - is working'); $t->diag('Tests terminated'); // test object creation function _create_object() { $classname = TEST_CLASS; $method = TEST_METHOD_SETTER; if (!class_exists($classname)) { throw new Exception(sprintf('Unknow class "%s"', $classname)); } $obj = new $classname(); // set a field to set the status of the object to isModified and have the doSave() function work $obj->{$method}('Trial value');
public function executeKeyvoteComparati() { $lanci = array(); $c = new Criteria(); $c->add(sfLaunchingPeer::OBJECT_MODEL, 'OppVotazione'); $c->add(sfLaunchingPeer::LAUNCH_NAMESPACE, 'key_vote'); $c->addDescendingOrderByColumn(sfLaunchingPeer::PRIORITY); $evidences = sfLaunchingPeer::doSelect($c); foreach ($evidences as $evidence) { $c1 = new Criteria(); $c1->addJoin(OppCaricaPeer::ID, OppVotazioneHasCaricaPeer::CARICA_ID); $c1->add(OppVotazioneHasCaricaPeer::CARICA_ID, array($this->parlamentare1->getId(), $this->parlamentare2->getId()), Criteria::IN); $c1->add(OppVotazioneHasCaricaPeer::VOTAZIONE_ID, $evidence->getObjectId()); $results = OppVotazioneHasCaricaPeer::doSelect($c1); if (count($results) == 2) { if ($results[0]->getCaricaId() == $this->parlamentare1->getId()) { $left = 0; $right = 1; } else { $left = 1; $right = 0; } $lanci[] = array($results[1]->getOppVotazione(), $evidence->getObjectModel(), $results[$left]->getVoto(), $results[$right]->getVoto()); } } $this->lanci = $lanci; }