Esempio n. 1
0
 function display()
 {
     $prevpage = null;
     $nextpage = null;
     $page = ModUtil::apiFunc('Content', 'Page', 'getPage', array('id' => $this->pageId));
     $tables = DBUtil::getTables();
     $pageTable = $tables['content_page'];
     $pageColumn = $tables['content_page_column'];
     $options = array('makeTree' => true);
     $options['orderBy'] = 'position';
     $options['orderDir'] = 'desc';
     $options['pageSize'] = 1;
     $options['filter']['superParentId'] = $page['parentPageId'];
     if ($page['position'] > 0) {
         $options['filter']['where'] = "{$pageColumn['level']} = {$page['level']} and {$pageColumn['position']} < {$page['position']}";
         $pages = ModUtil::apiFunc('Content', 'Page', 'getPages', $options);
         if (count($pages) > 0) {
             $prevpage = $pages[0];
         }
     }
     if (isset($page['position']) && $page['position'] >= 0) {
         $options['orderDir'] = 'asc';
         $options['filter']['where'] = "{$pageColumn['level']} = {$page['level']} and {$pageColumn['position']} > {$page['position']}";
         $pages = ModUtil::apiFunc('Content', 'Page', 'getPages', $options);
         if (count($pages) > 0) {
             $nextpage = $pages[0];
         }
     }
     $this->view->assign('loggedin', UserUtil::isLoggedIn());
     $this->view->assign('prevpage', $prevpage);
     $this->view->assign('nextpage', $nextpage);
     return $this->view->fetch($this->getTemplate());
 }
/**
 * User category selector.
 *
 * Available parameters:
 *   - btnText:  If set, the results are assigned to the corresponding variable instead of printed out
 *   - cid:      category ID
 *
 * Example
 * {selector_user_category cid="1" assign="category"}
 *
 * @param array       $params All attributes passed to this function from the template.
 * @param Zikula_View $view   Reference to the Zikula_View object.
 *
 * @return string HTML code of the selector.
 */
function smarty_function_selector_user_category($params, Zikula_View $view)
{
    $field = isset($params['field']) ? $params['field'] : 'id';
    $selectedValue = isset($params['selectedValue']) ? $params['selectedValue'] : 0;
    $defaultValue = isset($params['defaultValue']) ? $params['defaultValue'] : 0;
    $defaultText = isset($params['defaultText']) ? $params['defaultText'] : '';
    $lang = isset($params['lang']) ? $params['lang'] : ZLanguage::getLanguageCode();
    $name = isset($params['name']) ? $params['name'] : 'defautlselectorname';
    $recurse = isset($params['recurse']) ? $params['recurse'] : true;
    $relative = isset($params['relative']) ? $params['relative'] : true;
    $includeRoot = isset($params['includeRoot']) ? $params['includeRoot'] : false;
    $includeLeaf = isset($params['includeLeaf']) ? $params['includeLeaf'] : true;
    $all = isset($params['all']) ? $params['all'] : false;
    $displayPath = isset($params['displayPath']) ? $params['displayPath'] : false;
    $attributes = isset($params['attributes']) ? $params['attributes'] : null;
    $assign = isset($params['assign']) ? $params['assign'] : null;
    $editLink = isset($params['editLink']) ? $params['editLink'] : true;
    $submit = isset($params['submit']) ? $params['submit'] : false;
    $multipleSize = isset($params['multipleSize']) ? $params['multipleSize'] : 1;
    $doReplaceRootCat = false;
    $userCats = ModUtil::apiFunc('ZikulaCategoriesModule', 'user', 'getusercategories', array('returnCategory' => 1, 'relative' => $relative));
    $html = CategoryUtil::getSelector_Categories($userCats, $field, $selectedValue, $name, $defaultValue, $defaultText, $submit, $displayPath, $doReplaceRootCat, $multipleSize);
    if ($editLink && $allowUserEdit && UserUtil::isLoggedIn() && SecurityUtil::checkPermission('ZikulaCategoriesModule::', "{$category['id']}::", ACCESS_EDIT)) {
        $url = ModUtil::url('ZikulaCategoriesModule', 'user', 'edituser');
        $html .= "&nbsp;&nbsp;<a href=\"{$url}\">" . __('Edit sub-categories') . '</a>';
    }
    if ($assign) {
        $view->assign($assign, $html);
    } else {
        return $html;
    }
}
Esempio n. 3
0
 /**
  * Display the block.
  *
  * @param array $blockinfo the blockinfo structure
  *
  * @return string output of the rendered block
  */
 public function display($blockinfo)
 {
     // only show block content if the user has the required permissions
     if (!SecurityUtil::checkPermission('Reviews:ModerationBlock:', "{$blockinfo['title']}::", ACCESS_OVERVIEW)) {
         return false;
     }
     // check if the module is available at all
     if (!ModUtil::available('Reviews')) {
         return false;
     }
     if (!UserUtil::isLoggedIn()) {
         return false;
     }
     ModUtil::initOOModule('Reviews');
     $this->view->setCaching(Zikula_View::CACHE_DISABLED);
     $template = $this->getDisplayTemplate($vars);
     $workflowHelper = new Reviews_Util_Workflow($this->serviceManager);
     $amounts = $workflowHelper->collectAmountOfModerationItems();
     // assign block vars and fetched data
     $this->view->assign('moderationObjects', $amounts);
     // set a block title
     if (empty($blockinfo['title'])) {
         $blockinfo['title'] = $this->__('Moderation');
     }
     $blockinfo['content'] = $this->view->fetch($template);
     // return the block to the theme
     return BlockUtil::themeBlock($blockinfo);
 }
