Ejemplo n.º 1
0
 public static function award_points($params, $userid, $action, $reference, $info)
 {
     $functions = null;
     switch ($params->get('points_system', 'none')) {
         case 'cjblog':
         case 'touch':
         case 'jomsocial':
         case 'easysocial':
             $functions = array('newsurvey' => 'com_communitysurveys.new_survey', 'response' => 'com_communitysurveys.credits', 'userresponse' => 'com_communitysurveys.survey_response');
             break;
         case 'aup':
             $functions = array('newsurvey' => 'sysplgaup_new_survey', 'response' => 'sysplgaup_survey_response', 'userresponse' => 'sysplgaup_response_points');
             break;
         default:
             return false;
     }
     switch ($action) {
         case 1:
             // new survey
             CJFunctions::award_points($params->get('points_system'), $userid, array('points' => $params->get('points_on_new_survey', 0), 'reference' => $reference, 'info' => $info, 'function' => $functions['newsurvey'], 'component' => 'com_communitysurveys'));
             break;
         case 2:
             // new response - charged to author
             CJFunctions::award_points($params->get('points_system'), $userid, array('points' => $params->get('points_on_new_response', 0), 'reference' => $reference, 'info' => $info, 'function' => $functions['response'], 'component' => 'com_communitysurveys'));
             break;
         case 3:
             // new response - for users
             CJFunctions::award_points($params->get('points_system'), $userid, array('points' => $params->get('points_on_new_response_user', 0), 'reference' => $reference, 'info' => $info, 'function' => $functions['userresponse'], 'component' => 'com_communitysurveys'));
             break;
     }
 }
Ejemplo n.º 2
0
 function display($tpl = null)
 {
     $model = $this->getModel();
     $app = JFactory::getApplication();
     $latest_surveys = $model->get_surveys(array(), 5, 0);
     $this->assignRef('latest_surveys', $latest_surveys['surveys']);
     $pending_surveys = $model->get_surveys(array(), 10, 0, 2);
     $this->assignRef('pending_surveys', $pending_surveys['surveys']);
     $version = $app->getUserState(S_APP_NAME . '.VERSION');
     if (!$version) {
         $version = CJFunctions::get_component_update_check(S_APP_NAME, S_CURR_VERSION);
         $v = array();
         if (!empty($version)) {
             $v['connect'] = (int) $version['connect'];
             $v['version'] = (string) $version['version'];
             $v['released'] = (string) $version['released'];
             $v['changelog'] = (string) $version['changelog'];
             $v['status'] = (string) $version['status'];
             $app->setUserState(S_APP_NAME . '.VERSION', $v);
         }
     }
     $this->assignRef('version', $version);
     $this->addToolBar();
     parent::display($tpl);
 }
Ejemplo n.º 3
0
 function update($parent)
 {
     $db = JFactory::getDBO();
     if (method_exists($parent, 'extension_root')) {
         $sqlfile = $parent->getPath('extension_root') . DS . 'sql' . DS . 'install.mysql.utf8.sql';
     } else {
         $sqlfile = $parent->getParent()->getPath('extension_root') . DS . 'sql' . DS . 'install.mysql.utf8.sql';
     }
     // Don't modify below this line
     $buffer = file_get_contents($sqlfile);
     if ($buffer !== false) {
         jimport('joomla.installer.helper');
         $queries = JInstallerHelper::splitSql($buffer);
         if (count($queries) != 0) {
             foreach ($queries as $query) {
                 $query = trim($query);
                 if ($query != '' && $query[0] != '#') {
                     $db->setQuery($query);
                     if (!$db->query()) {
                         CJFunctions::throw_error(JText::sprintf('JLIB_INSTALLER_ERROR_SQL_ERROR', $db->stderr(true)), 1);
                         return false;
                     }
                 }
             }
         }
     }
     echo '<p>' . JText::sprintf('COM_CJBLOG_UPDATE_TEXT', $parent->get('manifest')->version) . '</p>';
 }
Ejemplo n.º 4
0
 function display($tpl = null)
 {
     JToolBarHelper::title(JText::_('COM_CJBLOG') . " <small>[" . JText::_("COM_CJBLOG_POINT_RULES") . "]</small>");
     JToolBarHelper::divider();
     $model = $this->getModel();
     $app = JFactory::getApplication();
     switch ($this->action) {
         case 'default':
             JToolBarHelper::publishList();
             JToolBarHelper::unpublishList();
             JToolBarHelper::deleteList();
             $return = $model->get_rules();
             $items = $return->rules ? $return->rules : array();
             $this->assignRef('items', $items);
             $this->assignRef('state', $return->state);
             $this->assignRef('pagination', $return->pagination);
             $tpl = null;
             break;
         case 'form':
             JToolBarHelper::save();
             JToolBarHelper::cancel();
             $id = $app->input->getInt('id', 0);
             if (!$id) {
                 return CJFunctions::throw_error(JText::_('COM_CJBLOG_NO_ITEM_FOUND'), 404);
             }
             $rule = $model->get_rule($id);
             $this->assignRef('rule', $rule);
             $tpl = 'form';
             break;
     }
     parent::display($tpl);
 }
Ejemplo n.º 5
0
 public function publish_item()
 {
     $return = $this->change_state('published', true);
     if ($return == 1) {
         $app = JFactory::getApplication();
         $from = $app->getCfg('mailfrom');
         $fromname = $app->getCfg('fromname');
         $sitename = $app->getCfg('sitename');
         $model = $this->getModel('surveys');
         $id = $app->input->getInt('id');
         $survey = $model->get_survey_details($id);
         if (!empty($survey)) {
             $body = JText::sprintf('COM_COMMUNITYSURVEYS_NOTIF_APPROVAL_BODY', $survey->name, $survey->title, $sitename);
             $title = JText::sprintf('COM_COMMUNITYSURVEYS_NOTIF_APPROVAL_TITLE', $sitename);
             CJFunctions::send_email($from, $fromname, $survey->email, $title, $body, 1);
         }
         echo json_encode(array('data' => 1));
     } else {
         if (!JFactory::getUser()->authorise('core.edit.state', S_APP_NAME)) {
             echo json_encode(array('error' => JText::_('COM_COMMUNITYSURVEYS_NOT_AUTHORIZED')));
         } else {
             $msg = $return == 0 ? JText::_('COM_COMMUNITYSURVEYS_MSG_ERROR') : JText::_('COM_COMMUNITYSURVEYS_MSG_NO_ITEM_SELECTED');
             echo json_encode(array('error' => $msg));
         }
     }
     jexit();
 }
