Exemple #1
0
 /**
  * Check if an upload file meets all validation criteria.
  *
  * @param array $file Reference to data of uploaded file.
  *
  * @return boolean true if file is valid else false
  */
 protected function validateFileUpload($file)
 {
     $dom = ZLanguage::getModuleDomain('MUBoard');
     // check if a file has been uploaded properly without errors
     if (!is_array($file) || is_array($file) && $file['error'] != '0') {
         if (is_array($file)) {
             return $this->handleError($file);
         }
         return LogUtil::registerError(__('Error! No file found.', $dom));
     }
     // extract file extension
     $fileName = $file['name'];
     $extensionarr = explode('.', $fileName);
     $extension = strtolower($extensionarr[count($extensionarr) - 1]);
     // validate extension
     $isValidExtension = $this->isAllowedFileExtension($objectType, $fieldName, $extension);
     if ($isValidExtension === false) {
         return LogUtil::registerError(__('Error! This file type is not allowed. Please choose another file format.', $dom));
     }
     // validate image file
     $imgInfo = array();
     $isImage = in_array($extension, $this->imageFileTypes);
     if ($isImage) {
         $imgInfo = getimagesize($file['tmp_name']);
         if (!is_array($imgInfo) || !$imgInfo[0] || !$imgInfo[1]) {
             return LogUtil::registerError(__('Error! This file type seems not to be a valid image.', $dom));
         }
     }
     return true;
 }
Exemple #2
0
/**
 * Update operation.
 * @param object $entity The treated object.
 * @param array  $params Additional arguments.
 *
 * @return bool False on failure or true if everything worked well.
 */
function Reviews_operation_update(&$entity, $params)
{
    $dom = ZLanguage::getModuleDomain('Reviews');
    // initialise the result flag
    $result = false;
    $objectType = $entity['_objectType'];
    $currentState = $entity['workflowState'];
    // get attributes read from the workflow
    if (isset($params['nextstate']) && !empty($params['nextstate'])) {
        // assign value to the data object
        $entity['workflowState'] = $params['nextstate'];
        if ($params['nextstate'] == 'archived') {
            // bypass validator (for example an end date could have lost it's "value in future")
            $entity['_bypassValidation'] = true;
        }
    }
    // get entity manager
    $serviceManager = ServiceUtil::getManager();
    $entityManager = $serviceManager->getService('doctrine.entitymanager');
    // save entity data
    try {
        //$this->entityManager->transactional(function($entityManager) {
        $entityManager->persist($entity);
        $entityManager->flush();
        //});
        $result = true;
    } catch (\Exception $e) {
        LogUtil::registerError($e->getMessage());
    }
    // return result of this operation
    return $result;
}
/**
 * Content
 *
 * @copyright (C) 2007-2010, Content Development Team
 * @link http://github.com/zikula-modules/Content
 * @license See license.txt
 */
function smarty_function_contentcolumncount($params, $view)
{
    $dom = ZLanguage::getModuleDomain('Content');
    // input is layout name
    $layout = isset($params['layout']) ? $params['layout'] : '';
    $columnCount = 1;
    // assume 1 if no match can be found
    // now start simple matching with a regular expression on the layout name. No science here.
    // Looking for the first numbers in the string and stops with text again. Then take the highest single digit.
    // Examples:
    // layout			columnCount
    // ---------------------------------
    // column21212		2
    // column2d2575		2
    // column3d502525	3
    // column23andtext	3
    //
    if (preg_match('/[1-9]+/', $layout, $matches)) {
        // found first set of numbers
        $matchSplit = str_split($matches[0]);
        rsort($matchSplit);
        $columnCount = $matchSplit[0];
    }
    if (isset($params['assign'])) {
        $smarty->assign($params['assign'], $columnCount);
    } else {
        return $columnCount;
    }
}
/**
 * Content
 *
 * @copyright (C) 2007-2010, Content Development Team
 * @link http://github.com/zikula-modules/Content
 * @license See license.txt
 */
function smarty_function_contentcodeeditor($params, $view)
{
    $dom = ZLanguage::getModuleDomain('Content');
    $inputId = $params['inputId'];
    $inputType = isset($params['inputType']) ? $params['inputType'] : null;
    // Get reference to optional radio button that enables the editor (a hack for the HTML plugin).
    // It would have been easier just to read a $var in the template, but this won't work with a
    // Forms plugin - you would just get the initial value from when the page was loaded
    $htmlRadioButton = isset($params['htmlradioid']) ? $view->getPluginById($params['htmlradioid']) : null;
    $textRadioButton = isset($params['textradioid']) ? $view->getPluginById($params['textradioid']) : null;
    $html = '';
    $useBBCode = $textRadioButton == null && $inputType == 'text' && !$view->isPostBack() || $textRadioButton != null && $textRadioButton->checked;
    if ($useBBCode && ModUtil::available('BBCode')) {
        $html = "<div class=\"z-formrow\"><em class=\"z-sub\">";
        $html .= ModUtil::func('BBCode', 'User', 'bbcodes', array('textfieldid' => $inputId, 'images' => 0));
        $html .= "</em></div>";
    } else {
        if ($useBBCode && !ModUtil::available('BBCode')) {
            $html = "<div class=\"z-formrow\"><em class=\"z-sub\">";
            $html .= '(' . __("Please install the BBCode module to enable BBCodes display.", $dom) . ')';
            $html .= "</em></div>";
        }
    }
    return $html;
}
Exemple #5
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);
 }
/**
 * AddressBook
 *
 * @copyright (c) AddressBook Development Team
 * @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html
 * @package AddressBook
 */