Esempio n. 4
0
 /**
  * Performs the actual search processing.
  */
 public function search($args)
 {
     ModUtil::dbInfoLoad('Search');
     $dbtables = DBUtil::getTables();
     $pageTable = $dbtables['content_page'];
     $pageColumn = $dbtables['content_page_column'];
     $contentTable = $dbtables['content_content'];
     $contentColumn = $dbtables['content_content_column'];
     $contentSearchTable = $dbtables['content_searchable'];
     $contentSearchColumn = $dbtables['content_searchable_column'];
     $translatedPageTable = $dbtables['content_translatedpage'];
     $translatedPageColumn = $dbtables['content_translatedpage_column'];
     $sessionId = session_id();
     // check whether we need to search also in translated content
     $multilingual = System::getVar('multilingual');
     $currentLanguage = ZLanguage::getLanguageCode();
     $searchWhereClauses = array();
     $searchWhereClauses[] = '(' . Search_Api_User::construct_where($args, array($pageColumn['title']), $pageColumn['language']) . ')';
     if ($multilingual) {
         $searchWhereClauses[] = '(' . Search_Api_User::construct_where($args, array($translatedPageColumn['title']), $translatedPageColumn['language']) . ')';
     }
     $searchWhereClauses[] = '(' . Search_Api_User::construct_where($args, array($contentSearchColumn['text']), $contentSearchColumn['language']) . ')';
     // add default filters
     $whereClauses = array();
     $whereClauses[] = '(' . implode(' OR ', $searchWhereClauses) . ')';
     $whereClauses[] = $pageColumn['active'] . ' = 1';
     $whereClauses[] = "({$pageColumn['activeFrom']} IS NULL OR {$pageColumn['activeFrom']} <= NOW())";
     $whereClauses[] = "({$pageColumn['activeTo']} IS NULL OR {$pageColumn['activeTo']} >= NOW())";
     $whereClauses[] = $contentColumn['active'] . ' = 1';
     $whereClauses[] = $contentColumn['visiblefor'] . (UserUtil::isLoggedIn() ? ' <= 1' : ' >= 1');
     $titleFields = $pageColumn['title'];
     $additionalJoins = '';
     if ($multilingual) {
         // if searching in non-default languages, we need the translated title
         $titleFields .= ', ' . $translatedPageColumn['title'] . ' AS translatedTitle';
         // join also the translation table if required
         $additionalJoins = "LEFT OUTER JOIN {$translatedPageTable} ON {$translatedPageColumn['pageId']} = {$pageColumn['id']} AND {$translatedPageColumn['language']} = '{$currentLanguage}'";
         // prevent content snippets in other languages
         $whereClauses[] = $contentSearchColumn['language'] . ' = \'' . $currentLanguage . '\'';
     }
     $where = implode(' AND ', $whereClauses);
     $sql = "\n            SELECT DISTINCT {$titleFields},\n            {$contentSearchColumn['text']} AS description,\n            {$pageColumn['id']} AS pageId,\n            {$pageColumn['cr_date']} AS createdDate\n            FROM {$pageTable}\n            JOIN {$contentTable}\n            ON {$contentColumn['pageId']} = {$pageColumn['id']}\n            JOIN {$contentSearchTable}\n            ON {$contentSearchColumn['contentId']} = {$contentColumn['id']}\n            {$additionalJoins}\n            WHERE {$where}\n        ";
     $result = DBUtil::executeSQL($sql);
     if (!$result) {
         return LogUtil::registerError($this->__('Error! Could not load items.'));
     }
     $objectArray = DBUtil::marshallObjects($result);
     foreach ($objectArray as $object) {
         $pageTitle = $object['page_title'];
         if ($object['translatedTitle'] != '') {
             $pageTitle = $object['translatedTitle'];
         }
         $searchItemData = array('title' => $pageTitle, 'text' => $object['description'], 'extra' => $object['pageId'], 'created' => $object['createdDate'], 'module' => 'Content', 'session' => $sessionId);
         if (!\DBUtil::insertObject($searchItemData, 'search_result')) {
             return \LogUtil::registerError($this->__('Error! Could not save the search results.'));
         }
     }
     return true;
 }
Esempio n. 5
0
    /**
     * Check the user access to a forum
     * @author:	Albert Pérez Monfort (aperezm@xtec.cat)
     * @param:	Identity of the forum
     * @return:	0 - No access
     * 		1 - Read
     * 		2 - Read and Write
     * 		3 - Read, write and topics creation
     * 		4 - Moderate
     */
    public function access($args) {
        $fid = FormUtil::getPassedValue('fid', isset($args['fid']) ? $args['fid'] : null, 'POST');
        $uid = FormUtil::getPassedValue('uid', isset($args['uid']) ? $args['uid'] : UserUtil::getVar('uid'), 'POST');
        $sv = FormUtil::getPassedValue('sv', isset($args['sv']) ? $args['sv'] : null, 'POST');
        $requestByCron = false;
        if (!ModUtil::func('IWmain', 'user', 'checkSecurityValue', array('sv' => $sv))) {
            // security check
            if (!SecurityUtil::checkPermission('IWforums::', '::', ACCESS_READ)) {
                throw new Zikula_Exception_Forbidden();
            }
        } else {
            $requestByCron = true;
        }
        // needed argument
        if (!is_numeric($fid)) {
            return false;
        }
        // get item
        $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
        $item = ModUtil::apiFunc('IWforums', 'user', 'get', array('fid' => $fid,
                    'sv' => $sv));
        if ($item == false) {
            LogUtil::registerError($this->__('The forum upon which the ation had to be carried out hasn\'t been found'));
            return System::redirect(ModUtil::url('IWforums', 'user', 'main'));
        }
        // if forum is not active deny access
        if ($item['actiu'] != 1)
            return 0;

        $uid = (!UserUtil::isLoggedIn() && !$requestByCron) ? '-1' : $uid;
        if ($uid != '-1') {
            if ($uid != UserUtil::getVar('uid') && !$requestByCron)
                return 0;
        }
        // check if the user can access the forum as moderator
        if (strpos($item['mod'], '$' . $uid . '$') !== false)
            return 4;

        // if user is not registered check if can access the forum only in readtable mode
        if ($uid == '-1' && strpos($item['grup'], '$-1|') !== false)
            return 1;
       
        // check if user can access the forum throug the group
        // get user groups
        $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
        $groups = ModUtil::func('IWmain', 'user', 'getAllUserGroups', array('sv' => $sv,
                    'uid' => $uid));
        $accessType = 0;
        foreach ($groups as $group) {
            $pos = strpos($item['grup'], '$' . $group['id'] . '|');
            if ($pos !== false) {
                $access = substr($item['grup'], $pos + 1, strlen($group['id']) + 2);
                $accessArray = explode('|', $access);
                if ($accessType < $accessArray[1])
                    $accessType = $accessArray[1];
            }
        }
        return $accessType;
    }
Esempio n. 6
0
 /**
  * get the User Links for this extension
  *
  * @return array
  */
 private function getUser()
 {
     $links = array();
     if (\UserUtil::isLoggedIn()) {
         $links[] = array('url' => $this->router->generate('kaikmediagallerymodule_user_index'), 'text' => $this->translator->__('Gallery'), 'title' => $this->translator->__('Manage your media'), 'icon' => 'image');
     }
     return $links;
 }
Esempio n. 7
0
    /**
     * Display the output of the login block.
     *
     * @param array $blockInfo A blockinfo structure.
     *
     * @return string The output.
     */
    public function display($blockInfo)
    {
        $renderedOutput = '';

        if (SecurityUtil::checkPermission('Loginblock::', $blockInfo['title'].'::', ACCESS_READ)) {
            if (!UserUtil::isLoggedIn()) {
                if (empty($blockInfo['title'])) {
                    $blockInfo['title'] = DataUtil::formatForDisplay('Login');
                }

                $authenticationMethodList = new Users_Helper_AuthenticationMethodList($this);

                if ($authenticationMethodList->countEnabledForAuthentication() > 1) {
                    $selectedAuthenticationMethod = $this->request->request->get('authentication_method', false);
                } else {
                    // There is only one (or there is none), so auto-select it.
                    $authenticationMethod = $authenticationMethodList->getAuthenticationMethodForDefault();
                    $selectedAuthenticationMethod = array(
                        'modname'   => $authenticationMethod->modname,
                        'method'    => $authenticationMethod->method,
                    );
                }

                // TODO - The order and availability should be set by block configuration
                $authenticationMethodDisplayOrder = array();
                foreach ($authenticationMethodList as $authenticationMethod) {
                    if ($authenticationMethod->isEnabledForAuthentication()) {
                        $authenticationMethodDisplayOrder[] = array(
                            'modname'   => $authenticationMethod->modname,
                            'method'    => $authenticationMethod->method,
                        );
                    }
                }

                $this->view->assign('authentication_method_display_order', $authenticationMethodDisplayOrder)
                           ->assign('selected_authentication_method', $selectedAuthenticationMethod);

                // If the current page was reached via a POST or FILES then we don't want to return here.
                // Only return if the current page was reached via a regular GET
                if ($this->request->isGet()) {
                    $this->view->assign('returnpage', System::getCurrentUri());
                } else {
                    $this->view->assign('returnpage', '');
                }

                $tplName = mb_strtolower("users_block_login_{$blockInfo['position']}.tpl");
                if ($this->view->template_exists($tplName)) {
                    $blockInfo['content'] = $this->view->fetch($tplName);
                } else {
                    $blockInfo['content'] = $this->view->fetch('users_block_login.tpl');
                }

                $renderedOutput = BlockUtil::themeBlock($blockInfo);
            }
        }

        return $renderedOutput;
    }
