コード例 #1
0
 /**
  * On an module remove hook call this listener
  *
  * Listens for the 'user.account.create' event.
  *
  * @param Zikula_Event $event Event.
  */
 public static function onCreateUser(Zikula_Event $event)
 {
     if (!ModUtil::getVar('Dashboard', 'widgetsnewuser', false)) {
         return;
     }
     $user = $event->getSubject();
     $helper = new Dashboard_Helper_WidgetHelper(ServiceUtil::getService('doctrine.entitymanager'));
     $widgets = $helper->getRegisteredWidgets($user['uid']);
     foreach ($widgets as $widget) {
         Dashboard_Util::addUserWidget($user['uid'], $widget);
     }
 }
コード例 #2
0
ファイル: User.php プロジェクト: robbrandt/Dashboard
 public function addWidget()
 {
     $this->checkCsrfToken();
     if (!SecurityUtil::checkPermission('Dashboard::', '::', ACCESS_READ)) {
         return LogUtil::registerPermissionError();
     }
     $widgetId = $this->request->request->get('id', null);
     if (null === $widgetId) {
         throw new Exception($this->__(sprintf('%s not found', $widgetId)));
     }
     $widget = $this->entityManager->getRepository('Dashboard_Entity_Widget')->findOneBy(array('id' => $widgetId));
     if (!$widget) {
         throw new Exception(sprintf('Widget id %s not found', $widgetId));
     }
     $class = $widget->getClass();
     /* @var Dashboard_AbstractWidget $widget */
     $widget = new $class();
     if (false === ModUtil::available($widget->getModule())) {
         throw new Exception($this->__(sprintf('%s not available (disabled or not installed', $widget->getModule())));
     }
     $uid = $this->request->getSession()->get('uid');
     Dashboard_Util::addUserWidget($uid, $widget);
     return $this->redirect(ModUtil::url('Dashboard', 'user', 'view'));
 }