Skip to content
Snippets Groups Projects
Commit ef16ca3d authored by Moritz Strohm's avatar Moritz Strohm Committed by David Siegfried
Browse files

TIC #758

Merge request studip/studip!398
parent 0f92ccad
No related branches found
No related tags found
No related merge requests found
...@@ -212,6 +212,7 @@ class HelpContentController extends AuthenticatedController ...@@ -212,6 +212,7 @@ class HelpContentController extends AuthenticatedController
$help_content->content = Request::get('help_content_content'); $help_content->content = Request::get('help_content_content');
$help_content->route = Request::get('help_content_route'); $help_content->route = Request::get('help_content_route');
$help_content->comment = Request::get('help_content_comment');
$help_content->author_email = $GLOBALS['user']->Email; $help_content->author_email = $GLOBALS['user']->Email;
$help_content->installation_id = Config::get()->STUDIP_INSTALLATION_ID; $help_content->installation_id = Config::get()->STUDIP_INSTALLATION_ID;
......
...@@ -3,24 +3,20 @@ ...@@ -3,24 +3,20 @@
<form action="<?= $controller->url_for('help_content/store_settings') ?>" method="post"> <form action="<?= $controller->url_for('help_content/store_settings') ?>" method="post">
<input type="hidden" name="help_content_searchterm" value="<?= $help_content_searchterm ?>"> <input type="hidden" name="help_content_searchterm" value="<?= $help_content_searchterm ?>">
<?= CSRFProtection::tokenTag() ?> <?= CSRFProtection::tokenTag() ?>
<table class="default"> <table class="default sortable-table">
<caption> <caption>
<?= sprintf(ngettext('%u Hilfe-Text', '%u Hilfe-Texte', $count), $count) ?> <?= sprintf(ngettext('%u Hilfe-Text', '%u Hilfe-Texte', $count), $count) ?>
</caption> </caption>
<colgroup>
<col width="20">
<col width="20%">
<col width="10%">
<col>
<col width="80">
</colgroup>
<thead> <thead>
<tr> <tr>
<th><?= _("Aktiv") ?></th> <th><?= _('Aktiv') ?></th>
<th><?= _("Seite") ?></th> <th data-sort="text"><?= _('Seite') ?></th>
<th><?= _("Sprache") ?></th> <th data-sort="text"><?= _('Sprache') ?></th>
<th><?= _("Inhalt") ?></th> <th data-sort="text"><?= _('Stud.IP Version') ?></th>
<th><?= _("Aktion") ?></th> <th><?= _('Inhalt') ?></th>
<th data-sort="htmldata"><?= _('Letzte Änderung') ?></th>
<th data-sort="htmldata"><?= _('Geändert von') ?></th>
<th class="actions"><?= _('Aktionen') ?></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
...@@ -30,10 +26,30 @@ ...@@ -30,10 +26,30 @@
value="1" class="help_on" value="1" class="help_on"
<?= tooltip(_("Status der Hilfe (aktiv oder inaktiv)"), false) ?><?= $help_content->visible ? ' checked' : '' ?>> <?= tooltip(_("Status der Hilfe (aktiv oder inaktiv)"), false) ?><?= $help_content->visible ? ' checked' : '' ?>>
</td> </td>
<td><?= htmlReady($help_content->route) ?></td> <td>
<?= htmlReady($help_content->route) ?>
<? if ($help_content->comment) : ?>
<?= tooltipIcon($help_content->comment) ?>
<? endif ?>
</td>
<td><?= htmlReady($help_content->language) ?></td> <td><?= htmlReady($help_content->language) ?></td>
<td><?= htmlReady($help_content->studip_version) ?></td>
<td><?= formatReady($help_content->content) ?></td> <td><?= formatReady($help_content->content) ?></td>
<td><?= $help_content->chdate ? date('d.m.Y H:i', $help_content->chdate) : '' ?></td>
<td> <td>
<? if ($help_content->author) : ?>
<a href="<?= URLHelper::getLink('dispatch.php/profile', ['username' => $help_content->author->username]) ?>" class="link-intern" title="<?= _('Zum Profil') ?>">
<?= htmlReady($help_content->author->getFullName()) ?>
</a>
<? elseif ($help_content->author_email) : ?>
<a href="mailto:<?= htmlReady($help_content->author_email) ?>">
<?= htmlReady($help_content->author_email) ?>
</a>
<? else : ?>
<?= _('unbekannt') ?>
<? endif ?>
</td>
<td class="actions">
<a href="<?= URLHelper::getURL('dispatch.php/help_content/edit/' . $help_content_id) ?>" <?= tooltip(_('Hilfe-Text bearbeiten')) ?> <a href="<?= URLHelper::getURL('dispatch.php/help_content/edit/' . $help_content_id) ?>" <?= tooltip(_('Hilfe-Text bearbeiten')) ?>
data-dialog="size=auto;reload-on-close"> data-dialog="size=auto;reload-on-close">
<?= Icon::create('edit', 'clickable')->asImg() ?></a> <?= Icon::create('edit', 'clickable')->asImg() ?></a>
...@@ -46,7 +62,7 @@ ...@@ -46,7 +62,7 @@
</tbody> </tbody>
<tfoot> <tfoot>
<tr> <tr>
<td colspan="6"> <td colspan="8">
<?= Button::createAccept(_('Speichern'), 'save_help_content_settings') ?> <?= Button::createAccept(_('Speichern'), 'save_help_content_settings') ?>
</td> </td>
</tr> </tr>
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
<? else : ?> <? else : ?>
<legend><?= _('Neuer Hilfe-Text') ?></legend> <legend><?= _('Neuer Hilfe-Text') ?></legend>
<label for="help_content_route"> <label for="help_content_route">
<?= _('Seite:') ?> <?= _('Seite') ?>:
<input type="text" size="60" maxlength="255" name="help_content_route" <input type="text" size="60" maxlength="255" name="help_content_route"
value="" value=""
placeholder="<?= _('Bitte geben Sie eine Route für den Hilfe-Text an') ?>"> placeholder="<?= _('Bitte geben Sie eine Route für den Hilfe-Text an') ?>">
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
<? endif ?> <? endif ?>
<? if ($help_admin) : ?> <? if ($help_admin) : ?>
<label for="help_content_language"> <label for="help_content_language">
<span class="required"><?= _('Sprache des Textes:') ?></span> <span class="required"><?= _('Sprache des Textes') ?>:</span>
<select name="help_content_language"> <select name="help_content_language">
<? foreach ($GLOBALS['INSTALLED_LANGUAGES'] as $key => $language) : ?> <? foreach ($GLOBALS['INSTALLED_LANGUAGES'] as $key => $language) : ?>
<option value="<?= mb_substr($key, 0, 2) ?>"<?= ($help_content->language == mb_substr($key, 0, 2)) ? ' selected' : '' ?>> <option value="<?= mb_substr($key, 0, 2) ?>"<?= ($help_content->language == mb_substr($key, 0, 2)) ? ' selected' : '' ?>>
...@@ -30,9 +30,13 @@ ...@@ -30,9 +30,13 @@
</label> </label>
<? endif ?> <? endif ?>
<label for="help_content_content"> <label for="help_content_content">
<?= _('Hilfe-Text:') ?> <?= _('Hilfe-Text') ?>:
<textarea cols="60" rows="5" name="help_content_content" <textarea cols="60" rows="5" name="help_content_content"
placeholder="<?= _('Bitte geben Sie den Text ein') ?>"><?= $help_content->content ? htmlReady($help_content->content) : '' ?></textarea> placeholder="<?= _('Bitte geben Sie den Text ein') ?>"><?= htmlReady($help_content->content ?: '') ?></textarea>
</label>
<label for="help_content_comment">
<?= _('Bemerkung') ?>:
<textarea name="help_content_comment"><?= htmlReady($help_content->comment ?: '') ?></textarea>
</label> </label>
</fieldset> </fieldset>
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
<? endif ?> <? endif ?>
<label> <label>
<span class="required"><?= _('Name der Tour:') ?></span> <span class="required"><?= _('Name der Tour') ?>:</span>
<input type="text" size="60" maxlength="255" name="tour_name" <input type="text" size="60" maxlength="255" name="tour_name"
value="<?= $tour ? htmlReady($tour->name) : '' ?>" value="<?= $tour ? htmlReady($tour->name) : '' ?>"
required="required" aria-required="true" required="required" aria-required="true"
...@@ -30,14 +30,14 @@ ...@@ -30,14 +30,14 @@
</label> </label>
<label> <label>
<span class="required"> <?= _('Beschreibung:') ?></span> <span class="required"> <?= _('Bemerkung') ?>:</span>
<textarea cols="60" rows="5" name="tour_description" <textarea cols="60" rows="5" name="tour_description"
required="required" aria-required="true" required="required" aria-required="true"
placeholder="<?= _('Bitte geben an, welchen Inhalt die Tour hat') ?>"><?= $tour ? htmlReady($tour->description) : '' ?></textarea> placeholder="<?= _('Bitte geben an, welchen Inhalt die Tour hat') ?>"><?= $tour ? htmlReady($tour->description) : '' ?></textarea>
</label> </label>
<label> <label>
<?= _('Art der Tour:') ?> <?= _('Art der Tour') ?>:
<select name="tour_type"> <select name="tour_type">
<option value="tour" <? if ($tour->type === 'tour') echo 'selected'; ?>> <option value="tour" <? if ($tour->type === 'tour') echo 'selected'; ?>>
<?= _('Tour (passiv)') ?> <?= _('Tour (passiv)') ?>
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
</label> </label>
<label> <label>
<?= _('Zugang zur Tour:') ?> <?= _('Zugang zur Tour') ?>:
<select name="tour_access"> <select name="tour_access">
<option value="link" <? if ($tour->settings->access === 'link') echo 'selected'; ?>> <option value="link" <? if ($tour->settings->access === 'link') echo 'selected'; ?>>
<?= _('unsichtbar') ?> <?= _('unsichtbar') ?>
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
<? if (!count($tour->steps)) : ?> <? if (!count($tour->steps)) : ?>
<label> <label>
<span class="required"><?= _('Startseite der Tour:') ?></span> <span class="required"><?= _('Startseite der Tour') ?>:</span>
<input type="text" size="60" maxlength="255" name="tour_startpage" <input type="text" size="60" maxlength="255" name="tour_startpage"
value="<?= $tour_startpage ? htmlReady($tour_startpage) : '' ?>" value="<?= $tour_startpage ? htmlReady($tour_startpage) : '' ?>"
required="required" aria-required="true" required="required" aria-required="true"
...@@ -78,7 +78,7 @@ ...@@ -78,7 +78,7 @@
<? endif ?> <? endif ?>
<section> <section>
<?= _('Geltungsbereich (Nutzendenstatus):') ?> <?= _('Geltungsbereich (Nutzendenstatus)') ?>:
<? foreach (['autor', 'tutor', 'dozent', 'admin', 'root'] as $role) : ?> <? foreach (['autor', 'tutor', 'dozent', 'admin', 'root'] as $role) : ?>
<label> <label>
<input type="checkbox" name="tour_roles[]" value="<?= $role ?>" <input type="checkbox" name="tour_roles[]" value="<?= $role ?>"
...@@ -114,24 +114,19 @@ ...@@ -114,24 +114,19 @@
<? if (!$tour->isNew()) : ?> <? if (!$tour->isNew()) : ?>
<form method="post"> <form method="post">
<?= CSRFProtection::tokenTag() ?> <?= CSRFProtection::tokenTag() ?>
<table class="default"> <table class="default sortable-table">
<caption> <caption>
<div class="step_list_title"><?= _('Schritte') ?></div> <div class="step_list_title"><?= _('Schritte') ?></div>
</caption> </caption>
<colgroup>
<col width="2%">
<col width="25%">
<col>
<col width="15%">
<col width="80">
</colgroup>
<thead> <thead>
<tr> <tr>
<th><?= _('Nr.') ?></th> <th data-sort="htmldata"><?= _('Nr.') ?></th>
<th><?= _('Überschrift') ?></th> <th data-sort="text"><?= _('Überschrift') ?></th>
<th><?= _('Inhalt') ?></th> <th><?= _('Inhalt') ?></th>
<th><?= _('Seite') ?></th> <th data-sort="text"><?= _('Seite') ?></th>
<th><?= _('Aktion') ?></th> <th data-sort="htmldata"><?= _('Letzte Änderung') ?></th>
<th data-sort="htmldata"><?= _('Geändert von') ?></th>
<th class="actions"><?= _('Aktionen') ?></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
...@@ -142,6 +137,8 @@ ...@@ -142,6 +137,8 @@
<td><?= htmlReady($step->title) ?></td> <td><?= htmlReady($step->title) ?></td>
<td><?= htmlReady($step->tip) ?></td> <td><?= htmlReady($step->tip) ?></td>
<td><?= htmlReady($step->route) ?></td> <td><?= htmlReady($step->route) ?></td>
<td><?= $tour->chdate ? date('d.m.Y H:i', $tour->chdate) : '' ?></td>
<td><?= htmlReady($step->author ? $step->author->getFullName() : ($step->author_email ?: _('unbekannt'))) ?></td>
<td class="actions"> <td class="actions">
<? $actionMenu = ActionMenu::get()->setContext($step->title) ?> <? $actionMenu = ActionMenu::get()->setContext($step->title) ?>
<? $actionMenu->addLink( <? $actionMenu->addLink(
...@@ -167,7 +164,7 @@ ...@@ -167,7 +164,7 @@
<? endforeach ?> <? endforeach ?>
<? else : ?> <? else : ?>
<tr> <tr>
<td colspan="6"> <td colspan="7">
<?= _('In dieser Tour sind bisher keine Schritte vorhanden.') ?> <?= _('In dieser Tour sind bisher keine Schritte vorhanden.') ?>
</td> </td>
</tr> </tr>
......
...@@ -18,30 +18,23 @@ ...@@ -18,30 +18,23 @@
</table> </table>
<? endif ?> <? endif ?>
<table class="default"> <table class="default sortable-table">
<caption> <caption>
<div class="tour_list_title"><?= _('Touren') ?></div> <div class="tour_list_title"><?= _('Touren') ?></div>
</caption> </caption>
<colgroup>
<col width="20">
<col>
<col width="10%">
<col width="10%">
<col width="10%">
<col width="20%">
<col width="10%">
<col width="80">
</colgroup>
<thead> <thead>
<tr> <tr>
<th><?= _('Aktiv') ?></th> <th><?= _('Aktiv') ?></th>
<th><?= _('Überschrift') ?></th> <th data-sort="text"><?= _('Überschrift') ?></th>
<th><?= _('Sprache') ?></th> <th data-sort="htmldata"><?= _('Stud.IP Version') ?></th>
<th><?= _('Typ') ?></th> <th data-sort="text"><?= _('Sprache') ?></th>
<th><?= _('Zugang') ?></th> <th data-sort="text"><?= _('Typ') ?></th>
<th><?= _('Startseite') ?></th> <th data-sort="text"><?= _('Zugang') ?></th>
<th><?= _('Anzahl der Schritte') ?></th> <th data-sort="text"><?= _('Startseite') ?></th>
<th><?= _('Aktion') ?></th> <th data-sort="htmldata"><?= _('Anzahl der Schritte') ?></th>
<th data-sort="htmldata"><?= _('Letzte Änderung') ?></th>
<th data-sort="htmldata"><?= _('Geändert von') ?></th>
<th class="actions"><?= _('Aktionen') ?></th>
</tr> </tr>
</thead> </thead>
<? if (count($tours)) : ?> <? if (count($tours)) : ?>
...@@ -49,23 +42,39 @@ ...@@ -49,23 +42,39 @@
<? foreach ($tours as $tour_id => $tour) : ?> <? foreach ($tours as $tour_id => $tour) : ?>
<tr> <tr>
<td> <td>
<input type="checkbox" name="tour_status_<?= $tour_id ?>" value="1" <input type="checkbox" name="tour_status_<?= htmlReady($tour_id) ?>" value="1"
aria-label="<?= _('Status der Tour (aktiv oder inaktiv)') ?>" <?= tooltip(_("Status der Tour (aktiv oder inaktiv)"), false) ?><?= ($tour->settings->active) ? ' checked' : '' ?>> aria-label="<?= _('Status der Tour (aktiv oder inaktiv)') ?>" <?= tooltip(_("Status der Tour (aktiv oder inaktiv)"), false) ?><?= ($tour->settings->active) ? ' checked' : '' ?>>
</td> </td>
<td> <td>
<a href="<?= $controller->link_for('tour/admin_details/' . $tour_id) ?>"> <a href="<?= $controller->link_for('tour/admin_details/' . htmlReady($tour_id)) ?>">
<?= htmlReady($tour->name) ?> <?= htmlReady($tour->name) ?>
<?= tooltipIcon($tour->description) ?>
</a> </a>
</td> </td>
<td><?= $tour->language ?></td> <td><?= htmlReady($tour->studip_version) ?></td>
<td><?= $tour->type ?></td> <td><?= htmlReady($tour->language) ?></td>
<td><?= $tour->settings->access ?></td> <td><?= htmlReady($tour->type) ?></td>
<td><?= htmlReady($tour->settings->access) ?></td>
<td> <td>
<? if (count($tour->steps)): ?> <? if (count($tour->steps)): ?>
<?= htmlReady($tour->steps[0]->route) ?> <?= htmlReady($tour->steps[0]->route) ?>
<? endif; ?> <? endif; ?>
</td> </td>
<td><?= count($tour->steps) ?></td> <td><?= count($tour->steps) ?></td>
<td><?= $tour->chdate ? date('d.m.Y H:i', $tour->chdate) : '' ?></td>
<td>
<? if ($tour->author) : ?>
<a href="<?= URLHelper::getLink('dispatch.php/profile', ['username' => $tour->author->username]) ?>" class="link-intern" title="<?= _('Zum Profil') ?>">
<?= htmlReady($tour->author->getFullName()) ?>
</a>
<? elseif ($tour->author_email) : ?>
<a href="mailto:<?= htmlReady($tour->author_email) ?>">
<?= htmlReady($tour->author_email) ?>
</a>
<? else : ?>
<?= _('unbekannt') ?>
<? endif ?>
</td>
<td class="actions"> <td class="actions">
<?= ActionMenu::get()->setContext( <?= ActionMenu::get()->setContext(
$tour->name $tour->name
...@@ -89,7 +98,7 @@ ...@@ -89,7 +98,7 @@
</tbody> </tbody>
<tfoot> <tfoot>
<tr> <tr>
<td colspan="8"> <td colspan="11">
<?= Button::createAccept(_('Speichern'), 'save_tour_settings') ?> <?= Button::createAccept(_('Speichern'), 'save_tour_settings') ?>
</td> </td>
</tr> </tr>
...@@ -97,7 +106,7 @@ ...@@ -97,7 +106,7 @@
<? else : ?> <? else : ?>
<tbody> <tbody>
<tr> <tr>
<td colspan="8" style="text-align: center"> <td colspan="11" style="text-align: center">
<?= _('Keine Touren vorhanden.') ?> <?= _('Keine Touren vorhanden.') ?>
</td> </td>
</tr> </tr>
......
<?php
class AddCommentToHelpContent extends Migration
{
public function description()
{
return 'Adds the column "comment" to the help_content table.';
}
protected function up()
{
DBManager::get()->exec(
"ALTER IGNORE TABLE `help_content`
ADD COLUMN comment TEXT NULL"
);
}
protected function down()
{
DBManager::get()->exec(
"ALTER IGNORE TABLE `help_content`
DROP COLUMN comment"
);
}
}
...@@ -23,26 +23,25 @@ ...@@ -23,26 +23,25 @@
/** /**
* HelpContent.class.php - model class for Stud.IP help content * HelpContent.class.php - model class for Stud.IP help content
* *
*
*
*
* @author Arne Schröder <schroeder@data-quest> * @author Arne Schröder <schroeder@data-quest>
* @access public * @access public
* *
* @property string content_id database column * @property string $content_id database column
* @property string language database column * @property string $language database column
* @property string label database column * @property string $label database column
* @property string icon database column * @property string $icon database column
* @property string content database column * @property string $content database column
* @property string route database column * @property string $comment database column
* @property string studip_version database column * @property string $route database column
* @property string position database column * @property string $studip_version database column
* @property string custom database column * @property string $position database column
* @property string visible database column * @property string $custom database column
* @property string author_email database column * @property string $visible database column
* @property string installation_id database column * @property string $author_email database column
* @property string mkdate database column * @property string $installation_id database column
* @property string chdate database column * @property string $mkdate database column
* @property string $chdate database column
* @property User|null $author has_one author
*/ */
class HelpContent extends SimpleORMap class HelpContent extends SimpleORMap
{ {
...@@ -55,6 +54,14 @@ class HelpContent extends SimpleORMap ...@@ -55,6 +54,14 @@ class HelpContent extends SimpleORMap
{ {
$config['db_table'] = 'help_content'; $config['db_table'] = 'help_content';
$config['has_one']['author'] = [
'class_name' => User::class,
'foreign_key' => 'author_email',
'assoc_func' => 'findOneByEmail',
];
$config['registered_callbacks']['before_store'][] = 'cbUpdateStudipVersion';
parent::configure($config); parent::configure($config);
} }
...@@ -174,4 +181,9 @@ class HelpContent extends SimpleORMap ...@@ -174,4 +181,9 @@ class HelpContent extends SimpleORMap
} }
return $objects; return $objects;
} }
public function cbUpdateStudipVersion()
{
$this->studip_version = StudipVersion::getStudipVersion();
}
} }
...@@ -29,26 +29,28 @@ require_once 'lib/object.inc.php'; ...@@ -29,26 +29,28 @@ require_once 'lib/object.inc.php';
* @author Arne Schröder <schroeder@data-quest> * @author Arne Schröder <schroeder@data-quest>
* @access public * @access public
* *
* @property string tour_id database column * @property string $tour_id database column
* @property string id alias column for tour_id * @property string $id alias column for tour_id
* @property string name database column * @property string $name database column
* @property string description database column * @property string $description database column
* @property string type database column * @property string $type database column
* @property string roles database column * @property string $roles database column
* @property string version database column * @property string $version database column
* @property string language database column * @property string $language database column
* @property string studip_version database column * @property string $studip_version database column
* @property string installation_id database column * @property string $installation_id database column
* @property string mkdate database column * @property string $mkdate database column
* @property SimpleORMapCollection steps has_many HelpTourStep * @property SimpleORMapCollection $steps has_many HelpTourStep
* @property SimpleORMapCollection audiences has_many HelpTourAudience * @property SimpleORMapCollection $audiences has_many HelpTourAudience
* @property HelpTourSettings settings has_one HelpTourSettings * @property HelpTourSettings $settings has_one HelpTourSettings
* @property User|null $author has_one author
*/ */
class HelpTour extends SimpleORMap class HelpTour extends SimpleORMap
{ {
protected static function configure($config = []) protected static function configure($config = [])
{ {
$config['db_table'] = 'help_tours'; $config['db_table'] = 'help_tours';
$config['has_one']['settings'] = [ $config['has_one']['settings'] = [
'class_name' => HelpTourSettings::class, 'class_name' => HelpTourSettings::class,
'assoc_foreign_key' => 'tour_id', 'assoc_foreign_key' => 'tour_id',
...@@ -67,10 +69,24 @@ class HelpTour extends SimpleORMap ...@@ -67,10 +69,24 @@ class HelpTour extends SimpleORMap
'on_delete' => 'delete', 'on_delete' => 'delete',
'on_store' => 'store', 'on_store' => 'store',
]; ];
$config['has_one']['author'] = [
'class_name' => User::class,
'foreign_key' => 'author_email',
'assoc_func' => 'findOneByEmail',
];
$config['registered_callbacks']['before_store'][] = 'cbUpdateStudipVersion';
parent::configure($config); parent::configure($config);
} }
public function cbUpdateStudipVersion()
{
$this->studip_version = StudipVersion::getStudipVersion();
}
/** /**
* get visible tours for helpbar * get visible tours for helpbar
* *
......
...@@ -30,19 +30,20 @@ ...@@ -30,19 +30,20 @@
* @license http://www.gnu.org/licenses/gpl-2.0.html GPL version 2 * @license http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
* @category Stud.IP * @category Stud.IP
* *
* @property string tour_id database column * @property string $tour_id database column
* @property string step database column * @property string $step database column
* @property string title database column * @property string $title database column
* @property string tip database column * @property string $tip database column
* @property string orientation database column * @property string $orientation database column
* @property string interactive database column * @property string $interactive database column
* @property string css_selector database column * @property string $css_selector database column
* @property string route database column * @property string $route database column
* @property string author_email database column * @property string $author_email database column
* @property string mkdate database column * @property string $mkdate database column
* @property string chdate database column * @property string $chdate database column
* @property string id computed column read/write * @property string $id computed column read/write
* @property HelpTours help_tour belongs_to HelpTours * @property HelpTour $help_tour belongs_to HelpTour
* @property User|null $author has_one author
*/ */
class HelpTourStep extends SimpleORMap class HelpTourStep extends SimpleORMap
{ {
...@@ -55,9 +56,32 @@ class HelpTourStep extends SimpleORMap ...@@ -55,9 +56,32 @@ class HelpTourStep extends SimpleORMap
'foreign_key' => 'tour_id', 'foreign_key' => 'tour_id',
]; ];
$config['has_one']['author'] = [
'class_name' => User::class,
'foreign_key' => 'author_email',
'assoc_func' => 'findOneByEmail',
];
$config['registered_callbacks']['after_store'][] = 'cbUpdateTour';
parent::configure($config); parent::configure($config);
} }
public function cbUpdateTour()
{
if (!$this->help_tour) {
return;
}
$this->help_tour->author_email = $this->author_email;
$this->help_tour->chdate = $this->chdate;
if ($this->help_tour->isDirty()) {
$this->help_tour->store();
}
}
/** /**
* checks, if tour step data is complete * checks, if tour step data is complete
* *
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment