CAPÍTULO III. PLANTEAMIENTO DE LA PROPUESTA
Anexo 8: Manual Tecnico
UNIVERSIDAD REGIONAL AUTÓNOMA DE LOS ANDES “UNIANDES”
FACULTAD DE SISTEMAS MERCANTILES CARRERA DE SISTEMAS
MANUAL DE TECNICO
Aplicación de encuestas vía equipos móviles en el Gobierno Parroquial La Paz.
Autora
Erika Maricela Cuasapas Carlosama.
Tutor
Ing. Freed Carrera.
Tulcán - Ecuador 2015
Variables de la index principal.
Código de login del sitio web. defined('_JEXEC') or die;
// Include the syndicate functions only once require_once dirname(__FILE__).'/helper.php'; $params->def('greeting', 1);
$type = modLoginHelper::getType();
$return = modLoginHelper::getReturnURL($params, $type);
$user = JFactory::getUser();
require JModuleHelper::getLayoutPath('mod_login', $params->get('layout', 'default'));
Código de menu principal. defined('_JEXEC') or die;
// Include the syndicate functions only once require_once dirname(__FILE__).'/helper.php'; $list = modMenuHelper::getList($params); $app = JFactory::getApplication();
$menu = $app->getMenu();
$active = $menu->getActive();
$active_id = isset($active) ? $active->id : $menu->getDefault()->id; $path = isset($active) ? $active->tree : array();
$showAll = $params->get('showAllChildren');
$class_sfx = htmlspecialchars($params->get('class_sfx')); if(count($list)) {
require JModuleHelper::getLayoutPath('mod_menu', $params-
}
Código de tipos de usuario.
// Include the latest functions only once
require_once dirname(__FILE__).'/helper.php'; $shownumber = $params->get('shownumber', 5);
$names = moduserslatestHelper::getUsers($params);
$linknames = $params->get('linknames', 0);
$moduleclass_sfx = htmlspecialchars($params->get('moduleclass_sfx'));
require JModuleHelper::getLayoutPath('mod_users_latest', $params-
>get('layout', 'default'));
Código de publicación y carga de artículos. require_once dirname(__FILE__).'/helper.php'; $params->def('count', 10);
$moduleclass_sfx = htmlspecialchars($params->get('moduleclass_sfx')); $list = modArchiveHelper::getList($params);
require JModuleHelper::getLayoutPath('mod_articles_archive', $params-
>get('layout', 'default'));
Código de búsqueda en el sitio.
class SearchController extends JControllerLegacy {
/**
* Method to display a view. *
* @param boolean If true, the view output will be
cached
* @param array An array of safe url parameters and their
variable types, for valid values see {@link JFilterInput::clean()}. *
* @return JController This object to support chaining. * @since 1.5
public function display($cachable = false, $urlparams = false) {
JRequest::setVar('view', 'search'); // force it to be the search view return parent::display($cachable, $urlparams);
}
function search() {
// slashes cause errors, <> get stripped anyway later on. # causes problems.
$badchars = array('#', '>', '<', '\\');
$searchword = trim(str_replace($badchars, '',
JRequest::getString('searchword', null, 'post')));
// if searchword enclosed in double quotes, strip quotes and do exact match
if (substr($searchword, 0, 1) == '"' && substr($searchword, -1) == '"') { $post['searchword'] = substr($searchword, 1, -1); JRequest::setVar('searchphrase', 'exact'); } else { $post['searchword'] = $searchword; }
$post['ordering'] = JRequest::getWord('ordering', null, 'post');
$post['searchphrase'] = JRequest::getWord('searchphrase',
'all', 'post');
$post['limit'] = JRequest::getUInt('limit', null, 'post'); if ($post['limit'] === null) unset($post['limit']);
$areas = JRequest::getVar('areas', null, 'post', 'array'); if ($areas) {
foreach($areas as $area) {
$post['areas'][] = JFilterInput::getInstance()- >clean($area, 'cmd');
}
}// set Itemid id for links from menu $app = JFactory::getApplication(); $menu = $app->getMenu(); $items= $menu->getItems('link', 'index.php?option=com_search&view=search'); if(isset($items[0])) { $post['Itemid'] = $items[0]->id;
} elseif (JRequest::getInt('Itemid') > 0) { //use Itemid from requesting page only if there is no existing menu
$post['Itemid'] = JRequest::getInt('Itemid'); } unset($post['task']); unset($post['submit']); $uri = JURI::getInstance(); $uri->setQuery($post); $uri->setVar('option', 'com_search'); $this->setRedirect(JRoute::_('index.php'.$uri- >toString(array('query', 'fragment')), false));
} } Código de encuestas. class VBAnswer { //Variablen
var $db, $user, $document, $id; private $vote;
private function __construct() {
$this->document = & JFactory::getDocument(); $this->db =& JFactory::getDBO();
$this->user =& VBUser::getInstance(); $this->access =& VBAccess::getInstance(); $this->vote =& VBVote::getInstance();
$this->vbparams =& VBParams::getInstance(); $this->log =& VBLog::getInstance();
}
static function &getInstance() { static $instance;
if(empty($instance)) {
$instance = new VBAnswer(); }
return $instance; }
function addAnswer($boxID, $answer, $published, $color) { $this->user->loadUser(true);
$date = new JDate();
$ins = new JObject(); $ins->id = null; $ins->box_id = $boxID; $ins->answer = $answer; $ins->published = $published; $ins->autor_id = $this->user->id; $ins->created = $date->toMySQL(); $ins->color = substr($color, 1); $this->db->insertObject('#__jvotesystem_answers', $ins); $this->id = $this->db->insertid(); if(!$this->db->getErrorMsg()) {
$this->log->add("DB", 'AddedAnswer', array("id"=>$this- >id));
//other extensions
JPluginHelper::importPlugin( 'jvotesystem' ); $dispatcher =& JDispatcher::getInstance();
$res = $dispatcher->trigger( 'onAnswerAdded', array( $this- >id ) ); return true; } else { $this->log->add("ERROR", 'AddingAnswer', array("db_error"=>$this->db->getErrorMsg())); return false; } } function getID() { return $this->id; } function removeAnswer($answer) {
$text = @VBAnswer::getAnswer($answer, false)->answer;
$vbtemplate =& VBTemplate::getInstance();
$path = $vbtemplate-
>getTemplatePath("main").DS."removingAnswer.php"; if(JFile::exists($path)) @require $path;
$sql = 'DELETE FROM `#__jvotesystem_answers` ' . ' WHERE `id` = '.$answer
. ' LIMIT 1';
$this->db->setQuery($sql); $this->db->query();
if($this->db->getErrorMsg()) { $this->log->add("ERROR", 'RemovingAnswer', array("id"=>$answer, "db_error"=>$this->db- >getErrorMsg())); return false; }
$sql = 'DELETE FROM `#__jvotesystem_votes` ' .' WHERE `answer_id` = '.$answer;
$this->db->setQuery($sql); $this->db->query();
$votes = $this->db->getAffectedRows();
if($this->db->getErrorMsg()) { $this->log->add("ERROR", 'RemovingVotesOfAnswer', array("id"=>$answer, "db_error"=>$this->db- >getErrorMsg())); return false; }
$sql = 'DELETE FROM `#__jvotesystem_comments` ' .' WHERE `answer_id` = '.$answer;
$this->db->setQuery($sql); $this->db->query();
$comments = $this->db->getAffectedRows();
if($this->db->getErrorMsg()) { $this->log->add("ERROR", 'RemovingCommentsOfAnswer', array("id"=>$answer, "db_error"=>$this->db- >getErrorMsg())); return false; }
$this->log->add("DB", 'RemovedAnswer', array("id"=> (int)$answer, "answer" => $text, "votes"=>$votes, "comments"=>$comments));
//Tasks
$tasks =& VBTasks::getInstance();
$tasks->removeTask(VBTasks::$_Answer, $answer);
$tasks->removeTask(VBTasks::$_Spam_Answer, $answer);
return true; }
$upd->id = $answerID; $upd->published = $state; $upd->no_spam_admin = 1;
$this->db->updateObject('#__jvotesystem_answers', $upd, 'id'); if($this->db->getErrorMsg()) { $this->log->add("ERROR", 'ChangingPublishStateAnswer', array("id"=>$answerID, "state"=>$state, "db_error"=>$this->db->getErrorMsg())); return false; }
//Tasks
$tasks =& VBTasks::getInstance();
$tasks->removeTask(VBTasks::$_Answer, $answerID); $tasks->removeTask(VBTasks::$_Spam_Answer, $answerID); $this->log->add("DB", 'ChangedPublishStateAnswer', array("id"=>$answerID, "state"=>$state)); return true; }
function getAnswersPageCount($box, $aid, $search = '') {
$answer = $this->vote->getAnswers($box->id, array( "answers" => $aid, 'search' => $search ), 0, 1);
if(empty($answer)) return null;
$answersperpage = (!isset($box->answers_per_page) || $box- >answers_per_page <= 0) ? $this->vbparams->get('answersPerPage') : $box- >answers_per_page;
$seiten = ($answer[0]->counter / $answersperpage); $pages = ceil($seiten);
return $pages; }
function getRankOfAnswer($bid, $aid) {
$answers = $this->vote->getAnswers($bid, array( "answers" => $aid ), 0, 1);
if(empty($answers) || $answers[0]->published == 0) return "#"; return (int)$answers[0]->rank;
}
function getAnswer($answerID, $published = true) {
$sql = 'SELECT a. * , COUNT( c. `id` ) AS comments ' . ' FROM `#__jvotesystem_answers` AS a '
. ' LEFT JOIN `#__jvotesystem_comments` AS c ON ( c. `answer_id` = a. `id` ';
if($published == true) $sql .= ' AND c. `published` = 1 '; $sql .= ' ) '
. ' WHERE a. `id` = '.$this->db->quote($answerID) . ' GROUP BY a. `id`';
$this->db->setQuery($sql); return $this->db->loadObject();
} }//class