function smarty_function_AddressShowGmap($params, &$smarty)
{
    $dom = ZLanguage::getModuleDomain('AddressBook');
    $assign = isset($params['assign']) ? $params['assign'] : null;
    $directions = '';
    if (isset($params['directions'])) {
        $directions = '<a href="http://maps.google.com/maps?f=d&daddr=' . $params['lat_long'];
        if (isset($params['zoomlevel'])) {
            $directions .= '&z=' . $params['zoomlevel'];
        }
        $directions .= '" target="_blank">' . __('Get directions to this location', $dom) . '</a>';
    }
    if (!empty($directions)) {
        $directions = '<div>' . $directions . '</div>';
    }
    include_once 'modules/AddressBook/lib/vendor/GMaps/GoogleMapV3.php';
    $map_id = 'googlemap';
    if (isset($params['mapid'])) {
        $map_id .= $params['mapid'];
    }
    $app_id = 'ZikulaAddressBook';
    $map = new GoogleMapAPI($map_id, $app_id);
    if (isset($params['maptype'])) {
        $map->setMapType($params['maptype']);
        // hybrid, satellite, terrain, roadmap
    }
    if (isset($params['zoomlevel'])) {
        $map->setZoomLevel($params['zoomlevel']);
    }
    $map->setTypeControlsStyle('dropdown');
    $map->setWidth(isset($params['width']) && $params['width'] ? $params['width'] : '100%');
    $map->setHeight(isset($params['height']) && $params['height'] ? $params['height'] : '400px');
    // handle one (center) point
    if (isset($params['lat_long'])) {
        $arrLatLong = explode(',', $params['lat_long']);
        $map->setCenterCoords($arrLatLong[1], $arrLatLong[0]);
        $map->addMarkerByCoords($arrLatLong[1], $arrLatLong[0], $params['title'], $params['html'], $params['tooltip'], $params['icon'], $params['iconshadow']);
    }
    // API key
    if (isset($params['api_key'])) {
        $map->setApiKey($params['api_key']);
    }
    // handle array of points
    if (isset($params['points'])) {
        foreach ($params['points'] as $point) {
            $arrLatLong = explode(',', $point['lat_long']);
            $map->addMarkerByCoords($arrLatLong[1], $arrLatLong[0], $point['title'], $point['html'], $point['tooltip'], $point['icon'], $point['iconshadow']);
        }
    }
    // load the map
    $map->enableOnLoad();
    if ($assign) {
        $result = $map->getHeaderJS() . $map->getMapJS() . $directions . $map->printMap() . $map->printOnLoad();
        $smarty->assign($assign, $result);
    } else {
        PageUtil::addVar('rawtext', $map->getHeaderJS());
        PageUtil::addVar('rawtext', $map->getMapJS());
        return $directions . $map->printMap() . $map->printOnLoad();
    }
}
 public function __construct(EntityManagerInterface $entityManager, RequestStack $requestStack, EngineInterface $renderEngine)
 {
     $this->entityManager = $entityManager;
     $this->requestStack = $requestStack;
     $this->renderEngine = $renderEngine;
     $this->domain = \ZLanguage::getModuleDomain('CmfcmfMediaModule');
 }
Exemple #8
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);
     }
 }
 /**
  * Post constructor hook.
  *
  * @return void
  */
 public function setup()
 {
     $this->view = \Zikula_View::getInstance(self::MODULENAME, false);
     // set caching off
     $this->_em = \ServiceUtil::get('doctrine.entitymanager');
     $this->domain = \ZLanguage::getModuleDomain(self::MODULENAME);
 }
Exemple #10
0
 public function __construct(RouterInterface $router, SecurityManager $securityManager, TranslatorInterface $translator)
 {
     $this->router = $router;
     $this->securityManager = $securityManager;
     $this->domain = \ZLanguage::getModuleDomain('CmfcmfMediaModule');
     $this->translator = $translator;
 }
Exemple #11
0
 /**
  * Initialize form handler.
  *
  * This method takes care of all necessary initialisation of our data and form states.
  *
  * @return boolean False in case of initialization errors, otherwise true.
  */
 public function initialize(Zikula_Form_View $view)
 {
     $dom = ZLanguage::getModuleDomain($this->name);
     // permission check
     if (!SecurityUtil::checkPermission('MUBoard::', '::', ACCESS_ADMIN)) {
         return $view->registerError(LogUtil::registerPermissionError());
     }
     // retrieve module vars
     $modVars = ModUtil::getVar('MUBoard');
     // initialise list entries for the 'number images' setting
     $modVars['numberImagesItems'] = array(array('value' => '1', 'text' => '1'), array('value' => '2', 'text' => '2'), array('value' => '3', 'text' => '3'));
     // initialise list entries for the 'number files' setting
     $modVars['numberFilesItems'] = array(array('value' => '1', 'text' => '1'), array('value' => '2', 'text' => '2'), array('value' => '3', 'text' => '3'));
     // initialise list entries for the 'sorting postings' setting
     $modVars['sortingCategoriesItems'] = array(array('value' => 'descending', 'text' => __('Descending', $dom)), array('value' => 'ascending', 'text' => __('Ascending', $dom)));
     // initialise list entries for the 'sorting postings' setting
     $modVars['sortingPostingsItems'] = array(array('value' => 'descending', 'text' => __('Descending', $dom)), array('value' => 'ascending', 'text' => __('Ascending', $dom)));
     // initialise list entries for the 'icon set' setting
     $modVars['iconSetItems'] = array(array('value' => '1', 'text' => '1'), array('value' => '2', 'text' => '2'), array('value' => '3', 'text' => '3'));
     // initialise list entries for the 'template' setting
     $modVars['templateItems'] = array(array('value' => 'normal', 'text' => 'Normal'), array('value' => 'jquery', 'text' => 'jQuery'));
     // assign all module vars
     $this->view->assign('config', $modVars);
     // custom initialisation aspects
     $this->initializeAdditions();
     // everything okay, no initialization errors occured
     return true;
 }
Exemple #12
0
 /**
  * Performs all validation rules.
  *
  * @return mixed either array with error information or true on success
  */
 public function validateAll()
 {
     $errorInfo = array('message' => '', 'code' => 0, 'debugArray' => array());
     $dom = ZLanguage::getModuleDomain('MUBoard');
     if (!$this->isStringNotLongerThan('title', 255)) {
         $errorInfo['message'] = __f('Error! Length of field value must not be higher than %2$s (%1$s).', array('title', 255), $dom);
         return $errorInfo;
     }
     if (!$this->isStringNotEmpty('title')) {
         $errorInfo['message'] = __f('Error! Field value must not be empty (%s).', array('title'), $dom);
         return $errorInfo;
     }
     if (!$this->isStringNotLongerThan('description', 2000)) {
         $errorInfo['message'] = __f('Error! Length of field value must not be higher than %2$s (%1$s).', array('description', 2000), $dom);
         return $errorInfo;
     }
     if (!$this->isStringNotEmpty('description')) {
         $errorInfo['message'] = __f('Error! Field value must not be empty (%s).', array('description'), $dom);
         return $errorInfo;
     }
     if (!$this->isValidInteger('pos')) {
         $errorInfo['message'] = __f('Error! Field value may only contain digits (%s).', array('pos'), $dom);
         return $errorInfo;
     }
     /* if (!$this->isNumberNotEmpty('pos')) {
            $errorInfo['message'] = __f('Error! Field value must not be 0 (%s).', array('pos'), $dom);
            return $errorInfo;
        }*/
     if (!$this->isNumberNotLongerThan('pos', 3)) {
         $errorInfo['message'] = __f('Error! Length of field value must not be higher than %2$s (%1$s).', array('pos', 3), $dom);
         return $errorInfo;
     }
     return true;
 }
Exemple #13
0
 /**
  * Performs all validation rules.
  *
  * @return mixed either array with error information or true on success
  */
 public function validateAll()
 {
     $errorInfo = array('message' => '', 'code' => 0, 'debugArray' => array());
     $dom = ZLanguage::getModuleDomain('MUBoard');
     if (!$this->isValidInteger('userid')) {
         $errorInfo['message'] = __f('Error! Field value may only contain digits (%s).', array('userid'), $dom);
         return $errorInfo;
     }
     if (!$this->isNumberNotEmpty('userid')) {
         $errorInfo['message'] = __f('Error! Field value must not be 0 (%s).', array('userid'), $dom);
         return $errorInfo;
     }
     if (!$this->isNumberNotLongerThan('userid', 11)) {
         $errorInfo['message'] = __f('Error! Length of field value must not be higher than %2$s (%1$s).', array('userid', 11), $dom);
         return $errorInfo;
     }
     if (!$this->isValidInteger('numberPostings')) {
         $errorInfo['message'] = __f('Error! Field value may only contain digits (%s).', array('numberPostings'), $dom);
         return $errorInfo;
     }
     /* if (!$this->isNumberNotEmpty('numberPostings')) {
            $errorInfo['message'] = __f('Error! Field value must not be 0 (%s).', array('numberPostings'), $dom);
            return $errorInfo;
        }*/
     if (!$this->isNumberNotLongerThan('numberPostings', 11)) {
         $errorInfo['message'] = __f('Error! Length of field value must not be higher than %2$s (%1$s).', array('numberPostings', 11), $dom);
         return $errorInfo;
     }
     if (!$this->isValidDateTime('lastVisit')) {
         $errorInfo['message'] = __f('Error! Field value must be a valid datetime (%s).', array('lastVisit'), $dom);
         return $errorInfo;
     }
     return true;
 }
Exemple #14
0
/**
 * Content needle
 * @param $args['nid'] needle id
 * @return array()
 */
