Esempio n. 1
0
 /**
  * Save changes to a user domain.
  */
 function save_action()
 {
     $id = Request::get('id');
     $name = Request::get('name');
     if ($id && $name) {
         try {
             $domain = new UserDomain($id);
             $old_name = $domain->getName();
             if (Request::get('new_domain') && isset($old_name)) {
                 throw new Exception(_('Diese ID wird bereits verwendet'));
             }
             $domain->setName($name);
             $domain->store();
         } catch (Exception $ex) {
             $this->message = MessageBox::error($ex->getMessage());
         }
     } else {
         $this->message = MessageBox::error(_('Sie haben keinen Namen und keine ID angegeben.'));
     }
     $this->domains = UserDomain::getUserDomains();
     $this->render_action('index');
 }
Esempio n. 2
0
 /**
  * This method sets the user domains for the current user.
  *
  * @access  private
  * @param   User  the user object
  */
 function setUserDomains($user)
 {
     $user_domains = $this->getUserDomains();
     $uid = $user->id;
     if (isset($user_domains)) {
         $old_domains = UserDomain::getUserDomainsForUser($uid);
         foreach ($old_domains as $domain) {
             if (!in_array($domain->getID(), $user_domains)) {
                 $domain->removeUser($uid);
             }
         }
         foreach ($user_domains as $user_domain) {
             $domain = new UserDomain($user_domain);
             $name = $domain->getName();
             if (!isset($name)) {
                 $domain->setName($user_domain);
                 $domain->store();
             }
             if (!in_array($domain, $old_domains)) {
                 $domain->addUser($uid);
             }
         }
     }
 }