update

Extends \Survey_Common_Action

This controller performs updates, it is highly ajax oriented Methods are only called from JavaScript controller (wich is called from the global_setting view). comfortupdate.js is the first registered script.

Public methods are written in a chronological way: - First, when the user click on the 'check for updates' button, the plugin buildComfortButtons.js call for getstablebutton() or getbothbuttons() method and inject the HTML inside the li#udapteButtonsContainer in the _checkButtons view - Then, when the user click on one of those buttons, the comfortUpdateNextStep.js plugin will call for the getWelcome() method and inject the HTML inside div#updaterContainer in the _right_container view (all steps will be then injected here) - Then, when the user click on the continue button, the comfortUpdateNextStep.js plugin will call for the step1() method and inject the the HTML inside div#updaterContainer in the _right_container view - etc. etc.

Some steps must be shown out of the chronological process: getNewKey and submitKey. They are at the end of the controller's interface. Some steps must be 'checked again' after the user fixed some errors (such as file permissions). Those steps are/can be diplayed by the plugin displayComfortStep.js. They are called from buttons like :

'methodToCall', 'neededVariable'=>$value));?>'> button text

so they will call an url such as : globalsettings?update=methodToCall&neededVariable=value. So the globalsetting controller will render the view as usual, but : the _ajaxVariables view will parse those url datas to some hidden field. The comfortupdate.js check the value of the hidden field update, and if the update's one contain a step, it call displayComfortStep.js wich will display the right step instead of the 'check update' buttons.

Most steps are retrieving datas from the comfort update server thanks to the model UpdateForm's methods. The server return an answer object, with a property 'result' to tell if the process was succesfull or if it failed. This object contains in general all the necessary datas for the views.

Handling errors : They are different types of possible errors : - Warning message (like : modified files, etc.) : they don't stop the process, they are parsed to the step view, and the view manage how to display them. They can be generated from the ComfortUpdate server ($answer_from_server->result == TRUE ; and something like $answer_from_server->error == message or anything else that the step view manage ), or in the LimeSurvey update controller/model - Error while processing a request on the server part : should never happen, but if something goes wrong in the server side (like generating an object from model), the server returns an error object ($answer_from_server->result == FALSE ; $answer_from_server->error == message ) Those errors stop the process, and are display in _error view. Very usefull to debug. They are parsed directly to $this->_renderError - Error while checking needed datas in the LimeSurvey update controller : the controller always check if it has the needed datas (such as destintion_build, or zip_file), or the state of the key (outdated, etc). For the code to be dryer, the method parse an error string to $this->_renderErrorString($error), wich generate the error object, and then render the error view

Methods

First function to be called, when comming to admin/update

index() 

managekey

managekey() 

manage_submitkey

manage_submitkey() 

delete_key

delete_key() 

This function return the update buttons for stable branch

getstablebutton() : \html

Response

\html

the button code

This function return the update buttons for all versions

getbothbuttons() : \html

Response

\html

the buttons code

This function has a special rendering, because the ComfortUpdate server can choose what it's going to show : the welcome message or the subscribe message or the updater update, etc.

getwelcome() : \html

The same system is used for the static views (update key, etc.)

Response

\html

the welcome message

returns the "Checking basic requirements" step

checkLocalErrors() : \html

Response

\html

the welcome message

Display change log

changeLog() : \HTML

Response

\HTML

diaplay the result of the changed files check

fileSystem() : \html

Response

\html

HTML

backup files

backup() : \html

Response

\html

Display step4

step4() : \html

Response

\html

This function update the updater It is called from the view _updater_update.

updateUpdater() : \html

The view _updater_update is called by the ComfortUpdate server during the getWelcome step if the updater version is not the minimal required one.

Response

\html

the welcome message

This return the subscribe message

getnewkey() : \html

Response

\html

the welcome message

This function create or update the LS update key

submitkey() : \html

Response

\html

Update database

db($continue = null) 

Arguments

$continue

For updates from the old updater.

step4b() 

This function change the notification state : big alert notification 1, or small one 0 It's called via ajax from view adminmenu

notificationstate($state = '0') 

Arguments

$state

this function render the update buttons

_getButtons(string $crosscheck) 

Arguments

$crosscheck

string

This method render the welcome/subscribe/key_updated message

_renderWelcome(\obj $serverAnswer) 

Arguments

$serverAnswer

\obj

the answer return by the server

This method renders the error view

_renderError(object $errorObject) : \html

Arguments

$errorObject

object

Response

\html

This method convert a string to an error object, and then render the error view

_renderErrorString(string $error) : \html

Arguments

$error

string

the error message

Response

\html

This function convert the huge updateinfos array to a base64 string, so it can be parsed to the view to be inserted in an hidden input element.

_parseToView(array $updateinfos) : \$string

Arguments

$updateinfos

array

the udpadte infos array returned by the update server

Response