function content_needleapi_content($args)
{
    $dom = ZLanguage::getModuleDomain('Content');
    // Get arguments from argument array
    $nid = $args['nid'];
    unset($args);
    // cache the results
    static $cache;
    if (!isset($cache)) {
        $cache = array();
    }
    if (!empty($nid)) {
        if (!isset($cache[$nid])) {
            // not in cache array
            if (ModUtil::available('Content')) {
                $contentpage = ModUtil::apiFunc('Content', 'Page', 'getPage', array('id' => $nid, 'includeContent' => false));
                if ($contentpage != false) {
                    $cache[$nid] = '<a href="' . DataUtil::formatForDisplay(ModUtil::url('Content', 'user', 'view', array('pid' => $nid))) . '" title="' . DataUtil::formatForDisplay($contentpage['title']) . '">' . DataUtil::formatForDisplay($contentpage['title']) . '</a>';
                } else {
                    $cache[$nid] = '<em>' . DataUtil::formatForDisplay(__('Unknown id', $dom)) . '</em>';
                }
            } else {
                $cache[$nid] = '<em>' . DataUtil::formatForDisplay(__('Content not available', $dom)) . '</em>';
            }
        }
        $result = $cache[$nid];
    } else {
        $result = '<em>' . DataUtil::formatForDisplay(__('No needle id', $dom)) . '</em>';
    }
    return $result;
}
/**
* Smarty modifier to get the respective status text
*
* Example
*   <!--[$article.published_status|news_getstatustext]-->
* 
* @author       Mateo Tibaquira [mateo]
* @since        17/11/2009
* @param        int      $status       The status to transform
* @return       string   the modified output
*/
function smarty_modifier_news_getstatustext($status)
{
    $dom    = ZLanguage::getModuleDomain('News');
    $output = __('Unknown status', $dom);

    switch ($status)
    {
        case 0:
            $output = __('Published', $dom);
            break;

        case 1:
            $output = __('Rejected', $dom);
            break;

        case 2:
            $output = __('Pending Review', $dom);
            break;

        case 3:
            $output = __('Archived', $dom);
            break;

        case 4:
            $output = __('Draft', $dom);
            break;
    }

    return $output;
}
function mediashare_source_browserapi_addMediaItem($args)
{
    $dom = ZLanguage::getModuleDomain('mediashare');
    if (!isset($args['albumId'])) {
        return LogUtil::registerError(__f('Missing [%1$s] in \'%2$s\'', array('albumId', 'source_browserapi.addMediaItem'), $dom));
    }
    $uploadFilename = $args['uploadFilename'];
    // FIXME Required because the globals??
    //pnModAPILoad('mediashare', 'edit');
    // For OPEN_BASEDIR reasons we move the uploaded file as fast as possible to an accessible place
    // MUST remember to remove it afterwards!!!
    // Create and check tmpfilename
    $tmpDir = pnModGetVar('mediashare', 'tmpDirName');
    if (($tmpFilename = tempnam($tmpDir, 'Upload_')) === false) {
        return LogUtil::registerError(__f("Unable to create a temporary file in '%s'", $tmpDir, $dom) . ' - ' . __('(uploading image)', $dom));
    }
    if (is_uploaded_file($uploadFilename)) {
        if (move_uploaded_file($uploadFilename, $tmpFilename) === false) {
            unlink($tmpFilename);
            return LogUtil::registerError(__f('Unable to move uploaded file from \'%1$s\' to \'%2$s\'', array($uploadFilename, $tmpFilename), $dom) . ' - ' . __('(uploading image)', $dom));
        }
    } else {
        if (!copy($uploadFilename, $tmpFilename)) {
            unlink($tmpFilename);
            return LogUtil::registerError(__f('Unable to copy the file from \'%1$s\' to \'%2$s\'', array($uploadFilename, $tmpFilename), $dom) . ' - ' . __('(adding image)', $dom));
        }
    }
    $args['mediaFilename'] = $tmpFilename;
    $result = pnModAPIFunc('mediashare', 'edit', 'addMediaItem', $args);
    unlink($tmpFilename);
    return $result;
}
function smarty_function_mediashare_breadcrumb($params, &$smarty)
{
    $dom = ZLanguage::getModuleDomain('mediashare');
    if (!isset($params['albumId'])) {
        $smarty->trigger_error(__f('Missing [%1$s] in \'%2$s\'', array('albumId', 'mediashare_breadcrumb'), $dom));
        return false;
    }
    $mode = isset($params['mode']) ? $params['mode'] : 'view';
    $breadcrumb = pnModAPIFunc('mediashare', 'user', 'getAlbumBreadcrumb', array('albumId' => (int) $params['albumId']));
    if ($breadcrumb === false) {
        $smarty->trigger_error(LogUtil::getErrorMessagesText());
        return false;
    }
    $urlType = $mode == 'edit' ? 'edit' : 'user';
    $url = pnModUrl('mediashare', $urlType, 'view', array('aid' => 0));
    $result = "<div class=\"mediashare-breadcrumb\">";
    $first = true;
    foreach ($breadcrumb as $album) {
        $url = DataUtil::formatForDisplay(pnModUrl('mediashare', $urlType, 'view', array('aid' => $album['id'])));
        $result .= ($first ? '' : ' &raquo; ') . "<a href=\"{$url}\">" . htmlspecialchars($album['title']) . "</a>";
        $first = false;
    }
    $result .= "</div>";
    if (isset($params['assign'])) {
        $smarty->assign($params['assign'], $result);
    }
    return $result;
}
function smarty_function_iwqvuserassignmentactionmenulinks($params, &$smarty) {
    $dom = ZLanguage::getModuleDomain('IWqv');
    // set some defaults
    if (!isset($params['start'])) {
        $params['start'] = '[';
    }
    if (!isset($params['end'])) {
        $params['end'] = ']';
    }
    if (!isset($params['separator'])) {
        $params['separator'] = ' | ';
    }
    if (!isset($params['class'])) {
        $params['class'] = 'pn-sub';
    }
    
    $html = '';

    if ($params['viewas'] == 'teacher') {
        if (SecurityUtil::checkPermission('IWqv::', "::", ACCESS_ADD)) {
            $html = "<span class=\"" . $params['class'] . "\">" . $params['start'] . " ";
            $html .= "<a onclick=\"iwqvPreviewAssignment('" . $params['url'] . "?skin=" . $params['skin'] . "&lang=" . $params['lang'] . "')\" href=\"javascript:void(0);\">" . __('preview', $dom) . "</a>";
            if (isset($params['hidecorrect']) && $params['hidecorrect'] == false)
                $html .= $params['separator'] . "<a onclick=\"iwqvShowAssignment(" . $params['qvid'] . ", '" . $params['viewas'] . "')\" href=\"javascript:void(0);\">" . __('correct', $dom) . "</a>";
            $html .= $params['separator'] . "<a onclick=\"iwqvEditAssignment(" . $params['qvid'] . ")\" href=\"javascript:void(0);\">" . __('edit', $dom) . "</a>";

            if (SecurityUtil::checkPermission('IWqv::', "::", ACCESS_DELETE)) {
                if (isset($params['hidecorrect']) && $params['hidecorrect'] == false)
                    $html .= $params['separator'] . "<a onclick=\"iwqvDeleteAssignment(" . $params['qvid'] . ")\" href=\"javascript:void(0);\">" . __('delete', $dom) . "</a>";
            }
            $html .= $params['end'] . "</span>\n";
        }
    }
    return $html;
}
Exemple #19
0
 /**
  * Collect available actions for this entity.
  */
 protected function prepareItemActions()
 {
     if (!empty($this->_actions)) {
         return;
     }
     $currentType = FormUtil::getPassedValue('type', 'user', 'GETPOST', FILTER_SANITIZE_STRING);
     $currentFunc = FormUtil::getPassedValue('func', 'main', 'GETPOST', FILTER_SANITIZE_STRING);
     $dom = ZLanguage::getModuleDomain('Reviews');
     if ($currentType == 'admin') {
         if (in_array($currentFunc, array('main', 'view'))) {
             $this->_actions[] = array('url' => array('type' => 'user', 'func' => 'display', 'arguments' => array('ot' => 'review', 'id' => $this['id'], 'slug' => $this->slug)), 'icon' => 'preview', 'linkTitle' => __('Open preview page', $dom), 'linkText' => __('Preview', $dom));
             $this->_actions[] = array('url' => array('type' => 'admin', 'func' => 'display', 'arguments' => array('ot' => 'review', 'id' => $this['id'], 'slug' => $this->slug)), 'icon' => 'display', 'linkTitle' => str_replace('"', '', $this->getTitleFromDisplayPattern()), 'linkText' => __('Details', $dom));
         }
         if (in_array($currentFunc, array('main', 'view', 'display'))) {
             $component = 'Reviews:Review:';
             $instance = $this->id . '::';
             if (SecurityUtil::checkPermission($component, $instance, ACCESS_EDIT)) {
                 $this->_actions[] = array('url' => array('type' => 'admin', 'func' => 'edit', 'arguments' => array('ot' => 'review', 'id' => $this['id'])), 'icon' => 'edit', 'linkTitle' => __('Edit', $dom), 'linkText' => __('Edit', $dom));
                 $this->_actions[] = array('url' => array('type' => 'admin', 'func' => 'edit', 'arguments' => array('ot' => 'review', 'astemplate' => $this['id'])), 'icon' => 'saveas', 'linkTitle' => __('Reuse for new item', $dom), 'linkText' => __('Reuse', $dom));
             }
             if (SecurityUtil::checkPermission($component, $instance, ACCESS_DELETE)) {
                 $this->_actions[] = array('url' => array('type' => 'admin', 'func' => 'delete', 'arguments' => array('ot' => 'review', 'id' => $this['id'])), 'icon' => 'delete', 'linkTitle' => __('Delete', $dom), 'linkText' => __('Delete', $dom));
             }
         }
         if ($currentFunc == 'display') {
             $this->_actions[] = array('url' => array('type' => 'admin', 'func' => 'view', 'arguments' => array('ot' => 'review')), 'icon' => 'back', 'linkTitle' => __('Back to overview', $dom), 'linkText' => __('Back to overview', $dom));
         }
     }
     if ($currentType == 'user') {
         if (in_array($currentFunc, array('main', 'view'))) {
             if (ModUtil::getVar('Reviews', 'addcategorytitletopermalink') == 1 && ModUtil::getVar('Reviews', 'enablecategorization') == 1) {
                 $this->_actions[] = array('url' => array('type' => 'user', 'func' => 'display', 'arguments' => array('ot' => 'review', 'id' => $this['id'], 'slug' => $this->slug)), 'icon' => 'display', 'linkTitle' => str_replace('"', '', $this->getTitleFromDisplayPattern()), 'linkText' => __('Details', $dom));
             } else {
                 $this->_actions[] = array('url' => array('type' => 'user', 'func' => 'display', 'arguments' => array('ot' => 'review', 'id' => $this['id'], 'slug' => $this->slug)), 'icon' => 'display', 'linkTitle' => str_replace('"', '', $this->getTitleFromDisplayPattern()), 'linkText' => __('Details', $dom));
             }
         }
         /* if (in_array($currentFunc, array('main', 'view', 'display'))) {
             $component = 'Reviews:Review:';
            $instance = $this->id . '::';
            if (SecurityUtil::checkPermission($component, $instance, ACCESS_EDIT)) {
            $this->_actions[] = array(
                    'url' => array('type' => 'user', 'func' => 'edit', 'arguments' => array('ot' => 'review', 'id' => $this['id'])),
                    'icon' => 'edit',
                    'linkTitle' => __('Edit', $dom),
                    'linkText' => __('Edit', $dom)
            );
            $this->_actions[] = array(
                    'url' => array('type' => 'user', 'func' => 'edit', 'arguments' => array('ot' => 'review', 'astemplate' => $this['id'])),
                    'icon' => 'saveas',
                    'linkTitle' => __('Reuse for new item', $dom),
                    'linkText' => __('Reuse', $dom)
            );
            }
            } */
         if ($currentFunc == 'display') {
             $this->_actions[] = array('url' => array('type' => 'user', 'func' => 'view', 'arguments' => array('ot' => 'review')), 'icon' => 'back', 'linkTitle' => __('Back to overview', $dom), 'linkText' => __('Back to overview', $dom));
         }
     }
 }
