コード例 #1
0
ファイル: upgrade-all.php プロジェクト: himanshu12k/ce-www
function db_upgrade_all($oldversion)
{
    /// This function does anything necessary to upgrade
    /// older versions to match current functionality
    global $modifyoutput, $dbprefix, $usertemplaterootdir, $standardtemplaterootdir, $clang;
    echo str_pad($clang->gT('The LimeSurvey database is being upgraded') . ' (' . date('Y-m-d H:i:s') . ')', 14096) . "." . $clang->gT('Please be patient...') . "<br /><br />\n";
    if ($oldversion < 143) {
        // Move all user templates to the new user template directory
        echo sprintf($clang->gT("Moving user templates to new location at %s..."), $usertemplaterootdir) . "<br />";
        $myDirectory = opendir($standardtemplaterootdir);
        $aFailedTemplates = array();
        // get each entry
        while ($entryName = readdir($myDirectory)) {
            if (!in_array($entryName, array('.', '..', '.svn')) && is_dir($standardtemplaterootdir . DIRECTORY_SEPARATOR . $entryName) && !isStandardTemplate($entryName)) {
                if (!rename($standardtemplaterootdir . DIRECTORY_SEPARATOR . $entryName, $usertemplaterootdir . DIRECTORY_SEPARATOR . $entryName)) {
                    $aFailedTemplates[] = $entryName;
                }
            }
        }
        if (count($aFailedTemplates) > 0) {
            echo "The following templates at {$standardtemplaterootdir} could not be moved to the new location at {$usertemplaterootdir}:<br /><ul>";
            foreach ($aFailedTemplates as $sFailedTemplate) {
                echo "<li>{$sFailedTemplate}</li>";
            }
            echo "</ul>Please move these templates manually after the upgrade has finished.<br />";
        }
        // close directory
        closedir($myDirectory);
    }
}
コード例 #2
0
function gettemplatelist($usertemplaterootdir, $standardtemplates, $standardtemplaterootdir)
{
    #global $usertemplatierootdir, $standardtemplates,$standardtemplaterootdir;
    if (!$usertemplaterootdir) {
        die("gettemplatelist() no template directory");
    }
    if ($handle = opendir($standardtemplaterootdir)) {
        while (false !== ($file = readdir($handle))) {
            if (!is_file("{$standardtemplaterootdir}/{$file}") && $file != "." && $file != ".." && $file != ".svn" && isStandardTemplate($file)) {
                $list_of_files[$file] = $standardtemplaterootdir . DIRECTORY_SEPARATOR . $file;
            }
        }
        closedir($handle);
    }
    if ($handle = opendir($usertemplaterootdir)) {
        while (false !== ($file = readdir($handle))) {
            if (!is_file("{$usertemplaterootdir}/{$file}") && $file != "." && $file != ".." && $file != ".svn") {
                $list_of_files[$file] = $usertemplaterootdir . DIRECTORY_SEPARATOR . $file;
            }
        }
        closedir($handle);
    }
    if (!empty($list_of_files)) {
        ksort($list_of_files);
    }
    return $list_of_files;
}
コード例 #3
0
 /**
  * Function responsible to rename a template(folder).
  *
  * @access public
  * @return void
  */
 public function templaterename()
 {
     if (!Permission::model()->hasGlobalPermission('templates', 'update')) {
         die('No permission');
     }
     if (returnGlobal('action') == "templaterename" && returnGlobal('newname') && returnGlobal('copydir')) {
         $clang = Yii::app()->lang;
         $sOldName = sanitize_dirname(returnGlobal('copydir'));
         $sNewName = sanitize_dirname(returnGlobal('newname'));
         $sNewDirectoryPath = Yii::app()->getConfig('usertemplaterootdir') . "/" . $sNewName;
         $sOldDirectoryPath = Yii::app()->getConfig('usertemplaterootdir') . "/" . returnGlobal('copydir');
         if (isStandardTemplate(returnGlobal('newname'))) {
             $this->getController()->error(sprintf($clang->gT("Template could not be renamed to `%s`.", "js"), $sNewName) . " " . $clang->gT("This name is reserved for standard template.", "js"));
         } elseif (file_exists($sNewDirectoryPath)) {
             $this->getController()->error(sprintf($clang->gT("Template could not be renamed to `%s`.", "js"), $sNewName) . " " . $clang->gT("A template with that name already exists.", "js"));
         } elseif (rename($sOldDirectoryPath, $sNewDirectoryPath) == false) {
             $this->getController()->error(sprintf($clang->gT("Template could not be renamed to `%s`.", "js"), $sNewName) . " " . $clang->gT("Maybe you don't have permission.", "js"));
         } else {
             Survey::model()->updateAll(array('template' => $sNewName), "template = :oldname", array(':oldname' => $sOldName));
             if (getGlobalSetting('defaulttemplate') == $sOldName) {
                 setGlobalSetting('defaulttemplate', $sNewName);
             }
             $this->index("startpage.pstpl", "welcome", $sNewName);
         }
     }
 }