Ejemplo n.º 6
0
 function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $model = $this->getModel();
     $document = JFactory::getDocument();
     $pathway = $app->getPathway();
     $active = $app->getMenu()->getActive();
     $this->print = $app->input->getBool('print');
     /********************************** PARAMS *****************************/
     $appparams = JComponentHelper::getParams(CJBLOG);
     $menuParams = new JRegistry();
     if ($active) {
         $menuParams->loadString($active->params);
     }
     $this->params = clone $menuParams;
     $this->params->merge($appparams);
     /********************************** PARAMS *****************************/
     $limit = $app->getCfg('list_limit', 20);
     $limitstart = $app->input->getInt('limitstart', 0);
     $limitstart = $limit != 0 ? floor($limitstart / $limit) * $limit : 0;
     $keywords = $app->input->getString('search', null);
     $itemid = CJFunctions::get_active_menu_id();
     $user = JFactory::getUser();
     $return = $model->get_tags($limitstart, $limit, $this->params, $keywords);
     $this->assignRef('items', $return['tags']);
     $this->assignRef('pagination', $return['pagination']);
     $this->assign('task', null);
     $this->assign('brand', JText::_('LBL_TAGS'));
     $this->assign('brand_url', JRoute::_('index.php?option=' . CJBLOG . '&view=tags' . $itemid));
     $this->assign('page_url', 'index.php?option=' . CJBLOG . '&view=tags' . $itemid);
     $page_heading = JText::_('LBL_TAGS');
     $pathway->addItem($page_heading);
     // set browser title
     $this->params->set('page_heading', $this->params->get('page_heading', $page_heading));
     if ($app->getCfg('sitename_pagetitles', 0) == 1) {
         $document->setTitle(JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $page_heading));
     } elseif ($app->getCfg('sitename_pagetitles', 0) == 2) {
         $document->setTitle(JText::sprintf('JPAGETITLE', $page_heading, $app->getCfg('sitename')));
     }
     // set meta description
     if ($this->params->get('menu-meta_description')) {
         $document->setDescription($this->params->get('menu-meta_description'));
     }
     // set meta keywords
     if ($this->params->get('menu-meta_keywords')) {
         $document->setMetadata('keywords', $this->params->get('menu-meta_keywords'));
     }
     // set robots
     if ($this->params->get('robots')) {
         $document->setMetadata('robots', $this->params->get('robots'));
     }
     // set nofollow if it is print
     if ($this->print) {
         $document->setMetaData('robots', 'noindex, nofollow');
     }
     parent::display($tpl);
 }
Ejemplo n.º 7
0
 public function display($data = null)
 {
     $app = JFactory::getApplication();
     $doc = JFactory::getDocument();
     $params = $app->getParams();
     $model = $this->getModel();
     // Get some data from the model
     $limit = $app->getCfg('feed_limit');
     $catid = $app->input->getInt('catid', 0);
     $active = $app->getMenu()->getActive();
     $site_email = $app->getCfg('mailfrom');
     $itemid = CJFunctions::get_active_menu_id(false);
     if (!$catid) {
         $menuparams = $app->getMenu()->getParams($itemid);
         $catid = (int) $menuparams->get('catid', 0);
         $app->input->set('catid', $catid);
     }
     /********************************** PARAMS *****************************/
     $appparams = JComponentHelper::getParams(Q_APP_NAME);
     $menuParams = new JRegistry();
     if ($active) {
         $menuParams->loadString($active->params);
     }
     $this->params = clone $menuParams;
     $this->params->merge($appparams);
     /********************************** PARAMS *****************************/
     $options = array('catid' => $catid, 'limit' => $limit, 'limitstart' => 0, 'order' => 'a.created', 'order_dir' => 'desc');
     $return = $model->get_surveys(1, $options, $this->params);
     if (!empty($return['surveys'])) {
         foreach ($return['surveys'] as $row) {
             // strip html from feed item title
             $title = $this->escape($row->title);
             $title = html_entity_decode($title, ENT_COMPAT, 'UTF-8');
             // url link to question
             $link = JRoute::_('index.php?option=' . Q_APP_NAME . '&view=response&task=take_survey&id=' . $row->id . ':' . $row->alias . '&Itemid=' . $itemid);
             // strip html from feed item description text
             $description = $row->description;
             $author = $row->created_by_alias;
             @($date = $row->created ? date('r', strtotime($row->created)) : '');
             // load individual item creator class
             $item = new JFeedItem();
             $item->title = $title;
             $item->link = $link;
             $item->description = $description;
             $item->date = $date;
             $item->category = $row->category_title;
             $item->author = $author;
             if ($site_email == 'site') {
                 $item->authorEmail = $site_email;
             } else {
                 $item->authorEmail = $row->email;
             }
             // loads item info into rss array
             $doc->addItem($item);
         }
     }
 }
Ejemplo n.º 8
0
 public static function fontawesome($custom_tag = true)
 {
     $app = JFactory::getApplication();
     $doc = JFactory::getDocument();
     // Load FontAwesome if it not already loaded
     if (!isset($app->cjfa)) {
         CJFunctions::add_css_to_document($doc, CJLIB_MEDIA_URI . '/fontawesome/css/font-awesome.min.css', $custom_tag);
         $app->cjfa = true;
     }
 }
Ejemplo n.º 9
0
 function get_user_points()
 {
     if (JFactory::getUser()->guest) {
         CJFunctions::throw_error(JText::_('JERROR_ALERTNOAUTHOR'), 401);
     } else {
         $view = $this->getView('user', 'html');
         $model = $this->getModel('users');
         $view->setModel($model, true);
         $view->assign('action', 'user_points');
         $view->display();
     }
 }
Ejemplo n.º 10
0
 function display($tpl = null)
 {
     JToolBarHelper::title(JText::_('COM_CJBLOG') . " <small>[" . JText::_("COM_CJBLOG_BADGES") . "]</small>");
     JToolBarHelper::divider();
     $model = $this->getModel();
     $app = JFactory::getApplication();
     switch ($this->action) {
         case 'default':
             JToolBarHelper::addNew();
             JToolBarHelper::editList();
             JToolBarHelper::publishList();
             JToolBarHelper::unpublishList();
             JToolBarHelper::deleteList();
             $return = $model->get_badges();
             $items = $return->badges ? $return->badges : array();
             $this->assignRef('items', $items);
             $this->assignRef('state', $return->state);
             $this->assignRef('pagination', $return->pagination);
             $tpl = null;
             break;
         case 'add':
             JToolBarHelper::save();
             JToolBarHelper::cancel();
             $components = $model->get_components();
             $badge = new stdClass();
             $badge->title = $badge->alias = $badge->name = $badge->description = $badge->asset_name = $badge->icon = $badge->css_class = '';
             $badge->id = $badge->published = 0;
             $this->assignRef('components', $components);
             $this->assignRef('badge', $badge);
             $tpl = 'form';
             break;
         case 'edit':
             JToolBarHelper::save();
             JToolBarHelper::cancel();
             if (!empty($this->badge)) {
                 $app->enqueueMessage($model->getError());
                 $this->assignRef('badge', $this->badge);
             } else {
                 $id = $app->input->getInt('id', 0);
                 if (!$id) {
                     return CJFunctions::throw_error(JText::_('COM_CJBLOG_NO_ITEM_FOUND'), 404);
                 }
                 $badge = $model->get_badge($id);
                 $this->assignRef('badge', $badge);
             }
             $components = $model->get_components();
             $this->assignRef('components', $components);
             $tpl = 'form';
             break;
     }
     parent::display($tpl);
 }
Ejemplo n.º 11
0
 function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $active = $app->getMenu()->getActive();
     $cache = JFactory::getCache();
     $user = JFactory::getUser();
     $model = $this->getModel();
     $articles_model = $this->getModel('articles');
     /********************************** PARAMS *****************************/
     $appparams = JComponentHelper::getParams(CJBLOG);
     $menuParams = new JRegistry();
     if ($active) {
         $menuParams->loadString($active->params);
     }
     $this->params = clone $menuParams;
     $this->params->merge($appparams);
     /********************************** PARAMS *****************************/
     $id = $app->input->getInt('id', 0);
     if (!$id) {
         if (!$user->guest) {
             $id = $user->id;
         } else {
             if ($this->params->get('blogUserId', 0) > 0) {
                 $id = $this->params->get('blogUserId');
             } else {
                 CJFunctions::throw_error(JText::_('MSG_NO_USER_FOUND'), 403);
                 return;
             }
         }
     }
     $limitstart = $app->input->getInt('start', 0);
     $limitstart = floor($limitstart / 5) * 5;
     $profile = $cache->call(array('CjBlogApi', 'get_user_profile'), $id);
     $articles = $model->get_articles(array('published' => 1, 'pagination' => true, 'limitstart' => $limitstart, 'limit' => 5, 'order' => 'a.created', 'order_dir' => 'desc', 'user_id' => $id));
     $this->assignRef('user', $profile);
     $this->assignRef('articles', $articles->articles);
     $this->assignRef('pagination', $articles->pagination);
     $document = JFactory::getDocument();
     $title = JText::sprintf('TXT_USERS_BLOG', addslashes($profile['name']));
     $title = CjBlogHelper::get_page_title($title);
     $document->setTitle($title);
     if ($this->params->get('menu-meta_description')) {
         $document->setDescription($this->params->get('menu-meta_description'));
     }
     if ($this->params->get('menu-meta_keywords')) {
         $document->setMetadata('keywords', $this->params->get('menu-meta_keywords'));
     }
     if ($this->params->get('robots')) {
         $document->setMetadata('robots', $this->params->get('robots'));
     }
     parent::display($tpl);
 }
Ejemplo n.º 12
0
 public function load_users_from_items($items, $component)
 {
     if (empty($items) || $component == 'none') {
         return;
     }
     $ids = array();
     foreach ($items as $item) {
         $ids[] = $item->created_by;
     }
     if (!empty($ids)) {
         CJFunctions::load_users($component, $ids);
     }
 }
Ejemplo n.º 13
0
 function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $active = $app->getMenu()->getActive();
     $cache = JFactory::getCache();
     $user = JFactory::getUser();
     $document = JFactory::getDocument();
     $model = $this->getModel();
     $articles_model = $this->getModel('articles');
     /********************************** PARAMS *****************************/
     $appparams = JComponentHelper::getParams(CJBLOG);
     $menuParams = new JRegistry();
     if ($active) {
         $menuParams->loadString($active->params);
     }
     $this->params = clone $menuParams;
     $this->params->merge($appparams);
     /********************************** PARAMS *****************************/
     $document->addScript(CJBLOG_MEDIA_URI . 'js/jquery.form.js');
     $document->addScript(CJBLOG_MEDIA_URI . 'js/jquery.Jcrop.min.js');
     $id = $app->input->getInt('id', 0);
     if (!$id) {
         if (!$user->guest) {
             $id = $user->id;
         } else {
             CJFunctions::throw_error(JText::_('MSG_NO_USER_FOUND'), 403);
             return;
         }
     }
     if ($user->id != $id) {
         $model->hit($id);
     }
     $profile = $cache->call(array('CjBlogApi', 'get_user_profile'), $id);
     // 		$badges = $cache->call(array('CjBlogApi', 'get_user_badges'), $id);
     // 		$articles = $cache->call(array($articles_model, 'get_articles'), array('published'=>1, 'pagination'=>false, 'limitstart'=>0, 'limit'=>5, 'user_id'=>$id));
     if (!$profile) {
         CJFunctions::throw_error(JText::_('MSG_NO_USER_FOUND'), 403);
     }
     $this->assignRef('profile', $profile);
     $document->setTitle(CjBlogHelper::get_page_title($profile['name']));
     if ($this->params->get('menu-meta_description')) {
         $document->setDescription($this->params->get('menu-meta_description'));
     }
     if ($this->params->get('menu-meta_keywords')) {
         $document->setMetadata('keywords', $this->params->get('menu-meta_keywords'));
     }
     if ($this->params->get('robots')) {
         $document->setMetadata('robots', $this->params->get('robots'));
     }
     parent::display($tpl);
 }