Exemple #20
0
 function getMediaDisplayHtml($url, $width, $height, $id, $args)
 {
     $dom = ZLanguage::getModuleDomain('mediashare');
     $widthHtml = $width == null ? '' : " width=\"{$width}\"";
     $heightHtml = $height == null ? '' : " height=\"{$height}\"";
     $output = '<object classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA"' . ' id="' . $id . '"' . $widthHtml . $heightHtml . ' standby="' . __('Loading Real Player components...', $dom) . '"' . ' type="application/x-oleobject">' . '<param name="src" value="' . $url . '">' . '<param name="AutoStart" value="false">' . '<param name="MaintainAspect" value="1">' . '<embed type="audio/x-pn-realaudio-plugin" src="' . $url . '"' . $widthHtml . $heightHtml . ' autostart="false" align="center" MaintainAspect="1">' . '</embed>' . '</object>';
     return $output;
 }
Exemple #21
0
 function getMediaDisplayHtml($url, $width, $height, $id, $args)
 {
     $dom = ZLanguage::getModuleDomain('mediashare');
     $widthHtml = $width == null ? '' : " width=\"{$width}\"";
     $heightHtml = $height == null ? '' : " height=\"{$height}\"";
     $output = '<object classid="clsid:22d6f312-b0f6-11d0-94ab-0080c74c7e95"' . ' id="' . $id . '"' . $widthHtml . $heightHtml . ' standby="' . __('Loading Microsoft Windows Media Player components...', $dom) . '"' . ' type="application/x-oleobject"' . ' codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701">' . '<param name="fileName" value="' . $url . '">' . '<param name="AutoStart" value="false">' . '<param name="showControls" value="true">' . '<embed type="application/x-mplayer2" src="' . $url . '" name="MediaPlayer"' . ' ShowControls="1" ShowStatusBar="0" ShowDisplay="0" autostart="0"' . $widthHtml . $heightHtml . '>' . '</embed>' . '</object>';
     return $output;
 }
