| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | /* |
|---|
| 4 | * Proof of concept of what a new feature look like with the new mail interface |
|---|
| 5 | * |
|---|
| 6 | **/ |
|---|
| 7 | |
|---|
| 8 | Class m_mail_jabber{ |
|---|
| 9 | var $advanced; |
|---|
| 10 | var $enabled; |
|---|
| 11 | |
|---|
| 12 | function m_mail_jabber(){ |
|---|
| 13 | // Get configuration var |
|---|
| 14 | $this->enabled=variable_get('mail_jabber_enabled',null); |
|---|
| 15 | $this->advanced=variable_get('mail_jabber_advanced',null); |
|---|
| 16 | |
|---|
| 17 | // Setup the vars if there aren't any |
|---|
| 18 | if (is_null($this->enabled)) { |
|---|
| 19 | variable_set('mail_jabber_enabled',true,'To enable or disable the Jabber module in the mail edit page'); |
|---|
| 20 | $this->enabled=true; |
|---|
| 21 | } |
|---|
| 22 | |
|---|
| 23 | if (is_null($this->advanced)) { |
|---|
| 24 | variable_set('mail_jabber_advanced',true,'To choose the category of Jabber in the mail edit page'); |
|---|
| 25 | $this->advanced=true; |
|---|
| 26 | } |
|---|
| 27 | |
|---|
| 28 | } |
|---|
| 29 | |
|---|
| 30 | /** |
|---|
| 31 | * Hooks called by the mail class, it's |
|---|
| 32 | * used to verify that a given mail is |
|---|
| 33 | * allowed to be created by all the class friends of mail |
|---|
| 34 | * |
|---|
| 35 | * @param dom_id integer domain id of the target mail |
|---|
| 36 | * @param mail_arg string left part of '@' of the target mail |
|---|
| 37 | * @return array a hashtable contening the statei (boolean) and an error message |
|---|
| 38 | * |
|---|
| 39 | */ |
|---|
| 40 | function hooks_mail_cancreate($dom_id, $mail_arg){ |
|---|
| 41 | global $db, $err, $cuid; |
|---|
| 42 | $err->log("m_mail_jabber","hooks_mail_cancreate"); |
|---|
| 43 | $return = array ( |
|---|
| 44 | "state" => true, // Do we allow this creation ? |
|---|
| 45 | "error" => ""); // Error message (txt) |
|---|
| 46 | |
|---|
| 47 | // Return our informations |
|---|
| 48 | return $return; |
|---|
| 49 | } |
|---|
| 50 | |
|---|
| 51 | /** |
|---|
| 52 | * Hooks called to list a given mail properties |
|---|
| 53 | * @param mail_id the id of the mail being processed |
|---|
| 54 | * @return false, or an hashtable of the usefull information |
|---|
| 55 | * |
|---|
| 56 | **/ |
|---|
| 57 | function hooks_mail_properties_list($mail_id){ |
|---|
| 58 | global $db, $err; |
|---|
| 59 | $err->log("mail_jabber","mail_properties_list"); |
|---|
| 60 | |
|---|
| 61 | // Return if this feature isn't enabled |
|---|
| 62 | if (!$this->enabled) return false; |
|---|
| 63 | |
|---|
| 64 | // Setup the object |
|---|
| 65 | $return = array ( |
|---|
| 66 | "label" => "jabberdemo", // an internal label |
|---|
| 67 | "short_desc" => _("Jabber Demo"), // A human short description |
|---|
| 68 | "class" => "mail_jabber", |
|---|
| 69 | "human_desc" => _("This is just a demo.<br/>Look at m_mail_jabber.php"), // A human long description |
|---|
| 70 | "form_param" => Array($mail_id), |
|---|
| 71 | "url" => "javascript:alert('Ici un renvoie vers le formulaire adequat de cette entrée.');", // The URL to go |
|---|
| 72 | "pass_required" => true, // This feature require the mail to have a global password ? |
|---|
| 73 | "advanced" => $this->advanced, // Is this an advanced feature ? |
|---|
| 74 | ); |
|---|
| 75 | |
|---|
| 76 | /* We can return many array merged to have many |
|---|
| 77 | * entry (with different informations, for example |
|---|
| 78 | * different description or target URL), to list many |
|---|
| 79 | * action directly in the page |
|---|
| 80 | **/ |
|---|
| 81 | // To view an example, uncomment next line |
|---|
| 82 | // $return=Array($return,$return,$return); |
|---|
| 83 | return $return; |
|---|
| 84 | } |
|---|
| 85 | |
|---|
| 86 | } |
|---|
| 87 | |
|---|
| 88 | ?> |
|---|