Ejemplo n.º 14
0
 public function get_my_responses()
 {
     $user = JFactory::getUser();
     if ($user->guest) {
         $itemid = CJFunctions::get_active_menu_id();
         $redirect_url = base64_encode(JRoute::_('index.php?option=' . S_APP_NAME . '&view=survey' . $itemid));
         $this->setRedirect(CJFunctions::get_login_url($redirect_url, $itemid), JText::_('MSG_NOT_LOGGED_IN'));
     } else {
         $model = $this->getModel('survey');
         $view = $this->getView('user', 'html');
         $view->setModel($model, true);
         $view->assign('action', 'responses');
         $view->display('responses');
     }
 }
Ejemplo n.º 15
0
 function upload_avatar()
 {
     $input = JFactory::getApplication()->input;
     $user = JFactory::getUser();
     $id = $input->getInt('id', 0);
     $xhr = $input->server->get('HTTP_X_REQUESTED_WITH') == 'XMLHttpRequest';
     if (!$xhr) {
         echo '<textarea>';
     }
     if ($user->id != $id && !$user->authorise('core.manage')) {
         echo json_encode(array('error' => JText::_('JERROR_ALERTNOAUTHOR')));
     } else {
         if (!$id) {
             echo json_encode(array('error' => JText::_('MSG_ERROR_PROCESSING')));
         } else {
             $tmp_file = $input->files->get('input-avatar-image');
             if ($tmp_file['error'] > 0) {
                 echo json_encode(array('error' => JText::_('MSG_ERROR_PROCESSING')));
             } else {
                 $temp_image_path = $tmp_file['tmp_name'];
                 $temp_image_name = $tmp_file['name'];
                 $temp_image_ext = JFile::getExt($temp_image_name);
                 list($temp_image_width, $temp_image_height, $temp_image_type) = getimagesize($temp_image_path);
                 if ($temp_image_type === NULL || $temp_image_width < 128 || $temp_image_height < 128 || !in_array(strtolower($temp_image_ext), array('png', 'jpg', 'gif')) || !in_array($temp_image_type, array(IMAGETYPE_PNG, IMAGETYPE_JPEG, IMAGETYPE_GIF))) {
                     echo json_encode(array('error' => JText::_('MSG_INVALID_IMAGE_FILE')));
                 } else {
                     $user_profile = CjBlogApi::get_user_profile($id);
                     $file_name = '';
                     if (!empty($user_profile['avatar'])) {
                         $file_name = $user_profile['avatar'];
                     } else {
                         $file_name = CJFunctions::generate_random_key(25, 'abcdefghijklmnopqrstuvwxyz1234567890') . '.' . $temp_image_ext;
                     }
                     $uploaded_image_path = CJBLOG_AVATAR_BASE_DIR . 'original' . DS . $file_name;
                     if (JFile::upload($temp_image_path, $uploaded_image_path)) {
                         echo json_encode(array('avatar' => array('url' => CJBLOG_AVATAR_BASE_URI . 'original/' . $file_name, 'file_name' => $file_name, 'width' => $temp_image_width, 'height' => $temp_image_height)));
                     } else {
                         echo json_encode(array('error' => JText::_('MSG_ERROR_PROCESSING')));
                     }
                 }
             }
         }
     }
     if (!$xhr) {
         echo '</textarea>';
     }
     jexit();
 }
Ejemplo n.º 16
0
 function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $model = $this->getModel();
     $active = $app->getMenu()->getActive();
     $pathway = $app->getPathway();
     $this->print = $app->input->getBool('print');
     /********************************** PARAMS *****************************/
     $appparams = JComponentHelper::getParams(S_APP_NAME);
     $menuParams = new JRegistry();
     if ($active) {
         $menuParams->loadString($active->params);
     }
     $this->params = clone $menuParams;
     $this->params->merge($appparams);
     /********************************** PARAMS *****************************/
     $limit = $this->params->get('list_length', $app->getCfg('list_limit', 20));
     $limitstart = $app->input->getInt('start', 0);
     $limitstart = $limit != 0 ? floor($limitstart / $limit) * $limit : 0;
     $itemid = CJFunctions::get_active_menu_id();
     $survey_itemid = CJFunctions::get_active_menu_id(true, 'index.php?option=' . S_APP_NAME . '&view=survey');
     $user = JFactory::getUser();
     switch ($this->action) {
         case 'surveys':
             $options = array('userid' => $user->id, 'limit' => $limit, 'limitstart' => $limitstart, 'order' => 'a.created', 'order_dir' => 'desc');
             $return = $model->get_surveys(4, $options, $this->params);
             $this->assignRef('items', $return['surveys']);
             $this->assignRef('state', $return['state']);
             $this->assignRef('pagination', $return['pagination']);
             $this->assign('task', null);
             $this->assign('brand', JText::_('LBL_HOME'));
             $this->assign('brand_url', JRoute::_('index.php?option=' . S_APP_NAME . '&view=survey' . $survey_itemid));
             $this->assign('page_url', 'index.php?option=' . S_APP_NAME . '&view=users&task=my_surveys' . $itemid);
             break;
         case 'responses':
             $return = $model->get_responses(0, $user->id);
             $this->assignRef('items', $return->rows);
             $this->assignRef('pagination', $return->pagination);
             $this->assignRef('lists', $return->lists);
             $this->assign('task', null);
             $this->assign('brand', JText::_('LBL_HOME'));
             $this->assign('brand_url', JRoute::_('index.php?option=' . S_APP_NAME . '&view=survey' . $survey_itemid));
             $this->assign('page_url', 'index.php?option=' . S_APP_NAME . '&view=users&task=my_responses' . $itemid);
             break;
     }
     $pathway->addItem($this->brand);
     parent::display($tpl);
 }
Ejemplo n.º 17
0
 function display($tpl = null)
 {
     JToolBarHelper::title(JText::_('COM_CJBLOG') . " <small>[" . JText::_("COM_CJBLOG_BADGE_RULES") . "]</small>");
     JToolBarHelper::divider();
     $model = $this->getModel();
     $app = JFactory::getApplication();
     switch ($this->action) {
         case 'rule_list':
             JToolBarHelper::addNew();
             JToolBarHelper::editList();
             JToolBarHelper::publishList();
             JToolBarHelper::unpublishList();
             JToolBarHelper::deleteList();
             $return = $model->get_badge_rules();
             $items = !empty($return->rules) ? $return->rules : array();
             $this->assignRef('items', $items);
             $this->assignRef('state', $return->state);
             $this->assignRef('pagination', $return->pagination);
             break;
         case 'rule_types':
             JToolBarHelper::cancel();
             $rule_types = $model->get_rule_types();
             $this->assignRef('rules', $rule_types);
             $tpl = 'rule_types';
             break;
         case 'edit':
             JToolBarHelper::cancel();
             JToolBarHelper::save();
             $id = $app->input->getInt('id', 0);
             $name = $app->input->getCmd('name', null);
             $asset_name = $app->input->getCmd('asset', null);
             if ($id > 0 || !empty($name) && !empty($asset_name)) {
                 $rule_type = $model->get_rule_type($id, $asset_name, $name);
                 if (empty($rule_type)) {
                     return CJFunctions::throw_error(JText::_('COM_CJBLOG_ERROR_PROCESSING'), 404);
                 }
                 $this->assignRef('rule_type', $rule_type);
             } else {
                 return CJFunctions::throw_error(JText::_('COM_CJBLOG_NO_ITEM_FOUND'), 404);
             }
             $tpl = 'rule_form';
             break;
     }
     parent::display($tpl);
 }
Ejemplo n.º 18
0
 function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $model = $this->getModel();
     $document = JFactory::getDocument();
     $user = JFactory::getUser();
     $usermodel = $this->getModel('users');
     $active = $app->getMenu()->getActive();
     $this->print = $app->input->getBool('print');
     /********************************** PARAMS *****************************/
     $this->params = JComponentHelper::getParams(S_APP_NAME);
     /********************************** PARAMS *****************************/
     $page_heading = JText::_('LBL_INVITE_USERS');
     $itemid = CJFunctions::get_active_menu_id();
     $id = $app->input->getInt('id', 0);
     $survey = $model->get_survey_details($id);
     $contact_groups = $model->get_contact_groups($user->id);
     $credits = $model->check_user_credits();
     $contacts = $model->get_contacts($user->id, 3, 0, true);
     $jsgroups = $usermodel->get_jomsocial_user_groups($survey->created_by, true);
     $unique_urls = $model->get_survey_keys($id);
     $this->assignRef('item', $survey);
     $this->assignRef('contact_groups', $contact_groups);
     $this->assignRef('contacts', $contacts);
     $this->assignRef('credits', $credits);
     $this->assignRef('jsgroups', $jsgroups);
     $this->assignRef('unique_urls', $unique_urls);
     JToolBarHelper::preferences(S_APP_NAME);
     JToolBarHelper::cancel();
     $document->addScript(JUri::root(true) . '/media/' . S_APP_NAME . '/js/cj.surveys.min.js');
     // set browser title
     $this->params->set('page_heading', $this->params->get('page_heading', $page_heading));
     $title = $this->params->get('page_title', $app->getCfg('sitename'));
     if ($app->getCfg('sitename_pagetitles', 0) == 1) {
         $document->setTitle(JText::sprintf('COM_COMMUNITYSURVEYS_JPAGETITLE', $title, $page_heading));
     } elseif ($app->getCfg('sitename_pagetitles', 0) == 2) {
         $document->setTitle(JText::sprintf('COM_COMMUNITYSURVEYS_JPAGETITLE', $page_heading, $title));
     } else {
         $document->setTitle($page_heading);
     }
     JToolBarHelper::title(JText::_('COM_COMMUNITYSURVEYS') . ': <small><small>[ ' . JText::_('COM_COMMUNITYSURVEYS_INVITE') . ' ]</small></small>', 'logo.png');
     parent::display($tpl);
 }
Ejemplo n.º 19
0
 function get_article_form()
 {
     $user = JFactory::getUser();
     $app = JFactory::getApplication();
     $view = $this->getView('form', 'html');
     $model = $this->getModel('articles');
     $id = $app->input->getInt('id', 0);
     if ($id > 0) {
         $asset = 'com_content.article.' . $id;
         if (!$user->authorise('core.edit', $asset) && !$user->authorise('core.edit.own', $asset)) {
             CJFunctions::throw_error(JText::_('JERROR_ALERTNOAUTHOR'), 401);
             return false;
         }
         jimport('joomla.database.table');
         JTable::addIncludePath(JPATH_PLATFORM . DS . 'joomla' . DS . 'database' . DS . 'table' . DS);
         $row = JTable::getInstance('content');
         if (!$row || !$row->load($id)) {
             CJFunctions::throw_error($row->getError(), 403);
         }
         if (!$row->checkout($user->id)) {
             return CJFunctions::throw_error($row->getError(), 403);
         } else {
             $this->holdEditId('com_content.edit.article', $id);
         }
     } else {
         if ($user->guest) {
             $itemid = CJFunctions::get_active_menu_id();
             $form_itemid = CJFunctions::get_active_menu_id(true, 'index.php?option=' . CJBLOG . '&view=form');
             $redirect = base64_encode(JRoute::_('index.php?option=' . CJBLOG . '&view=form' . $form_itemid));
             $this->setRedirect(JRoute::_('index.php?option=com_users&view=login' . $itemid . '&return=' . $redirect, false), JText::_('COM_CJBLOG_USER_LOGIN'));
             return false;
         } else {
             if (!$user->authorise('core.create', 'com_content')) {
                 CJFunctions::throw_error(JText::_('JERROR_ALERTNOAUTHOR'), 401);
                 return false;
             }
         }
     }
     $view->setModel($model, true);
     $view->assign('action', 'form');
     $view->display();
 }
