Beispiel #1
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);
         }
     }
 }
Beispiel #2
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);
 }
Beispiel #3
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');
     }
 }
Beispiel #4
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);
 }
Beispiel #5
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);
 }
Beispiel #6
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();
 }
Beispiel #7
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);
         }
     }
 }
Beispiel #8
0
 /**
  * Gets the user profile url of one or more user ids. 
  *  - If <code>identifier</code> is numeric, a single profile url is returned, 
  *  - if <code>identifier</code> is an array of integers, respective associative array of user profiles is returned with userid as index of the array elements,
  *  - false otherwise. 
  * @param mixed $identifiers numeric or array of numeric user ids
  * @param string $username if <code>path_only</code> is set as false, this option tells if the link value should be user original name or username.
  * @param boolean $path_only if set to true, uri of the profile is returned, otherwise html link of the user profile is returned.
  * 
  * @return mixed user profile or array of user profiles based on the arguments passed. 
  */
 public static function get_user_profile_url($identifiers, $username = '******', $path_only = false, $attribs = null, $xhtml = true, $ssl = null)
 {
     require_once JPATH_ROOT . DS . 'components' . DS . CJBLOG . DS . 'router.php';
     $params = JComponentHelper::getParams(CJBLOG);
     $profile_itemid = CJFunctions::get_active_menu_id(true, 'index.php?option=' . CJBLOG . '&view=profile');
     $profiles = self::get_user_profile($identifiers);
     $username = $params->get('user_display_name', $username);
     if (CjBlogApi::$_enable_logging) {
         JLog::add('Get Profile Urls - Profiles Loaded: ' . count($profiles), JLog::DEBUG, CJBLOG);
     }
     if (!empty($profiles)) {
         if (is_numeric($identifiers)) {
             if ($path_only) {
                 return JRoute::_('index.php?option=' . CJBLOG . '&view=profile&id=' . $profiles['id'] . ':' . $profiles['username'] . $profile_itemid, $xhtml, $ssl);
             } else {
                 return JHtml::link(JRoute::_('index.php?option=' . CJBLOG . '&view=profile&id=' . $profiles['id'] . ':' . $profiles['username'] . $profile_itemid, $xhtml, $ssl), CJFunctions::escape($profiles[$username]), $attribs);
             }
         } elseif (is_array($identifiers)) {
             if (!empty($profiles)) {
                 $return = array();
                 if (in_array(0, $identifiers)) {
                     if (null == $attribs) {
                         $attribs = array();
                     }
                     $attribs['onclick'] = 'return false';
                     $return[0] = $path_only ? '#' : JText::_('COM_CJBLOG_GUEST');
                 }
                 foreach ($profiles as $profile) {
                     if ($path_only) {
                         $return[$profile['id']] = JRoute::_('index.php?option=' . CJBLOG . '&view=profile&id=' . $profile['id'] . ':' . $profile['username'] . $profile_itemid);
                     } else {
                         $return[$profile['id']] = JHtml::link(JRoute::_('index.php?option=' . CJBLOG . '&view=profile&id=' . $profile['id'] . ':' . $profile['username'] . $profile_itemid), CJFunctions::escape($profile[$username]), $attribs);
                     }
                 }
                 return $return;
             }
         }
     }
     return $path_only ? '#' : JText::_('COM_CJBLOG_GUEST');
 }
Beispiel #9
0
 function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $model = $this->getModel();
     $document = JFactory::getDocument();
     $pathway = $app->getPathway();
     $user = JFactory::getUser();
     $usermodel = $this->getModel('users');
     $active = $app->getMenu()->getActive();
     $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 *****************************/
     $page_heading = JText::_('LBL_INVITE_USERS');
     $pathway->addItem($page_heading);
     $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);
     $unique_urls = $model->get_survey_keys($id);
     $jsgroups = $usermodel->get_jomsocial_user_groups($survey->created_by);
     $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);
     $this->assign('brand', JText::_('LBL_HOME'));
     $this->assign('brand_url', JRoute::_('index.php?option=' . S_APP_NAME . '&view=survey' . $itemid));
     // 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('JPAGETITLE', $title, $page_heading));
     } elseif ($app->getCfg('sitename_pagetitles', 0) == 2) {
         $document->setTitle(JText::sprintf('JPAGETITLE', $page_heading, $title));
     } else {
         $document->setTitle($page_heading);
     }
     // 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'));
     }
     parent::display($tpl);
 }
Beispiel #10
0
 private function send_invitations($sid, &$contacts, $remaining = 0)
 {
     if (!empty($contacts)) {
         $app = JFactory::getApplication();
         $user = JFactory::getUser();
         $model = $this->getModel('survey');
         $params = JComponentHelper::getParams(S_APP_NAME);
         $itemid = CJFunctions::get_active_menu_id(true, 'index.php?option=' . S_APP_NAME . '&view=survey');
         $editor = $user->authorise('core.wysiwyg', S_APP_NAME) ? $params->get('default_editor', 'bbcode') : 'none';
         $subject = $app->input->getString('invitation-subject', JText::_('TXT_INVITE_DEFAULT_SUB'));
         $default_body = $editor == 'wysiwyg' ? str_replace("\n", '<br>', JText::_('TXT_INVITE_DEFAULT_BODY')) : JText::_('TXT_INVITE_DEFAULT_BODY');
         $body = CJFunctions::get_clean_var('invitation-body', true, $default_body);
         $body = CJFunctions::process_html($body, $editor == 'bbcode');
         $messageid = $app->input->getInt('messageid', 0);
         $count = count($contacts);
         $keys = $model->create_survey_keys($sid, $count);
         if (!empty($keys) && count($keys) > 0) {
             $emails = array();
             foreach ($keys as $i => $key) {
                 $link = JRoute::_('index.php?option=' . S_APP_NAME . '&view=survey&task=take_survey&key=' . $key . $itemid, false, -1);
                 $link = '<a href="' . $link . '">' . $link . '</a>';
                 $email = new stdClass();
                 $email->name = $contacts[$i]->name;
                 $email->subid = 0;
                 $email->link = $link;
                 $email->email = $contacts[$i]->email;
                 $emails[] = $email;
                 $contacts[$i]->key = $key;
                 $i++;
             }
             $template = $params->get('mail-tpl-newanswer', 'mail-blue.tpl');
             $sent = $model->add_messages_to_queue($sid, $subject, $body, $emails, $template, $messageid);
             $model->update_key_userids($sid, $contacts);
             if ($sent === false) {
                 echo json_encode(array('error' => JText::_('MSG_ERROR_PROCESSING') . (S_DEBUG_ENABLED ? $model->getError() : '')));
             } else {
                 echo json_encode(array('message' => JText::sprintf('MSG_INVITATIONS_ADDED_TO_QUEUE', $sent), 'remaining' => $remaining));
             }
         } else {
             echo json_encode(array('error' => JText::_('MSG_NO_CREDITS')));
         }
     } else {
         echo json_encode(array('error' => JText::_('MSG_NO_CONTACTS_SELECTED')));
     }
 }
