Пример #1
0
    /**
     * Тест установки sitemap-индекса к конфигу  
     */
    public function testSelectControlNames()
    {
        SystemRegisterSample::clearCache();
        $fileList = \DAO_FileSystem::getInstance()->getFileList(LIB_PATH . 'custom_config/controls/');
        $list = CConfigControlManager::selectAll();
        $this->assertEquals(sizeof($fileList), sizeof($list));
        // Добавляем в реестр файлег, но не пишем класс
        $path = LIB_PATH . 'custom_config/test.php';
        $register = new SystemRegister('Applications/cconfig/user_control_path');
        $register->insert('test', $path, '');
        file_put_contents($path, '');
        $list = CConfigControlManager::selectAll();
        $this->assertEquals(sizeof($fileList), sizeof($list));
        // Заполняем инфо о классе, таким образом класс становится доступным
        $path = 'custom_config/test2.php';
        $contents = <<<EOD
<?
class CConfigControl_Test2 extends CConfigBaseControl {
\tpublic function getXType() {
\t\treturn "test2";
\t}
}
?>
EOD;
        file_put_contents(LIB_PATH . $path, $contents);
        $register->insert('test2', $path, '');
        $list = CConfigControlManager::selectAll();
        $this->assertEquals(sizeof($fileList) + 1, sizeof($list));
    }
Пример #2
0
 protected function configureLoginAttempts($perSession, $perHosts)
 {
     $register = new \SystemRegister(UsersLogin::SystemRegisterPath);
     $register->PerSession->value = \IntegerHelper::toNatural($perSession);
     $register->PerHost->value = \IntegerHelper::toNatural($perHosts);
     \SystemRegisterSample::createCache();
 }
Пример #3
0
 /**
  * Очищаем системный реестр
  */
 protected function clearSystemRegister()
 {
     SystemRegisterSample::clearCache();
     $register = new SystemRegister('Applications/cconfig');
     $register->delete('user_control_path');
     SystemRegisterSample::clearCache();
     $register->insert('user_control_path', null, '', SYSTEMREGISTER_BRANCH_TYPE);
 }
Пример #4
0
 public function testCheckChildCache()
 {
     SystemRegisterSample::loadAll();
     // Проверяем что кеш создался
     $this->assertEquals(sizeof(SystemRegisterSample::$aChildCache), 3);
     // Получаем значение
     $data = new SystemRegister('AppData/test1');
     $this->assertEquals($data->value1->value, 'This is a simple value');
 }
Пример #5
0
 protected function action()
 {
     $schema = CConfig::getSchema(Record::CriticalEmailSchemaName);
     $result = $schema->getControlByName('to');
     $result->setValue($this->getParam('notification_emails'));
     $register = new \SystemRegister(self::RegisterPath);
     $register->maximumLogLength = $this->getParam('maximumLogLength');
     \SystemRegisterSample::createCache();
     \CMSLog::addMessage(self::LogName, sprintf('Audit settings updated. New log length - "%s", Notification emails account - "%s"', $this->getParam('notification_emails'), $this->getParam('maximumLogLength')));
     return true;
 }
Пример #6
0
 public static function restore()
 {
     $data = array('Audit' => array('notification_emails' => '', 'maximumLogLength' => 65536), 'Security' => array('salt' => '123', 'LoginAttempts' => array('PerSession' => 5, 'PerHost' => 10), 'DDosDetector' => ['MaxConnections' => 1000, 'Message' => '', 'Period' => '1 minute']), 'Schedule' => array('runningFlag' => '0'), 'Sitemap' => array('visible' => 'false'), 'email' => array('use_standart_mail_function' => 0, 'enable_ssl' => 0, 'smtp_server' => 0, 'smtp_port' => '', 'smtp_user' => '', 'smtp_password' => '', 'from_email' => '', 'from_name' => ''), 'Front-end' => array('enable_debug' => true, 'pack' => 0, 'technical_message' => '', 'need_cms_auth' => false));
     self::restorePath('/System/', $data);
     $applicationImport = array('users' => array('captcha_provider' => 'none', 'registration_need_email' => 1, 'front-end' => ['account_confirmation' => 1, 'account_registration_success_email' => 0]));
     self::restorePath('/Applications/', $applicationImport);
     self::restoreImageColumnConfig();
     $usersConfig = array('table' => \UserAccount::TableName, 'fields' => array('id' => '\\Extasy\\Columns\\Index', 'login' => '\\Extasy\\Users\\Columns\\Login', 'email' => '\\Extasy\\Users\\Columns\\Email', 'new_email' => '\\Extasy\\Columns\\Input', 'name' => '\\Extasy\\Columns\\Input', 'avatar' => array('class' => '\\Extasy\\Columns\\Image', 'base_dir' => 'users/', 'images' => ''), 'password' => '\\Extasy\\Columns\\Password', 'rights' => '\\GrantColumn', 'last_activity_date' => '\\Extasy\\Columns\\Datetime', 'confirmation_code' => '\\Extasy\\Users\\Columns\\ConfirmationCode', 'email_confirmation_code' => '\\Extasy\\Columns\\Input', 'time_access' => '\\Extasy\\Users\\Columns\\TimeAccess', 'social_networks' => '\\Extasy\\Users\\Columns\\SocialNetworks'));
     Configure::write(\UserAccount::ModelConfigureKey, $usersConfig);
     $data = array('cconfig' => array('user_control_path' => array()));
     self::restorePath('/Applications/', $data);
     \SystemRegisterSample::createCache();
 }
Пример #7
0
 public function testStatuses()
 {
     $register = new \SystemRegister('System/Schedule');
     $register->runningFlag->value = 1;
     \SystemRegisterSample::createCache();
     //
     $api = new ServerStatus();
     $this->assertEquals(1, $api->exec());
     //
     $register = new \SystemRegister('System/Schedule');
     $register->runningFlag->value = 0;
     \SystemRegisterSample::createCache();
     $api = new ServerStatus();
     $this->assertEquals(0, $api->exec());
 }
Пример #8
0
 public function tearDown()
 {
     SystemRegisterSample::clearCache();
     \Extasy\tests\system_register\Restorator::restore();
 }
Пример #9
0
 /**
  * Возвращает имена классов всех контролов, с которыми в данный момент работает CConfig
  * @return array
  */
 public static function selectAll()
 {
     // Грузим все файлы в папке контролов
     $files = DAO::getInstance('fs')->getFileList(CCONFIG_CONTROLS_PATH);
     $result = array();
     foreach ($files as $row) {
         try {
             $row = basename($row, '.php');
             $result[$row] = self::loadControl($row);
         } catch (Exception $e) {
         }
     }
     // Дополняем классами, записанными в реестре
     $register = new SystemRegister('Applications/cconfig/user_control_path');
     $paths = SystemRegisterSample::selectChild($register->getId());
     foreach ($paths as $row) {
         try {
             $result[$row['name']] = self::loadControl($row['name']);
         } catch (Exception $e) {
         }
     }
     return $result;
 }
Пример #10
0
 /**
  * Обновляет имя и комментарий текущего нода
  */
 public function setupAttr($name, $comment)
 {
     SystemRegisterSample::update($this->parent, $this->nId, $name, '', $comment, SYSTEMREGISTER_BRANCH_TYPE);
     return $this;
 }
Пример #11
0
 public static function setupRootDocuments(array $documentList)
 {
     $register = new SystemRegister(self::RootDocumentsKey);
     SystemRegisterHelper::import($register, $documentList);
     SystemRegisterSample::createCache();
 }
Пример #12
0
use Faid\DBSimple;
use Extasy\tests\Helper as TestsHelper;
use UserAccount;
use ACL;
use Extasy\Audit\Api\ApiOperation;
use Extasy\Audit\Record;
use Extasy\Audit\Log;
use Extasy\tests\system_register\Restorator;
use Extasy\Columns\Password as passwordColumn;
$register = new \SystemRegister('/System/');
try {
    $register->delete('Audit');
} catch (\Exception $e) {
}
Restorator::restore();
\SystemRegisterSample::createCache();
TestsHelper::dbFixture(ACL_TABLE, array());
ACL::create(ApiOperation::RightName);
// user record
TestsHelper::dbFixture(USERS_TABLE, array(array('login' => 'login', 'password' => passwordColumn::hash('testtest')), array('login' => 'guest', 'password' => passwordColumn::hash('testtest'))));
// grant user permission
$user = UserAccount::getByLogin('login');
ACL::grant(ApiOperation::RightName, $user->obj_rights->getEntity());
\UsersLogin::login('login', 'testtest');
// base logs
TestsHelper::dbFixture(Log::getTableName(), array(array('name' => 'Log1', 'critical' => 0, 'enable_logging' => 1), array('name' => 'Log2', 'critical' => 1, 'enable_logging' => 1)));
// base records
// - [different by user_id]
// - [different by date]
// - [different by content]
TestsHelper::dbFixture(Record::getTableName(), array(array('log_id' => 1, 'date' => '2001-01-01 00:00:00', 'short' => 'short log', 'full' => 'full_log', 'user_id' => 1, 'user_login' => 'login'), array('log_id' => 2, 'date' => '2001-01-02 00:00:00', 'short' => 'short log', 'full' => 'full_log', 'user_id' => 1, 'user_login' => 'login'), array('log_id' => 1, 'date' => '2001-01-03 00:00:00', 'short' => 'short log', 'full' => 'full_log')));
Пример #13
0
 public function testImportUpdatingFileCacheWithDeletion()
 {
     $system = new SystemRegister('/System/');
     $this->assertEquals(false, isset($system->array));
     SystemRegisterHelper::import($system, array('XX' => '1', 'yy' => '2', 'Gisma' => 'rulit!', 'array' => array('0' => 'value1', '1' => array('1' => '2', '3' => '4'))));
     $this->assertEquals(true, isset($system->array));
     //
     SystemRegisterSample::loadAll();
     $base = new SystemRegister('System');
     $this->assertEquals(true, isset($system->array));
     $base->delete('array');
     $this->assertEquals(false, isset($base->array));
     //
     SystemRegisterSample::clearCache();
     SystemRegisterSample::loadAll();
     $system = new SystemRegister('/System/');
     $this->assertEquals(false, isset($base->array));
 }