Ejemplo n.º 20
0
 function display($tpl = null)
 {
     JToolBarHelper::title(JText::_('COM_CJBLOG') . " <small>[" . JText::_("COM_CJBLOG_CONTROL_PANEL") . "]</small>");
     $app = JFactory::getApplication();
     $version = $app->getUserState(CJBLOG . '.VERSION', null);
     if (!$version) {
         $version = CJFunctions::get_component_update_check(CJBLOG, CJBLOG_VERSION);
         $v = array();
         if (!empty($version)) {
             $v['connect'] = (int) $version['connect'];
             $v['version'] = (string) $version['version'];
             $v['released'] = (string) $version['released'];
             $v['changelog'] = (string) $version['changelog'];
             $v['status'] = (string) $version['status'];
             $app->setUserState(CJBLOG . '.VERSION', $v);
         }
     }
     $this->assignRef('version', $version);
     parent::display($tpl);
 }
Ejemplo n.º 21
0
 function get_all_surveys()
 {
     $user = JFactory::getUser();
     if ($user->guest) {
         $itemid = CJFunctions::get_active_menu_id();
         $redirect_url = base64_encode(JRoute::_('index.php?option=' . S_APP_NAME . '&view=survey&task=all' . $itemid));
         $this->setRedirect(CJFunctions::get_login_url($redirect_url, $itemid), JText::_('MSG_NOT_LOGGED_IN'));
     } else {
         if ($user->authorise('core.manage', S_APP_NAME)) {
             $view = $this->getView('survey', 'html');
             $model = $this->getModel('survey');
             $users_model = $this->getModel('users');
             $categories_model = $this->getModel('categories');
             $view->setModel($model, true);
             $view->setModel($users_model, false);
             $view->setModel($categories_model, false);
             $view->assign('action', 'all_surveys');
             $view->display();
         } else {
             CJFunctions::throw_error(JText::_('MSG_UNAUTHORIZED'), 401);
         }
     }
 }
Ejemplo n.º 22
0
    echo $row->city;
    ?>
</td>
					<td class="center"><?php 
    echo $row->responses;
    ?>
</td>
				</tr>
				<?php 
}
?>
			</tbody>
		</table>
		<div class="row-fluid">
			<?php 
echo CJFunctions::get_pagination('index.php?option=' . S_APP_NAME . '&view=reports&task=location_report&id=' . $this->item->id . ':' . $this->item->alias . $itemid, $this->pagination->get('pages.start'), $this->pagination->get('pages.current'), $this->pagination->get('pages.total'), $this->pagination->get('limit'), true);
?>
		</div>
		<input type="hidden" name="boxchecked" value="0" />
		<input type="hidden" name="filter_order" id="filter_order" value="<?php 
echo $this->lists['order'];
?>
" />
		<input type="hidden" name="filter_order_Dir" id="filter_order_Dir" value="<?php 
echo $this->lists['order_dir'];
?>
" />
	</form>
	
	<div style="display: none;">
		<input type="hidden" name="cjpageid" id="cjpageid" value="report_locations">
Ejemplo n.º 23
0
<?php

/**
 * @version		$Id: default.php 01 2012-04-30 11:37:09Z maverick $
 * @package		CoreJoomla.Surveys
 * @subpackage	Components.site
 * @copyright	Copyright (C) 2009 - 2012 corejoomla.com, Inc. All rights reserved.
 * @author		Maverick
 * @link		http://www.corejoomla.com/
 * @license		License GNU General Public License version 2 or later
 */
defined('_JEXEC') or die;
$user = JFactory::getUser();
$page_id = 6;
$editor = $user->authorise('core.wysiwyg', S_APP_NAME) ? $this->params->get('default_editor', 'bbcode') : 'none';
CJFunctions::load_jquery(array('libs' => array('validate', 'form')));
?>


<div id="cj-wrapper">
	
	<?php 
include_once JPATH_COMPONENT . DS . 'helpers' . DS . 'header.php';
?>
	
	<h2 class="page-header"><?php 
echo $this->escape($this->item->title);
?>
</h2>

	<div class="container-fluid no-space-left no-space-right surveys-wrapper">
Ejemplo n.º 24
0
<?php

/**
 * @version		$Id: header.php 01 2011-08-13 11:37:09Z maverick $
 * @package		CoreJoomla.Surveys
 * @subpackage	Components
 * @copyright	Copyright (C) 2009 - 2011 corejoomla.com. All rights reserved.
 * @author		Maverick
 * @link		http://www.corejoomla.com/
 * @license		License GNU General Public License version 2 or later
 */
defined('_JEXEC') or die;
$user = JFactory::getUser();
$itemid = CJFunctions::get_active_menu_id();
$user_itemid = CJFunctions::get_active_menu_id(true, 'index.php?option=' . S_APP_NAME . '&view=user');
$surveys_itemid = CJFunctions::get_active_menu_id(true, 'index.php?option=' . S_APP_NAME . '&view=survey');
$catparam = !empty($catparam) ? $catparam : '';
?>