Beispiel #11
0
    public function onContentPrepare($context, &$article, &$params, $page = 0)
    {
        $app = JFactory::getApplication();
        $menu = $app->getMenu();
        if ($menu->getActive() == $menu->getDefault() || $context != 'com_content.article' || $page > 0 || empty($article->id)) {
            return true;
        }
        $db = JFactory::getDbo();
        $document = JFactory::getDocument();
        $user = JFactory::getUser();
        $api = new CjLibApi();
        $article_url = JRoute::_(ContentHelperRoute::getArticleRoute($article->id . ':' . $article->alias, $article->catid . ':' . $article->category_alias));
        /******************************** TRIGGER BADGE RULE ******************************************/
        CjBlogApi::trigger_badge_rule('com_content.num_hits', array('num_hits' => $article->hits, 'ref_id' => $article->id), $article->created_by);
        /******************************* TRIGGER POINTS RULES ******************************************/
        $appparams = JComponentHelper::getParams('com_cjblog');
        if ($appparams->get('enable_points')) {
            CjBlogApi::award_points('com_content.hits', $user->id, 0, $article->id, JHtml::link($article_url, $article->title));
            CjBlogApi::award_points('com_content.popular_articles', $article->created_by, 0, $article->id, JHtml::link($article_url, $article->title), array('hits' => $article->hits));
        }
        // Check if the plugin is disabled for the article category
        $include_categories = $this->params->get('include_categories');
        $exclude_categories = $this->params->get('exclude_categories');
        $about_length = $this->params->get('about_length', 180);
        if (!empty($include_categories)) {
            $include_categories = explode(',', $include_categories);
            if (!in_array($article->catid, $include_categories)) {
                return true;
            }
        } else {
            if (!empty($exclude_categories)) {
                $exclude_categories = explode(',', $exclude_categories);
                if (in_array($article->catid, $exclude_categories)) {
                    return true;
                }
            }
        }
        $print = $app->input->getInt('print', 0);
        if ($print) {
            return true;
        }
        /********************************** CONTENT HEADER *********************************************/
        require_once JPATH_ROOT . '/components/com_cjblog/router.php';
        $CjLib = JPATH_ROOT . '/components/com_cjlib/framework.php';
        CJLib::import('corejoomla.framework.core');
        $custom_tag = false;
        JHtml::_('jquery.framework');
        CJLib::behavior('bscore', array('customtag' => $custom_tag));
        CJFunctions::load_jquery(array('libs' => array('rating', 'social', 'fontawesome'), 'custom_tag' => $custom_tag));
        $document->addScript(JUri::root(true) . '/media/com_cjblog/js/cjblog.min.js');
        $document->addStyleSheet(JUri::root(true) . '/media/com_cjblog/css/cjblog.min.css');
        $articles_itemid = CJFunctions::get_active_menu_id(true, 'index.php?option=com_cjblog&view=articles');
        $profile = CjBlogApi::get_user_profile($article->created_by);
        // 		$params->merge($appparams);
        $meta_header = '';
        $meta_stats = '';
        $meta_rating = '';
        $meta_rating_readonly = '';
        $social_buttons = '';
        $tags_html = '';
        $show_category = $appparams->get('show_category', 1);
        $show_date = $appparams->get('show_create_date', 1);
        $date_format = JText::_($appparams->get('date_format', 'd F Y'));
        $show_hits = $appparams->get('show_hits', 1);
        $show_author = $appparams->get('show_author', 1);
        $show_favoured = $appparams->get('show_favoured', 1);
        $show_rating = $appparams->get('show_rating', 1);
        $user_name = $appparams->get('user_display_name', 'name');
        $hot_hits = $appparams->get('hot_article_num_hits', 250);
        $social_buttons = $appparams->get('display_social_buttons', 1);
        $sharing_buttons_customtag = $appparams->get('sharing_buttons_customtag', '');
        $sharing_buttons_customtext = $appparams->get('sharing_buttons_customtext', '');
        $social_buttons_theme = $appparams->get('social_buttons_theme', 'jssocials-theme-classic.css');
        $sharing_position = $appparams->get('sharing_buttons_position', 'bottom');
        $jssocial_label = $appparams->get('jssocial_button_label', 'true');
        $jssocial_count = $appparams->get('jssocial_button_count', 'true');
        $social_buttons_via = $appparams->get('tweet_button_via', '');
        $social_buttons_hashtag = $appparams->get('tweet_button_hashtag', '');
        $jssocial_email = $appparams->get('jssocial_button_email', '1');
        $jssocial_twitter = $appparams->get('jssocial_button_twitter', '1');
        $jssocial_facebook = $appparams->get('jssocial_button_facebook', '1');
        $jssocial_googleplus = $appparams->get('jssocial_button_googleplus', '1');
        $jssocial_linkedin = $appparams->get('jssocial_button_linkedin', '1');
        $jssocial_pinterest = $appparams->get('jssocial_button_pinterest', '1');
        $profileApp = $appparams->get('profile_component', 'cjblog');
        $avatarApp = $appparams->get('avatar_component', 'cjblog');
        $showProfile = JFactory::getUser($article->created_by)->authorise('core.showprofile', 'com_cjblog');
        $bbcode = $appparams->get('default_editor', 'wysiwygbb') == 'wysiwygbb' ? true : false;
        $about = !empty($profile['about']) ? '<div>' . CJFunctions::preprocessHtml($profile['about'], false, $bbcode) . '</div>' : '';
        if ($about_length > 0) {
            $about = CJFunctions::substrws($about, $about_length);
        }
        if ($show_category && $show_date) {
            $cat_url = JRoute::_('index.php?option=com_cjblog&view=articles&task=latest&id=' . $article->catid . ':' . $article->category_alias . $articles_itemid);
            $cat_link = JHtml::link($cat_url, CJFunctions::escape($article->category_title));
            $formatted_date = CJFunctions::get_localized_date($article->created, $date_format);
            $meta_header = JText::sprintf('TXT_POSTED_IN_CATEGORY_ON', $cat_link, $formatted_date);
        } else {
            if ($show_category) {
                $cat_url = JRoute::_('index.php?option=com_cjblog&view=articles&task=latest&id=' . $article->catid . ':' . $article->category_alias . $articles_itemid);
                $cat_link = JHtml::link($cat_url, CJFunctions::escape($article->category_title));
                $meta_header = JText::sprintf('TXT_POSTED_IN_CATEGORY', $cat_link);
            } else {
                if ($show_date) {
                    $meta_header = JText::sprintf('TXT_POSTED_ON', CJFunctions::get_localized_date($article->created, $date_format));
                }
            }
        }
        if ($article->hits > $hot_hits) {
            $meta_stats = $meta_stats . '<span class="label label-important hot-article">' . JText::_('LBL_HOT') . '</span> ';
        }
        if ($show_hits) {
            $meta_stats = $meta_stats . '<span class="label label-info">' . JText::sprintf('TXT_NUM_HITS', $article->hits) . '</span> ';
        }
        if ($show_favoured) {
            $query = 'select favorites from ' . T_CJBLOG_CONTENT . ' where id = ' . $article->id;
            $db->setQuery($query);
            $favored = (int) $db->loadResult();
            if (!$user->guest) {
                $query = 'select count(*) from ' . T_CJBLOG_FAVORITES . ' where content_id = ' . $article->id . ' and user_id = ' . $user->id;
                $db->setQuery($query);
                $count = $db->loadResult();
                if ($count == 0) {
                    $meta_stats = $meta_stats . '
						<span class="label label-info favorites">' . JText::sprintf('TXT_NUM_FAVOURED', $favored) . '</span>
						<a id="btn-add-to-favorites"
							class="btn btn-mini tooltip-hover"
							href="' . JRoute::_('index.php?option=com_cjblog&view=articles&task=favorite&id=' . $article->id . $articles_itemid) . '"
							onclick="return false;"
							title="' . JText::_('LBL_ADD_TO_FAVORITES') . '">
							<i class="fa fa-star"></i>
						</a>';
                } else {
                    $meta_stats = $meta_stats . '
						<span class="label label-info favorites tooltip-hover" title="' . JText::_('LBL_YOU_ADDED_TO_FAVORITES') . '">
							<i class="fa fa-star"></i> ' . JText::sprintf('TXT_NUM_FAVOURED', $favored) . '
						</span>
						<a id="btn-remove-favorite"
							class="btn btn-mini tooltip-hover"
							href="' . JRoute::_('index.php?option=com_cjblog&view=articles&task=remove_favorite&id=' . $article->id . $articles_itemid) . '"
							onclick="return false;"
							title="' . JText::_('LBL_REMOVE_FAVORITE') . '">
							<i class="icon-remove"></i>
						</a>';
                }
            } else {
                $meta_stats = $meta_stats . '<span class="label label-info favorites">' . JText::sprintf('TXT_NUM_FAVOURED', $favored) . '</span>';
            }
        }
        $asset = 'com_content.article.' . $article->id;
        $redirect_url = base64_encode($article_url);
        if ($user->authorise('core.edit.own', $asset) && $article->created_by == $user->id || $user->authorise('core.manage')) {
            $meta_stats = $meta_stats . '
						<a id="btn-edit-article"
							class="btn btn-mini tooltip-hover"
							href="' . JRoute::_(CjBlogHelperRoute::getFormRoute($article->id) . '&return=' . $redirect_url) . '"
							title="' . JText::_('LBL_EDIT_ARTICLE') . '">
							<i class="fa fa-pencil"></i>
						</a>';
        }
        if ($user->authorise('core.edit.state')) {
            if ($article->state == 1) {
                $meta_stats = $meta_stats . '
						<a id="btn-publish-article"
							class="btn btn-mini tooltip-hover"
							href="' . JRoute::_('index.php?option=com_cjblog&view=articles&task=unpublish&id=' . $article->id . $articles_itemid . '&return=' . $redirect_url) . '"
							title="' . JText::_('LBL_PUBLISHED') . '">
							<i class="fa fa-check"></i>
						</a>';
            } else {
                $meta_stats = $meta_stats . '
						<a id="btn-publish-article"
							class="btn btn-mini tooltip-hover"
							href="' . JRoute::_('index.php?option=com_cjblog&view=articles&task=publish&id=' . $article->id . $articles_itemid . '&return=' . $redirect_url) . '"
							title="' . JText::_('LBL_UNPUBLISHED') . '">
							<i class="fa fa-ban"></i>
						</a>';
            }
        }
        if ($show_rating && $user->authorise('articles.rate', 'com_cjblog')) {
            $rating = CJFunctions::get_rating(CJBLOG_ASSET_ID, $article->id);
            $meta_rating_readonly = '
				<div class="pull-right">
					<span class="article-star-rating-readonly"
						data-rating-score="' . $rating['rating'] . '"
						data-rating-hints="' . JText::_('LBL_RATING_HINTS') . '"
						data-rating-noratemsg="' . JText::_('LBL_RATING_NORATE_HINT') . '"
						data-rating-cancelhint="' . JText::_('LBL_RATING_CANCEL_HINT') . '"></span>
					(' . JText::sprintf('TXT_RATINGS', $rating['total_ratings']) . ')
				</div>';
            $readonly = false;
            $hash = CJFunctions::get_hash('com_content.article.rating.item_' . $article->id);
            $cookie = $app->input->cookie->get($hash, null);
            if ($cookie) {
                $readonly = true;
            } else {
                if (!$user->guest) {
                    $query = 'select count(*) from ' . T_CJ_RATING_DETAILS . ' where item_id = ' . $article->id . ' and asset_id = 1 and created_by = ' . $user->id;
                    $db->setQuery($query);
                    $count = (int) $db->loadResult();
                    if ($count > 0) {
                        $app->input->cookie->set($hash, 1, time() + 60 * 60 * 24 * 365, $article_url);
                        $readonly = true;
                    }
                }
            }
            if (!$readonly) {
                $meta_rating = '
					<div>' . JText::_('LBL_RATE_THIS_ARTICLE') . ':</div>
					<span class="article-star-rating"
						data-rating-score="' . $rating['rating'] . '"
						data-rating-url="' . JRoute::_('index.php?option=com_cjblog&view=articles&task=rate&id=' . $article->id . $articles_itemid) . '"
						data-rating-hints="' . JText::_('LBL_RATING_HINTS') . '"
						data-rating-noratemsg="' . JText::_('LBL_RATING_NORATE_HINT') . '"
						data-rating-cancelhint="' . JText::_('LBL_RATING_CANCEL_HINT') . '"></span>
					(<span id="article-rating-info">' . JText::sprintf('TXT_RATING_INFO', $rating['rating'], $rating['total_ratings']) . '</span>)
					<hr>';
            }
        }
        if ($social_buttons == 1) {
            $params_image = new JRegistry();
            $params_image->loadString($article->images);
            $intro = $params_image->get('image_intro');
            $pinterest_image = false;
            if (!empty($intro)) {
                $pinterest_image = JUri::root() . $intro;
            } else {
                preg_match_all('/<img .*src=["|\']([^"|\']+)/i', $article->introtext . $article->fulltext, $matches);
                foreach ($matches[1] as $key => $file_path) {
                    $pinterest_image = JUri::root() . $file_path;
                    break;
                }
            }
            $document->addScript(JUri::root(true) . '/media/com_cjblog/js/jssocials.min.js');
            $document->addStyleSheet(JUri::root(true) . '/media/com_cjblog/css/jssocials.css');
            $document->addStyleSheet(JUri::root(true) . '/media/com_cjblog/css/' . $social_buttons_theme . '');
        }
        if ($social_buttons == 1 || $social_buttons == 2) {
            if ($sharing_buttons_customtext == '') {
                $sharing_buttons_customtext = JText::_('LBL_SOCIAL_SHARING_DESC');
            }
            $social_buttons_construct = '<div class="social-sharing"><p>' . $sharing_buttons_customtext . '</p></div>';
            if ($social_buttons == 1) {
                $social_buttons_jssocials = '
								showLabel: ' . $jssocial_label . ',
								showCount: ' . $jssocial_count . ',
								shares: [';
                if ($jssocial_twitter == "1") {
                    $social_buttons_jssocials = $social_buttons_jssocials . '
									{ share: "twitter",
										via: "' . $social_buttons_via . '",
										hashtags: "' . $social_buttons_hashtag . '",
										text: "' . $article->title . '"},';
                }
                if ($jssocial_facebook == "1") {
                    $social_buttons_jssocials = $social_buttons_jssocials . '
									{ share: "facebook"},';
                }
                if ($jssocial_googleplus == "1") {
                    $social_buttons_jssocials = $social_buttons_jssocials . '
									{ share: "googleplus"},';
                }
                if ($jssocial_linkedin == "1") {
                    $social_buttons_jssocials = $social_buttons_jssocials . '
									{ share: "linkedin"},';
                }
                if ($jssocial_pinterest == "1" && $pinterest_image) {
                    $social_buttons_jssocials = $social_buttons_jssocials . '
                                                                        { share: "pinterest",
                                                                                media: "' . $pinterest_image . '"},';
                }
                if ($jssocial_email == "1") {
                    $social_buttons_jssocials = $social_buttons_jssocials . '
									{ share: "email",
										text: "' . $article->title . '"},';
                }
                $social_buttons_jssocials = $social_buttons_jssocials . '
								]';
                $social_buttons_top = $social_buttons_construct . '
						<div id="share-top">
							<script type="text/javascript">
								jQuery("#share-top").jsSocials({' . $social_buttons_jssocials . '
								});
							</script>
						</div>';
                $social_buttons_bottom = $social_buttons_construct . '
						<div id="share-bottom">
							<script type="text/javascript">
								jQuery("#share-bottom").jsSocials({' . $social_buttons_jssocials . '
								});
							</script>
						</div>';
            } else {
                $social_buttons_top = $social_buttons_construct . $sharing_buttons_customtag;
                $social_buttons_bottom = $social_buttons_top;
            }
        }
        JLoader::import('joomla.application.component.model');
        JLoader::import('articles', JPATH_ROOT . '/components/com_cjblog/models');
        $model = JModelLegacy::getInstance('articles', 'CjBlogModel');
        $tags = $model->get_tags_by_itemids(array($article->id));
        if (!empty($tags)) {
            $tags_html = '<div class="tags-list margin-top-10">';
            foreach ($tags as $tag) {
                $tags_html .= '
						<a title="' . JText::sprintf('TXT_TAGGED_ARTICLES', CJFunctions::escape($tag->tag_text)) . ' - ' . CJFunctions::escape($tag->description) . '" class="tooltip-hover label tag-item"
							href="' . JRoute::_('index.php?option=com_cjblog&view=articles&task=tag&id=' . $tag->tag_id . ':' . $tag->alias . $articles_itemid) . '">
							<i class="fa fa-tags"></i> ' . CJFunctions::escape($tag->tag_text) . '
						</a>';
            }
            $tags_html .= '</div>';
        }
        $avatar = $api->getUserAvatarImage($avatarApp, $article->created_by, $profile['email'], 48);
        if ($showProfile) {
            $profileUrl = $api->getUserProfileUrl($profileApp, $article->created_by);
        } else {
            $profileUrl = "#";
        }
        $html_top = '
		<div class="well well-small">
			<div class="media clearfix" style="overflow: visible">
				<div class="pull-left"><a href="' . $profileUrl . '" class="thumbnail nomargin-bottom">
					<img class="img-avatar" src="' . $avatar . '" alt="' . CjLibUtils::escape($profile[$user_name]) . '" style="max-width: 48px;"></a>
				</div>
				<div class="media-body">
					<div class="muted">' . ($show_author == 1 ? JText::sprintf('TXT_WRITTEN_BY', JHtml::link($profileUrl, CjLibUtils::escape($profile[$user_name]))) . ' ' : '') . $meta_header . '</div>
					<div style="margin-top: 5px;" class="clearfix">
						<div class="pull-left">' . $meta_stats . '</div>
						' . $meta_rating_readonly . '
					</div>
				</div>
				' . ($sharing_position == 'top' || $sharing_position == 'both' ? '<hr/>' . $social_buttons_top : '') . '
			</div>
		</div>';
        $html_bottom = $tags_html . '
		<div class="panel panel-default">
			<div class="panel-body">
				<div class="media clearfix" style="overflow: visible">
					' . $meta_rating . '
					' . ($sharing_position == 'bottom' || $sharing_position == 'both' ? $social_buttons_bottom . '<hr/>' : '') . '
					<div class="pull-left"><a href="' . $profileUrl . '" class="thumbnail nomargin-bottom"><img class="img-avatar" src="' . $avatar . '" alt="' . $profile[$user_name] . '" style="max-width: 48px;"></a></div>
					<div class="media-body">
						<h4 class="media-heading">' . JText::sprintf('TXT_AUTHOR', CjLibUtils::escape($profile[$user_name])) . '</h4>
						<div style="margin: 5px 0;">' . CjBlogApi::get_user_badges_markup($profile) . '</div>
						' . (!empty($profile[$user_name] && $showProfile) ? $about : '') . '
					</div>
				</div>
				<input id="cjblog_page_id" value="article" type="hidden">
			</div>
		</div>';
        $article->text = '<div id="cj-wrapper">' . $html_top . $article->text . $html_bottom . '</div>';
    }
Beispiel #12
0
 function finalize_survey()
 {
     $user = JFactory::getUser();
     $app = JFactory::getApplication();
     if (!$user->authorise('core.create', S_APP_NAME)) {
         CJFunctions::throw_error(JText::_('MSG_UNAUTHORIZED'), 401);
     } else {
         $model = JModelLegacy::getInstance('survey', 'CommunitySurveysModel');
         $id = JRequest::getInt('id', 0);
         $survey = $model->get_survey_details($id, true);
         $itemid = CJFunctions::get_active_menu_id();
         if ($survey->published == 3) {
             $status = $user->authorise('core.autoapprove', S_APP_NAME) ? 1 : 2;
             if (!$model->finalize_survey($id, $status)) {
                 $error = S_DEBUG_ENABLED ? $model->getError() : '';
                 $this->setRedirect(JRoute::_('index.php?option=' . S_APP_NAME . '&view=surveys&task=list' . $itemid, false), JText::_('MSG_ERROR_PROCESSING') . $error);
             } else {
                 $config = JComponentHelper::getParams(S_APP_NAME);
                 if (!$user->authorise('core.autoapprove', S_APP_NAME)) {
                     if ($config->get('admin_new_survey_notification', 1) == 1) {
                         $from = $app->getCfg('mailfrom');
                         $fromname = $app->getCfg('fromname');
                         $admin_emails = $model->get_admin_emails($params->get('admin_user_groups', 8));
                         if (!empty($admin_emails)) {
                             CJFunctions::send_email($from, $fromname, $admin_emails, JText::_('MSG_MAIL_PENDING_REVIEW_SUBJECT'), JText::_('MSG_MAIL_PENDING_REVIEW_BODY'), 1);
                         }
                     }
                     $this->setRedirect(JRoute::_('index.php?option=' . S_APP_NAME . '&view=surveys&task=list' . $itemid, false), JText::_('MSG_SENT_FOR_REVIEW'));
                 } else {
                     $this->setRedirect(JRoute::_('index.php?option=' . S_APP_NAME . '&view=surveys&task=list' . $itemid, false), JText::_('MSG_SUCCESSFULLY_SAVED'));
                 }
             }
         } else {
             $this->setRedirect(JRoute::_('index.php?option=' . S_APP_NAME . '&view=surveys&task=list' . $itemid, false), JText::_('MSG_SUCCESSFULLY_SAVED'));
         }
     }
 }