Exemple #22
0
 /**
  * Constructor.
  *
  * @param Zikula_View $view View instance.
  */
 public function __construct(Zikula_View $view)
 {
     $parts = explode('_', get_class($this));
     $this->modname = $parts[0];
     $this->pluginname = array_pop($parts);
     $this->domain = ZLanguage::getModuleDomain($this->modname);
     $this->view = $view;
 }
Exemple #23
0
 function displayEditing()
 {
     $dom = ZLanguage::getModuleDomain('mediashare');
     if (!empty($this->mediaItemId)) {
         return pnModFunc('mediashare', 'user', 'simpledisplay', array('mid' => $this->mediaItemId, 'showAlbumLink' => $this->showAlbumLink, 'text' => $this->text, 'containerWidth' => $this->styleWidth));
     }
     return __('No media item selected', $dom);
 }
Exemple #24
0
 /**
  * Collect available actions for this entity.
  */
 protected function prepareItemActions()
 {
     if (!empty($this->_actions)) {
         return;
     }
     $currentType = FormUtil::getPassedValue('type', 'user', 'GETPOST', FILTER_SANITIZE_STRING);
     $currentFunc = FormUtil::getPassedValue('func', 'main', 'GETPOST', FILTER_SANITIZE_STRING);
     $dom = ZLanguage::getModuleDomain('MUBoard');
     if ($currentType == 'admin') {
         if (in_array($currentFunc, array('main', 'view'))) {
             $this->_actions[] = array('url' => array('type' => 'user', 'func' => 'display', 'arguments' => array('ot' => 'posting', 'id' => $this['id'])), 'icon' => 'preview', 'linkTitle' => __('Open preview page', $dom), 'linkText' => __('Preview', $dom));
             $this->_actions[] = array('url' => array('type' => 'admin', 'func' => 'display', 'arguments' => array('ot' => 'posting', 'id' => $this['id'])), 'icon' => 'display', 'linkTitle' => str_replace('"', '', $this['title']), 'linkText' => __('Details', $dom));
         }
         if (in_array($currentFunc, array('main', 'view', 'display'))) {
             if (SecurityUtil::checkPermission('MUBoard::', '.*', ACCESS_EDIT)) {
                 $this->_actions[] = array('url' => array('type' => 'admin', 'func' => 'edit', 'arguments' => array('ot' => 'posting', 'id' => $this['id'])), 'icon' => 'edit', 'linkTitle' => __('Edit', $dom), 'linkText' => __('Edit', $dom));
                 $this->_actions[] = array('url' => array('type' => 'admin', 'func' => 'edit', 'arguments' => array('ot' => 'posting', 'astemplate' => $this['id'])), 'icon' => 'saveas', 'linkTitle' => __('Reuse for new item', $dom), 'linkText' => __('Reuse', $dom));
             }
             if (SecurityUtil::checkPermission('MUBoard::', '.*', ACCESS_DELETE)) {
                 $this->_actions[] = array('url' => array('type' => 'admin', 'func' => 'delete', 'arguments' => array('ot' => 'posting', 'id' => $this['id'])), 'icon' => 'delete', 'linkTitle' => __('Delete', $dom), 'linkText' => __('Delete', $dom));
             }
         }
         if ($currentFunc == 'display') {
             $this->_actions[] = array('url' => array('type' => 'admin', 'func' => 'view', 'arguments' => array('ot' => 'posting')), 'icon' => 'back', 'linkTitle' => __('Back to overview', $dom), 'linkText' => __('Back to overview', $dom));
         }
     }
     if ($currentType == 'user') {
         if (in_array($currentFunc, array('main', 'view'))) {
             $this->_actions[] = array('url' => array('type' => 'user', 'func' => 'display', 'arguments' => array('ot' => 'posting', 'id' => $this['id'])), 'icon' => 'display', 'linkTitle' => str_replace('"', '', $this['title']), 'linkText' => __('Details', $dom));
         }
         if (in_array($currentFunc, array('main', 'view', 'display'))) {
             if (SecurityUtil::checkPermission('MUBoard::', '.*', ACCESS_EDIT)) {
                 /*$this->_actions[] = array(
                    'url' => array('type' => 'user', 'func' => 'edit', 'arguments' => array('ot' => 'posting')),
                           'icon' => 'save',
                           'linkTitle' => __('Create new issue', $dom),
                           'linkText' => __('', $dom)
                   );
                   $this->_actions[] = array(
                           'url' => array('type' => 'user', 'func' => 'edit', 'arguments' => array('ot' => 'posting', 'id' => $this['id'])),
                           'icon' => 'edit',
                           'linkTitle' => __('Edit', $dom),
                           'linkText' => __('Edit', $dom)
                   );
                   $this->_actions[] = array(
                           'url' => array('type' => 'user', 'func' => 'edit', 'arguments' => array('ot' => 'posting', 'astemplate' => $this['id'])),
                           'icon' => 'saveas',
                           'linkTitle' => __('Reuse for new item', $dom),
                           'linkText' => __('Reuse', $dom)
                   );*/
             }
         }
         if ($currentFunc == 'display') {
             $this->_actions[] = array('url' => array('type' => 'user', 'func' => 'display', 'arguments' => array('ot' => 'forum', 'id' => $posting . Forum . id)), 'icon' => 'back', 'linkTitle' => __('Back to forum ', $dom) . $posting . Forum . title, 'linkText' => __('Back to forum overview', $dom));
             $this->_actions[] = array('url' => array('type' => 'user', 'func' => 'view', 'arguments' => array('ot' => 'category')), 'icon' => 'back', 'linkTitle' => __('Back to forum overview', $dom), 'linkText' => __('', $dom));
         }
     }
 }