Esempio n. 8
0
/**
 * Gets qv summary information
 *
 * @author: Sara Arjona Téllez (sarjona@xtec.cat)
 */
function IWqv_qvsummaryblock_display($row) {
    // Security check
    if (!SecurityUtil::checkPermission('IWqv:summaryBlock:', $row['title'] . "::", ACCESS_READ) || !UserUtil::isLoggedIn()) {
        return false;
    }

    $uid = UserUtil::getVar('uid');
    if (!isset($uid))
        $uid = '-1';

    // Get the qvsummary saved in the user vars. It is renovate every 10 minutes
    $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
    $exists = ModUtil::apiFunc('IWmain', 'user', 'userVarExists', array('name' => 'qvsummary',
                'module' => 'IWqv',
                'uid' => $uid,
                'sv' => $sv));
    if ($exists) {
        $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
        $s = ModUtil::func('IWmain', 'user', 'userGetVar', array('uid' => $uid,
                    'name' => 'qvsummary',
                    'module' => 'IWqv',
                    'sv' => $sv,
                    'nult' => true));
    } else {
        $teacherassignments = ModUtil::apiFunc('IWqv', 'user', 'getall', array("teacher" => $uid));
        $studentassignments = ModUtil::apiFunc('IWqv', 'user', 'getall', array("student" => $uid));

        if (empty($teacherassignments) && empty($studentassignments)) {
            
        }

        $view = Zikula_View::getInstance('IWqv', false);
        $view->assign('teacherassignments', $teacherassignments);
        $view->assign('studentassignments', $studentassignments);
        $view->assign('isblock', true);
        $s = $view->fetch('IWqv_block_summary.htm');

        if (empty($teacherassignments) && empty($studentassignments)) {
            $s = '';
        }

        //Copy the block information into user vars
        $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
        ModUtil::func('IWmain', 'user', 'userSetVar', array('uid' => $uid,
            'name' => 'qvsummary',
            'module' => 'IWqv',
            'sv' => $sv,
            'value' => $s,
            'lifetime' => '2000'));
    }

    if ($s == '') {
        return false;
    }

    $row['content'] = $s;
    return BlockUtil::themesideblock($row);
}
Esempio n. 9
0
/**
 * Zikula_View function to display the welcome message
 *
 * Example
 * {userwelcome}
 *
 * @param array       $params All attributes passed to this function from the template.
 * @param Zikula_View $view   Reference to the Zikula_View object.
 *
 * @see    function.userwelcome.php::smarty_function_userwelcome()
 *
 * @return string The welcome message.
 */
function smarty_function_userwelcome($params, Zikula_View $view)
{
    if (UserUtil::isLoggedIn()) {
        $username = UserUtil::getVar('uname');
    } else {
        $username = __('anonymous guest');
    }
    return __f('Welcome, %s!', $username);
}
Esempio n. 10
0
/**
 * Zikula_View function to display the user name
 *
 * Example
 * {user}
 *
 * @param array       $params All attributes passed to this function from the template.
 * @param Zikula_View $view   Reference to the Zikula_View object.
 *
 * @see    function.userwelcome.php::smarty_function_user()
 *
 * @return string The username.
 */
function smarty_function_user($params, Zikula_View $view)
{
    if (UserUtil::isLoggedIn()) {
        $username = UserUtil::getVar('uname');
    } else {
        $username = __('anonymous guest');
    }
    return DataUtil::formatForDisplayHTML($username);
}
Esempio n. 11
0
    public function reloadFlaggedBlock() {
        // Security check
        if (!SecurityUtil::checkPermission('IWmain:flaggedBlock:', "::", ACCESS_READ) || !UserUtil::isLoggedIn()) {
            AjaxUtil::error(DataUtil::formatForDisplayHTML($this->__('Sorry! No authorization to access this module.')));
        }

        //get the headlines saved in the user vars. It is renovate every 10 minutes

        $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
        $exists = ModUtil::apiFunc('IWmain', 'user', 'userVarExists',
                                    array('name' => 'flagged',
                                          'module' => 'IWmain_block_flagged',
                                          'uid' => UserUtil::getVar('uid'),
                                          'sv' => $sv));
        $chars = 15;
        if (!$exists) {
            ModUtil::func('IWmain', 'user', 'flagged',
                           array('where' => '',
                                 'chars' => $chars));
        }
        $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
        $have_flags = ModUtil::func('IWmain', 'user', 'userGetVar',
                                     array('uid' => UserUtil::getVar('uid'),
                                           'name' => 'have_flags',
                                           'module' => 'IWmain_block_flagged',
                                           'sv' => $sv));
        if ($have_flags != '0') {
            ModUtil::func('IWmain', 'user', 'flagged',
                           array('where' => $have_flags,
                                 'chars' => $chars));
            //Posa la variable d'usuari have_news en blanc per no haver-la de tornar a llegir a la propera reiteraci�
            $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
            ModUtil::func('IWmain', 'user', 'userSetVar',
                           array('uid' => UserUtil::getVar('uid'),
                                 'name' => 'have_flags',
                                 'module' => 'IWmain_block_flagged',
                                 'sv' => $sv,
                                 'value' => '0'));
        }

        $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
        $flags = ModUtil::func('IWmain', 'user', 'userGetVar',
                                array('uid' => UserUtil::getVar('uid'),
                                      'name' => 'flagged',
                                      'module' => 'IWmain_block_flagged',
                                      'sv' => $sv,
                                      'nult' => true));

        $view = Zikula_View::getInstance('IWmain', false);

        $view->assign('flags', $flags);
        $content = $view->fetch('IWmain_block_iwflagged.tpl');

        return new Zikula_Response_Ajax(array('content' => $content,
                ));
    }
Esempio n. 12
0
 /**
  * @Route("/info")
  * @Theme("admin")
  * the main administration function
  *
  * @return RedirectResponse
  */
 public function infoAction(Request $request)
 {
     // Permission check
     if (!$this->get('kaikmedia_gallery_module.access_manager')->hasPermission()) {
         throw new AccessDeniedException();
     }
     $request->attributes->set('_legacy', true);
     // forces template to render inside old theme
     return $this->render('KaikmediaGalleryModule:Admin:info.html.twig', ['ZUserLoggedIn' => \UserUtil::isLoggedIn()]);
 }
Esempio n. 13
0
/**
 * Zikula_View function to determine whether the current user is logged in.
 *
 * This function will return true if that is true and false otherwise
 *
 * available parameters:
 *  - assign      if set, the loggedin status will be assigned to this variable
 *
 * @param array       $params All attributes passed to this function from the template.
 * @param Zikula_View $view   Reference to the Zikula_View object.
 *
 * @return   bool   the logged in status
 */
