This is the API documentation for concrete5 version 5.6 and earlier. View Current API Documentation
  1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  39  40  41  42  43  44  45  46  47  48  49  50  51  52  53  54  55  56  57  58  59  60  61  62  63  64  65  66  67  68  69  70  71  72  73  74  75  76  77  78  79  80  81  82  83  84  85  86  87  88  89  90  91  92  93  94  95  96  97  98  99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 
<?php
/**
 * @access private
 * @package Helpers
 * @category Concrete
 * @author Andrew Embler <[email protected]>
 * @copyright  Copyright (c) 2003-2008 Concrete5. (http://www.concrete5.org)
 * @license    http://www.concrete5.org/license/     MIT License
 */

/**
 * @access private
 * @package Helpers
 * @category Concrete
 * @author Andrew Embler <[email protected]>
 * @copyright  Copyright (c) 2003-2008 Concrete5. (http://www.concrete5.org)
 * @license    http://www.concrete5.org/license/     MIT License
 */

defined('C5_EXECUTE') or die("Access Denied.");
class ConcreteUpgradeVersion520Helper {
    
    public function prepare() {
        $db = Loader::db();
        $columns = $db->MetaColumns('PagePaths');
        if ($columns['PPID'] == false) {

            $db->Execute('alter table PagePaths change cID ppID int unsigned not null auto_increment');
            $db->Execute('alter table PagePaths add column cID int unsigned not null default 0');
            $db->Execute('update PagePaths set cID = ppID');

        }
        
        $columns = $db->MetaColumns('btFormQuestions');
        if ($columns['QID'] == false) {
            try{
                $db->query('ALTER TABLE btFormQuestions CHANGE msqID msqID INT(11) UNSIGNED NOT NULL '); 
                $db->query('ALTER TABLE btFormQuestions DROP PRIMARY KEY'); 
            }catch(Exception $e){ }
            try{
                $db->query('ALTER TABLE btFormQuestions ADD qID INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY ');             
            }catch(Exception $e){ } 

        }

        $columns = $db->MetaColumns('btSlideshowImg');
        if ($columns['FID'] == false && $columns['IMAGE_BID'] != false) {
            try{
                $db->query('ALTER TABLE btSlideshowImg CHANGE image_bID fID INT(11) unsigned null'); 
            }catch(Exception $e){ } 
        }
    }
    
    public function run() {
        $db = Loader::db();
        $tables = $db->MetaTables('TABLES');

        if (in_array('btFormQuestions', $tables)) {
            
            //$db->CacheFlush();
            //$db->setDebug(true);

            $questionsWithBIDs=$db->getAll('SELECT max(bID) AS bID, btForm.questionSetId AS qSetId FROM `btForm` GROUP BY questionSetId');
            foreach($questionsWithBIDs as $questionsWithBID){
                $vals=array( intval($questionsWithBID['bID']), intval($questionsWithBID['qSetId']) );
                $rs=$db->query('UPDATE btFormQuestions SET bID=? WHERE questionSetId=? AND bID=0',$vals);  
            }
        }
        
        // now we populate files
        $num = $db->GetOne("select count(*) from Files");
        if ($num < 1) {
            $r = $db->Execute("select btFile.*, Blocks.bDateAdded from btFile inner join Blocks on btFile.bID = Blocks.bID");
            while ($row = $r->fetchRow()) {
                $v = array($row['bID'], 1, $row['filename'], null, '', $row['origfilename'], $row['bDateAdded']);
                $db->Execute("insert into FileVersions (fID, fvID, fvFilename, fvPrefix, fvExtension, fvTitle, fvDateAdded) values (?, ?, ?, ?, ?, ?, ?)", $v); 
                $db->Execute("insert into Files (fID, fDateAdded) values (?, ?)", array($row['bID'], $row['bDateAdded']));
            }
        }

        Loader::model('single_page');
        // Rename Forms to Reports
        $p = Page::getByPath('/dashboard/mediabrowser');
        if (!$p->isError()) {
            $p->delete();
        }

        $p = Page::getByPath('/dashboard/files');
        if ($p->isError()) {
            $d2 = SinglePage::add('/dashboard/files');
            $d2a = SinglePage::add('/dashboard/files/search');
            $d2b = SinglePage::add('/dashboard/files/attributes');
            $d2c = SinglePage::add('/dashboard/files/sets');
            $d2d = SinglePage::add('/dashboard/files/access');                      
            $d2->update(array('cName'=>t('File Manager'), 'cDescription'=>t('All documents and images.')));
            $d3b = SinglePage::add('/dashboard/reports/surveys');
        }

        $p = Page::getByPath('/dashboard/scrapbook');
        if ($p->isError()) {
            $d3 = SinglePage::add('/dashboard/scrapbook');
            $d3b = SinglePage::add('/dashboard/scrapbook/user');
            $d3a = SinglePage::add('/dashboard/scrapbook/global');
            $d3->update(array('cName'=>t('Scrapbook'), 'cDescription'=>t('Share content across your site.')));
        }
            
        Loader::model('file_set');
        Loader::model('groups');
        
        $htbt = BlockType::getByHandle('html');
        if (!is_object($htbt)) {
            BlockType::installBlockType('html');            
        }
        
        $g1 = Group::getByID(GUEST_GROUP_ID);
        $g2 = Group::getByID(REGISTERED_GROUP_ID);
        $g3 = Group::getByID(ADMIN_GROUP_ID);
        
        $fs = FileSet::getGlobal();
        $fs->setPermissions($g1, FilePermissions::PTYPE_NONE, FilePermissions::PTYPE_ALL, FilePermissions::PTYPE_NONE, FilePermissions::PTYPE_NONE, FilePermissions::PTYPE_NONE);
        $fs->setPermissions($g2, FilePermissions::PTYPE_NONE, FilePermissions::PTYPE_ALL, FilePermissions::PTYPE_NONE, FilePermissions::PTYPE_NONE, FilePermissions::PTYPE_NONE);
        $fs->setPermissions($g3, FilePermissions::PTYPE_ALL, FilePermissions::PTYPE_ALL, FilePermissions::PTYPE_ALL, FilePermissions::PTYPE_ALL, FilePermissions::PTYPE_ALL);


        $p = Page::getByPath('/dashboard/reports/surveys');
        if ($p->isError()) {
            $p = SinglePage::add('/dashboard/reports/surveys');
        }
    }
    
}