Exemple #25
0
function mediashareSourceBrowserUpload(&$args)
{
    if (!SecurityUtil::confirmAuthKey()) {
        return LogUtil::registerAuthidError();
    }
    $dom = ZLanguage::getModuleDomain('mediashare');
    $albumId = mediashareGetIntUrl('aid', $args, 0);
    // Check access
    if (!mediashareAccessAlbum($albumId, mediashareAccessRequirementAddMedia, '')) {
        return LogUtil::registerPermissionError();
    }
    // Get parent album information
    if (!($album = pnModAPIFunc('mediashare', 'user', 'getAlbum', array('albumId' => $albumId)))) {
        return false;
    }
    // Start fetching media items
    $imageNum = (int) FormUtil::getPassedValue('imagenum');
    $statusSet = array();
    for ($i = 1; $i <= $imageNum; ++$i) {
        $uploadInfo = $_FILES["upload{$i}"];
        $width = FormUtil::getPassedValue("width{$i}");
        $height = FormUtil::getPassedValue("height{$i}");
        if (isset($uploadInfo['error']) && $uploadInfo['error'] != 0 && $uploadInfo['name'] != '') {
            $statusSet[] = array('ok' => false, 'message' => $uploadInfo['name'] . ': ' . mediashareUploadErrorMsg($uploadInfo['error']));
        } else {
            if ($uploadInfo['size'] > 0) {
                $result = pnModAPIFunc('mediashare', 'source_browser', 'addMediaItem', array('albumId' => $albumId, 'uploadFilename' => $uploadInfo['tmp_name'], 'fileSize' => $uploadInfo['size'], 'filename' => $uploadInfo['name'], 'mimeType' => $uploadInfo['type'], 'title' => null, 'keywords' => null, 'description' => null, 'width' => $width, 'height' => $height));
                if ($result === false) {
                    $status = array('ok' => false, 'message' => LogUtil::getErrorMessagesText());
                } else {
                    $status = array('ok' => true, 'message' => $result['message'], 'mediaId' => $result['mediaId']);
                }
                $statusSet = array_merge($statusSet, array($status));
            }
        }
    }
    // Quick count of uploaded images + getting IDs for further editing
    $editMediaIds = array();
    $acceptedImageNum = 0;
    foreach ($statusSet as $status) {
        if ($status['ok']) {
            ++$acceptedImageNum;
            $editMediaIds[] = $status['mediaId'];
        }
    }
    $album['imageCount'] += $acceptedImageNum;
    // Update for showing only
    if ($acceptedImageNum == 0) {
        $statusSet[] = array('ok' => false, 'message' => __('No media items', $dom));
    }
    if (($items = pnModAPIFunc('mediashare', 'user', 'getMediaItems', array('mediaIdList' => $editMediaIds))) === false) {
        return false;
    }
    $render =& pnRender::getInstance('mediashare', false);
    $render->assign('statusSet', $statusSet);
    $render->assign('items', $items);
    return $render->fetch('mediashare_source_browser_uploadet.html');
}
Exemple #26
0
 /**
  * Performs all validation rules.
  *
  * @return mixed either array with error information or true on success
  */
 public function validateAll()
 {
     $errorInfo = array('message' => '', 'code' => 0, 'debugArray' => array());
     $dom = ZLanguage::getModuleDomain('MUBoard');
     if (!$this->isStringNotLongerThan('title', 255)) {
         $errorInfo['message'] = __f('Error! Length of field value must not be higher than %2$s (%1$s).', array('title', 255), $dom);
         return $errorInfo;
     }
     if (!$this->isStringNotLongerThan('text', 10000)) {
         $errorInfo['message'] = __f('Error! Length of field value must not be higher than %2$s (%1$s).', array('text', 5000), $dom);
         return $errorInfo;
     }
     if (!$this->isStringNotEmpty('text')) {
         $errorInfo['message'] = __f('Error! Field value must not be empty (%s).', array('text'), $dom);
         return $errorInfo;
     }
     if (!$this->isValidInteger('invocations')) {
         $errorInfo['message'] = __f('Error! Field value may only contain digits (%s).', array('invocations'), $dom);
         return $errorInfo;
     }
     if (!$this->isNumberNotLongerThan('invocations', 11)) {
         $errorInfo['message'] = __f('Error! Length of field value must not be higher than %2$s (%1$s).', array('invocations', 11), $dom);
         return $errorInfo;
     }
     if (!$this->isValidBoolean('state')) {
         $errorInfo['message'] = __f('Error! Field value must be a valid boolean (%s).', array('state'), $dom);
         return $errorInfo;
     }
     if (!$this->isValidBoolean('solved')) {
         $errorInfo['message'] = __f('Error! Field value must be a valid boolean (%s).', array('solved'), $dom);
         return $errorInfo;
     }
     if (!$this->isStringNotLongerThan('firstImage', 255)) {
         $errorInfo['message'] = __f('Error! Length of field value must not be higher than %2$s (%1$s).', array('firstImage', 255), $dom);
         return $errorInfo;
     }
     if (!$this->isStringNotLongerThan('secondImage', 255)) {
         $errorInfo['message'] = __f('Error! Length of field value must not be higher than %2$s (%1$s).', array('secondImage', 255), $dom);
         return $errorInfo;
     }
     if (!$this->isStringNotLongerThan('thirdImage', 255)) {
         $errorInfo['message'] = __f('Error! Length of field value must not be higher than %2$s (%1$s).', array('thirdImage', 255), $dom);
         return $errorInfo;
     }
     if (!$this->isStringNotLongerThan('firstFile', 255)) {
         $errorInfo['message'] = __f('Error! Length of field value must not be higher than %2$s (%1$s).', array('firstFile', 255), $dom);
         return $errorInfo;
     }
     if (!$this->isStringNotLongerThan('secondFile', 255)) {
         $errorInfo['message'] = __f('Error! Length of field value must not be higher than %2$s (%1$s).', array('secondFile', 255), $dom);
         return $errorInfo;
     }
     if (!$this->isStringNotLongerThan('thirdFile', 255)) {
         $errorInfo['message'] = __f('Error! Length of field value must not be higher than %2$s (%1$s).', array('thirdFile', 255), $dom);
         return $errorInfo;
     }
     return true;
 }