Beispiel #13
0
<?php

/**
 * @package     corejoomla.site
 * @subpackage  com_cjblog
 *
 * @copyright   Copyright (C) 2009 - 2015 corejoomla.com. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */
defined('_JEXEC') or die;
$app = JFactory::getApplication();
$api = new CjLibApi();
$itemid = CJFunctions::get_active_menu_id();
$jform_itemid = CJFunctions::get_active_menu_id(true, 'index.php?option=com_content&view=form&layout=edit');
$active_id = $this->active_id;
$child_categories = !empty($this->category) ? $this->category->getChildren() : false;
$page_heading = $this->params->get('page_heading');
$task = $app->input->getCmd('task', '');
$cat_alias = !empty($this->category) ? '&catid=' . $this->category->id : '';
$layout = $this->params->get('layout', 'default');
$return = base64_encode(JRoute::_('index.php'));
$profileApp = $this->params->get('profile_component', 'cjblog');
$avatarApp = $this->params->get('avatar_component', 'cjblog');
$avatarSize = $this->params->get('list_avatar_size', 48);
?>

<div id="cj-wrapper">

	<?php 
include_once JPATH_COMPONENT . '/helpers/header.php';
?>
Beispiel #14
0
 function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $model = $this->getModel();
     $document = JFactory::getDocument();
     $pathway = $app->getPathway();
     $user = JFactory::getUser();
     $active = $app->getMenu()->getActive();
     $page_heading = JText::_('TXT_CREATE_EDIT_SURVEY');
     $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 *****************************/
     $id = $app->input->getInt('id', 0);
     $itemid = CJFunctions::get_active_menu_id();
     switch ($this->action) {
         case 'form':
             $survey = null;
             JFactory::getLanguage()->load('com_communitysurveys', JPATH_ADMINISTRATOR);
             if (!empty($this->survey)) {
                 $survey = $this->survey;
             } elseif ($id) {
                 $survey = $model->get_survey_details($id);
             } else {
                 $survey = new stdClass();
                 $survey->id = $survey->catid = $survey->duration = $survey->max_responses = $survey->display_notice = $survey->anonymous = $survey->enable_save_btn = $survey->skip_intro = $survey->notification = $survey->public_permissions = 0;
                 $survey->show_answers = $survey->display_template = $survey->multiple_responses = $survey->backward_navigation = $survey->private_survey = $survey->display_progress = 1;
                 $survey->title = $survey->introtext = $survey->endtext = $survey->custom_header = $survey->alias = '';
                 $survey->redirect_url = 'http://vcomcc.com/index.php/forum/front-page';
                 $survey->publish_up = $survey->publish_down = '0000-00-00 00:00:00';
                 $survey->created_by = $user->id;
                 $survey->restriction = 'username';
                 $survey->tags = array();
             }
             $this->assignRef('item', $survey);
             $this->assign('brand', JText::_('LBL_HOME'));
             $this->assign('brand_url', JRoute::_('index.php?option=' . S_APP_NAME . '&view=survey' . $itemid));
             break;
         case 'questions':
             $page_id = $app->input->getInt('pid', 0);
             $survey = $model->get_survey_details($id, $page_id, false, true, false);
             if (!$page_id && !empty($survey->pages)) {
                 $page_id = $survey->pages[0];
             }
             $survey->questions = $model->get_questions($id, $page_id, true, true);
             $survey->pages = $model->get_pages_list($id);
             $this->assignRef('item', $survey);
             $this->assignRef('pid', $page_id);
             $this->assign('brand', JText::_('LBL_HOME'));
             $this->assign('brand_url', JRoute::_('index.php?option=' . S_APP_NAME . '&view=survey' . $itemid));
             $tpl = 'questions';
             break;
     }
     $pathway->addItem($page_heading);
     // 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('JPAGETITLE', $title, $page_heading));
     } elseif ($app->getCfg('sitename_pagetitles', 0) == 2) {
         $document->setTitle(JText::sprintf('JPAGETITLE', $page_heading, $title));
     } else {
         $document->setTitle($page_heading);
     }
     // 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'));
     }
     parent::display($tpl);
 }
Beispiel #15
0
 function copy_survey()
 {
     $app = JFactory::getApplication();
     $id = $app->input->getInt('id', 0);
     $model = $this->getModel('survey');
     if (!$id) {
         $this->setRedirect('index.php?option=' . S_APP_NAME . '&view=surveys', JText::_('MSG_ERROR_PROCESSING'));
     }
     if (!JFactory::getUser()->authorise('core.create', S_APP_NAME) || !$model->authorize_survey($id)) {
         return CJFunctions::throw_error(JText::_('JERROR_ALERTNOAUTHOR'), 403);
     } else {
         $user_itemid = CJFunctions::get_active_menu_id(true, 'index.php?option=' . S_APP_NAME . '&view=user');
         if (!$model->copy_survey($id)) {
             $this->setRedirect(JRoute::_('index.php?option=' . S_APP_NAME . '&view=user&task=my_surveys' . $user_itemid), JText::_('MSG_ERROR_PROCESSING'));
         } else {
             $this->setRedirect(JRoute::_('index.php?option=' . S_APP_NAME . '&view=user&task=my_surveys' . $user_itemid), JText::_('MSG_COPY_SUCCESS'));
         }
     }
 }
Beispiel #16
0
<?php

/**
 * @version		$Id: mod_surveyform.php 01 2014-07-08 11:37:09Z maverick $
 * @package		CoreJoomla.Surveys
 * @subpackage	Modules.site
 * @copyright	Copyright (C) 2009 - 2014 corejoomla.com, Inc. All rights reserved.
 * @author		Maverick
 * @link		http://www.corejoomla.com/
 * @license		License GNU General Public License version 2 or later
 */
