/** * * Returns array of people containing entity, mutuals (friends), groups (shared) and priority * @param Int $guid * @param Int $friends_limit * @param Int $groups_limit * @return Array */ function get_suggestions($guid, $friends_of_friends_limit = 10, $groups_members_limit = 10) { $dbprefix = elgg_get_config('dbprefix'); $guid = sanitize_int($guid); $suggestions = array(); if ($friends_of_friends_limit) { // get some friends of friends $options = array('selects' => array('COUNT(fof.guid_two) as priority'), 'type' => 'user', 'joins' => array("JOIN {$dbprefix}users_entity ue ON ue.guid = e.guid", "JOIN {$dbprefix}entity_relationships fr ON fr.guid_one = {$guid} AND fr.relationship = 'friend'", "JOIN {$dbprefix}entity_relationships fof ON fof.guid_one = fr.guid_two AND fof.relationship = 'friend'"), "wheres" => array("ue.banned = 'no'", "e.guid NOT IN (SELECT f.guid_two FROM {$dbprefix}entity_relationships f WHERE f.guid_one = {$guid} AND f.relationship = 'friend')", "fof.guid_two = e.guid", "e.guid != {$guid}"), 'group_by' => 'e.guid', 'order_by' => 'priority desc, ue.last_action desc', 'limit' => abs((int) $friends_of_friends_limit)); $fof = elgg_get_entities($options); foreach ($fof as $f) { $priority = (int) $f->getVolatileData('select:priority'); $suggestions[$f->guid] = array('entity' => $f, 'mutuals' => $priority, 'groups' => 0, 'priority' => $priority); } } if ($groups_members_limit) { // get some mutual group members $options = array('selects' => array('COUNT(mog.guid_two) as priority'), 'type' => 'user', 'joins' => array("JOIN {$dbprefix}users_entity ue ON ue.guid = e.guid", "JOIN {$dbprefix}entity_relationships g ON g.guid_one = {$guid} AND g.relationship = 'member'", "JOIN {$dbprefix}groups_entity ge ON ge.guid = g.guid_two", "JOIN {$dbprefix}entity_relationships mog ON mog.guid_two = g.guid_two AND mog.relationship = 'member'"), "wheres" => array("ue.banned = 'no'", "e.guid NOT IN (SELECT f.guid_two FROM {$dbprefix}entity_relationships f WHERE f.guid_one = {$guid} AND f.relationship = 'friend')", "mog.guid_one = e.guid", "e.guid != {$guid}"), 'group_by' => 'e.guid', 'order_by' => 'priority desc, ue.last_action desc', 'limit' => 3); // get members of groups $mog = elgg_get_entities($options); foreach ($mog as $m) { if (!isset($suggestions[$m->guid])) { $priority = (int) $m->getVolatileData('select:priority'); $suggestions[$m->guid] = array('entity' => $m, 'mutuals' => 0, 'groups' => $priority, 'priority' => $priority); } else { $priority = (int) $m->getVolatileData('select:priority'); $suggestions[$m->guid]['groups'] = $priority; $suggestions[$m->guid]['priority'] += $priority; } } } // sort by priority usort($suggestions, __NAMESPACE__ . '\\suggested_friends_sorter'); return $suggestions; }
/** * Check if an entity_guid is valid for sending tag notifications * * @param int $entity_guid the entity GUID * * @return bool */ protected static function validateEntity($entity_guid) { $entity_guid = sanitize_int($entity_guid, false); if (empty($entity_guid)) { return false; } // cache plugin self::cachePlugin(); if (check_entity_relationship(self::$plugin->getGUID(), 'tag_tools:notification', $entity_guid)) { // already enqueued return false; } // can't use elgg get entity because cache is not correctly updated $entity_row = get_entity_as_row($entity_guid); if ($entity_row === false) { // invalid entity return false; } $entity_access = sanitise_int($entity_row->access_id); if ($entity_access === ACCESS_PRIVATE) { // private entity return false; } if (!tag_tools_is_notification_entity($entity_guid)) { // not supported entity type/subtype return false; } return true; }
/** * Load edit email template screen. * @param mixed $iSurveyId * @return */ function index($iSurveyId) { $clang = $this->getController()->lang; $iSurveyId = sanitize_int($iSurveyId); $this->getController()->_css_admin_includes(Yii::app()->getConfig('adminstyleurl') . "superfish.css"); Yii::app()->loadHelper('admin.htmleditor'); Yii::app()->loadHelper('surveytranslator'); Yii::app()->session['FileManagerContext'] = "edit:assessments:{$iSurveyId}"; if (isset($iSurveyId) && getEmailFormat($iSurveyId) == 'html') { $ishtml = true; } else { $ishtml = false; } $grplangs = Survey::model()->findByPk($iSurveyId)->additionalLanguages; $baselang = Survey::model()->findByPk($iSurveyId)->language; array_unshift($grplangs, $baselang); $sEditScript = PrepareEditorScript(false, $this->getController()); $aData['attrib'] = array(); $aData['bplangs'] = array(); $aData['defaulttexts'] = array(); if ($ishtml) { $sEscapeMode = 'html'; } else { $sEscapeMode = 'unescaped'; } foreach ($grplangs as $key => $grouplang) { $aData['bplangs'][$key] = new limesurvey_lang($grouplang); $aData['attrib'][$key] = Surveys_languagesettings::model()->find('surveyls_survey_id = :ssid AND surveyls_language = :ls', array(':ssid' => $iSurveyId, ':ls' => $grouplang)); $aData['defaulttexts'][$key] = templateDefaultTexts($aData['bplangs'][$key], $sEscapeMode); } $aData['surveyid'] = $iSurveyId; $aData['ishtml'] = $ishtml; $aData['grplangs'] = $grplangs; $this->_renderWrappedTemplate('emailtemplates', array('output' => $sEditScript, 'emailtemplates_view'), $aData); }
function index() { $sFieldName = isset($_GET['name']) ? $_GET['name'] : 0; $sFieldText = isset($_GET['text']) ? $_GET['text'] : 0; $sFieldType = isset($_GET['type']) ? $_GET['type'] : 0; $sAction = isset($_GET['action']) ? $_GET['action'] : 0; $iSurveyId = isset($_GET['sid']) ? $_GET['sid'] : 0; $iGroupId = isset($_GET['gid']) ? $_GET['gid'] : 0; $iQuestionId = isset($_GET['qid']) ? $_GET['qid'] : 0; $sLanguage = isset($_GET['lang']) ? $_GET['lang'] : 0; $aData['clang'] = $this->getController()->lang; $aData['sFieldName'] = $sFieldName; if (get_magic_quotes_gpc()) { $aData['sFieldText'] = $sFieldText = stripslashes($sFieldText); } else { $aData['sFieldText'] = $sFieldText; } if (!$sFieldName || !$sFieldText) { $this->getController()->render('/admin/htmleditor/pop_nofields_view', $aData); } else { $aData['sFieldType'] = $sFieldType = preg_replace("/[^_.a-zA-Z0-9-]/", "", $sFieldType); $aData['sAction'] = preg_replace("/[^_.a-zA-Z0-9-]/", "", $sAction); $aData['iSurveyId'] = sanitize_int($iSurveyId); $aData['iGroupId'] = sanitize_int($iGroupId); $aData['iQuestionId'] = sanitize_int($iQuestionId); $aData['sControlIdEna'] = $sFieldName . '_popupctrlena'; $aData['sControlIdDis'] = $sFieldName . '_popupctrldis'; $aData['toolbarname'] = 'popup'; $aData['htmlformatoption'] = ''; if (in_array($sFieldType, array('email-inv', 'email-reg', 'email-conf', 'email-rem'))) { $aData['htmlformatoption'] = ',fullPage:true'; } $this->getController()->render('/admin/htmleditor/pop_editor_view', $aData); } }
function index() { $aData = array(); $needpermission = false; $aData['surveyid'] = $surveyid = sanitize_int(Yii::app()->request->getQuery('sid')); $aData['sa'] = $sa = sanitize_paranoid_string(Yii::app()->request->getQuery('sa', 'index')); if (($aData['sa'] == 'survey_logic_file' || $aData['sa'] == 'navigation_test') && $surveyid) { $needpermission = true; } if ($needpermission && !Permission::model()->hasSurveyPermission($surveyid, 'surveycontent', 'read')) { App()->getClientScript()->registerPackage('jquery-superfish'); $message['title'] = gT('Access denied!'); $message['message'] = gT('You do not have sufficient rights to access this page.'); $message['class'] = "error"; $this->_renderWrappedTemplate('survey', array("message" => $message), $aData); } else { App()->getClientScript()->registerPackage('jqueryui'); App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('generalscripts') . "survey_runtime.js"); App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('generalscripts') . "expressions/em_javascript.js"); App()->getClientScript()->registerCssFile(Yii::app()->getConfig('adminstyleurl') . "adminstyle.css"); $this->_printOnLoad(Yii::app()->request->getQuery('sa', 'index')); $aData['pagetitle'] = "ExpressionManager: {$aData['sa']}"; //header("Content-type: text/html; charset=UTF-8"); // needed for correct UTF-8 encoding if (isset($_GET['sa'])) { $this->test($aData['sa'], $aData); } else { $this->_renderWrappedTemplate('expressions', 'test_view', $aData); } } }
/** * Check if the user is checked in at the place * * @param integer $user_guid GUID of the user to check * @return integer Count of checkins within checkin duration limit */ public function isCheckedIn($user_guid = 0) { if (!$user_guid) { $user_guid = elgg_get_logged_in_user_guid(); } return elgg_get_annotations(array('guids' => $this->guid, 'annotation_owner_guids' => sanitize_int($user_guid), 'annotation_names' => 'checkin', 'annotation_created_time_lower' => time() - $this->getCheckinDuration(), 'count' => true)); }
/** * Get the max number of characters allowed in a wire post * * @return int the number of characters */ function thewire_tools_get_wire_length() { static $result; if (isset($result)) { return $result; } $result = sanitize_int(elgg_get_plugin_setting('limit', 'thewire', 140), false); return $result; }
/** * {@inheritdoc} */ public function get(ParameterBag $params) { $options = array('types' => 'object', 'subtypes' => 'file', 'limit' => $params->limit, 'offset' => $params->offset, 'container_guids' => sanitize_int($params->guid), 'sort' => $params->sort, 'preload_owners' => true, 'preload_containers' => true); $getter = 'elgg_get_entities'; if ($params->simpletype) { $options['metadata_name_value_pairs'] = array('name' => 'simpletype', 'value' => $params->simpletype); $getter = 'elgg_get_entities_from_metadata'; } return new BatchResult($getter, $options); }
/** * Add a user as an author * @param int $user_guid * * @return bool */ public function addAuthor($user_guid) { $user_guid = sanitize_int($user_guid, false); if (empty($user_guid)) { return false; } $result = (bool) $this->addRelationship($user_guid, 'author'); $authors = explode(',', $this->authors); $authors[] = $user_guid; $this->authors = implode(',', $authors); return $result; }
function friend_collections_message_picker_callback($query, $options = array()) { $id = sanitize_int(get_input('id')); $guids = get_members_of_access_collection($id, true); // replace mysql vars with escaped strings $q = str_replace(array('_', '%'), array('\\_', '\\%'), $query); if (!$guids || !$id) { return array(); } $dbprefix = elgg_get_config('dbprefix'); return elgg_get_entities(array('type' => 'user', 'joins' => array("JOIN {$dbprefix}users_entity ue ON ue.guid = e.guid", "JOIN {$dbprefix}access_collection_membership acm ON acm.user_guid = e.guid"), 'wheres' => array("ue.username LIKE '%{$q}%' OR ue.name LIKE '%{$q}%'", "acm.access_collection_id = {$id}"), 'order_by' => 'ue.name ASC')); }
/** * Loads a survey from the database that has the given ID. If no matching * survey is found then null is returned. Note that no results are loaded * from this function call, only survey structure/definition. * * In the future it would be nice to load all languages from the db at * once and have the infrastructure be able to return responses based * on language codes. * * @param int $id * @return SurveyObj */ public function loadSurveyById($id, $lang = null) { $survey = new SurveyObj(); $clang = Yii::app()->lang; $intId = sanitize_int($id); $survey->id = $intId; $survey->info = getSurveyInfo($survey->id); $availableLanguages = Survey::model()->findByPk($intId)->getAllLanguages(); if (is_null($lang) || in_array($lang, $availableLanguages) === false) { // use base language when requested language is not found or no specific language is requested $lang = Survey::model()->findByPk($intId)->language; } $clang = new limesurvey_lang($lang); $survey->fieldMap = createFieldMap($intId, 'full', true, false, $lang); // Check to see if timings are present and add to fieldmap if needed if ($survey->info['savetimings'] == "Y") { $survey->fieldMap = $survey->fieldMap + createTimingsFieldMap($intId, 'full', true, false, $lang); } if (empty($intId)) { //The id given to us is not an integer, croak. safeDie("An invalid survey ID was encountered: {$sid}"); } //Load groups $sQuery = 'SELECT g.* FROM {{groups}} AS g ' . 'WHERE g.sid = ' . $intId . ' AND g.language = \'' . $lang . '\' ' . 'ORDER BY g.group_order;'; $recordSet = Yii::app()->db->createCommand($sQuery)->query()->readAll(); $survey->groups = $recordSet; //Load questions $sQuery = 'SELECT q.* FROM {{questions}} AS q ' . 'JOIN {{groups}} AS g ON (q.gid = g.gid and q.language = g.language) ' . 'WHERE q.sid = ' . $intId . ' AND q.language = \'' . $lang . '\' ' . 'ORDER BY g.group_order, q.question_order;'; $survey->questions = Yii::app()->db->createCommand($sQuery)->query()->readAll(); //Load answers $sQuery = 'SELECT DISTINCT a.* FROM {{answers}} AS a ' . 'JOIN {{questions}} AS q ON a.qid = q.qid ' . 'WHERE q.sid = ' . $intId . ' AND a.language = \'' . $lang . '\' ' . 'ORDER BY a.qid, a.sortorder;'; //$survey->answers = Yii::app()->db->createCommand($sQuery)->queryAll(); $aAnswers = Yii::app()->db->createCommand($sQuery)->queryAll(); foreach ($aAnswers as $aAnswer) { if (Yii::app()->controller->action->id != 'remotecontrol') { $aAnswer['answer'] = stripTagsFull($aAnswer['answer']); } $survey->answers[$aAnswer['qid']][$aAnswer['scale_id']][$aAnswer['code']] = $aAnswer; } //Load language settings for requested language $sQuery = 'SELECT * FROM {{surveys_languagesettings}} WHERE surveyls_survey_id = ' . $intId . ' AND surveyls_language = \'' . $lang . '\';'; $recordSet = Yii::app()->db->createCommand($sQuery)->query(); $survey->languageSettings = $recordSet->read(); $recordSet->close(); if (tableExists('tokens_' . $survey->id) && array_key_exists('token', SurveyDynamic::model($survey->id)->attributes) && Permission::model()->hasSurveyPermission($survey->id, 'tokens', 'read')) { // Now add the tokenFields $survey->tokenFields = getTokenFieldsAndNames($survey->id); unset($survey->tokenFields['token']); } return $survey; }
function globalsettingssave() { global $action, $editsurvey, $connect, $scriptname, $clang; if (isset($action) && $action == "globalsettingssave") { if ($_SESSION['USER_RIGHT_SUPERADMIN'] == 1) { if (sanitize_int($_POST['maxemails']) < 1) { $_POST['maxemails'] = 1; } setGlobalSetting('sitename', strip_tags($_POST['sitename'])); setGlobalSetting('updatecheckperiod', (int) $_POST['updatecheckperiod']); setGlobalSetting('addTitleToLinks', sanitize_paranoid_string($_POST['addTitleToLinks'])); setGlobalSetting('defaultlang', sanitize_languagecode($_POST['defaultlang'])); setGlobalSetting('defaulthtmleditormode', sanitize_paranoid_string($_POST['defaulthtmleditormode'])); setGlobalSetting('defaulttemplate', sanitize_paranoid_string($_POST['defaulttemplate'])); setGlobalSetting('emailmethod', strip_tags($_POST['emailmethod'])); setGlobalSetting('emailsmtphost', strip_tags(returnglobal('emailsmtphost'))); if (returnglobal('emailsmtppassword') != 'somepassword') { setGlobalSetting('emailsmtppassword', strip_tags(returnglobal('emailsmtppassword'))); } setGlobalSetting('emailsmtpssl', sanitize_paranoid_string(returnglobal('emailsmtpssl'))); setGlobalSetting('emailsmtpdebug', sanitize_int(returnglobal('emailsmtpdebug'))); setGlobalSetting('emailsmtpuser', strip_tags(returnglobal('emailsmtpuser'))); setGlobalSetting('filterxsshtml', strip_tags($_POST['filterxsshtml'])); setGlobalSetting('siteadminbounce', strip_tags($_POST['siteadminbounce'])); setGlobalSetting('siteadminemail', strip_tags($_POST['siteadminemail'])); setGlobalSetting('siteadminname', strip_tags($_POST['siteadminname'])); setGlobalSetting('shownoanswer', sanitize_int($_POST['shownoanswer'])); $repeatheadingstemp = (int) $_POST['repeatheadings']; if ($repeatheadingstemp == 0) { $repeatheadingstemp = 25; } setGlobalSetting('repeatheadings', $repeatheadingstemp); setGlobalSetting('maxemails', sanitize_int($_POST['maxemails'])); $sessionlifetimetemp = (int) $_POST['sessionlifetime']; if ($sessionlifetimetemp == 0) { $sessionlifetimetemp = 3600; } setGlobalSetting('sessionlifetime', $sessionlifetimetemp); setGlobalSetting('surveyPreview_require_Auth', strip_tags($_POST['surveyPreview_require_Auth'])); $savetime = trim(strip_tags((double) $_POST['timeadjust']) . ' hours'); //makes sure it is a number, at least 0 if (substr($savetime, 0, 1) != '-' && substr($savetime, 0, 1) != '+') { $savetime = '+' . $savetime; } setGlobalSetting('timeadjust', $savetime); setGlobalSetting('usepdfexport', strip_tags($_POST['usepdfexport'])); setGlobalSetting('usercontrolSameGroupPolicy', strip_tags($_POST['usercontrolSameGroupPolicy'])); $editsurvey .= "<div class='header'>" . $clang->gT("Global settings") . "</div>\n" . "<div class=\"messagebox\">\n" . "<br /><div class=\"successheader\">" . $clang->gT("Global settings were saved.") . "</div>\n" . "<br/><input type=\"submit\" onclick=\"window.open('admin.php', '_top')\" value=\"" . $clang->gT("Continue") . "\"/>\n" . "</div>\n"; } } }
/** * Root function for any export results action * * @param mixed $iSurveyId * @param mixed $sLanguageCode * @param csv|doc|pdf|xls $sExportPlugin Type of export * @param FormattingOptions $oOptions * @param string $sFilter */ function exportSurvey($iSurveyId, $sLanguageCode, $sExportPlugin, FormattingOptions $oOptions, $sFilter = '') { //Do some input validation. if (empty($iSurveyId)) { safeDie('A survey ID must be supplied.'); } if (empty($sLanguageCode)) { safeDie('A language code must be supplied.'); } if (empty($oOptions)) { safeDie('Formatting options must be supplied.'); } if (empty($oOptions->selectedColumns)) { safeDie('At least one column must be selected for export.'); } //echo $oOptions->toString().PHP_EOL; $writer = null; $iSurveyId = sanitize_int($iSurveyId); if ($oOptions->output == 'display') { header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Pragma: public"); } $exports = $this->getExports(); if (array_key_exists($sExportPlugin, $exports) && !empty($exports[$sExportPlugin])) { // This must be a plugin, now use plugin to load the right class $event = new PluginEvent('newExport'); $event->set('type', $sExportPlugin); $oPluginManager = App()->getPluginManager(); $oPluginManager->dispatchEvent($event, $exports[$sExportPlugin]); $writer = $event->get('writer'); } if (!$writer instanceof IWriter) { throw new Exception(sprintf('Writer for %s should implement IWriter', $sExportPlugin)); } $surveyDao = new SurveyDao(); $survey = $surveyDao->loadSurveyById($iSurveyId, $sLanguageCode); $writer->init($survey, $sLanguageCode, $oOptions); $surveyDao->loadSurveyResults($survey, $oOptions->responseMinRecord, $oOptions->responseMaxRecord, $sFilter, $oOptions->responseCompletionState); $writer->write($survey, $sLanguageCode, $oOptions, true); $result = $writer->close(); // Close resultset if needed if ($survey->responses instanceof CDbDataReader) { $survey->responses->close(); } if ($oOptions->output == 'file') { return $writer->filename; } else { return $result; } }
function actionAJAXRegisterForm($surveyid) { Yii::app()->loadHelper('database'); Yii::app()->loadHelper('replacements'); $redata = compact(array_keys(get_defined_vars())); $surveyid = sanitize_int($surveyid); $row = Survey::model()->find('sid=:sid', array(':sid' => $surveyid)) or show_error("Can't find survey data"); $thistpl = getTemplatePath(validateTemplateDir($row->template)); $data['sid'] = $surveyid; $data['startdate'] = $row->startdate; $data['enddate'] = $row->expires; Yii::import('application.libraries.Limesurvey_lang'); Yii::app()->lang = new Limesurvey_lang($baselang); echo templatereplace(file_get_contents("{$thistpl}/register.pstpl"), array(), $redata, 'register.php', false, NULL, $data); }
/** * Returns suggested groups ... to be implemented (Rosana) * * @param ElggUser $user (optional) the user to get the groups for, defaults to the current user * @param int $limit (optional) the number of suggested groups to return, default = 10 * * @return ElggGroup[] */ function fuzzy_filter_get_suggested_groups($user = null, $limit = null) { if (!$user instanceof ElggUser) { $user = elgg_get_logged_in_user_entity(); } if (is_null($limit)) { $limit = (int) get_input('limit', 10); } $limit = sanitize_int($limit, false); if (empty($user) || $limit < 1) { return []; } $result = []; return $result; }
/** * Helper function to let a plugin put content * into the side-body easily. * * @param int $surveyId * @param string $plugin Name of the plugin class * @param string $method Name of the plugin method * @return void */ public function sidebody($surveyId, $plugin, $method) { $aData = array(); $surveyId = sanitize_int($surveyId); $surveyinfo = getSurveyInfo($surveyId); $aData['surveyid'] = $surveyId; $aData['surveybar']['buttons']['view'] = true; $aData['title_bar']['title'] = $surveyinfo['surveyls_title'] . "(" . gT("ID") . ":" . $surveyId . ")"; $content = $this->getContent($surveyId, $plugin, $method); $aData['sidemenu'] = array(); $aData['sidemenu']['state'] = false; $aData['sideMenuBehaviour'] = getGlobalSetting('sideMenuBehaviour'); $aData['content'] = $content; $aData['activated'] = $surveyinfo['active']; $this->_renderWrappedTemplate(null, array('super/sidebody'), $aData); }
public function view($iSurveyId) { $iSurveyId = sanitize_int($iSurveyId); $aViewUrls = array(); if (!Permission::model()->hasSurveyPermission($iSurveyId, 'responses', 'read')) { die; } App()->getClientScript()->registerPackage('jquery-tablesorter'); App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('adminscripts') . 'saved.js'); $aThisSurvey = getSurveyInfo($iSurveyId); $aData['sSurveyName'] = $aThisSurvey['name']; $aData['iSurveyId'] = $iSurveyId; $aViewUrls[] = 'savedbar_view'; $aViewUrls['savedlist_view'][] = $this->_showSavedList($iSurveyId); $this->_renderWrappedTemplate('saved', $aViewUrls, $aData); }
/** * {@inheritdoc} */ public function get($uid = '') { switch ($uid) { case 'me': $uid = "ue" . elgg_get_logged_in_user_guid(); break; case 'site': $uid = "se" . elgg_get_site_entity()->guid; break; } $abbr = substr($uid, 0, 2); switch ($abbr) { case 'an': $id = (int) substr($uid, 2); $object = elgg_get_annotation_from_id($id); break; case 'md': $id = (int) substr($uid, 2); $object = elgg_get_metadata_from_id($id); break; case 'rl': $id = (int) substr($uid, 2); $object = get_relationship($id); break; case 'rv': $id = (int) substr($uid, 2); $river = elgg_get_river(array('ids' => sanitize_int($id))); $object = $river ? $river[0] : false; break; case 'ue': case 'se': case 'oe': case 'ge': $id = (int) substr($uid, 2); $object = get_entity($id); break; default: $object = get_user_by_username($uid); if (!$object && is_numeric($uid)) { $object = get_entity($uid); } } if (!$this->isExportable($object)) { return false; } return $object; }
public function index() { if (isset($_GET['surveyid'])) { $surveyid = sanitize_int($_GET['surveyid']); } if (isset($_GET['gid'])) { $gid = sanitize_int($_GET['gid']); } if (isset($_GET['qid'])) { $qid = sanitize_int($_GET['qid']); } if (isset($_GET['fieldtype'])) { $fieldtype = $_GET['fieldtype']; } if (isset($_GET['action'])) { $action = $_GET['action']; } $clang = Yii::app()->lang; if (!Yii::app()->session['loginID']) { die("Unauthenticated Access Forbiden"); } list($replacementFields, $isInstertAnswerEnabled) = $this->_getReplacementFields($fieldtype, $surveyid); if ($isInstertAnswerEnabled === true) { if (empty($surveyid)) { safeDie("No SID provided."); } //2: Get all other questions that occur before this question that are pre-determined answer types $fieldmap = createFieldMap($surveyid, 'full', false, false, getBaseLanguageFromSurveyID($surveyid)); $surveyInfo = getSurveyInfo($surveyid); $surveyformat = $surveyInfo['format']; // S, G, A //Go through each question until we reach the current one //error_log(print_r($qrows,true)); $questionlist = $this->_getQuestionList($action, $gid, $qid, $fieldmap, $fieldtype, $surveyformat); $childQuestions = $this->_getChildQuestions($questionlist); } $data['countfields'] = count($replacementFields); $data['replFields'] = $replacementFields; $data['clang'] = $clang; if (isset($childQuestions)) { $data['cquestions'] = $childQuestions; } if (isset($surveyformat)) { $data['surveyformat'] = $surveyformat; } $this->getController()->render('/admin/limeReplacementFields_view', $data); }
public function index() { $iSurveyID = sanitize_int($_REQUEST['surveyid']); $tolang = Yii::app()->getRequest()->getParam('lang'); $action = Yii::app()->getRequest()->getParam('action'); $actionvalue = Yii::app()->getRequest()->getPost('actionvalue'); if ($action == "ajaxtranslategoogleapi") { echo $this->translate_google_api(); return; } App()->getClientScript()->registerScriptFile(App()->getAssetManager()->publish(ADMIN_SCRIPT_PATH . 'translation.js')); $baselang = Survey::model()->findByPk($iSurveyID)->language; $langs = Survey::model()->findByPk($iSurveyID)->additionalLanguages; Yii::app()->loadHelper("database"); Yii::app()->loadHelper("admin/htmleditor"); if (empty($tolang) && count($langs) > 0) { $tolang = $langs[0]; } // TODO need to do some validation here on surveyid $surveyinfo = getSurveyInfo($iSurveyID); $survey_title = $surveyinfo['name']; Yii::app()->loadHelper("surveytranslator"); $supportedLanguages = getLanguageData(FALSE, Yii::app()->session['adminlang']); $baselangdesc = $supportedLanguages[$baselang]['description']; $aData = array("surveyid" => $iSurveyID, "survey_title" => $survey_title, "tolang" => $tolang, "adminmenu" => $this->showTranslateAdminmenu($iSurveyID, $survey_title, $tolang)); $aViewUrls['translateheader_view'][] = $aData; $tab_names = array("title", "welcome", "group", "question", "subquestion", "answer", "emailinvite", "emailreminder", "emailconfirmation", "emailregistration"); if (!empty($tolang)) { // Only save if the administration user has the correct permission if ($actionvalue == "translateSave" && Permission::model()->hasSurveyPermission($iSurveyID, 'translations', 'update')) { $this->_translateSave($iSurveyID, $tolang, $baselang, $tab_names); Yii::app()->setFlashMessage(gT("Saved"), 'success'); } $tolangdesc = $supportedLanguages[$tolang]['description']; // Display tabs with fields to translate, as well as input fields for translated values $aViewUrls = array_merge($aViewUrls, $this->_displayUntranslatedFields($iSurveyID, $tolang, $baselang, $tab_names, $baselangdesc, $tolangdesc)); //var_dump(array_keys($aViewUrls));die(); } $aData['sidemenu']['state'] = false; $surveyinfo = Survey::model()->findByPk($iSurveyID)->surveyinfo; $aData['title_bar']['title'] = $surveyinfo['surveyls_title'] . "(" . gT("ID") . ":" . $iSurveyID . ")"; $aData['surveybar']['savebutton']['form'] = 'frmeditgroup'; $aData['surveybar']['closebutton']['url'] = 'admin/survey/sa/view/surveyid/' . $iSurveyID; // Close button $this->_renderWrappedTemplate('translate', $aViewUrls, $aData); }
public function view($iSurveyId) { $iSurveyId = sanitize_int($iSurveyId); $clang = $this->getController()->lang; $aViewUrls = array(); if (!hasSurveyPermission($iSurveyId, 'responses', 'read')) { die; } $this->getController()->_js_admin_includes(Yii::app()->getConfig('generalscripts') . 'jquery/jquery.tablesorter.min.js'); $this->getController()->_js_admin_includes(Yii::app()->getConfig('adminscripts') . 'saved.js'); $aThisSurvey = getSurveyInfo($iSurveyId); $aData['sSurveyName'] = $aThisSurvey['name']; $aData['iSurveyId'] = $iSurveyId; $aViewUrls[] = 'savedbar_view'; $aViewUrls['savedlist_view'][] = $this->_showSavedList($iSurveyId); $this->_renderWrappedTemplate('saved', $aViewUrls, $aData); }
function index() { Yii::app()->loadHelper('admin/htmleditor'); $aData = array('ckLanguage' => sTranslateLangCode2CK(Yii::app()->session['adminlang']), 'sFieldName' => sanitize_xss_string(App()->request->getQuery('name')), 'sFieldText' => sanitize_xss_string(App()->request->getQuery('text')), 'sFieldType' => sanitize_xss_string(App()->request->getQuery('type')), 'sAction' => sanitize_paranoid_string(App()->request->getQuery('action')), 'iSurveyId' => sanitize_int(App()->request->getQuery('sid', 0)), 'iGroupId' => sanitize_int(App()->request->getQuery('gid', 0)), 'iQuestionId' => sanitize_int(App()->request->getQuery('qid', 0))); if (!$aData['sFieldName']) { $this->getController()->render('/admin/htmleditor/pop_nofields_view', $aData); } else { $aData['sControlIdEna'] = $aData['sFieldName'] . '_popupctrlena'; $aData['sControlIdDis'] = $aData['sFieldName'] . '_popupctrldis'; $aData['toolbarname'] = 'popup'; $aData['htmlformatoption'] = ''; if (in_array($aData['sFieldType'], array('email-inv', 'email-reg', 'email-conf', 'email-rem'))) { $aData['htmlformatoption'] = ',fullPage:true'; } $this->getController()->render('/admin/htmleditor/pop_editor_view', $aData); } }
/** * Load edit email template screen. * @param mixed $iSurveyId * @return */ function index($iSurveyId) { $iSurveyId = sanitize_int($iSurveyId); Yii::app()->loadHelper('admin.htmleditor'); Yii::app()->loadHelper('surveytranslator'); Yii::app()->session['FileManagerContext'] = "edit:emailsettings:{$iSurveyId}"; initKcfinder(); if (isset($iSurveyId) && getEmailFormat($iSurveyId) == 'html') { $ishtml = true; } else { $ishtml = false; } $grplangs = Survey::model()->findByPk($iSurveyId)->additionalLanguages; $baselang = Survey::model()->findByPk($iSurveyId)->language; array_unshift($grplangs, $baselang); $sEditScript = PrepareEditorScript(false, $this->getController()); $aData['attrib'] = array(); $aData['bplangs'] = array(); $aData['defaulttexts'] = array(); if ($ishtml) { $sEscapeMode = 'html'; } else { $sEscapeMode = 'unescaped'; } foreach ($grplangs as $key => $grouplang) { $aData['bplangs'][$key] = $grouplang; $aData['attrib'][$key] = SurveyLanguageSetting::model()->find('surveyls_survey_id = :ssid AND surveyls_language = :ls', array(':ssid' => $iSurveyId, ':ls' => $grouplang)); $aData['attrib'][$key]['attachments'] = unserialize($aData['attrib'][$key]['attachments']); $aData['defaulttexts'][$key] = templateDefaultTexts($aData['bplangs'][$key], $sEscapeMode); } $aData['sidemenu']['state'] = false; $surveyinfo = Survey::model()->findByPk($iSurveyId)->surveyinfo; $aData['title_bar']['title'] = $surveyinfo['surveyls_title'] . "(" . gT("ID") . ":" . $iSurveyId . ")"; $aData['surveybar']['savebutton']['form'] = 'frmeditgroup'; $aData['surveybar']['saveandclosebutton']['form'] = 'frmeditgroup'; if (!Permission::model()->hasSurveyPermission($iSurveyId, 'surveycontent', 'update')) { unset($aData['surveybar']['savebutton']); unset($aData['surveybar']['saveandclosebutton']); } $aData['surveybar']['closebutton']['url'] = 'admin/survey/sa/view/surveyid/' . $iSurveyId; // Close button $aData['surveyid'] = $iSurveyId; $aData['ishtml'] = $ishtml; $aData['grplangs'] = $grplangs; $this->_renderWrappedTemplate('emailtemplates', array('output' => $sEditScript, 'emailtemplates_view'), $aData); }
function actionAJAXRegisterForm($surveyid) { Yii::app()->loadHelper('database'); Yii::app()->loadHelper('replacements'); $redata = compact(array_keys(get_defined_vars())); $iSurveyID = sanitize_int($surveyid); $oSurvey = Survey::model()->find('sid=:sid', array(':sid' => $iSurveyID)) or show_error("Can't find survey data"); $thistpl = getTemplatePath(validateTemplateDir($oSurvey->template)); $data['sid'] = $iSurveyID; $data['startdate'] = $oSurvey->startdate; $data['enddate'] = $oSurvey->expires; $data['thissurvey'] = getSurveyInfo($iSurveyID, $oSurvey->language); Yii::import('application.libraries.Limesurvey_lang'); Yii::app()->lang = new Limesurvey_lang($oSurvey->language); echo templatereplace(file_get_contents("{$thistpl}/register.pstpl"), array(), $data, 'register.php', false, NULL, $data); unset($_SESSION['survey_' . $iSurveyID]['register_errormsg']); }
function index() { $aData = array(); $needpermission = false; $aData['surveyid'] = $surveyid = $iSurveyID = sanitize_int(Yii::app()->request->getQuery('sid')); $aData['sa'] = $sa = sanitize_paranoid_string(Yii::app()->request->getQuery('sa', 'index')); $aData['fullpagebar']['closebutton']['url'] = 'admin/'; if (($aData['sa'] == 'survey_logic_file' || $aData['sa'] == 'navigation_test') && $surveyid) { $needpermission = true; } if ($needpermission && !Permission::model()->hasSurveyPermission($surveyid, 'surveycontent', 'read')) { $message['title'] = gT('Access denied!'); $message['message'] = gT('You do not have sufficient rights to access this page.'); $message['class'] = "error"; $this->_renderWrappedTemplate('survey', array("message" => $message), $aData); } else { App()->getClientScript()->registerPackage('jqueryui'); App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('generalscripts') . "survey_runtime.js"); App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('generalscripts') . "expressions/em_javascript.js"); //App()->getClientScript()->registerCssFile(Yii::app()->getConfig('adminstyleurl') . "adminstyle.css" ); $this->_printOnLoad(Yii::app()->request->getQuery('sa', 'index')); $aData['pagetitle'] = "ExpressionManager: {$aData['sa']}"; if (isset($iSurveyID)) { $aData['sidebar']['state'] = "close"; $surveyinfo = Survey::model()->findByPk($iSurveyID)->surveyinfo; $aData['title_bar']['title'] = $surveyinfo['surveyls_title'] . "(" . gT("ID") . ":" . $iSurveyID . ")"; if (Yii::app()->request->getQuery('gid') != '') { $aData['questiongroupbar']['closebutton']['url'] = 'admin/questiongroups/sa/view/surveyid/' . $aData['surveyid'] . '/gid/' . sanitize_int(Yii::app()->request->getQuery('gid')); } else { $aData['surveybar']['closebutton']['url'] = 'admin/survey/sa/view/surveyid/' . $aData['surveyid']; } if (Yii::app()->request->getQuery('qid') != '') { $aData['questiongroupbar']['closebutton']['url'] = 'admin/questions/sa/view/surveyid/' . $aData['surveyid'] . '/gid/' . sanitize_int(Yii::app()->request->getQuery('gid')) . '/qid/' . sanitize_int(Yii::app()->request->getQuery('qid')); $aData['gid'] = sanitize_int(Yii::app()->request->getQuery('gid')); } } //header("Content-type: text/html; charset=UTF-8"); // needed for correct UTF-8 encoding if (isset($_GET['sa'])) { $this->test($aData['sa'], $aData); } else { $this->_renderWrappedTemplate('expressions', 'test_view', $aData); } } }
public function view($iSurveyId) { $iSurveyId = sanitize_int($iSurveyId); $aViewUrls = array(); if (!Permission::model()->hasSurveyPermission($iSurveyId, 'responses', 'read')) { die; } $aThisSurvey = getSurveyInfo($iSurveyId); $aData['sSurveyName'] = $aThisSurvey['name']; $aData['iSurveyId'] = $iSurveyId; $aViewUrls[] = 'savedbar_view'; $aViewUrls['savedlist_view'][] = $this->_showSavedList($iSurveyId); // saved.js bugs if table is empty if (count($aViewUrls['savedlist_view'][0]['aResults'])) { App()->getClientScript()->registerPackage('jquery-tablesorter'); $this->registerScriptFile('ADMIN_SCRIPT_PATH', 'saved.js'); } $this->_renderWrappedTemplate('saved', $aViewUrls, $aData); }
public function index() { $iSurveyID = sanitize_int($_REQUEST['surveyid']); $tolang = Yii::app()->getRequest()->getParam('lang'); $action = Yii::app()->getRequest()->getParam('action'); $actionvalue = Yii::app()->getRequest()->getPost('actionvalue'); //echo $this->query('title','querybase'); //die(); if ($action == "ajaxtranslategoogleapi") { echo $this->translate_google_api(); return; } App()->getClientScript()->registerScriptFile(Yii::app()->getConfig("adminscripts") . 'translation.js'); $clang = Yii::app()->lang; $baselang = Survey::model()->findByPk($iSurveyID)->language; $langs = Survey::model()->findByPk($iSurveyID)->additionalLanguages; Yii::app()->loadHelper("database"); Yii::app()->loadHelper("admin/htmleditor"); if (empty($tolang) && count($langs) > 0) { $tolang = $langs[0]; } // TODO need to do some validation here on surveyid $surveyinfo = getSurveyInfo($iSurveyID); $survey_title = $surveyinfo['name']; Yii::app()->loadHelper("surveytranslator"); $supportedLanguages = getLanguageData(FALSE, Yii::app()->session['adminlang']); $baselangdesc = $supportedLanguages[$baselang]['description']; $aData = array("surveyid" => $iSurveyID, "survey_title" => $survey_title, "tolang" => $tolang, "clang" => $clang, "adminmenu" => $this->showTranslateAdminmenu($iSurveyID, $survey_title, $tolang)); $aViewUrls['translateheader_view'][] = $aData; $tab_names = array("title", "welcome", "group", "question", "subquestion", "answer", "emailinvite", "emailreminder", "emailconfirmation", "emailregistration"); if (!empty($tolang)) { // Only save if the administration user has the correct permission if ($actionvalue == "translateSave" && Permission::model()->hasSurveyPermission($iSurveyID, 'translations', 'update')) { $this->_translateSave($iSurveyID, $tolang, $baselang, $tab_names); } $tolangdesc = $supportedLanguages[$tolang]['description']; // Display tabs with fields to translate, as well as input fields for translated values $aViewUrls = array_merge($aViewUrls, $this->_displayUntranslatedFields($iSurveyID, $tolang, $baselang, $tab_names, $baselangdesc, $tolangdesc)); //var_dump(array_keys($aViewUrls));die(); } $this->_renderWrappedTemplate('translate', $aViewUrls, $aData); }
function user_default_limit_settings_save() { $user_default_limit = sanitize_int(get_input('user_default_limit'), false); $user_guid = (int) get_input('guid'); if (empty($user_default_limit)) { return; } if ($user_default_limit < 10 || $user_default_limit > 100) { return; } if ($user_guid) { $user = get_user($user_guid); } else { $user = elgg_get_logged_in_user_entity(); } if (empty($user) || !$user->canEdit()) { return; } $user->setPrivateSetting('user_default_limit', $user_default_limit); }
/** * fixes the numbering of questions * @global $dbprefix $dbprefix * @global $connect $connect * @global $clang $clang * @param <type> $fixnumbering */ function fixNumbering($fixnumbering) { global $dbprefix, $connect, $clang, $surveyid; LimeExpressionManager::RevertUpgradeConditionsToRelevance($surveyid); //Fix a question id - requires renumbering a question $oldqid = sanitize_int($fixnumbering); $query = "SELECT qid FROM {$dbprefix}questions ORDER BY qid DESC"; $result = db_select_limit_assoc($query, 1) or safe_die($query . "<br />" . $connect->ErrorMsg()); while ($row = $result->FetchRow()) { $lastqid = $row['qid']; } $newqid = $lastqid + 1; $query = "UPDATE {$dbprefix}questions SET qid={$newqid} WHERE qid={$oldqid}"; $result = $connect->Execute($query) or safe_die($query . "<br />" . $connect->ErrorMsg()); // Update subquestions $query = "UPDATE {$dbprefix}questions SET parent_qid={$newqid} WHERE parent_qid={$oldqid}"; $result = $connect->Execute($query) or safe_die($query . "<br />" . $connect->ErrorMsg()); //Update conditions.. firstly conditions FOR this question $query = "UPDATE {$dbprefix}conditions SET qid={$newqid} WHERE qid={$oldqid}"; $result = $connect->Execute($query) or safe_die($query . "<br />" . $connect->ErrorMsg()); //Now conditions based upon this question $query = "SELECT cqid, cfieldname FROM {$dbprefix}conditions WHERE cqid={$oldqid}"; $result = db_execute_assoc($query) or safe_die($query . "<br />" . $connect->ErrorMsg()); while ($row = $result->FetchRow()) { $switcher[] = array("cqid" => $row['cqid'], "cfieldname" => $row['cfieldname']); } if (isset($switcher)) { foreach ($switcher as $switch) { $query = "UPDATE {$dbprefix}conditions\n SET cqid={$newqid},\n cfieldname='" . str_replace("X" . $oldqid, "X" . $newqid, $switch['cfieldname']) . "'\n WHERE cqid={$oldqid}"; $result = $connect->Execute($query) or safe_die($query . "<br />" . $connect->ErrorMsg()); } } //Now question_attributes $query = "UPDATE {$dbprefix}question_attributes SET qid={$newqid} WHERE qid={$oldqid}"; $result = $connect->Execute($query) or safe_die($query . "<br />" . $connect->ErrorMsg()); //Now answers $query = "UPDATE {$dbprefix}answers SET qid={$newqid} WHERE qid={$oldqid}"; $result = $connect->Execute($query) or safe_die($query . "<br />" . $connect->ErrorMsg()); LimeExpressionManager::UpgradeConditionsToRelevance($surveyid); }
/** * Load edit email template screen. * @param mixed $iSurveyId * @return */ function index($iSurveyId) { $iSurveyId = sanitize_int($iSurveyId); App()->getClientScript()->registerPackage('jquery-superfish'); Yii::app()->loadHelper('admin.htmleditor'); Yii::app()->loadHelper('surveytranslator'); Yii::app()->session['FileManagerContext'] = "edit:emailsettings:{$iSurveyId}"; initKcfinder(); if (isset($iSurveyId) && getEmailFormat($iSurveyId) == 'html') { $ishtml = true; } else { $ishtml = false; } $grplangs = Survey::model()->findByPk($iSurveyId)->additionalLanguages; $baselang = Survey::model()->findByPk($iSurveyId)->language; array_unshift($grplangs, $baselang); $sEditScript = PrepareEditorScript(false, $this->getController()); $aData['attrib'] = array(); $aData['bplangs'] = array(); $aData['defaulttexts'] = array(); if ($ishtml) { $sEscapeMode = 'html'; } else { $sEscapeMode = 'unescaped'; } foreach ($grplangs as $key => $grouplang) { $aData['bplangs'][$key] = $grouplang; $aData['attrib'][$key] = SurveyLanguageSetting::model()->find('surveyls_survey_id = :ssid AND surveyls_language = :ls', array(':ssid' => $iSurveyId, ':ls' => $grouplang)); $aData['attrib'][$key]['attachments'] = unserialize($aData['attrib'][$key]['attachments']); $aData['defaulttexts'][$key] = templateDefaultTexts($aData['bplangs'][$key], $sEscapeMode); } $aData['surveyid'] = $iSurveyId; $aData['ishtml'] = $ishtml; $aData['grplangs'] = $grplangs; $this->_renderWrappedTemplate('emailtemplates', array('output' => $sEditScript, 'emailtemplates_view'), $aData); }