index 516f0b476ffd81be76e4addaf5f5a19967d34cb2..8c2f6ab1be227073383dace92741e4ce3f6672ea 100644 (file)
public $plHeadline = "unconfigured";
// The currently used object(s) (e.g. in edit, removal)
- protected $dn = "";
+ public $dn = ""; // this is public due to some compatibility problems with class plugin..
protected $dns = array();
// The last used object(s).
// The tab definitions to use for the current object.
protected $tabClass = ""; // e.g. usertabs
protected $tabType = ""; // e.g. USERTABS
+ protected $aclPlugin = ""; // e.g. generic
protected $aclCategory = ""; // e.g. users
protected $objectName = ""; // e.g. users
protected $last_dialogObject = null;
// Whether to display the apply button or not
- protected $displayApplyBtn = "";
+ protected $displayApplyBtn = FALSE;
+
+ // Whether to display a header or not.
+ protected $skipHeader = false;
// Whether to display a footer or not.
protected $skipFooter = false;
// A list of configured actions/events
protected $actions = array();
+ // Attributes managed by this plugin, can be used in post events;
+ public $attributes = array();
+
function __construct(&$config,$ui,$plugname, $headpage)
{
$this->plugname = $plugname;
// Display tab object.
if($this->tabObject instanceOf tabs || $this->tabObject instanceOf multi_plug){
- $this->tabObject->save_object();
+# $this->tabObject->save_object();
$display = $this->tabObject->execute();
$display.= $this->_getTabFooter();
return($this->getHeader().$display);
*/
protected function getHeader()
{
+ if($this->skipHeader) return("");
+
if (get_object_info() != ""){
$display= print_header(get_template_path($this->plIcon),_($this->plDescription),
"<img alt=\"\" class=\"center\" src=\"".get_template_path('images/lists/locked.png')."\">".
* @param Array 'all' A combination of both 'action' and 'target'.
*/
function saveSnapshot($action="",$target=array(),$all=array())
- {
+ {
+ if(!is_object($this->dialogObject)) return;
$this->dialogObject->save_object();
$msgs = $this->dialogObject->check();
if(count($msgs)){
if(empty($tabClass) || empty($tabType)){
// No tab type defined
}else{
- $this->tabObject= new $tabClass($this->config,$this->config->data['TABS'][$tabType], $this->dn, $aclCategory);
- $this->tabObject->set_acl_base($this->headpage->getBase());
- $this->tabObject->parent = &$this;
- @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,$this->dn,"Create new entry initiated!");
+ if (isset($this->config->data['TABS'][$tabType])) {
+ $this->tabObject= new $tabClass($this->config,$this->config->data['TABS'][$tabType], $this->dn, $aclCategory);
+ $this->tabObject->set_acl_base($this->headpage->getBase());
+ $this->tabObject->parent = &$this;
+ @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,$this->dn,"Create new entry initiated!");
+ } else {
+ msg_dialog::display(_("Error"), sprintf(_("No tab declaration for '%s' found in your configuration file. Cannot create plugin instance!"), $tabType), ERROR_DIALOG);
+ }
}
}
if(!empty($altTabType)) $tabType = $altTabType;
if(!empty($altAclCategory)) $aclCategory = $altAclCategory;
+ $this->displayApplyBtn = count($target) == 1;
+
// Single edit - we only got one object dn.
if(count($target) == 1){
- $this->displayApplyBtn = TRUE;
$this->is_new = FALSE;
$this->is_single_edit = TRUE;
$this->is_multiple_edit = FALSE;
$this->dns = array();
$this->tabObject = null;
$this->dialogObject = null;
+ $this->skipFooter = FALSE;
set_object_info();
}
$this->filter = $str;
}
-
function postcreate() {
- $this->_handlePostEvent('POSTCREATE');
+ $this->handle_post_events('add');
}
function postmodify(){
- $this->_handlePostEvent('POSTMODIFY');
+ $this->handle_post_events('modify');
}
function postremove(){
- $this->_handlePostEvent('POSTREMOVE');
+ $this->handle_post_events('remove');
}
- function _handlePostEvent($type)
+ function is_modal_dialog()
{
+ return(is_object($this->tabObject) || is_object($this->dialogObject));
+ }
- /* Find postcreate entries for this class */
- $command= $this->config->search(get_class($this), $type,array('menu', 'tabs'));
- if ($command != ""){
-
- /* Walk through attribute list */
- foreach ($this->attributes as $attr){
- if (!is_array($this->$attr)){
- $add_attrs[$attr] = $this->$attr;
- }
- }
- $add_attrs['dn']=$this->dn;
-
- $tmp = array();
- foreach($add_attrs as $name => $value){
- $tmp[$name] = strlen($name);
- }
- arsort($tmp);
-
- /* Additional attributes */
- foreach ($tmp as $name => $len){
- $value = $add_attrs[$name];
- $command= str_replace("%$name", "$value", $command);
+ /*! \brief Forward command execution request
+ * to the correct method.
+ */
+ function handle_post_events($mode, $addAttrs= array())
+ {
+ if(!in_array_strict($mode, array('add','remove','modify'))){
+ trigger_error(sprintf("Invalid post event type given %s! Valid types are [add,modify,remove].", $mode));
+ return;
}
-
- if (check_command($command)){
- @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__,
- $command, "Execute");
- exec($command,$arr);
- foreach($arr as $str){
- @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__,
- $command, "Result: ".$str);
- }
- } else {
- $message= msgPool::cmdnotfound($type, get_class($this));
- msg_dialog::display(_("Error"), $message, ERROR_DIALOG);
+ switch ($mode){
+ case "add":
+ plugin::callHook($this,"POSTCREATE", $addAttrs);
+ break;
+
+ case "modify":
+ plugin::callHook($this,"POSTMODIFY", $addAttrs);
+ break;
+
+ case "remove":
+ plugin::callHook($this,"POSTREMOVE", $addAttrs);
+ break;
}
- }
-
}
}