Ejemplo n.º 1
0
 /**
  * Sets the value of the Registry Relation.
  *
  * @param Doctrine_Event $event Event.
  *
  * @return void
  */
 public function preSave($event)
 {
     $subclasses = ModUtil::getVar('Categories', 'EntityCategorySubclasses', array());
     // get the registry object
     $registry = Doctrine::getTable('Zikula_Doctrine_Model_Registry')->findOneByModuleAndTableAndProperty($subclasses[get_class($this)]['module'], $subclasses[get_class($this)]['table'], $this->reg_property);
     $this['Registry'] = $registry;
 }
Ejemplo n.º 2
0
 function handleCommand(Zikula_Form_View $view, &$args)
 {
     if ($args['commandName'] == 'cancel') {
         $url = ModUtil::url('Scribite', 'admin', 'main');
         return $view->redirect($url);
     } else {
         if ($args['commandName'] == 'restore') {
             $classname = 'ModulePlugin_Scribite_' . $this->editor . '_Plugin';
             if (method_exists($classname, 'getDefaults')) {
                 $defaults = $classname::getDefaults();
                 if (!empty($defaults)) {
                     ModUtil::setVars("moduleplugin.scribite." . strtolower($this->editor), $defaults);
                     LogUtil::registerStatus('Defaults succesfully restored.');
                 }
             }
             return true;
         }
     }
     // check for valid form
     if (!$view->isValid()) {
         return false;
     }
     $data = $view->getValues();
     ModUtil::setVars("moduleplugin.scribite." . strtolower($this->editor), $data);
     LogUtil::registerStatus($this->__('Done! Module configuration updated.'));
     return true;
 }
/**
 * Smarty function to display the category menu for admin links. This also adds the
 * navtabs.css to the page vars array for stylesheets.
 *
 * Admin
 * {admincategorymenu}
 *
 * @see          function.admincategorymenu.php::smarty_function_admincategoreymenu()
 * @param        array       $params      All attributes passed to this function from the template
 * @param        object      $view        Reference to the Zikula_View object
 * @return       string      the results of the module function
 */
function smarty_function_admincategorymenu($params, $view)
{
    PageUtil::addVar('stylesheet', ThemeUtil::getModuleStylesheet('Admin'));
    $modinfo = ModUtil::getInfoFromName($view->getTplVar('toplevelmodule'));
    $acid = ModUtil::apiFunc('AdminModule', 'admin', 'getmodcategory', array('mid' => $modinfo['id']));
    return ModUtil::func('AdminModule', 'admin', 'categorymenu', array('acid' => $acid));
}
Ejemplo n.º 4
0
 /**
  *
  */
 public function moduleSearch($args)
 {
     $dom = ZLanguage::getModuleDomain('MUBoard');
     $searchsubmit = $this->request->getPost()->filter('searchsubmit', 'none', FILTER_SANITIZE_STRING);
     $searchoptions = $this->request->getPost()->filter('searchoptions', 'all', FILTER_SANITIZE_STRING);
     $searchplace = $this->request->getPost()->filter('searchplace', 'title', FILTER_SANITIZE_STRING);
     $resultorder = $this->request->getPost()->filter('resultorder', 'none', FILTER_SANITIZE_STRING);
     $kind = $this->request->query->filter('kind', 'none', FILTER_SANITIZE_STRING);
     // user has not entered a string and there is 'none' as kind of search
     if ($searchsubmit == 'none' && $kind == 'none') {
         // return search form template
         return $this->searchRedirect();
     } else {
         if ($searchsubmit != 'none' && $kind == 'none') {
             $searchstring = $this->request->getPost()->filter('searchstring', '', FILTER_SANITIZE_STRING);
             if ($searchstring == '') {
                 $url = ModUtil::url($this->name, 'search', 'modulesearch');
                 return LogUtil::registerError(__('You have to enter a string!', $dom), null, $url);
             } else {
                 $args['searchstring'] = $searchstring;
                 $args['searchoptions'] = $searchoptions;
                 $args['searchplace'] = $searchplace;
                 $args['resultorder'] = $resultorder;
                 $args['kind'] = $kind;
             }
         }
         if ($searchsubmit == 'none' && $kind != 'none') {
             $args['kind'] = $kind;
         }
     }
     return ModUtil::apiFunc($this->name, 'search', 'moduleSearch', $args);
 }
