public function run()
 {
     $cfg = new Config();
     $pNum = (int) $cfg->get('OLD_VERSION_JOB_PAGE_NUM');
     $pNum = $pNum < 0 ? 1 : $pNum + 1;
     $pl = new PageList();
     $pl->setItemsPerPage(3);
     /* probably want to keep a record of pages that have been gone through 
      * so you don't start from the beginning each time..
      */
     $pages = $pl->getPage($pNum);
     if (!count($pages)) {
         $cfg->save('OLD_VERSION_JOB_PAGE_NUM', 0);
         return t("All pages have been processed, starting from beginning on next run.");
     }
     $versionCount = 0;
     $pagesAffected = array();
     foreach ($pages as $page) {
         if ($page instanceof Page) {
             $pvl = new VersionList($page);
             $pagesAffected[] = $page->getCollectionID();
             foreach (array_slice(array_reverse($pvl->getVersionListArray()), 10) as $v) {
                 if ($v instanceof CollectionVersion && !$v->isApproved() && !$v->isMostRecent()) {
                     @$v->delete();
                     $versionCount++;
                 }
             }
         }
     }
     $pageCount = count($pagesAffected);
     $cfg->save('OLD_VERSION_JOB_PAGE_NUM', $pNum);
     //i18n: %1$d is the number of versions deleted, %2$d is the number of affected pages, %3$d is the number of times that the Remove Old Page Versions job has been executed.
     return t2('%1$d versions deleted from %2$d page (%3$d)', '%1$d versions deleted from %2$d pages (%3$s)', $pageCount, $versionCount, $pageCount, implode(',', $pagesAffected));
 }
 public function run()
 {
     //$u = new User();
     //if(!$u->isSuperUser()) { die(t("Access Denied."));} // cheap security check...
     $cfg = new Config();
     Loader::model('page_list');
     $pl = new PageList();
     //$pl->ignorePermissions();
     $pNum = $cfg->get('OLD_VERSION_JOB_PAGE_NUM');
     if ($pNum <= 0) {
         $cfg->save('OLD_VERSION_JOB_PAGE_NUM', 0);
     }
     $pl->setItemsPerPage(3);
     /* probably want to keep a record of pages that have been gone through 
      * so you don't start from the beginning each time..
      */
     $pNum = $pNum + 1;
     $pages = $pl->getPage($pNum);
     $cfg->save('OLD_VERSION_JOB_PAGE_NUM', $pNum);
     $pageCount = 0;
     $versionCount = 0;
     if (count($pages) == 0) {
         $cfg->save('OLD_VERSION_JOB_PAGE_NUM', 0);
         return t("All pages have been processes, starting from beginning on next run.");
     }
     foreach ($pages as $page) {
         if ($page instanceof Page) {
             $pvl = new VersionList($page);
             $versions = $pvl->getVersionListArray();
             $versions = array_reverse($versions);
             $vCount = count($versions);
             if ($vCount <= 10) {
                 continue;
             }
             $pageCount++;
             $stopAt = $vCount - 10;
             $i = 0;
             foreach ($versions as $v) {
                 if ($v instanceof CollectionVersion) {
                     if ($v->isApproved() || $v->isMostRecent()) {
                         // may want to add a date check here too
                         continue;
                     } else {
                         @$v->delete();
                         $versionCount++;
                     }
                 }
                 $i++;
                 if ($i >= $stopAt) {
                     break;
                 }
             }
         }
     }
     $pages = $pageCount == 1 ? t("Page") : t("Pages");
     return $versionCount . " " . t("versions deleted from") . " " . $pageCount . " " . $pages . " (" . $pNum . ")";
 }
Example #3
0
 public function saveAuthenticationType($args)
 {
     \Config::save('auth.facebook.appid', $args['apikey']);
     \Config::save('auth.facebook.secret', $args['apisecret']);
     \Config::save('auth.facebook.registration.enabled', (bool) $args['registration_enabled']);
     \Config::save('auth.facebook.registration.group', intval($args['registration_group'], 10));
 }
 public function saveAuthenticationType($args)
 {
     \Config::save('auth.worldskills.appid', $args['apikey']);
     \Config::save('auth.worldskills.secret', $args['apisecret']);
     \Config::save('auth.worldskills.roles_application_code', $args['roles_application_code']);
     \Config::save('auth.worldskills.registration.group', intval($args['registration_group'], 10));
 }
Example #5
0
	public function update_profiles() { 
		if ($this->isPost()) {
			Config::save('ENABLE_USER_PROFILES', ($this->post('public_profiles')?true:false));
			$message = ($this->post('public_profiles')?t('Public profiles have been enabled'):t('Public profiles have been disabled.'));
			$this->redirect('/dashboard/system/registration/profiles',$message);
		}
	}
Example #6
0
 public function SaveProfile(Button $button)
 {
     $form = $button->getForm();
     $values = $form->getValues();
     try {
         if ($this->mode == 'superadmin') {
             if (isset($values['password_new'])) {
                 if ($values['password'] == $this->profile_data['password']) {
                     if ($values['password_new'] == $values['password_new_confirm']) {
                         $values['password'] = $values['password_new'];
                     } else {
                         throw new AuthenticationException('New password does not match.');
                     }
                 } else {
                     throw new AuthenticationException('Old password does not match with provided password.');
                 }
             } else {
                 unset($values['password']);
             }
             unset($values['password_new']);
             unset($values['password_new_confirm']);
             $this->config_data['admin'] = array_merge($this->config_data['admin'], $values);
             $config = new Config();
             $config->import($this->config_data);
             $config->save(APP_DIR . '/config/admin.ini', 'admin');
             $this->flash('Super admin profile updated');
         }
     } catch (Exception $e) {
         $this->flash($e->getMessage(), 'error');
     }
     $this->end();
 }
Example #7
0
	function txt_editor_config(){
		if (!$this->token->validate("txt_editor_config")) { 
			$this->error->add($this->token->getErrorMessage());
		}

		$textEditorWidth = intval($this->post('CONTENTS_TXT_EDITOR_WIDTH'));
		if( $textEditorWidth<580 ) {
			$this->error->add(t('The editor must be at least 580 pixels wide.'));
		}
		$textEditorHeight = intval($this->post('CONTENTS_TXT_EDITOR_HEIGHT'));
		if( $textEditorHeight<100 ) {
			$this->error->add(t('The editor must be at least 100 pixels tall.'));
		}
		
		if (!$this->error->has()) { 
 			Config::save('CONTENTS_TXT_EDITOR_MODE', $this->post('CONTENTS_TXT_EDITOR_MODE') );
			Config::save( 'CONTENTS_TXT_EDITOR_WIDTH', $textEditorWidth );
			Config::save( 'CONTENTS_TXT_EDITOR_HEIGHT', $textEditorHeight );	
			
			$db = Loader::db();
			$values=array( $textEditorWidth, $textEditorHeight );
			$db->query( 'UPDATE BlockTypes SET btInterfaceWidth=?, btInterfaceHeight=? where btHandle = "content"', $values );
			
			if($this->post('CONTENTS_TXT_EDITOR_MODE')=='CUSTOM')
				Config::save('CONTENTS_TXT_EDITOR_CUSTOM_CODE', $this->post('CONTENTS_TXT_EDITOR_CUSTOM_CODE') );
 			$this->redirect('/dashboard/system/basics/editor', 'txt_editor_config_saved'); 
		}
	}
Example #8
0
 public function saveAuthenticationType($args)
 {
     \Config::save('auth.community.appid', $args['apikey']);
     \Config::save('auth.community.secret', $args['apisecret']);
     \Config::save('auth.community.registration.enabled', !!$args['registration_enabled']);
     \Config::save('auth.community.registration.group', intval($args['registration_group'], 10));
 }
Example #9
0
 public static function getOrCreate($groups)
 {
     $db = Loader::db();
     $petID = $db->GetOne('select petID from PermissionAccessEntityTypes where petHandle = \'group_combination\'');
     $q = 'select pae.peID from PermissionAccessEntities pae ';
     $i = 1;
     foreach ($groups as $g) {
         $q .= 'left join PermissionAccessEntityGroups paeg' . $i . ' on pae.peID = paeg' . $i . '.peID ';
         $i++;
     }
     $q .= 'where petID = ? ';
     $i = 1;
     foreach ($groups as $g) {
         $q .= 'and paeg' . $i . '.gID = ' . $g->getGroupID() . ' ';
         $i++;
     }
     $peID = $db->GetOne($q, array($petID));
     if (!$peID) {
         $db->Execute("insert into PermissionAccessEntities (petID) values (?)", array($petID));
         Config::save('ACCESS_ENTITY_UPDATED', time());
         $peID = $db->Insert_ID();
         foreach ($groups as $g) {
             $db->Execute('insert into PermissionAccessEntityGroups (peID, gID) values (?, ?)', array($peID, $g->getGroupID()));
         }
     }
     return PermissionAccessEntity::getByID($peID);
 }
Example #10
0
 public function update_registration_type()
 {
     if ($this->isPost()) {
         Config::save('ENABLE_OPENID_AUTHENTICATION', $this->post('enable_openID') ? true : false);
         Config::save('USER_REGISTRATION_WITH_EMAIL_ADDRESS', $this->post('email_as_username') ? true : false);
         Config::save('REGISTRATION_TYPE', $this->post('registration_type'));
         Config::save('ENABLE_REGISTRATION_CAPTCHA', $this->post('enable_registration_captcha') ? true : false);
         switch ($this->post('registration_type')) {
             case "enabled":
                 Config::save('ENABLE_REGISTRATION', true);
                 Config::save('USER_VALIDATE_EMAIL', false);
                 Config::save('USER_VALIDATE_EMAIL_REQUIRED', false);
                 Config::save('USER_REGISTRATION_APPROVAL_REQUIRED', false);
                 break;
             case "validate_email":
                 Config::save('ENABLE_REGISTRATION', true);
                 Config::save('USER_VALIDATE_EMAIL', true);
                 Config::save('USER_VALIDATE_EMAIL_REQUIRED', true);
                 Config::save('USER_REGISTRATION_APPROVAL_REQUIRED', false);
                 break;
             case "manual_approve":
                 Config::save('ENABLE_REGISTRATION', true);
                 Config::save('USER_REGISTRATION_APPROVAL_REQUIRED', true);
                 Config::save('USER_VALIDATE_EMAIL', false);
                 Config::save('USER_VALIDATE_EMAIL_REQUIRED', false);
                 break;
             default:
                 // disabled
                 Config::save('ENABLE_REGISTRATION', false);
                 break;
         }
         Config::save('REGISTRATION_TYPE', $this->post('registration_type'));
         $this->redirect('/dashboard/system/registration/public_registration', t('Registration settings have been saved.'));
     }
 }
Example #11
0
 public function enterAction()
 {
     $config = Config::share();
     if (!empty($_POST['systemPass'])) {
         if (empty($config['systemPass'])) {
             $config['systemPass'] = password_hash($_POST['systemPass'], PASSWORD_DEFAULT);
             $config['installed'] = true;
             Config::save('share', $config);
         }
         if (password_verify($_POST['systemPass'], $config['systemPass'])) {
             $_SESSION['systemLogin'] = 1;
         } else {
             if (empty($config['failTry'])) {
                 $config['failTry'] = 1;
             } else {
                 $config['failTry']++;
             }
             Config::save('share', $config);
         }
         Tools::redirect('/setup');
     }
     if (!empty($config['systemPass']) && !empty($_COOKIE['systemPass']) && $_COOKIE['systemPass'] == $config['systemPass']) {
         Tools::redirect('/setup');
     }
     $this->view->setTitle('Enter');
     $this->view->page();
 }
 public function save()
 {
     $helper_file = Loader::helper('concrete/file');
     $validation_token = Loader::helper('validation/token');
     Loader::model('file_storage_location');
     if (!$validation_token->validate("file_storage")) {
         $this->set('error', array($validation_token->getErrorMessage()));
         return;
     }
     if ($_POST['delete']) {
         $fsl = FileStorageLocation::getByID(FileStorageLocation::ALTERNATE_ID);
         if (is_object($fsl)) {
             $fsl->delete();
             $this->redirect('/dashboard/system/environment/file_storage_locations', 'storage_deleted');
         }
     } else {
         Config::save('DIR_FILES_UPLOADED', $this->post('DIR_FILES_UPLOADED'));
         if ($this->post('fslName') != '' && $this->post('fslDirectory') != '') {
             $fsl = FileStorageLocation::getByID(FileStorageLocation::ALTERNATE_ID);
             if (!is_object($fsl)) {
                 FileStorageLocation::add($this->post('fslName'), $this->post('fslDirectory'), FileStorageLocation::ALTERNATE_ID);
             } else {
                 $fsl->update($this->post('fslName'), $this->post('fslDirectory'));
             }
         }
         $this->redirect('/dashboard/system/environment/file_storage_locations', 'storage_saved');
     }
 }
 public function update_library()
 {
     if (Loader::helper("validation/token")->validate('update_library')) {
         if ($this->post('activeLibrary')) {
             $scl = SystemAntispamLibrary::getByHandle($this->post('activeLibrary'));
             if (is_object($scl)) {
                 $scl->activate();
                 Config::save('ANTISPAM_NOTIFY_EMAIL', $this->post('ANTISPAM_NOTIFY_EMAIL'));
                 Config::save('ANTISPAM_LOG_SPAM', $this->post('ANTISPAM_LOG_SPAM'));
                 if ($scl->hasOptionsForm() && $this->post('ccm-submit-submit')) {
                     $controller = $scl->getController();
                     $controller->saveOptions($this->post());
                 }
                 $this->redirect('/dashboard/system/permissions/antispam', 'saved');
             } else {
                 $this->error->add(t('Invalid anti-spam library.'));
             }
         } else {
             SystemAntispamLibrary::deactivateAll();
         }
     } else {
         $this->error->add(Loader::helper('validation/token')->getErrorMessage());
     }
     $this->view();
 }
 public function view($updated = false)
 {
     Loader::library('database_indexed_search');
     if ($this->post('reindex')) {
         IndexedSearch::clearSearchIndex();
         $this->redirect('/dashboard/system/seo/search_index', 'index_cleared');
     } else {
         if ($updated) {
             $this->set('message', t('Search Index Preferences Updated'));
         }
         if ($this->isPost()) {
             if ($this->token->validate('update_search_index')) {
                 $areas = $this->post('arHandle');
                 if (!is_array($areas)) {
                     $areas = array();
                 }
                 Config::save('SEARCH_INDEX_AREA_LIST', serialize($areas));
                 Config::save('SEARCH_INDEX_AREA_METHOD', Loader::helper('security')->sanitizeString($this->post('SEARCH_INDEX_AREA_METHOD')));
                 $this->redirect('/dashboard/system/seo/search_index', 'updated');
             } else {
                 $this->set('error', array($this->token->getErrorMessage()));
             }
         }
         $areas = Area::getHandleList();
         $selectedAreas = array();
         $this->set('areas', $areas);
         $this->set('selectedAreas', IndexedSearch::getSavedSearchableAreas());
     }
 }
Example #15
0
	function update_favicon(){
		Loader::library('file/importer');
		if ($this->token->validate("update_favicon")) { 
		
			if(intval($this->post('remove_favicon'))==1){
				Config::save('FAVICON_FID',0);
					$this->redirect('/dashboard/system/basics/icons/', 'favicon_removed');
			} else {
				$fi = new FileImporter();
				$resp = $fi->import($_FILES['favicon_file']['tmp_name'], $_FILES['favicon_file']['name'], $fr);
				if (!($resp instanceof FileVersion)) {
					switch($resp) {
						case FileImporter::E_FILE_INVALID_EXTENSION:
							$this->error->add(t('Invalid file extension.'));
							break;
						case FileImporter::E_FILE_INVALID:
							$this->error->add(t('Invalid file.'));
							break;
						
					}
				} else {
				
					Config::save('FAVICON_FID', $resp->getFileID());
					$filepath=$resp->getPath();  
					//@copy($filepath, DIR_BASE.'/favicon.ico');
					$this->redirect('/dashboard/system/basics/icons/', 'favicon_saved');

				}
			}		
			
		}else{
			$this->set('error', array($this->token->getErrorMessage()));
		}
	}
Example #16
0
 /**
  * The index action
  * 
  * @access public
  * @return void
  */
 public function action_index()
 {
     $settings = \Config::load('autoresponder.db');
     // $autoResponder = Model_Setting::find(array('where' => array(array('meta_key', '=', 'auto-responders'))));
     if (\Input::post()) {
         $input = \Input::post();
         if (!\Input::is_ajax()) {
             $val = Model_Setting::validate('create');
             if (!$val->run()) {
                 if ($val->error() != array()) {
                     // show validation errors
                     \Messages::error('<strong>There was an error while trying to create settings</strong>');
                     foreach ($val->error() as $e) {
                         \Messages::error($e->get_message());
                     }
                 }
             } else {
                 try {
                     \Config::save('autoresponder.db', array('logo_url' => $input['logo_url'], 'company_name' => $input['company_name'], 'address' => $input['address'], 'website' => $input['website'], 'phone' => $input['phone'], 'email_address' => $input['email_address'], 'sender_email_address' => $input['sender_email_address'], 'contact_us_email_address' => $input['contact_us_email_address'], 'instagram_account_name' => $input['instagram_account_name'], 'facebook_account_name' => $input['facebook_account_name']));
                     // $setting->save();
                     \Messages::success('Settings successfully created.');
                     \Response::redirect('admin/settings');
                 } catch (\Database_Exception $e) {
                     // show validation errors
                     \Messages::error('<strong>There was an error while trying to create settings.</strong>');
                     // Uncomment lines below to show database errors
                     $errors = $e->getMessage();
                     \Messages::error($errors);
                 }
             }
         }
     }
     \View::set_global('title', 'Settings');
     \Theme::instance()->set_partial('content', $this->view_dir . 'index')->set('settings', $settings, false);
 }
Example #17
0
	public function getLatestAvailableVersionNumber() {
		if (defined('MULTI_SITE') && MULTI_SITE == 1) {
			$updates = Update::getLocalAvailableUpdates();
			$multiSiteVersion = 0;
			foreach($updates as $up) {
				if (version_compare($up->getUpdateVersion(), $multiSiteVersion, '>')) {
					$multiSiteVersion = $up->getUpdateVersion();
				}	
			}
			Config::save('APP_VERSION_LATEST', $multiSiteVersion);
			return $multiSiteVersion;
		}
		
		$d = Loader::helper('date');
		// first, we check session
		$queryWS = false;
		Cache::disableCache();
		$vNum = Config::get('APP_VERSION_LATEST', true);
		Cache::enableCache();
		if (is_object($vNum)) {
			$seconds = strtotime($vNum->timestamp);
			$version = $vNum->value;
			if (is_object($version)) {
				$versionNum = $version->version;
			} else {
				$versionNum = $version;
			}
			$diff = time() - $seconds;
			if ($diff > APP_VERSION_LATEST_THRESHOLD) {
				// we grab a new value from the service
				$queryWS = true;
			}
		} else {
			$queryWS = true;
		}
		
		if ($queryWS) {
			Loader::library('marketplace');
			$mi = Marketplace::getInstance();
			if ($mi->isConnected()) {
				Marketplace::checkPackageUpdates();
			}
			$update = Update::getLatestAvailableUpdate();
			$versionNum = $update->version;
			
			if ($versionNum) {
				Config::save('APP_VERSION_LATEST', $versionNum);
				if (version_compare($versionNum, APP_VERSION, '>')) {
					Loader::model('system_notification');
					SystemNotification::add(SystemNotification::SN_TYPE_CORE_UPDATE, t('A new version of concrete5 is now available.'), '', $update->notes, View::url('/dashboard/system/update'));
				}		
			} else {
				// we don't know so we're going to assume we're it
				Config::save('APP_VERSION_LATEST', APP_VERSION);
			}
		}
		
		return $versionNum;
	}
Example #18
0
 public function update_user_timezones()
 {
     if ($this->isPost()) {
         Config::save('ENABLE_USER_TIMEZONES', $this->post('user_timezones') ? true : false);
         $message = $this->post('user_timezones') ? t('User time zones have been enabled') : t('User time zones have been disabled.');
         $this->redirect('/dashboard/users/registration', $message);
     }
 }
Example #19
0
 public function enable_advanced_permissions()
 {
     if ($this->token->validate("enable_advanced_permissions")) {
         Config::save('PERMISSIONS_MODEL', 'advanced');
         $this->redirect('/dashboard/system/permissions/advanced', 'permissions_enabled');
     } else {
         $this->error->add($this->token->getErrorMessage());
     }
 }
Example #20
0
 public function action_upgrade()
 {
     $mig = \Migrate::latest();
     $version = \Model_Version::find('last', array('order_by' => array('meta_update_time' => 'desc')));
     Config::load('install', true);
     Config::set('install.version', $version['value']);
     Config::save('install', 'install');
     echo json_encode(array('status' => true, 'ver' => $version['value'], 'dat' => Date('d/m/Y', $version['meta_update_time'])));
 }
 public function save()
 {
     if ($this->isPost()) {
         \Config::save('worldskills.api_url', $this->post('api_url'));
         \Config::save('worldskills.authorize_url', $this->post('authorize_url'));
         $this->redirect('/dashboard/system/basics/worldskills', 'saved');
     }
     $this->view();
 }
Example #22
0
	public function update_sitename() {
		if ($this->token->validate("update_sitename")) {
			if ($this->isPost()) {
				Config::save('SITE', $this->post('SITE'));
				$this->redirect('/dashboard/system/basics/site_name','sitename_saved');
			}
		} else {
			$this->set('error', array($this->token->getErrorMessage()));
		}
	}
Example #23
0
	public function update_profiles() { 
		if ($this->isPost()) {
			Config::save('ENABLE_USER_PROFILES', ($this->post('public_profiles')?true:false));
			Config::save('GRAVATAR_FALLBACK', ($this->post('gravatar_fallback')?true:false));
			Config::save('GRAVATAR_MAX_LEVEL', $this->post('gravatar_max_level'));
			Config::save('GRAVATAR_IMAGE_SET', $this->post('gravatar_image_set'));
			$message = ($this->post('public_profiles')?t('Public profiles have been enabled'):t('Public profiles have been disabled.'));
			$this->redirect('/dashboard/system/registration/profiles',$message);
		}
	}
Example #24
0
 public function save_mobile_theme()
 {
     $pt = PageTheme::getByID($this->post('MOBILE_THEME_ID'));
     if (is_object($pt)) {
         Config::save('MOBILE_THEME_ID', $pt->getThemeID());
     } else {
         Config::save('MOBILE_THEME_ID', 0);
     }
     $this->redirect('/dashboard/pages/themes', 'mobile_theme_saved');
 }
Example #25
0
 public function run()
 {
     $db = Loader::db();
     $columns = $db->MetaColumns('Pages');
     if (!isset($columns['CISSYSTEMPAGE'])) {
         $db->Execute('alter table Pages add column cIsSystemPage tinyint(1) not null default 0');
         $db->Execute('alter table Pages add index (cIsSystemPage)');
     }
     $columns = $db->MetaColumns('Pages');
     if (!isset($columns['CISACTIVE'])) {
         $db->Execute('alter table Pages add column cIsActive tinyint(1) not null default 1');
         $db->Execute('alter table Pages add index (cIsActive)');
         $db->Execute('update Pages set cIsActive = 1');
     }
     $columns = $db->MetaColumns('PageSearchIndex');
     if (!isset($columns['CREQUIRESREINDEX'])) {
         $db->Execute('alter table PageSearchIndex add column cRequiresReindex tinyint(1) not null default 0');
         $db->Execute('alter table PageSearchIndex add index (cRequiresReindex)');
     }
     // install version job
     Loader::model("job");
     Job::installByHandle('remove_old_page_versions');
     // flag system pages appropriately
     Page::rescanSystemPages();
     // add a newsflow task permission
     $db = Loader::db();
     $cnt = $db->GetOne('select count(*) from TaskPermissions where tpHandle = ?', array('view_newsflow'));
     if ($cnt < 1) {
         $g3 = Group::getByID(ADMIN_GROUP_ID);
         $tip = TaskPermission::addTask('view_newsflow', t('View Newsflow'), false);
         if (is_object($g3)) {
             $tip->addAccess($g3);
         }
     }
     // Install new block types
     $this->installBlockTypes();
     // install stacks, trash and drafts
     $this->installSinglePages();
     // move the old dashboard
     $newDashPage = Page::getByPath('/dashboard/welcome');
     if (!is_object($newDashPage) || $newDashPage->isError()) {
         $dashboard = Page::getByPath('/dashboard');
         $dashboard->moveToTrash();
         // install new dashboard + page types
         $this->installDashboard();
         $this->migrateOldDashboard();
     }
     Loader::model('system/captcha/library');
     $scl = SystemCaptchaLibrary::getByHandle('securimage');
     if (!is_object($scl)) {
         $scl = SystemCaptchaLibrary::add('securimage', t('SecurImage (Default)'));
         $scl->activate();
     }
     Config::save('SEEN_INTRODUCTION', 1);
 }
Example #26
0
 public function import_wordpress_xml()
 {
     if ($this->post('import-images') == 'on') {
         $this->importImages = true;
         $filesetname;
         $this->post('file-set-name') ? $this->filesetname = $this->post('file-set-name') : ($this->filesetname = t("Imported Wordpress Files"));
         $this->createFileSet = true;
     }
     $pages = array();
     if (intval($this->post('wp-file')) > 0) {
         Loader::model('file');
         $co = new Config();
         $pkg = Package::getByHandle('wordpress_site_importer');
         $co->setPackageObject($pkg);
         $co->save("WORDPRESS_IMPORT_FID", $this->post('wp-file'));
         $importFile = File::getByID($this->post('wp-file'));
         $nv = $importFile->getVersion();
         $fileUrl = $nv->getDownloadURL();
         $xml = @simplexml_load_file($fileUrl, "SimpleXMLElement", LIBXML_NOCDATA);
         $items = array();
         foreach ($xml->channel->item as $item) {
             $items[] = $item->asxml();
         }
         $db = Loader::db();
         $sql = $db->Prepare('insert into WordpressItems (wpItem) values(?)');
         foreach ($items as $item) {
             $db->Execute($sql, $item);
         }
         $categories = array();
         $namespaces = $xml->getDocNamespaces();
         foreach ($xml->xpath('/rss/channel/wp:category') as $term_arr) {
             $t = $term_arr->children($namespaces['wp']);
             $categories[] = array('term_id' => (int) $t->term_id, 'category_nicename' => (string) $t->category_nicename, 'category_parent' => (string) $t->category_parent, 'cat_name' => (string) $t->cat_name, 'category_description' => (string) $t->category_description);
         }
         Loader::model('attribute/categories/collection');
         $akt = CollectionAttributeKey::getByHandle("wordpress_category");
         for ($i = 0; $i < count($categories); $i++) {
             $opt = new SelectAttributeTypeOption(0, $categories[$i]['cat_name'], $i);
             $opt = $opt->saveOrCreate($akt);
         }
         foreach ($xml->xpath('/rss/channel/wp:tag') as $term_arr) {
             $t = $term_arr->children($namespaces['wp']);
             $tags[] = array('term_id' => (int) $t->term_id, 'tag_slug' => (string) $t->tag_slug, 'tag_name' => (string) $t->tag_name, 'tag_description' => (string) $t->tag_description);
         }
         $akt = CollectionAttributeKey::getByHandle("tags");
         for ($i = 0; $i < count($tags); $i++) {
             $opt = new SelectAttributeTypeOption(0, $tags[$i]['tag_name'], $i);
             $opt = $opt->saveOrCreate($akt);
         }
     } else {
         echo t("No file");
         exit;
     }
     $this->view();
 }
Example #27
0
 public function testWrite()
 {
     $data = array('a' => 'foo', 'b' => array('c' => 'bar'));
     $conf = new Config($this->store);
     $conf->override = $data;
     $this->assertEquals($data, $conf->toArray());
     $this->assertTrue($conf->save());
     $this->assertTrue($conf['b']->save());
     $conf = new Config($this->store);
     $this->assertEquals($data, $conf->toArray());
 }
Example #28
0
 public function save_interface_language()
 {
     if (Loader::helper('validation/token')->validate('save_interface_language')) {
         Config::save('SITE_LOCALE', $this->post('SITE_LOCALE'));
         Config::save('LANGUAGE_CHOOSE_ON_LOGIN', $this->post('LANGUAGE_CHOOSE_ON_LOGIN'));
         $this->redirect('/dashboard/settings/multilingual', 'interface_settings_saved');
     } else {
         $this->error->add(Loader::helper('validation/token')->getErrorMessage());
     }
     $this->view();
 }
Example #29
0
	public function update_debug() {
		if ($this->token->validate("update_debug")) {
			if ($this->isPost()) {
				Config::save('SITE_DEBUG_LEVEL', $this->post('debug_level'));
				$this->redirect('/dashboard/system/environment/debug', 'debug_saved');

			}
		} else {
			$this->set('error', array($this->token->getErrorMessage()));
		}
	}
Example #30
0
 public function indexAction()
 {
     $config = $this->Recaptcha->config;
     if (filter_input(INPUT_POST, 'secret', FILTER_SANITIZE_STRING) && filter_input(INPUT_POST, 'sitekey', FILTER_SANITIZE_STRING)) {
         $config['secret'] = filter_input(INPUT_POST, 'secret', FILTER_SANITIZE_STRING);
         $config['sitekey'] = filter_input(INPUT_POST, 'sitekey', FILTER_SANITIZE_STRING);
         Config::save('module', $config, 'Recaptcha');
         Tools::redirect('/admin/Recaptcha', 'Настройки были сохранены', 'success');
     }
     $this->view->page(['data' => compact('config')]);
 }