Exemple #27
0
 /**
  * Builds an instance of this class.
  *
  * @param Zikula_EventManager $eventManager An instance of a Zikula event manager appropriate for this listener.
  */
 public function __construct(Zikula_EventManager $eventManager)
 {
     parent::__construct($eventManager);
     
     $this->domain = ZLanguage::getModuleDomain($this->name);
     
     $this->serviceManager = $eventManager->getServiceManager();
     $this->request = $this->serviceManager->getService('request');
 }
Exemple #28
0
 function getMediaDisplayHtml($url, $width, $height, $id, $args)
 {
     $dom = ZLanguage::getModuleDomain('mediashare');
     //$width="100px"; $height="100px";
     $widthHtml = $width == null ? '' : " width=\"{$width}\"";
     $heightHtml = $height == null ? '' : " height=\"{$height}\"";
     // FIXME Incomplete plugin?
     return '<a href="' . $url . '">' . __('PDF Link', $dom) . '</a>';
 }
/**
 * Smarty modifier to format datetimes in a more Human Readable form 
 * (like tomorow, 4 days from now, 6 hours ago)
 *
 * Example
 * <!--[$futuredate|dateformatHuman:'%x':'2']-->
 *
 * @author   Erik Spaan
 * @since    05/03/09
 * @param    string   $string   input datetime string
 * @param    string   $format   The format of the regular date output (default %x)
 * @param    string   $niceval  [1|2|3|4] Choose the nice value of the output (default 2)
 *                                    1 = full human readable
 *                                    2 = past date > 1 day with dateformat, otherwise human readable
 *                                    3 = within 1 day human readable, otherwise dateformat
 *                                    4 = only use the specified format
 * @return   string   the modified output
 */
function smarty_modifier_dateformatHuman($string, $format = '%x', $niceval = 2)
{
    $dom = ZLanguage::getModuleDomain('News');
    if (empty($format)) {
        $format = '%x';
    }
    // store the current datetime in a variable
    $now = DateUtil::getDatetime();
    if (empty($string)) {
        return DateUtil::formatDatetime($now, $format);
    }
    if (empty($niceval)) {
        $niceval = 2;
    }
    // now format the date with respect to the current datetime
    $res = '';
    $diff = DateUtil::getDatetimeDiff($now, $string);
    if ($diff['d'] < 0) {
        if ($niceval == 1) {
            $res = _fn('%s day ago', '%s days ago', abs($diff['d']), abs($diff['d']), $dom);
        } elseif ($niceval < 4 && $diff['d'] == -1) {
            $res = __('yesterday', $dom);
        } else {
            $res = DateUtil::formatDatetime($string, $format);
        }
    } elseif ($diff['d'] > 0) {
        if ($niceval > 2) {
            $res = DateUtil::formatDatetime($string, $format);
        } elseif ($diff['d'] == 1) {
            $res = __('tomorrow', $dom);
        } else {
            $res = _fn('%s day from now', '%s days from now', $diff['d'], $diff['d'], $dom);
        }
    } else {
        // no day difference
        if ($diff['h'] < 0) {
            $res = _fn('%s hour ago', '%s hours ago', abs($diff['h']), abs($diff['h']), $dom);
        } elseif ($diff['h'] > 0) {
            $res = _fn('%s hour from now', '%s hours from now', $diff['h'], $diff['h'], $dom);
        } else {
            // no hour difference
            if ($diff['m'] < 0) {
                $res = _fn('%s minute ago', '%s minutes ago', abs($diff['m']), abs($diff['m']), $dom);
            } elseif ($diff['m'] > 0) {
                $res = _fn('%s minute from now', '%s minutes from now', $diff['m'], $diff['m'], $dom);
            } else {
                // no min difference
                if ($diff['s'] < 0) {
                    $res = _fn('%s second ago', '%s seconds ago', abs($diff['s']), abs($diff['s']), $dom);
                } else {
                    $res = _fn('%s second from now', '%s seconds from now', $diff['s'], $diff['s'], $dom);
                }
            }
        }
    }
    return $res;
}
Exemple #30
0
/**
 * Set plugins
 */
function mediashare_adminapi_setTemplateGlobally($args)
{
    $dom = ZLanguage::getModuleDomain('mediashare');
    $new = array('template' => DataUtil::formatForStore($args['template']));
    if (!DBUtil::updateObject($new, 'mediashare_albums', '1=1', 'id')) {
        return LogUtil::registerError(__f('Error in %1$s: %2$s.', array('adminapi.setTemplateGlobally', 'Could not set the template.'), $dom));
    }
    return true;
}