//don't allow other scripts to grab and execute our file
defined('_JEXEC') or die;
$user = JFactory::getUser();
$itemid = CJFunctions::get_active_menu_id(true, 'index.php?option=com_communitysurveys&view=survey');
$options = JComponentHelper::getParams('com_communitysurveys');
CJFunctions::load_jquery(array('libs' => array('validate')));
$wysiwyg = $user->authorise('core.wysiwyg', 'com_communitysurveys');
$bbcode = $options->get('default_editor', 'bbcode') == 'bbcode' ? true : false;
$content = $options->get('process_content_plugins', 0) == 1;
require_once JPATH_ROOT . '/components/com_communitysurveys/helpers/formfields.php';
$formfields = new SurveyFormFields($wysiwyg, $bbcode, $content);
?>
<style>
<!--
.error {color: red}
-->
</style>
<script type="text/javascript">
<!--
jQuery(document).ready(function($){
Beispiel #17
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');
Beispiel #18
0
 function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $model = $this->getModel();
     $document = JFactory::getDocument();
     $user = JFactory::getUser();
     $pathway = $app->getPathway();
     $active = $app->getMenu()->getActive();
     $itemid = CJFunctions::get_active_menu_id();
     $this->print = $app->input->getBool('print');
     $page_heading = '';
     /********************************** 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 *****************************/
     CJFunctions::load_jquery(array('libs' => array('fontawesome')));
     switch ($this->action) {
         case 'survey_reports':
             $id = $app->input->getInt('id', 0);
             if (!$id) {
                 CJFunctions::throw_error(JText::_('JERROR_ALERTNOAUTHOR'), 401);
             }
             $survey = $model->get_survey_details($id, false, true);
             if (empty($survey)) {
                 CJFunctions::throw_error(JText::_('JERROR_ALERTNOAUTHOR'), 401);
             }
             $survey->stats = $model->get_survey_statistics($survey->id);
             $this->assignRef('item', $survey);
             $page_heading = JText::sprintf('TXT_REPORTS', $this->escape($survey->title));
             break;
         case 'consolidated_report':
             $page_heading = JText::sprintf('TXT_REPORTS', $this->escape($this->item->title));
             break;
         case 'consolidated_pdf_report':
             $page_heading = JText::sprintf('TXT_REPORTS', $this->escape($this->item->title));
             break;
         case 'survey_responses':
             $id = $app->input->getInt('id', 0);
             if (!$id) {
                 CJFunctions::throw_error(JText::_('JERROR_ALERTNOAUTHOR'), 401);
             }
             $survey = $model->get_survey_details($id, false, true);
             if (empty($survey)) {
                 CJFunctions::throw_error(JText::_('JERROR_ALERTNOAUTHOR'), 401);
             }
             $result = $model->get_responses($survey->id);
             $responses = empty($result->rows) ? array() : $result->rows;
             $this->load_users($responses);
             $this->assignRef('item', $survey);
             $this->assignRef('responses', $responses);
             $this->assignRef('pagination', $result->pagination);
             $this->assignRef('lists', $result->lists);
             $page_heading = JText::sprintf('TXT_REPORTS', $this->escape($survey->title));
             break;
         case 'location_report':
             $id = $app->input->getInt('id', 0);
             if (!$id) {
                 CJFunctions::throw_error(JText::_('JERROR_ALERTNOAUTHOR'), 401);
             }
             $survey = $model->get_survey_details($id, false, true);
             if (empty($survey)) {
                 CJFunctions::throw_error(JText::_('JERROR_ALERTNOAUTHOR'), 401);
             }
             $result = $model->get_location_report($survey->id);
             $responses = empty($result->rows) ? array() : $result->rows;
             $this->assignRef('item', $survey);
             $this->assignRef('locations', $responses);
             $this->assignRef('pagination', $result->pagination);
             $this->assignRef('lists', $result->lists);
             $page_heading = JText::sprintf('TXT_REPORTS', $this->escape($survey->title));
             break;
         case 'device_report':
             $id = $app->input->getInt('id', 0);
             if (!$id) {
                 CJFunctions::throw_error(JText::_('JERROR_ALERTNOAUTHOR'), 401);
             }
             $survey = $model->get_survey_details($id, false, true);
             if (empty($survey)) {
                 CJFunctions::throw_error(JText::_('JERROR_ALERTNOAUTHOR'), 401);
             }
             $result = $model->get_device_report($survey->id);
             $responses = empty($result->rows) ? array() : $result->rows;
             $this->assignRef('item', $survey);
             $this->assignRef('devices', $responses);
             $this->assignRef('pagination', $result->pagination);
             $this->assignRef('lists', $result->lists);
             $page_heading = JText::sprintf('TXT_REPORTS', $this->escape($survey->title));
             break;
         case 'os_report':
             $id = $app->input->getInt('id', 0);
             if (!$id) {
                 CJFunctions::throw_error(JText::_('JERROR_ALERTNOAUTHOR'), 401);
             }
             $survey = $model->get_survey_details($id, false, true);
             if (empty($survey)) {
                 CJFunctions::throw_error(JText::_('JERROR_ALERTNOAUTHOR'), 401);
             }
             $result = $model->get_os_report($survey->id);
             $responses = empty($result->rows) ? array() : $result->rows;
             $this->assignRef('item', $survey);
             $this->assignRef('oses', $responses);
             $this->assignRef('pagination', $result->pagination);
             $this->assignRef('lists', $result->lists);
             $page_heading = JText::sprintf('TXT_REPORTS', $this->escape($survey->title));
             break;
         case 'view_response':
             $id = $app->input->getInt('id', 0);
             $rid = $app->input->getInt('rid', 0);
             if (!$id) {
                 CJFunctions::throw_error(JText::_('JERROR_ALERTNOAUTHOR'), 401);
             }
             $survey = $model->get_survey_details($id, false, true);
             if (empty($survey)) {
                 CJFunctions::throw_error(JText::_('JERROR_ALERTNOAUTHOR'), 401);
             }
             $survey->questions = $model->get_questions($survey->id);
             $survey->response = $model->get_response_details($rid, $survey->id, 0, false, false);
             foreach ($survey->questions as &$question) {
                 $question->responses = array();
                 foreach ($survey->response->answers as $answer) {
                     if ($question->id == $answer->question_id) {
                         $question->responses[] = $answer;
                     }
                 }
             }
             $page_heading = JText::sprintf('TXT_RESULTS', $this->escape($survey->title));
             $this->assignRef('item', $survey);
             $this->assign('response_id', $rid);
             break;
     }
     $this->assign('brand', JText::_('LBL_HOME'));
     $this->assign('brand_url', 'index.php?option=' . S_APP_NAME . '&view=survey' . $itemid);
     // set browser title
     $this->params->set('page_heading', $this->params->get('page_heading', $page_heading));
     $pathway->addItem($page_heading);
     $title = $this->params->get('page_title', $app->getCfg('sitename'));
     if ($app->getCfg('sitename_pagetitles', 0) == 1) {
         $document->setTitle(JText::sprintf('JPAGETITLE', $title, $page_heading));
     } elseif ($app->getCfg('sitename_pagetitles', 0) == 2) {
         $document->setTitle(JText::sprintf('JPAGETITLE', $page_heading, $title));
     } else {
         $document->setTitle($page_heading);
     }
     // 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);
 }
Beispiel #19
0
defined('_JEXEC') or die;
$user = JFactory::getUser();
$api = new CjLibApi();
$params = $displayData['params'];
$brand = isset($displayData['brand']) ? $displayData['brand'] : JText::_('COM_CJBLOG_LABEL_HOME');
$profileComponent = $params->get('profile_component', 'cjblog');
$categories_itemid = CJFunctions::get_active_menu_id(true, 'index.php?option=' . CJBLOG . '&view=categories');
$users_itemid = CJFunctions::get_active_menu_id(true, 'index.php?option=' . CJBLOG . '&view=users');
$user_itemid = CJFunctions::get_active_menu_id(true, 'index.php?option=' . CJBLOG . '&view=user');
$blog_itemid = CJFunctions::get_active_menu_id(true, 'index.php?option=' . CJBLOG . '&view=blog');
$profile_itemid = CJFunctions::get_active_menu_id(true, 'index.php?option=' . CJBLOG . '&view=profile');
$articles_itemid = CJFunctions::get_active_menu_id(true, 'index.php?option=' . CJBLOG . '&view=articles');
$search_itemid = CJFunctions::get_active_menu_id(true, 'index.php?option=' . CJBLOG . '&view=search');
$badges_itemid = CJFunctions::get_active_menu_id(true, 'index.php?option=' . CJBLOG . '&view=badges');
$form_itemid = CJFunctions::get_active_menu_id(true, 'index.php?option=' . CJBLOG . '&view=form');
$tags_itemid = CJFunctions::get_active_menu_id(true, 'index.php?option=' . CJBLOG . '&view=tags');
if ($params->get('show_header_bar') == 1) {
    ?>
	<nav class="navbar navbar-default" role="navigation">
		<div class="navbar-inner">
			<div class="navbar-header">
				<button type="button" class="btn btn-navbar navbar-toggle" data-toggle="collapse" data-target="#cjb-navbar-collapse">
	<!-- 				<span class="sr-only">Toggle navigation</span> -->
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
				</button>
				<a class="brand navbar-brand" href="<?php 
    echo JRoute::_('index.php?option=com_cjblog&view=articles&task=latest' . $articles_itemid);
    ?>
">
Beispiel #20
0
 function download_pdf_report()
 {
     $itemid = CJFunctions::get_active_menu_id();
     $user = JFactory::getUser();
     $app = JFactory::getApplication();
     $surveyId = $app->input->getInt('id', 0);
     $params = JComponentHelper::getParams(S_APP_NAME);
     if ($user->guest) {
         $redirect_url = base64_encode(JRoute::_('index.php?option=' . S_APP_NAME . '&view=reports&task=dashboard&id=' . $surveyId . $itemid));
         $this->setRedirect(CJFunctions::get_login_url($redirect_url, $itemid), JText::_('MSG_NOT_LOGGED_IN'));
         return;
     }
     if (!$user->authorise('core.create', S_APP_NAME) && !$user->authorise('core.manage', S_APP_NAME)) {
         $this->setRedirect(JRoute::_('index.php?option=' . S_APP_NAME . '&view=survey' . $itemid), JText::_('MSG_UNAUTHORIZED'));
         return;
     }
     if (!$surveyId) {
         $this->setRedirect(JRoute::_('index.php?option=' . S_APP_NAME . '&view=survey' . $itemid), JText::_('MSG_UNAUTHORIZED'));
         return;
     }
     $cids = $app->input->post->getArray(array('cid' => 'array'));
     JArrayHelper::toInteger($cids['cid']);
     if (empty($cids['cid'])) {
         $this->setRedirect(JRoute::_('index.php?option=' . S_APP_NAME . '&view=reports&task=responses&id=' . $surveyId . $itemid, false), JText::_('MSG_SELECT_ITEMS_TO_CONTINUE'));
         return;
     }
     $model = $this->getModel('survey');
     $pdfData = $model->get_reponse_data_for_csv($surveyId, $cids['cid']);
     if (empty($pdfData)) {
         $this->setRedirect(JRoute::_('index.php?option=' . S_APP_NAME . '&view=reports&task=dashboard&id=' . $surveyId . $itemid), JText::_('MSG_ERROR_PROCESSING') . $model->getError());
         return;
     }
     // All validations done, write data now
     require_once JPATH_COMPONENT_SITE . '/helpers/reports.php';
     $generator = new SurveyReports();
     $fileName = 'survey_' . $surveyId . '_' . date('dmYHis') . '.pdf';
     $generator->generatePdfReport($pdfData, 'D', $params, $fileName);
     jexit();
 }
Beispiel #21
0
 function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $model = $this->getModel();
     $document = JFactory::getDocument();
     $user = JFactory::getUser();
     $page_heading = JText::_('TXT_CREATE_EDIT_SURVEY');
     $this->print = $app->input->getBool('print');
     /********************************** PARAMS *****************************/
     $this->params = JComponentHelper::getParams(S_APP_NAME);
     /********************************** PARAMS *****************************/
     $id = $app->input->getInt('id', 0);
     $itemid = CJFunctions::get_active_menu_id();
     $this->addToolBar();
     switch ($this->action) {
         case 'form':
             $survey = null;
             if (!empty($this->survey)) {
                 $survey = $this->survey;
             } elseif ($id) {
                 $survey = $model->get_survey_details($id);
             } else {
                 $survey = new stdClass();
                 $survey->id = $survey->created_by = $survey->catid = $survey->duration = $survey->skip_intro = $survey->max_responses = $survey->anonymous = $survey->display_notice = $survey->enable_save_btn = $survey->display_progress = $survey->notification = $survey->public_permissions = $survey->published = 0;
                 $survey->show_answers = $survey->display_template = $survey->multiple_responses = $survey->backward_navigation = $survey->private_survey = 1;
                 $survey->title = $survey->introtext = $survey->endtext = $survey->custom_header = $survey->alias = '';
                 $survey->publish_up = $survey->publish_down = '0000-00-00 00:00:00';
                 $survey->redirect_url = 'http://vcomcc.com/index.php/forum/front-page';
                 $survey->created_by = $user->id;
                 $survey->username = $user->username;
                 $survey->restriction = 'username';
                 $survey->username = 2;
                 $survey->tags = array();
             }
             $this->assignRef('item', $survey);
             $this->assign('brand', JText::_('LBL_HOME'));
             $this->assign('brand_url', JRoute::_('index.php?option=' . S_APP_NAME . '&view=survey' . $itemid));
             if (count($user->getAuthorisedCategories(S_APP_NAME, 'core.create')) > 0) {
                 JToolBarHelper::cancel();
                 JToolBarHelper::custom('save', 'save', 'save', 'Save & Next', false, false);
             }
             break;
         case 'questions':
             $page_id = $app->input->getInt('pid', 0);
             $survey = $model->get_survey_details($id, $page_id, false, true, false);
             if (!$page_id && !empty($survey->pages)) {
                 $page_id = $survey->pages[0];
             }
             $survey->questions = $model->get_questions($id, $page_id, true, true);
             $survey->pages = $model->get_pages_list($id);
             $this->assignRef('item', $survey);
             $this->assignRef('pid', $page_id);
             $this->assign('brand', JText::_('LBL_HOME'));
             $this->assign('brand_url', JRoute::_('index.php?option=' . S_APP_NAME . '&view=survey' . $itemid));
             if (count($user->getAuthorisedCategories(S_APP_NAME, 'core.create')) > 0) {
                 JToolBarHelper::custom('finalize', 'save', 'save', 'Save & Close', false, false);
             }
             $tpl = 'questions';
             break;
     }
     $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);
     }
     parent::display($tpl);
 }
