Merge remote-tracking branch 'origin/master' into design_changes

This commit is contained in:
Maxime Corteel 2016-04-24 19:30:49 +02:00
Родитель d2f7bae5c6 0ebc95bd6e
Коммит 518c9efe7e
5 изменённых файлов: 44 добавлений и 20 удалений

Просмотреть файл

@ -44,6 +44,7 @@ class Application extends App {
$c->query('UserManager'), $c->query('UserManager'),
$c->query('AvatarManager'), $c->query('AvatarManager'),
$c->query('Logger'), $c->query('Logger'),
$c->query('L10N'),
$c->query('ServerContainer')->getURLGenerator(), $c->query('ServerContainer')->getURLGenerator(),
$c->query('UserId'), $c->query('UserId'),
$c->query('AccessMapper'), $c->query('AccessMapper'),
@ -69,6 +70,10 @@ class Application extends App {
return $c->query('ServerContainer')->getLogger(); return $c->query('ServerContainer')->getLogger();
}); });
$container->registerService('L10N', function($c) {
return $c->query('ServerContainer')->getL10N($c->query('AppName'));
});
$server = $container->getServer(); $server = $container->getServer();
$container->registerService('AccessMapper', function($c) use ($server) { $container->registerService('AccessMapper', function($c) use ($server) {
/** @var SimpleContainer $c */ /** @var SimpleContainer $c */

Просмотреть файл

@ -31,6 +31,7 @@ use \OCA\Polls\Db\TextMapper;
use \OCP\IUserManager; use \OCP\IUserManager;
use \OCP\IAvatarManager; use \OCP\IAvatarManager;
use \OCP\ILogger; use \OCP\ILogger;
use \OCP\IL10N;
use \OCP\IRequest; use \OCP\IRequest;
use \OCP\IURLGenerator; use \OCP\IURLGenerator;
use OCP\Security\ISecureRandom; use OCP\Security\ISecureRandom;
@ -39,8 +40,6 @@ use \OCP\AppFramework\Http\RedirectResponse;
use \OCP\AppFramework\Http\JSONResponse; use \OCP\AppFramework\Http\JSONResponse;
use \OCP\AppFramework\Controller; use \OCP\AppFramework\Controller;
$userMgr = \OC::$server->getUserManager();
class PageController extends Controller { class PageController extends Controller {
private $userId; private $userId;
@ -56,10 +55,13 @@ class PageController extends Controller {
private $manager; private $manager;
private $avatarManager; private $avatarManager;
private $logger; private $logger;
private $trans;
private $userMgr;
public function __construct($appName, IRequest $request, public function __construct($appName, IRequest $request,
IUserManager $manager, IUserManager $manager,
IAvatarManager $avatarManager, IAvatarManager $avatarManager,
ILogger $logger, ILogger $logger,
IL10N $trans,
IURLGenerator $urlGenerator, IURLGenerator $urlGenerator,
$userId, $userId,
AccessMapper $accessMapper, AccessMapper $accessMapper,
@ -74,6 +76,7 @@ class PageController extends Controller {
$this->manager = $manager; $this->manager = $manager;
$this->avatarManager = $avatarManager; $this->avatarManager = $avatarManager;
$this->logger = $logger; $this->logger = $logger;
$this->trans = $trans;
$this->urlGenerator = $urlGenerator; $this->urlGenerator = $urlGenerator;
$this->userId = $userId; $this->userId = $userId;
$this->accessMapper = $accessMapper; $this->accessMapper = $accessMapper;
@ -84,6 +87,7 @@ class PageController extends Controller {
$this->participationMapper = $ParticipationMapper; $this->participationMapper = $ParticipationMapper;
$this->participationTextMapper = $ParticipationTextMapper; $this->participationTextMapper = $ParticipationTextMapper;
$this->textMapper = $textMapper; $this->textMapper = $textMapper;
$this->userMgr = \OC::$server->getUserManager();
} }
/** /**
@ -117,15 +121,24 @@ class PageController extends Controller {
if(strlen($email) === 0 || !isset($email)) continue; if(strlen($email) === 0 || !isset($email)) continue;
$url = \OC::$server->getURLGenerator()->getAbsoluteURL(\OC::$server->getURLGenerator()->linkToRoute('polls.page.goto_poll', array('hash' => $poll->getHash()))); $url = \OC::$server->getURLGenerator()->getAbsoluteURL(\OC::$server->getURLGenerator()->linkToRoute('polls.page.goto_poll', array('hash' => $poll->getHash())));
$msg = $l->t('Hello %s,<br/><br/><strong>%s</strong> participated in the poll \'%s\'.<br/><br/>To go directly to the poll, you can use this <a href="%s">link</a>', array( $recUser = $this->userMgr->get($notif->getUserId());
$userMgr->get($notif->getUserId())->getDisplayName(), $userMgr->get($from)->getDisplayName(), $poll->getTitle(), $url)); $sendUser = $this->userMgr->get($from);
$rec = "";
if($recUser !== null) $rec = $recUser->getDisplayName();
if($sendUser !== null) {
$sender = $sendUser->getDisplayName();
} else {
$sender = $from;
}
$msg = $this->trans->t('Hello %s,<br/><br/><strong>%s</strong> participated in the poll \'%s\'.<br/><br/>To go directly to the poll, you can use this <a href="%s">link</a>', array(
$rec, $sender, $poll->getTitle(), $url));
$msg .= "<br/><br/>"; $msg .= "<br/><br/>";
$toname = $userMgr->get($notif->getUserId())->getDisplayName(); $toname = $this->userMgr->get($notif->getUserId())->getDisplayName();
$subject = $l->t('ownCloud Polls - New Comment'); $subject = $this->trans->t('ownCloud Polls - New Comment');
$fromaddress = \OCP\Util::getDefaultEmailAddress('no-reply'); $fromaddress = \OCP\Util::getDefaultEmailAddress('no-reply');
$fromname = $l->t("ownCloud Polls") . ' (' . $from . ')'; $fromname = $this->trans->t("ownCloud Polls") . ' (' . $from . ')';
try { try {
$mailer = \OC::$server->getMailer(); $mailer = \OC::$server->getMailer();
@ -133,7 +146,7 @@ class PageController extends Controller {
$message->setSubject($subject); $message->setSubject($subject);
$message->setFrom(array($fromaddress => $fromname)); $message->setFrom(array($fromaddress => $fromname));
$message->setTo(array($email => $toname)); $message->setTo(array($email => $toname));
$message->setBody($msg); $message->setHtmlBody($msg);
$mailer->send($message); $mailer->send($message);
} catch (\Exception $e) { } catch (\Exception $e) {
$message = 'error sending mail to: ' . $toname . ' (' . $email . ')'; $message = 'error sending mail to: ' . $toname . ' (' . $email . ')';
@ -286,16 +299,22 @@ class PageController extends Controller {
ISecureRandom::CHAR_LOWER. ISecureRandom::CHAR_LOWER.
ISecureRandom::CHAR_UPPER)); ISecureRandom::CHAR_UPPER));
$accessValues = json_decode($accessValues);
$groups = $accessValues->groups;
$users = $accessValues->users;
if ($accessType === 'select') { if ($accessType === 'select') {
$accessType = ''; if (isset($accessValues)) {
foreach ($groups as $gid) { $accessValues = json_decode($accessValues);
$accessType .= $gid . ';'; if($accessValues !== null) {
} $groups = array();
foreach ($users as $uid) { $users = array();
$accessType .= $uid . ';'; if($accessValues->groups !== null) $groups = $accessValues->groups;
if($accessValues->users !== null) $users = $accessValues->users;
$accessType = '';
foreach ($groups as $gid) {
$accessType .= $gid . ';';
}
foreach ($users as $uid) {
$accessType .= $uid . ';';
}
}
} }
} }
$event->setAccess($accessType); $event->setAccess($accessType);

Просмотреть файл

@ -74,6 +74,6 @@ class CommentMapper extends Mapper {
*/ */
public function deleteByPoll($pollId) { public function deleteByPoll($pollId) {
$sql = 'DELETE FROM `*PREFIX*polls_comments` WHERE poll_id=?'; $sql = 'DELETE FROM `*PREFIX*polls_comments` WHERE poll_id=?';
$this->execute($sql, [$pollId], $limit, $offset); $this->execute($sql, [$pollId]);
} }
} }

Просмотреть файл

@ -79,6 +79,6 @@ class ParticipationMapper extends Mapper {
*/ */
public function deleteByPoll($pollId) { public function deleteByPoll($pollId) {
$sql = 'DELETE FROM `*PREFIX*polls_particip` WHERE poll_id=?'; $sql = 'DELETE FROM `*PREFIX*polls_particip` WHERE poll_id=?';
$this->execute($sql, [$pollId], $limit, $offset); $this->execute($sql, [$pollId]);
} }
} }

Просмотреть файл

@ -79,6 +79,6 @@ class ParticipationTextMapper extends Mapper {
*/ */
public function deleteByPoll($pollId) { public function deleteByPoll($pollId) {
$sql = 'DELETE FROM `*PREFIX*polls_particip_text` WHERE poll_id=?'; $sql = 'DELETE FROM `*PREFIX*polls_particip_text` WHERE poll_id=?';
$this->execute($sql, [$pollId], $limit, $offset); $this->execute($sql, [$pollId]);
} }
} }