isModuleInstalled() public static method

Is module installed?
public static isModuleInstalled ( string $module ) : boolean
$module string
return boolean
Example #1
0
 /**
  * Validate if the module can be installed.
  */
 private function validateInstall()
 {
     // already installed
     if (BackendModel::isModuleInstalled($this->currentModule)) {
         $this->redirect(BackendModel::createURLForAction('Modules') . '&error=already-installed&var=' . $this->currentModule);
     }
     // no installer class present
     if (!is_file(BACKEND_MODULES_PATH . '/' . $this->currentModule . '/Installer/Installer.php')) {
         $this->redirect(BackendModel::createURLForAction('Modules') . '&error=no-installer-file&var=' . $this->currentModule);
     }
 }
Example #2
0
 /**
  * Load the form
  */
 protected function loadForm()
 {
     //--Create form
     $this->frm = new BackendForm("send_preview");
     //--Get the groups
     $groups = BackendMailengineModel::getAllGroupsForDropdown(true);
     if (empty($groups)) {
         \SpoonHTTP::redirect(BackendModel::createURLForAction('index', $this->module) . "&id=" . $this->id . "&error=GroupsNeededToSendMailing");
     }
     //--Loop all the users
     foreach ($groups as $key => $value) {
         $groupCheckboxes[] = array("label" => $value, "value" => $key);
     }
     //--Add multicheckboxes to form
     $this->frm->addMultiCheckbox("groups", $groupCheckboxes, null);
     $this->frm->addDate('start_date');
     $this->frm->addTime('start_time', null, 'inputText time');
     if (BackendModel::isModuleInstalled('profiles')) {
         $profiles = BackendMailengineModel::getAllProfiles();
         $profileGroups = BackendMailengineModel::getAllProfileGroupsForDropdown(true);
         $profileGroupCheckboxes = array();
         $this->tpl->assign("profilesCount", count($profiles));
         //--Loop all the users
         foreach ($profileGroups as $key => $value) {
             $profileGroupCheckboxes[] = array("label" => $value, "value" => $key);
         }
         if (!empty($profileGroups)) {
             $this->frm->addMultiCheckbox("profile_groups", $profileGroupCheckboxes, null);
         }
         $this->frm->addCheckbox("profiles_all");
     }
     //--Create review form
     $this->frm_review = new BackendForm("send_review");
     //--Add hidden field as dummy
     $this->frm_review->addHidden("profiles_all");
     $this->frm_review->addHidden("profile_groups");
     $this->frm_review->addHidden("groups");
     $this->frm_review->addDate("start_date");
     $this->frm_review->addTime("start_time");
 }