Beispiel #22
0
 function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $model = $this->getModel();
     $document = JFactory::getDocument();
     $user = JFactory::getUser();
     $pathway = $app->getPathway();
     $active = $app->getMenu()->getActive();
     $itemid = CJFunctions::get_active_menu_id();
     $this->print = $app->input->getBool('print');
     $page_heading = '';
     /********************************** 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 *****************************/
     switch ($this->action) {
         case 'survey_intro':
             $page_heading = JText::sprintf('TXT_INTRODUCTION', $this->escape($this->item->title));
             break;
         case 'response_form':
             $page_heading = JText::sprintf('TXT_SURVEY_RESPONSE', $this->escape($this->item->title));
             break;
         case 'survey_results':
             $id = $app->input->getInt('id', 0);
             $response_id = $app->input->getInt('rid', 0);
             if (!$id) {
                 CJFunctions::throw_error(JText::_('JERROR_ALERTNOAUTHOR'), 401);
             }
             $survey = $model->get_consolidated_report($id);
             if (empty($survey) || $survey->public_permissions != 1 && $survey->created_by != $user->id && !$user->authorise('core.manage', 'com_communitysurveys')) {
                 CJFunctions::throw_error(JText::_('JERROR_ALERTNOAUTHOR'), 401);
             }
             $response_details = $model->get_response_details($response_id, $id, 0, true, true);
             if (!empty($response_details) && !empty($survey->questions)) {
                 foreach ($response_details as $response_detail) {
                     foreach ($survey->questions as &$question) {
                         if ($question->id == $response_detail->question_id) {
                             $question->response_details[] = $response_detail;
                         }
                     }
                 }
             }
             $page_heading = JText::sprintf('TXT_RESULTS', $this->escape($survey->title));
             $this->assignRef('item', $survey);
             $this->assign('responseId', $response_id);
             break;
         case 'end_message':
             $id = $app->input->getInt('id', 0);
             if (!$id) {
                 CJFunctions::throw_error(JText::_('JERROR_ALERTNOAUTHOR'), 401);
             }
             $survey = $model->get_survey_details($id);
             if (isset($survey->catid) && !$user->authorise('core.respond', S_APP_NAME . '.category.' . $survey->catid)) {
                 CJFunctions::throw_error(JText::_('JERROR_ALERTNOAUTHOR'), 401);
                 return;
             }
             if ($survey->private_survey != '1' && $this->params->get('enable_related_surveys', 1) == 1) {
                 $search_params = array('q' => $survey->title, 'u' => '', 'qt' => 0, 'm' => 0, 'type' => 0, 'all' => 0);
                 $options = array('catid' => 0, 'search_params' => $search_params, 'limit' => 5, 'limitstart' => 0, 'order' => 'a.created', 'order_dir' => 'desc');
                 $return = $model->get_surveys(7, $options, $this->params);
                 $survey->related = $return['surveys'];
             } else {
                 $survey->related = array();
             }
             $page_heading = JText::sprintf('TXT_RESULTS', $this->escape($survey->title));
             $this->assignRef('item', $survey);
             break;
     }
     if ($this->is_hide_template($this->params->get('hide_template', 0), $this->item->display_template)) {
         $app->input->set('tmpl', 'component');
         $app->input->set('format', 'raw');
         CJLib::import('corejoomla.ui.bootstrap', true);
         $this->assign('hide_template', 1);
     } else {
         $this->assign('hide_template', 0);
     }
     $this->assign('brand', JText::_('LBL_HOME'));
     $this->assign('brand_url', 'index.php?option=' . S_APP_NAME . '&view=survey' . $itemid);
     // set browser title
     $this->params->set('page_heading', $this->params->get('page_heading', $page_heading));
     $pathway->addItem($page_heading);
     $title = $this->params->get('page_title', $app->getCfg('sitename'));
     if ($app->getCfg('sitename_pagetitles', 0) == 1) {
         $document->setTitle(JText::sprintf('JPAGETITLE', $title, $page_heading));
     } elseif ($app->getCfg('sitename_pagetitles', 0) == 2) {
         $document->setTitle(JText::sprintf('JPAGETITLE', $page_heading, $title));
     } else {
         $document->setTitle($page_heading);
     }
     // 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);
 }
Beispiel #23
0
 function acymailing_replaceusertags(&$email, &$user, $send = true)
 {
     if (!$send) {
         return;
     }
     $match = '#{surveyurl:(.*)}#Ui';
     $variables = array('body', 'altbody');
     $found = false;
     $results = array();
     foreach ($variables as $var) {
         if (empty($email->{$var})) {
             continue;
         }
         $found = preg_match_all($match, $email->{$var}, $results[$var]) || $found;
         if (empty($results[$var][0])) {
             unset($results[$var]);
         }
     }
     if (!$found) {
         return;
     }
     // CJLib includes
     $cjlib = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_cjlib' . DIRECTORY_SEPARATOR . 'framework.php';
     if (file_exists($cjlib)) {
         require_once $cjlib;
     } else {
         die('CJLib (CoreJoomla API Library) component not found. Please download and install it to continue.');
     }
     CJLib::import('corejoomla.framework.core');
     $htmlreplace = array();
     $textreplace = array();
     $db = JFactory::getDbo();
     $mailerHelper = acymailing_get('helper.mailer');
     foreach ($results as $var => $allresults) {
         foreach ($allresults[0] as $i => $oneTag) {
             if (isset($htmlreplace[$oneTag])) {
                 continue;
             }
             $start = strpos($oneTag, ':') + 1;
             $length = strpos($oneTag, '}') - strpos($oneTag, ':') - 1;
             $sid = intval(substr($oneTag, $start, $length));
             if ($sid > 0) {
                 $keys = array();
                 $key = CJFunctions::generate_random_key();
                 $query = 'insert into #__survey_keys(key_name, survey_id, response_id) values (' . $db->quote($key) . ',' . $sid . ', 0)';
                 $db->setQuery($query);
                 if ($db->query()) {
                     $itemid = CJFunctions::get_active_menu_id();
                     $link = JRoute::_('index.php?option=' . S_APP_NAME . '&view=survey&task=take_survey&key=' . $key . $itemid, false, -1);
                     $link = str_replace('/administrator/', '/', $link);
                     $link = '<a href="' . $link . '">' . $link . '</a>';
                 }
                 $htmlreplace[$oneTag] = $link;
                 $textreplace[$oneTag] = $mailerHelper->textVersion($link);
             }
         }
     }
     $email->body = str_replace(array_keys($htmlreplace), $htmlreplace, $email->body);
     $email->altbody = str_replace(array_keys($textreplace), $textreplace, $email->altbody);
 }
