Beispiel #1
0
 /**
  * New comment mailling
  *  To user or To Admin
  * @param Demand $demand
  * @param User $currentUser
  */
 public function newCommentSendMail(Demand $demand, User $currentUser)
 {
     // Define necessary vars
     $template = "SpiritDevDBoxPortalBundle:Mailer/NewComment:newComment.html.twig";
     // Template
     $subject = $this->getSubject("New comment on your demand");
     // Subject
     $demandUrl = $this->router->generate('spirit_dev_dbox_portal_bundle_demand', array('id' => $demand->getId()), true);
     // Define target mail and template user to return
     if ($currentUser->getDn() == "uid=sys,dc=ldap,dc=test" || $currentUser->getDn() == "uid=admin,dc=ldap,dc=test") {
         // If user is admin, set Ldap User mail
         $mailTo = $demand->getApplicant()->getEmail();
         $templateUser = $demand->getApplicant();
     } else {
         // If user is LDAP user, Set admin mail
         $mailTo = $this->adminMail;
         $templateUser = null;
     }
     $rendered = $this->templating->render($template, array('demand' => $demand, 'user' => $templateUser, 'demand_url' => $demandUrl));
     // Template rendering
     // Send message
     $this->sendEmailMessage($rendered, $subject, $mailTo);
 }
Beispiel #2
0
 /**
  * @param User $user
  * @return mixed
  */
 public function createUser(User $user)
 {
     // Fast Return in case of server stopped
     if (!$this->isServerAvailable()) {
         return null;
     }
     // Create user
     $newUser = $this->gitLabClient->api($this::API_USERS)->create($user->getEmail(), '1234567890', array('username' => $user->getUsername(), 'name' => $user->getCommonName(), 'provider' => $this->ldapProvider, 'extern_uid' => $user->getDn(), 'confirm' => false, 'projects_limit' => 0));
     // Return created user
     return $newUser;
 }
Beispiel #3
0
 /**
  * Unlock user LDAP Account
  * @param User $user
  * @return mixed
  */
 public function ldapUnlockAccount(User $user)
 {
     $ldapInitialization = $this->ldapInit();
     $issue = null;
     if ($ldapInitialization) {
         $ldapSearch = ldap_search($this->ldapLinkIdentifier, $this->baseDn, 'uid=' . $user->getUsername());
         $ldapUser = ldap_get_entries($this->ldapLinkIdentifier, $ldapSearch);
         $ldapUserPassword = $ldapUser[0]['userpassword'][0];
         $ldapUserNewPassword = substr($ldapUserPassword, 0, 6) . substr($ldapUserPassword, 7, strlen($ldapUserPassword));
         $modifiedInfos = ['userPassword' => $ldapUserNewPassword];
         $issue = ldap_modify($this->ldapLinkIdentifier, $user->getDn(), $modifiedInfos);
     }
     ldap_close($this->ldapLinkIdentifier);
     return $issue;
 }