Пример #14
0
 /**
  * Обновляет значение листа
  */
 public function update()
 {
     if (empty($this->nId)) {
         throw new SystemRegisterException('Update failed! Attribute $id  empty');
     }
     SystemRegisterSample::update($this->parent, $this->nId, $this->szName, $this->szValue, $this->szComment, $this->szType);
 }
Пример #15
0
 /**
  * Возвращает дерево реестра в виде ассоциативного массива
  */
 public static function exportData($nId = 0)
 {
     $aData = SystemRegisterSample::selectChild($nId);
     $aResult = array();
     foreach ($aData as $row) {
         if ($row['type'] == SYSTEMREGISTER_BRANCH_TYPE) {
             $aResult[$row['name']] = self::exportData($row['id']);
         } else {
             $aResult[$row['name']] = $row['value'];
         }
     }
     return $aResult;
 }
Пример #16
0
 /**
  * Загружает всю таблицу в кеш сразу
  */
 public static function loadAll()
 {
     try {
         // Если есть кеш, то грузим его
         $getCache = SimpleCache::get(SYSTEM_REGISTER_GET_CACHE);
         $childCache = SimpleCache::get(SYSTEM_REGISTER_CHILD_CACHE);
         self::$aGetCache = $getCache;
         self::$aChildCache = $childCache;
         return;
     } catch (SimpleCacheException $e) {
     }
     self::createCache();
 }
Пример #17
0
 public function delete($id)
 {
     $node = SystemRegisterHelper::createById($id);
     if (is_subclass_of($node, 'SystemRegister') || get_class($node) == 'SystemRegister') {
         $aPath = explode('/', $node->getFullPath());
         $szKey = $aPath = $aPath[sizeof($aPath) - 1];
         $node->getParent()->delete($szKey);
     } else {
         $szKey = $node->name;
         $node->parent->delete($szKey);
     }
     SystemRegisterSample::createCache();
     die;
 }
Пример #18
0
 public function post($ssl, $server, $port, $name, $password, $from_email, $from_name)
 {
     $this->register->enable_ssl->value = $ssl;
     $this->register->smtp_server->value = $server;
     $this->register->smtp_port->value = $port;
     $this->register->smtp_user->value = $name;
     $this->register->smtp_password->value = $password;
     $this->register->from_email->value = $from_email;
     $this->register->from_name->value = $from_name;
     SystemRegisterSample::createCache();
     $this->addAlert('Настройки сохранены');
     $this->jumpBack();
 }
Пример #19
0
 protected function action()
 {
     $register = new \SystemRegister('System/Schedule');
     $register->runningFlag->value = intval($this->getParam('runningFlag'));
     \SystemRegisterSample::createCache();
 }
Пример #20
0
<?php

$register = new SystemRegister('System/CMS');
$register->delete('display_administrate_scripts');
SystemRegisterSample::clearCache();
Пример #21
0
 public function testRunnerNotWorksOnSystemRegisterFlag()
 {
     $register = new \SystemRegister('System/Schedule');
     $register->runningFlag->value = 0;
     \SystemRegisterSample::createCache();
     //
     $job = new TestAction();
     $job->insert();
     //
     $runner = new Runner();
     $runner->resolveJobs();
     //
     $this->assertFalse(TestAction::isCalled());
     $job = TestAction::getById($job->id->getValue());
     $this->assertEquals(TestAction::NewStatus, $job->status->getValue());
 }