Ejemplo n.º 5
0
    public function Install() {
        // Checks if module IWmain is installed. If not returns error
        $modid = ModUtil::getIdFromName('IWmain');
        $modinfo = ModUtil::getInfo($modid);

        if ($modinfo['state'] != 3) {
            return LogUtil::registerError($this->__('Module IWmain is needed. You have to install the IWmain module before installing it.'));
        }

        // Check if the version needed is correct
        $versionNeeded = '2.0';
        if (!ModUtil::func('IWmain', 'admin', 'checkVersion', array('version' => $versionNeeded))) {
            return false;
        }

        // create module tables
        $tables = array('IWstats', 'IWstats_summary');
        foreach ($tables as $table) {
            if (!DBUtil::createTable($table)) {
                return false;
            }
        }

        // create several indexes for IWstats table
        $table = DBUtil::getTables();
        $c = $table['IWstats_column'];
        if (!DBUtil::createIndex($c['moduleid'], 'IWstats', 'moduleid')) {
            return false;
        }
        if (!DBUtil::createIndex($c['uid'], 'IWstats', 'uid')) {
            return false;
        }
        if (!DBUtil::createIndex($c['ip'], 'IWstats', 'ip')) {
            return false;
        }
        if (!DBUtil::createIndex($c['ipForward'], 'IWstats', 'ipForward')) {
            return false;
        }
        if (!DBUtil::createIndex($c['ipClient'], 'IWstats', 'ipClient')) {
            return false;
        }
        if (!DBUtil::createIndex($c['userAgent'], 'IWstats', 'userAgent')) {
            return false;
        }
        if (!DBUtil::createIndex($c['isadmin'], 'IWstats', 'isadmin')) {
            return false;
        }

        // Set up config variables
        $this->setVar('skippedIps', '')
                ->setVar('modulesSkipped', '')
                ->setVar('deleteFromDays', 90)
                ->setVar('keepDays', 90);

        // create the system init hook
        EventUtil::registerPersistentModuleHandler('IWstats', 'core.postinit', array('IWstats_Listeners', 'coreinit'));

        // Initialisation successful
        return true;
    }
Ejemplo n.º 6
0
 /**
  * get available Admin panel links
  *
  * @return array Array of admin links
  */
 public function getlinks()
 {
     $links = array();
     if (SecurityUtil::checkPermission($this->name . '::', '::', ACCESS_READ)) {
         $links[] = array('url' => ModUtil::url($this->name, 'user', 'main'), 'text' => $this->__('Frontend'), 'title' => $this->__('Switch to user area.'), 'class' => 'z-icon-es-home');
     }
     if (SecurityUtil::checkPermission($this->name . '::', '::', ACCESS_ADMIN)) {
         $links[] = array('url' => ModUtil::url($this->name, 'admin', 'view', array('ot' => 'category')), 'text' => $this->__('Categories'), 'title' => $this->__('Category list'));
     }
     if (SecurityUtil::checkPermission($this->name . '::', '::', ACCESS_ADMIN)) {
         $links[] = array('url' => ModUtil::url($this->name, 'admin', 'view', array('ot' => 'forum')), 'text' => $this->__('Forums'), 'title' => $this->__('Forum list'));
     }
     if (SecurityUtil::checkPermission($this->name . '::', '::', ACCESS_ADMIN)) {
         $links[] = array('url' => ModUtil::url($this->name, 'admin', 'view', array('ot' => 'posting')), 'text' => $this->__('Postings'), 'title' => $this->__('Posting list'));
     }
     if (SecurityUtil::checkPermission($this->name . '::', '::', ACCESS_ADMIN)) {
         $links[] = array('url' => ModUtil::url($this->name, 'admin', 'view', array('ot' => 'abo')), 'text' => $this->__('Abos'), 'title' => $this->__('Abo list'));
     }
     if (SecurityUtil::checkPermission($this->name . '::', '::', ACCESS_ADMIN)) {
         $links[] = array('url' => ModUtil::url($this->name, 'admin', 'view', array('ot' => 'user')), 'text' => $this->__('Users'), 'title' => $this->__('User list'));
     }
     if (SecurityUtil::checkPermission($this->name . '::', '::', ACCESS_ADMIN)) {
         $links[] = array('url' => ModUtil::url($this->name, 'admin', 'view', array('ot' => 'rank')), 'text' => $this->__('Ranks'), 'title' => $this->__('Rank list'));
     }
     if (SecurityUtil::checkPermission($this->name . '::', '::', ACCESS_ADMIN)) {
         $links[] = array('url' => ModUtil::url($this->name, 'admin', 'config'), 'text' => $this->__('Configuration'), 'title' => $this->__('Manage settings for this application'));
     }
     return $links;
 }
Ejemplo n.º 7
0
    public function handleCommand(Zikula_Form_View $view, &$args)
    {
        if ($args['commandName'] == 'save') {
            if (!$this->view->isValid()) {
                return false;
            }

            $data = $this->view->getValues();

            if (!ModUtil::setVars('Content', $data['config'])) {
                return $this->view->setErrorMsg($this->__('Failed to set configuration variables'));
            }
            if ($data['config']['categoryUsage'] < 4) {
                // load the category registry util
                $mainCategory = CategoryRegistryUtil::getRegisteredModuleCategory('Content', 'content_page', $data['config']['categoryPropPrimary']);
                if (!$mainCategory) {
                    return LogUtil::registerError($this->__('Main category property does not exist.'));
                }
                if ($data['config']['categoryUsage'] < 3) {
                    $secondCategory = CategoryRegistryUtil::getRegisteredModuleCategory('Content', 'content_page', $data['config']['categoryPropSecondary']);
                    if (!$secondCategory) {
                        return LogUtil::registerError($this->__('Second category property does not exist.'));
                    }
                }
            }
            LogUtil::registerStatus($this->__('Done! Saved module configuration.'));
        } else if ($args['commandName'] == 'cancel') {
        }

        $url = ModUtil::url('Content', 'admin', 'main');

        return $this->view->redirect($url);
    }