Example #3
0
 /**
  * Update the widgets
  *
  * @param \SpoonFormElement[] $widgetPresets The widgets presets.
  * @return array
  */
 private function updateWidgets($widgetPresets)
 {
     // empty dashboard sequence
     $this->dashboardSequence = array();
     // get users
     $users = BackendGroupsModel::getUsers($this->id);
     // loop through users and create objects
     foreach ($users as $user) {
         $userObjects[] = new BackendUser($user['id']);
     }
     // any users present?
     if (!empty($userObjects)) {
         // loop through user objects and get all sequences
         foreach ($userObjects as $user) {
             $userSequences[$user->getUserId()] = $user->getSetting('dashboard_sequence');
         }
     }
     // loop through all widgets
     foreach ($this->widgetInstances as $widget) {
         if (!BackendModel::isModuleInstalled($widget['module'])) {
             continue;
         }
         // create instance
         $instance = new $widget['className']($this->getKernel());
         // execute instance
         $instance->execute();
         // create module array if no existence
         if (!isset($this->dashboardSequence[$widget['module']])) {
             $this->dashboardSequence[$widget['module']] = array();
         }
         // create dashboard sequence
         $this->dashboardSequence[$widget['module']] += array($widget['widget'] => array('column' => $instance->getColumn(), 'position' => (int) $instance->getPosition(), 'hidden' => false, 'present' => false));
         // loop through selected widgets
         foreach ($widgetPresets as $preset) {
             // if selected
             if ($preset->getChecked()) {
                 // get the preset module name
                 $presetModule = str_replace('widgets_', '', str_replace($widget['widget'], '', $preset->getName()));
                 // if the preset module name matches the widget module name
                 if ($presetModule == $widget['module']) {
                     // remove widgets_[modulename] prefix
                     $selected = str_replace('widgets_' . $widget['module'], '', $preset->getName());
                     // if right widget set visible
                     if ($selected == $widget['widget']) {
                         $this->dashboardSequence[$widget['module']][$widget['widget']]['present'] = true;
                     }
                 }
             }
         }
     }
     // build group
     $userGroup['name'] = $this->frm->getField('name')->getValue();
     $userGroup['id'] = $this->id;
     // build setting
     $setting['group_id'] = $this->id;
     $setting['name'] = 'dashboard_sequence';
     $setting['value'] = serialize($this->dashboardSequence);
     // update group
     BackendGroupsModel::update($userGroup, $setting);
     // loop through all widgets
     foreach ($this->widgetInstances as $widget) {
         // loop through users
         foreach ($users as $user) {
             // unset visible if already present
             if (isset($userSequences[$user['id']][$widget['module']][$widget['widget']])) {
                 $userSequences[$user['id']][$widget['module']][$widget['widget']]['present'] = false;
             }
             // get groups for user
             $groups = BackendGroupsModel::getGroupsByUser($user['id']);
             // loop through groups
             foreach ($groups as $group) {
                 // get group sequence
                 $groupSequence = BackendGroupsModel::getSetting($group['id'], 'dashboard_sequence');
                 // loop through selected widgets
                 foreach ($widgetPresets as $preset) {
                     // if selected
                     if ($preset->getChecked()) {
                         // convert camelcasing to underscore notation
                         $selected = str_replace('widgets_', '', $preset->getName());
                         // if selected is the right widget
                         if ($selected == $widget['widget']) {
                             // set widgets visible
                             $this->dashboardSequence[$widget['module']][$widget['widget']]['present'] = true;
                             // usersequence has widget?
                             if (isset($userSequences[$user['id']][$widget['module']][$widget['widget']])) {
                                 // set visible
                                 $userSequences[$user['id']][$widget['module']][$widget['widget']]['present'] = true;
                             } else {
                                 // assign module if not yet present
                                 if (!isset($userSequences[$user['id']][$widget['module']])) {
                                     $userSequences[$user['id']][$widget['module']] = array();
                                 }
                                 // add widget
                                 $userSequences[$user['id']][$widget['module']] += array($widget['widget'] => array('column' => $instance->getColumn(), 'position' => (int) $instance->getPosition(), 'hidden' => false, 'present' => true));
                             }
                         }
                     }
                     // widget in visible in other group?
                     if ($groupSequence[$widget['module']][$widget['widget']]['present']) {
                         // set visible
                         $userSequences[$user['id']][$widget['module']][$widget['widget']]['present'] = true;
                     }
                 }
             }
         }
     }
     // any users present?
     if (!empty($userObjects)) {
         // loop through users and update sequence
         foreach ($userObjects as $user) {
             $user->setSetting('dashboard_sequence', $userSequences[$user->getUserId()]);
         }
     }
     return $userGroup;
 }