コード例 #4
0
function upgradeTables143()
{
    global $modifyoutput;
    $aQIDReplacements = array();
    $answerquery = "select a.*, q.sid, q.gid from {{answers}} a,{{questions}} q where a.qid=q.qid and q.type in ('L','O','!') and a.default_value='Y'";
    $answerresult = Yii::app()->getDb()->createCommand($answerquery)->queryAll();
    foreach ($answerresult as $row) {
        modifyDatabase("", "INSERT INTO {{defaultvalues}} (qid, scale_id,language,specialtype,defaultvalue) VALUES ({$row['qid']},0," . dbQuoteAll($row['language']) . ",''," . dbQuoteAll($row['code']) . ")");
        echo $modifyoutput;
        flush();
        @ob_flush();
    }
    // Convert answers to subquestions
    $answerquery = "select a.*, q.sid, q.gid, q.type from {{answers}} a,{{questions}} q where a.qid=q.qid and a.language=q.language and q.type in ('1','A','B','C','E','F','H','K',';',':','M','P','Q')";
    $answerresult = Yii::app()->getDb()->createCommand($answerquery)->queryAll();
    foreach ($answerresult as $row) {
        $aInsert = array();
        if (isset($aQIDReplacements[$row['qid'] . '_' . $row['code']])) {
            $aInsert['qid'] = $aQIDReplacements[$row['qid'] . '_' . $row['code']];
        }
        $aInsert['sid'] = $row['sid'];
        $aInsert['gid'] = $row['gid'];
        $aInsert['parent_qid'] = $row['qid'];
        $aInsert['type'] = $row['type'];
        $aInsert['title'] = $row['code'];
        $aInsert['question'] = $row['answer'];
        $aInsert['question_order'] = $row['sortorder'];
        $aInsert['language'] = $row['language'];
        $iLastInsertID = Question::model()->insertRecords($aInsert);
        if (!isset($aInsert['qid'])) {
            $aQIDReplacements[$row['qid'] . '_' . $row['code']] = $iLastInsertID;
            $iSaveSQID = $aQIDReplacements[$row['qid'] . '_' . $row['code']];
        } else {
            $iSaveSQID = $aInsert['qid'];
        }
        if (($row['type'] == 'M' || $row['type'] == 'P') && $row['default_value'] == 'Y') {
            modifyDatabase("", "INSERT INTO {{defaultvalues}} (qid, sqid, scale_id,language,specialtype,defaultvalue) VALUES ({$row['qid']},{$iSaveSQID},0," . dbQuoteAll($row['language']) . ",'','Y')");
            echo $modifyoutput;
            flush();
            @ob_flush();
        }
    }
    // Sanitize data
    if (Yii::app()->db->driverName == 'pgsql') {
        modifyDatabase("", "delete from {{answers}} USING {{questions}} WHERE {{answers}}.qid={{questions}}.qid AND {{questions}}.type in ('1','F','H','M','P','W','Z')");
        echo $modifyoutput;
        flush();
        @ob_flush();
    } else {
        modifyDatabase("", "delete {{answers}} from {{answers}} LEFT join {{questions}} ON {{answers}}.qid={{questions}}.qid where {{questions}}.type in ('1','F','H','M','P','W','Z')");
        echo $modifyoutput;
        flush();
        @ob_flush();
    }
    // Convert labels to answers
    $answerquery = "select qid ,type ,lid ,lid1, language from {{questions}} where parent_qid=0 and type in ('1','F','H','M','P','W','Z')";
    $answerresult = Yii::app()->getDb()->createCommand($answerquery)->queryAll();
    foreach ($answerresult as $row) {
        $labelquery = "Select * from {{labels}} where lid={$row['lid']} and language=" . dbQuoteAll($row['language']);
        $labelresult = Yii::app()->getDb()->createCommand($labelquery)->queryAll();
        foreach ($labelresult as $lrow) {
            modifyDatabase("", "INSERT INTO {{answers}} (qid, code, answer, sortorder, language, assessment_value) VALUES ({$row['qid']}," . dbQuoteAll($lrow['code']) . "," . dbQuoteAll($lrow['title']) . ",{$lrow['sortorder']}," . dbQuoteAll($lrow['language']) . ",{$lrow['assessment_value']})");
            echo $modifyoutput;
            flush();
            @ob_flush();
            //$labelids[]
        }
        if ($row['type'] == '1') {
            $labelquery = "Select * from {{labels}} where lid={$row['lid1']} and language=" . dbQuoteAll($row['language']);
            $labelresult = Yii::app()->getDb()->createCommand($labelquery)->queryAll();
            foreach ($labelresult as $lrow) {
                modifyDatabase("", "INSERT INTO {{answers}} (qid, code, answer, sortorder, language, scale_id, assessment_value) VALUES ({$row['qid']}," . dbQuoteAll($lrow['code']) . "," . dbQuoteAll($lrow['title']) . ",{$lrow['sortorder']}," . dbQuoteAll($lrow['language']) . ",1,{$lrow['assessment_value']})");
                echo $modifyoutput;
                flush();
                @ob_flush();
            }
        }
    }
    // Convert labels to subquestions
    $answerquery = "select * from {{questions}} where parent_qid=0 and type in (';',':')";
    $answerresult = Yii::app()->getDb()->createCommand($answerquery)->queryAll();
    foreach ($answerresult as $row) {
        $labelquery = "Select * from {{labels}} where lid={$row['lid']} and language=" . dbQuoteAll($row['language']);
        $labelresult = Yii::app()->getDb()->createCommand($labelquery)->queryAll();
        foreach ($labelresult as $lrow) {
            $aInsert = array();
            if (isset($aQIDReplacements[$row['qid'] . '_' . $lrow['code'] . '_1'])) {
                $aInsert['qid'] = $aQIDReplacements[$row['qid'] . '_' . $lrow['code'] . '_1'];
            }
            $aInsert['sid'] = $row['sid'];
            $aInsert['gid'] = $row['gid'];
            $aInsert['parent_qid'] = $row['qid'];
            $aInsert['type'] = $row['type'];
            $aInsert['title'] = $lrow['code'];
            $aInsert['question'] = $lrow['title'];
            $aInsert['question_order'] = $lrow['sortorder'];
            $aInsert['language'] = $lrow['language'];
            $aInsert['scale_id'] = 1;
            $iLastInsertID = Question::model()->insertRecords($aInsert);
            if (isset($aInsert['qid'])) {
                $aQIDReplacements[$row['qid'] . '_' . $lrow['code'] . '_1'] = $iLastInsertID;
            }
        }
    }
    $updatequery = "update {{questions}} set type='!' where type='W'";
    modifyDatabase("", $updatequery);
    echo $modifyoutput;
    flush();
    @ob_flush();
    $updatequery = "update {{questions}} set type='L' where type='Z'";
    modifyDatabase("", $updatequery);
    echo $modifyoutput;
    flush();
    @ob_flush();
    // Now move all non-standard templates to the /upload dir
    $usertemplaterootdir = Yii::app()->getConfig("usertemplaterootdir");
    $standardtemplaterootdir = Yii::app()->getConfig('standardtemplaterootdir');
    if (!$usertemplaterootdir) {
        die("getTemplateList() no template directory");
    }
    if ($handle = opendir($standardtemplaterootdir)) {
        while (false !== ($file = readdir($handle))) {
            if (!is_file("{$standardtemplaterootdir}/{$file}") && $file != "." && $file != ".." && $file != ".svn" && !isStandardTemplate($file)) {
                if (!rename($standardtemplaterootdir . DIRECTORY_SEPARATOR . $file, $usertemplaterootdir . DIRECTORY_SEPARATOR . $file)) {
                    echo "There was a problem moving directory '" . $standardtemplaterootdir . DIRECTORY_SEPARATOR . $file . "' to '" . $usertemplaterootdir . DIRECTORY_SEPARATOR . $file . "' due to missing permissions. Please do this manually.<br />";
                }
            }
        }
        closedir($handle);
    }
}
コード例 #5
0
function upgrade_tables143()
{
    global $modifyoutput, $dbprefix, $connect;
    $aQIDReplacements = array();
    $answerquery = "select a.*, q.sid, q.gid from {$dbprefix}answers a,{$dbprefix}questions q where a.qid=q.qid and q.type in ('L','O','!') and a.default_value='Y'";
    $answerresult = db_execute_assoc($answerquery);
    if (!$answerresult) {
        return "Database Error";
    } else {
        while ($row = $answerresult->FetchRow()) {
            modify_database("", "INSERT INTO {$dbprefix}defaultvalues (qid, scale_id,language,specialtype,defaultvalue) VALUES ({$row['qid']},0," . db_quoteall($row['language']) . ",''," . db_quoteall($row['code']) . ")");
            echo $modifyoutput;
            flush();
            ob_flush();
        }
    }
    // Convert answers to subquestions
    $answerquery = "select a.*, q.sid, q.gid, q.type from {$dbprefix}answers a,{$dbprefix}questions q where a.qid=q.qid and a.language=q.language and q.type in ('1','A','B','C','E','F','H','K',';',':','M','P','Q')";
    $answerresult = db_execute_assoc($answerquery);
    if (!$answerresult) {
        return "Database Error";
    } else {
        while ($row = $answerresult->FetchRow()) {
            $insertarray = array();
            if (isset($aQIDReplacements[$row['qid'] . '_' . $row['code']])) {
                $insertarray['qid'] = $aQIDReplacements[$row['qid'] . '_' . $row['code']];
                db_switchIDInsert('questions', true);
            }
            $insertarray['sid'] = $row['sid'];
            $insertarray['gid'] = $row['gid'];
            $insertarray['parent_qid'] = $row['qid'];
            $insertarray['type'] = $row['type'];
            $insertarray['title'] = $row['code'];
            $insertarray['question'] = $row['answer'];
            $insertarray['question_order'] = $row['sortorder'];
            $insertarray['language'] = $row['language'];
            $tablename = "{$dbprefix}questions";
            $query = $connect->GetInsertSQL($tablename, $insertarray);
            modify_database("", $query);
            echo $modifyoutput;
            flush();
            ob_flush();
            if (!isset($insertarray['qid'])) {
                $aQIDReplacements[$row['qid'] . '_' . $row['code']] = $connect->Insert_ID("{$dbprefix}questions", "qid");
                $iSaveSQID = $aQIDReplacements[$row['qid'] . '_' . $row['code']];
            } else {
                $iSaveSQID = $insertarray['qid'];
                db_switchIDInsert('questions', false);
            }
            if (($row['type'] == 'M' || $row['type'] == 'P') && $row['default_value'] == 'Y') {
                modify_database("", "INSERT INTO {$dbprefix}defaultvalues (qid, sqid, scale_id,language,specialtype,defaultvalue) VALUES ({$row['qid']},{$iSaveSQID},0," . db_quoteall($row['language']) . ",'','Y')");
                echo $modifyoutput;
                flush();
                ob_flush();
            }
        }
    }
    modify_database("", "delete {$dbprefix}answers from {$dbprefix}answers LEFT join {$dbprefix}questions ON {$dbprefix}answers.qid={$dbprefix}questions.qid where {$dbprefix}questions.type in ('1','F','H','M','P','W','Z')");
    echo $modifyoutput;
    flush();
    ob_flush();
    // Convert labels to answers
    $answerquery = "select qid ,type ,lid ,lid1, language from {$dbprefix}questions where parent_qid=0 and type in ('1','F','H','M','P','W','Z')";
    $answerresult = db_execute_assoc($answerquery);
    if (!$answerresult) {
        return "Database Error";
    } else {
        while ($row = $answerresult->FetchRow()) {
            $labelquery = "Select * from {$dbprefix}labels where lid={$row['lid']} and language=" . db_quoteall($row['language']);
            $labelresult = db_execute_assoc($labelquery);
            while ($lrow = $labelresult->FetchRow()) {
                modify_database("", "INSERT INTO {$dbprefix}answers (qid, code, answer, sortorder, language, assessment_value) VALUES ({$row['qid']}," . db_quoteall($lrow['code']) . "," . db_quoteall($lrow['title']) . ",{$lrow['sortorder']}," . db_quoteall($lrow['language']) . ",{$lrow['assessment_value']})");
                echo $modifyoutput;
                flush();
                ob_flush();
                //$labelids[]
            }
            if ($row['type'] == '1') {
                $labelquery = "Select * from {$dbprefix}labels where lid={$row['lid1']} and language=" . db_quoteall($row['language']);
                $labelresult = db_execute_assoc($labelquery);
                while ($lrow = $labelresult->FetchRow()) {
                    modify_database("", "INSERT INTO {$dbprefix}answers (qid, code, answer, sortorder, language, scale_id, assessment_value) VALUES ({$row['qid']}," . db_quoteall($lrow['code']) . "," . db_quoteall($lrow['title']) . ",{$lrow['sortorder']}," . db_quoteall($lrow['language']) . ",1,{$lrow['assessment_value']})");
                    echo $modifyoutput;
                    flush();
                    ob_flush();
                }
            }
        }
    }
    // Convert labels to subquestions
    $answerquery = "select * from {$dbprefix}questions where parent_qid=0 and type in (';',':')";
    $answerresult = db_execute_assoc($answerquery);
    if (!$answerresult) {
        return "Database Error";
    } else {
        while ($row = $answerresult->FetchRow()) {
            $labelquery = "Select * from {$dbprefix}labels where lid={$row['lid']} and language=" . db_quoteall($row['language']);
            $labelresult = db_execute_assoc($labelquery);
            while ($lrow = $labelresult->FetchRow()) {
                $insertarray = array();
                if (isset($aQIDReplacements[$row['qid'] . '_' . $lrow['code'] . '_1'])) {
                    $insertarray['qid'] = $aQIDReplacements[$row['qid'] . '_' . $lrow['code'] . '_1'];
                    db_switchIDInsert('questions', true);
                }
                $insertarray['sid'] = $row['sid'];
                $insertarray['gid'] = $row['gid'];
                $insertarray['type'] = $row['type'];
                $insertarray['parent_qid'] = $row['qid'];
                $insertarray['title'] = $lrow['code'];
                $insertarray['question'] = $lrow['title'];
                $insertarray['question_order'] = $lrow['sortorder'];
                $insertarray['language'] = $lrow['language'];
                $insertarray['scale_id'] = 1;
                $tablename = "{$dbprefix}questions";
                $query = $connect->GetInsertSQL($tablename, $insertarray);
                modify_database("", $query);
                echo $modifyoutput;
                flush();
                ob_flush();
                if (isset($insertarray['qid'])) {
                    $aQIDReplacements[$row['qid'] . '_' . $lrow['code'] . '_1'] = $connect->Insert_ID("{$dbprefix}questions", "qid");
                    db_switchIDInsert('questions', false);
                }
            }
        }
    }
    $updatequery = "update {$dbprefix}questions set type='!' where type='W'";
    modify_database("", $updatequery);
    echo $modifyoutput;
    flush();
    ob_flush();
    $updatequery = "update {$dbprefix}questions set type='L' where type='Z'";
    modify_database("", $updatequery);
    echo $modifyoutput;
    flush();
    ob_flush();
    // Now move all non-standard templates to the /upload dir
    global $usertemplaterootdir, $standardtemplates, $standardtemplaterootdir;
    if (!$usertemplaterootdir) {
        die("gettemplatelist() no template directory");
    }
    if ($handle = opendir($standardtemplaterootdir)) {
        while (false !== ($file = readdir($handle))) {
            if (!is_file("{$standardtemplaterootdir}/{$file}") && $file != "." && $file != ".." && $file != ".svn" && !isStandardTemplate($file)) {
                if (!rename($standardtemplaterootdir . DIRECTORY_SEPARATOR . $file, $usertemplaterootdir . DIRECTORY_SEPARATOR . $file)) {
                    echo "There was a problem moving directory '" . $standardtemplaterootdir . DIRECTORY_SEPARATOR . $file . "' to '" . $usertemplaterootdir . DIRECTORY_SEPARATOR . $file . "' due to missing permissions. Please do this manually.<br />";
                }
            }
        }
        closedir($handle);
    }
}
コード例 #6
0
/**
* This function returns the complete URL path to a given template name
*
* @param mixed $sTemplateName
*/
function getTemplateURL($sTemplateName)
{
    if (isStandardTemplate($sTemplateName)) {
        return Yii::app()->getConfig("standardtemplaterooturl") . '/' . $sTemplateName;
    } else {
        if (file_exists(Yii::app()->getConfig("usertemplaterootdir") . '/' . $sTemplateName)) {
            return Yii::app()->getConfig("usertemplaterooturl") . '/' . $sTemplateName;
        } elseif (file_exists(Yii::app()->getConfig("usertemplaterootdir") . '/' . Yii::app()->getConfig('defaulttemplate'))) {
            return Yii::app()->getConfig("usertemplaterooturl") . '/' . Yii::app()->getConfig('defaulttemplate');
        } elseif (file_exists(Yii::app()->getConfig("standardtemplaterootdir") . '/' . Yii::app()->getConfig('defaulttemplate'))) {
            return Yii::app()->getConfig("standardtemplaterooturl") . '/' . Yii::app()->getConfig('defaulttemplate');
        } else {
            return Yii::app()->getConfig("standardtemplaterooturl") . '/default';
        }
    }
}
コード例 #7
0
ファイル: templates.php プロジェクト: rawaludin/LimeSurvey
 /**
  * Function responsible to rename a template(folder).
  *
  * @access public
  * @return void
  */
 public function templaterename()
 {
     if (returnGlobal('action') == "templaterename" && returnGlobal('newname') && returnGlobal('copydir')) {
         $clang = Yii::app()->lang;
         $newname = sanitize_paranoid_string(returnGlobal('newname'));
         $newdirname = Yii::app()->getConfig('usertemplaterootdir') . "/" . $newname;
         $olddirname = Yii::app()->getConfig('usertemplaterootdir') . "/" . returnGlobal('copydir');
         if (isStandardTemplate(returnGlobal('newname'))) {
             $this->getController()->error(sprintf($clang->gT("Template could not be renamed to `%s`.", "js"), $newname) . " " . $clang->gT("This name is reserved for standard template.", "js"));
         } elseif (rename($olddirname, $newdirname) == false) {
             $this->getController()->error(sprintf($clang->gT("Directory could not be renamed to `%s`.", "js"), $newname) . " " . $clang->gT("Maybe you don't have permission.", "js"));
         } else {
             $templatename = $newname;
             $this->index("startpage.pstpl", "welcome", $templatename);
         }
     }
 }