<?php 
if ($this->params->get('display_toolbar', 1) == 1 && !$this->print && $page_id >= 0) {
    ?>
<div class="navbar">
	<div class="navbar-inner">
		<div class="header-container">

			<a class="btn btn-navbar" data-toggle="collapse" data-target=".cs-nav-collapse"> 
				<span class="icon-bar"></span> 
				<span class="icon-bar"></span> 
				<span class="icon-bar"></span>
			</a>
Ejemplo n.º 25
0
?>
					</div>
					
					<div class="clearfix margin-top-20">
						<label>
							<?php 
echo JText::_('LBL_CUSTOMHEADER');
?>
:
							<i class="icon-info-sign tooltip-hover" title="<?php 
echo JText::_('HLP_CUSTOMHEADER');
?>
"></i>
						</label>
						<?php 
echo CJFunctions::load_editor($editor, 'custom_header', 'custom_header', $this->item->custom_header, '5', '40', '99%', '200px', '', 'width: 99%;');
?>
					</div>
				</div>
				
				<div class="span6">
					<h3 class="page-header"><?php 
echo JText::_('LBL_SURVEY_OPTIONS');
?>
</h3>
					<div class="form-horizontal">
						<div class="control-group">
							<label class="control-label">
								<?php 
echo JText::_('LBL_SURVEYTYPE');
?>
Ejemplo n.º 26
0
<?php

/**
 * @version		$Id: default_contacts.php 01 2012-04-30 11:37:09Z maverick $
 * @package		CoreJoomla.Surveys
 * @subpackage	Components.site
 * @copyright	Copyright (C) 2009 - 2012 corejoomla.com, Inc. All rights reserved.
 * @author		Maverick
 * @link		http://www.corejoomla.com/
 * @license		License GNU General Public License version 2 or later
 */
defined('_JEXEC') or die;
$itemid = CJFunctions::get_active_menu_id();
?>
<div class="invite-contacts-wrapper">
	<div class="tabbable">
		<ul class="nav nav-tabs">
			<li class="active"><a href="#tab-contact-groups" data-toggle="tab"><?php 
echo JText::_('LBL_CONTACT_GROUPS');
?>
</a></li>
			<li><a href="#tab-contacts" data-toggle="tab"><?php 
echo JText::_('LBL_CONTACTS');
?>
</a></li>
		</ul>
		<div class="tab-content">
			<div class="tab-pane active" id="tab-contact-groups">
				<button type="button" class="btn btn-small btn-success btn-create-contact-group">
					<i class="fa fa-plus-square"></i> <?php 
echo JText::_('LBL_NEW');
Ejemplo n.º 27
0
            ?>
"><?php 
            echo JText::_('LBL_INVITE');
            ?>
</a>
						<a href="<?php 
            echo JRoute::_('index.php?option=' . S_APP_NAME . '&view=reports&task=dashboard&id=' . $item->id . ':' . $item->alias . $itemid);
            ?>
"><?php 
            echo JText::_('LBL_REPORTS');
            ?>
</a>
						<?php 
        }
        ?>
					</small>
				</div>
			</div>
		</div>
		<?php 
    }
    ?>
		<?php 
}
?>
		
		<?php 
echo CJFunctions::load_module_position('surveys-results-bottom');
?>
	</div>
</div>
Ejemplo n.º 28
0
		<div class="pull-left margin-right-10 avatar hidden-phone">
			<?php 
    echo CJFunctions::get_user_avatar($this->params->get('user_avatar'), $this->item->response->created_by, $this->params->get('user_display_name'), $this->params->get('avatar_size'), $this->item->response->email, array('class' => 'thumbnail tooltip-hover', 'title' => $this->item->response->username), array('class' => 'media-object', 'style' => 'height:' . $this->params->get('avatar_size') . 'px'));
    ?>
		</div>
		<?php 
}
?>

		<div class="form-inline">
			<label><?php 
echo JText::_('LBL_USERNAME');
?>
: </label>
			<?php 
echo $this->item->response->created_by > 0 ? CJFunctions::get_user_profile_link($this->params->get('user_avatar'), $this->item->response->created_by, $this->escape($this->item->response->username)) : $this->escape($this->item->response->username);
?>
		</div>
		<div class="form-inline">
			<label><?php 
echo JText::_('LBL_DATE');
?>
: </label> 
			<?php 
echo $this->escape($this->item->response->created);
?>
		</div>
	</div>
	
	<div class="results-wrapper margin-top-20">
	<?php 
