public function executeProcessNewOrgForm(sfWebRequest $request) { $f = $request->getParameter("organization"); $p = Doctrine::getTable('Principal')->findOneByFedid($this->getUser()->getUsername()); $o = new Organization(); $o->setName($f["name"]); $o->setDescription($f["description"]); $o->setCreatedAt(date('Y-m-d H:i:s')); $o->save(); $op = new OrganizationPrincipal(); $op->setOrganization($o); $op->setPrincipal($p); $op->save(); $i = new Invitation(); $i->setEmail($p->getEmail()); $i->setOrganization($o); $i->setUuid('1'); $i->setCreatedAt(date('Y-m-d H:i:s')); $i->setAcceptAt(date('Y-m-d H:i:s')); $i->setCounter(1); $i->setInviter($p); $i->setPrincipal($p); $i->setStatus("accepted"); $i->save(); $r = new Role(); $r->setName($f["role_name"]); $r->setOrganization($o); $r->setShoworder(0); $r->save(); $o->setDefaultRoleId($r->getId()); $o->save(); $this->redirect("show/index?id=" . $o->getId()); }
public function executeCreate(sfWebRequest $request) { $i18n = sfContext::getInstance()->getI18N(); $form = new InvitePrincipalForm(); $a = $request->getParameter($form->getName()); $oid = $a['o_id']; $form->bind($request->getParameter('invite')); if (!$form->isValid()) { $this->getUser()->setFlash('notice', $i18n->__('Could not send the invitation, please check the e-mail address and try again!')); $this->redirect("show/index?id=" . $oid); } $emails = $form->getValue('email'); $o_id = $form->getValue('o_id'); $role_id = $form->getValue('role_id'); $m = $form->getValue('message'); $o = Doctrine::getTable('Organization')->find($o_id); $p = $this->getUser()->getPrincipal(); foreach ($emails as $email) { $uuid = uniqid(); $i = new Invitation(); $i->setEmail($email); $i->setOrganization($o); $i->setUuid($uuid); $i->setCreatedAt(date('Y-m-d H:i:s')); $i->setCounter(1); $i->setInviter($p); $i->setStatus('pending'); $i->setRoleId($role_id); $i->save(); $r = $i->getRole(); /* Send email */ $params = array("i" => $i, "m" => $m, "o" => $o, "p" => $p, "r" => $r, "reinvite" => FALSE); $email_params = array("to" => $i->getEmail(), "subject" => $i18n->__('Invitation to %organization% organization', array("%organization%" => $o)), "bodyhtml" => $this->getPartial('invitePrincipal/inviteHtml', $params)); $this->sendEmail($email_params); $to = $o->getManagersEmailArray(); $params = array("o" => $o, "p" => $p, "r" => $r, "email" => $email); $email_params = array("to" => $to, "subject" => $i18n->__('Invitation of %email% to %organization% organization', array("%email%" => $email, "%organization%" => $o)), "bodyhtml" => $this->getPartial('invitePrincipal/inviteNoticeHtml', $params)); $this->sendEmail($email_params); } $this->getUser()->setFlash('notice', $i18n->__('The invitation has been sent.')); $this->redirect("show/index?id=" . $o->getId()); }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { $data = Input::only('role_id', 'name', 'email'); $invitation = new Invitation(); $invitation->role_id = $data['role_id']; $invitation->email = $data['email']; $invitation->name = $data['name']; try { $invitation->save(); } catch (ValidationException $errors) { return Redirect::route('admin.invitations.create')->withErrors($errors->getErrors()); } $data['code'] = $invitation->code; Mail::send('emails.auth.invitation', $data, function ($message) use($data) { $message->to($data['email'], $data['name'])->subject('Покана за регистрация в РегистърБГ'); }); if (count(Mail::failures()) > 0) { return Redirect::route('admin.invitations.index')->withErrors(array('mainError' => 'Възникна грешка при изпращане на имейл. Моля опитайте по-късно.'))->withInput(); } return Redirect::route('admin.invitations.index')->withErrors(array('mainSuccess' => 'Поканата е успешно изпратена.')); }
} if ($trusted) { $body .= '<p>If you accept this invitation, you will become a <a href="' . Url::help() . '">trusted member</a> of this project.</p>'; } $body .= '<p>To respond to this invitation, log into ' . PIPELINE_NAME . ' and visit your <a href="' . Url::dashboard() . '">dashboard</a>.</p>'; $email = array('to' => $u->getEmail(), 'subject' => '[' . PIPELINE_NAME . '] Invitation to join the project ' . $project->getTitle(), 'message' => $body); // send email Email::send($email); } } foreach ($emails as $e) { // generate code // $code = sha1(microtime(true).mt_rand(10000,90000)); // send invitation $invite = new Invitation(array('inviter_id' => Session::getUserID(), 'invitee_email' => $e, 'project_id' => $project->getID(), 'trusted' => $trusted, 'invitation_message' => $message)); $invite->save(); // log event $logEvent = new Event(array('event_type_id' => 'invite_member_email', 'project_id' => $project->getID(), 'user_1_id' => Session::getUserID(), 'item_1_id' => $invite->getID(), 'data_1' => $e, 'data_2' => $message, 'data_3' => $trusted)); $logEvent->save(); // compose email $body = "<p>" . formatUserLink(Session::getUserID()) . ' invited you to join the project ' . formatProjectLink($project->getID()) . '.</p>'; if (!empty($message)) { $body .= '<blockquote>' . formatInvitationMessage($message) . '</blockquote>'; } if ($trusted) { $body .= '<p>If you accept this invitation, you will become a <a href="' . Url::help() . '">trusted member</a> of this project.</p>'; } $body .= '<p>To respond to this invitation, <a href="' . Url::consent($e) . '">register</a> a free account on ' . PIPELINE_NAME . ' using this email address (' . $e . ').</p>'; $email = array('to' => $e, 'subject' => '[' . PIPELINE_NAME . '] Invitation to join the project ' . $project->getTitle(), 'message' => $body); // send email Email::send($email);
public static function createFromSignup($data, $refererMember, Invitation $invitation = null, PropelPDO $con) { // This functions expects this parameter to be valid! // E.g. the result from self::validateSignupForm() $now = time(); if (!$con->beginTransaction()) { throw new Exception('Could not begin transaction'); } try { $member = new Member(); $member->setFirstName($data['firstName'])->setLastName($data['lastName'])->setEmail($data['email'])->setTitle($data['title'])->setCity($data['city'])->setCountry($data['country'])->setAge($data['age'])->setBankRecipient($data['bank_recipient'])->setIban($data['iban'])->setBic($data['bic'])->setPassword($data['password'])->setSignupDate($now); if ($invitation) { $member->setType($invitation->getType()); if ($invitation->getFreeSignup()) { $member->setPaidDate($now); } $invitation->setAcceptedDate($now); } $member->setRefererMember($refererMember, $con); $member->save($con); if ($invitation) { $invitation->setAcceptedMemberId($member->getId()); $invitation->save($con); } if (!$con->commit()) { throw new Exception('Could not commit transaction'); } } catch (Exception $e) { $con->rollBack(); throw $e; } return $member; }
public function createFromSignup($data, $referrerMember, \Invitation $invitation = null, \PropelPDO $con) { // This functions expects this parameter to be valid! // E.g. the result from $this->validateSignupForm() $now = time(); if (!$con->beginTransaction()) { throw new \Exception('Could not begin transaction'); } try { $member = new \Member(); $member->setFirstName($data['firstName'])->setLastName($data['lastName'])->setEmail($data['email'])->setTitle($data['title'])->setCity($data['city'])->setZipCode($data['zip_code'])->setCountry('India')->setAge($data['age'])->setBankRecipient($data['bank_recipient'])->setIban($data['iban'])->setBic($data['bic'])->setPassword($data['password'])->setSignupDate($now)->setBonusIds('{}')->setPaidDate(null)->setIsExtended(1); $member->setHash(\Member::calcHash($member)); $wasFreeInvitation = false; if ($invitation) { $invitationType = $invitation->getType(); $member->setType($invitationType); // Special case if e.g. director invites another director. // The referrer of the referrer will be the referrer. // This is necessary because the same type can not be on same line vertical // but horizontal. E.g. Director can have more marketing leader under him // but only Directors next to him (NOT under him) if ($invitationType > \Member::TYPE_MEMBER && $referrerMember->getType() == $invitationType) { $referrerMember = $referrerMember->getReferrerMember(); } $invitation->setAcceptedDate($now); if ($invitation->getFreeSignup()) { $member->setFreeInvitation(1); $wasFreeInvitation = true; } // Deprecated code // if ( $invitation->getType() === \Member::TYPE_SUB_PROMOTER ) { // $member->setSubPromoterReferral($invitation->getMeta()['promoter_id']); // } } $member->setReferrerMember($referrerMember, $con); $member->save($con); $member->setNum($member->getId() + 1000000); if ($invitation) { $invitation->setAcceptedMemberId($member->getId()); $invitation->save($con); if ($wasFreeInvitation) { $member->onReceivedMemberFee(\Transaction::$BASE_CURRENCY, $now, true, $con); } } if ($wasFreeInvitation) { \Tbmt\MailHelper::sendFreeSignupConfirm($member); \Tbmt\MailHelper::sendNewFreeRecruitmentCongrats($referrerMember, $member); } else { \Tbmt\MailHelper::sendSignupConfirm($member); \Tbmt\MailHelper::sendNewRecruitmentCongrats($referrerMember, $member); } $member->save($con); if (!$con->commit()) { throw new \Exception('Could not commit transaction'); } } catch (\Exception $e) { $con->rollBack(); throw $e; } return $member; }