Ejemplo n.º 8
0
 public function getlinks($args)
 {
     $links = array();
     $sublinks = array();
     $links[] = array('url' => ModUtil::url('Scribite', 'admin', 'modules'), 'text' => $this->__('Module list'), 'class' => 'z-icon-es-view');
     $links[] = array('url' => ModUtil::url('Scribite', 'admin', 'newmodule'), 'text' => $this->__('Add module'), 'class' => 'z-icon-es-new');
     $links[] = array('url' => ModUtil::url('Scribite', 'admin', 'modifyconfig'), 'text' => $this->__('Settings'), 'class' => 'z-icon-es-config');
     // check for all supported editors and generate links
     if (ModUtil::apiFunc('scribite', 'user', 'getEditors', array('editorname' => 'xinha'))) {
         $sublinks[] = array('url' => ModUtil::url('scribite', 'admin', 'modifyxinha'), 'text' => $this->__('Xinha'));
     }
     if (ModUtil::apiFunc('scribite', 'user', 'getEditors', array('editorname' => 'ckeditor'))) {
         $sublinks[] = array('url' => ModUtil::url('scribite', 'admin', 'modifyckeditor'), 'text' => $this->__('CKEditor'));
     }
     // openwysiwyg deprecated @4.3.0
     //        if (ModUtil::apiFunc('scribite', 'user', 'getEditors', array('editorname' => 'openwysiwyg'))) {
     //            $sublinks[] = array(
     //                'url' => ModUtil::url('scribite', 'admin', 'modifyopenwysiwyg'),
     //                'text' => $this->__('openWYSIWYG'));
     //        }
     if (ModUtil::apiFunc('scribite', 'user', 'getEditors', array('editorname' => 'nicedit'))) {
         $sublinks[] = array('url' => ModUtil::url('scribite', 'admin', 'modifynicedit'), 'text' => $this->__('NicEdit'));
     }
     if (ModUtil::apiFunc('scribite', 'user', 'getEditors', array('editorname' => 'markitup'))) {
         $sublinks[] = array('url' => ModUtil::url('scribite', 'admin', 'modifymarkitup'), 'text' => $this->__('markitup'));
     }
     if (ModUtil::apiFunc('scribite', 'user', 'getEditors', array('editorname' => 'tinymce'))) {
         $sublinks[] = array('url' => ModUtil::url('scribite', 'admin', 'modifytinymce'), 'text' => $this->__('TinyMCE'));
     }
     // add YUI page
     $sublinks[] = array('url' => ModUtil::url('scribite', 'admin', 'modifyyui'), 'text' => $this->__('YUI Editor'));
     $links[] = array('url' => ModUtil::url('Scribite', 'admin', 'modules'), 'text' => $this->__('Editor Config'), 'class' => 'z-icon-es-editor', 'links' => $sublinks);
     // return output
     return $links;
 }
Ejemplo n.º 9
0
    /**
    * Initialise SiriusXtecAuth module.
    */
    public function install()
    {
        // create module vars
        // ldap configuration
        $this->setVars(array('ldap_server'  => 'host.domain',
                             'ldap_basedn'  => 'cn=users,dc=host,dc=domain',
                             'ldap_searchattr' => 'cn'));
        // module configutation
        $defaultGroupId = ModUtil::getVar('Groups', 'defaultgroup');
        $initGroups = array($defaultGroupId);
        $this->setVars(array('ldap_active' => false,
                             'users_creation' => false,
                             'new_users_activation' => false,
                             'new_users_groups' => $initGroups,
                             'iw_write' => false,
                             'iw_lastnames' => false,
                             'loginXtecApps' => false,
                             'logoutXtecApps' => false,
                             'gtafProtocol' => 'http',
                             'e13Protocol' => 'http',
                             'gtafURL' => 'aplitic.xtec.cat/pls/gafoas/pk_for_mod_menu.p_for_opcions_menu?p_perfil=RES',
                             'e13URL' => 'aplitic.xtec.cat/pls/e13_formacio_gaf/formacio_gaf.inici',
							 'loginTime' => 200,
							 'logoutTime' => 200));
        // register handler
        EventUtil::registerPersistentModuleHandler('SiriusXtecAuth', 'module.users.ui.login.failed', array('SiriusXtecAuth_Listeners', 'trySiriusXtecAuth'));
        EventUtil::registerPersistentModuleHandler('SiriusXtecAuth', 'module.users.ui.logout.succeeded', array('SiriusXtecAuth_Listeners', 'logoutXtecApps'));
        // finish
        return true;
    }
Ejemplo n.º 10
0
 /**
  * Create or edit record.
  *
  * @return string|boolean Output.
  */
 public function edit()
 {
     if (!SecurityUtil::checkPermission('ExampleDoctrine::', '::', ACCESS_ADD)) {
         return LogUtil::registerPermissionError(ModUtil::url('ExampleDoctrine', 'user', 'index'));
     }
     $id = $this->request->query->getInt('id');
     if ($id) {
         // load user with id
         $user = $this->entityManager->find('ExampleDoctrine_Entity_User', $id);
         if (!$user) {
             return LogUtil::registerError($this->__f('User with id %s not found', $id));
         }
     } else {
         $user = new ExampleDoctrine_Entity_User();
     }
     /* @var $form Symfony\Component\Form\Form */
     $form = $this->serviceManager->getService('symfony.formfactory')->create(new ExampleDoctrine_Form_UserType(), $user);
     if ($this->request->getMethod() == 'POST') {
         $form->bindRequest($this->request);
         if ($form->isValid()) {
             $data = $form->getData();
             $this->entityManager->persist($data);
             $this->entityManager->flush();
             return $this->redirect(ModUtil::url('ExampleDoctrine', 'user', 'view'));
         }
     }
     return $this->view->assign('form', $form->createView())->fetch('exampledoctrine_user_edit.tpl');
 }
Ejemplo n.º 11
0
 /**
  * This function sets active/inactive status.
  *
  * @param eid
  *
  * @return mixed true or Ajax error
  */
 public function setstatus()
 {
     $this->checkAjaxToken();
     $this->throwForbiddenUnless(SecurityUtil::checkPermission('Ephemerides::', '::', ACCESS_ADMIN));
     $eid = $this->request->request->get('eid', 0);
     $status = $this->request->request->get('status', 0);
     $alert = '';
     if ($eid == 0) {
         $alert .= $this->__('No ID passed.');
     } else {
         $item = array('eid' => $eid, 'status' => $status);
         $res = DBUtil::updateObject($item, 'ephem', '', 'eid');
         if (!$res) {
             $alert .= $item['eid'] . ', ' . $this->__f('Could not change item, ID %s.', DataUtil::formatForDisplay($eid));
             if ($item['status']) {
                 $item['status'] = 0;
             } else {
                 $item['status'] = 1;
             }
         }
     }
     // get current status to return
     $item = ModUtil::apiFunc($this->name, 'user', 'get', array('eid' => $eid));
     if (!$item) {
         $alert .= $this->__f('Could not get data, ID %s.', DataUtil::formatForDisplay($eid));
     }
     return new Zikula_Response_Ajax(array('eid' => $eid, 'status' => $item['status'], 'alert' => $alert));
 }
Ejemplo n.º 12
0
 public function getContent($args)
 {
     switch ($args['pluginid']) {
         case 1:
             //$uid = $args['uid'];
             // Get matching news stories published since last newsletter
             // No selection on categories made !!
             $items = ModUtil::apiFunc('News', 'user', 'getall',
                             array('numitems' => $this->getVar('itemsperpage'),
                                 'status' => 0,
                                 'from' => DateUtil::getDatetime($args['last']),
                                 'filterbydate' => true));
             if ($items != false) {
                 if ($args['contenttype'] == 't') {
                     $counter = 0;
                     $output.="\n";
                     foreach ($items as $item) {
                         $counter++;
                         $output .= $counter . '. ' . $item['title'] . " (" . $this->__f('by %1$s on %2$s', array($item['contributor'], DateUtil::formatDatetime($item['from'], 'datebrief'))) . ")\n";
                     }
                 } else {
                     $render = Zikula_View::getInstance('News');
                     $render->assign('readperm', SecurityUtil::checkPermission('News::', "::", ACCESS_READ));
                     $render->assign('articles', $items);
                     $output = $render->fetch('mailz/listarticles.tpl');
                 }
             } else {
                 $output = $this->__f('No News publisher articles since last newsletter on %s.', DateUtil::formatDatetime($args['last'], 'datebrief')) . "\n";
             }
             return $output;
     }
     return '';
 }
Ejemplo n.º 13
0
/**
 * Smarty function to display a link to the next post
 *
 * Example
 * <!--[nextpostlink sid=$info.sid layout='%link% <span class="news_metanav">&raquo;</span>']-->
 *
 * @author Mark West
 * @since 20/10/03
 * @see function.nextpostlink.php::smarty_function_nextpostlink()
 * @param array $params All attributes passed to this function from the template
 * @param object &$smarty Reference to the Smarty object
 * @param integer $sid article id
 * @param string $layout HTML string in which to insert link
 * @return string the results of the module function
 */
function smarty_function_nextpostlink($params, &$smarty)
{
    if (!isset($params['sid'])) {
        // get the info template var
        $info = $smarty->get_template_vars('info');
        $params['sid'] = $info['sid'];
    }

    if (!isset($params['layout'])) {
        $params['layout'] = '%link% <span class="news_metanav">&raquo;</span>';
    }

    $article = ModUtil::apiFunc('News', 'user', 'getall',
                            array('query' => array(array('sid', '>', $params[sid])),
                                  'orderdir' => 'ASC',
                                  'numitems' => 1));

    if (!$article) {
        return;
    }

    $articlelink = '<a href="'.DataUtil::formatForDisplay(ModUtil::url('News', 'user', 'display', array('sid' => $article[0]['sid']))).'">'.DataUtil::formatForDisplay($article[0]['title']).'</a>';
    $articlelink = str_replace('%link%', $articlelink, $params['layout']);

    if (isset($params['assign'])) {
        $smarty->assign($params['assign'], $articlelink);
    } else {
        return $articlelink;
    }
}
Ejemplo n.º 14
0
    /**
     * Handle module install event "installer.module.installed".
     * Receives $modinfo as $args
     *
     * @param Zikula_Event $event
     *
     * @return void
     */
    public static function moduleInstall(Zikula_Event $event)
    {
        $mod = $event['name'];

        // determine search capability
        if (ModUtil::apiFunc($mod, 'search', 'info')) {

            // get all search blocks
            $blocks = BlockUtil::getBlocksInfo();

            foreach ($blocks as $block) {

                $block = $block->toArray();

                if ($block['bkey'] != 'Search') {
                    continue;
                }

                $content = BlockUtil::varsFromContent($block['content']);

                if (!isset($content['active'])) {
                    $content['active'] = array();
                }
                $content['active'][$mod] = 1;

                $block['content'] = BlockUtil::varsToContent($content);
                ModUtil::apiFunc('Blocks', 'admin', 'update', $block);
            }
        }
    }
Ejemplo n.º 15
0
    public function display($blockinfo) {
        // Security check (1)
        if (!SecurityUtil::checkPermission('IWmenu:topblock:', "$blockinfo[title]::", ACCESS_READ)) {
            return false;
        }

        // Check if the module is available. (2)
        if (!ModUtil::available('IWmenu')) {
            return false;
        }

        // Get variables from content block (3)
        //Get cached user menu
        $uid = is_null(UserUtil::getVar('uid')) ? '-1' : UserUtil::getVar('uid');

        //Generate menu
        $menu_estructure = ModUtil::apiFunc('IWmenu', 'user', 'getMenuStructure');
        // Defaults (4)
        if (empty($menu_estructure)) {
            return false;
        }

        // Create output object (6)
        $view = Zikula_View::getInstance('IWmenu');

        // assign your data to to the template (7)
        $view->assign('menu', $menu_estructure);

        // Populate block info and pass to theme (8)
        $menu = $view->fetch('IWmenu_block_top.htm');

        //$blockinfo['content'] = $menu;
        //return BlockUtil::themesideblock($blockinfo);
        return $menu;
    }
Ejemplo n.º 16
0
 /**
  * @param CollectionEntity|AbstractMediaEntity $entity
  *
  * @return string
  */
 public function escapeDescription($entity)
 {
     $description = $entity->getDescription();
     $strategy = null;
     $hookName = null;
     if ($entity instanceof CollectionEntity) {
         $strategy = \ModUtil::getVar('CmfcmfMediaModule', 'descriptionEscapingStrategyForCollection');
         $hookName = 'collections';
     } elseif ($entity instanceof AbstractMediaEntity) {
         $strategy = \ModUtil::getVar('CmfcmfMediaModule', 'descriptionEscapingStrategyForMedia');
         $hookName = 'media';
     } else {
         throw new \LogicException();
     }
     $eventName = "cmfcmfmediamodule.filter_hooks.{$hookName}.filter";
     $hook = new \Zikula_FilterHook($eventName, $description);
     $description = $this->hookDispatcher->dispatch($eventName, $hook)->getData();
     switch ($strategy) {
         case 'raw':
             return $description;
         case 'text':
             return htmlentities($description);
         case 'markdown':
             return $this->markdownExtra->transform($description);
         default:
             throw new \LogicException();
     }
 }
Ejemplo n.º 17
0
 public function handleCommand(Zikula_Form_View $view, &$args)
 {
     if (!SecurityUtil::checkPermission('Content:page:', '::', ACCESS_ADD)) {
         throw new Zikula_Exception_Forbidden($this->__('Error! You have not been granted access to create pages.'));
     }
     if ($args['commandName'] == 'create') {
         $pageData = $this->view->getValues();
         $validators = $this->notifyHooks(new Zikula_ValidationHook('content.ui_hooks.pages.validate_edit', new Zikula_Hook_ValidationProviders()))->getValidators();
         if (!$validators->hasErrors() && $this->view->isValid()) {
             $id = ModUtil::apiFunc('Content', 'Page', 'newPage', array('page' => $pageData, 'pageId' => $this->pageId, 'location' => $this->location));
             if ($id === false) {
                 return false;
             }
             // notify any hooks they may now commit the as the original form has been committed.
             $objectUrl = new Zikula_ModUrl('Content', 'user', 'view', ZLanguage::getLanguageCode(), array('pid' => $this->pageId));
             $this->notifyHooks(new Zikula_ProcessHook('content.ui_hooks.pages.process_edit', $this->pageId, $objectUrl));
         } else {
             return false;
         }
         $url = ModUtil::url('Content', 'admin', 'editPage', array('pid' => $id));
     } else {
         if ($args['commandName'] == 'cancel') {
             $id = null;
             $url = ModUtil::url('Content', 'admin', 'main');
         }
     }
     return $this->view->redirect($url);
 }
Ejemplo n.º 18
0
 public function Install() {
     // Checks if module IWmain is installed. If not returns error
     $modid = ModUtil::getIdFromName('IWmain');
     $modinfo = ModUtil::getInfo($modid);
     if ($modinfo['state'] != 3) {
         return LogUtil::registerError($this->$this->__('Module IWmain is needed. You have to install the IWmain module before installing it.'));
     }
     // Check if the version needed is correct
     $versionNeeded = '3.0.0';
     if (!ModUtil::func('IWmain', 'admin', 'checkVersion', array('version' => $versionNeeded))) {
         return false;
     }
     // Create module table
     if (!DBUtil::createTable('IWusers'))
         return false;
     if (!DBUtil::createTable('IWusers_friends'))
         return false;
     // Create the index
     if (!DBUtil::createIndex('iw_uid', 'IWusers', 'uid'))
         return false;
     if (!DBUtil::createIndex('iw_uid', 'IWusers_friends', 'uid'))
         return false;
     if (!DBUtil::createIndex('iw_fid', 'IWusers_friends', 'fid'))
         return false;
     //Create module vars
     $this->setVar('friendsSystemAvailable', 1)
             ->setVar('invisibleGroupsInList', '$')
             ->setVar('usersCanManageName', 0)
             ->setVar('allowUserChangeAvatar', '1')
             ->setVar('allowUserSetTheirSex', '0')
             ->setVar('allowUserDescribeTheirSelves', '1')
             ->setVar('avatarChangeValidationNeeded', '1')
             ->setVar('usersPictureFolder', 'photos');
     return true;
 }