Beispiel #24
0
 function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $model = $this->getModel();
     $document = JFactory::getDocument();
     $user = JFactory::getUser();
     $active = $app->getMenu()->getActive();
     $itemid = CJFunctions::get_active_menu_id();
     $this->print = $app->input->getBool('print');
     $page_heading = '';
     /********************************** PARAMS *****************************/
     $this->params = JComponentHelper::getParams(S_APP_NAME);
     /********************************** PARAMS *****************************/
     CJFunctions::load_jquery(array('libs' => array('fontawesome')));
     $document->addScript(JUri::root(true) . '/media/' . S_APP_NAME . '/js/cj.surveys.min.js');
     $document->addStyleDeclaration('#element-box .m {background-color: #fff;}');
     JToolBarHelper::custom('surveys', 'back', 'back', JText::_('COM_COMMUNITYSURVEYS_SURVEYS'), false, false);
     switch ($this->action) {
         case 'survey_reports':
             $id = $app->input->getInt('id', 0);
             if (!$id) {
                 CJFunctions::throw_error(JText::_('JERROR_ALERTNOAUTHOR'), 401);
             }
             $survey = $model->get_survey_details($id, false, true);
             if (empty($survey)) {
                 CJFunctions::throw_error(JText::_('JERROR_ALERTNOAUTHOR'), 401);
             }
             $survey->stats = $model->get_survey_statistics($survey->id);
             $this->assignRef('item', $survey);
             $page_heading = JText::sprintf('TXT_REPORTS', $this->escape($survey->title));
             break;
         case 'consolidated_report':
             $page_heading = JText::sprintf('TXT_REPORTS', $this->escape($this->item->title));
             JToolBarHelper::custom('reports', 'picture', 'picture', JText::_('COM_COMMUNITYSURVEYS_REPORTS'), false, false);
             break;
         case 'survey_responses':
             $id = $app->input->getInt('id', 0);
             if (!$id) {
                 CJFunctions::throw_error(JText::_('JERROR_ALERTNOAUTHOR'), 401);
             }
             $survey = $model->get_survey_details($id, false, true);
             if (empty($survey)) {
                 CJFunctions::throw_error(JText::_('JERROR_ALERTNOAUTHOR'), 401);
             }
             $result = $model->get_responses($survey->id, 0, 'limitstart');
             $responses = empty($result->rows) ? array() : $result->rows;
             $this->assignRef('item', $survey);
             $this->assignRef('responses', $responses);
             $this->assignRef('pagination', $result->pagination);
             $this->assignRef('lists', $result->lists);
             $page_heading = JText::sprintf('TXT_REPORTS', $this->escape($survey->title));
             JToolBarHelper::custom('reports', 'picture', 'picture', JText::_('COM_COMMUNITYSURVEYS_REPORTS'), false, false);
             JToolBarHelper::custom('csvdownload', 'download', 'download', 'CSV', false, false);
             JToolBarHelper::custom('pdfdownload', 'download', 'download', 'PDF', true, false);
             JToolBarHelper::divider();
             JToolBarHelper::deleteList('', 'remove_responses', 'JTOOLBAR_DELETE');
             break;
         case 'location_report':
             $id = $app->input->getInt('id', 0);
             if (!$id) {
                 CJFunctions::throw_error(JText::_('JERROR_ALERTNOAUTHOR'), 401);
             }
             $survey = $model->get_survey_details($id, false, true);
             if (empty($survey)) {
                 CJFunctions::throw_error(JText::_('JERROR_ALERTNOAUTHOR'), 401);
             }
             $result = $model->get_location_report($survey->id, 'limitstart');
             $responses = empty($result->rows) ? array() : $result->rows;
             $this->assignRef('item', $survey);
             $this->assignRef('locations', $responses);
             $this->assignRef('pagination', $result->pagination);
             $this->assignRef('lists', $result->lists);
             $page_heading = JText::sprintf('TXT_REPORTS', $this->escape($survey->title));
             JToolBarHelper::custom('reports', 'picture', 'picture', JText::_('COM_COMMUNITYSURVEYS_REPORTS'), false, false);
             break;
         case 'device_report':
             $id = $app->input->getInt('id', 0);
             if (!$id) {
                 CJFunctions::throw_error(JText::_('JERROR_ALERTNOAUTHOR'), 401);
             }
             $survey = $model->get_survey_details($id, false, true);
             if (empty($survey)) {
                 CJFunctions::throw_error(JText::_('JERROR_ALERTNOAUTHOR'), 401);
             }
             $result = $model->get_device_report($survey->id, 'limitstart');
             $responses = empty($result->rows) ? array() : $result->rows;
             $this->assignRef('item', $survey);
             $this->assignRef('devices', $responses);
             $this->assignRef('pagination', $result->pagination);
             $this->assignRef('lists', $result->lists);
             $page_heading = JText::sprintf('TXT_REPORTS', $this->escape($survey->title));
             JToolBarHelper::custom('reports', 'picture', 'picture', JText::_('COM_COMMUNITYSURVEYS_REPORTS'), false, false);
             break;
         case 'os_report':
             $id = $app->input->getInt('id', 0);
             if (!$id) {
                 CJFunctions::throw_error(JText::_('JERROR_ALERTNOAUTHOR'), 401);
             }
             $survey = $model->get_survey_details($id, false, true);
             if (empty($survey)) {
                 CJFunctions::throw_error(JText::_('JERROR_ALERTNOAUTHOR'), 401);
             }
             $result = $model->get_os_report($survey->id, 'limitstart');
             $responses = empty($result->rows) ? array() : $result->rows;
             $this->assignRef('item', $survey);
             $this->assignRef('oses', $responses);
             $this->assignRef('pagination', $result->pagination);
             $this->assignRef('lists', $result->lists);
             $page_heading = JText::sprintf('TXT_REPORTS', $this->escape($survey->title));
             JToolBarHelper::custom('reports', 'picture', 'picture', JText::_('COM_COMMUNITYSURVEYS_REPORTS'), false, false);
             break;
         case 'view_response':
             $id = $app->input->getInt('id', 0);
             $rid = $app->input->getInt('rid', 0);
             if (!$id) {
                 CJFunctions::throw_error(JText::_('JERROR_ALERTNOAUTHOR'), 401);
             }
             $survey = $model->get_survey_details($id, false, true);
             if (empty($survey)) {
                 CJFunctions::throw_error(JText::_('JERROR_ALERTNOAUTHOR'), 401);
             }
             $survey->questions = $model->get_questions($survey->id);
             $responses = $model->get_response_details($rid, $survey->id, 0, false);
             foreach ($survey->questions as &$question) {
                 $question->responses = array();
                 foreach ($responses as $response) {
                     if ($question->id == $response->question_id) {
                         $question->responses[] = $response;
                     }
                 }
             }
             $page_heading = JText::sprintf('TXT_RESULTS', $this->escape($survey->title));
             JToolBarHelper::custom('reports', 'picture', 'picture', JText::_('COM_COMMUNITYSURVEYS_REPORTS'), false, false);
             JToolBarHelper::custom('responses', 'picture', 'picture', JText::_('COM_COMMUNITYSURVEYS_RESPONSES'), false, false);
             $this->assignRef('item', $survey);
             $this->assign('response_id', $rid);
             break;
     }
     $this->assign('brand', JText::_('LBL_HOME'));
     $this->assign('brand_url', 'index.php?option=' . S_APP_NAME . '&view=survey' . $itemid);
     // 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('JPAGETITLE', $title, $page_heading));
     } elseif ($app->getCfg('sitename_pagetitles', 0) == 2) {
         $document->setTitle(JText::sprintf('JPAGETITLE', $page_heading, $title));
     } else {
         $document->setTitle($page_heading);
     }
     // 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');
     }
     JToolBarHelper::title(JText::_('COM_COMMUNITYSURVEYS') . ': <small><small>[ ' . JText::_('COM_COMMUNITYSURVEYS_REPORTS') . ' ]</small></small>', 'logo.png');
     parent::display($tpl);
 }
Beispiel #25
0
 private function do_survey_redirect($survey, $silent = false)
 {
     $error_msg = '';
     $redirect = false;
     $itemid = CJFunctions::get_active_menu_id(true, 'index.php?option=' . S_APP_NAME . '&view=survey');
     switch ($survey->error) {
         case 1:
             // no survey found with the sid or surey key
             $error_msg = 'RC 1: ' . JText::_('MSG_SURVEY_NOT_FOUND');
             break;
         case 2:
             // Looks like a deleted survey or some db error occurred
             $error_msg = 'RC 2: ' . JText::_('MSG_ERROR_PROCESSING');
             break;
         case 3:
             // Accessing unpublished survey
             $error_msg = 'RC 3: ' . JText::_('MSG_UNAUTHORIZED');
             break;
         case 4:
             // User is a guest and the user has no permission to respond
             $error_msg = 'RC 4: ' . JText::_('MSG_LOGIN_TO_CONTINUE');
             $login_needed = true;
             break;
         case 5:
             // User is a registered user and has no permission to respond
             $error_msg = 'RC 5: ' . JText::_('MSG_UNAUTHORIZED');
             break;
         case 6:
             // A private survey accessed without a private key/survey key
             $error_msg = 'RC 6: ' . JText::_('MSG_PRIVATE_SURVEY_WITH_NO_KEY');
             break;
         case 7:
             // Survey accessed before it goes live, that is publish up date not yet reached
             $error_msg = 'RC 7: ' . JText::_('COM_COMMUNITYSURVEYS_MSG_SURVEY_NOT_YET_UP');
             break;
         case 8:
             // Survey accessed after it is closed, i.e. publish down date is over
             $error_msg = 'RC 8: ' . JText::_('MSG_SURVEY_CLOSED');
             break;
         case 9:
             // The survey has already taken as found in response data in DB. The survey is accessed through key/unique url
             $error_msg = 'RC 9: ' . JText::_('MSG_SURVEY_ALREADY_TAKEN');
             $redirect = true;
             break;
         case 10:
             // The survey has already taken as found in response data in DB. Survey key found in cookie.
             $error_msg = 'RC 10: ' . JText::_('MSG_SURVEY_ALREADY_TAKEN');
             $redirect = true;
             break;
         case 11:
             // The survey has already taken as found in response data in DB. Response found with this IP.
             $error_msg = 'RC 11: ' . JText::_('MSG_SURVEY_ALREADY_TAKEN');
             $redirect = true;
             break;
         case 12:
             // The survey has already taken as found in response data in DB. Response found with this user id.
             $error_msg = 'RC 12: ' . JText::_('MSG_SURVEY_ALREADY_TAKEN');
             $redirect = true;
             break;
         case 13:
             // New response with unique key from invite page but already a response exist with this key. Not legimate access.
             $error_msg = 'RC 13: ' . JText::_('MSG_ERROR_PROCESSING');
             break;
         case 14:
             // The number of responses recieved to the survey exceeded the allowed responses.
             $error_msg = 'RC 14: ' . JText::_('MSG_EXCEED_RESPONSE_LIMIT');
             break;
         case 15:
             // There are no credits available to the survey owner to offer this response to the user.
             $error_msg = 'RC 15: ' . JText::_('MSG_NO_CREDITS');
             break;
         case 16:
             // An error occurred while updating the newly create survey key for the response. DB Error.
             $error_msg = 'RC 16: ' . JText::_('MSG_ERROR_PROCESSING');
             break;
         case 17:
             // An error occurred while updating/inserting new response. DB Error.
             $error_msg = 'RC 17: ' . JText::_('MSG_ERROR_PROCESSING');
             break;
         case 19:
             // max responses reached for the group the user belongs to
             $error_msg = 'RC 19: The survey already received maximum allowed responses for your user group.';
             break;
         case 18:
             // Something went wrong no survey object created
         // Something went wrong no survey object created
         default:
             $error_msg = 'RC 18: ' . JText::_('MSG_ERROR_PROCESSING');
             break;
     }
     if (S_DEBUG_ENABLED) {
         $model = $this->getModel('survey');
         $error_msg = $error_msg . $model->getError();
     }
     if ($silent) {
         return $error_msg;
     } else {
         if ($login_needed) {
             $activeitemid = CJFunctions::get_active_menu_id();
             $redirect = base64_encode(JURI::getInstance()->toString());
             $this->setRedirect(JRoute::_('index.php?option=com_users&view=login' . $activeitemid . '&return=' . $redirect, false), $error_msg);
         } else {
             if ($redirect) {
                 if (empty($survey->redirect_url)) {
                     if ($survey->public_permissions == '1' && JFactory::getUser()->authorise('core.results', S_APP_NAME)) {
                         $this->setRedirect(JRoute::_('index.php?option=' . S_APP_NAME . '&view=response&task=view_result&id=' . $survey->id . ':' . $survey->alias . '&rid=' . $survey->response_id . $itemid, false), $error_msg);
                     } else {
                         $this->setRedirect(JRoute::_('index.php?option=' . S_APP_NAME . '&view=response&task=end_message&id=' . $survey->id . ':' . $survey->alias . $itemid, false), $error_msg);
                     }
                 } else {
                     $this->setRedirect($survey->redirect_url, $error_msg);
                 }
             } else {
                 $this->setRedirect(JRoute::_('index.php?option=' . S_APP_NAME . '&view=survey' . $itemid, false), $error_msg);
             }
         }
     }
     return;
 }
