protected function setNavigation(Member $member) { if ($member->getId() !== $this->getUser()->getMemberId()) { sfConfig::set('sf_nav_type', 'friend'); sfConfig::set('sf_nav_id', $member->getId()); } }
public function getScheduleByThisDayAndMember($year, $month, $day, Member $member) { $day = sprintf('%04d-%02d-%02d', (int) $year, (int) $month, (int) $day); $scheduleIds = Doctrine::getTable('ScheduleMember')->getScheduleIdsByMemberId($member->getId()); $q = $this->createQuery()->select('id, title')->where('start_date <= ?', $day)->andWhere('end_date >= ?', $day); if (!count($scheduleIds)) { $q->andWhere('member_id = ?', (int) $member->getId()); } else { $q->andWhere('member_id = ? OR id IN (' . implode(', ', $scheduleIds) . ')', (int) $member->getId()); } return $q->execute(); }
protected function execute($arguments = array(), $options = array()) { $databaseManager = new sfDatabaseManager($this->configuration); $n = (int)$options['number']; $link = $options['link']; if (!is_null($link)) { $linkMember = Doctrine::getTable('Member')->find($link); if (!$linkMember) { throw new Exception("not found member: ".$link); } } for ($i = 0; $i < $n; $i++) { $member = new Member(); $member->setName('dummy'); $member->setIsActive(self::fetchRandomNotActive($options['notactivemember-rate'], $n)); $member->save(); $member->setName(sprintf($options['name-format'], $member->getId())); $member->save(); $address = sprintf($options['mail-address-format'], $member->getId()); $member->setConfig('pc_address', $address); $member->setConfig('mobile_address', $address); $password = preg_replace("/%d/", $member->getId(), $options['password-format'], 1); $member->setConfig('password', md5($password)); $this->logSection('member+', $member->getName()); if (isset($linkMember)) { $memberRelationship1 = new MemberRelationship(); $memberRelationship1->setMember($member); $memberRelationship1->setMemberRelatedByMemberIdFrom($linkMember); $memberRelationship1->setIsFriend(true); $memberRelationship1->save(); $memberRelationship2 = new MemberRelationship(); $memberRelationship2->setMember($linkMember); $memberRelationship2->setMemberRelatedByMemberIdFrom($member); $memberRelationship2->setIsFriend(true); $memberRelationship2->save(); $this->logSection('friend link', sprintf("%s - %s", $linkMember->getId(), $member->getId())); } } }
/** * Distribute provisions for member signup. * * ATTENTION: This method does NOT save changes to $advertisedMember. The * caller is required to save this object! * * @param Member $advertisedMember * @param PropelPDO $con */ public function payAdvertisingFor(\Member $referrer, \Tbmt\MemberFee $memberFee, \Member $advertisedMember, $currency, $when, \PropelPDO $con) { $advertisedMemberId = $advertisedMember->getId(); $transfer = $referrer->getCurrentTransferBundle($currency, $con); if ($referrer->getFundsLevel() === \Member::FUNDS_LEVEL1) { // @see resources/snowball.txt - processes - P1 $transaction = $transfer->createTransactionForReason($referrer, \Transaction::REASON_ADVERTISED_LVL1, $advertisedMemberId, $when, $con); $memberFee->subtract($transaction->getAmount(), \Transaction::REASON_ADVERTISED_LVL1); $parent = $referrer->getMemberRelatedByParentId($con); if ($parent) { $parentTransfer = $parent->getCurrentTransferBundle($currency, $con); $parentTransaction = $parentTransfer->createTransactionForReason($parent, \Transaction::REASON_ADVERTISED_INDIRECT, $advertisedMemberId, $when, $con); $memberFee->subtract($parentTransaction->getAmount(), \Transaction::REASON_ADVERTISED_INDIRECT); $parentTransfer->save($con); $parent->save($con); } } else { // if ( $this->getFundsLevel() >= Member::FUNDS_LEVEL2 ) { // @see resources/snowball.txt - processes - P3 $transaction = $transfer->createTransactionForReason($referrer, \Transaction::REASON_ADVERTISED_LVL2, $advertisedMemberId, $when, $con); $memberFee->subtract($transaction->getAmount(), \Transaction::REASON_ADVERTISED_LVL2); } $transfer->save($con); \MemberBonusIds::payBonuses($memberFee, $advertisedMember, $currency, $when, $con); }
/** * opDumpMemberTask::execute() * * @param array $arguments * @param array $options * @return */ protected function execute($arguments = array(), $options = array()) { // initialize the database connection $databaseManager = new sfDatabaseManager($this->configuration); $connection = $databaseManager->getDatabase($options['connection'])->getConnection(); $doctrineConnection = $databaseManager->getDatabase($options['connection'])->getDoctrineConnection(); $fp = fopen(sfConfig::get('sf_data_dir') . '/memberlist.csv', 'w'); // gets member list(using pure SQL) $sql = 'select * from member'; $members = $doctrineConnection->fetchAll($sql, array()); foreach ($members as $member) { $line = array(); $memberObj = new Member(); $memberObj->fromArray($member); // nickname is required $name = $memberObj->getName(); if (empty($name)) { continue; } $line[] = $memberObj->getId(); $line[] = $name; $email = trim($memberObj->getConfig('pc_address')); if (empty($email)) { $email = $memberObj->getConfig('mobile_address'); } if (empty($email)) { continue; } $line[] = trim($email); fputcsv($fp, $line, ',', '"'); } fclose($fp); }
static function createDefaultUserPermissions(Contact $user, Member $member, $remove_previous = true) { $role_id = $user->getUserType(); $permission_group_id = $user->getPermissionGroupId(); $member_id = $member->getId(); try { if ($remove_previous) { ContactMemberPermissions::delete("permission_group_id = '$permission_group_id' AND member_id = $member_id"); } $shtab_permissions = array(); $new_permissions = array(); $role_permissions = self::findAll(array('conditions' => 'role_id = '.$role_id)); foreach ($role_permissions as $role_perm) { if ($member->canContainObject($role_perm->getObjectTypeId())) { $cmp = new ContactMemberPermission(); $cmp->setPermissionGroupId($permission_group_id); $cmp->setMemberId($member_id); $cmp->setObjectTypeId($role_perm->getObjectTypeId()); $cmp->setCanDelete($role_perm->getCanDelete()); $cmp->setCanWrite($role_perm->getCanWrite()); $cmp->save(); $new_permissions[] = $cmp; $perm = new stdClass(); $perm->m = $member_id; $perm->r = 1; $perm->w = $role_perm->getCanWrite(); $perm->d = $role_perm->getCanDelete(); $perm->o = $role_perm->getObjectTypeId(); $shtab_permissions[] = $perm; } } if (count($shtab_permissions)) { $cdp = ContactDimensionPermissions::instance()->findOne(array('conditions' => "permission_group_id = '$permission_group_id' AND dimension_id = ".$member->getDimensionId())); if (!$cdp instanceof ContactDimensionPermission) { $cdp = new ContactDimensionPermission(); $cdp->setPermissionGroupId($permission_group_id); $cdp->setContactDimensionId($member->getDimensionId()); $cdp->setPermissionType('check'); $cdp->save(); } else { if ($cdp->getPermissionType() == 'deny all') { $cdp->setPermissionType('check'); $cdp->save(); } } $stCtrl = new SharingTableController(); $stCtrl->afterPermissionChanged($permission_group_id, $shtab_permissions); } return $new_permissions; } catch (Exception $e) { throw $e; } }
static function getSubmembers(Member $member, $recursive = true) { $members = Members::findAll(array('conditions' => '`parent_member_id` = ' . $member->getId())); if ($recursive) { foreach ($members as $m) { $members = array_merge($members, self::getSubmembers($m, $recursive)); } } return $members; }
/** * Distribute provisions for member signup. * * ATTENTION: This method does NOT save changes to $advertisedMember. The * caller is required to save this object! * * @param Member $advertisedMember * @param PropelPDO $con */ public function payAdvertisingFor(\Member $referrer, \Tbmt\MemberFee $memberFee, \Member $advertisedMember, $currency, $when, $freeFromInvitation, \PropelPDO $con) { $advertisedMemberId = $advertisedMember->getId(); $transfer = $referrer->getCurrentTransferBundle($currency, $con); $transaction = $transfer->createTransactionForReason($referrer, \Transaction::REASON_ADVERTISED_LVL1, $advertisedMemberId, $when, $con); $memberFee->subtract($transaction->getAmount(), \Transaction::REASON_ADVERTISED_LVL1); $transfer->save($con); \MemberBonusIds::payBonuses($memberFee, $advertisedMember, $currency, $when, $con); }
public static function getInvitationHash(\Member $member, $type, $salt) { $id = $member->getId(); $num = $member->getNum(); $typeKey = \Member::$INVITATION_BY_KEY[$type]; $data = $id . $num . $type . $typeKey; return hash_hmac(self::ALGORITHM, $data, $salt . ':' . self::$salt) . $type; // self::TYPE_ORGLEADER => Cryption::getInvitationHash($id.$num, self::INVITE_ORGLEADER).self::TYPE_ORGLEADER, // self::TYPE_PROMOTER => Cryption::getInvitationHash($id.$num, self::INVITE_PROMOTER).self::TYPE_PROMOTER }
public static function activity_createBonusTransaction(Member $login, Member $recipient, array $data, PropelPDO $con) { $currentTransfer = $recipient->getCurrentTransferBundle(self::$BASE_CURRENCY, $con); $when = time(); $amount = $data['amount']; $recipient->addOutstandingTotal($amount, self::$BASE_CURRENCY); $transaction = $currentTransfer->addAmount($amount)->setReason(Transaction::REASON_CUSTOM_BONUS)->setPurpose($data['purpose'])->setRelatedId($login->getId())->setDate($when)->save($con); $currentTransfer->save($con); $recipient->save($con); }
public static function create(Member $login, array $data, PropelPDO $con) { $type = $data['type']; $hash = SystemStats::getIncreasedInvitationIncrementer($con); $invitation = new Invitation(); if ($type === \Member::TYPE_SUB_PROMOTER) { $invitation->setMeta(['promoter_num' => $data['promoter_num'], 'promoter_id' => $data['promoter_id']]); } $invitation->setHash($hash)->setMemberId($login->getId())->setType($type)->setFreeSignup(isset($data['free_signup']) && $data['free_signup'] ? 1 : 0)->setCreationDate(time())->save($con); return $invitation; }
protected function executeTransaction($conn, $arguments = array(), $options = array()) { $n = (int) $options['number']; $link = $options['link']; if (null !== $link) { $linkMember = Doctrine::getTable('Member')->find($link); if (!$linkMember) { throw new Exception("not found member: " . $link); } } for ($i = 0; $i < $n; $i++) { $member = new Member(); $member->setName('dummy'); $member->setIsActive(true); $member->save(); $member->setName(sprintf($options['name-format'], $member->getId())); $member->save(); $address = sprintf($options['mail-address-format'], $member->getId()); self::setMemberConfig($member->id, 'pc_address', $address); self::setMemberConfig($member->id, 'mobile_address', $address); $password = preg_replace("/%d/", $member->getId(), $options['password-format'], 1); self::setMemberConfig($member->id, 'password', md5($password)); $this->logSection('member+', $member->getName()); if (isset($linkMember)) { $memberRelationship1 = new MemberRelationship(); $memberRelationship1->setMemberIdTo($member->id); $memberRelationship1->setMemberIdFrom($linkMember->id); $memberRelationship1->setIsFriend(true); $memberRelationship1->save(); $memberRelationship1->free(true); $memberRelationship2 = new MemberRelationship(); $memberRelationship2->setMemberIdTo($linkMember->id); $memberRelationship2->setMemberIdFrom($member->id); $memberRelationship2->setIsFriend(true); $memberRelationship2->save(); $memberRelationship2->free(true); $this->logSection('friend link', sprintf("%s - %s", $linkMember->getId(), $member->getId())); } $member->free(true); } }
static function createDefaultUserPermissions(Contact $user, Member $member, $remove_previous = true) { $role_id = $user->getUserType(); $permission_group_id = $user->getPermissionGroupId(); $member_id = $member->getId(); try { DB::beginWork(); if ($remove_previous) { ContactMemberPermissions::delete("permission_group_id = {$permission_group_id} AND member_id = {$member_id}"); } $shtab_permissions = array(); $new_permissions = array(); $role_permissions = self::findAll(array('conditions' => 'role_id = ' . $role_id)); foreach ($role_permissions as $role_perm) { if ($member->canContainObject($role_perm->getObjectTypeId())) { $cmp = new ContactMemberPermission(); $cmp->setPermissionGroupId($permission_group_id); $cmp->setMemberId($member_id); $cmp->setObjectTypeId($role_perm->getObjectTypeId()); $cmp->setCanDelete($role_perm->getCanDelete()); $cmp->setCanWrite($role_perm->getCanWrite()); $cmp->save(); $new_permissions[] = $cmp; $perm = new stdClass(); $perm->m = $member_id; $perm->r = 1; $perm->w = $role_perm->getCanWrite(); $perm->d = $role_perm->getCanDelete(); $perm->o = $role_perm->getObjectTypeId(); $shtab_permissions[] = $perm; } } if (count($shtab_permissions)) { $stCtrl = new SharingTableController(); $stCtrl->afterPermissionChanged($permission_group_id, $shtab_permissions); } DB::commit(); return $new_permissions; } catch (Exception $e) { DB::rollback(); throw $e; } }
static function getSubmembers(Member $member, $recursive = true, $extra_conditions = "", $order_by = null, $order_dir = null, $offset = -1, $limit = -1) { if (is_null($order_by)) { $order_by = "name"; } if (is_null($order_dir)) { $order_dir = "ASC"; } $params = array('conditions' => '`parent_member_id` = ' . $member->getId() . ' ' . $extra_conditions, 'order' => "`{$order_by}` {$order_dir}"); if ($limit > 0 && $offset >= 0) { $params['limit'] = $limit; $params['offset'] = $offset; } $members = Members::findAll($params); if ($recursive) { foreach ($members as $m) { $members = array_merge($members, self::getSubmembers($m, $recursive)); } } return $members; }
public static function createBonusTransaction(Member $login, Member $recipient, array $data, PropelPDO $con) { $currentTransfer = $recipient->getCurrentTransferBundle(self::$BASE_CURRENCY, $con); $when = time(); if (!$con->beginTransaction()) { throw new Exception('Could not begin transaction'); } try { $amount = $data['amount']; $recipient->addOutstandingTotal($amount, self::$BASE_CURRENCY); $transaction = $currentTransfer->addAmount($amount)->setReason(Transaction::REASON_CUSTOM_BONUS)->setPurpose($data['purpose'])->setRelatedId($login->getId())->setDate($when)->save($con); $currentTransfer->save($con); $recipient->save($con); if (!$con->commit()) { throw new Exception('Could not commit transaction'); } } catch (Exception $e) { $con->rollBack(); throw $e; } }
public static function setRead(Member $target, $notificationId) { $notificationObject = Doctrine::getTable('MemberConfig')->findOneByMemberIdAndName($target->getId(), 'notification_center'); if (!$notificationObject) { return false; } else { $notifications = unserialize($notificationObject->getValue()); } $success = false; foreach ($notifications as &$notification) { if ($notificationId === $notification['id']) { $notification['unread'] = false; $success = true; } } unset($notification); $notificationObject->setValue(serialize($notifications)); $notificationObject->save(); $notificationObject->free(true); return $success; }
private function createCluster($memberNum) { $memberIds = array(); for($i = 0; $i < $memberNum; ++$i) { $member = new Member(); $member->setName('dummy'); $member->setIsActive(true); $member->save(); $memberIds[] = $member->getId(); $member->setName(sprintf('dummy%d', $member->getId())); $member->save(); $address = sprintf('*****@*****.**', $member->getId()); $this->setMemberConfig($member->getId(), 'pc_address', $address); $this->setMemberConfig($member->getId(), 'mobile_address', $address); $password = '******'; $this->setMemberConfig($member->getId(), 'password', md5($password)); $member->free(true); } for($i = 0; $i < $memberNum; ++$i) { for($j = $i + 1; $j < $memberNum; ++$j) { if ($i === $j) continue; $relation = new MemberRelationship(); $relation->setMemberIdFrom($memberIds[$i]); $relation->setMemberIdTo($memberIds[$j]); $relation->setFriend(true); $relation->save(); $relation->free(true); } } }
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param Member $value A Member object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool(Member $obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getId(); } // if key === null self::$instances[$key] = $obj; } }
header('Cache-Control: no-cache, must-revalidate'); require_once 'framework/functions/basic.inc.php'; initialize_paths(); require_once 'framework/inc/constants.inc.php'; load('config/config'); load('functions/useful', INC_LOAD); load('inc/default', INC_LOAD); load('core/cache'); load('core/errors'); load('core/breadcrumb'); load('core/sessions'); load('builder/form'); load('templates/constructor'); load('lang/lang'); load('db/mysql'); load('members/member'); @(require_once ROOT . 'install/install_delete_dir.php'); $cache = new Cache(false, false); $bdd = new Bdd(); $sessions = new Sessions(); $member = new Member(); $config = new Config($cache, $member->getDesign(), $member->getLang()); $authorizations = new Rights(); $authorizations->init(); $rights = new Member_rights($member->getId()); $rights->init($config->getInfos('module'), $config->getInfos('page')); $lang = new Lang('accueil', 'index', $member->getLang()); $breadcrumb = new Breadcrumb(); $tpl = new TemplatesConstructor(); $tpl->init($config); autoload_libs();
public function setAuthorByMember(Member $member) { sfContext::getInstance()->getConfiguration()->loadHelpers(array('Url', 'opUtil')); $uri = url_for('@feeds_member_retrieve_resource_normal?model=member&id=' . $member->getId(), true); $this->setAuthor($member->getName(), $uri); }
} else { echo 'ok'; } exit; } if ($_POST['action'] == 'upload_resume') { $resume = NULL; $member = new Member($_POST['member']); $is_update = false; $data = array(); $data['modified_on'] = now(); $data['name'] = str_replace(array('\'', '"', '\\'), '', basename($_FILES['my_file']['name'])); $data['private'] = 'N'; if ($_POST['id'] == '0') { $data['is_yel_uploaded'] = '1'; $resume = new Resume($member->getId()); if (!$resume->create($data)) { redirect_to('member.php?member_email_addr=' . $member->getId() . '&page=resumes&error=1'); exit; } } else { $resume = new Resume($member->getId(), $_POST['id']); $is_update = true; if (!$resume->update($data)) { redirect_to('member.php?member_email_addr=' . $member->getId() . '&page=resumes&error=2'); exit; } } $data = array(); $data['FILE'] = array(); $data['FILE']['type'] = $_FILES['my_file']['type'];
public static function payBonuses(\Tbmt\MemberFee $memberFee, Member $payingMember, $currency, $when, PropelPDO $con) { $bonusByIds = self::toArray($payingMember->getBonusIds()); if (!is_array($bonusByIds)) { return; } // Each member carries all members which receive bonus for his signup $bonusIds = array_keys($bonusByIds); if (count($bonusIds) === 0) { return; } $relatedId = $payingMember->getId(); // Select all bonus members $bonusMembers = MemberQuery::create()->filterByDeletionDate(null, Criteria::ISNULL)->filterById($bonusIds, Criteria::IN)->find($con); $spreadBonuses = []; $toBeSaved = []; foreach ($bonusMembers as $member) { $type = $member->getType(); $transfer = null; // Even so the system still supporting this, it was declarated deprecated by marcus sheffold if ($member->getBonusLevel() > 0) { // Pay the individual bonus set for this member $transfer = self::doPay($memberFee, $transfer, $member, \Transaction::REASON_CUSTOM_BONUS_LEVEL, $relatedId, $currency, $when, $con); } $reasonByType = $member->getTransactionReasonByType($type); if ($reasonByType !== null) { $transfer = self::doPay($memberFee, $transfer, $member, $reasonByType, $relatedId, $currency, $when, $con); } $reasonByMemberNum = $member->getTransactionReasonByMemberNum(); if ($reasonByMemberNum !== null) { $transfer = self::doPay($memberFee, $transfer, $member, $reasonByMemberNum, $relatedId, $currency, $when, $con); } // lazy save all these objects later to prevent multiple // database update's cause there might get more bonuses spread. if ($transfer) { $toBeSaved[] = $member; $toBeSaved[] = $transfer; // Save the payed bonuses by type $spreadBonuses[$type] = [$transfer, $member, $reasonByType]; } } $propagateBonuses = [Member::TYPE_PROMOTER, Member::TYPE_ORGLEADER, Member::TYPE_MARKETINGLEADER, Member::TYPE_SALES_MANAGER, Member::TYPE_CEO]; $collectUnspreadBonusus = []; foreach ($propagateBonuses as $memberType) { if (!isset($spreadBonuses[$memberType])) { // This bonus is unspread, so collect it to give it to the next higher // existing member type $collectUnspreadBonusus[] = $memberType; } else { $memberObjects = $spreadBonuses[$memberType]; foreach ($collectUnspreadBonusus as $memberType) { self::doPay($memberFee, $memberObjects[0], $memberObjects[1], \Member::getTransactionReasonByType($memberType), $relatedId, $currency, $when, $con); } // Reset $collectUnspreadBonusus = []; } } foreach ($toBeSaved as $row) { $row->save($con); } }
function saveMember($member_data, Member $member, $is_new = true) { try { DB::beginWork(); if (!$is_new) { $old_parent = $member->getParentMemberId(); } $member->setFromAttributes($member_data); /* @var $member Member */ $object_type = ObjectTypes::findById($member->getObjectTypeId()); if (!$object_type instanceof ObjectType) { throw new Exception(lang("you must select a valid object type")); } if ($member->getParentMemberId() == 0) { $dot = DimensionObjectTypes::findById(array('dimension_id' => $member->getDimensionId(), 'object_type_id' => $member->getObjectTypeId())); if (!$dot->getIsRoot()) { throw new Exception(lang("member cannot be root", lang($object_type->getName()))); } $member->setDepth(1); } else { $allowedParents = $this->getAssignableParents($member->getDimensionId(), $member->getObjectTypeId()); if (!$is_new) { $childrenIds = $member->getAllChildrenIds(true); } $hasValidParent = false; if ($member->getId() == $member->getParentMemberId() || !$is_new && in_array($member->getParentMemberId(), $childrenIds)) { throw new Exception(lang("invalid parent member")); } foreach ($allowedParents as $parent) { if ($parent['id'] == $member->getParentMemberId()) { $hasValidParent = true; break; } } if (!$hasValidParent) { throw new Exception(lang("invalid parent member")); } $parent = Members::findById($member->getParentMemberId()); if ($parent instanceof Member) { $member->setDepth($parent->getDepth() + 1); } else { $member->setDepth(1); } } if ($object_type->getType() == 'dimension_object') { $handler_class = $object_type->getHandlerClass(); if ($is_new || $member->getObjectId() == 0) { eval('$dimension_object = ' . $handler_class . '::instance()->newDimensionObject();'); } else { $dimension_object = Objects::findObject($member->getObjectId()); } if ($dimension_object) { $dimension_object->modifyMemberValidations($member); $dimension_obj_data = array_var($_POST, 'dim_obj'); if (!array_var($dimension_obj_data, 'name')) { $dimension_obj_data['name'] = $member->getName(); } eval('$fields = ' . $handler_class . '::getPublicColumns();'); foreach ($fields as $field) { if (array_var($field, 'type') == DATA_TYPE_DATETIME) { $dimension_obj_data[$field['col']] = getDateValue($dimension_obj_data[$field['col']]); } } $member->save(); $dimension_object->setFromAttributes($dimension_obj_data, $member); $dimension_object->save(); $member->setObjectId($dimension_object->getId()); $member->save(); Hook::fire("after_add_dimension_object_member", $member, $null); } } else { $member->save(); } // Other dimensions member restrictions $restricted_members = array_var($_POST, 'restricted_members'); if (is_array($restricted_members)) { MemberRestrictions::clearRestrictions($member->getId()); foreach ($restricted_members as $dim_id => $dim_members) { foreach ($dim_members as $mem_id => $member_restrictions) { $restricted = isset($member_restrictions['restricted']); if ($restricted) { $order_num = array_var($member_restrictions, 'order_num', 0); $member_restriction = new MemberRestriction(); $member_restriction->setMemberId($member->getId()); $member_restriction->setRestrictedMemberId($mem_id); $member_restriction->setOrder($order_num); $member_restriction->save(); } } } } // Save member property members (also check for required associations) if (array_var($_POST, 'save_properties')) { $required_association_ids = DimensionMemberAssociations::getRequiredAssociatations($member->getDimensionId(), $member->getObjectTypeId(), true); $missing_req_association_ids = array_fill_keys($required_association_ids, true); // if keeps record change is_active, if not delete record $old_properties = MemberPropertyMembers::getAssociatedPropertiesForMember($member->getId()); foreach ($old_properties as $property) { $association = DimensionMemberAssociations::findById($property->getAssociationId()); if (!$association->getKeepsRecord()) { $property->delete(); } } $new_properties = array(); $associated_members = array_var($_POST, 'associated_members', array()); foreach ($associated_members as $prop_member_id => $assoc_id) { $active_association = null; if (isset($missing_req_association_ids[$assoc_id])) { $missing_req_association_ids[$assoc_id] = false; } $conditions = "`association_id` = {$assoc_id} AND `member_id` = " . $member->getId() . " AND `is_active` = 1"; $active_associations = MemberPropertyMembers::find(array('conditions' => $conditions)); if (count($active_associations) > 0) { $active_association = $active_associations[0]; } $association = DimensionMemberAssociations::findById($assoc_id); if ($active_association instanceof MemberPropertyMember) { if ($active_association->getPropertyMemberId() != $prop_member_id) { if ($association->getKeepsRecord()) { $active_association->setIsActive(false); $active_association->save(); } // save current association $mpm = new MemberPropertyMember(); $mpm->setAssociationId($assoc_id); $mpm->setMemberId($member->getId()); $mpm->setPropertyMemberId($prop_member_id); $mpm->setIsActive(true); $mpm->save(); $new_properties[] = $mpm; } } else { // save current association $mpm = new MemberPropertyMember(); $mpm->setAssociationId($assoc_id); $mpm->setMemberId($member->getId()); $mpm->setPropertyMemberId($prop_member_id); $mpm->setIsActive(true); $mpm->save(); $new_properties[] = $mpm; } } $missing_names = array(); $missing_count = 0; foreach ($missing_req_association_ids as $assoc => $missing) { $assoc_instance = DimensionMemberAssociations::findById($assoc); if ($assoc_instance instanceof DimensionMemberAssociation) { $assoc_dim = Dimensions::getDimensionById($assoc_instance->getAssociatedDimensionMemberAssociationId()); if ($assoc_dim instanceof Dimension) { if (!in_array($assoc_dim->getName(), $missing_names)) { $missing_names[] = $assoc_dim->getName(); } } } if ($missing) { $missing_count++; } } if ($missing_count > 0) { throw new Exception(lang("missing required associations", implode(", ", $missing_names))); } $args = array($member, $old_properties, $new_properties); Hook::fire('edit_member_properties', $args, $ret); } if ($is_new) { // set all permissions for the creator $dimension = $member->getDimension(); $allowed_object_types = array(); $dim_obj_types = $dimension->getAllowedObjectTypeContents(); foreach ($dim_obj_types as $dim_obj_type) { // To draw a row for each object type of the dimension if (!in_array($dim_obj_type->getContentObjectTypeId(), $allowed_object_types) && $dim_obj_type->getDimensionObjectTypeId() == $member->getObjectTypeId()) { $allowed_object_types[] = $dim_obj_type->getContentObjectTypeId(); } } $allowed_object_types[] = $object_type->getId(); foreach ($allowed_object_types as $ot) { $cmp = ContactMemberPermissions::findOne(array('conditions' => 'permission_group_id = ' . logged_user()->getPermissionGroupId() . ' AND member_id = ' . $member->getId() . ' AND object_type_id = ' . $ot)); if (!$cmp instanceof ContactMemberPermission) { $cmp = new ContactMemberPermission(); $cmp->setPermissionGroupId(logged_user()->getPermissionGroupId()); $cmp->setMemberId($member->getId()); $cmp->setObjectTypeId($ot); } $cmp->setCanWrite(1); $cmp->setCanDelete(1); $cmp->save(); } // set all permissions for permission groups that has allow all in the dimension $permission_groups = ContactDimensionPermissions::findAll(array("conditions" => array("`dimension_id` = ? AND `permission_type` = 'allow all'", $dimension->getId()))); if (is_array($permission_groups)) { foreach ($permission_groups as $pg) { foreach ($allowed_object_types as $ot) { $cmp = ContactMemberPermissions::findById(array('permission_group_id' => $pg->getPermissionGroupId(), 'member_id' => $member->getId(), 'object_type_id' => $ot)); if (!$cmp instanceof ContactMemberPermission) { $cmp = new ContactMemberPermission(); $cmp->setPermissionGroupId($pg->getPermissionGroupId()); $cmp->setMemberId($member->getId()); $cmp->setObjectTypeId($ot); } $cmp->setCanWrite(1); $cmp->setCanDelete(1); $cmp->save(); } } } // Inherit permissions from parent node, if they are not already set if ($member->getDepth() && $member->getParentMember()) { $parentNodeId = $member->getParentMember()->getId(); $condition = "member_id = {$parentNodeId}"; foreach (ContactMemberPermissions::instance()->findAll(array("conditions" => $condition)) as $parentPermission) { /* @var $parentPermission ContactMemberPermission */ $g = $parentPermission->getPermissionGroupId(); $t = $parentPermission->getObjectTypeId(); $w = $parentPermission->getCanWrite(); $d = $parentPermission->getCanDelete(); $existsCondition = "member_id = " . $member->getId() . " AND permission_group_id= {$g} AND object_type_id = {$t}"; if (!ContactMemberPermissions::instance()->count(array("conditions" => $existsCondition))) { $newPermission = new ContactMemberPermission(); $newPermission->setPermissionGroupId($g); $newPermission->setObjectTypeId($t); $newPermission->setCanWrite($w); $newPermission->setCanDelete($d); $newPermission->setMemberId($member->getId()); $newPermission->save(); } } } // Fill sharing table if is a dimension object (after permission creation); if (isset($dimension_object) && $dimension_object instanceof ContentDataObject) { $dimension_object->addToSharingTable(); } } else { // if parent changed rebuild object_members for every object in this member if ($old_parent != $member->getParentMemberId()) { $sql = "SELECT om.object_id FROM " . TABLE_PREFIX . "object_members om WHERE om.member_id=" . $member->getId(); $object_ids = DB::executeAll($sql); if (!is_array($object_ids)) { $object_ids = array(); } foreach ($object_ids as $row) { $content_object = Objects::findObject($row['object_id']); if (!$content_object instanceof ContentDataObject) { continue; } $parent_ids = array(); if ($old_parent > 0) { $all_parents = Members::findById($old_parent)->getAllParentMembersInHierarchy(true); foreach ($all_parents as $p) { $parent_ids[] = $p->getId(); } if (count($parent_ids) > 0) { DB::execute("DELETE FROM " . TABLE_PREFIX . "object_members WHERE object_id=" . $content_object->getId() . " AND member_id IN (" . implode(",", $parent_ids) . ")"); } } $content_object->addToMembers(array($member)); $content_object->addToSharingTable(); } } } DB::commit(); flash_success(lang('success save member', lang(ObjectTypes::findById($member->getObjectTypeId())->getName()), $member->getName())); ajx_current("back"); // Add od to array on new members if ($is_new) { $member_data['member_id'] = $member->getId(); } evt_add("after member save", $member_data); return $member; } catch (Exception $e) { DB::rollback(); flash_error($e->getMessage()); ajx_current("empty"); } }
function core_dim_add_company_to_users_dimension($object, $user_dim, $company_ot) { $member = new Member(); $member->setName($object->getObjectName()); $member->setObjectTypeId($company_ot->getId()); $member->setDimensionId($user_dim->getId()); $member->setDepth(1); $member->setParentMemberId(0); $member->setObjectId($object->getId()); $member->save(); // permisssions $sql = "INSERT INTO `" . TABLE_PREFIX . "contact_dimension_permissions` (`permission_group_id`, `dimension_id`, `permission_type`)\n\t\t\t SELECT `c`.`permission_group_id`, " . $user_dim->getId() . ", 'check'\n\t\t\t FROM `" . TABLE_PREFIX . "contacts` `c` \n\t\t\t WHERE `c`.`is_company`=0 AND `c`.`user_type`!=0 AND `c`.`disabled`=0\n\t\t\t ON DUPLICATE KEY UPDATE `dimension_id`=`dimension_id`;"; DB::execute($sql); $sql = "INSERT INTO `" . TABLE_PREFIX . "contact_member_permissions` (`permission_group_id`, `member_id`, `object_type_id`, `can_write`, `can_delete`)\n\t\t\t SELECT `c`.`permission_group_id`, " . $member->getId() . ", `ot`.`id`, (`c`.`object_id` = " . $object->getId() . ") as `can_write`, (`c`.`object_id` = " . $object->getId() . ") as `can_delete`\n\t\t\t FROM `" . TABLE_PREFIX . "contacts` `c` JOIN `" . TABLE_PREFIX . "object_types` `ot` \n\t\t\t WHERE `c`.`is_company`=0 \n\t\t\t \tAND `c`.`user_type`!=0 AND `c`.`disabled`=0\n\t\t\t\tAND `ot`.`type` IN ('content_object', 'comment')\n\t\t\t ON DUPLICATE KEY UPDATE `member_id`=`member_id`;"; DB::execute($sql); return $member; }
$data['password'] = md5($temp_password); $member->setAdmin(true); if (!$member->update($data)) { echo 'ko'; exit; } $lines = file(dirname(__FILE__) . '/../private/mail/member_password_reset.txt'); $message = ''; foreach ($lines as $line) { $message .= $line; } $temp_password_line = "Temporary password: "******"\n"; $message = str_replace('%temp_password_line%', $temp_password_line, $message); $subject = "Member Password Reset"; $headers = 'From: YellowElevator.com <*****@*****.**>' . "\n"; mail($member->getId(), $subject, $message, $headers); // $handle = fopen('/tmp/email_to_'. $member->getId(). '.txt', 'w'); // fwrite($handle, 'Subject: '. $subject. "\n\n"); // fwrite($handle, $message); // fclose($handle); echo 'ok'; exit; } echo 'bad'; exit; } if ($_POST['action'] == 'login') { $id = $_POST['id']; $hash = $_POST['hash']; $sid = $_POST['sid']; $_SESSION['yel']['member']['id'] = $id;
public function setAuthorByMember(Member $member) { $this->setAuthor($member->getName(), $member->getId()); }
<a href="http://<?php echo $GLOBALS['root'] . '/employers/resume_download.php?id=' . $_GET['id']; ?> "> Click here to download the resume. </a> <?php } else { echo 'Sorry, the resume file seemed to be missing. Please contact us at <a href="mailto: support@yellowelevator.com">support@yellowelevator.com</a>.'; } ?> </div> <br/> <div style="text-align: center;"> <img src="candidate_photo.php?id=<?php echo $member->getId(); ?> " style="border: none;" /> </div> </body> </html> <?php } else { if (file_exists($file)) { $filename_items = explode('.', $resume_file['file_name']); $ext = $filename_items[1]; header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Expires: -1'); header('Content-Description: File Transfer'); header('Content-Length: ' . $resume_file['file_size']);
protected function processStep3Check(sfWebRequest $request) { $default_airport = AirportPeer::getByIdent(sfConfig::get('app_default_airport_ident')); $this->forward404Unless($default_airport); $app = $this->application_temp; $person = $this->person; if (!$person instanceof Person) { $person = new Person(); } /* @var $app ApplicationTemp */ /* @var $person Person */ // Person $tmp_arr = $app->toArray(BasePeer::TYPE_FIELDNAME); $tmp_arr['evening_phone'] = $tmp_arr['eve_phone']; $tmp_arr['evening_comment'] = $tmp_arr['eve_comment']; unset($tmp_arr['id']); $person->fromArray($tmp_arr, BasePeer::TYPE_FIELDNAME); $person->save(); // Member $member = MemberPeer::retrieveByPK($app->getMemberId()); if (!$member instanceof Member) { $member = new Member(); } $member->setActive(1); $member->setCoPilot($app->getApplicantCopilot()); $member->setContact('By Email'); $member->setDateOfBirth($app->getDateOfBirth()); $member->setDriversLicenseState($app->getDriversLicenseState()); $member->setDriversLicenseNumber($app->getDriversLicenseNumber()); $member->setEmergencyContactName($app->getEmergencyContactName()); $member->setEmergencyContactPhone($app->getEmergencyContactPhone()); $member->setFlightStatus($app->getApplicantPilot() ? 'Verify Orientation' : 'Non-pilot'); //$member->setJoinDate(time()); $member->setLanguages($app->getLanguagesSpoken()); //Farazi //$member->setMasterMemberId($app->getMasterMemberId()); // Get Last renewal date $this->member = MemberPeer::retrieveByPK($app->getMemberId()); $lastRenewalDate = strtotime($this->member->getRenewalDate()); $member->setMemberClassId($app->getMemberClassId()); $member->setPersonId($person->getId()); $member->setRenewedDate(time()); ///Farazi Renewal Date From Memberclass if ($app->getMemberClassId()) { $memclass = MemberClassPeer::retrieveByPK($app->getMemberClassId()); $renewal_period = $memclass->getRenewalPeriod(); $renewalTime = strtotime('+' . $renewal_period . ' month', $lastRenewalDate); //echo $renewalTime; $member->setRenewalDate($renewalTime); //$member->setRenewalDate(strtotime('+'.$renewal_period.' month')); } // Farazi End //$member->setRenewalDate(strtotime('+1 year')); $member->setSpouseName($app->getSpouseFirstName() . ' ' . $app->getSpouseLastName()); $member->setWeight($app->getWeight()); $member->setWingId($app->getWingId()); $member->save(); // Pilot if ($app->getApplicantPilot()) { $pilot = $member->getPilot(); if (!$pilot instanceof Pilot) { $pilot = new Pilot(); } if ($pilot->isNew()) { // remove aircrafts foreach ($member->getPilotAircrafts() as $p_a) { PilotAircraftPeer::doDelete($p_a); } } $pilot->setMemberId($member->getId()); $airport = AirportPeer::getByIdent($app->getHomeBase()); if (!$airport instanceof Airport) { $airport = $default_airport; } $pilot->setPrimaryAirportId($airport->getId()); $pilot->setTotalHours($app->getTotalHours()); $pilot->setLicenseType('Private'); foreach (sfConfig::get('app_pilot_license_types') as $key => $val) { if (stripos($app->getRatings(), $key) !== false) { $pilot->setLicenseType($key); } } $pilot->setIfr(stripos($app->getRatings(), 'ifr') !== false ? 1 : 0); $pilot->setMultiEngine(stripos($app->getRatings(), 'multi') !== false ? 1 : 0); $pilot->setSeInstructor('No'); // @see ApplicationForm foreach (sfConfig::get('app_pilot_se_instructor') as $key => $val) { if (stripos($app->getRatings(), $key) !== false) { $pilot->setSeInstructor($key); } } $pilot->setMeInstructor($pilot->getSeInstructor()); $pilot->save(); // Availability $availability = $member->getAvailability(); if (!$availability instanceof Availability) { $availability = new Availability(); } $availability->setMemberId($member->getId()); $availability->setNotAvailable(0); $availability->setNoWeekday($app->getAvailabilityWeekdays() == 0); $availability->setNoNight($app->getAvailabilityWeeknights() == 0); $availability->setLastMinute($app->getAvailabilityLastMinute()); $availability->setAsMissionMssistant($app->getAvailabilityCopilot()); $availability->setNoWeekend($app->getAvailabilityWeekends() == 0); $availability->save(); //Farazi //Delete all aircrafts $pilot_aircrafts = PilotAircraftPeer::getByMemberId($member->getId()); foreach ($pilot_aircrafts as $pilot_aircraft) { $pilot_aircraft->delete(); } // Primary aircraft if ($app->getAircraftPrimaryId() && ($aircraft = AircraftPeer::retrieveByPK($app->getAircraftPrimaryId()))) { $pilot_aircraft = new PilotAircraft(); $pilot_aircraft->setMemberId($member->getId()); $pilot_aircraft->setAircraftId($aircraft->getId()); $pilot_aircraft->setNNumber($app->getAircraftPrimaryNNumber()); $pilot_aircraft->setOwn($app->getAircraftPrimaryOwn()); $pilot_aircraft->setSeats($app->getAircraftPrimarySeats()); $pilot_aircraft->setKnownIce($app->getAircraftPrimaryIce()); $pilot_aircraft->save(); } // Secondary aircraft if ($app->getAircraftSecondaryId() && ($aircraft = AircraftPeer::retrieveByPK($app->getAircraftSecondaryId()))) { $pilot_aircraft = new PilotAircraft(); $pilot_aircraft->setMemberId($member->getId()); $pilot_aircraft->setAircraftId($aircraft->getId()); $pilot_aircraft->setNNumber($app->getAircraftSecondaryNNumber()); $pilot_aircraft->setOwn($app->getAircraftSecondaryOwn()); $pilot_aircraft->setSeats($app->getAircraftSecondarySeats()); $pilot_aircraft->setKnownIce($app->getAircraftSecondaryIce()); $pilot_aircraft->save(); } // Third aircraft if ($app->getAircraftThirdId() && ($aircraft = AircraftPeer::retrieveByPK($app->getAircraftThirdId()))) { $pilot_aircraft = new PilotAircraft(); $pilot_aircraft->setMemberId($member->getId()); $pilot_aircraft->setAircraftId($aircraft->getId()); $pilot_aircraft->setNNumber($app->getAircraftThirdNNumber()); $pilot_aircraft->setOwn($app->getAircraftThirdOwn()); $pilot_aircraft->setSeats($app->getAircraftThirdSeats()); $pilot_aircraft->setKnownIce($app->getAircraftThirdIce()); $pilot_aircraft->save(); } } // Application_temp $app->setPersonId($person->getId()); $app->setMemberId($member->getId()); $app->setProcessedDate(time()); $app->save(); // Application $tmp_arr = $app->toArray(BasePeer::TYPE_FIELDNAME); $tmp_arr['date'] = $tmp_arr['application_date']; $tmp_arr['company'] = $tmp_arr['company_name']; foreach (sfConfig::get('app_pilot_license_types') as $key => $val) { if (stripos($tmp_arr['ratings'], $key) !== false) { $tmp_arr['license_type'] = $key; } } $tmp_arr['ifr'] = stripos($tmp_arr['ratings'], 'ifr') !== false ? 1 : 0; $tmp_arr['multi_engine'] = stripos($tmp_arr['ratings'], 'multi') !== false ? 1 : 0; $tmp_arr['se_instructor'] = 'No'; // @see ApplicationForm foreach (sfConfig::get('app_pilot_se_instructor') as $key => $val) { if (stripos($tmp_arr['ratings'], $key) !== false) { $tmp_arr['se_instructor'] = $key; } } $tmp_arr['me_instructor'] = $tmp_arr['se_instructor']; $tmp_arr['other_ratings'] = $tmp_arr['ratings']; $tmp_arr['fbo'] = $tmp_arr['fbo_name']; $tmp_arr['member_meetings'] = 0; $tmp_arr['executive_board'] = 0; $tmp_arr['dues_amount_paid'] = $tmp_arr['dues_amount_paid'] ? $tmp_arr['dues_amount_paid'] : 0; $tmp_arr['donation_amount_paid'] = $tmp_arr['donation_amount_paid'] ? $tmp_arr['donation_amount_paid'] : 0; unset($tmp_arr['id']); $application = new Application(); $application->fromArray($tmp_arr, BasePeer::TYPE_FIELDNAME); $application->save(); $this->getUser()->setFlash('success', 'Membership renewal completed successfully.'); //$this->redirect('renewal/processComplete?id='.$member->getId()); $this->redirect('renewal/processStep3?id=' . $this->application_temp->getId()); //$this->redirect('renewal/index?id='.$member->getId()); }
/** * Declares an association between this object and a Member object. * * @param Member $v * @return MemberWingJob The current object (for fluent API support) * @throws PropelException */ public function setMember(Member $v = null) { if ($v === null) { $this->setMemberId(NULL); } else { $this->setMemberId($v->getId()); } $this->aMember = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the Member object, it will not be re-added. if ($v !== null) { $v->addMemberWingJob($this); } return $this; }
public static function payBonuses(\Tbmt\MemberFee $memberFee, Member $payingMember, $currency, $when, PropelPDO $con) { $bonusByIds = self::toArray($payingMember->getBonusIds()); if (!is_array($bonusByIds)) { return; } $bonusIds = array_keys($bonusByIds); if (count($bonusIds) === 0) { return; } $relatedId = $payingMember->getId(); $bonusMembers = MemberQuery::create()->filterByDeletionDate(null, Criteria::ISNULL)->filterById($bonusIds, Criteria::IN)->find($con); $spreadBonuses = []; $membersByType = []; $toBeSaved = []; foreach ($bonusMembers as $member) { $type = $member->getType(); $transfer = self::doPay($memberFee, null, $member, $member->getBonusReason(), $relatedId, $currency, $when, $con); // lazy save all these objects later to prevent multiple // database update's cause there might get more bonuses spread. $toBeSaved[] = $member; $toBeSaved[] = $transfer; $spreadBonuses[$type] = [$member, $transfer]; } $inheritBonuses = []; $add_OL = null; $add_VL = []; $vl = null; if (!isset($spreadBonuses[Member::TYPE_PROMOTER])) { // if promoter does not exist give org leader his bonus $add_OL = Transaction::REASON_PM_BONUS; } if (!isset($spreadBonuses[Member::TYPE_ORGLEADER])) { // if org leader does not exist give marketing leader his bonus $add_VL[] = Transaction::REASON_OL_BONUS; if ($add_OL) { $add_VL[] = $add_OL; $add_OL = null; } } if (!isset($spreadBonuses[Member::TYPE_MARKETINGLEADER])) { $add_VL = []; } else { $vl = $spreadBonuses[Member::TYPE_MARKETINGLEADER]; } if ($add_OL) { $ol = $spreadBonuses[Member::TYPE_ORGLEADER]; self::doPay($memberFee, $ol[1], $ol[0], $add_OL, $relatedId, $currency, $when, $con); } foreach ($add_VL as $params) { self::doPay($memberFee, $vl[1], $vl[0], $params, $relatedId, $currency, $when, $con); } foreach ($toBeSaved as $row) { $row->save($con); } }