Ejemplo n.º 19
0
 /**
  * Display block
  */
 public function display($blockinfo)
 {
     if (!SecurityUtil::checkPermission('Zgoodies:marqueeblock:', "{$blockinfo['bid']}::", ACCESS_OVERVIEW)) {
         return;
     }
     if (!ModUtil::available('Zgoodies')) {
         return;
     }
     $vars = BlockUtil::varsFromContent($blockinfo['content']);
     $lang = ZLanguage::getLanguageCode();
     // block title
     if (isset($vars['block_title'][$lang]) && !empty($vars['block_title'][$lang])) {
         $blockinfo['title'] = $vars['block_title'][$lang];
     }
     // marquee content
     if (isset($vars['marquee_content'][$lang]) && !empty($vars['marquee_content'][$lang])) {
         $vars['marquee_content_lang'] = $vars['marquee_content'][$lang];
     }
     if (!isset($vars['marquee_content'])) {
         $vars['marquee_content_lang'] = '';
     }
     $this->view->assign('vars', $vars);
     $this->view->assign('bid', $blockinfo['bid']);
     $blockinfo['content'] = $this->view->fetch('blocks/' . $vars['block_template']);
     if (isset($vars['block_wrap']) && !$vars['block_wrap']) {
         if (empty($blockinfo['title'])) {
             return $blockinfo['content'];
         } else {
             return '<h4>' . DataUtil::formatForDisplayHTML($blockinfo['title']) . '</h4>' . "\n" . $blockinfo['content'];
         }
     }
     return BlockUtil::themeBlock($blockinfo);
 }
Ejemplo n.º 20
0
    /**
     * Toggleblock.
     *
     * This function toggles active/inactive.
     *
     * @param bid int  id of block to toggle.
     *
     * @return mixed true or Ajax error
     */
    public function toggleblock()
    {
        $this->checkAjaxToken();
        $this->throwForbiddenUnless(SecurityUtil::checkPermission('Blocks::', '::', ACCESS_ADMIN));

        $bid = $this->request->request->get('bid', -1);

        if ($bid == -1) {
            throw new Zikula_Exception_Fatal($this->__('No block ID passed.'));
        }

        // read the block information
        $blockinfo = BlockUtil::getBlockInfo($bid);
        if ($blockinfo == false) {
            throw new Zikula_Exception_Fatal($this->__f('Error! Could not retrieve block information for block ID %s.', DataUtil::formatForDisplay($bid)));
        }

        if ($blockinfo['active'] == 1) {
            ModUtil::apiFunc('Blocks', 'admin', 'deactivate', array('bid' => $bid));
        } else {
            ModUtil::apiFunc('Blocks', 'admin', 'activate', array('bid' => $bid));
        }

        return new Zikula_Response_Ajax(array('bid' => $bid));
    }
Ejemplo n.º 21
0
    public function search(){
        // Check permission
        $this->throwForbiddenUnless(SecurityUtil::checkPermission('Llicencies::', '::', ACCESS_READ));
        //path to zk jquery lib
        $js      = new JCSSUtil;
        $scripts = $js->scriptsMap();
        $jquery  = $scripts['jquery']['path'];
        
        // Omplim les llistes desplegables del fromulari
        $cursos   = ModUtil::apiFunc('Llicencies', 'user', 'getYears');
        $temes    = ModUtil::apiFunc('Llicencies', 'user', 'getTopicList');
        $subtemes = ModUtil::apiFunc('Llicencies', 'user', 'getSubtopicList');
        $tipus    = ModUtil::apiFunc('Llicencies', 'user', 'getTypeList');
        
        $view = Zikula_View::getInstance($this->name);
        $view->assign('jquery'  , $jquery);
        $view->assign('cursos'  , $cursos);
        $view->assign('temes'   , $temes);
        $view->assign('subtemes', $subtemes);
        $view->assign('tipus'   , $tipus);        
        $view->assign('admin'   , false);
        // Carreagr el formulari per a fer la cerca de llicències d'estudi

        return $this->view->display('Llicencies_main.tpl');
    }
Ejemplo n.º 22
0
/**
 * Section to show the latest articles of a user.
 *
 * Parameters passed in the $args array:
 * -------------------------------------
 * numeric uid      The user account id of the user for whom to return comments.
 * numeric numitems Number of comments to show.
 * 
 * @param array $args All parameters passed to this function.
 * 
 * @return array An array of articles.
 */
function Profile_sectionapi_news($args)
{
    // validates an the uid parameter
    if (!isset($args['uid']) || empty($args['uid'])) {
        return false;
    }

    // assures the number of items to retrieve
    if (!isset($args['numitems']) || empty($args['numitems'])) {
        $args['numitems'] = 5;
    }

    // only published articles
    $args['status'] = 0;

    // exclude future articles
    $args['filterbydate'] = true;

    // removes unallowed parameters
    if (isset($args['from']))  unset($args['from']);
    if (isset($args['to']))    unset($args['to']);
    if (isset($args['query'])) unset($args['query']);

    return ModUtil::apiFunc('News', 'user', 'getall', $args);
}
Ejemplo n.º 23
0
 public function displayEditing()
 {
     if (!empty($this->addressid)) {
         return ModUtil::func('AddressBook', 'user', 'simpledisplay', array('id' => (int) $this->addressid));
     }
     return $this->__('No address selected');
 }