Example #4
0
 /**
  * Insert the widgets
  *
  * @param \SpoonFormElement[] $widgetPresets The widgets presets.
  */
 private function insertWidgets($widgetPresets)
 {
     // loop through all widgets
     foreach ($this->widgetInstances as $widget) {
         if (!BackendModel::isModuleInstalled($widget['module'])) {
             continue;
         }
         // create instance
         $instance = new $widget['className']($this->getKernel());
         // execute instance
         $instance->execute();
         // create module array if no existence
         if (!isset($this->dashboardSequence[$widget['module']])) {
             $this->dashboardSequence[$widget['module']] = array();
         }
         // create dashboard sequence
         $this->dashboardSequence[$widget['module']] += array($widget['widget'] => array('column' => $instance->getColumn(), 'position' => (int) $instance->getPosition(), 'hidden' => false, 'present' => false));
         // loop through selected widgets
         foreach ($widgetPresets as $preset) {
             // if selected
             if ($preset->getChecked()) {
                 // get the preset module name
                 $presetModule = str_replace('widgets_', '', str_replace($widget['widget'], '', $preset->getName()));
                 // if the preset module name matches the widget module name
                 if ($presetModule == $widget['module']) {
                     // remove widgets_[modulename] prefix
                     $selected = str_replace('widgets_' . $widget['module'], '', $preset->getName());
                     // if right widget set visible
                     if ($selected == $widget['widget']) {
                         $this->dashboardSequence[$widget['module']][$widget['widget']]['present'] = true;
                     }
                 }
             }
         }
     }
     // build group
     $group['name'] = $this->frm->getField('name')->getValue();
     // build setting
     $setting['name'] = 'dashboard_sequence';
     $setting['value'] = serialize($this->dashboardSequence);
     // insert group and settings
     $group['id'] = BackendGroupsModel::insert($group, $setting);
     return $group;
 }
Example #5
0
 /**
  * Insert the widgets
  *
  * @param \SpoonFormElement[] $widgetPresets The widgets presets.
  *
  * @return mixed
  */
 private function insertWidgets($widgetPresets)
 {
     // empty dashboard sequence
     $this->hiddenOnDashboard = array();
     // loop through all widgets
     foreach ($this->widgetInstances as $widget) {
         if (!BackendModel::isModuleInstalled($widget['module'])) {
             continue;
         }
         foreach ($widgetPresets as $preset) {
             if ($preset->getAttribute('id') !== 'widgets' . $widget['module'] . $widget['widget']) {
                 continue;
             }
             if (!$preset->getChecked()) {
                 if (!isset($this->hiddenOnDashboard[$widget['module']])) {
                     $this->hiddenOnDashboard[$widget['module']] = array();
                 }
                 $this->hiddenOnDashboard[$widget['module']][] = $widget['widget'];
             }
         }
     }
     // build group
     $userGroup['name'] = $this->frm->getField('name')->getValue();
     // build setting
     $setting['name'] = 'hidden_on_dashboard';
     $setting['value'] = serialize($this->hiddenOnDashboard);
     // insert group
     $userGroup['id'] = BackendGroupsModel::insert($userGroup, $setting);
     return $userGroup;
 }
Example #6
0
 /**
  * Parse.
  */
 protected function parse()
 {
     parent::parse();
     // assign module data
     $this->tpl->assign('name', $this->currentModule);
     $this->tpl->assign('warnings', $this->warnings);
     $this->tpl->assign('information', $this->information);
     $this->tpl->assign('showExtensionsInstallModule', !BackendModel::isModuleInstalled($this->currentModule) && BackendAuthentication::isAllowedAction('InstallModule'));
     // data grids
     $this->tpl->assign('dataGridEvents', isset($this->dataGridEvents) && $this->dataGridEvents->getNumResults() > 0 ? $this->dataGridEvents->getContent() : false);
     $this->tpl->assign('dataGridCronjobs', isset($this->dataGridCronjobs) && $this->dataGridCronjobs->getNumResults() > 0 ? $this->dataGridCronjobs->getContent() : false);
 }