Ejemplo n.º 29
0
 function generatePdfReport($pdfData, $mode, $params, $fileName)
 {
     $countries = CJFunctions::get_country_names();
     $responses = array();
     $include_email_in_reports = $params->get('include_email_in_reports', 0);
     foreach ($pdfData->responses as $response) {
         $responses[$response->id] = new stdClass();
         $responses[$response->id]->created_by = $response->created_by;
         $responses[$response->id]->created = $response->created;
         $responses[$response->id]->username = $response->username;
         $responses[$response->id]->name = $response->name;
         if ($include_email_in_reports == 1) {
             $responses[$response->id]->email = $response->email;
         }
         $responses[$response->id]->questions = array();
         foreach ($pdfData->questions as $question) {
             $responses[$response->id]->questions[$question->id] = new stdClass();
             $responses[$response->id]->questions[$question->id]->answer = '';
             $responses[$response->id]->questions[$question->id]->question_type = $question->question_type;
         }
     }
     if (!empty($pdfData->entries)) {
         foreach ($pdfData->entries as $entry) {
             if (isset($responses[$entry->response_id]) && isset($responses[$entry->response_id]->questions[$entry->question_id])) {
                 if (!empty($entry->answer)) {
                     if (empty($responses[$entry->response_id]->questions[$entry->question_id]->answer)) {
                         $responses[$entry->response_id]->questions[$entry->question_id]->answer = $entry->answer;
                     } else {
                         $responses[$entry->response_id]->questions[$entry->question_id]->answer .= '<br/>' . $entry->answer;
                     }
                     if (!empty($entry->answer_image) && JFile::exists(S_IMAGES_UPLOAD_DIR . '/' . $entry->answer_image)) {
                         //$image = JHtml::image(JURI::root(true).'/media/communitysurveys/images/'.$entry->answer_image, $entry->answer);
                         $image = '<img src="' . JURI::root(true) . '/media/communitysurveys/images/' . $entry->answer_image . '">';
                         $responses[$entry->response_id]->questions[$entry->question_id]->answer .= '<br/>' . $image;
                     }
                 }
                 if (!empty($entry->answer2)) {
                     if (empty($responses[$entry->response_id]->questions[$entry->question_id]->answer)) {
                         $responses[$entry->response_id]->questions[$entry->question_id]->answer = $entry->answer2;
                     } else {
                         $responses[$entry->response_id]->questions[$entry->question_id]->answer .= '<br/>' . $entry->answer2;
                     }
                 }
                 if (!empty($entry->free_text)) {
                     // do special types formatting //
                     if ($responses[$entry->response_id]->questions[$entry->question_id]->question_type == S_SPECIAL_NAME) {
                         $names = explode('|', $entry->free_text);
                         if (!empty($names)) {
                             $entry->free_text = $names[0] . '. ' . $names[1] . ' ' . $names[2];
                         } else {
                             $entry->free_text = '';
                         }
                     } else {
                         if ($responses[$entry->response_id]->questions[$entry->question_id]->question_type == S_SPECIAL_ADDRESS) {
                             $parts = explode('|||', $entry->free_text);
                             if (count($parts) == 7) {
                                 $entry->free_text = '<address><strong>' . CJFunctions::escape($parts[0]) . '</strong><br>';
                                 $entry->free_text .= CJFunctions::escape($parts[1]) . '<br>';
                                 if (!empty($parts[2])) {
                                     $entry->free_text .= CJFunctions::escape($parts[2]) . '<br>';
                                 }
                                 $entry->free_text .= CJFunctions::escape($parts[3]) . ', ' . CJFunctions::escape($parts[4]) . ', ' . CJFunctions::escape($parts[6]) . '<br>';
                                 $entry->free_text .= !empty($countries[$parts[5]]) ? $countries[$parts[5]]->country_name : CJFunctions::escape($parts[5]);
                             } else {
                                 $entry->free_text = '';
                             }
                         }
                     }
                     // do special types formatting //
                     if (empty($responses[$entry->response_id]->questions[$entry->question_id]->answer)) {
                         $responses[$entry->response_id]->questions[$entry->question_id]->answer = $entry->free_text;
                     } else {
                         $responses[$entry->response_id]->questions[$entry->question_id]->answer .= '<br/>' . $entry->free_text;
                     }
                 }
             }
         }
     }
     $response_rows = array();
     foreach ($responses as $id => $response) {
         $string = '<table class="table table-striped" width="100%">';
         $string = $string . '<tr><th width="30%"><strong>Response ID:</strong></th><td width="70%">' . $id . '</td></tr>';
         $string = $string . '<tr><th><strong>Response Date:</strong></th><td>' . $response->created . '</td></tr>';
         $string = $string . '<tr><th><strong>User ID:</strong></th><td>' . $response->created_by . '</td></tr>';
         $string = $string . '<tr><th><strong>Username:</strong></th><td>' . $response->username . '</td></tr>';
         $string = $string . '<tr><th><strong>User Display Name:</strong></th><td>' . $response->name . '</td></tr>';
         if ($include_email_in_reports == 1) {
             $string = $string . '<tr><td><strong>Email:</strong></td><td>' . $response->email . '</td></tr>';
         }
         foreach ($pdfData->questions as $question) {
             $string = $string . '<tr><td colspan="2">&nbsp;<hr></td></tr>';
             $string = $string . '<tr><th colspan="2"><h3>' . $question->title . '</h3></th></tr>';
             if (!empty($question->description)) {
                 $string = $string . '<tr><td colspan="2">' . $question->description . '</td></tr>';
             }
             $string = $string . '<tr><td colspan="2">&nbsp;</td></tr>';
             $string = $string . '<tr><td colspan="2">' . $response->questions[$question->id]->answer . '</td></tr>';
         }
         $string = $string . '</table>';
         array_push($response_rows, $string);
     }
     // create new PDF document
     require_once JPATH_COMPONENT_SITE . '/helpers/tcpdf.php';
     $pdf = new MYPDF('P', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
     // set default header data
     $pdf->SetHeaderData('logo.png', PDF_HEADER_LOGO_WIDTH, $pdfData->title, '');
     // set document information
     $pdf->SetCreator(PDF_CREATOR);
     $pdf->SetAuthor('corejoomla.com');
     $pdf->SetTitle('Survey Report');
     $pdf->SetSubject('Survey Responses Report');
     $pdf->SetKeywords('survey, report');
     // set header and footer fonts
     $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
     $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
     // set default monospaced font
     $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
     //set margins
     $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
     $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
     $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
     //set auto page breaks
     $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
     //set image scale factor
     $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
     // ---------------------------------------------------------
     // set font
     $pdf->SetFont('freesans');
     foreach ($response_rows as $i => $response) {
         $pdf->AddPage();
         $pdf->writeHTML($response, true, false, true, false, '');
         $pdf->lastPage();
     }
     $pdf->Output($fileName, $mode);
 }
Ejemplo n.º 30
0
    }
    $classname = 'CommunitySurveysController' . JString::ucfirst($view);
    $controller = new $classname();
    $document = JFactory::getDocument();
    CJFunctions::load_jquery(array('libs' => array('fontawesome')));
    $document->addStyleSheet(CJLIB_URI . '/framework/assets/cj.framework.css');
    $document->addStyleSheet(JURI::base(true) . '/components/' . S_APP_NAME . '/assets/css/cj.surveys.admin.min.css');
    $document->addScript(JURI::base(true) . '/components/' . S_APP_NAME . '/assets/js/cj.surveys.admin.min.js');
    CommunitySurveysHelper::addSubmenu($view);
    $params = JComponentHelper::getParams(S_APP_NAME);
    define('S_DEBUG_ENABLED', $params->get('enable_debugging', 0) == '1');
    /********************************* VERSION CHECK *******************************/
    if (empty($task)) {
        $version = $app->getUserState(S_APP_NAME . '.VERSION');
        if (!$version) {
            $version = CJFunctions::get_component_update_check(S_APP_NAME, S_CURR_VERSION);
            $v = array();
            $v['connect'] = (int) $version['connect'];
            $v['version'] = (string) $version['version'];
            $v['released'] = (string) $version['released'];
            $v['changelog'] = (string) $version['changelog'];
            $v['status'] = (int) $version['status'];
            if ($version['connect'] == 1) {
                $app->setUserState(S_APP_NAME . '.VERSION', $v);
            }
        }
        if (!empty($version['status']) && $version['status'] != 0 && !empty($version['version'])) {
            echo '<div class="alert alert-success">
					<button type="button" class="close" data-dismiss="alert">&times;</button>
					<i class="icon-info-sign"></i> 
					Community Surveys ' . $version['version'] . ' is now available, please <a target="_blank" href="http://www.corejoomla.com/downloads.html">download it here</a>.