Ejemplo n.º 24
0
 /**
  * Setup internal properties.
  *
  * @param $bundle
  *
  * @return void
  */
 protected function _configureBase($bundle = null)
 {
     $this->systemBaseDir = realpath('.');
     if (null !== $bundle) {
         $this->name = $bundle->getName();
         $this->domain = ZLanguage::getModuleDomain($this->name);
         $this->baseDir = $bundle->getPath();
         $versionClass = $bundle->getVersionClass();
         $this->version = new $versionClass($bundle);
     } else {
         $className = $this->getReflection()->getName();
         $separator = false === strpos($className, '_') ? '\\' : '_';
         $parts = explode($separator, $className);
         $this->name = $parts[0];
         $this->baseDir = $this->libBaseDir = realpath(dirname($this->reflection->getFileName()) . '/../..');
         if (realpath("{$this->baseDir}/lib/" . $this->name)) {
             $this->libBaseDir = realpath("{$this->baseDir}/lib/" . $this->name);
         }
         $versionClass = "{$this->name}\\{$this->name}Version";
         $versionClassOld = "{$this->name}_Version";
         $versionClass = class_exists($versionClass) ? $versionClass : $versionClassOld;
         $this->version = new $versionClass();
     }
     $this->modinfo = array('directory' => $this->name, 'type' => ModUtil::getModuleBaseDir($this->name) == 'system' ? ModUtil::TYPE_SYSTEM : ModUtil::TYPE_MODULE);
     if ($this->modinfo['type'] == ModUtil::TYPE_MODULE) {
         $this->domain = ZLanguage::getModuleDomain($this->name);
     }
 }
/**
 * 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;
    }
}
Ejemplo n.º 26
0
 function delete()
 {
     // security check
     if (!SecurityUtil::checkPermission('AddressBook::', '::', ACCESS_ADMIN)) {
         return LogUtil::registerPermissionError();
     }
     $ot = FormUtil::getPassedValue('ot', 'categories', 'GETPOST');
     $id = (int) FormUtil::getPassedValue('id', 0, 'GETPOST');
     $url = ModUtil::url('AddressBook', 'admin', 'view', array('ot' => $ot));
     $class = 'AddressBook_DBObject_' . ucfirst($ot);
     if (!class_exists($class)) {
         return z_exit(__f('Error! Unable to load class [%s]', $ot));
     }
     $object = new $class();
     $data = $object->get($id);
     if (!$data) {
         LogUtil::registerError(__f('%1$s with ID of %2$s doesn\'\\t seem to exist', array($ot, $id)));
         return System::redirect($url);
     }
     $object->delete();
     if ($ot == "customfield") {
         $sql = "ALTER TABLE addressbook_address DROP adr_custom_" . $id;
         try {
             DBUtil::executeSQL($sql, -1, -1, true, true);
         } catch (Exception $e) {
         }
     }
     LogUtil::registerStatus($this->__('Done! Item deleted.'));
     return System::redirect($url);
 }
Ejemplo n.º 27
0
 /**
  * Handles an error.
  *
  * @param integer $errno      Number of the error.
  * @param string  $errstr     Error message.
  * @param string  $errfile    Filename where the error occurred.
  * @param integer $errline    Line of the error.
  * @param string  $errcontext Context of the error.
  *
  * @return boolean
  */
 public function handler($errno, $errstr, $errfile = '', $errline = 0, $errcontext = null)
 {
     $this->setupHandler($errno, $errstr, $errfile, $errline, $errcontext);
     // Notify all loggers
     $this->eventManager->notify($this->event->setArgs(array('trace' => $this->trace, 'type' => $this->type, 'errno' => $this->errno, 'errstr' => $this->errstr, 'errfile' => $this->errfile, 'errline' => $this->errline, 'errcontext' => $this->errcontext)));
     if ($this->isPHPError() && System::isDevelopmentMode() && $this->showPHPErrorHandler()) {
         // allow PHP to return error
         $this->resetHandler();
         return false;
     }
     if (!$this->isDisplayErrorTemplate()) {
         // prevent PHP from handling the event after we return
         $this->resetHandler();
         return true;
     }
     // obey reporing level
     if (abs($this->getType()) > $this->serviceManager['log.display_level']) {
         return false;
     }
     // unless in development mode, exit.
     if (!$this->serviceManager['log.display_template']) {
         return false;
     }
     // if we get this far, display template
     echo ModUtil::func('Errors', 'user', 'system', array('type' => $this->errno, 'message' => $this->errstr, 'file' => $this->errfile, 'line' => $this->errline));
     Zikula_View_Theme::getInstance()->themefooter();
     System::shutDown();
 }
Ejemplo n.º 28
0
 /**
  * display items for a day
  *
  * @param $args array Arguments array.
  *
  * @return string html string
  */
 public function display($args)
 {
     $eid = FormUtil::getPassedValue('eid', isset($args['eid']) ? $args['eid'] : null, 'REQUEST');
     $objectid = FormUtil::getPassedValue('objectid', isset($args['objectid']) ? $args['objectid'] : null, 'REQUEST');
     if (!empty($objectid)) {
         $eid = $objectid;
     }
     if (!isset($args['eid']) and !empty($eid)) {
         $args['eid'] = $eid;
     }
     // Chek permissions
     $this->throwForbiddenUnless(SecurityUtil::checkPermission('Ephemerides::', '::', ACCESS_READ), LogUtil::getErrorMsgPermission());
     // check if the contents are cached.
     $template = 'ephemerides_user_display.tpl';
     if ($this->view->is_cached($template)) {
         return $this->view->fetch($template);
     }
     // get items
     if (isset($args['eid']) and $args['eid'] > 0) {
         $items = ModUtil::apiFunc($this->name, 'user', 'getall', $args);
     } else {
         $items = ModUtil::apiFunc($this->name, 'user', 'gettoday', $args);
     }
     $this->view->assign('items', $items);
     return $this->view->fetch($template);
 }
Ejemplo n.º 29
0
/**
 * Zikula_View function to create  manual link.
 *
 * This function creates a manual link from some parameters.
 *
 * Available parameters:
 *   - manual:    name of manual file, manual.html if not set
 *   - chapter:   an anchor in the manual file to jump to
 *   - newwindow: opens the manual in a new window using javascript
 *   - width:     width of the window if newwindow is set, default 600
 *   - height:    height of the window if newwindow is set, default 400
 *   - title:     name of the new window if newwindow is set, default is modulename
 *   - class:     class for use in the <a> tag
 *   - assign:    if set, the results ( array('url', 'link') are assigned to the corresponding variable instead of printed out
 *
 * Example
 * {manuallink newwindow=1 width=400 height=300 title=rtfm }
 *
 * @param array       $params All attributes passed to this function from the template.
 * @param Zikula_View $view   Reference to the Zikula_View object.
 *
 * @return string|void
 */
function smarty_function_manuallink($params, Zikula_View $view)
{
    LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated.', array('manuallink')), E_USER_DEPRECATED);
    $userlang = ZLanguage::transformFS(ZLanguage::getLanguageCode());
    $stdlang = System::getVar('language_i18n');
    $title = isset($params['title']) ? $params['title'] : 'Manual';
    $manual = isset($params['manual']) ? $params['manual'] : 'manual.html';
    $chapter = isset($params['chapter']) ? '#' . $params['chapter'] : '';
    $class = isset($params['class']) ? 'class="' . $params['class'] . '"' : '';
    $width = isset($params['width']) ? $params['width'] : 600;
    $height = isset($params['height']) ? $params['height'] : 400;
    $modname = ModUtil::getName();
    $possibleplaces = array("modules/{$modname}/docs/{$userlang}/manual/{$manual}", "modules/{$modname}/docs/{$stdlang}/manual/{$manual}", "modules/{$modname}/docs/en/manual/{$manual}", "modules/{$modname}/docs/{$userlang}/{$manual}", "modules/{$modname}/docs/{$stdlang}/{$manual}", "modules/{$modname}/docs/lang/en/{$manual}");
    foreach ($possibleplaces as $possibleplace) {
        if (file_exists($possibleplace)) {
            $url = $possibleplace . $chapter;
            break;
        }
    }
    if (isset($params['newwindow'])) {
        $link = "<a {$class} href='#' onclick=\"window.open( '" . DataUtil::formatForDisplay($url) . "' , '" . DataUtil::formatForDisplay($modname) . "', 'status=yes,scrollbars=yes,resizable=yes,width={$width},height={$height}'); picwin.focus();\">" . DataUtil::formatForDisplayHTML($title) . "</a>";
    } else {
        $link = "<a {$class} href=\"" . DataUtil::formatForDisplay($url) . "\">" . DataUtil::formatForDisplayHTML($title) . "</a>";
    }
    if (isset($params['assign'])) {
        $ret = array('url' => $url, 'link' => $link);
        $view->assign($params['assign'], $ret);
        return;
    } else {
        return $link;
    }
}
Ejemplo n.º 30
0
 /**
  * Display block.
  *
  * @param  array  $blockinfo Blockinfo structure.
  *
  * @return output Rendered block.
  */
 public function display($blockinfo)
 {
     if (!SecurityUtil::checkPermission('PendingContent::', "{$blockinfo['title']}::", ACCESS_OVERVIEW)) {
         return;
     }
     // trigger event
     $event = new Zikula_Event('get.pending_content', new Zikula_Collection_Container('pending_content'));
     $pendingCollection = EventUtil::getManager()->notify($event)->getSubject();
     $content = array();
     // process results
     foreach ($pendingCollection as $collection) {
         $module = $collection->getName();
         foreach ($collection as $item) {
             $link = ModUtil::url($module, $item->getController(), $item->getMethod(), $item->getArgs());
             $content[] = array('description' => $item->getDescription(), 'link' => $link, 'number' => $item->getNumber());
         }
     }
     if (!empty($content)) {
         $this->view->assign('content', $content);
         $blockinfo['content'] = $this->view->fetch('blocks_block_pendingcontent.tpl');
     } else {
         $blockinfo['content'] = '';
     }
     return BlockUtil::themeBlock($blockinfo);
 }