diff --git a/gosa-plugins/sudo/admin/sudo/class_sudoGeneric.inc b/gosa-plugins/sudo/admin/sudo/class_sudoGeneric.inc
index 02d83b68a3080376c9ba97556fafa51cea7491e2..1f5f1413e8022fd45003023d97708766cd716ff3 100644 (file)
*/
class sudo extends plugin
{
- /* Group attributes */
- var $cn= "";
- var $description= "";
- var $sudoUser = array("ALL");
- var $sudoCommand= array();
- var $sudoHost = array("ALL");
- var $sudoRunAs = array("ALL");
+ protected $cn= "";
+ protected $description= "";
- var $accessTo = array();
- var $trustModel = "";
- var $show_ws_dialog = FALSE;
- var $was_trust_account= FALSE;
+ protected $sudoUser = array("ALL");
+ protected $sudoCommand= array();
+ protected $sudoHost = array("ALL");
+ protected $sudoRunAs = array("ALL");
+ protected $accessTo = array();
+ protected $trustModel = "";
- var $objectclasses = array("top","sudoRole");
- var $attributes = array("cn","description","sudoUser","sudoCommand","sudoHost","sudoRunAs","accessTo","trustModel");
+ private $is_default = FALSE;
+ private $show_ws_dialog = FALSE;
+ private $was_trust_account= FALSE;
- var $is_account = TRUE;
- var $is_default = FALSE;
- var $dialog;
+ public $objectclasses = array("top","sudoRole");
+ public $attributes = array("cn","description","sudoUser","sudoCommand","sudoHost","sudoRunAs","accessTo","trustModel");
+
+ public $ignore_account = TRUE;
+
+ public $orig_dn;
/*! \brief Returns to the base department for sudo roles.
This department is then used to store new roles.
}
/* Is this account a trustAccount? */
- if ($this->is_account && isset($this->attrs['trustModel'])){
+ if (isset($this->attrs['trustModel'])){
$this->trustModel= $this->attrs['trustModel'][0];
$this->was_trust_account= TRUE;
} else {
}
$this->accessTo = array();
- if ($this->is_account && isset($this->attrs['accessTo'])){
+ if (isset($this->attrs['accessTo'])){
for ($i= 0; $i<$this->attrs['accessTo']['count']; $i++){
$tmp= $this->attrs['accessTo'][$i];
$this->accessTo[$tmp]= $tmp;
}
- if(preg_match("/^default$/i",$this->cn)){
+ if(preg_match("/^defaults$/i",$this->cn)){
$this->is_default = TRUE;
}
"regex" => "*");
session::set("sysfilter", $sysfilter);
}
+
+ $this->orig_dn = $this->dn;
}
$smarty = get_smarty();
$smarty->assign("is_default",$this->is_default);
foreach($this->attributes as $attr){
- $smarty->assign($attr,$this->$attr);
+ if(is_string($this->$attr)){
+ $smarty->assign($attr,htmlentities($this->$attr));
+ }else{
+ $smarty->assign($attr,$this->$attr);
+ }
$smarty->assign($attr."ACL",$this->getacl($attr));
}
/* Fill divlists
*/
- $neg_img= "<img src='images/negate.png' alt='!' class='center'>";
- $option = "<input type='image' src='images/negate.png' name='neg_%ATTR%_%KEY%' class='center'>";
- $option.= "<input type='image' src='images/edittrash.png' name='del_%ATTR%_%KEY%' class='center'>";
+ $neg_img= "<img src='plugins/sudo/images/negate.png' alt='!' class='center'>";
+ $option = "<input type='image' src='plugins/sudo/images/negate.png' name='neg_%ATTR%_%KEY%' class='center'>";
+ $option.= "<input type='image' src='images/lists/trash.png' name='del_%ATTR%_%KEY%' class='center'>";
foreach(array("sudoCommand","sudoHost","sudoRunAs") as $attr){
if($this->acl_is_readable($attr)){
foreach($this->$attr as $key => $entry){
}
foreach(array("sudoUser") as $attr){
- $img1 = "<img src='images/select_user.png' alt='"._("User")."'>";
- $img2 = "<img src='images/select_groups.png' alt='"._("Group")."'>";
+ $img1 = "<img src='plugins/users/images/select_user.png' alt='"._("User")."' class='center'>";
+ $img2 = "<img src='plugins/groups/images/groups.png' alt='"._("Group")."' class='center'>";
if($this->acl_is_readable($attr)){
foreach($this->$attr as $key => $entry){
$neg = "";
plugin::save_object();
if($this->is_default){
- $this->cn = "default";
+ $this->cn = "defaults";
}
if(is_object($this->dialog)){
$this->attrs['sudoRunAs'] = array_values($this->attrs['sudoRunAs']);
$this->attrs['sudoUser'] = array_values($this->attrs['sudoUser']);
$this->attrs['sudoCommand'] = array_values($this->attrs['sudoCommand']);
+
$this->cleanup();
$ldap = $this->config->get_ldap_link();
$ldap->cd($this->config->current['BASE']);
+
if($this->is_new){
$ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
$ldap->cd($this->dn);
$message = plugin::check();
/* Is a name given? */
- if(empty($this->cn)){
+ if($this->cn == ""){
$message[] = msgPool::required(_("Name"));
}
/* Check if name is reserved */
- if(!$this->is_default && preg_match("/^default$/i",$this->cn)){
+ if(!$this->is_default && preg_match("/^defaults$/i",$this->cn)){
$message[] = msgPool::reserved(_("Name"));
}
/* Check name */
- if(!preg_match("/^[a-z]*$/i",$this->cn)){
- $message[] = msgPool::invalid(_("Name"),$this->cn,"/[a-z]/i");
+ if(!preg_match("/^[0-9a-z\@]*$/i",$this->cn)){
+ $message[] = msgPool::invalid(_("Name"),$this->cn,"/[0-9a-z\@]/i");
}
/* Check if this entry will cause duplicated ldap entries */
}
}
+ /* Check if we are allowed to create or move this object
+ */
+ if($this->orig_dn == "new" && !$this->acl_is_createable($this->get_sudoers_ou($this->config))){
+ $message[] = msgPool::permCreate();
+ }
+
return ($message);
}
foreach( array("depselect","regex") as $type){
$smarty->assign("$type", $sysfilter[$type]);
}
- $smarty->assign("search_image", get_template_path('images/search.png'));
- $smarty->assign("launchimage", get_template_path('images/small_filter.png'));
- $smarty->assign("tree_image", get_template_path('images/tree.png'));
+ $smarty->assign("search_image", get_template_path('images/lists/search.png'));
+ $smarty->assign("launchimage", get_template_path('images/lists/action.png'));
+ $smarty->assign("tree_image", get_template_path('images/lists/search-subtree.png'));
$smarty->assign("deplist", $this->config->idepartments);
$smarty->assign("alphabet", generate_alphabet());
$smarty->assign("hint", print_sizelimit_warning());
}
+ /*! \brief Force this entry to be handled and saved as 'default'
+ @param BOOL TRUE -force defaults FALSE -normal
+ */
public function set_default($state)
{
$this->is_default = TRUE;
- $this->cn = "default";
+ $this->cn = "defaults";
}
"trustModel" => _("Access control list"))
));
}
+
+
+ /*! \brief This function will be called if an object gets copied.
+ This function adapts attributes from the source object.
+ @param Array The source object.
+ */
+ function PrepareForCopyPaste($source)
+ {
+ plugin::PrepareForCopyPaste($source);
+ foreach(array("sudoUser","sudoCommand","sudoHost","sudoRunAs") as $attr){
+ $this->$attr = array();
+ if(isset($source[$attr])){
+ $tmp = array();
+ for($i = 0 ; $i < $source[$attr]['count']; $i++){
+ $tmp[] = $source[$attr][$i];
+ }
+ $this->$attr = $tmp;
+ }
+ }
+
+ /* Is this account a trustAccount? */
+ if (isset($source['trustModel'])){
+ $this->trustModel= $source['trustModel'][0];
+ $this->was_trust_account= TRUE;
+ } else {
+ $this->was_trust_account= FALSE;
+ $this->trustModel= "";
+ }
+
+ $this->accessTo = array();
+ if (isset($source['accessTo'])){
+ for ($i= 0; $i<$source['accessTo']['count']; $i++){
+ $tmp= $source['accessTo'][$i];
+ $this->accessTo[$tmp]= $tmp;
+ }
+ }
+ }
+
+
+ /*! \brief Used for copy & paste.
+ Returns a HTML input mask, which allows to change the cn of this entry.
+ @param Array Array containing current status && a HTML template.
+ */
+ function getCopyDialog()
+ {
+ $vars = array("cn");
+ $smarty = get_smarty();
+ $smarty->assign("cn", htmlentities($this->cn));
+ $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE));
+ $ret = array();
+ $ret['string'] = $str;
+ $ret['status'] = "";
+ return($ret);
+ }
+
+
+ public function get_cn()
+ {
+ return($this->cn);
+ }
+
+
+ /*! \brief Used for copy & paste.
+ Some entries must be renamed to avaoid duplicate entries.
+ */
+ function saveCopyDialog()
+ {
+ if(isset($_POST['cn'])){
+ $this->cn = get_post('cn');
+ }
+ }
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>