Skip to content
Snippets Groups Projects
Commit bffffe72 authored by Rasmus Fuhse's avatar Rasmus Fuhse
Browse files

re #78

parent ea6f2b73
Branches
No related tags found
No related merge requests found
...@@ -7,4 +7,19 @@ $(document).ready(function () { ...@@ -7,4 +7,19 @@ $(document).ready(function () {
$('input#used_at').val($.trim(e.target.text)); $('input#used_at').val($.trim(e.target.text));
}); });
}); });
}); });
\ No newline at end of file
STUDIP.PluginMarket = {
addCollaborator: function (user_id, name) {
jQuery.ajax({
url: STUDIP.ABSOLUTE_URI_STUDIP + "plugins.php/pluginmarket/myplugins/add_user",
data: {
"user_id": user_id
},
success: function (html) {
jQuery(html).hide().appendTo("#plugincollaborators").fadeIn();
}
});
return false;
}
};
\ No newline at end of file
...@@ -194,3 +194,10 @@ article.contentbox { ...@@ -194,3 +194,10 @@ article.contentbox {
transform: scale(1,1) rotate(0deg); transform: scale(1,1) rotate(0deg);
} }
} }
#plugincollaborators {
input[type=checkbox]:checked + span {
opacity: 0.5;
text-decoration: line-through;
}
}
\ No newline at end of file
...@@ -66,7 +66,9 @@ class MarketPlugin extends SimpleORMap { ...@@ -66,7 +66,9 @@ class MarketPlugin extends SimpleORMap {
public function isWritable($user_id = null) { public function isWritable($user_id = null) {
$user_id || $user_id = $GLOBALS['user']->id; $user_id || $user_id = $GLOBALS['user']->id;
return ($this['user_id'] === $user_id) || $this->isRootable($user_id); return ($this['user_id'] === $user_id)
|| $this->isRootable($user_id)
|| in_array($user_id, $this->more_users->pluck("user_id"));
} }
public function isRootable($user_id = null) { public function isRootable($user_id = null) {
...@@ -166,5 +168,4 @@ class MarketPlugin extends SimpleORMap { ...@@ -166,5 +168,4 @@ class MarketPlugin extends SimpleORMap {
return $rating; return $rating;
} }
} }
\ No newline at end of file
...@@ -13,7 +13,11 @@ class MypluginsController extends MarketController ...@@ -13,7 +13,11 @@ class MypluginsController extends MarketController
public function overview_action() public function overview_action()
{ {
$this->plugins = MarketPlugin::findBySQL("user_id = ? ORDER BY mkdate DESC", array($GLOBALS['user']->id)); $this->plugins = MarketPlugin::findBySQL("LEFT JOIN pluginmarket_user_plugins USING (plugin_id)
WHERE pluginmarket_plugins.user_id = :user_id
OR pluginmarket_user_plugins.user_id = :user_id
ORDER BY mkdate DESC", array('user_id' => $GLOBALS['user']->id)
);
} }
public function addfromzip_action() public function addfromzip_action()
...@@ -166,6 +170,51 @@ class MypluginsController extends MarketController ...@@ -166,6 +170,51 @@ class MypluginsController extends MarketController
} }
} }
foreach (Request::getArray("collaborator") as $user_id) {
if ($this->marketplugin['user_id'] !== $user_id) {
$statement = DBManager::get()->prepare("
INSERT IGNORE INTO pluginmarket_user_plugins
SET user_id = :user_id,
plugin_id = :plugin_id
");
$statement->execute(array(
'user_id' => $user_id,
'plugin_id' => $this->marketplugin->getId()
));
}
}
$this->marketplugin->store();
foreach (Request::getArray("drop_collaborator") as $user_id) {
if ($this->marketplugin['user_id'] === $user_id) {
if (count($this->marketplugin->more_users)) {
$new_boss = $this->marketplugin->more_users[0];
$this->marketplugin['user_id'] = $new_boss->getId();
$this->marketplugin->store();
$statement = DBManager::get()->prepare("
DELETE FROM pluginmarket_user_plugins
WHERE user_id = :user_id
AND plugin_id = :plugin_id
");
$statement->execute(array(
'user_id' => $new_boss->getId(),
'plugin_id' => $this->marketplugin->getId()
));
}
} else {
$statement = DBManager::get()->prepare("
DELETE FROM pluginmarket_user_plugins
WHERE user_id = :user_id
AND plugin_id = :plugin_id
");
$statement->execute(array(
'user_id' => $user_id,
'plugin_id' => $this->marketplugin->getId()
));
}
}
PageLayout::postMessage(MessageBox::success(_("Plugin wurde gespeichert."))); PageLayout::postMessage(MessageBox::success(_("Plugin wurde gespeichert.")));
$this->redirect('presenting/details/' . $this->marketplugin->getId()); $this->redirect('presenting/details/' . $this->marketplugin->getId());
} }
...@@ -209,5 +258,11 @@ class MypluginsController extends MarketController ...@@ -209,5 +258,11 @@ class MypluginsController extends MarketController
} }
} }
public function add_user_action()
{
$this->user = User::find(Request::option("user_id"));
$this->render_template("myplugins/_collaborator.php");
}
} }
\ No newline at end of file
<li>
<input type="checkbox"
id="drop_collaborator_<?= htmlReady($user->getId()) ?>"
name="drop_collaborator[]"
value="<?= htmlReady($user->getId()) ?>"
style="display: none;">
<span>
<?= Avatar::getAvatar($user->getId())->getImageTag(Avatar::SMALL) ?>
<?= htmlReady($user->getFullName()) ?>
</span>
<input type="hidden" name="collaborator[]" value="<?= htmlReady($user->getId()) ?>">
<label for="drop_collaborator_<?= htmlReady($user->getId()) ?>" style="cursor: pointer; display: inline;">
<?= Icon::create("trash", "clickable")->asImg(20, array('class' => "text-bottom")) ?>
</label>
</li>
\ No newline at end of file
...@@ -46,6 +46,17 @@ ...@@ -46,6 +46,17 @@
<input type="text" name="tags" value="<?= htmlReady(ucwords(implode(", ", $marketplugin->getTags()))) ?>"> <input type="text" name="tags" value="<?= htmlReady(ucwords(implode(", ", $marketplugin->getTags()))) ?>">
</label> </label>
<div style="margin-bottom: 10px; margin-top: 10px;">
<?= _("Mitarbeiter") ?>
<ul class="clean" style="margin-bottom: 5px;" id="plugincollaborators">
<?= $this->render_partial("myplugins/_collaborator.php", array('user' => $marketplugin->user)) ?>
<? foreach ($marketplugin->more_users as $user) : ?>
<?= $this->render_partial("myplugins/_collaborator.php", array('user' => $user)) ?>
<? endforeach ?>
</ul>
<?= QuickSearch::get("user_id", new StandardSearch("user_id"))->fireJSFunctionOnSelect("STUDIP.PluginMarket.addCollaborator")->render() ?>
</div>
<div> <div>
<?= _("Lizenz") ?> <?= _("Lizenz") ?>
<input type="hidden" name="data[license]" value="GPL 2 or later"> <input type="hidden" name="data[license]" value="GPL 2 or later">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment