public function __construct() { // Construct any possible parent; parent::__construct(); // Do the tie ... $this->tieInCommonConfiguration(); // Set the proper configuration options, from the config file; self::$objLyricsTable = $this->getConfigKey(new S('lyrics_table')); self::$objLyricsTableFId = $this->getConfigKey(new S('lyrics_table_field_id')); self::$objLyricsTableFSEO = $this->getConfigKey(new S('lyrics_table_field_seo')); self::$objLyricsTableFTitle = $this->getConfigKey(new S('lyrics_table_field_title')); self::$objLyricsTableFArtist = $this->getConfigKey(new S('lyrics_table_field_artist')); self::$objLyricsTableFAlbum = $this->getConfigKey(new S('lyrics_table_field_album')); self::$objLyricsTableFLyrics = $this->getConfigKey(new S('lyrics_table_field_lyrics')); self::$objLyricsTableFDateAdded = $this->getConfigKey(new S('lyrics_table_field_date_added')); self::$objItemsPerPage = new S('10'); // Load'em defaults ... ATH, STG and others ... $this->ATH = MOD::activateModule(new FilePath('mod/authentication'), new B(TRUE)); $this->STG = MOD::activateModule(new FilePath('mod/settings'), new B(TRUE)); // DB: Auto-CREATE: $objQueryDB = new FileContent($this->getPathToModule()->toRelativePath() . _S . CFG_DIR . _S . __CLASS__ . SCH_EXTENSION); // Make a FOREACH on each ... foreach (_S($objQueryDB->toString())->fromStringToArray(RA_SCHEMA_HASH_TAG) as $k => $v) { // Make'em ... $this->_Q(_S($v)); } }
public function __construct() { // Construct any possible parent; parent::__construct(); // Do the tie ... $this->tieInCommonConfiguration(); // Set the proper configuration options, from the config file; self::$objSettingsCountryTable = $this->getConfigKey(new S('settings_country_table')); self::$objSettingsCountryTableFIso = $this->getConfigKey(new S('settings_country_table_field_iso')); self::$objSettingsCountryTableFName = $this->getConfigKey(new S('settings_country_table_field_name')); self::$objSettingsCountryTableFPrnt = $this->getConfigKey(new S('settings_country_table_field_printable_name')); self::$objSettingsCountryTableFIsoT = $this->getConfigKey(new S('settings_country_table_field_iso3')); self::$objSettingsCountryTableFCode = $this->getConfigKey(new S('settings_country_table_field_numcode')); // Errors ... self::$objSettingsErrTable = $this->getConfigKey(new S('settings_error_pages_table')); self::$objSettingsErrTableFId = $this->getConfigKey(new S('settings_error_pages_table_field_id')); self::$objSettingsErrTableFCode = $this->getConfigKey(new S('settings_error_pages_table_error_code')); self::$objSettingsErrTableFTitle = $this->getConfigKey(new S('settings_error_pages_table_title')); self::$objSettingsErrTableFContent = $this->getConfigKey(new S('settings_error_pages_table_content')); // DB: Auto-CREATE: $objQueryDB = new FileContent($this->getPathToModule()->toRelativePath() . _S . CFG_DIR . _S . __CLASS__ . SCH_EXTENSION); // Make a FOREACH on each ... foreach (_S($objQueryDB->toString())->fromStringToArray(RA_SCHEMA_HASH_TAG) as $k => $v) { // Make'em ... $this->_Q(_S($v)); } }
public function __construct() { // Construct any possible parent; parent::__construct(); // Do the tie ... $this->tieInCommonConfiguration(); // Set some configuration defaults, taking them from the config file; self::$objContactTable = $this->getConfigKey(new S('contact_table_message')); self::$objContactTableFId = $this->getConfigKey(new S('contact_table_message_field_id')); self::$objContactTableFMessage = $this->getConfigKey(new S('contact_table_message_content')); self::$objContactTableFSubjectId = $this->getConfigKey(new S('contact_table_message_subject_id')); self::$objContactTableFEMAIL = $this->getConfigKey(new S('contact_table_message_email')); self::$objContactTableFResolved = $this->getConfigKey(new S('contact_table_message_resolved')); self::$objContactTableFComment = $this->getConfigKey(new S('contact_table_message_comment')); self::$objContactTableFReceived = $this->getConfigKey(new S('contact_table_message_received')); self::$objContactTableFLastEdited = $this->getConfigKey(new S('contact_table_message_last_edited')); // Subjects .. self::$objContactSubjectTable = $this->getConfigKey(new S('contact_table_subject')); self::$objContactSubjectFId = $this->getConfigKey(new S('contact_table_subject_field_id')); self::$objContactSubjectFTitle = $this->getConfigKey(new S('contact_table_subject_title')); // DB: Auto-CREATE: $objQueryDB = new FileContent($this->getPathToModule()->toRelativePath() . _S . CFG_DIR . _S . __CLASS__ . SCH_EXTENSION); // Make a FOREACH on each ... foreach (_S($objQueryDB->toString())->fromStringToArray(RA_SCHEMA_HASH_TAG) as $k => $v) { // Make'em ... $this->_Q(_S($v)); } // Load'em defaults ... ATH, STG and others ... $this->ATH = MOD::activateModule(new FilePath('mod/authentication'), new B(TRUE)); $this->STG = MOD::activateModule(new FilePath('mod/settings'), new B(TRUE)); }
public function __construct() { // Construct any possible parent; parent::__construct(); // Do the tie ... $this->tieInCommonConfiguration(); // Set the proper configuration options, from the config file; self::$objLetterTable = $this->getConfigKey(new S('newsletter_table')); self::$objLetterTableFId = $this->getConfigKey(new S('newsletter_table_field_id')); self::$objLetterTableFEML = $this->getConfigKey(new S('newsletter_table_field_email')); self::$objLetterTableFFirstName = $this->getConfigKey(new S('newsletter_table_field_first_name')); self::$objLetterTableFLastName = $this->getConfigKey(new S('newsletter_table_field_last_name')); self::$objLetterTableFType = $this->getConfigKey(new S('newsletter_table_field_email_type')); self::$objLetterTableFConfirmed = $this->getConfigKey(new S('newsletter_table_field_is_confirmed')); self::$objLetterTableFKey = $this->getConfigKey(new S('newsletter_table_field_confirmation_key')); self::$objLetterTableFSubscribed = $this->getConfigKey(new S('newsletter_table_field_date')); self::$objLetterTableFCategoryId = $this->getConfigKey(new S('newsletter_table_field_category_id')); // Categories ... self::$objCategoryTable = $this->getConfigKey(new S('newsletter_category_table')); self::$objCategoryTableFId = $this->getConfigKey(new S('newsletter_category_table_id')); self::$objCategoryTableFName = $this->getConfigKey(new S('newsletter_category_table_name')); self::$objCategoryTableFSEO = $this->getConfigKey(new S('newsletter_category_table_seo')); self::$objCategoryTableFDescription = $this->getConfigKey(new S('newsletter_category_table_description')); self::$objCategoryTableFDate = $this->getConfigKey(new S('newsletter_category_table_date')); // Load'em defaults ... ATH, STG and others ... $this->ATH = MOD::activateModule(new FilePath('mod/authentication'), new B(TRUE)); $this->STG = MOD::activateModule(new FilePath('mod/settings'), new B(TRUE)); // DB: Auto-CREATE: $objQueryDB = new FileContent($this->getPathToModule()->toRelativePath() . _S . CFG_DIR . _S . __CLASS__ . SCH_EXTENSION); // Make a FOREACH on each ... foreach (_S($objQueryDB->toString())->fromStringToArray(RA_SCHEMA_HASH_TAG) as $k => $v) { // Make'em ... $this->_Q(_S($v)); } // Get an MPTT Object, build the ROOT, make sure the table is OK; self::$objMPTT = new MPTT(self::$objCategoryTable, MPTT::mpttAddUnique(new S(__CLASS__), new S((string) $_SERVER['REQUEST_TIME']))); }
public function testModelWithAttachmentTestItem() { $pathToFiles = Yii::getPathOfAlias('application.modules.zurmo.tests.unit.files'); $filePath = $pathToFiles . DIRECTORY_SEPARATOR . 'testNote.txt'; // create 2 extra file model which should persist when $model is delete, their content should also persist. $pdfFile = FileModelUtil::makeByFilePathAndName($filePath, 'testPDF.pdf'); $pdfFileId = $pdfFile->id; $pdfFileName = $pdfFile->name; $pdfFileContent = $pdfFile->fileContent->content; $pdfFileType = $pdfFile->type; $pdfFileSize = $pdfFile->size; $pdfFile->forgetAll(); unset($pdfFile); $zipFile = FileModelUtil::makeByFilePathAndName($filePath, 'testZip.zip'); $zipFileId = $zipFile->id; $zipFileName = $zipFile->name; $zipFileContent = $zipFile->fileContent->content; $zipFileType = $zipFile->type; $zipFileSize = $zipFile->size; $zipFile->forgetAll(); unset($zipFile); $model = new ModelWithAttachmentTestItem(); $fileModel = FileModelUtil::makeByFilePathAndName($filePath, 'testNote.txt'); $firstFileModelId = $fileModel->id; $this->assertTrue($fileModel instanceof FileModel); $this->assertEquals(6495, strlen($fileModel->fileContent->content)); $theContent = $fileModel->fileContent->content; $model->files->add($fileModel); $model->member = 'test'; $saved = $model->save(); $this->assertTrue($saved); $modelId = $model->id; $model->forget(); $model = ModelWithAttachmentTestItem::getById($modelId); $this->assertEquals($theContent, $model->files[0]->fileContent->content); $this->assertEquals('testNote.txt', $model->files[0]->name); $this->assertEquals('text/plain', $model->files[0]->type); $this->assertEquals(6495, $model->files[0]->size); //Now try using CUploadedFile. self::resetAndPopulateFilesArrayByFilePathAndName('aTest', $filePath, 'testNote.txt'); $uploadedFile = CUploadedFile::getInstanceByName('aTest'); $this->assertTrue($uploadedFile instanceof CUploadedFile); $fileModel = FileModelUtil::makeByUploadedFile($uploadedFile); $this->assertTrue($fileModel instanceof FileModel); $this->assertTrue($fileModel->id != $firstFileModelId); $this->assertTrue($fileModel->id > 0); $model = ModelWithAttachmentTestItem::getById($modelId); $model->files->add($fileModel); $saved = $model->save(); $this->assertTrue($saved); $modelId = $model->id; $model->forget(); RedBeanModel::forgetAll(); $model = ModelWithAttachmentTestItem::getById($modelId); $this->assertEquals(2, $model->files->count()); //Delete the model and confirm the related models are removed $this->assertEquals(1, ModelWithAttachmentTestitem::getCount()); $this->assertEquals(4, FileModel::getCount()); $this->assertEquals(4, FileContent::getCount()); $this->assertTrue($model->delete()); $this->assertEquals(0, ModelWithAttachmentTestitem::getCount()); $this->assertEquals(2, FileModel::getCount()); $this->assertEquals(2, FileContent::getCount()); $pdfFile = FileModel::getById($pdfFileId); $this->assertEquals($pdfFileContent, $pdfFile->fileContent->content); $this->assertEquals($pdfFileName, $pdfFile->name); $this->assertEquals($pdfFileType, $pdfFile->type); $this->assertEquals($pdfFileSize, $pdfFile->size); $zipFile = FileModel::getById($zipFileId); $this->assertEquals($zipFileContent, $zipFile->fileContent->content); $this->assertEquals($zipFileName, $zipFile->name); $this->assertEquals($zipFileType, $zipFile->type); $this->assertEquals($zipFileSize, $zipFile->size); }
public function __construct() { // Construct any possible parent; parent::__construct(); // Do the tie ... $this->tieInCommonConfiguration(); // Set the proper configuration options, from the config file; self::$objProductsTable = $this->getConfigKey(new S('products_table')); self::$objProductsTableFId = $this->getConfigKey(new S('products_table_field_id')); self::$objProductsTableFCode = $this->getConfigKey(new S('products_table_field_code')); self::$objProductsTableFName = $this->getConfigKey(new S('products_table_field_name')); self::$objProductsTableFSEO = $this->getConfigKey(new S('products_table_field_seo')); self::$objProductsTableFPDF = $this->getConfigKey(new S('products_table_field_pdf')); self::$objProductsTableFURL = $this->getConfigKey(new S('products_table_field_url')); self::$objProductsTableFDescription = $this->getConfigKey(new S('products_table_field_description')); self::$objProductsTableFPrice = $this->getConfigKey(new S('products_table_field_price')); self::$objProductsTableFStoc = $this->getConfigKey(new S('products_table_field_stoc')); self::$objProductsTableFCategoryId = $this->getConfigKey(new S('products_table_field_category_id')); // Categories ... self::$objCategoryTable = $this->getConfigKey(new S('products_table_categories')); self::$objCategoryTableFId = $this->getConfigKey(new S('products_table_categories_field_id')); self::$objCategoryTableFName = $this->getConfigKey(new S('products_table_categories_field_name')); self::$objCategoryTableFSEO = $this->getConfigKey(new S('products_table_categories_field_seo')); self::$objCategoryTableFDescription = $this->getConfigKey(new S('products_table_categories_field_description')); self::$objCategoryTableFDate = $this->getConfigKey(new S('products_table_categories_field_date')); // Images for products ... self::$objProductsIMGTable = $this->getConfigKey(new S('products_table_images')); self::$objProductsIMGTableFId = $this->getConfigKey(new S('products_table_images_field_id')); self::$objProductsIMGTableFProdId = $this->getConfigKey(new S('products_table_images_field_product_id')); self::$objProductsIMGTableFTitle = $this->getConfigKey(new S('products_table_images_field_title')); self::$objProductsIMGTableFURL = $this->getConfigKey(new S('products_table_images_field_url')); self::$objProductsIMGTableFCaption = $this->getConfigKey(new S('products_table_images_field_caption')); // Properties for product ... self::$objProductsPropertyTable = $this->getConfigKey(new S('products_table_properties')); self::$objProductsPropertyTableFId = $this->getConfigKey(new S('products_table_properties_field_id')); self::$objProductsPropertyTableFPId = $this->getConfigKey(new S('products_table_properties_field_product_id')); self::$objProductsPropertyTableFKey = $this->getConfigKey(new S('products_table_properties_field_key')); self::$objProductsPropertyTableFVar = $this->getConfigKey(new S('products_table_properties_field_var')); // Configuration ... self::$objItemsPerPage = new S('10'); // Load'em defaults ... ATH, STG and others ... $this->ATH = MOD::activateModule(new FilePath('mod/authentication'), new B(TRUE)); $this->STG = MOD::activateModule(new FilePath('mod/settings'), new B(TRUE)); // DB: Auto-CREATE: $objQueryDB = new FileContent($this->getPathToModule()->toRelativePath() . _S . CFG_DIR . _S . __CLASS__ . SCH_EXTENSION); // Make a FOREACH on each ... foreach (_S($objQueryDB->toString())->fromStringToArray(RA_SCHEMA_HASH_TAG) as $k => $v) { // Make'em ... $this->_Q(_S($v)); } // Get an MPTT Object, build the ROOT, make sure the table is OK; self::$objMPTT = new MPTT(self::$objCategoryTable, MPTT::mpttAddUnique(new S(__CLASS__), new S((string) $_SERVER['REQUEST_TIME']))); }
public function testFileControllerActions() { $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super'); $this->assertEquals(0, count(FileModel::getAll())); $pathToFiles = Yii::getPathOfAlias('application.modules.zurmo.tests.unit.files'); $filePath = $pathToFiles . DIRECTORY_SEPARATOR . 'testNote.txt'; $contents = file_get_contents($pathToFiles . DIRECTORY_SEPARATOR . 'testNote.txt'); //upload a file $filePath = $pathToFiles . DIRECTORY_SEPARATOR . 'testNote.txt'; self::resetAndPopulateFilesArrayByFilePathAndName('aTest', $filePath, 'testNote.txt'); $this->resetPostArray(); $this->SetGetArray(array('filesVariableName' => 'aTest')); $content = $this->runControllerWithExitExceptionAndGetContent('zurmo/fileModel/upload'); //Confirm the file has actually been uploaded $files = FileModel::getAll(); $compareJsonString = '[{"name":"testNote.txt","type":"text\\/plain","size":"6.34KB","id":' . $files[0]->id . '}]'; $this->assertEquals($compareJsonString, $content); $fileModels = FileModel::getAll(); $this->assertEquals(1, count($fileModels)); $this->assertEquals($contents, $fileModels[0]->fileContent->content); if (!RedBeanDatabase::isFrozen()) { //add fileModel to a model. $model = new ModelWithAttachmentTestItem(); $model->member = 'test'; $model->files->add($fileModels[0]); $this->assertTrue($model->save()); $modelId = $model->id; $model->forget(); //download a file. $this->setGetArray(array('id' => $fileModels[0]->id, 'modelId' => $modelId, 'modelClassName' => 'ModelWithAttachmentTestItem')); $this->resetPostArray(); $content = $this->runControllerWithExitExceptionAndGetContent('zurmo/fileModel/download'); $compareContent = 'Testing download.'; $this->assertEquals($compareContent, $content); } //todo: test all file errors. //Test deleting a file. $this->assertEquals(1, count(FileModel::getAll())); $this->assertEquals(1, count(FileContent::getAll())); $this->setGetArray(array('id' => $fileModels[0]->id)); $this->resetPostArray(); $this->runControllerWithNoExceptionsAndGetContent('zurmo/fileModel/delete', true); //Now confirm that there are no file models or content in the system. $this->assertEquals(0, count(FileModel::getAll())); $this->assertEquals(0, count(FileContent::getAll())); //Test GlobalSearchAutoComplete $this->assertTrue(ContactsModule::loadStartingData()); $this->setGetArray(array('term' => 'something')); $this->resetPostArray(); $content = $this->runControllerWithNoExceptionsAndGetContent('zurmo/default/globalSearchAutoComplete'); $compareContent = '[{"href":"","label":"No results found","iconClass":""}'; // Not Coding Standard $this->assertTrue(strpos($content, $compareContent) !== false); }
public function __construct() { // Construct any possible parent, parse the configuration meanwhile; parent::__construct(); // Tie in common configuration; $this->tieInCommonConfiguration(); // Articles ... self::$objArticleTable = $this->getConfigKey(new S('articles_table')); self::$objArticleTableFId = $this->getConfigKey(new S('articles_table_field_id')); self::$objArticleTableFTitle = $this->getConfigKey(new S('articles_table_field_title')); self::$objArticleTableFSEO = $this->getConfigKey(new S('articles_table_field_seo')); self::$objArticleTableFExcerpt = $this->getConfigKey(new S('articles_table_field_excerpt')); self::$objArticleTableFTags = $this->getConfigKey(new S('articles_table_field_tags')); self::$objArticleTableFContent = $this->getConfigKey(new S('articles_table_field_content')); self::$objArticleTableFDatePublished = $this->getConfigKey(new S('articles_table_field_date_published')); self::$objArticleTableFDateUpdated = $this->getConfigKey(new S('articles_table_field_date_updated')); self::$objArticleTableFState = $this->getConfigKey(new S('articles_table_field_state')); self::$objArticleTableFAuthorId = $this->getConfigKey(new S('articles_table_field_author_id')); self::$objArticleTableFCategoryId = $this->getConfigKey(new S('articles_table_field_category_id')); self::$objArticleTableFCanComment = $this->getConfigKey(new S('articles_table_field_can_comment')); self::$objArticleTableFViews = $this->getConfigKey(new S('articles_table_field_views')); // Comments ... self::$objCommentsTable = $this->getConfigKey(new S('articles_comments_table')); self::$objCommentsTableFId = $this->getConfigKey(new S('articles_comments_table_id')); self::$objCommentsTableFName = $this->getConfigKey(new S('articles_comments_table_name')); self::$objCommentsTableFEML = $this->getConfigKey(new S('articles_comments_table_email')); self::$objCommentsTableFURL = $this->getConfigKey(new S('articles_comments_table_website')); self::$objCommentsTableFRUId = $this->getConfigKey(new S('articles_comments_table_registered_user_id')); self::$objCommentsTableFComment = $this->getConfigKey(new S('articles_comments_table_comment')); self::$objCommentsTableFApproved = $this->getConfigKey(new S('articles_comments_table_approved')); self::$objCommentsTableFDate = $this->getConfigKey(new S('articles_comments_table_date')); self::$objCommentsTableFArticleId = $this->getConfigKey(new S('articles_comments_table_article_id')); // Categories ... self::$objCategoryTable = $this->getConfigKey(new S('articles_category_table')); self::$objCategoryTableFId = $this->getConfigKey(new S('articles_category_table_id')); self::$objCategoryTableFName = $this->getConfigKey(new S('articles_category_table_name')); self::$objCategoryTableFSEO = $this->getConfigKey(new S('articles_category_table_seo')); self::$objCategoryTableFDescription = $this->getConfigKey(new S('articles_category_table_description')); self::$objCategoryTableFDate = $this->getConfigKey(new S('articles_category_table_date')); // Configuration ... self::$objItemsPerPage = $this->getConfigKey(new S('articles_per_page')); // Load'em defaults ... ATH, STG and others ... $this->ATH = MOD::activateModule(new FilePath('mod/authentication'), new B(TRUE)); $this->STG = MOD::activateModule(new FilePath('mod/settings'), new B(TRUE)); // DB: Auto-CREATE: $objQueryDB = new FileContent($this->getPathToModule()->toRelativePath() . _S . CFG_DIR . _S . __CLASS__ . SCH_EXTENSION); // Make a FOREACH on each ... foreach (_S($objQueryDB->toString())->fromStringToArray(RA_SCHEMA_HASH_TAG) as $k => $v) { // Make'em ... $this->_Q(_S($v)); } // Get an MPTT Object, build the ROOT ... self::$objMPTT = new MPTT(self::$objCategoryTable, MPTT::mpttAddUnique(new S(__CLASS__), new S((string) $_SERVER['REQUEST_TIME']))); }
/** * Will return the <html><head><base href=''> container. This method is used by core developers to add the specific container and * <base href=''> tags to the start of the header section of our generated DOM; * * @return S Will return the header container for the current page * @author Catalin Z. Alexandru <*****@*****.**> * @copyright Under the terms of the GNU General Public License v3 * @version $Id: 10_TPL.php 315 2009-10-11 07:11:31Z catalin.zamfir $ * @since Version 1.0 * @access private * @static * @final */ private static final function getHTMLHeadContainer() { // Return the <HTML><head> container; $containerHTMLHead = new FileContent(FORM_TP_DIR . _S . 'frm_web_html_head_container.tp'); return $containerHTMLHead->doToken('[%BASE_HREF_URL%]', DOCUMENT_HOST); }
public function __construct() { // Construct any possible parent, parse the configuration while doing that; parent::__construct(); // Tie in common configuration data; $this->tieInCommonConfiguration(); // Set the proper configuration options for this object; self::$objAuthUsersTable = $this->getConfigKey(new S('authentication_users_table')); self::$objAuthUsersTableFId = $this->getConfigKey(new S('authentication_users_table_field_id')); self::$objAuthUsersTableFUName = $this->getConfigKey(new S('authentication_users_table_field_username')); self::$objAuthUsersTableFUPass = $this->getConfigKey(new S('authentication_users_table_field_password')); self::$objAuthUsersTableFEML = $this->getConfigKey(new S('authentication_users_table_field_email')); self::$objAuthUsersTableFPhone = $this->getConfigKey(new S('authentication_users_table_field_phone')); self::$objAuthUsersTableFFName = $this->getConfigKey(new S('authentication_users_table_field_first_name')); self::$objAuthUsersTableFLName = $this->getConfigKey(new S('authentication_users_table_field_last_name')); self::$objAuthUsersTableFUGId = $this->getConfigKey(new S('authentication_users_table_field_group_id')); self::$objAuthUsersTableFRegOn = $this->getConfigKey(new S('authentication_users_table_field_registered_on')); self::$objAuthUsersTableFLastLog = $this->getConfigKey(new S('authentication_users_table_field_visited_on')); self::$objAuthUsersTableFHash = $this->getConfigKey(new S('authentication_users_table_field_hash')); self::$objAuthUsersTableFActivated = $this->getConfigKey(new S('authentication_users_table_field_activated')); self::$objAuthUsersTableFCountry = $this->getConfigKey(new S('authentication_users_table_field_country')); self::$objAuthUsersTableFSignature = $this->getConfigKey(new S('authentication_users_table_field_signature')); self::$objAuthUsersTableFDesc = $this->getConfigKey(new S('authentication_users_table_field_description')); self::$objAuthUsersTableFYM = $this->getConfigKey(new S('authentication_users_table_field_ym')); self::$objAuthUsersTableFMSN = $this->getConfigKey(new S('authentication_users_table_field_msn')); self::$objAuthUsersTableFICQ = $this->getConfigKey(new S('authentication_users_table_field_icq')); self::$objAuthUsersTableFAOL = $this->getConfigKey(new S('authentication_users_table_field_aol')); self::$objAuthUsersTableFCity = $this->getConfigKey(new S('authentication_users_table_field_city')); self::$objAuthUsersTableFAvatar = $this->getConfigKey(new S('authentication_users_table_field_avatar')); self::$objAuthUsersTableFIp = $this->getConfigKey(new S('authentication_users_table_field_ip')); // Groups ... self::$objAuthGroupTable = $this->getConfigKey(new S('authentication_group_table')); self::$objAuthGroupTableFId = $this->getConfigKey(new S('authentication_group_table_field_id')); self::$objAuthGroupTableFName = $this->getConfigKey(new S('authentication_group_table_field_name')); self::$objAuthGroupTableFSEO = $this->getConfigKey(new S('authentication_group_table_field_seo')); // Zones ... self::$objAuthZonesTable = $this->getConfigKey(new S('authentication_zones_table')); self::$objAuthZonesTableFId = $this->getConfigKey(new S('authentication_zones_table_field_id')); self::$objAuthZonesTableFName = $this->getConfigKey(new S('authentication_zones_table_field_name')); self::$objAuthZonesTableFDesc = $this->getConfigKey(new S('authentication_zones_table_field_description')); self::$objAuthZonesTableFPrice = $this->getConfigKey(new S('authentication_zones_table_field_price')); // Zone mappings ... self::$objAuthZoneMTable = $this->getConfigKey(new S('authentication_gtozm_table')); self::$objAuthZoneMTableFId = $this->getConfigKey(new S('authentication_gtozm_table_field_id')); self::$objAuthZoneMTableFZId = $this->getConfigKey(new S('authentication_gtozm_table_field_zone_id')); self::$objAuthZoneMTableFUGId = $this->getConfigKey(new S('authentication_gtozm_table_field_ug_id')); self::$objAuthZoneMTableFIUG = $this->getConfigKey(new S('authentication_gtozm_table_field_is_group')); self::$objAuthZoneMTableFAorD = $this->getConfigKey(new S('authentication_gtozm_table_field_deny_or_allow')); self::$objAuthZoneMTableFErase = $this->getConfigKey(new S('authentication_gtozm_table_field_eraseable')); // Configuration ... self::$objAuthDefaultGroup = $this->getConfigKey(new S('authentication_default_group')); self::$objAuthDefaultUsername = $this->getConfigKey(new S('authentication_default_admin_username')); self::$objAuthDefaultPassword = $this->getConfigKey(new S('authentication_default_admin_password')); // DB: Auto-CREATE: $objQueryDB = new FileContent($this->getPathToModule()->toRelativePath() . _S . CFG_DIR . _S . __CLASS__ . SCH_EXTENSION); // Make a FOREACH on each ... foreach (_S($objQueryDB->toString())->fromStringToArray(RA_SCHEMA_HASH_TAG) as $k => $v) { // Make'em ... $this->_Q(_S($v)); } // Check non-modified user data, to prevent hackers; if ($this->checkIfUserIsLoggedIn()->toBoolean() == TRUE) { $this->checkIfUserDataIsOK(); } // Get an MPTT Object, build the ROOT, make sure the table is OK; self::$objMPTT = new MPTT(self::$objAuthGroupTable, self::$objAuthDefaultGroup); self::$objMPTTForZones = new MPTT(self::$objAuthZonesTable, $this->getObjectCLASS()); // Load'em defaults ... ATH, STG and others ... $this->STG = MOD::activateModule(new FilePath('mod/settings'), new B(TRUE)); // Check that the default administrator user exists, or create it; $this->setDefaultAdministratorSettings(); // Check to see if this zone exists, and if not, add it; if ($this->checkZoneByName(new S(__CLASS__))->toBoolean() == FALSE) { $this->doMakeZone(new S(__CLASS__), self::$objAuthZonesTableFName); } if ($this->checkAdministratorIsMappedToZone($this->getObjectCLASS())->toBoolean() == FALSE) { $this->doMapAdministratorToZone($this->getObjectCLASS()); } // Do the tie, with myself, just for sub-zones; $this->tieInWithAuthentication($this); }
public function __construct() { // Construct any possible parent, parse the configuration meanwhile; parent::__construct(); // Tie in common configuration data; $this->tieInCommonConfiguration(); // Get object configuration data, and set current object properties; self::$objTextTable = $this->getConfigKey(new S('texts_table')); self::$objTextTableFId = $this->getConfigKey(new S('texts_table_field_id')); self::$objTextTableFTitle = $this->getConfigKey(new S('texts_table_field_title')); self::$objTextTableFSEO = $this->getConfigKey(new S('texts_table_field_seo')); self::$objTextTableFContent = $this->getConfigKey(new S('texts_table_field_content')); self::$objTextTableFTags = $this->getConfigKey(new S('texts_table_field_tags')); self::$objTextTableFCanComment = $this->getConfigKey(new S('texts_table_field_can_comment')); self::$objTextTableFDatePublished = $this->getConfigKey(new S('texts_table_field_date_published')); self::$objTextTableFDateUpdated = $this->getConfigKey(new S('texts_table_field_date_updated')); self::$objTextTableFAuthorId = $this->getConfigKey(new S('texts_table_field_author_id')); self::$objTextTableFCategoryId = $this->getConfigKey(new S('texts_table_field_category_id')); // Categories ... self::$objCategoryTable = $this->getConfigKey(new S('texts_category_table')); self::$objCategoryTableFId = $this->getConfigKey(new S('texts_category_table_id')); self::$objCategoryTableFName = $this->getConfigKey(new S('texts_category_table_name')); self::$objCategoryTableFSEO = $this->getConfigKey(new S('texts_category_table_seo')); // Comments ... self::$objCommentsTable = $this->getConfigKey(new S('texts_comments_table')); self::$objCommentsTableFId = $this->getConfigKey(new S('texts_comments_table_id')); self::$objCommentsTableFName = $this->getConfigKey(new S('texts_comments_table_name')); self::$objCommentsTableFEML = $this->getConfigKey(new S('texts_comments_table_email')); self::$objCommentsTableFURL = $this->getConfigKey(new S('texts_comments_table_website')); self::$objCommentsTableFRUId = $this->getConfigKey(new S('texts_comments_table_registered_user_id')); self::$objCommentsTableFComment = $this->getConfigKey(new S('texts_comments_table_comment')); self::$objCommentsTableFApproved = $this->getConfigKey(new S('texts_comments_table_approved')); self::$objCommentsTableFDate = $this->getConfigKey(new S('texts_comments_table_date')); self::$objCommentsTableFTextId = $this->getConfigKey(new S('texts_comments_table_text_id')); // DB: Auto-CREATE: $objQueryDB = new FileContent($this->getPathToModule()->toRelativePath() . _S . CFG_DIR . _S . __CLASS__ . SCH_EXTENSION); // Make a FOREACH on each ... foreach (_S($objQueryDB->toString())->fromStringToArray(RA_SCHEMA_HASH_TAG) as $k => $v) { // Make'em ... $this->_Q(_S($v)); } // Get an MPTT Object, build the ROOT, make sure the table is OK; self::$objMPTT = new MPTT(self::$objCategoryTable, new S(__CLASS__)); // Load'em defaults ... ATH, STG and others ... $this->ATH = MOD::activateModule(new FilePath('mod/authentication'), new B(TRUE)); $this->STG = MOD::activateModule(new FilePath('mod/settings'), new B(TRUE)); }
/** * @param string $content */ protected function setContent($content) { $content = json_encode($content, JSON_NUMERIC_CHECK | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); parent::setContent($content . PHP_EOL); }
public function testModelWithAttachmentTestItem() { if (!RedBeanDatabase::isFrozen()) { Yii::app()->user->userModel = User::getByUsername('super'); $pathToFiles = Yii::getPathOfAlias('application.modules.zurmo.tests.unit.files'); $filePath = $pathToFiles . DIRECTORY_SEPARATOR . 'testNote.txt'; $model = new ModelWithAttachmentTestItem(); $fileModel = FileModelUtil::makeByFilePathAndName($filePath, 'testNote.txt'); $firstFileModelId = $fileModel->id; $this->assertTrue($fileModel instanceof FileModel); $this->assertEquals(6495, strlen($fileModel->fileContent->content)); $theContent = $fileModel->fileContent->content; $model->files->add($fileModel); $model->member = 'test'; $saved = $model->save(); $this->assertTrue($saved); $modelId = $model->id; $model->forget(); $model = ModelWithAttachmentTestItem::getById($modelId); $this->assertEquals($theContent, $model->files[0]->fileContent->content); $this->assertEquals('testNote.txt', $model->files[0]->name); $this->assertEquals('text/plain', $model->files[0]->type); $this->assertEquals(6495, $model->files[0]->size); //Now try using CUploadedFile. self::resetAndPopulateFilesArrayByFilePathAndName('aTest', $filePath, 'testNote.txt'); $uploadedFile = CUploadedFile::getInstanceByName('aTest'); $this->assertTrue($uploadedFile instanceof CUploadedFile); $fileModel = FileModelUtil::makeByUploadedFile($uploadedFile); $this->assertTrue($fileModel instanceof FileModel); $this->assertTrue($fileModel->id != $firstFileModelId); $this->assertTrue($fileModel->id > 0); $model = ModelWithAttachmentTestItem::getById($modelId); $model->files->add($fileModel); $saved = $model->save(); $this->assertTrue($saved); $modelId = $model->id; $model->forget(); $model = ModelWithAttachmentTestItem::getById($modelId); $this->assertEquals(2, $model->files->count()); //Delete the model and confirm the related models are removed $this->assertEquals(1, count(ModelWithAttachmentTestitem::getAll())); $this->assertEquals(2, count(FileModel::getAll())); $this->assertEquals(2, count(FileContent::getAll())); $model->delete(); $this->assertEquals(0, count(ModelWithAttachmentTestitem::getAll())); $this->assertEquals(0, count(FileModel::getAll())); $this->assertEquals(0, count(FileContent::getAll())); } }
/** * Will execute necessary SQL operations on the current form ... * * This method, setSQLOperationsOnForm, you don't need to know the internal workings of it. This is because, as you can see * it is a private method, and thus, it's used internally by the class, to achieve it's goals of execution. Just pass on * and read any other 'public' or 'protected' method out there ... * * @param array $inputAttributes The core attributes (found in every HTML element) that can be set; * @param string $tp The path to the .tp file where to set those variables; */ private static function setCoreInputAttributes(A $inputAttributes, &$tp) { $coreSetAttributes = new A(); foreach ($inputAttributes as $k => $v) { switch ($k) { case 'reg_javascript_replace': // On Key Pressed ... $jssTpPath = new FileContent(FORM_TP_DIR . _S . JAVASCRIPT_DIR . _S . 'checkKeyEvent.js'); $coreSetAttributes['onkeypress'] = $jssTpPath->doToken('[%REPLACE_VALUE_EVENT%]', $v); // On Lost Focus ... $jssTpPath = new FileContent(FORM_TP_DIR . _S . JAVASCRIPT_DIR . _S . 'checkKeyEventRegExp.js'); $coreSetAttributes['onblur'] = $jssTpPath->doToken('[%REGEXP_REPLACE_JS%]', $v); self::manageJSS(new FilePath(FORM_TP_DIR . _WS . JAVASCRIPT_DIR . _WS . 'checkKey.js'), new S('RA_checkKey')); break; default: $coreSetAttributes[$k] = $v; break; } } self::tpSet($coreSetAttributes, new S('coreSetAttributes'), $tp, new S('explode')); }
public function testMakeByExistingFileModelIdWithoutSharedContent() { $oldFileContentsCount = FileContent::getCount(); $file1 = ZurmoTestHelper::createFileModel('testNote.txt'); $file2 = FileModelUtil::makeByExistingFileModelId($file1->id, false); $this->assertTrue($file2 !== false); $this->assertEquals($file1->name, $file2->name); $this->assertEquals($file1->type, $file2->type); $this->assertEquals($file1->size, $file2->size); $this->assertEquals($file1->fileContent->content, $file2->fileContent->content); // fileContent should be replicated as we explicitly passed false to sharedContent $this->assertNotEquals($file1->fileContent->id, $file2->fileContent->id); $this->assertEquals($oldFileContentsCount + 2, FileContent::getCount()); }
/** * @param string $filename * @param string $kernel_filename */ public function __construct($filename, $kernel_filename) { parent::__construct($filename); $this->kernel_filename = $kernel_filename; }
/** * Will return the string made by parsing a .tp file, and replacing tokens. This method wil actually replace the tokens in the * framework error-screen template file. This will help us output debugged code to the developer so we can help him quickly find * the error he was looking for; * * @param A (native) $debugArray The debug array to be parsed * @return S (native) The array, parsed as an error screen string * @author Catalin Z. Alexandru <*****@*****.**> * @copyright Under the terms of the GNU General Public License v3 * @version $Id: 08_ERR.php 313 2009-10-09 13:27:52Z catalin.zamfir $ * @since Version 1.0 * @access private * @static */ private static function getDebugBacktrace($debugArray) { # Set the errorString, to be returned; $errorString = _NONE; foreach ($debugArray as $k => $v) { # Declare some __CODE__ variables; $codeFile = _NONE; $codeLine = 0; $debugContent = new FileContent(FORM_TP_DIR . _S . 'frm_error_debug.tp'); if (isset($debugArray[$k]['file'])) { # Replace [%FILE%] with the one given in the backtrace; $debugContent->doToken('[%FILE%]', $codeFile = str_replace(DOCUMENT_ROOT, _NONE, $debugArray[$k]['file'])); } else { # Else, determine the current __FILE__, and output something; $debugContent->doToken('[%FILE%]', $codeFile = str_replace(DOCUMENT_ROOT, _NONE, __FILE__)); } if (isset($debugArray[$k]['line'])) { # Replace [%LINE%] with the one given in the backtrace; $debugContent->doToken('[%LINE%]', $codeLine = $debugArray[$k]['line']); } else { # Set it to LINE: 20, almost near the declaration of our classes; $debugContent->doToken('[%LINE%]', $codeLine = 20); } if (isset($debugArray[$k]['class'])) { # Replace [%CLASS%] with the one in the backtrace; $debugContent->doToken('[%CLASS%]', $debugArray[$k]['class']); } else { # Set it to [no __CLASS__] ... $debugContent->doToken('[%CLASS%]', '[no __CLASS__]'); } if (isset($debugArray[$k]['function'])) { $debugContent->doToken('[%METHOD%]', $debugArray[$k]['function']); } else { $debugContent->doToken('[%METHOD%]', '[no __METHOD__]'); } # Replace [%CODE%] from error file; $debugContent->doToken('[%CODE%]', self::getDebugCode(new S($codeFile), new I($codeLine))); $debugContent->doToken('[%ID%]', $k); $errorString .= $debugContent; } # After the foreach, return the concatenated error screen; return $errorString; }
public function testFileContentModelNotBeingCached() { $fileContent = new FileContent(); $fileContent->content = str_repeat('a', 1000); $this->assertTrue($fileContent->save()); $modelIdentifier = $fileContent->getModelIdentifier(); RedBeanModelsCache::cacheModel($fileContent); try { RedBeanModelsCache::getModel($modelIdentifier); } catch (NotFoundException $e) { $this->fail('NotFoundException exception is thrown.'); } $prefix = RedBeanModelsCache::getCachePrefix($modelIdentifier, RedBeanModelsCache::$cacheType); $cachedData = false; if (isset(Yii::app()->cache)) { $cachedData = Yii::app()->cache->get($prefix . $modelIdentifier); } $this->assertFalse($cachedData); }
public function __construct() { // Construct any possible parent, parse the configuration meanwhile; parent::__construct(); // Tie in common configuration data; $this->tieInCommonConfiguration(); // Get the confiuration data ... self::$objAudioTable = $this->getConfigKey(new S('audio_table')); self::$objAudioTableFId = $this->getConfigKey(new S('audio_table_field_id')); self::$objAudioTableFFile = $this->getConfigKey(new S('audio_table_field_file')); self::$objAudioTableFArtwork = $this->getConfigKey(new S('audio_table_field_artwork')); self::$objAudioTableFTitle = $this->getConfigKey(new S('audio_table_field_title')); self::$objAudioTableFSEO = $this->getConfigKey(new S('audio_table_field_seo')); self::$objAudioTableFArtist = $this->getConfigKey(new S('audio_table_field_artist')); self::$objAudioTableFAlbum = $this->getConfigKey(new S('audio_table_field_album')); self::$objAudioTableFLyrics = $this->getConfigKey(new S('audio_table_field_lyrics')); self::$objAudioTableFDescription = $this->getConfigKey(new S('audio_table_field_description')); self::$objAudioTableFUploadedDate = $this->getConfigKey(new S('audio_table_field_date_uploaded')); self::$objAudioTableFUploaderId = $this->getConfigKey(new S('audio_table_field_uploader_id')); self::$objAudioTableFCategoryId = $this->getConfigKey(new S('audio_table_field_category_id')); self::$objAudioTableFApproved = $this->getConfigKey(new S('audio_table_field_approved')); self::$objAudioTableFCanComment = $this->getConfigKey(new S('audio_table_field_can_comment')); self::$objAudioTableFViews = $this->getConfigKey(new S('audio_table_field_views')); // Comments ... self::$objCommentsTable = $this->getConfigKey(new S('audio_comments_table')); self::$objCommentsTableFId = $this->getConfigKey(new S('audio_comments_table_id')); self::$objCommentsTableFName = $this->getConfigKey(new S('audio_comments_table_name')); self::$objCommentsTableFEML = $this->getConfigKey(new S('audio_comments_table_email')); self::$objCommentsTableFURL = $this->getConfigKey(new S('audio_comments_table_website')); self::$objCommentsTableFRUId = $this->getConfigKey(new S('audio_comments_table_registered_user_id')); self::$objCommentsTableFComment = $this->getConfigKey(new S('audio_comments_table_comment')); self::$objCommentsTableFApproved = $this->getConfigKey(new S('audio_comments_table_approved')); self::$objCommentsTableFDate = $this->getConfigKey(new S('audio_comments_table_date')); self::$objCommentsTableFAudioFileId = $this->getConfigKey(new S('audio_comments_table_audio_file_id')); // Categories ... self::$objCategoryTable = $this->getConfigKey(new S('audio_category_table')); self::$objCategoryTableFId = $this->getConfigKey(new S('audio_category_table_id')); self::$objCategoryTableFName = $this->getConfigKey(new S('audio_category_table_name')); self::$objCategoryTableFSEO = $this->getConfigKey(new S('audio_category_table_seo')); self::$objCategoryTableFDescription = $this->getConfigKey(new S('audio_category_table_description')); self::$objCategoryTableFDate = $this->getConfigKey(new S('audio_category_table_date')); // Configuration ... self::$objItemsPerPage = $this->getConfigKey(new S('audio_settings_audio_items_per_page')); // Load'em defaults ... ATH, STG and others ... $this->ATH = MOD::activateModule(new FilePath('mod/authentication'), new B(TRUE)); $this->STG = MOD::activateModule(new FilePath('mod/settings'), new B(TRUE)); // DB: Auto-CREATE: $objQueryDB = new FileContent($this->getPathToModule()->toRelativePath() . _S . CFG_DIR . _S . __CLASS__ . SCH_EXTENSION); // Make a FOREACH on each ... foreach (_S($objQueryDB->toString())->fromStringToArray(RA_SCHEMA_HASH_TAG) as $k => $v) { // Make'em ... $this->_Q(_S($v)); } // Get an MPTT Object, build the ROOT, make sure the table is OK; self::$objMPTT = new MPTT(self::$objCategoryTable, MPTT::mpttAddUnique(new S(__CLASS__), new S((string) $_SERVER['REQUEST_TIME']))); // Get some JSS data ... $this->objPathToSkinJSS = $this->getPathToSkinJSS()->toRelativePath(); $this->objPathToSkinCSS = $this->getPathToSkinCSS()->toRelativePath(); // CALL them specific TPL methods, add JSS & CSS to page <head'er ... TPL::manageJSS(new FilePath($this->objPathToSkinJSS . self::AUDIO_PLAYER_JS_PATH), new S(self::AUDIO_PLAYER_JS_STRING)); }
/** * Will do a __CALL to some one-liner methods; * * We thought, that for the moment performance is not an issue, and we made it so that these virtual methods are called * using the PHP __call method, just to save some space, and to have a clearer code beyond this scope; * * @param string $objFunctionName The name of the called function; * @param array $objFunctionArgs The function arguments; * @return mixed Can return anything; */ public function __CALL($objFunctionName, $objFunctionArgs) { switch ($objFunctionName) { case 'getPathToModule': // Do return ... return $this->objPathToModule; break; case 'getPathToAdmin': // Do return ... return $this->objPathToAdmin; break; case 'getPathToSkin': // Do return ... return $this->objPathToSkin; break; case 'getPathToLanguage': // Do return ... return $this->objPathToLang; break; case 'getPathToSkinCSS': // Do return ... return new FilePath($this->objPathToSkin->toRelativePath() . SKIN_CSS_DIR . _S); break; case 'getPathToSkinJSS': // Do return ... return new FilePath($this->objPathToSkin->toRelativePath() . SKIN_JSS_DIR . _S); break; case 'getPathToSkinIMG': // Do return ... return new FilePath($this->objPathToSkin->toRelativePath() . SKIN_IMG_DIR . _S); break; case 'getHELP': // Set some requirements ... $objFileContent = new FileContent($this->getPathToLanguage()->toRelativePath() . $objFunctionArgs[0] . HLP_EXTENSION); // Do return ... return new S($objFileContent->toString()); break; } }
public static function saveLogoFile($fileName, $filePath, $fileModelIdentifier) { if (ZurmoConfigurationUtil::getByModuleName('ZurmoModule', $fileModelIdentifier) !== null) { $fileModelId = ZurmoConfigurationUtil::getByModuleName('ZurmoModule', $fileModelIdentifier); $file = FileModel::getById($fileModelId); $fileContent = FileContent::getById($file->fileContent->id); $contents = file_get_contents($filePath); $fileContent->content = $contents; $file->fileContent = $fileContent; $file->name = $fileName; $file->type = ZurmoFileHelper::getMimeType($filePath); $file->size = filesize($filePath); $saved = $file->save(); return $file->id; } else { $contents = file_get_contents($filePath); $fileContent = new FileContent(); $fileContent->content = $contents; $file = new FileModel(); $file->fileContent = $fileContent; $file->name = $fileName; $file->type = ZurmoFileHelper::getMimeType($filePath); $file->size = filesize($filePath); $saved = $file->save(); return $file->id; } }