/** * Method delete alias of the domain. * * @param string $alias alias to delete * @return bool return TRUE on success, FALSE on failure */ function delete_domain_alias($alias) { global $data, $lang_str; $data->add_method('del_domain_alias'); $data->add_method('reload_domains'); $errors = array(); if (false === ($dom_names = $this->get_domain_names(null))) { return false; } if (count($dom_names) <= 1) { $errors[] = $lang_str['can_not_del_last_dom_name']; return false; } $opt['id'] = $this->did; $opt['name'] = $alias; if (false === domain_remove_symlinks($opt['name'], $errors)) { ErrorHandler::add_error($errors); return false; } if (false === $data->del_domain_alias($opt, $errors)) { ErrorHandler::add_error($errors); return false; } foreach ($this->dom_names as $k => $v) { if ($v['name'] == $alias) { unset($this->dom_names[$k]); break; } } /* notify SER to reload domains */ if (false === $data->reload_domains(null, $errors)) { ErrorHandler::add_error($errors); return false; } return true; }
/** * Method create or remove symlinks for all aliases of the domain * * Method create or remove symlinks in directory with domain specific config and * in directory with virtual hosts (for purpose of apache) * * @param bool $create if true, function create symlinks, otherwise remove them * @param array $errors array with error messages * @return bool return TRUE on success, FALSE on failure */ function create_or_remove_all_symlinks($create, &$errors) { global $data; if (false === $this->get_domain_names($errors)) { return false; } foreach ($this->dom_names as $v) { if ($create) { if (false === domain_create_symlinks($this->id, $v['name'], $errors)) { return false; } } else { if (false === domain_remove_symlinks($v['name'], $errors)) { return false; } } } return true; }