\$string

__construct

__construct($controller = null, $id = null) 
inherited

Arguments

$controller

$id

Override runWithParams() implementation in CAction to help us parse requests with subactions.

runWithParams(array $params) 
inherited

Arguments

$params

array

URL Parameters

Some functions have different parameters, which are just an alias of the usual parameters we're getting in the url. This function just populates those variables so that we don't end up in an error.

_addPseudoParams(array $params) : array
inherited

This is also used while rendering wrapped template {@link Survey_Common_Action::_renderWrappedTemplate()}

Arguments

$params

array

Parameters to parse and populate

Response

array

Populated parameters

Action classes require them to have a run method. We reroute it to index if called.

run() 
inherited

Routes the action into correct subaction

route(string $sa, string[] $get_vars) : void
inherited
access

protected

Arguments

$sa

string

$get_vars

string[]

Renders template(s) wrapped in header and footer

_renderWrappedTemplate(string $sAction = '', string|array $aViewUrls = array(), array $aData = array()) 
inherited

Addition of parameters should be avoided if they can be added to $aData

NOTE FROM LOUIS : We want to remove this function, wich doesn't respect MVC pattern. The work it's doing should be handle by layout files, and subviews inside views. Eg : for route "admin/survey/sa/listquestiongroups/surveyid/282267" the Group controller should use a main layout (with admin menu bar as a widget), then render the list view, in wich the question group bar is called as a subview.

So for now, we try to evacuate all the renderWrappedTemplate logic (if statements, etc.) to subfunctions, then it will be easier to remove. Comments starting with //// indicate how it should work in the future

Arguments

$sAction

string

Current action, the folder to fetch views from

$aViewUrls

string|array

View url(s)

$aData

array

Data to be passed on. Optional.

Display the update notification

_updatenotification() 
inherited

Display notifications

_notifications() 
inherited

Survey summary

_nsurveysummary($aData) 
inherited

Arguments

$aData

Header

_showHeaders($aData) 
inherited

Arguments

$aData

_showadminmenu() function returns html text for the administration button bar

_showadminmenu($aData) : string
inherited
access

public

global

string $homedir

string $scriptname

string $surveyid

string $setfont

string $imageurl

int $surveyid

Arguments

$aData

Response

string

$adminmenu

_titlebar

_titlebar($aData) 
inherited

Arguments

$aData

_tokenbar

_tokenbar($aData) 
inherited

Arguments

$aData

Render the save/cancel bar for Organize question groups/questions

_organizequestionbar(array $aData) 
inherited
since 2014-09-30
author

Olle Haerstedt

Arguments

$aData

array

Shows admin menu for question

_questionbar($aData) 
inherited

Arguments

$aData

Show admin menu for question group view

_nquestiongroupbar(array $aData) 
inherited

Arguments

$aData

array

?

_fullpagebar

_fullpagebar($aData) 
inherited

Arguments

$aData

Shows admin menu for surveys

_surveybar($aData) 
inherited

Arguments

$aData

Show side menu for survey view

_surveysidemenu(array $aData) 
inherited

Arguments

$aData

array

all the needed data

Render the quick-menu that is shown when side-menu is hidden.

renderQuickmenu(array $aData) : string
inherited

Only show home-icon for now.

Add support for plugin to attach icon elements using event afterQuickMenuLoad

todo

Make quick-menu user configurable

Arguments

$aData

array

Response

string

listquestion groups

_listquestiongroups($aData) 
inherited

Arguments

$aData

_listquestions

_listquestions($aData) 
inherited

Arguments

$aData

Show survey summary

_surveysummary($aData) 
inherited

Arguments

$aData

Browse Menu Bar

_browsemenubar($aData) 
inherited

Arguments

$aData

Load menu bar of user group controller.

_userGroupBar($aData) : void
inherited

Arguments

$aData

This function will register a script file, and will choose if it should use the asset manager or not

registerScriptFile(string $cPATH, string $sFile) 
inherited

Arguments

$cPATH

string

: the CONSTANT name of the path of the script file (need to be converted in url if asset manager is not used)

$sFile

string

: the file to publish

This function will register a script file, and will choose if it should use the asset manager or not

registerCssFile(string $sPath, string $sFile) 
inherited

Arguments

$sPath

string

: the type the path of the css file to publish ( public, template, etc)

$sFile

string

: the file to publish

_filterImportedResources

_filterImportedResources(string $extractdir, string $destdir) 
inherited

Arguments

$extractdir

string

$destdir

string

Creates a temporary directory

_tempdir(string $dir, string $prefix = '', int $mode = 448) : string
inherited
access

protected

Arguments

$dir

string

$prefix

string

$mode

int

Response

string

Get extra menus from plugins that are using event beforeAdminMenuRender

fetchExtraMenus(array $aData) : \array<ExtraMenu>
inherited

Arguments

$aData

array

Response

\array