Example #7
0
 /**
  * Loads the actual components on the page
  */
 public function load()
 {
     // set tracking cookie
     Model::getVisitorId();
     // create header instance
     $this->header = new Header($this->getKernel());
     // get page content from pageId of the requested URL
     $this->record = $this->getPageContent(Navigation::getPageId(implode('/', $this->URL->getPages())));
     if (empty($this->record)) {
         $this->record = Model::getPage(404);
     }
     // authentication
     if (BackendModel::isModuleInstalled('Profiles') && isset($this->record['data']['auth_required'])) {
         $data = $this->record['data'];
         // is auth required and is profile logged in
         if ($data['auth_required']) {
             if (!FrontendAuthenticationModel::isLoggedIn()) {
                 // redirect to login page
                 $queryString = $this->URL->getQueryString();
                 throw new RedirectException('Redirect', new RedirectResponse(Navigation::getURLForBlock('Profiles', 'Login') . '?queryString=' . $queryString));
             }
             // specific groups for auth?
             if (!empty($data['auth_groups'])) {
                 $inGroup = false;
                 foreach ($data['auth_groups'] as $group) {
                     if (FrontendAuthenticationModel::getProfile()->isInGroup($group)) {
                         $inGroup = true;
                     }
                 }
                 if (!$inGroup) {
                     $this->record = Model::getPage(404);
                 }
             }
         }
     }
     // we need to set the correct id
     $this->pageId = (int) $this->record['id'];
     // set headers if this is a 404 page
     if ($this->pageId == 404) {
         $this->statusCode = 404;
         if (extension_loaded('newrelic')) {
             newrelic_name_transaction('404');
         }
     }
     // create breadcrumb instance
     $this->breadcrumb = new Breadcrumb($this->getKernel());
     // new footer instance
     $this->footer = new Footer($this->getKernel());
     // process page
     $this->processPage();
     // execute all extras linked to the page
     $this->processExtras();
     // store statistics
     $this->storeStatistics();
     // trigger event
     Model::triggerEvent('Core', 'after_page_processed', array('id' => $this->getId(), 'record' => $this->getRecord(), 'statusCode' => $this->getStatusCode(), 'sessionId' => \SpoonSession::getSessionId(), 'visitorId' => Model::getVisitorId(), 'SESSION' => $_SESSION, 'COOKIE' => $_COOKIE, 'GET' => $_GET, 'POST' => $_POST, 'SERVER' => $_SERVER));
 }
Example #8
0
 /**
  * Parse
  */
 protected function parse()
 {
     parent::parse();
     // set
     $this->record['url'] = $this->meta->getURL();
     if ($this->id == 1) {
         $this->record['url'] = '';
     }
     // parse some variables
     $this->tpl->assign('item', $this->record);
     $this->tpl->assign('isGod', $this->isGod);
     $this->tpl->assign('templates', $this->templates);
     $this->tpl->assign('positions', $this->positions);
     $this->tpl->assign('extrasData', json_encode(BackendExtensionsModel::getExtrasData()));
     $this->tpl->assign('extrasById', json_encode(BackendExtensionsModel::getExtras()));
     $this->tpl->assign('prefixURL', rtrim(BackendPagesModel::getFullURL($this->record['parent_id']), '/'));
     $this->tpl->assign('formErrors', (string) $this->frm->getErrors());
     $this->tpl->assign('showTags', $this->showTags());
     // init var
     $showDelete = true;
     // has children?
     if (BackendPagesModel::getFirstChildId($this->record['id']) !== false) {
         $showDelete = false;
     }
     if (!$this->record['delete_allowed']) {
         $showDelete = false;
     }
     // allowed?
     if (!BackendAuthentication::isAllowedAction('Delete', $this->getModule())) {
         $showDelete = false;
     }
     // show delete button
     $this->tpl->assign('allowPagesDelete', $showDelete);
     // assign template
     $this->tpl->assignArray($this->templates[$this->record['template_id']], 'template');
     // parse datagrids
     $this->tpl->assign('revisions', $this->dgRevisions->getNumResults() != 0 ? $this->dgRevisions->getContent() : false);
     $this->tpl->assign('drafts', $this->dgDrafts->getNumResults() != 0 ? $this->dgDrafts->getContent() : false);
     // parse the tree
     $this->tpl->assign('tree', BackendPagesModel::getTreeHTML());
     // assign if profiles module is installed
     $this->tpl->assign('showAuthenticationTab', BackendModel::isModuleInstalled('Profiles'));
 }