Beispiel #26
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>
Beispiel #27
0
 function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $document = JFactory::getDocument();
     $user = JFactory::getUser();
     $model = $this->getModel();
     $users_model = $this->getModel('users');
     $categories_model = $this->getModel('categories');
     $pathway = $app->getPathway();
     $active = $app->getMenu()->getActive();
     $itemid = CJFunctions::get_active_menu_id();
     $this->print = $app->input->getBool('print');
     $page_heading = '';
     /********************************** 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;
     $catid = $app->input->getInt('id', 0);
     if (!$catid) {
         $menuid = CJFunctions::get_active_menu_id(false);
         $catid = (int) $app->getMenu()->getParams($menuid)->get('catid', 0);
         $app->input->set('id', $catid);
     }
     $app->input->set('cscatid', $catid);
     //set this only if it is not tags or search
     switch ($this->action) {
         case 'all_surveys':
             $options = array('catid' => $catid, 'limit' => $limit, 'limitstart' => $limitstart);
             $return = $model->get_surveys(3, $options, $this->params);
             $users_model->load_users_from_items($return['surveys'], $this->params->get('user_avatar', 'none'));
             $this->assignRef('items', $return['surveys']);
             $this->assignRef('state', $return['state']);
             $this->assignRef('pagination', $return['pagination']);
             if ($this->params->get('display_cat_list', 1) == 1) {
                 $categories = $categories_model->get_categories($catid);
                 $this->assignRef('categories', $categories);
             }
             $this->assign('task', '');
             $this->assign('page_id', 10);
             $this->assign('brand', JText::_('LBL_HOME'));
             $this->assign('brand_url', 'index.php?option=' . S_APP_NAME . '&view=survey' . $itemid);
             $this->assign('page_url', 'index.php?option=' . S_APP_NAME . '&view=survey&task=all' . $itemid);
             $page_heading = JText::_('LBL_ALL_SURVEYS');
             break;
         case 'latest_surveys':
             $options = array('catid' => $catid, 'limit' => $limit, 'limitstart' => $limitstart);
             $return = $model->get_surveys(1, $options, $this->params);
             $users_model->load_users_from_items($return['surveys'], $this->params->get('user_avatar', 'none'));
             $this->assignRef('items', $return['surveys']);
             $this->assignRef('state', $return['state']);
             $this->assignRef('pagination', $return['pagination']);
             if ($this->params->get('display_cat_list', 1) == 1) {
                 $categories = $categories_model->get_categories($catid);
                 $this->assignRef('categories', $categories);
             }
             $this->assign('task', '');
             $this->assign('brand', JText::_('LBL_HOME'));
             $this->assign('brand_url', 'index.php?option=' . S_APP_NAME . '&view=survey' . $itemid);
             $this->assign('page_url', 'index.php?option=' . S_APP_NAME . '&view=survey' . $itemid);
             $page_heading = JText::_('LBL_LATEST_SURVEYS');
             break;
         case 'popular_surveys':
             $options = array('catid' => $catid, 'limit' => $limit, 'limitstart' => $limitstart);
             $return = $model->get_surveys(2, $options, $this->params);
             $users_model->load_users_from_items($return['surveys'], $this->params->get('user_avatar', 'none'));
             $this->assignRef('items', $return['surveys']);
             $this->assignRef('state', $return['state']);
             $this->assignRef('pagination', $return['pagination']);
             if ($this->params->get('display_cat_list', 1) == 1) {
                 $categories = $categories_model->get_categories($catid);
                 $this->assignRef('categories', $categories);
             }
             $this->assign('task', '');
             $this->assign('brand', JText::_('LBL_HOME'));
             $this->assign('brand_url', 'index.php?option=' . S_APP_NAME . '&view=survey' . $itemid);
             $this->assign('page_url', 'index.php?option=' . S_APP_NAME . '&view=survey&task=popular' . $itemid);
             $page_heading = JText::_('LBL_POPULAR_SURVEYS');
             break;
         case 'search_surveys':
             $search_keywords = $app->input->getString('q', '');
             // search keywords
             $search_username = $app->input->getString('u', '');
             // username
             $search_query_type = $app->input->getInt('qt', 0);
             // query type, search in titles or titles+description
             $search_exact_match = $app->input->getInt('m', 0);
             // exact match of username
             $match_all_words = $app->input->getInt('all', 0);
             // search in all
             $search_type = $app->input->getInt('type', 0);
             // search in all
             $search_order = $app->input->getInt('ord', 0);
             // search order type
             $search_order_dir = $app->input->getInt('dir', 0);
             // direction
             $search_categories = $app->input->getArray(array('cid' => 'array'));
             // category ids
             JArrayHelper::toInteger($search_categories['cid']);
             $search_categories = array_filter($search_categories['cid']);
             $order = $search_order == 1 ? 'a.responses' : 'a.created';
             $order_dir = $search_order_dir == 0 ? 'asc' : 'desc';
             $search_params = array('q' => $search_keywords, 'u' => $search_username, 'qt' => $search_query_type, 'm' => $search_exact_match, 'type' => $search_type, 'all' => $match_all_words);
             $options = array('catid' => $search_categories, 'search_params' => $search_params, 'limit' => $limit, 'limitstart' => $limitstart, 'order' => $order, 'order_dir' => $order_dir);
             $return = $model->get_surveys(7, $options, $this->params);
             $query = '&q=' . $search_keywords . '&u=' . $search_username . '&qt=' . $search_query_type . '&m=' . $search_exact_match . '&type=' . $search_type . '&ord=' . $search_order . '&dir=' . $search_order_dir . (!empty($search_categories) ? '&cid[]=' . implode('&cid[]=', $search_categories) : '');
             $this->assignRef('items', $return['surveys']);
             $this->assignRef('state', $return['state']);
             $this->assignRef('pagination', $return['pagination']);
             if ($this->params->get('display_cat_list', 1) == 1) {
                 $this->assign('categories', array());
             }
             $this->assign('task', null);
             $this->assign('brand', JText::_('LBL_HOME'));
             $this->assign('brand_url', 'index.php?option=' . S_APP_NAME . '&view=survey');
             $this->assign('page_url', 'index.php?option=' . S_APP_NAME . '&view=survey&task=search' . $query . $itemid);
             $page_heading = JText::_('LBL_SEARCH');
             break;
     }
     if ($catid > 0) {
         $category = JCategories::getInstance('Communitysurveys')->get($catid);
         $this->assignRef('category', $category);
         if (!empty($category)) {
             // breadcrumbs
             if (!in_array($this->action, array('search'))) {
                 $temp = $category;
                 while ($temp && $temp->id > 1) {
                     $pathway->addItem($temp->title, JRoute::_($this->page_url . '&id=' . $temp->id . ':' . $temp->alias . $itemid));
                     $temp = $temp->getParent();
                 }
             }
             // add to pathway
             $pathway->addItem($page_heading);
             $page_heading = $page_heading . ' - ' . $category->title;
             // 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('JPAGETITLE', $title, $page_heading));
     } elseif ($app->getCfg('sitename_pagetitles', 0) == 2) {
         $document->setTitle(JText::sprintf('JPAGETITLE', $page_heading, $title));
     } else {
         $document->setTitle($page_heading);
     }
     // 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);
 }