Commit 3db4b96f authored by arildb's avatar arildb

[NEW] Mail-in routing of incoming email to structures. Configured per user in "My Tiki" / "Mail-in"

...the option for this is still pending.
[ENH] Mail-in admin panel lists actions before the "Add New" account section.
[DOC] Make header like comments for each mail-in type
parent 9b36c259
......@@ -2095,6 +2095,7 @@ installer/schema/20130608_mailin_response_tiki.sql -text
installer/schema/20130611_mailin_add_html_tiki.sql -text
installer/schema/20130614_mailin_add_admin_tiki.sql -text
installer/schema/20130616_mailin_add_namespace_tiki.sql -text
installer/schema/20130623_create_mailin_user_struct_tiki.sql -text
installer/schema/999999991_decode_pages_sources_tiki.php -text
installer/schema/99999999_image_plugins_kill_tiki.php -text
installer/schema/index.php -text
......
......@@ -3755,3 +3755,15 @@ CREATE TABLE `tiki_workspace_templates` (
`definition` TEXT,
`is_advanced` CHAR(1) NOT NULL DEFAULT 'n'
) ENGINE=MyISAM;
DROP TABLE IF EXISTS `tiki_user_mailin_struct`;
CREATE TABLE `tiki_user_mailin_struct` (
`mailin_struct_id` int(12) NOT NULL auto_increment,
`username` varchar(200) NOT NULL,
`subj_pattern` varchar(255) NULL,
`body_pattern` varchar(255) NULL,
`structure_id` int(14) NOT NULL,
`page_id` int(14) NULL,
`is_active` char(1) NULL DEFAULT 'n',
PRIMARY KEY (`mailin_struct_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
CREATE TABLE `tiki_user_mailin_struct` (
`mailin_struct_id` int(12) NOT NULL auto_increment,
`username` varchar(200) NOT NULL,
`subj_pattern` varchar(255) NULL,
`body_pattern` varchar(255) NULL,
`structure_id` int(14) NOT NULL,
`page_id` int(14) NULL,
`is_active` char(1) NULL DEFAULT 'n',
PRIMARY KEY (`mailin_struct_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
......@@ -251,13 +251,22 @@ class StructLib extends TikiLib
\param alias An alias for the wiki page name.
\return the new entries page_ref_id or null if not created.
*/
public function s_create_page($parent_id, $after_ref_id, $name, $alias='', $structure_id=null)
public function s_create_page($parent_id, $after_ref_id, $name, $alias='', $structure_id=null, $options = array())
{
global $prefs;
$ret = null;
$hide_toc = isset($options['hide_toc']) ? $options['hide_toc'] : 'n';
$creator = isset($options['creator']) ? $options['creator'] : tra('system');
$creator_msg = isset($options['creator_msg']) ? $options['creator_msg'] : tra('created from structure');
$ip_source = isset($options['ip_source']) ? $options['ip_source'] : '0.0.0.0';
// If the page doesn't exist then create a new wiki page!
$newpagebody = tra("Table of contents") . ":" . "{toc}";
$created = $this->create_page($name, 0, $newpagebody, $this->now, tra('created from structure'), 'system', '0.0.0.0', '', false, '', array('parent_id'=>$parent_id));
$newpagebody = '';
if ($hide_toc !== 'y') {
$newpagebody = tra("Table of contents") . ":" . "{toc}";
}
$created = $this->create_page($name, 0, $newpagebody, $this->now, $creator_msg, $creator, $ip_source, '', false, '', array('parent_id'=>$parent_id));
if (!empty($parent_id) || $created || ! $this->page_is_in_structure($name)) {
// if were not trying to add a duplicate structure head
......@@ -721,6 +730,14 @@ class StructLib extends TikiLib
$cant = $this->getOne($query, array($pageName));
return $cant;
}
public function page_id_is_in_structure($pageId)
{
$query = 'select count(*) ';
$query .= 'from `tiki_structures` ts, `tiki_pages` tp ';
$query .= 'where ts.`page_id`=tp.`page_id` and `page_id`=?';
$cant = $this->getOne($query, array($pageId));
return $cant;
}
//Is this page the head page for a structure?
public function get_struct_ref_if_head($pageName)
{
......@@ -980,7 +997,7 @@ class StructLib extends TikiLib
if (!empty($join_bindvars)) {
$bindvars = empty($bindvars)? $join_bindvars : array_merge($join_bindvars, $bindvars);
}
$query = "select `page_ref_id`,`parent_id`,ts.`page_id`,`page_alias`,`pos`,
$query = "select `page_ref_id`,`structure_id`,`parent_id`,ts.`page_id`,`page_alias`,`pos`,
`pageName`,tp.`hits`,`data`,tp.`description`,`lastModif`,`comment`,`version`,
`user`,`ip`,`flag`,`points`,`votes`,`cache`,`wiki_cache`,`cache_timestamp`,
`pageRank`,`creator`,`page_size` from `tiki_structures` as ts $join_tables $mid order by ".$this->convertSortMode($sort_mode);
......@@ -1197,6 +1214,24 @@ class StructLib extends TikiLib
$this->query($query, array($structure_id, $structure_id, $pos+1, $page_ref_id));
}
}
public function move_to_structure_child($parent_ref_id, $structure_id, $first=true)
{
$query = "update `tiki_structures` set `pos`=`pos`-1 where `pos`>? and `parent_id`=?";
$this->query($query, array((int) $page_info["pos"], (int) $parent_ref_id));
if ($first) {
$query = "update `tiki_structures` set `pos`=`pos`+1 where `parent_id`=?";
$this->query($query, array($structure_id));
$pos = 1;
$query = "update `tiki_structures` set `structure_id`=?, `parent_id`=?, `pos`=? where `page_ref_id`=?";
$this->query($query, array($structure_id, $structure_id, $pos+1, $page_ref_id));
} else {
$query = "select max(`pos`) from `tiki_structures` where `parent_id`=?";
$pos = $this->getOne($query, array($structure_id));
$query = "update `tiki_structures` set `structure_id`=?, `parent_id`=?, `pos`=? where `page_ref_id`=?";
$this->query($query, array($structure_id, $structure_id, $pos+1, $page_ref_id));
}
return true;
}
/* transform a structure into a menu */
public function to_menu($channels, $structure, $sectionLevel=0, $cumul=0, $params=array())
{
......
......@@ -46,6 +46,34 @@
{section name=n loop=$tikifeedback}<div class="simplebox {if $tikifeedback[n].num > 0} highlight{/if}">{$tikifeedback[n].mes}</div>{/section}
{/if}
<br>
<a name="check" ></a><h2><a href="tiki-mailin.php#check">{tr}Check Mail-in accounts{/tr}</a></h2>
<form action="tiki-admin_mailin.php" method="post">
<table class="formcolor">
<tr>
<td>{tr}Check automatically{/tr}</td>
<td>
&nbsp;&nbsp;
{tr}Yes{/tr}
<input type="radio" name="mailin_autocheck" {if $prefs.mailin_autocheck eq 'y'}checked="checked"{/if} value="y">
&nbsp;&nbsp;
{tr}No{/tr}
<input type="radio" name="mailin_autocheck" {if $prefs.mailin_autocheck eq 'n'}checked="checked"{/if} value="n">
</td>
</tr>
<tr>
<td>{tr}Frequency{/tr}</td>
<td><input type="text" name="mailin_autocheckFreq" size="6" value="{$prefs.mailin_autocheckFreq}">&nbsp;{tr}mn{/tr}</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="submit" name="set_auto" value="{tr}Set{/tr}"></td>
</tr>
<tr>
<td>{tr}Check manually{/tr}</td>
<td><a href="tiki-mailin.php">Check Now</a></td>
</tr>
</table>
</form>
<a name="add" ></a><h2>{if $accountId eq 0}{tr}Add new Mail-in account{/tr}{else}{tr}Edit Mail-in account:{/tr} <i>{$info.account}</i>{/if}</h2>
<form action="tiki-admin_mailin.php" method="post">
......@@ -239,32 +267,3 @@
</tr>
</table>
</form>
<a name="check" ></a><h2><a href="tiki-mailin.php#check">{tr}Check Mail-in accounts{/tr}</a></h2>
<form action="tiki-admin_mailin.php" method="post">
<table class="formcolor">
<tr>
<td>{tr}Check automatically{/tr}</td>
<td>
&nbsp;&nbsp;
{tr}Yes{/tr}
<input type="radio" name="mailin_autocheck" {if $prefs.mailin_autocheck eq 'y'}checked="checked"{/if} value="y">
&nbsp;&nbsp;
{tr}No{/tr}
<input type="radio" name="mailin_autocheck" {if $prefs.mailin_autocheck eq 'n'}checked="checked"{/if} value="n">
</td>
</tr>
<tr>
<td>{tr}Frequency{/tr}</td>
<td><input type="text" name="mailin_autocheckFreq" size="6" value="{$prefs.mailin_autocheckFreq}">&nbsp;{tr}mn{/tr}</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="submit" name="set_auto" value="{tr}Set{/tr}"></td>
</tr>
<tr>
<td>{tr}Check manually{/tr}</td>
<td><a href="tiki-mailin.php">Check Now</a></td>
</tr>
</table>
</form>
......@@ -62,5 +62,10 @@
{button _icon="img/icons/large/socialnetworks.png" _text="{tr}Social networks{/tr}" href="tiki-socialnetworks.php" _menu_text="y"}
{/if}
{if $prefs.feature_mailin eq 'y' and !empty($user) and ($tiki_p_send_mailin eq 'y' or $tiki_p_admin_mailin eq 'y')}
{button _icon="img/icons/large/green_question48x48.png" _text="{tr}Mail-in{/tr}" href="tiki-user_mailin.php" _menu_text="y"}
{/if}
</div>
<br/>
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment