}
            $script->cleanExit();
            break;
        case 'appenable':
            $tenant = new \Innomatic\Domain\Domain(InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getDataAccess(), $argv[2], null);
            $appid = \Innomatic\Application\Application::getAppIdFromName($argv[3]);
            if ($tenant->enableApplication($appid)) {
                print "Application {$argv['3']} enabled to tenant {$argv['2']}\n";
                $script->cleanExit();
            } else {
                print "Application {$argv['3']} not enabled to tenant {$argv['2']}\n";
                $script->cleanExit(1);
            }
            break;
        case 'appdisable':
            $tenant = new \Innomatic\Domain\Domain(InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getDataAccess(), $argv[2], null);
            $appid = \Innomatic\Application\Application::getAppIdFromName($argv[3]);
            if ($tenant->disableApplication($appid)) {
                print "Application {$argv['3']} disabled from tenant {$argv['2']}\n";
                $script->cleanExit();
            } else {
                print "Application {$argv['3']} not disabled from tenant {$argv['2']}\n";
                $script->cleanExit(1);
            }
            break;
        default:
            print 'Usage: php innomatic/core/scripts/tenant.php command' . "\n";
            print 'Type tenant.php -h for a list of supported commands' . "\n";
    }
} catch (\Exception $e) {
    echo $e;
 public function executeSetmotd($eventData)
 {
     if (User::isAdminUser(\Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getCurrentUser()->getUserName(), \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getCurrentDomain()->getDomainId()) or \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getCurrentUser()->hasPermission('edit_motd')) {
         $domain = new \Innomatic\Domain\Domain(\Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getDataAccess(), \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getCurrentDomain()->getDomainId(), \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getCurrentDomain()->getDataAccess());
         $domain->setMotd($eventData['motd']);
         $this->status = $this->localeCatalog->getStr('motd_set.status');
         $this->setChanged();
         $this->notifyObservers('status');
     }
 }
function action_deactivateapplication($eventData)
{
    global $gLocale, $gLocale, $gStatus;
    $domainQuery = \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getDataAccess()->execute('SELECT domainid FROM domains WHERE id = ' . $eventData['domainid']);
    if ($domainQuery) {
        $domainData = $domainQuery->getFields();
        $domain = new \Innomatic\Domain\Domain(\Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getDataAccess(), $domainData['domainid'], $null);
        if (!$domain->disableApplication($eventData['appid'])) {
            $unmetDeps = $domain->getLastActionUnmetDeps();
            if (count($unmetDeps)) {
                while (list(, $dep) = each($unmetDeps)) {
                    $unmetDepsStr .= ' ' . $dep;
                }
                $gStatus .= $gLocale->getStr('modnotdisabled_status') . ' ';
                $gStatus .= $gLocale->getStr('disunmetdeps_status') . $unmetDepsStr . '.';
            }
        } else {
            $gStatus .= $gLocale->getStr('moddisabled_status');
        }
    }
}
 public function executeDeactivateapplication($eventData)
 {
     $domainQuery = \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getDataAccess()->execute('SELECT domainid FROM domains WHERE id = ' . $eventData['domainid']);
     if ($domainQuery) {
         $domainData = $domainQuery->getFields();
         $null = null;
         $domain = new \Innomatic\Domain\Domain(\Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getDataAccess(), $domainData['domainid'], $null);
         if (!$domain->disableApplication($eventData['appid'])) {
             $unmetDeps = $domain->getLastActionUnmetDeps();
             if (count($unmetDeps)) {
                 while (list(, $dep) = each($unmetDeps)) {
                     $unmetDepsStr .= ' ' . $dep;
                 }
                 $this->status .= $this->localeCatalog->getStr('modnotdisabled_status') . ' ';
                 $this->status .= $this->localeCatalog->getStr('disunmetdeps_status') . $unmetDepsStr . '.';
             }
         } else {
             $this->status .= $this->localeCatalog->getStr('moddisabled_status');
         }
     }
     $this->setChanged();
     $this->notifyObservers('status');
 }
    public function viewMotd($eventData)
    {
        if (!\Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getCurrentUser()->hasPermission('edit_motd')) {
            return $this->viewDefault();
        }
        $domain = new \Innomatic\Domain\Domain(\Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getDataAccess(), \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getCurrentDomain()->getDomainId(), \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getCurrentDomain()->getDataAccess());
        $xmlDef = '<vertgroup><name>motd</name>
          <children>

            <form><name>motd</name>
              <args>
                <method>post</method>
                <action type="encoded">' . urlencode(WuiEventsCall::buildEventsCallString('', array(array('view', 'motd', ''), array('action', 'setmotd', '')))) . '</action>
              </args>
              <children>

                <grid><name>motd</name>

                  <children>

                    <label row="0" col="0" halign="" valign="top"><name>label</name>
                      <args>
                        <label type="encoded">' . urlencode($this->localeCatalog->getStr('motd.label')) . '</label>
                      </args>
                    </label>

                    <text row="0" col="1"><name>motd</name>
                      <args>
                        <rows>10</rows>
                        <cols>80</cols>
                        <disp>action</disp>
                        <value type="encoded">' . urlencode($domain->getMotd()) . '</value>
                      </args>
                    </text>

                  </children>

                </grid>

              </children>
            </form>

            <horizbar><name>hb</name></horizbar>

            <button>
              <name>apply</name>
              <args>
                <horiz>true</horiz>
                <frame>false</frame>
                <themeimage>buttonok</themeimage>
                <label type="encoded">' . urlencode($this->localeCatalog->getStr('set_motd.submit')) . '</label>
                <formsubmit>motd</formsubmit>
                <action type="encoded">' . urlencode(WuiEventsCall::buildEventsCallString('', array(array('view', 'motd', ''), array('action', 'setmotd', '')))) . '</action>
              </args>
            </button>

          </children>
        </vertgroup>';
        $this->wuiMainframe->addChild(new WuiXml('page', array('definition' => $xmlDef)));
        $this->wuiTitlebar->mTitle .= ' - ' . $this->localeCatalog->getStr('motd.title');
    }
function tenant_login_login($eventData)
{
    $container = \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer');
    $username = $eventData['username'];
    // Handle the case when the root user tries to login from the tenant login form
    if (strcmp($username, 'root') === 0) {
        require_once 'innomatic/desktop/auth/DesktopRootAuthenticatorHelper.php';
        \Innomatic\Desktop\Auth\root_login_login($eventData);
        $response = \Innomatic\Webapp\WebAppContainer::instance('\\Innomatic\\Webapp\\WebAppContainer')->getProcessor()->getResponse();
        $response->sendRedirect($container->getBaseUrl(false) . '/root/');
        $response->flushBuffer();
        return;
    }
    $domainId = \Innomatic\Domain\User\User::extractDomainID($username);
    // Checks it it can find the domain by hostname
    if (!strlen($domainId)) {
        $domainId = \Innomatic\Domain\Domain::getDomainByHostname();
        if (strlen($domainId)) {
            $username .= '@' . $domainId;
        }
    }
    // If no domain is found when in Multi Tenant edition, it must be reauth without
    // checking database, since no Domain can be accessed.
    if (!strlen($domainId)) {
        DesktopDomainAuthenticatorHelper::doAuth(true);
    }
    $tmpDomain = new \Innomatic\Domain\Domain($container->getDataAccess(), $domainId, null);
    $domainDA = $tmpDomain->getDataAccess();
    $userQuery = $domainDA->execute('SELECT * FROM domain_users WHERE username='******' AND password='******'password'])));
    // Check if the user/password couple exists
    if ($userQuery->getNumberRows()) {
        // Check if the user is not disabled
        if ($userQuery->getFields('disabled') == $container->getDataAccess()->fmttrue) {
            DesktopDomainAuthenticatorHelper::doAuth(true, 'userdisabled');
        } else {
            // Login ok, set the session key
            \Innomatic\Desktop\Controller\DesktopFrontController::instance('\\Innomatic\\Desktop\\Controller\\DesktopFrontController')->session->put('INNOMATIC_AUTH_USER', $username);
            $innomaticSecurity = new \Innomatic\Security\SecurityManager();
            $innomaticSecurity->logAccess($username, false, false, $_SERVER['REMOTE_ADDR']);
            unset($innomaticSecurity);
        }
    } else {
        DesktopDomainAuthenticatorHelper::doAuth(true);
    }
    // unset( $INNOMATIC_ROOT_AUTH_USER );
}
Exemple #7
0
 public function changePassword($newpassword)
 {
     $result = false;
     if ($this->userid != 0) {
         $uquery = $this->domainDA->execute('SELECT username FROM domain_users WHERE id=' . $this->userid);
         $squery = $this->rootDA->execute('SELECT id FROM domains WHERE domainid=' . $this->rootDA->formatText($uquery->getFields('username')));
         if ($squery->getNumberRows()) {
             $empty = '';
             $tmpdomain = new \Innomatic\Domain\Domain($this->rootDA, $uquery->getFields('username'), $empty);
             $result = $tmpdomain->changePassword($newpassword);
         } else {
             if (!empty($newpassword)) {
                 $upd .= 'UPDATE domain_users SET password = '******' WHERE id=' . $this->userid;
                 //$this->htp->changePassword( $uquery->getFields( 'username' ), $newpassword );
                 $result = $this->domainDA->execute($upd);
             }
         }
     }
     return $result;
 }
function login_login($eventData)
{
    $container = \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer');
    $username = $eventData['username'];
    $domainId = \Innomatic\Domain\User\User::extractDomainID($username);
    // Checks it it can find the domain by hostname
    if (!strlen($domainId)) {
        $domainId = \Innomatic\Domain\Domain::getDomainByHostname();
        if (strlen($domainId)) {
            $username .= '@' . $domainId;
        }
    }
    // If no domain is found when in Multi Tenant edition, it must be reauth without
    // checking database, since no Domain can be accessed.
    if (!strlen($domainId)) {
        DesktopDomainAuthenticatorHelper::doAuth(true);
    }
    $tmpDomain = new \Innomatic\Domain\Domain($container->getDataAccess(), $domainId, null);
    $domainDA = $tmpDomain->getDataAccess();
    $userQuery = $domainDA->execute('SELECT * FROM domain_users WHERE username='******' AND password='******'password'])));
    // Check if the user/password couple exists
    if ($userQuery->getNumberRows()) {
        // Check if the user is not disabled
        if ($userQuery->getFields('disabled') == $container->getDataAccess()->fmttrue) {
            DesktopDomainAuthenticatorHelper::doAuth(true, 'userdisabled');
        } else {
            // Login ok, set the session key
            \Innomatic\Desktop\Controller\DesktopFrontController::instance('\\Innomatic\\Desktop\\Controller\\DesktopFrontController')->session->put('INNOMATIC_AUTH_USER', $username);
            $innomaticSecurity = new \Innomatic\Security\SecurityManager();
            $innomaticSecurity->logAccess($username, false, false, $_SERVER['REMOTE_ADDR']);
            unset($innomaticSecurity);
        }
    } else {
        DesktopDomainAuthenticatorHelper::doAuth(true);
    }
    // unset( $INNOMATIC_ROOT_AUTH_USER );
}