Exemple #1
0
 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());
 }
Exemple #2
0
 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());
 }