コード例 #8
0
/**
* This function checks if a certain template may be by modified, copied, deleted according to the settings in config.php
* @param mixed $templatename
*/
function is_template_editable($templatename)
{
    if (isStandardTemplate($templatename) && Yii::app()->getConfig("standard_templates_readonly") == true) {
        return false;
    } else {
        return true;
    }
}
コード例 #9
0
/**
* This function returns the complete URL path to a given template name
*
* @param mixed $sTemplateName
*/
function sGetTemplateURL($sTemplateName)
{
    global $standardtemplaterooturl, $standardtemplaterootdir, $usertemplaterooturl, $usertemplaterootdir, $defaulttemplate;
    if (isStandardTemplate($sTemplateName)) {
        return $standardtemplaterooturl . '/' . $sTemplateName;
    } else {
        if (file_exists($usertemplaterootdir . '/' . $sTemplateName)) {
            return $usertemplaterooturl . '/' . $sTemplateName;
        } elseif (file_exists($usertemplaterootdir . '/' . $defaulttemplate)) {
            return $usertemplaterooturl . '/' . $defaulttemplate;
        } elseif (file_exists($standardtemplaterootdir . '/' . $defaulttemplate)) {
            return $standardtemplaterooturl . '/' . $defaulttemplate;
        } else {
            return $standardtemplaterooturl . '/default';
        }
    }
}
コード例 #10
0
ファイル: templates.php プロジェクト: himanshu12k/ce-www
/**
* This function checks if a certain template may be by modified, copied, deleted according to the settings in config.php
* @param mixed $templatename
*/
function is_template_editable($templatename)
{
    global $standard_templates_readonly, $debug, $defaulttemplate;
    if ($debug > 1) {
        return true;
    } elseif (isStandardTemplate($templatename) && $standard_templates_readonly == true) {
        return false;
    } else {
        return true;
    }
}
コード例 #11
0
 /**
  * Function responsible to rename a template(folder).
  *
  * @access public
  * @return void
  */
 public function templaterename()
 {
     if (returnGlobal('action') == "templaterename" && returnGlobal('newname') && returnGlobal('copydir')) {
         $clang = Yii::app()->lang;
         $oldname = sanitize_paranoid_string(returnGlobal('copydir'));
         $newname = sanitize_paranoid_string(returnGlobal('newname'));
         $newdirname = Yii::app()->getConfig('usertemplaterootdir') . "/" . $newname;
         $olddirname = Yii::app()->getConfig('usertemplaterootdir') . "/" . returnGlobal('copydir');
         if (isStandardTemplate(returnGlobal('newname'))) {
             $this->getController()->error(sprintf($clang->gT("Template could not be renamed to `%s`.", "js"), $newname) . " " . $clang->gT("This name is reserved for standard template.", "js"));
         } elseif (file_exists($newdirname)) {
             $this->getController()->error(sprintf($clang->gT("Template could not be renamed to `%s`.", "js"), $newname) . " " . $clang->gT("A template with that name already exists.", "js"));
         } elseif (rename($olddirname, $newdirname) == false) {
             $this->getController()->error(sprintf($clang->gT("Template could not be renamed to `%s`.", "js"), $newname) . " " . $clang->gT("Maybe you don't have permission.", "js"));
         } else {
             Survey::model()->updateAll(array('template' => $newname), "template = '{$oldname}'");
             $this->index("startpage.pstpl", "welcome", $newname);
         }
     }
 }