public function geocode() { global $app_config; static $sleep_delay; if (!$sleep_delay) { $sleep_delay = 90000; } $address = $this->getZip(); $url = "http://maps.google.com/maps/geo?q=" . urlencode($address) . "&output=csv&key=" . $app_config['google_maps']['api_key']; $data = GroupPeer::remote_request($url); $addr_bits = split(",", $data); list($response_code, $precision, $lat, $lon) = $addr_bits; if ($response_code == "620") { $sleep_delay += 20000; print "waiting {$sleep_delay} ... \n"; usleep($sleep_delay); return $this->geocode(); } if ($response_code = "200" && $lat != '""') { $this->setLat($lat); $this->setLon($lon); } $this->setGeocodeAttemptedAt(time() - 4 * 3600); usleep($sleep_delay); print $url . "\n"; print "{$response_code}: level {$precision}, LAT: {$lat}, LON: {$lon} \n\n"; }
public function getCustomListElements() { if (GroupPeer::doCount(new Criteria()) > 0) { return array(array('group_id' => CriteriaListWidgetDelegate::SELECT_ALL, 'name' => TranslationPeer::getString('wns.roles.select_all_title'), 'magic_column' => 'all'), array('group_id' => CriteriaListWidgetDelegate::SELECT_WITHOUT, 'name' => TranslationPeer::getString('wns.roles.select_without_group_title'), 'magic_column' => 'without')); } return array(); }
public function published_and_geocoded_by_state($state) { $crit = new Criteria(); $crit->add(GroupPeer::LAT, null, Criteria::NOT_EQUAL); $crit->add(GroupPeer::PUBLISH, true); $crit->add(GroupPeer::STATE, $state); return GroupPeer::doSelect($crit); }
function withinGroups() { $this->addFromStatement(GroupPeer::search($this->criteria)); }
/** * Retrieve multiple objects by pkey. * * @param array $pks List of primary keys * @param PropelPDO $con the connection to use * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function retrieveByPKs($pks, PropelPDO $con = null) { if ($con === null) { $con = Propel::getConnection(GroupPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(GroupPeer::DATABASE_NAME); $criteria->add(GroupPeer::ID, $pks, Criteria::IN); $objs = GroupPeer::doSelect($criteria, $con); } return $objs; }
/** * Method to invalidate the instance pool of all tables related to users * by a foreign key with ON DELETE CASCADE */ public static function clearRelatedInstancePool() { // Invalidate objects in UserGroupPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. UserGroupPeer::clearInstancePool(); // Invalidate objects in UserRolePeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. UserRolePeer::clearInstancePool(); // Invalidate objects in PagePeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. PagePeer::clearInstancePool(); // Invalidate objects in PagePeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. PagePeer::clearInstancePool(); // Invalidate objects in PagePropertyPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. PagePropertyPeer::clearInstancePool(); // Invalidate objects in PagePropertyPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. PagePropertyPeer::clearInstancePool(); // Invalidate objects in PageStringPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. PageStringPeer::clearInstancePool(); // Invalidate objects in PageStringPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. PageStringPeer::clearInstancePool(); // Invalidate objects in ContentObjectPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. ContentObjectPeer::clearInstancePool(); // Invalidate objects in ContentObjectPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. ContentObjectPeer::clearInstancePool(); // Invalidate objects in LanguageObjectPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. LanguageObjectPeer::clearInstancePool(); // Invalidate objects in LanguageObjectPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. LanguageObjectPeer::clearInstancePool(); // Invalidate objects in LanguageObjectHistoryPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. LanguageObjectHistoryPeer::clearInstancePool(); // Invalidate objects in LanguageObjectHistoryPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. LanguageObjectHistoryPeer::clearInstancePool(); // Invalidate objects in LanguagePeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. LanguagePeer::clearInstancePool(); // Invalidate objects in LanguagePeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. LanguagePeer::clearInstancePool(); // Invalidate objects in TranslationPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. TranslationPeer::clearInstancePool(); // Invalidate objects in TranslationPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. TranslationPeer::clearInstancePool(); // Invalidate objects in UserGroupPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. UserGroupPeer::clearInstancePool(); // Invalidate objects in UserGroupPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. UserGroupPeer::clearInstancePool(); // Invalidate objects in GroupPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. GroupPeer::clearInstancePool(); // Invalidate objects in GroupPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. GroupPeer::clearInstancePool(); // Invalidate objects in GroupRolePeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. GroupRolePeer::clearInstancePool(); // Invalidate objects in GroupRolePeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. GroupRolePeer::clearInstancePool(); // Invalidate objects in RolePeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. RolePeer::clearInstancePool(); // Invalidate objects in RolePeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. RolePeer::clearInstancePool(); // Invalidate objects in UserRolePeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. UserRolePeer::clearInstancePool(); // Invalidate objects in UserRolePeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. UserRolePeer::clearInstancePool(); // Invalidate objects in RightPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. RightPeer::clearInstancePool(); // Invalidate objects in RightPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. RightPeer::clearInstancePool(); // Invalidate objects in DocumentPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. DocumentPeer::clearInstancePool(); // Invalidate objects in DocumentPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. DocumentPeer::clearInstancePool(); // Invalidate objects in DocumentDataPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. DocumentDataPeer::clearInstancePool(); // Invalidate objects in DocumentDataPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. DocumentDataPeer::clearInstancePool(); // Invalidate objects in DocumentTypePeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. DocumentTypePeer::clearInstancePool(); // Invalidate objects in DocumentTypePeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. DocumentTypePeer::clearInstancePool(); // Invalidate objects in DocumentCategoryPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. DocumentCategoryPeer::clearInstancePool(); // Invalidate objects in DocumentCategoryPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. DocumentCategoryPeer::clearInstancePool(); // Invalidate objects in TagPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. TagPeer::clearInstancePool(); // Invalidate objects in TagPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. TagPeer::clearInstancePool(); // Invalidate objects in TagInstancePeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. TagInstancePeer::clearInstancePool(); // Invalidate objects in TagInstancePeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. TagInstancePeer::clearInstancePool(); // Invalidate objects in LinkPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. LinkPeer::clearInstancePool(); // Invalidate objects in LinkPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. LinkPeer::clearInstancePool(); // Invalidate objects in LinkCategoryPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. LinkCategoryPeer::clearInstancePool(); // Invalidate objects in LinkCategoryPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. LinkCategoryPeer::clearInstancePool(); // Invalidate objects in ReferencePeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. ReferencePeer::clearInstancePool(); // Invalidate objects in ReferencePeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. ReferencePeer::clearInstancePool(); }
<?php require_once 'start.php'; // initialize DIA library require_once APP_ROOT . '/lib/democracyinaction-php/api.php'; $dia_config = $app_config['democracy_in_action']; $dia = new DemocracyInAction_API($dia_config['node'], $dia_config['login'], $dia_config['password']); $dia->authenticate(); $dia_groups = $dia->get(Group::dia_object); if (!$dia_groups) { print "auth failed"; exit; } foreach ($dia_groups as $dia_group) { $group = GroupPeer::find_or_create_by_dia_key($dia_group); $group->save(); } $groups = GroupPeer::doSelect(new Criteria()); $groups_to_geocode = GroupPeer::geocodable(); foreach ($groups_to_geocode as $group) { $group->geocode(); $group->save(); }
/** * Find object by primary key using raw SQL to go fast. * Bypass doSelect() and the object formatter by using generated code. * * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * * @return Group A model object, or null if the key is not found * @throws PropelException */ protected function findPkSimple($key, $con) { $sql = 'SELECT `id`, `name`, `created_at`, `updated_at`, `created_by`, `updated_by` FROM `groups` WHERE `id` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); $stmt->execute(); } catch (Exception $e) { Propel::log($e->getMessage(), Propel::LOG_ERR); throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); } $obj = null; if ($row = $stmt->fetch(PDO::FETCH_NUM)) { $obj = new Group(); $obj->hydrate($row); GroupPeer::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); return $obj; }
public function mayOperate($sOperation, $oUser = false) { $oUser = GroupPeer::getRightsUser($oUser); $bIsAllowed = false; if ($oUser && ($this->isNew() || $this->getCreatedBy() === $oUser->getId()) && GroupPeer::mayOperateOnOwn($oUser, $this, $sOperation)) { $bIsAllowed = true; } else { if (GroupPeer::mayOperateOn($oUser, $this, $sOperation)) { $bIsAllowed = true; } } FilterModule::getFilters()->handleGroupOperationCheck($sOperation, $this, $oUser, array(&$bIsAllowed)); return $bIsAllowed; }
/** * Selects a collection of GroupRole objects pre-filled with all related objects except UserRelatedByUpdatedBy. * * @param Criteria $criteria * @param PropelPDO $con * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN * @return array Array of GroupRole objects. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doSelectJoinAllExceptUserRelatedByUpdatedBy(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) { $criteria = clone $criteria; // Set the correct dbName if it has not been overridden // $criteria->getDbName() will return the same object if not set to another value // so == check is okay and faster if ($criteria->getDbName() == Propel::getDefaultDB()) { $criteria->setDbName(GroupRolePeer::DATABASE_NAME); } GroupRolePeer::addSelectColumns($criteria); $startcol2 = GroupRolePeer::NUM_HYDRATE_COLUMNS; GroupPeer::addSelectColumns($criteria); $startcol3 = $startcol2 + GroupPeer::NUM_HYDRATE_COLUMNS; RolePeer::addSelectColumns($criteria); $startcol4 = $startcol3 + RolePeer::NUM_HYDRATE_COLUMNS; $criteria->addJoin(GroupRolePeer::GROUP_ID, GroupPeer::ID, $join_behavior); $criteria->addJoin(GroupRolePeer::ROLE_KEY, RolePeer::ROLE_KEY, $join_behavior); $stmt = BasePeer::doSelect($criteria, $con); $results = array(); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key1 = GroupRolePeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($obj1 = GroupRolePeer::getInstanceFromPool($key1))) { // We no longer rehydrate the object, since this can cause data loss. // See http://www.propelorm.org/ticket/509 // $obj1->hydrate($row, 0, true); // rehydrate } else { $cls = GroupRolePeer::getOMClass(); $obj1 = new $cls(); $obj1->hydrate($row); GroupRolePeer::addInstanceToPool($obj1, $key1); } // if obj1 already loaded // Add objects for joined Group rows $key2 = GroupPeer::getPrimaryKeyHashFromRow($row, $startcol2); if ($key2 !== null) { $obj2 = GroupPeer::getInstanceFromPool($key2); if (!$obj2) { $cls = GroupPeer::getOMClass(); $obj2 = new $cls(); $obj2->hydrate($row, $startcol2); GroupPeer::addInstanceToPool($obj2, $key2); } // if $obj2 already loaded // Add the $obj1 (GroupRole) to the collection in $obj2 (Group) $obj2->addGroupRole($obj1); } // if joined row is not null // Add objects for joined Role rows $key3 = RolePeer::getPrimaryKeyHashFromRow($row, $startcol3); if ($key3 !== null) { $obj3 = RolePeer::getInstanceFromPool($key3); if (!$obj3) { $cls = RolePeer::getOMClass(); $obj3 = new $cls(); $obj3->hydrate($row, $startcol3); RolePeer::addInstanceToPool($obj3, $key3); } // if $obj3 already loaded // Add the $obj1 (GroupRole) to the collection in $obj3 (Role) $obj3->addGroupRole($obj1); } // if joined row is not null $results[] = $obj1; } $stmt->closeCursor(); return $results; }
/** * Sends the number of points specified in $points to $groupID * * @param int $groupID * @param int $points * @return bool */ public function sendPointsToGroup($groupID, $points) { //If the user is banned, they can't give points if ($this->getHidden()) { return false; } //Nice try... you can't send negative points or send more points than //you've got or send a non-numeric number of points if ($points < 1 || $this->getPoints() < $points || !is_numeric($points)) { return false; } $group = GroupPeer::retrieveByPK($groupID); if (!$group) { return false; } //Move the points $group->setPoints($group->getPoints() + $points); $this->setPoints($this->getPoints() - $points); //If the group was bankrupt but now isn't, set the group as no longer //bankrupt if ($group->getPoints() >= 0 && $group->getBankruptSince() != null) { $group->setBankruptSince(null); } //Return true if the transaction worked on both ends return $group->save() && $this->save(); }
/** * This function performs the validation work for complex object models. * * In addition to checking the current object, all related objects will * also be validated. If all pass then <code>true</code> is returned; otherwise * an aggreagated array of ValidationFailed objects will be returned. * * @param array $columns Array of column names to validate. * @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise. */ protected function doValidate($columns = null) { if (!$this->alreadyInValidation) { $this->alreadyInValidation = true; $retval = null; $failureMap = array(); if (($retval = GroupPeer::doValidate($this, $columns)) !== true) { $failureMap = array_merge($failureMap, $retval); } $this->alreadyInValidation = false; } return !empty($failureMap) ? $failureMap : true; }
<?php require_once '../../start.php'; if ($state = request_params('state')) { $groups = GroupPeer::published_and_geocoded_by_state($state); } else { $groups = GroupPeer::published_and_geocoded(); } header(' Content-Type:text/xml'); print '<?xml version="1.0" encoding="UTF-8"?>'; ?> <POIs> <?php foreach ($groups as $group) { print " <POI label=\"" . htmlspecialchars($group->getName()) . "\" lat=\"" . $group->getLat() . "\" lon=\"" . $group->getLon() . "\" id=\"" . $group->getCdatKey() . "\" category=\"event_district\" location=\"" . htmlspecialchars($group->getCity()) . ", " . htmlspecialchars($group->getState()) . "\" description=\"" . htmlspecialchars($group->getDescription()) . "\" contact_name=\"" . htmlspecialchars($group->getContactName()) . "\" contact_email=\"" . htmlspecialchars($group->getEmail()) . "\" url=\"" . $group->getUrl() . "\">\n"; $url = $group->getUrl(); if (strpos($url, "http") !== 0) { $url = "http://" . $url; } print " <action url=\"" . $url . "\" event=\"onRelease\" target=\"_blank\"/>\n"; print " </POI>\n"; } ?> </POIs>
public function getDetail() { // display error info if ($this->iError) { $oTemplate = $this->constructTemplate('error_message'); $oTemplate->replaceIdentifier('error_title', StringPeer::getString('webdav.error_message') . ' ' . $this->sErrorLocation); $oTemplate->replacePstring("error_details", array('dir_name' => $this->sWebdavBaseDirPath), 'webdav.error_' . $this->iError); return $oTemplate; } // display module info if ($this->sFilePath === null) { $oTemplate = $this->constructTemplate('module_info'); if (count($this->aFiles) > 0) { $oTemplate->replaceIdentifier('edit_or_create_message', StringPeer::getString('webdav.choose_or_create')); } $oTemplate->replaceIdentifier('create_link', TagWriter::quickTag('a', array('class' => 'edit_related_link highlight', 'href' => LinkUtil::link('webdav', null, array('action' => 'create'))), StringPeer::getString('webdav.create'))); $oTemplate->replaceIdentifier('user_backend_link', TagWriter::quickTag('a', array('class' => 'edit_related_link highlight', 'href' => LinkUtil::link('users')), StringPeer::getString('module.backend.users'))); return $oTemplate; } $oTemplate = $this->constructTemplate('detail'); $oTemplate->replaceIdentifier('module_info_link', TagWriter::quickTag('a', array('title' => StringPeer::getString('module_info'), 'class' => 'info', 'href' => LinkUtil::link('webdav', null, array('get_module_info' => 'true'))))); if ($this->sFilePath === self::NEW_DIR_IDENTIFIER) { $aDirPermissionsGroupIds = array(); } else { $aDirPermissionsGroupIds = DirectoryPermissionPeer::getPermissionGroupIdsByFileName($this->sFilePath); $oDeleteTemplate = $this->constructTemplate("delete_button", true); $oDeleteTemplate->replacePstring("delete_item", array('name' => $this->sFilePath)); $oTemplate->replaceIdentifier("delete_button", $oDeleteTemplate, null, Template::LEAVE_IDENTIFIERS); // show users with usergroups $oUsersWithGroups = UserPeer::getUsersWithRights($aDirPermissionsGroupIds); $oUsersTemplate = $this->constructTemplate('detail_users'); if (count($oUsersWithGroups) > 0) { foreach ($oUsersWithGroups as $oUser) { $oUsersTemplate->replaceIdentifierMultiple('users', TagWriter::quickTag('a', array('class' => 'highlight', 'title' => StringPeer::getString('user.edit'), 'class' => 'webdav_files', 'href' => LinkUtil::link(array('users', $oUser->getId()), null, array('check_userkind' => true))), $oUser->getFullName() . ' [Benutzername:' . $oUser->getUserName() . ']')); } } else { $oUsersTemplate->replaceIdentifier('users', TagWriter::quickTag('div', array('class' => 'webdav_files'), StringPeer::getString('webdav.no_users_with_permission_message'))); } $oUsersTemplate->replaceIdentifier('user_backend_link', TagWriter::quickTag('a', array('class' => 'edit_related_link', 'href' => LinkUtil::link('users', null, array('check_userkind' => 'true'))), StringPeer::getString('user.edit'))); $oTemplate->replaceIdentifier("users_with_permission", $oUsersTemplate); $sServerPath = LinkUtil::absoluteLink(substr($this->sWebdavBaseDirPath, strrpos($this->sWebdavBaseDirPath, '/')) . '/' . $this->sFilePath); $oTemplate->replaceIdentifier("server_address", $sServerPath); // show files in current dir $aDirFiles = array_keys(ResourceFinder::getFolderContents($this->sWebdavBaseDirPath . '/' . $this->sFilePath)); if (count($aDirFiles) > 0) { $oFilesTemplate = $this->constructTemplate("detail_files"); $sWebDavDirPath = $this->sWebdavBaseDirPath . '/' . $this->sFilePath . '/'; foreach ($aDirFiles as $i => $sFilePath) { $iFileSize = filesize($sWebDavDirPath . $sFilePath); $sFileSize = DocumentUtil::getDocumentSize($iFileSize); if (substr($sFileSize, 0, 1) == '0') { $sFileSize = 'unknown'; } $oFilesTemplate->replaceIdentifierMultiple('files', TagWriter::quickTag('div', array('class' => 'webdav_files'), $sFilePath . ' [' . $sFileSize . ']')); } $oTemplate->replaceIdentifier('detail_files', $oFilesTemplate); } } $oTemplate->replaceIdentifier('name', $this->sFilePath); $oTemplate->replaceIdentifier('file_path_old', $this->sFilePath); if (isset($_POST['file_path'])) { $this->sFilePath = $_POST['file_path']; } $oTemplate->replaceIdentifier('file_path', $this->sFilePath === self::NEW_DIR_IDENTIFIER ? '' : $this->sFilePath); $oTemplate->replaceIdentifier('file_path_readonly', $this->sFilePath != self::NEW_DIR_IDENTIFIER ? ' readonly="readonly"' : '', null, Template::NO_HTML_ESCAPE); $aGroups = GroupPeer::getAll(); $oTemplate->replaceIdentifier('group_options', TagWriter::optionsFromObjects($aGroups, 'getId', 'getName', $aDirPermissionsGroupIds, array())); $oTemplate->replaceIdentifier('group_backend_link', TagWriter::quickTag('a', array('class' => 'edit_related_link highlight', 'href' => LinkUtil::link('groups')), StringPeer::getString('group.edit'))); return $oTemplate; }