function smarty_function_userloggedin($params, Zikula_View $view)
{
    $assign = isset($params['assign']) ? $params['assign'] : null;
    $return = UserUtil::isLoggedIn();
    if ($assign) {
        $view->assign($assign, $return);
    } else {
        return $return;
    }
}
Esempio n. 14
0
 /**
  * Show the month calendar into a bloc
  *
  * @param array $blockinfo The month and the year to show
  *
  * @return The calendar content
  */
 public function display($blockinfo)
 {
     $mes = FormUtil::getPassedValue('mes', isset($args['mes']) ? $args['mes'] : 0, 'REQUEST');
     $any = FormUtil::getPassedValue('any', isset($args['any']) ? $args['any'] : 0, 'REQUEST');
     // Security check
     if (!SecurityUtil::checkPermission("IWagendas:calendarblock:", $blockinfo['title'] . "::", ACCESS_READ)) return;
     // Check if the module is available
     if (!ModUtil::available('IWagendas')) return;
     $user = (UserUtil::isLoggedIn()) ? UserUtil::getVar('uid') : '-1';
     //get the calendar saved in the user vars.
     $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
     $exists = ModUtil::apiFunc('IWmain', 'user', 'userVarExists',
                                 array('name' => 'Calendar',
                                       'module' => 'IWagendas',
                                       'uid' => $user,
                                       'sv' => $sv));
     /*
     if ($exists) {
         $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
         $s = ModUtil::func('IWmain', 'user', 'userGetVar',
                             array('uid' => $user,
                                   'name' => 'calendar',
                                   'module' => 'IWagendas',
                                   'sv' => $sv,
                                   'nult' => true));
         $blockinfo['content'] = $s;
         return BlockUtil::themesideblock($blockinfo);
     }
      * 
      */
     $s = ModUtil::func('IWagendas', 'user', 'getCalendarContent',
                         array('mes' => $mes,
                               'any' => $any));
     //Copy the block information into user vars
     $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
     ModUtil::func('IWmain', 'user', 'userSetVar',
                    array('uid' => $user,
                          'name' => 'calendar',
                          'module' => 'IWagendas',
                          'sv' => $sv,
                          'value' => $s,
                          'lifetime' => '700'));
     //Copy the block information into user vars
     $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
     ModUtil::func('IWmain', 'user', 'userSetVar',
                    array('uid' => $user,
                          'name' => 'month',
                          'module' => 'IWagendas',
                          'sv' => $sv,
                          'value' => $mes));
     // Populate block info and pass to theme
     $blockinfo['content'] = $s;
     return BlockUtil::themesideblock($blockinfo);
 }
Esempio n. 15
0
 /**
  * If enabled and logged in, save login name of user in Apache session variable for Apache logs.
  *
  * Implements 'core.init' event when Zikula_Core::STAGE_SESSIONS.
  *
  * @param Zikula_Event $event The event handler.
  *
  * @return void
  */
 public function sessionLogging(Zikula_Event $event)
 {
     if ($event['stage'] & Zikula_Core::STAGE_SESSIONS) {
         // If enabled and logged in, save login name of user in Apache session variable for Apache logs
         if (isset($GLOBALS['ZConfig']['Log']['log.apache_uname']) && $GLOBALS['ZConfig']['Log']['log.apache_uname'] && UserUtil::isLoggedIn()) {
             if (function_exists('apache_setenv')) {
                 apache_setenv('Zikula-Username', UserUtil::getVar('uname'));
             }
         }
     }
 }
Esempio n. 16
0
    /**
     * Search plugin main function
     **/
    public function search($args)
    {
        ModUtil::dbInfoLoad('Search');
        $dbtables = DBUtil::getTables();

        $searchTable = $dbtables['search_result'];
        $searchColumn = $dbtables['search_result_column'];
        $pageTable = $dbtables['content_page'];
        $pageColumn = $dbtables['content_page_column'];
        $contentTable = $dbtables['content_content'];
        $contentColumn = $dbtables['content_content_column'];
        $contentSearchTable = $dbtables['content_searchable'];
        $contentSearchColumn = $dbtables['content_searchable_column'];

        $sessionId = session_id();

        $where = Search_Api_User::construct_where($args, 
				array($contentSearchColumn['text']), null);
        $wheretitle = Search_Api_User::construct_where($args, 
				array($pageColumn['title']), $pageColumn['language']);

		// Direct SQL way of searching in titles and searchable content items 
		// for Pages and Content items that are visible/active
		// Optimization and conversion into DBUtil calls should be done
        $sql = "INSERT INTO $searchTable
            ($searchColumn[title],
            $searchColumn[text],
            $searchColumn[module],
            $searchColumn[extra],
            $searchColumn[created],
            $searchColumn[session])
            SELECT DISTINCT $pageColumn[title],
            $contentSearchColumn[text],
            'Content',
            $pageColumn[id],
            $pageColumn[cr_date] AS createdDate,
            '" . DataUtil::formatForStore($sessionId) . "'
            FROM $pageTable
            JOIN $contentTable
            ON $contentColumn[pageId] = $pageColumn[id]
            JOIN $contentSearchTable
            ON $contentSearchColumn[contentId] = $contentColumn[id]
            WHERE ($where or $wheretitle) AND $pageColumn[active] = 1 AND ($pageColumn[activeFrom] IS NULL OR $pageColumn[activeFrom] <= NOW()) AND ($pageColumn[activeTo] IS NULL OR $pageColumn[activeTo] >= NOW()) AND $contentColumn[active] = 1 AND $contentColumn[visiblefor] " . (UserUtil::isLoggedIn() ? '<=1' : '>=1');

        $dbresult = DBUtil::executeSQL($sql);
        if (!$dbresult) {
            return LogUtil::registerError($this->__('Error! Could not load any Content pages or items.'));
        }
        return true;
    }
Esempio n. 17
0
    /**
     * Display block.
     *
     * @param array $blockInfo A blockinfo structure.
     *
     * @return string|void The rendered block.
     */
    public function display($blockInfo)
    {
        if (!SecurityUtil::checkPermission('Userblock::', $blockInfo['title']."::", ACCESS_READ)) {
            return;
        }

        if (UserUtil::isLoggedIn() && UserUtil::getVar('ublockon') == 1) {
            if (!isset($blockInfo['title']) || empty($blockInfo['title'])) {
                $blockInfo['title'] = $this->__f('Custom block content for %s', UserUtil::getVar('name'));
            }
            $blockInfo['content'] = nl2br(UserUtil::getVar('ublock'));

            return BlockUtil::themeBlock($blockInfo);
        }

        return;
    }
Esempio n. 18
0
/**
 * Zikula_View function to display some user links
 *
 * Example
 * {userlinks start="[" end="]" seperator="|"}
 *
 * Parameters:
 *  start     Start delimiter
 *  end       End delimiter
 *  seperator Seperator
 *
 * @param array       $params All attributes passed to this function from the template.
 * @param Zikula_View $view   Reference to the Zikula_View object.
 *
 * @see    function.userlinks.php::smarty_function_userlinks()
 *
 * @return string User links.
 */
function smarty_function_userlinks($params, Zikula_View $view)
{
    $start = isset($params['start']) ? $params['start'] : '[';
    $end = isset($params['end']) ? $params['end'] : ']';
    $seperator = isset($params['seperator']) ? $params['seperator'] : '|';
    if (UserUtil::isLoggedIn()) {
        $links = "{$start} ";
        $profileModule = System::getVar('profilemodule', '');
        if (!empty($profileModule) && ModUtil::available($profileModule)) {
            $links .= "<a href=\"" . DataUtil::formatForDisplay(ModUtil::url($profileModule, 'user', 'view')) . '">' . __('Your Account') . "</a> {$seperator} ";
        } else {
            $links .= "<a href=\"" . DataUtil::formatForDisplay(ModUtil::url('ZikulaUsersModule', 'user', 'index')) . '">' . __('Your Account') . "</a> {$seperator} ";
        }
        $links .= "<a href=\"" . DataUtil::formatForDisplay(ModUtil::url('ZikulaUsersModule', 'user', 'logout')) . '">' . __('Log out') . "</a> {$end}";
    } else {
        $links = "{$start} <a href=\"" . DataUtil::formatForDisplay(ModUtil::url('ZikulaUsersModule', 'user', 'register')) . '">' . __('Register new account') . "</a> {$seperator} " . "<a href=\"" . DataUtil::formatForDisplay(ModUtil::url('ZikulaUsersModule', 'user', 'login')) . '">' . __('Login') . "</a> {$end}";
    }
    return DataUtil::formatForDisplayHTML($links);
}
Esempio n. 19
0
    /**
     * Hide a note of a user
     * @author:     Albert Pérez Monfort (aperezm@xtec.cat)
     * @param:	args   Array with the id of the note
     * @return:	Redirect to the user main page
     */
    public function hide($args) {

        if (!SecurityUtil::checkPermission('IWnoteboard::', '::', ACCESS_READ)) {
            AjaxUtil::error(DataUtil::formatForDisplayHTML($this->__('Sorry! No authorization to access this module.')));
        }
        if (!UserUtil::isLoggedIn()) {
            AjaxUtil::error(DataUtil::formatForDisplayHTML($this->__('You are not allowed to do this action')));
        }
        $nid = FormUtil::getPassedValue('nid', -1, 'GET');
        if ($nid == -1) {
            LogUtil::registerError('no block id');
            AjaxUtil::output();
        }
        // get a note information
        $note = ModUtil::apiFunc('IWnoteboard', 'user', 'get',
                        array('nid' => $nid));
        if ($note == false) {
            LogUtil::registerError('unable to get note info for nid=' . DataUtil::formatForDisplay($nid));
            AjaxUtil::output();
        }
        // add the user as the hide note list
        $no_mostrar = $note['no_mostrar'] . '$' . UserUtil::getVar('uid') . '$';
        // delete the user as a signed note
        $marca = str_replace('$' . UserUtil::getVar('uid') . '$', '', $note['marca']);
        // hide a note for a user
        $lid = ModUtil::apiFunc('IWnoteboard', 'user', 'no_mostrar',
                        array('nid' => $nid,
                            'no_mostrar' => $no_mostrar,
                            'marca' => $marca));
        if (!$lid) {
            AjaxUtil::error(DataUtil::formatForDisplayHTML($this->__('The action has failed')));
        }
        //Delete users headlines var. This renoval the block information
        if ($note['titular'] != '') {
            $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
            ModUtil::apiFunc('IWmain', 'user', 'userDelVar', array('name' => 'nbheadlines',
                        'module' => 'IWnoteboard',
                        'uid' => UserUtil::getVar('uid'),
                        'sv' => $sv));
        }
        AjaxUtil::output(array('nid' => $nid));
    }
Esempio n. 20
0
 public function onKernelRequestSiteOff(GetResponseEvent $event)
 {
     if (!$event->isMasterRequest()) {
         return;
     }
     $response = $event->getResponse();
     $request = $event->getRequest();
     if ($response instanceof PlainResponse || $response instanceof JsonResponse || $request->isXmlHttpRequest()) {
         return;
     }
     if (\System::isInstalling()) {
         return;
     }
     // Get variables
     $module = strtolower($request->query->get('module'));
     $type = strtolower($request->query->get('type'));
     $func = strtolower($request->query->get('func'));
     $siteOff = (bool) \System::getVar('siteoff');
     $hasAdminPerms = \SecurityUtil::checkPermission('ZikulaSettingsModule::', 'SiteOff::', ACCESS_ADMIN);
     $urlParams = $module == 'users' && $type == 'user' && $func == 'siteofflogin';
     // params are lowercase
     $versionCheck = \Zikula_Core::VERSION_NUM != \System::getVar('Version_Num');
     // Check for site closed
     if ($siteOff && !$hasAdminPerms && !$urlParams || $versionCheck) {
         $hasOnlyOverviewAccess = \SecurityUtil::checkPermission('ZikulaUsersModule::', '::', ACCESS_OVERVIEW);
         if ($hasOnlyOverviewAccess && \UserUtil::isLoggedIn()) {
             \UserUtil::logout();
         }
         // initialise the language system to enable translations (#1764)
         $lang = \ZLanguage::getInstance();
         $lang->setup($request);
         $response = new Response();
         $response->headers->add(array('HTTP/1.1 503 Service Unavailable'));
         $response->setStatusCode(503);
         $content = (require_once \System::getSystemErrorTemplate('siteoff.tpl'));
         // move to CoreBundle and use Twig
         $response->setContent($content);
         $event->setResponse($response);
         $event->stopPropagation();
     }
 }
Esempio n. 21
0
/**
 * Zikula_View function to display the login box
 *
 * Example
 * {userlogin size=14 maxlength=25 maxlengthpass=20}
 *
 * Parameters:
 *  size           Size of text boxes (default=14)
 *  maxlength      Maximum length of text box for unamees (default=25)
 *  maxlengthpass  Maximum length of text box for password (default=20)
 *  class          Name of class  assigned to the login form
 *  value          The default value of the username input box
 *  js             Use javascript to automatically clear the default value (defaults to true)
 *
 * @param array       $params All attributes passed to this function from the template.
 * @param Zikula_View $view   Reference to the Zikula_View object.
 *
 * @see    function.userlogin.php::smarty_function_userlogin()
 *
 * @return string The welcome message.
 */
function smarty_function_userlogin($params, Zikula_View $view)
{
    $assign = isset($params['assign']) ? $params['assign'] : false;
    if (!UserUtil::isLoggedIn()) {
        // set some defaults
        $size = isset($params['size']) ? $params['size'] : 14;
        $maxlength = isset($params['maxlength']) ? $params['maxlength'] : 25;
        $maxlengthpass = isset($params['maxlenthpass']) ? $params['maxlenthpass'] : 20;
        $class = isset($params['class']) ? ' class="' . $params['class'] . '"' : '';
        if (ModUtil::getVar(Users_Constant::MODNAME, Users_Constant::MODVAR_LOGIN_METHOD, Users_Constant::LOGIN_METHOD_UNAME) == Users_Constant::LOGIN_METHOD_EMAIL) {
            $value = isset($params['value']) ? DataUtil::formatForDisplay($params['value']) : __('E-mail address');
            $userNameLabel = __('E-mail address');
            $methodName = 'email';
        } else {
            $value = isset($params['value']) ? DataUtil::formatForDisplay($params['value']) : __('User name');
            $userNameLabel = __('User name');
            $methodName = 'uname';
        }
        if (!isset($params['js']) || $params['js']) {
            $js = ' onblur="if (this.value==\'\')this.value=\'' . $value . '\';" onfocus="if (this.value==\'' . $value . '\')this.value=\'\';"';
        } else {
            $js = '';
        }
        // determine the current url so we can return the user to the correct place after login
        $returnurl = System::getCurrentUri();
        $csrftoken = SecurityUtil::generateCsrfToken();
        $loginbox = '<form' . $class . ' style="display:inline" action="' . DataUtil::formatForDisplay(ModUtil::url('Users', 'user', 'login')) . '" method="post"><div>' . "\n" . '<input type="hidden" name="csrftoken" value="' . $csrftoken . '" />' . "\n" . '<input type="hidden" name="authentication_method[modname]" value="Users" />' . "\n" . '<input type="hidden" name="authentication_method[method]" value="' . $methodName . '" />' . "\n" . '<label for="userlogin_plugin_uname">' . $userNameLabel . '</label>&nbsp;' . "\n" . '<input type="text" name="authentication_info[login_id]" id="userlogin_plugin_uname" size="' . $size . '" maxlength="' . $maxlength . '" value="' . $value . '"' . $js . ' />' . "\n" . '<label for="userlogin_plugin_pass">' . __('Password') . '</label>&nbsp;' . "\n" . '<input type="password" name="authentication_info[pass]" id="userlogin_plugin_pass" size="' . $size . '" maxlength="' . $maxlengthpass . '" />' . "\n";
        if (System::getVar('seclevel') != 'high') {
            $loginbox .= '<input type="checkbox" value="1" name="rememberme" id="userlogin_plugin_rememberme" />' . "\n" . '<label for="userlogin_plugin_rememberme">' . __('Remember me') . '</label>&nbsp;' . "\n";
        }
        $loginbox .= '<input type="hidden" name="returnurl" value="' . DataUtil::formatForDisplay($returnurl) . '" />' . "\n" . '<input type="submit" value="' . __('Log in') . '" />' . "\n" . '</div></form>' . "\n";
    } else {
        $loginbox = '';
    }
    if ($assign) {
        $view->assign($assign, $loginbox);
    } else {
        return $loginbox;
    }
}
Esempio n. 22
0
    /**
     * Show the month calendar into a bloc
     * @autor:	Albert Pérez Monfort
     * @autor:	Toni Ginard Lladó
     * param:	The month and the year to show
     * return:	The calendar content
     */
    public function display($blockinfo) {

        // Security check
        if (!SecurityUtil::checkPermission("IWusers:welcomeblock:", $blockinfo['title'] . "::", ACCESS_READ)) {
            return;
        }
        $baseURL = System::getBaseUrl();
        $baseURL .= 'index.php';
        if ('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] != $baseURL) {
            return;
        }
        // Check if the module is available
        if (!ModUtil::available('IWusers')) {
            return;
        }
        $user = (UserUtil::isLoggedIn()) ? UserUtil::getVar('uid') : '-1';
        // Only for loggedin users
        if ($user == '-1') {
            return;
        }
        $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
        $userName = ModUtil::func('IWmain', 'user', 'getUserInfo', array('sv' => $sv,
                    'uid' => $user,
                    'info' => 'n'));
        $values = explode('---', $blockinfo['url']);
        $hello = (!empty($values[0])) ? $values[0] : $this->__('Hi');
        $welcome = (!empty($values[0])) ? $values[1] : $this->__('welcome to the intranet');
        $date = (isset($values[2])) ? $values[2] : '';

        $s = $this->view->assign('userName', $userName)
                        ->assign('hello', $hello)
                        ->assign('welcome', $welcome)
                        ->assign('date', $date)
                        ->assign('dateText', date('d/m/Y', time()))
                        ->assign('timeText', date('H.i', time()))
                        ->fetch('IWusers_block_welcome.htm');
        // Populate block info and pass to theme
        $blockinfo['content'] = $s;
        return BlockUtil::themesideblock($blockinfo);
    }
Esempio n. 23
0
 /**
  * @Route(
  *     "/load/{_format}",
  *     defaults={"_format": "html"},
  *     requirements={
  *         "_format": "html|json"
  *     },
  *      options={"expose"=true}
  * )
  * @Method("GET")
  * Get media information.
  *
  * @param string $urltitle
  *
  * Parameters passed via GET:
  * --------------------------------------------------
  * string  urltitle mediaurl title.
  * string _format response format.
  *
  * @return RedirectResponse|string The rendered template output.
  *
  * @throws AccessDeniedException on failed permission check
  */
 public function loadAction(Request $request, $_format)
 {
     // Permission check
     if (!$this->get('kaikmedia_gallery_module.access_manager')->hasPermission()) {
         throw new AccessDeniedException();
     }
     $media = $this->get('doctrine.entitymanager')->getRepository('Kaikmedia\\GalleryModule\\Entity\\Media\\AbstractMediaEntity')->getAll(array('publicdomain' => 'include', 'author' => \UserUtil::getVar('uid')));
     $mediaArr = [];
     foreach ($media as $mediaItem) {
         $mediaArr[] = $mediaItem->toArray();
     }
     //json
     if ($_format == 'json') {
         $data = array('media' => $mediaArr, '_format' => $_format);
         $response = new JsonResponse($data);
         return $response;
     }
     //html
     $request->attributes->set('_legacy', true);
     // forces template to render inside old theme
     return $this->render('KaikmediaGalleryModule:Media:get.html.twig', ['ZUserLoggedIn' => \UserUtil::isLoggedIn()]);
 }
Esempio n. 24
0
    /**
     * Return an array of items to show in the "user account page".
     * 
     * Parameters passed in the $args array:
     * -------------------------------------
     * string uname The user name of the user for whom links should be returned; optional, defaults to the current user.
     * 
     * @param array $args All parameters passed to this function.
     *
     * @return   array   array of items, or false on failure
     */
    public function getall($args)
    {

        $items = array();

        // do not show the account links if Profile is not the Profile manager
        $profilemodule = System::getVar('profilemodule', '');
        if ($profilemodule != 'Profile') {
            return $items;
        }

        $uname = isset($args['uname']) ? $args['uname'] : null;
        if (!$uname && UserUtil::isLoggedIn()) {
            $uname = UserUtil::getVar('uname');
        }

        // Create an array of links to return
        if (!empty($uname)) {
            $uid = UserUtil::getIdFromName($uname);
            $items['0'] = array('url'     => ModUtil::url('Profile', 'user', 'view', array('uid' => $uid)),
                    'module'  => 'Profile',
                    //! account panel link
                    'title'   => $this->__('Personal info'),
                    'icon'    => 'admin.png');

            if (SecurityUtil::checkPermission('Profile:Members:', '::', ACCESS_READ)) {
                $items['1'] = array('url'     => ModUtil::url('Profile', 'user', 'viewmembers'),
                        'module'  => 'Profile',
                        'title'   => $this->__('Registered users list'),
                        'icon'    => 'members.png');
            }
        }

        // Return the items
        return $items;
    }
Esempio n. 25
0
    /**
     * Gets user news
     *
     * @author	Albert Pérez Monfort (aperezm@xtec.cat)
     * @return	The user news block
     */
    public function display($row) {
        // Security check
        if (!SecurityUtil::checkPermission('IWmain:newsBlock:', $row['title'] . "::", ACCESS_READ) || !UserUtil::isLoggedIn()) {
            return false;
        }

        if (ModUtil::getVar('IWmain', 'URLBase') != System::getBaseUrl()) {
            ModUtil::setVar('IWmain', 'URLBase', System::getBaseUrl());
        }

        $uid = UserUtil::getVar('uid');

        //get the headlines saved in the user vars. It is renovate every 10 minutes
        $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
        $exists = ModUtil::apiFunc('IWmain', 'user', 'userVarExists', array('name' => 'news',
                    'module' => 'IWmain_block_news',
                    'uid' => $uid,
                    'sv' => $sv));

        if ($exists) {
            $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
            $have_news = ModUtil::func('IWmain', 'user', 'userGetVar', array('uid' => $uid,
                        'name' => 'have_news',
                        'module' => 'IWmain_block_news',
                        'sv' => $sv));
            if ($have_news != '0') {
                ModUtil::func('IWmain', 'user', 'news', array('where' => $have_news));
                $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
                ModUtil::func('IWmain', 'user', 'userSetVar', array('uid' => $uid,
                    'name' => 'have_news',
                    'module' => 'IWmain_block_news',
                    'sv' => $sv,
                    'value' => '0'));
            }

            $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
            $have_flags = ModUtil::func('IWmain', 'user', 'userGetVar', array('uid' => UserUtil::getVar('uid'),
                        'name' => 'have_flags',
                        'module' => 'IWmain_block_flagged',
                        'sv' => $sv));

            if ($have_flags != '0') {
                ModUtil::func('IWmain', 'user', 'flagged', array('where' => $have_flags,
                    'chars' => 15));


                $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
                ModUtil::func('IWmain', 'user', 'userSetVar', array('uid' => UserUtil::getVar('uid'),
                    'name' => 'have_flags',
                    'module' => 'IWmain_block_flagged',
                    'sv' => $sv,
                    'value' => '0'));
            }
        } else {
            ModUtil::func('IWmain', 'user', 'news');
        }

        //get the flagged items
        $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
        if (!$exists = ModUtil::apiFunc('IWmain', 'user', 'userVarExists', array('name' => 'flagged',
                    'module' => 'IWmain_block_flagged',
                    'uid' => $uid,
                    'sv' => $sv))) {
            ModUtil::func('IWmain', 'user', 'flagged', array('where' => '',
                'chars' => 15));
        }

        $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
        $news = ModUtil::func('IWmain', 'user', 'userGetVar', array('uid' => $uid,
                    'name' => 'news',
                    'module' => 'IWmain_block_news',
                    'sv' => $sv,
                    'nult' => true));

        $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
        $flags = ModUtil::func('IWmain', 'user', 'userGetVar', array('uid' => UserUtil::getVar('uid'),
                    'name' => 'flagged',
                    'module' => 'IWmain_block_flagged',
                    'sv' => $sv,
                    'nult' => true));

        $this->view->assign('news', $news)
                ->assign('flags', $flags);

        $s = $this->view->fetch('IWmain_block_IWnews.tpl');

        $row['content'] = $s;
        return BlockUtil::themesideblock($row);
    }
Esempio n. 26
0
    public function pager($args) {
        $rpp = FormUtil::getPassedValue('rpp', isset($args['rpp']) ? $args['rpp'] : null, 'POST');
        $inici = FormUtil::getPassedValue('inici', isset($args['inici']) ? $args['inici'] : null, 'POST');
        $total = FormUtil::getPassedValue('total', isset($args['total']) ? $args['total'] : null, 'POST');
        $urltemplate = FormUtil::getPassedValue('urltemplate', isset($args['urltemplate']) ? $args['urltemplate'] : null, 'POST');

        //Security check
        if (!SecurityUtil::checkPermission('IWmessages::', '::', ACCESS_OVERVIEW) || !UserUtil::isLoggedIn()) {
            throw new Zikula_Exception_Forbidden();
        }

        // Quick check to ensure that we have work to do
        if ($total <= $rpp) {
            return;
        }

        if (!isset($inici) || empty($inici)) {
            $inici = 1;
        }

        if (!isset($rpp) || empty($rpp)) {
            $rpp = 10;
        }

        // Show startnum link
        if ($inici != 1) {
            $url = preg_replace('/%%/', 1, $urltemplate);
            $text = '<a href="' . $url . '"><<</a> | ';
        } else {
            $text = '<< | ';
        }
        $items[] = array('text' => $text);

        // Show following items
        $pagenum = 1;

        for ($curnum = 1; $curnum <= $total; $curnum += $rpp) {
            if (($inici < $curnum) || ($inici > ($curnum + $rpp - 1))) {
                //mod by marsu - use sliding window for pagelinks
                if ((($pagenum % 10) == 0) // link if page is multiple of 10
                        || ($pagenum == 1) // link first page
                        || (($curnum > ($inici - 4 * $rpp)) //link -3 and +3 pages
                        && ($curnum < ($inici + 4 * $rpp)))
                ) {
                    // Not on this page - show link
                    $url = preg_replace('/%%/', $curnum, $urltemplate);
                    $text = '<a href="' . $url . '">' . $pagenum . '</a> | ';
                    $items[] = array('text' => $text);
                }
                //end mod by marsu
            } else {
                // On this page - show text
                $text = $pagenum . ' | ';
                $items[] = array('text' => $text);
            }
            $pagenum++;
        }

        if (($curnum >= $rpp + 1) && ($inici < $curnum - $rpp)) {
            $url = preg_replace('/%%/', $curnum - $rpp, $urltemplate);
            $text = '<a href="' . $url . '">>></a>';
        } else {
            $text = '>>';
        }
        $items[] = array('text' => $text);

        return $this->view->assign('items', $items)
                ->fetch('IWmessages_user_pager.tpl');
    }
Esempio n. 27
0
 function update_company()
 {
     // Confirm the forms authorisation key
     $this->checkCsrfToken();
     $ot = FormUtil::getPassedValue('ot', 'address', 'GETPOST');
     $id = (int) FormUtil::getPassedValue('id', 0, 'GETPOST');
     $oldvalue = (int) FormUtil::getPassedValue('oldvalue', 0, 'GETPOST');
     $startnum = FormUtil::getPassedValue('startnum', 1, 'GET');
     $letter = FormUtil::getPassedValue('letter', 0);
     $sort = FormUtil::getPassedValue('sort', ModUtil::getVar('AddressBook', 'addressbooktype') == 1 ? 'sortname ASC' : 'sortcompany ASC');
     $search = FormUtil::getPassedValue('search', 0);
     $category = FormUtil::getPassedValue('category', 0);
     $private = FormUtil::getPassedValue('private', 0);
     $url = ModUtil::url('AddressBook', 'user', 'view', array('ot' => $ot, 'startnum' => $startnum, 'letter' => $letter, 'sort' => $sort, 'search' => $search, 'category' => $category, 'private' => $private));
     $object = new AddressBook_DBObject_Address();
     $data = $object->get($id);
     // security check
     // Get user id
     if (UserUtil::isLoggedIn()) {
         $user_id = UserUtil::getVar('uid');
     } else {
         $user_id = 0;
     }
     if (!(SecurityUtil::checkPermission('AddressBook::', '::', ACCESS_EDIT) || $user_id == $data['user_id'])) {
         return LogUtil::registerPermissionError();
     }
     $obj = array('company' => $data['company'], 'address1' => $data['address1'], 'address2' => $data['address2'], 'zip' => $data['zip'], 'city' => $data['city'], 'state' => $data['state'], 'country' => $data['country']);
     $res = DBUtil::updateObject($obj, 'addressbook_address', '', 'company');
     if (!$res) {
         LogUtil::registerError($this->__('Error! Company update failed.'));
         return System::redirect($url);
     }
     // clear respective cache
     ModUtil::apiFunc('AddressBook', 'user', 'clearItemCache', $data);
     LogUtil::registerStatus($this->__('Done! Company update successful.'));
     return System::redirect($url);
 }
Esempio n. 28
0
    public function display($blockinfo) {
        // Security check
        if (!SecurityUtil::checkPermission('IWagendas:nextblock:', $blockinfo['title'] . "::", ACCESS_READ))
            return;

        // Check if the module is available
        if (!ModUtil::available('IWagendas'))
            return;
        $user = (UserUtil::isLoggedIn()) ? UserUtil::getVar('uid') : '-1';
        //get the headlines saved in the user vars. It is renovate every 10 minutes
        $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
        $exists = ModUtil::apiFunc('IWmain', 'user', 'userVarExists', array('name' => 'next',
                    'module' => 'IWagendas',
                    'uid' => $user,
                    'sv' => $sv));
        //$exists = false;
        if ($exists) {
            $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
            $s = ModUtil::func('IWmain', 'user', 'userGetVar', array('uid' => $user,
                        'name' => 'next',
                        'module' => 'IWagendas',
                        'sv' => $sv,
                        'nult' => true));
            $blockinfo['content'] = $s;
            return BlockUtil::themesideblock($blockinfo);
        }

        // Get the view object
        $view = Zikula_View::getInstance('IWagendas', false);

        // Get the number of days in which the future events will be shown
        $days = $blockinfo['url'];

        // Get the annotations in the following days
        $texts = ModUtil::apiFunc('IWagendas', 'user', 'getEvents', array('inici' => time(),
                    'final' => time() + $days * 24 * 60 * 60));
        foreach ($texts as $text) {
            $datafield = str_replace("\r", '', str_replace('\'', '&acute;', $text['c1']));
            // replace any newlines that aren't preceded by a > with a <br />
            $datafield = preg_replace('/(?<!>)\n/', "<br />", $datafield);
            $title = ($text['tasca']) ? $this->__('Task') . ' - ' . $text['nivell'] : ($text['totdia'] == 1) ? $this->__('All day') : date('H:i', $text['data']);
            $date = date('d/m', $text['data']);
            $events[] = array('date' => $date,
                'title' => $title,
                'deleted' => $text['deleted'],
                'modified' => $text['modified'],
                'datafield' => $datafield);
        }

        if (count($texts) == 0) {
            $events[] = array('date' => '',
                'title' => '',
                'deleted' => 0,
                'modified' => 0,
                'datafield' => $this->__('There are no events in the agenda for the next ') . ' ' . $days . ' ' . $this->__(' days'),
            );
        }

        $view->assign('events', $events);
        $view->assign('days', $days);

        $s = $view->fetch('IWagendas_block_next.htm');

        //Copy the block information into user vars
        $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
        ModUtil::func('IWmain', 'user', 'userSetVar', array('uid' => $user,
            'name' => 'next',
            'module' => 'IWagendas',
            'sv' => $sv,
            'value' => $s,
            'lifetime' => '700'));

        $blockinfo['content'] = $s;

        return BlockUtil::themesideblock($blockinfo);
    }
Esempio n. 29
0
    /**
     * Get available menu links.
     *
     * @return array array of menu links.
     */
    public function getlinks($args)
    {
        $links = array();
        $search_modules = ModUtil::apiFunc('Search', 'user', 'getallplugins');

        if (SecurityUtil::checkPermission('Search::', '::', ACCESS_READ)) {
            $links[] = array('url' => ModUtil::url('Search', 'user', 'main', array()), 'text' => $this->__('New search'), 'class' => 'z-icon-es-search');
            if ((count($search_modules) > 0) && UserUtil::isLoggedIn()) {
                $links[] = array('url' => ModUtil::url('Search', 'user', 'recent', array()), 'text' => $this->__('Recent searches list'), 'class' => 'z-icon-es-view');
            }
        }

        return $links;
    }
Esempio n. 30
0
    /**
     * Define a message as marked
     * @author:     Albert Pérez Monfort (aperezm@xtec.cat)
     * @param:	args   Array with the id of the message
     * @return:	Redirect to the user main page
     */
    public function mark($args) {
        
        if (!SecurityUtil::checkPermission('IWforums::', '::', ACCESS_READ)) {
            throw new Zikula_Exception_Fatal($this->__('Sorry! No authorization to access this module.'));
        }

        if (!UserUtil::isLoggedIn()) {
            throw new Zikula_Exception_Fatal();
        }

        $fid = $this->request->getPost()->get('fid', '');
        if (!$fid) {
            throw new Zikula_Exception_Fatal($this->__('no forum id'));
        }

        $fmid = $this->request->getPost()->get('fmid', '');
        if (!$fmid) {
            throw new Zikula_Exception_Fatal($this->__('no message id'));
        }

        //get forum information
        $forum = ModUtil::apiFunc('IWforums', 'user', 'get',
                                   array('fid' => $fid));
        if ($forum == false) {
            AjaxUtil::error($this->__('The forum upon which the action had to be carried out hasn\'t been found'));
        }

        //check if user can access the forum
        $access = ModUtil::func('IWforums', 'user', 'access',
                                 array('fid' => $fid));
        if ($access < 1) {
            AjaxUtil::error($this->__('You can\'t access the forum'));
        }

        //get message information
        $registre = ModUtil::apiFunc('IWforums', 'user', 'get_msg',
                                      array('fmid' => $fmid));
        if ($registre == false) {
            AjaxUtil::error($this->__('No messages have been found'));
        }

        $marcat = (strpos($registre['marcat'], '$' . UserUtil::getVar('uid') . '$') === false) ? $registre['marcat'] . '$' . UserUtil::getVar('uid') . '$' : str_replace('$' . UserUtil::getVar('uid') . '$', '', $registre['marcat']);

        $m = (strpos($registre['marcat'], '$' . UserUtil::getVar('uid') . '$') === false) ? 1 : 0;

        $ha_marcat = ModUtil::apiFunc('IWforums', 'user', 'marcat',
                                       array('marcat' => $marcat,
                                             'fmid' => $fmid));
        ;
        $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
        ModUtil::func('IWmain', 'user', 'userSetVar',
                       array('module' => 'IWmain_block_flagged',
                             'name' => 'have_flags',
                             'value' => 'fo',
                             'sv' => $sv));

        $markText = ($m == 0) ? $this->__("Check the message") : $this->__('Uncheck the message');
        
        $ofMarkText = $markText;
        $markText = "<span style=\"cursor: pointer;\" id=\"markText\"><a onclick=\"javascript:mark(" . $fid . "," . $fmid . ")\">" . $markText . "</a></span>";
        $modid = ModUtil::getIdFromName('IWmain');
        $blocks = ModUtil::apiFunc('Blocks', 'user', 'getall',
                                    array('modid' => $modid));
        if (!empty($blocks)) {
            $reloadFlags = ($blocks[0]['active'] == 1) ? true : false;
        } else {
            $reloadFlags = false;
        }

        return new Zikula_Response_Ajax(array('fmid' => $fmid,
                'm' => $m,
                'markText' => $markText,
                'ofMarkText' => $ofMarkText,
                'reloadFlags' => $reloadFlags,
                ));
    }