Exemple #1
0
function mediashare_sourcesapi_scanSources()
{
    // Check access
    if (!SecurityUtil::checkPermission('mediashare::', '::', ACCESS_ADMIN)) {
        return LogUtil::registerPermissionError();
    }
    $dom = ZLanguage::getModuleDomain('mediashare');
    // Clear existing sources table
    if (!DBUtil::truncateTable('mediashare_sources')) {
        return LogUtil::registerError(__f('Error in %1$s: %2$s.', array('sourcesapi.scanSources', __f("Could not clear the '%s' table.", 'sources', $dom)), $dom));
    }
    // Scan for sources APIs
    $files = FileUtil::getFiles('modules/mediashare', false, true, 'php', 'f');
    foreach ($files as $file) {
        if (preg_match('/^pnsource_([-a-zA-Z0-9_]+)api.php$/', $file, $matches)) {
            $sourceName = $matches[1];
            $sourceApi = "source_{$sourceName}";
            // Force load - it is used during pninit
            pnModAPILoad('mediashare', $sourceApi, true);
            if (!($title = pnModAPIFunc('mediashare', $sourceApi, 'getTitle'))) {
                return false;
            }
            if (!pnModAPIFunc('mediashare', 'sources', 'addSource', array('title' => $title, 'name' => $sourceName))) {
                return false;
            }
        }
    }
    return true;
}
Exemple #2
0
function mediashare_external_pasteitem($args)
{
    // FIXME access check
    $albumId = mediashareGetIntUrl('aid', $args, 0);
    $mediaId = mediashareGetIntUrl('mid', $args, 0);
    $mode = FormUtil::getPassedValue('mode');
    if (isset($_POST['backButton'])) {
        return pnRedirect(pnModUrl('mediashare', 'external', 'finditem', array('aid' => $albumId, 'mid' => $mediaId, 'mode' => $mode)));
    }
    $mediaItem = pnModAPIFunc('mediashare', 'user', 'getMediaItem', array('mediaId' => $mediaId));
    /*
        if (!($handler = pnModAPIFunc('mediashare', 'mediahandler', 'loadHandler', array('handlerName' => $mediaItem['mediaHandler'])))) {
            return false;
        }
    */
    $render =& pnRender::getInstance('mediashare', false);
    mediashareExternalLoadTheme($render);
    $render->assign('albumId', $albumId);
    $render->assign('mediaId', $mediaId);
    $render->assign('mediaItem', $mediaItem);
    if ($mediaItem['mediaHandler'] != 'extapp') {
        $mediadir = pnModAPIFunc('mediashare', 'user', 'getRelativeMediadir');
        $render->assign('thumbnailUrl', $mediadir . $mediaItem['thumbnailRef']);
        $render->assign('previewUrl', $mediadir . $mediaItem['previewRef']);
        $render->assign('originalUrl', $mediadir . $mediaItem['originalRef']);
    } else {
        $render->assign('thumbnailUrl', "{$mediaItem['thumbnailRef']}");
        $render->assign('previewUrl', "{$mediaItem['previewRef']}");
        $render->assign('originalUrl', "{$mediaItem['originalRef']}");
    }
    $render->assign('mode', $mode);
    echo $render->fetch('mediashare_external_pasteitem.html');
    return true;
}
function mediashare_source_youtubeapi_getUploadInfo()
{
    if (!($userInfo = pnModAPIFunc('mediashare', 'edit', 'getUserInfo'))) {
        return false;
    }
    return array('post_max_size' => (int) ($post_max_size / 1000), 'upload_max_filesize' => (int) ($upload_max_filesize / 1000));
}
/** 
* Smarty plugin 
* ------------------------------------------------------------- 
* Type:     resource 
* Name:     userdb 
* Purpose:  read user maintained source as a template 
*           $tpl_name is parsed as a uri type of string where 
*          the path to the template field is encoded as: 
* 
* table/source_field?field=condtional&field=conditional... 
* 
* results in: 
*    SELECT source_field FROM table WHERE conditions... 
* ------------------------------------------------------------- 
*/
function smarty_resource_userdb_fetch($tpl_name, &$tpl_source, &$smarty, $default = false)
{
    $_url = parse_url($tpl_name);
    // (required) expected syntax: table/source_field
    $_path_items = explode('/', $_url['path']);
    $table = $_path_items[0];
    $source = $_path_items[1];
    // Theme Configuration
    $skinid = pnModAPIFunc('Xanthia', 'user', 'getSkinID', array('skin' => $table));
    $dbconn =& pnDBGetConn(true);
    $pntable =& pnDBGetTables();
    $table = $pntable['theme_tplsource'];
    $column =& $pntable['theme_tplsource_column'];
    $query = "SELECT {$column['tpl_source']}\n\t\t\t\t\tFROM {$table}\n\t\t\t\t\tWHERE {$column['tpl_file_name']}='{$source}'\n\t\t\t\t\tAND {$column['tpl_skin_id']}= '{$skinid}' LIMIT 1";
    $result =& $dbconn->Execute($query);
    if ($result->EOF) {
    } else {
        list($tpl_source) = $result->fields;
    }
    $result->MoveNext();
    $result->Close();
    if ($tpl_source) {
        return true;
    } else {
        return $default;
    }
}
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_mediashare_mediaUrl($params, &$smarty)
{
    $result = pnModAPIFunc('mediashare', 'user', 'getMediaUrl', $params);
    if (isset($params['assign'])) {
        $smarty->assign($params['assign'], $result);
    }
    return DataUtil::formatForDisplay($result);
}
Exemple #7
0
function mediashare_vfs_db_dump()
{
    $fileref = $_GET['ref'];
    // Retrieve image information
    if (!($media = pnModAPIFunc('mediashare', 'vfs_db', 'getMedia', array('fileref' => $fileref)))) {
        return false;
    }
    // Check access
    if (!mediashareAccessAlbum($media['albumId'], mediashareAccessRequirementView, null)) {
        return LogUtil::registerPermissionError();
    }
    // Some Mediashare users have reported this to make their setup work. The buffer may contain something
    // due to a buggy template or block
    while (@ob_end_clean()) {
    }
    if (pnConfigGetVar('UseCompression') == 1) {
        // With the "while (@ob_end_clean());" stuff above we are guranteed that no z-buffering is done
        // But(!) the "ob_start("ob_gzhandler");" made by pnAPI.php means a "Content-Encoding: gzip" is set.
        // So we need to reset this header since no compression is done
        header("Content-Encoding: identity");
    }
    // Check cached versus modified date
    $lastModifiedDate = date('D, d M Y H:i:s T', $media['modifiedDate']);
    $currentETag = $media['modifiedDate'];
    global $HTTP_SERVER_VARS;
    $cachedDate = isset($HTTP_SERVER_VARS['HTTP_IF_MODIFIED_SINCE']) ? $HTTP_SERVER_VARS['HTTP_IF_MODIFIED_SINCE'] : null;
    $cachedETag = isset($HTTP_SERVER_VARS['HTTP_IF_NONE_MATCH']) ? $HTTP_SERVER_VARS['HTTP_IF_NONE_MATCH'] : null;
    // If magic quotes are on then all query/post variables are escaped - so strip slashes to make a compare possible
    // - only cachedETag is expected to contain quotes
    if (get_magic_quotes_gpc()) {
        $cachedETag = stripslashes($cachedETag);
    }
    if ((empty($cachedDate) || $lastModifiedDate == $cachedDate) && '"' . $currentETag . '"' == $cachedETag) {
        header("HTTP/1.1 304 Not Modified");
        header("Status: 304 Not Modified");
        header("Expires: " . date('D, d M Y H:i:s T', time() + 180 * 24 * 3600));
        // My PHP insists on Expires in 1981 as default!
        header('Pragma: cache');
        // My PHP insists on putting a pragma "no-cache", so this is an attempt to avoid that
        header('Cache-Control: public');
        header("ETag: \"{$media['modifiedDate']}\"");
        return true;
    }
    header("Expires: " . date('D, d M Y H:i:s T', time() + 180 * 24 * 3600));
    // My PHP insists on Expires in 1981 as default!
    header('Pragma: cache');
    // My PHP insists on putting a pragma "no-cache", so this is an attempt to avoid that
    header('Cache-Control: public');
    header("ETag: \"{$media['modifiedDate']}\"");
    // Ensure correct content-type and a filename for eventual download
    header("Content-Type: {$media['mimeType']}");
    header("Content-Disposition: inline; filename=\"{$media['title']}\"");
    header("Last-Modified: {$lastModifiedDate}");
    header("Content-Length: " . strlen($media['data']));
    echo $media['data'];
    return true;
}
Exemple #8
0
/**
 * Scan for all media
 */
function mediashare_adminapi_scanAllPlugins()
{
    // Force load - it is used during pninit
    pnModAPILoad('mediashare', 'mediahandler', true);
    if (!pnModAPIFunc('mediashare', 'mediahandler', 'scanMediaHandlers')) {
        return false;
    }
    // Force load - it is used during pninit
    pnModAPILoad('mediashare', 'sources', true);
    return pnModAPIFunc('mediashare', 'sources', 'scanSources');
}
 function update($force)
 {
     if ($force || count($this->items) == 0) {
         $albums = pnModAPIFunc('mediashare', 'user', 'getAllAlbums', array('albumId' => 1, 'access' => $this->access, 'onlyMine' => $this->onlyMine));
         if ($albums === false) {
             pn_exit(LogUtil::getErrorMessagesText());
         }
         foreach ($albums as $album) {
             $this->addItem($album['title'], $album['id']);
         }
     }
 }
Exemple #10
0
/**
 * Mediashare AJAX handler
 *
 * @copyright (C) 2007, Jorn Wildt
 * @link http://www.elfisk.dk
 * @version $Id$
 * @license See license.txt
 */
function mediashare_ajax_getitems($args)
{
    $items = pnModAPIFunc('mediashare', 'user', 'getMediaItems', array('albumId' => FormUtil::getPassedValue('aid')));
    if ($items === false) {
        AjaxUtil::error(LogUtil::getErrorMessagesText(' - '), '403 Forbidden');
    }
    $mediaItems = array();
    foreach ($items as $item) {
        $mediaItems[] = array('id' => $item['id'], 'isExternal' => $item['mediaHandler'] == 'extapp', 'thumbnailRef' => $item['thumbnailRef'], 'previewRef' => $item['previewRef'], 'title' => $item['title']);
    }
    return array('mediaItems' => $mediaItems);
}
function smarty_function_mediashare_albumSelector($params, &$smarty)
{
    $dom = ZLanguage::getModuleDomain('mediashare');
    if (!isset($params['albumId'])) {
        $smarty->trigger_error(__f('Missing [%1$s] in \'%2$s\'', array('albumId', 'mediashare_albumSelector'), $dom));
        return false;
    }
    $albumId = $params['albumId'];
    $id = isset($params['id']) ? $params['id'] : 'album';
    $name = isset($params['name']) ? $params['name'] : $id;
    $excludeAlbumId = isset($params['excludeAlbumId']) ? $params['excludeAlbumId'] : null;
    $onlyMine = isset($params['onlyMine']) ? $params['onlyMine'] : false;
    $access = isset($params['access']) ? constant($params['access']) : 0xff;
    $albums = pnModAPIFunc('mediashare', 'user', 'getAllAlbums', array('albumId' => 1, 'excludeAlbumId' => $excludeAlbumId, 'access' => $access, 'onlyMine' => $onlyMine));
    if ($albums === false) {
        $smarty->trigger_error(LogUtil::getErrorMessagesText());
        return false;
    }
    if (isset($params['onchange'])) {
        $onChangeHtml = " onchange=\"{$params['onchange']}\"";
    } else {
        $onChangeHtml = '';
    }
    if (isset($params['id'])) {
        $idHtml = " id=\"{$id}\"";
    } else {
        $idHtml = '';
    }
    $html = "<select name=\"{$name}\"{$onChangeHtml}{$idHtml}>\n";
    foreach ($albums as $album) {
        $title = $album['title'];
        $id = (int) $album['id'];
        $level = $album['nestedSetLevel'] - 1;
        $indent = '';
        for ($i = 0; $i < $level; ++$i) {
            $indent .= '+ ';
        }
        $selectedHtml = $id == $albumId ? ' selected="selected"' : '';
        $html .= "<option value=\"{$id}\"{$selectedHtml}>{$indent}{$title}</option>\n";
    }
    $html .= "</select>";
    if (isset($params['assign'])) {
        $smarty->assign($params['assign'], $html);
    }
    return $html;
}
Exemple #12
0
/**
 * display block
 *
 * @param        array       $blockinfo     a blockinfo structure
 * @return       output      the rendered bock
 */
function FlashChatBridge_Onlineblock_display($blockinfo)
{
    if (!SecurityUtil::checkPermission('FlashChatBridge:Onlineblock:', "::", ACCESS_READ)) {
        return false;
    }
    if (!pnModAvailable('FlashChatBridge') || !pnUserLoggedIn()) {
        return false;
    }
    //pnModLoad("FlashChatBridge");
    $Users = pnModAPIFunc('FlashChatBridge', 'user', 'getChatterList');
    $count = count($Users);
    $render = pnRender::getInstance('FlashChatBridge', false);
    $render->assign('Users', $Users);
    $render->assign('Count', $count);
    $blockinfo['content'] = $render->fetch('flashchatbridge_block_online.htm');
    return pnBlockThemeBlock($blockinfo);
}
function smarty_function_mediashare_userinfo($params, $smarty)
{
    if (!($userInfo = pnModAPIFunc('mediashare', 'edit', 'getUserInfo'))) {
        return false;
    }
    $dom = ZLanguage::getModuleDomain('mediashare');
    $maxSize = $userInfo['mediaSizeLimitTotal'];
    $size = $userInfo['totalCapacityUsed'];
    $imageDir = 'modules/mediashare/pnimages';
    $leftSize = intval($maxSize > $size ? $size * 100 / $maxSize : 100);
    $rightSize = intval($maxSize > $size ? 100 - $leftSize : 0);
    $scale = 1000000;
    $unitTitle = 'Mb';
    $str = sprintf("%.2f %s %.2f %s", $size / $scale, __('of', $dom), $maxSize / $scale, $unitTitle);
    $result = "<div class=\"mediashare-userinfo\"><img src=\"{$imageDir}/bar_left.gif\" height=\"5\" width=\"{$leftSize}\" alt=\"\" />" . "<img src=\"{$imageDir}/bar_right.gif\" height=\"5\" width=\"{$rightSize}\" alt=\"\" />" . " {$leftSize}% ({$str})</div>";
    return $result;
}
Exemple #14
0
function mediashare_source_zipapi_getUploadInfo()
{
    if (!($userInfo = pnModAPIFunc('mediashare', 'edit', 'getUserInfo'))) {
        return false;
    }
    $upload_max_filesize = mediashareSourceZipParseIni(ini_get('upload_max_filesize'));
    if ($userInfo['totalCapacityLeft'] < $upload_max_filesize) {
        $upload_max_filesize = $userInfo['totalCapacityLeft'];
    }
    if ($userInfo['mediaSizeLimitSingle'] < $upload_max_filesize) {
        $upload_max_filesize = $userInfo['mediaSizeLimitSingle'];
    }
    $post_max_size = mediashareSourceZipParseIni(ini_get('post_max_size'));
    if ($userInfo['totalCapacityLeft'] < $post_max_size) {
        $post_max_size = $userInfo['totalCapacityLeft'];
    }
    return array('post_max_size' => (int) ($post_max_size / 1000), 'upload_max_filesize' => (int) ($upload_max_filesize / 1000));
}
function smarty_function_mediashare_mediaItem($params, &$smarty)
{
    $dom = ZLanguage::getModuleDomain('mediashare');
    pnModLoad('mediashare', 'user');
    $mediaBase = pnModAPIFunc('mediashare', 'user', 'getRelativeMediadir');
    // Check for absolute URLs returned by external apps.
    $src = substr($params['src'], 0, 4) == 'http' ? $params['src'] : $mediaBase . htmlspecialchars($params['src']);
    $title = isset($params['title']) ? $params['title'] : '';
    $id = isset($params['id']) ? $params['id'] : null;
    $isThumbnail = isset($params['isThumbnail']) ? (bool) $params['isThumbnail'] : false;
    $width = isset($params['width']) ? $params['width'] : null;
    $height = isset($params['height']) ? $params['height'] : null;
    $class = isset($params['class']) ? $params['class'] : null;
    $style = isset($params['style']) ? $params['style'] : null;
    $onclick = isset($params['onclick']) ? $params['onclick'] : null;
    $onmousedown = isset($params['onmousedown']) ? $params['onmousedown'] : null;
    if ($params['src'] == '') {
        $result = __('No media item found in this album', $dom);
    } else {
        if ($isThumbnail) {
            $onclickHtml = $onclick != null ? " onclick=\"{$onclick}\"" : '';
            $onmousedownHtml = $onmousedown != null ? " onmousedown=\"{$onmousedown}\"" : '';
            $widthHtml = $width == null ? '' : " width=\"{$width}\"";
            $heightHtml = $height == null ? '' : " height=\"{$height}\"";
            $classHtml = $class == null ? '' : " class=\"{$class}\"";
            $styleHtml = $style == null ? '' : " style=\"{$style}\"";
            $idHtml = isset($params['id']) ? " id=\"{$params['id']}\"" : '';
            $result = "<img src=\"{$src}\" alt=\"" . htmlspecialchars($title) . "\"{$idHtml}{$widthHtml}{$heightHtml}{$classHtml}{$styleHtml}{$onclickHtml}{$onmousedownHtml}/>";
        } else {
            $handler = pnModAPIFunc('mediashare', 'mediahandler', 'loadHandler', array('handlerName' => $params['mediaHandler']));
            if ($handler === false) {
                return false;
            }
            $result = $handler->getMediaDisplayHtml($src, $width, $height, $id, array('title' => $title, 'onclick' => $onclick, 'onmousedown' => $onmousedown, 'class' => $class, 'style' => $style));
        }
    }
    if (isset($params['assign'])) {
        $smarty->assign($params['assign'], $result);
    }
    return $result;
}
Exemple #16
0
/**
 * User main page
 * @return HTML
 */
function FlashChatBridge_user_main()
{
    // perform permission check
    if (!SecurityUtil::checkPermission('FlashChatBridge::', '::', ACCESS_READ)) {
        return LogUtil::registerPermissionError();
    }
    $render =& pnRender::getInstance('FlashChatBridge', false);
    $UserVars = pnUserGetVars(SessionUtil::getVar('uid'));
    $Users = pnModAPIFunc('FlashChatBridge', 'user', 'getChatterList');
    $count = count($Users);
    $settings = pnModGetVar('FlashChatBridge');
    $settings['init_user'] = $UserVars['uname'];
    $settings['init_password'] = $UserVars['pass'];
    if ($settings['autosize'] == 1) {
        $settings['width'] = "100%";
        $settings['height'] = "100%";
    }
    $render->assign('settings', $settings);
    $render->assign('Users', $Users);
    $render->assign('Count', $count);
    return $render->fetch('flashchatbridge_user_main.htm');
}
function smarty_function_mediashare_templateSelector($params, &$smarty)
{
    $id = isset($params['id']) ? $params['id'] : 'album';
    $selectedTemplate = $smarty->get_template_vars($id);
    $name = isset($params['name']) ? $params['name'] : $id;
    $templates = pnModAPIFunc('mediashare', 'user', 'getAllTemplates');
    if ($templates === false) {
        $smarty->trigger_error(LogUtil::getErrorMessagesText());
        return false;
    }
    if (isset($params['onchange']) && $params['onchange']) {
        $onChangeHtml = ' onchange="' . $params['onchange'] . '"';
    } else {
        $onChangeHtml = '';
    }
    if (isset($params['readonly']) && $params['readonly']) {
        $readonlyHtml = ' disabled="disabled"';
    } else {
        $readonlyHtml = '';
    }
    if (isset($params['id']) && $params['id']) {
        $idHtml = " id=\"{$id}\"";
    } else {
        $idHtml = '';
    }
    $html = "<select name=\"{$name}\"{$onChangeHtml}{$idHtml}{$readonlyHtml}>\n";
    foreach ($templates as $template) {
        $title = DataUtil::formatForDisplay($template['title']);
        $value = $template['title'];
        $selectedHtml = strcasecmp($value, $selectedTemplate) == 0 ? ' selected="selected"' : '';
        $html .= "<option value=\"{$value}\"{$selectedHtml}>{$title}</option>\n";
    }
    $html .= "</select>";
    if (isset($params['assign'])) {
        $smarty->assign($params['assign'], $html);
    }
    return $html;
}
Exemple #18
0
function mediashare_searchapi_search($args)
{
    $dom = ZLanguage::getModuleDomain('mediashare');
    pnModDBInfoLoad('mediashare');
    pnModDBInfoLoad('Search');
    $pntable = pnDBGetTables();
    $mediaTable = $pntable['mediashare_media'];
    $mediaColumn = $pntable['mediashare_media_column'];
    $albumsTable = $pntable['mediashare_albums'];
    $albumsColumn = $pntable['mediashare_albums_column'];
    $searchTable = $pntable['search_result'];
    $searchColumn = $pntable['search_result_column'];
    $sessionId = session_id();
    // Find accessible albums
    $accessibleAlbumSql = pnModAPIFunc('mediashare', 'user', 'getAccessibleAlbumsSql', array('access' => mediashareAccessRequirementViewSomething, 'field' => "media.{$mediaColumn['parentAlbumId']}"));
    $albumText = __('Multimedia file in album: ', $dom);
    $sql = "\nINSERT INTO {$searchTable}\n  ({$searchColumn['title']},\n   {$searchColumn['text']},\n   {$searchColumn['module']},\n   {$searchColumn['extra']},\n   {$searchColumn['created']},\n   {$searchColumn['session']})\nSELECT CONCAT(media.{$mediaColumn['title']}, ' [{$albumText}', album.{$albumsColumn['title']}, ']'),\n       media.{$mediaColumn['description']},\n       'mediashare',\n       CONCAT(album.{$albumsColumn['id']}, ':', media.{$mediaColumn['id']}),\n       media.{$mediaColumn['createdDate']},\n       '{$sessionId}'\nFROM {$mediaTable} media\nINNER JOIN {$albumsTable} album\n      ON album.{$albumsColumn['id']} = media.{$mediaColumn['parentAlbumId']}\nWHERE ({$accessibleAlbumSql}) AND ";
    $sql .= search_construct_where($args, array("media.{$mediaColumn['title']}", "media.{$mediaColumn['description']}", "media.{$mediaColumn['keywords']}"));
    $dbresult = DBUtil::executeSQL($sql);
    if (!$dbresult) {
        return LogUtil::registerError(__('Error! Could not load items.', $dom));
    }
    return true;
}
function smarty_function_mediashare_itemSelector($params, &$smarty)
{
    $dom = ZLanguage::getModuleDomain('mediashare');
    if (!isset($params['albumId'])) {
        $smarty->trigger_error(__f('Missing [%1$s] in \'%2$s\'', array('albumId', 'mediashare_albumSelector'), $dom));
        return false;
    }
    $albumId = $params['albumId'];
    $mediaId = $params['mediaId'];
    $items = pnModAPIFunc('mediashare', 'user', 'getMediaItems', array('albumId' => $albumId));
    if ($items === false) {
        return false;
    }
    if ($mediaId == 0 && count($items) > 0 && isset($params['fetchSelectedInto'])) {
        $mediaId = $items[0]['id'];
        $mediaItem = pnModAPIFunc('mediashare', 'user', 'getMediaItem', array('mediaId' => $mediaId));
        $smarty->assign($params['fetchSelectedInto'], $mediaItem);
    }
    if (isset($params['onchange'])) {
        $onChangeHtml = " onchange=\"{$params['onchange']}\"";
    } else {
        $onChangeHtml = '';
    }
    $html = "<select name=\"mid\"{$onChangeHtml}>\n";
    foreach ($items as $item) {
        $title = $item['title'];
        $id = (int) $item['id'];
        $selectedHtml = $id == $mediaId ? ' selected="selected"' : '';
        $html .= "<option value=\"{$id}\"{$selectedHtml}>{$title}</option>\n";
    }
    $html .= "</select>";
    if (isset($params['assign'])) {
        $smarty->assign($params['assign'], $html);
    }
    return $html;
}
 function decode(&$render)
 {
     $dom = ZLanguage::getModuleDomain('mediashare');
     $this->clearValidation($render);
     $value = FormUtil::getPassedValue($this->inputName, null, 'POST');
     $albumId = FormUtil::getPassedValue("{$this->inputName}_album", null, 'POST');
     $newAlbum = FormUtil::getPassedValue("{$this->inputName}_newalbum", null, 'POST');
     if (!empty($newAlbum)) {
         if (mediashareAccessAlbum($albumId, mediashareAccessRequirementAddAlbum, '')) {
             $newAlbumID = pnModAPIFunc('mediashare', 'edit', 'addAlbum', array('title' => $newAlbum, 'keywords' => '', 'summary' => '', 'description' => '', 'template' => null, 'parentAlbumId' => $albumId));
             if ($newAlbumID === false) {
                 $this->setError(LogUtil::getErrorMessagesText());
             } else {
                 $albumId = $newAlbumID;
             }
         } else {
             $this->setError(__('You do not have access to this feature', $dom));
         }
     }
     $file = isset($_FILES["{$this->inputName}_upload"]) ? $_FILES["{$this->inputName}_upload"] : null;
     if (!empty($file) && $file['error'] == 0) {
         if (mediashareAccessAlbum($albumId, mediashareAccessRequirementAddMedia, '')) {
             $result = pnModAPIFunc('mediashare', 'source_browser', 'addMediaItem', array('albumId' => $albumId, 'uploadFilename' => $file['tmp_name'], 'fileSize' => $file['size'], 'filename' => $file['name'], 'mimeType' => $file['type'], 'title' => null, 'keywords' => null, 'description' => null, 'width' => 0, 'height' => 0));
             if ($result === false) {
                 $this->setError(LogUtil::getErrorMessagesText());
             } else {
                 $value = $result['mediaId'];
             }
         } else {
             $this->setError(__('You do not have access to this feature', $dom));
         }
     }
     $this->selectedItemId = $value;
 }
// ----------------------------------------------------------------------
// LICENSE
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// To read the license please visit http://www.gnu.org/copyleft/gpl.html
// ----------------------------------------------------------------------
// Original Author of file: Gregor J. Rothfuss
// Purpose of file: XML-RPC server for postnuke
// ----------------------------------------------------------------------
include 'includes/pnAPI.php';
pnInit();
// Load user API for xmlrpc module
if (!pnModAPILoad('xmlrpc', 'user')) {
    die('Could not load xmlrpc module');
}
/* create an instance of an xmlrpc server and define the apis we export
   and the mapping to the functions.
 */
$server = pnModAPIFunc('xmlrpc', 'user', 'initServer');
if (!$server) {
    die('Could not load server');
}
Exemple #22
0
function mediashareSourceZipUpdate()
{
    if (!SecurityUtil::confirmAuthKey()) {
        return LogUtil::registerAuthidError();
    }
    $mediaIds = FormUtil::getPassedValue('mediaId');
    foreach ($mediaIds as $mediaId) {
        $mediaId = (int) $mediaId;
        $title = FormUtil::getPassedValue("title-{$mediaId}");
        $keywords = FormUtil::getPassedValue("keywords-{$mediaId}");
        $description = FormUtil::getPassedValue("description-{$mediaId}");
        // Check access
        if (!mediashareAccessItem($mediaId, mediashareAccessRequirementEditMedia, '')) {
            return LogUtil::registerPermissionError();
        }
        $args = array('mediaId' => $mediaId, 'title' => $title, 'keywords' => $keywords, 'description' => $description);
        if (!pnModAPIFunc('mediashare', 'edit', 'updateItem', $args)) {
            return false;
        }
    }
    return true;
}
Exemple #23
0
function mediashare_mediahandlerapi_scanMediaHandlers()
{
    // Check access
    if (!SecurityUtil::checkPermission('mediashare::', '::', ACCESS_ADMIN)) {
        return LogUtil::registerPermissionError();
    }
    $dom = ZLanguage::getModuleDomain('mediashare');
    // Clear existing handler table
    if (!DBUtil::truncateTable('mediashare_mediahandlers')) {
        return LogUtil::registerError(__f('Error in %1$s: %2$s.', array('mediahandlerapi.scanMediaHandlers', __f("Could not clear the '%s' table.", 'mediahandlers', $dom)), $dom));
    }
    // Scan for handlers APIs
    $files = FileUtil::getFiles('modules/mediashare', false, true, 'php', 'f');
    foreach ($files as $file) {
        if (preg_match('/^pnmedia_([-a-zA-Z0-9_]+)api.php$/', $file, $matches)) {
            $handlerName = $matches[1];
            $handlerApi = "media_{$handlerName}";
            // Force load - it is used during pninit
            pnModAPILoad('mediashare', $handlerApi, true);
            if (!($handler = pnModAPIFunc('mediashare', $handlerApi, 'buildHandler'))) {
                return false;
            }
            $fileTypes = $handler->getMediaTypes();
            foreach ($fileTypes as $fileType) {
                $fileType['handler'] = $handlerName;
                $fileType['title'] = $handler->getTitle();
                if (!pnModAPIFunc('mediashare', 'mediahandler', 'addMediaHandler', $fileType)) {
                    return false;
                }
            }
        }
    }
    return true;
}
Exemple #24
0
function mediashare_randomblock_display($blockinfo)
{
    // Security check
    if (!SecurityUtil::checkPermission('mediashare:randomblock:', "{$blockinfo['title']}::{$blockinfo['bid']}", ACCESS_READ)) {
        return;
    }
    $dom = ZLanguage::getModuleDomain('mediashare');
    // Get variables from content block
    $vars = pnBlockVarsFromContent($blockinfo['content']);
    $sessionVarName = 'mediashare_block_' . $blockinfo['bid'];
    $sessionVars = SessionUtil::getVar($sessionVarName);
    if ($sessionVars == '' || $sessionVars == null) {
        $sessionVars = array();
    }
    if (isset($sessionVars['oldContent']) && isset($sessionVars['lastUpdate'])) {
        $past = time() - $sessionVars['lastUpdate'];
        if ($past < $vars['cacheTime']) {
            // No need to refresh - move old content into real content
            $blockinfo['content'] = $sessionVars['oldContent'];
            return themesideblock($blockinfo);
        }
    }
    if ($vars['type'] == 'album') {
        $randomInfo = pnModAPIFunc('mediashare', 'user', 'getRandomMediaItem', array('albumId' => $vars['albumId'], 'mode' => 'album'));
    } else {
        if ($vars['type'] == 'latest') {
            $randomInfo = pnModAPIFunc('mediashare', 'user', 'getRandomMediaItem', array('latest' => true, 'mode' => 'latest'));
        } else {
            $randomInfo = pnModAPIFunc('mediashare', 'user', 'getRandomMediaItem');
        }
    }
    if ($randomInfo === false) {
        return false;
    }
    $mediaId = $randomInfo['mediaId'];
    $albumId = $randomInfo['albumId'];
    if (empty($mediaId)) {
        return;
    }
    // Get image info
    $mediaInfo = pnModAPIFunc('mediashare', 'user', 'getMediaItem', array('mediaId' => $mediaId));
    // Get album info
    $albumInfo = pnModAPIFunc('mediashare', 'user', 'getAlbum', array('albumId' => $albumId));
    $originalURL = pnModAPIFunc('mediashare', 'user', 'getMediaUrl', array('mediaItem' => $mediaInfo, 'src' => 'originalRef'));
    $previewURL = pnModAPIFunc('mediashare', 'user', 'getMediaUrl', array('mediaItem' => $mediaInfo, 'src' => 'previewRef'));
    $thumbnailURL = pnModAPIFunc('mediashare', 'user', 'getMediaUrl', array('mediaItem' => $mediaInfo, 'src' => 'thumbnailRef'));
    $albumURL = pnModUrl('mediashare', 'user', 'view', array('aid' => $albumId, 'mid' => $mediaId));
    // Create the final HTML by substituting various macros into the user specified HTML code
    $substitutes = array('originalURL' => $originalURL, 'previewURL' => $previewURL, 'thumbnailURL' => $thumbnailURL, 'albumURL' => $albumURL, 'title' => $mediaInfo['title'], 'owner' => __('Unknown', $dom), 'albumTitle' => $albumInfo['title']);
    $html = $vars['html'];
    foreach ($substitutes as $key => $value) {
        $pattern = '${' . $key . '}';
        $html = str_replace($pattern, $value, $html);
    }
    $blockinfo['content'] = $html;
    $sessionVars['oldContent'] = $html;
    $sessionVars['lastUpdate'] = time();
    SessionUtil::setVar($sessionVarName, $sessionVars);
    // ... and return encapsulated in a theme block
    return themesideblock($blockinfo);
}
Exemple #25
0
function checkCategoryLimits($eventdata)
{
    extract($eventdata);
    //print_r($eventdata);
    //print "$event_starttimeh:$event_starttimem";
    $limits =& pnModAPIFunc(__POSTCALENDAR__, 'user', 'getCategoryLimits');
    //print_r($limits);
    foreach ($limits as $limit) {
        if ($limit['catid'] == $event_category) {
            //print_r($limit);
            $sdate = $event_startmonth . '/' . $event_startday . '/' . $event_startyear;
            $edate = $sdate;
            $stime = date("H:i:00", strtotime($limit['startTime']));
            $etime = date("H:i:00", strtotime($limit['endTime']));
            if ($is_update) {
                $searchText = "a.pc_eid != '{$pc_event_id}' AND ";
            }
            //echo "stime is: $stime, etime is: $etime sdate is: $sdate edate is: $edate<br />";
            $a = array('s_category' => " a.pc_catid = {$event_category}", 'start' => $edate, 'end' => $sdate, 'stime' => $stime, 'etime' => $etime, 'providerID' => $event_userid, 's_keywords' => $searchText . "a.pc_starttime >= '{$stime}' AND a.pc_endtime <= '{$etime}'");
            $eventsByDate =& postcalendar_userapi_pcGetEvents($a);
            //print_r($eventsByDate);
            $ret = null;
            foreach ($eventsByDate as $day) {
                //if event time falls within limit time check
                //hour from forms is 12 not 24 format, convert here
                if ($event_startampm == 2 && $event_starttimeh != 12) {
                    $event_starttimeh += 12;
                } elseif ($event_startampm == 1 && $event_starttimeh == 12) {
                    $event_starttimeh -= 12;
                }
                $event_starttime = date("H:i:00", strtotime($event_starttimeh . ":" . $event_starttimem . ":" . "00"));
                $event_endtime = date("H:i:00", strtotime($event_endtimeh . ":" . $event_endtimem . ":" . "00"));
                if ($event_starttime >= $limit['startTime']) {
                    $numToday = count($day);
                    if ($numToday >= $limit['limit']) {
                        //reached limit
                        $ret = array("start" => $limit['startTime'], "end" => $limit['endTime'], "limit" => $limit['limit']);
                        return $ret;
                    }
                }
                //if in limit time span
            }
        }
    }
    return null;
}
Exemple #26
0
/**
 *    postcalendar_userapi_buildSubmitForm()
 *    create event submit form
 */
function postcalendar_userapi_buildSubmitForm($args, $admin = false)
{
    $_SESSION['category'] = "";
    if (!PC_ACCESS_ADD) {
        return _POSTCALENDARNOAUTH;
    }
    extract($args);
    unset($args);
    //since we seem to clobber category
    $cat = $category;
    $output = new pnHTML();
    $output->SetInputMode(_PNH_VERBATIMINPUT);
    // set up Smarty
    $tpl = new pcSmarty();
    $tpl->caching = false;
    $template_name = pnModGetVar(__POSTCALENDAR__, 'pcTemplate');
    if (!isset($template_name)) {
        $template_name = 'default';
    }
    //=================================================================
    //  Setup the correct config file path for the templates
    //=================================================================
    $modinfo = pnModGetInfo(pnModGetIDFromName(__POSTCALENDAR__));
    $modir = pnVarPrepForOS($modinfo['directory']);
    $modname = $modinfo['displayname'];
    $all_categories =& pnModAPIFunc(__POSTCALENDAR__, 'user', 'getCategories');
    //print_r($all_categories);
    unset($modinfo);
    $tpl->config_dir = "modules/{$modir}/pntemplates/{$template_name}/config/";
    //=================================================================
    //  PARSE MAIN
    //=================================================================
    $tpl->assign('webroot', $GLOBALS['web_root']);
    $tpl->assign_by_ref('TPL_NAME', $template_name);
    $tpl->assign('FUNCTION', pnVarCleanFromInput('func'));
    $tpl->assign_by_ref('ModuleName', $modname);
    $tpl->assign_by_ref('ModuleDirectory', $modir);
    $tpl->assign_by_ref('category', $all_categories);
    $tpl->assign('NewEventHeader', _PC_NEW_EVENT_HEADER);
    $tpl->assign('EventTitle', _PC_EVENT_TITLE);
    $tpl->assign('Required', _PC_REQUIRED);
    $tpl->assign('DateTimeTitle', _PC_DATE_TIME);
    $tpl->assign('AlldayEventTitle', _PC_ALLDAY_EVENT);
    $tpl->assign('TimedEventTitle', _PC_TIMED_EVENT);
    $tpl->assign('TimedDurationTitle', _PC_TIMED_DURATION);
    $tpl->assign('TimedDurationHoursTitle', _PC_TIMED_DURATION_HOURS);
    $tpl->assign('TimedDurationMinutesTitle', _PC_TIMED_DURATION_MINUTES);
    $tpl->assign('EventDescTitle', _PC_EVENT_DESC);
    //the double book variable comes from the eventdata array that is
    //passed here and extracted, injection is not an issue here
    if (is_numeric($double_book)) {
        $tpl->assign('double_book', $double_book);
    }
    //pennfirm begin patient info handling
    $ProviderID = pnVarCleanFromInput("provider_id");
    if (is_numeric($ProviderID)) {
        $tpl->assign('ProviderID', $ProviderID);
        $tpl->assign('provider_id', $ProviderID);
    } elseif (is_numeric($event_userid) && $event_userid != 0) {
        $tpl->assign('ProviderID', $event_userid);
        $tpl->assign('provider_id', $event_userid);
    } else {
        if ($_SESSION['userauthorized'] == 1) {
            $tpl->assign('ProviderID', $_SESSION['authUserID']);
        } else {
            $tpl->assign('ProviderID', "");
        }
    }
    $provinfo = getProviderInfo();
    $tpl->assign('providers', $provinfo);
    $PatientID = pnVarCleanFromInput("patient_id");
    // limit the number of results returned by getPatientPID
    // this helps to prevent the server from stalling on a request with
    // no PID and thousands of PIDs in the database -- JRM
    // the function getPatientPID($pid, $given, $orderby, $limit, $start) <-- defined in library/patient.inc
    $plistlimit = 500;
    if (is_numeric($PatientID)) {
        $tpl->assign('PatientList', getPatientPID(array('pid' => $PatientID, 'limit' => $plistlimit)));
    } elseif (is_numeric($event_pid)) {
        $tpl->assign('PatientList', getPatientPID(array('pid' => $event_pid, 'limit' => $plistlimit)));
    } else {
        $tpl->assign('PatientList', getPatientPID(array('limit' => $plistlimit)));
    }
    $tpl->assign('event_pid', $event_pid);
    $tpl->assign('event_aid', $event_aid);
    $tpl->assign('event_category', pnVarCleanFromInput("event_category"));
    if (empty($event_patient_name)) {
        $patient_data = getPatientData($event_pid, $given = "lname, fname");
        $event_patient_name = $patient_data['lname'] . ", " . $patient_data['fname'];
    }
    $tpl->assign('patient_value', $event_patient_name);
    //=================================================================
    //  PARSE INPUT_EVENT_TITLE
    //=================================================================
    $tpl->assign('InputEventTitle', 'event_subject');
    $tpl->assign('ValueEventTitle', pnVarPrepForDisplay($event_subject));
    //=================================================================
    //  PARSE SELECT_DATE_TIME
    //=================================================================
    // It seems that with Mozilla at least, <select> fields that are disabled
    // do not get passed as form data.  Therefore we ignore $double_book so
    // that the fields will not be disabled.  -- Rod 2005-03-22
    $output->SetOutputMode(_PNH_RETURNOUTPUT);
    if (_SETTING_USE_INT_DATES) {
        $sel_data = pnModAPIFunc(__POSTCALENDAR__, 'user', 'buildDaySelect', array('pc_day' => $day, 'selected' => $event_startday));
        $formdata = $output->FormSelectMultiple('event_startday', $sel_data, 0, 1, "", "", false, '');
        $sel_data = pnModAPIFunc(__POSTCALENDAR__, 'user', 'buildMonthSelect', array('pc_month' => $month, 'selected' => $event_startmonth));
        $formdata .= $output->FormSelectMultiple('event_startmonth', $sel_data, 0, 1, "", "", false, '');
    } else {
        $sel_data = pnModAPIFunc(__POSTCALENDAR__, 'user', 'buildMonthSelect', array('pc_month' => $month, 'selected' => $event_startmonth));
        $formdata = $output->FormSelectMultiple('event_startmonth', $sel_data, 0, 1, "", "", false, '');
        $sel_data = pnModAPIFunc(__POSTCALENDAR__, 'user', 'buildDaySelect', array('pc_day' => $day, 'selected' => $event_startday));
        $formdata .= $output->FormSelectMultiple('event_startday', $sel_data, 0, 1, "", "", false, '');
    }
    $sel_data = pnModAPIFunc(__POSTCALENDAR__, 'user', 'buildYearSelect', array('pc_year' => $year, 'selected' => $event_startyear));
    $formdata .= $output->FormSelectMultiple('event_startyear', $sel_data, 0, 1, "", "", false, '');
    $output->SetOutputMode(_PNH_KEEPOUTPUT);
    $tpl->assign('SelectDateTime', $formdata);
    $tpl->assign('InputAllday', 'event_allday');
    $tpl->assign('ValueAllday', '1');
    $tpl->assign('SelectedAllday', $event_allday == 1 ? 'checked' : '');
    $tpl->assign('InputTimed', 'event_allday');
    $tpl->assign('ValueTimed', '0');
    $tpl->assign('SelectedTimed', $event_allday == 0 ? 'checked' : '');
    $tpl->assign('STYLE', $GLOBALS['style']);
    //=================================================================
    //  PARSE SELECT_END_DATE_TIME
    //=================================================================
    $output->SetOutputMode(_PNH_RETURNOUTPUT);
    //if there is no end date we want the box to read todays date instead of jan 01 1994 :)
    if ($event_endmonth == 0 && $event_endday == 0 && $event_endyear == 0) {
        $event_endmonth = $month;
        $event_endday = $day;
        $event_endyear = $year;
    }
    if (_SETTING_USE_INT_DATES) {
        $sel_data = pnModAPIFunc(__POSTCALENDAR__, 'user', 'buildDaySelect', array('pc_day' => $day, 'selected' => $event_endday));
        $formdata = $output->FormSelectMultiple('event_endday', $sel_data, 0, 1, "", "", false, '');
        $sel_data = pnModAPIFunc(__POSTCALENDAR__, 'user', 'buildMonthSelect', array('pc_month' => $month, 'selected' => $event_endmonth));
        $formdata .= $output->FormSelectMultiple('event_endmonth', $sel_data, 0, 1, "", "", false, '');
    } else {
        $sel_data = pnModAPIFunc(__POSTCALENDAR__, 'user', 'buildMonthSelect', array('pc_month' => $month, 'selected' => $event_endmonth));
        $formdata = $output->FormSelectMultiple('event_endmonth', $sel_data, 0, 1, "", "", false, '');
        $sel_data = pnModAPIFunc(__POSTCALENDAR__, 'user', 'buildDaySelect', array('pc_day' => $day, 'selected' => $event_endday));
        $formdata .= $output->FormSelectMultiple('event_endday', $sel_data, 0, 1, "", "", false, '');
    }
    $sel_data = pnModAPIFunc(__POSTCALENDAR__, 'user', 'buildYearSelect', array('pc_year' => $year, 'selected' => $event_endyear));
    $formdata .= $output->FormSelectMultiple('event_endyear', $sel_data, 0, 1, "", "", false, '');
    $output->SetOutputMode(_PNH_KEEPOUTPUT);
    $tpl->assign('SelectEndDate', $formdata);
    //=================================================================
    //  PARSE SELECT_TIMED_EVENT
    //=================================================================
    $stimes = pnModAPIFunc(__POSTCALENDAR__, 'user', 'buildTimeSelect', array('hselected' => $event_starttimeh, 'mselected' => $event_starttimem));
    $output->SetOutputMode(_PNH_RETURNOUTPUT);
    $timed_hours = $output->FormSelectMultiple('event_starttimeh', $stimes['h'], 0, 1, "", "", false, '');
    $timed_minutes = $output->FormSelectMultiple('event_starttimem', $stimes['m'], 0, 1, "", "", false, '');
    if (!_SETTING_TIME_24HOUR) {
        $ampm = array();
        $ampm[0]['id'] = pnVarPrepForStore(_AM_VAL);
        $ampm[0]['name'] = pnVarPrepForDisplay(_PC_AM);
        $ampm[1]['id'] = pnVarPrepForStore(_PM_VAL);
        $ampm[1]['name'] = pnVarPrepForDisplay(_PC_PM);
        if ($event_startampm == "AM" || $event_startampm == _AM_VAL) {
            $ampm[0]['selected'] = 1;
        } else {
            $ampm[1]['selected'] = 1;
        }
        $timed_ampm = $output->FormSelectMultiple('event_startampm', $ampm, 0, 1, "", "", false, '');
    } else {
        $timed_ampm = '';
    }
    $output->SetOutputMode(_PNH_KEEPOUTPUT);
    $tpl->assign('SelectTimedHours', $timed_hours);
    $tpl->assign('SelectTimedMinutes', $timed_minutes);
    $tpl->assign('SelectTimedAMPM', $timed_ampm);
    $tpl->assign('event_startday', $event_startday);
    $tpl->assign('event_startmonth', $event_startmonth);
    $tpl->assign('event_startyear', $event_startyear);
    $tpl->assign('event_starttimeh', $event_starttimeh);
    $tpl->assign('event_starttimem', $event_starttimem);
    $tpl->assign('event_startampm', $event_startampm);
    $tpl->assign('event_dur_hours', $event_dur_hours);
    $tpl->assign('event_dur_minutes', $event_dur_minutes);
    //=================================================================
    //  PARSE SELECT_DURATION
    //=================================================================
    $event_dur_hours = (int) $event_dur_hours;
    for ($i = 0; $i <= 24; $i += 1) {
        $TimedDurationHours[$i] = array('value' => $i, 'selected' => $event_dur_hours == $i ? 'selected' : '', 'name' => sprintf('%02d', $i));
    }
    $tpl->assign('TimedDurationHours', $TimedDurationHours);
    $tpl->assign('InputTimedDurationHours', 'event_dur_hours');
    $found_time = false;
    for ($i = 0; $i < 60; $i += _SETTING_TIME_INCREMENT) {
        $TimedDurationMinutes[$i] = array('value' => $i, 'selected' => $event_dur_minutes == $i ? 'selected' : '', 'name' => sprintf('%02d', $i));
        if ($TimedDurationMinutes[$i]['selected'] == 'selected') {
            $found_time = true;
        }
    }
    if (!$found_time) {
        $TimedDurationMinutes[$i] = array('value' => $event_dur_minutes, 'selected' => 'selected', 'name' => sprintf('%02d', $event_dur_minutes));
    }
    $tpl->assign('TimedDurationMinutes', $TimedDurationMinutes);
    $tpl->assign('hidden_event_dur_minutes', $event_dur_minutes);
    $tpl->assign('InputTimedDurationMinutes', 'event_dur_minutes');
    //=================================================================
    //  PARSE INPUT_EVENT_DESC
    //=================================================================
    $tpl->assign('InputEventDesc', 'event_desc');
    if (empty($pc_html_or_text)) {
        $display_type = substr($event_desc, 0, 6);
        if ($display_type == ':text:') {
            $pc_html_or_text = 'text';
            $event_desc = substr($event_desc, 6);
        } elseif ($display_type == ':html:') {
            $pc_html_or_text = 'html';
            $event_desc = substr($event_desc, 6);
        } else {
            $pc_html_or_text = 'text';
        }
        unset($display_type);
    }
    $tpl->assign('ValueEventDesc', pnVarPrepForDisplay($event_desc));
    $eventHTMLorText = "<select name=\"pc_html_or_text\">";
    if ($pc_html_or_text == 'text') {
        $eventHTMLorText .= "<option value=\"text\" selected=\"selected\">" . _PC_SUBMIT_TEXT . "</option>";
    } else {
        $eventHTMLorText .= "<option value=\"text\">" . _PC_SUBMIT_TEXT . "</option>";
    }
    if ($pc_html_or_text == 'html') {
        $eventHTMLorText .= "<option value=\"html\" selected=\"selected\">" . _PC_SUBMIT_HTML . "</option>";
    } else {
        $eventHTMLorText .= "<option value=\"html\">" . _PC_SUBMIT_HTML . "</option>";
    }
    $eventHTMLorText .= "</select>";
    $tpl->assign('EventHTMLorText', $eventHTMLorText);
    //=================================================================
    //  PARSE select_event_topic_block
    //=================================================================
    $tpl->assign('displayTopics', _SETTING_DISPLAY_TOPICS);
    if ((bool) _SETTING_DISPLAY_TOPICS) {
        $a_topics =& postcalendar_userapi_getTopics();
        $topics = array();
        foreach ($a_topics as $topic) {
            array_push($topics, array('value' => $topic['id'], 'selected' => $topic['id'] == $event_topic ? 'selected' : '', 'name' => $topic['text']));
        }
        unset($a_topics);
        // only show this if we have topics to show
        if (count($topics) > 0) {
            $tpl->assign('topics', $topics);
            $tpl->assign('EventTopicTitle', _PC_EVENT_TOPIC);
            $tpl->assign('InputEventTopic', 'event_topic');
        }
    }
    //=================================================================
    //  PARSE select_event_type_block
    //=================================================================
    $categories = array();
    foreach ($all_categories as $category) {
        array_push($categories, array('value' => $category['id'], 'selected' => $category['id'] == $event_category ? 'selected' : '', 'name' => $category['name'], 'color' => $category['color'], 'desc' => $category['desc']));
    }
    // only show this if we have categories to show
    // you should ALWAYS have at least one valid category
    if (count($categories) > 0) {
        $tpl->assign('categories', $categories);
        $tpl->assign('EventCategoriesTitle', _PC_EVENT_CATEGORY);
        $tpl->assign('InputEventCategory', 'event_category');
        $tpl->assign('hidden_event_category', $event_category);
    }
    //=================================================================
    //  PARSE event_sharing_block
    //=================================================================
    $data = array();
    if (_SETTING_ALLOW_USER_CAL) {
        array_push($data, array(SHARING_PRIVATE, _PC_SHARE_PRIVATE));
        array_push($data, array(SHARING_PUBLIC, _PC_SHARE_PUBLIC));
        array_push($data, array(SHARING_BUSY, _PC_SHARE_SHOWBUSY));
    }
    if (pnSecAuthAction(0, 'PostCalendar::', '::', ACCESS_ADMIN) || _SETTING_ALLOW_GLOBAL || !_SETTING_ALLOW_USER_CAL) {
        array_push($data, array(SHARING_GLOBAL, _PC_SHARE_GLOBAL));
    }
    $sharing = array();
    foreach ($data as $cell) {
        array_push($sharing, array('value' => $cell[0], 'selected' => (int) $event_sharing == $cell[0] ? 'selected' : '', 'name' => $cell[1]));
    }
    //pennfirm get list of providers from openemr code in calendar.inc
    $tpl->assign("user", getCalendarProviderInfo());
    $tpl->assign('sharing', $sharing);
    $tpl->assign('EventSharingTitle', _PC_SHARING);
    $tpl->assign('InputEventSharing', 'event_sharing');
    //=================================================================
    //  location information
    //=================================================================
    $tpl->assign('EventLocationTitle', _PC_EVENT_LOCATION);
    $tpl->assign('InputLocation', 'event_location');
    $tpl->assign('ValueLocation', pnVarPrepForDisplay($event_location));
    $tpl->assign('EventStreetTitle', _PC_EVENT_STREET);
    $tpl->assign('InputStreet1', 'event_street1');
    $tpl->assign('ValueStreet1', pnVarPrepForDisplay($event_street1));
    $tpl->assign('InputStreet2', 'event_street2');
    $tpl->assign('ValueStreet2', pnVarPrepForDisplay($event_street2));
    $tpl->assign('EventCityTitle', _PC_EVENT_CITY);
    $tpl->assign('InputCity', 'event_city');
    $tpl->assign('ValueCity', pnVarPrepForDisplay($event_city));
    $tpl->assign('EventStateTitle', _PC_EVENT_STATE);
    $tpl->assign('InputState', 'event_state');
    $tpl->assign('ValueState', pnVarPrepForDisplay($event_state));
    $tpl->assign('EventPostalTitle', _PC_EVENT_POSTAL);
    $tpl->assign('InputPostal', 'event_postal');
    $tpl->assign('ValuePostal', pnVarPrepForDisplay($event_postal));
    //=================================================================
    //  contact information
    //=================================================================
    $tpl->assign('EventContactTitle', _PC_EVENT_CONTACT);
    $tpl->assign('InputContact', 'event_contname');
    $tpl->assign('ValueContact', pnVarPrepForDisplay($event_contname));
    $tpl->assign('EventPhoneTitle', _PC_EVENT_PHONE);
    $tpl->assign('InputPhone', 'event_conttel');
    $tpl->assign('ValuePhone', pnVarPrepForDisplay($event_conttel));
    $tpl->assign('EventEmailTitle', _PC_EVENT_EMAIL);
    $tpl->assign('InputEmail', 'event_contemail');
    $tpl->assign('ValueEmail', pnVarPrepForDisplay($event_contemail));
    $tpl->assign('EventWebsiteTitle', _PC_EVENT_WEBSITE);
    $tpl->assign('InputWebsite', 'event_website');
    $tpl->assign('ValueWebsite', pnVarPrepForDisplay($event_website));
    $tpl->assign('EventFeeTitle', _PC_EVENT_FEE);
    $tpl->assign('InputFee', 'event_fee');
    $tpl->assign('ValueFee', pnVarPrepForDisplay($event_fee));
    //=================================================================
    //  Repeating Information
    //=================================================================
    $tpl->assign('RepeatingHeader', _PC_REPEATING_HEADER);
    $tpl->assign('NoRepeatTitle', _PC_NO_REPEAT);
    $tpl->assign('RepeatTitle', _PC_REPEAT);
    $tpl->assign('RepeatOnTitle', _PC_REPEAT_ON);
    $tpl->assign('OfTheMonthTitle', _PC_OF_THE_MONTH);
    $tpl->assign('EndDateTitle', _PC_END_DATE);
    $tpl->assign('NoEndDateTitle', _PC_NO_END);
    $tpl->assign('InputNoRepeat', 'event_repeat');
    $tpl->assign('ValueNoRepeat', '0');
    $tpl->assign('SelectedNoRepeat', (int) $event_repeat == 0 ? 'checked' : '');
    $tpl->assign('InputRepeat', 'event_repeat');
    $tpl->assign('ValueRepeat', '1');
    $tpl->assign('SelectedRepeat', (int) $event_repeat == 1 ? 'checked' : '');
    unset($in);
    $in = array(_PC_EVERY, _PC_EVERY_OTHER, _PC_EVERY_THIRD, _PC_EVERY_FOURTH);
    $keys = array(REPEAT_EVERY, REPEAT_EVERY_OTHER, REPEAT_EVERY_THIRD, REPEAT_EVERY_FOURTH);
    $repeat_freq = array();
    foreach ($in as $k => $v) {
        array_push($repeat_freq, array('value' => $keys[$k], 'selected' => $keys[$k] == $event_repeat_freq ? 'selected' : '', 'name' => $v));
    }
    $tpl->assign('InputRepeatFreq', 'event_repeat_freq');
    if (empty($event_repeat_freq) || $event_repeat_freq < 1) {
        $event_repeat_freq = 1;
    }
    $tpl->assign('InputRepeatFreqVal', $event_repeat_freq);
    $tpl->assign('repeat_freq', $repeat_freq);
    unset($in);
    $in = array(_PC_EVERY_DAY, _PC_EVERY_WORKDAY, _PC_EVERY_WEEK, _PC_EVERY_MONTH, _PC_EVERY_YEAR);
    $keys = array(REPEAT_EVERY_DAY, REPEAT_EVERY_WORK_DAY, REPEAT_EVERY_WEEK, REPEAT_EVERY_MONTH, REPEAT_EVERY_YEAR);
    $repeat_freq_type = array();
    foreach ($in as $k => $v) {
        array_push($repeat_freq_type, array('value' => $keys[$k], 'selected' => $keys[$k] == $event_repeat_freq_type ? 'selected' : '', 'name' => $v));
    }
    $tpl->assign('InputRepeatFreqType', 'event_repeat_freq_type');
    $tpl->assign('repeat_freq_type', $repeat_freq_type);
    $tpl->assign('InputRepeatOn', 'event_repeat');
    $tpl->assign('ValueRepeatOn', '2');
    $tpl->assign('SelectedRepeatOn', (int) $event_repeat == 2 ? 'checked' : '');
    unset($in);
    $in = array(_PC_EVERY_1ST, _PC_EVERY_2ND, _PC_EVERY_3RD, _PC_EVERY_4TH, _PC_EVERY_LAST);
    $keys = array(REPEAT_ON_1ST, REPEAT_ON_2ND, REPEAT_ON_3RD, REPEAT_ON_4TH, REPEAT_ON_LAST);
    $repeat_on_num = array();
    foreach ($in as $k => $v) {
        array_push($repeat_on_num, array('value' => $keys[$k], 'selected' => $keys[$k] == $event_repeat_on_num ? 'selected' : '', 'name' => $v));
    }
    $tpl->assign('InputRepeatOnNum', 'event_repeat_on_num');
    $tpl->assign('repeat_on_num', $repeat_on_num);
    unset($in);
    $in = array(_PC_EVERY_SUN, _PC_EVERY_MON, _PC_EVERY_TUE, _PC_EVERY_WED, _PC_EVERY_THU, _PC_EVERY_FRI, _PC_EVERY_SAT);
    $keys = array(REPEAT_ON_SUN, REPEAT_ON_MON, REPEAT_ON_TUE, REPEAT_ON_WED, REPEAT_ON_THU, REPEAT_ON_FRI, REPEAT_ON_SAT);
    $repeat_on_day = array();
    foreach ($in as $k => $v) {
        array_push($repeat_on_day, array('value' => $keys[$k], 'selected' => $keys[$k] == $event_repeat_on_day ? 'selected' : '', 'name' => $v));
    }
    $tpl->assign('InputRepeatOnDay', 'event_repeat_on_day');
    $tpl->assign('repeat_on_day', $repeat_on_day);
    unset($in);
    $in = array(_PC_OF_EVERY_MONTH, _PC_OF_EVERY_2MONTH, _PC_OF_EVERY_3MONTH, _PC_OF_EVERY_4MONTH, _PC_OF_EVERY_6MONTH, _PC_OF_EVERY_YEAR);
    $keys = array(REPEAT_ON_MONTH, REPEAT_ON_2MONTH, REPEAT_ON_3MONTH, REPEAT_ON_4MONTH, REPEAT_ON_6MONTH, REPEAT_ON_YEAR);
    $repeat_on_freq = array();
    foreach ($in as $k => $v) {
        array_push($repeat_on_freq, array('value' => $keys[$k], 'selected' => $keys[$k] == $event_repeat_on_freq ? 'selected' : '', 'name' => $v));
    }
    $tpl->assign('InputRepeatOnFreq', 'event_repeat_on_freq');
    if (empty($event_repeat_on_freq) || $event_repeat_on_freq < 1) {
        $event_repeat_on_freq = 1;
    }
    $tpl->assign('InputRepeatOnFreqVal', $event_repeat_on_freq);
    $tpl->assign('repeat_on_freq', $repeat_on_freq);
    $tpl->assign('MonthsTitle', _PC_MONTHS);
    //=================================================================
    //  PARSE INPUT_END_DATE
    //=================================================================
    $tpl->assign('InputEndOn', 'event_endtype');
    $tpl->assign('ValueEndOn', '1');
    $tpl->assign('SelectedEndOn', (int) $event_endtype == 1 ? 'checked' : '');
    //=================================================================
    //  PARSE INPUT_NO_END
    //=================================================================
    $tpl->assign('InputNoEnd', 'event_endtype');
    $tpl->assign('ValueNoEnd', '0');
    $tpl->assign('SelectedNoEnd', (int) $event_endtype == 0 ? 'checked' : '');
    $qstring = preg_replace("/provider_id=[0-9]*[&]{0,1}/", "", $_SERVER['QUERY_STRING']);
    $tpl->assign('qstring', $qstring);
    $output->SetOutputMode(_PNH_RETURNOUTPUT);
    $authkey = $output->FormHidden('authid', pnSecGenAuthKey());
    $output->SetOutputMode(_PNH_KEEPOUTPUT);
    $form_hidden = "<input type=\"hidden\" name=\"is_update\" value=\"{$is_update}\" />";
    $form_hidden .= "<input type=\"hidden\" name=\"pc_event_id\" value=\"{$pc_event_id}\" />";
    $form_hidden .= "<input type=\"hidden\" name=\"category\" value=\"{$cat}\" />";
    if (isset($data_loaded)) {
        $form_hidden .= "<input type=\"hidden\" name=\"data_loaded\" value=\"{$data_loaded}\" />";
        $tpl->assign('FormHidden', $form_hidden);
    }
    $form_submit = '<input type=hidden name="form_action" value="commit"/>
                   ' . $authkey . '<input type="submit" name="submit" value="go">';
    $tpl->assign('FormSubmit', $form_submit);
    // do not cache this page
    if ($admin) {
        $output->Text($tpl->fetch($template_name . '/admin/submit.html'));
    } elseif (pnVarCleanFromInput("no_nav") == 1) {
        $output->Text($tpl->fetch($template_name . '/user/submit_no_nav.html'));
    } else {
        $output->Text($tpl->fetch($template_name . '/user/submit.html'));
    }
    $output->Text(postcalendar_footer());
    return $output->GetOutput();
}
Exemple #27
0
function postcalendar_admin_categoryLimitsUpdate()
{
    if (!PC_ACCESS_ADMIN) {
        return _POSTCALENDAR_NOAUTH;
    }
    $output = new pnHTML();
    $output->SetInputMode(_PNH_VERBATIMINPUT);
    list($dbconn) = pnDBGetConn();
    $pntable = pnDBGetTables();
    list($id, $del, $catId, $startTimeH, $startTimeM, $endTimeH, $endTimeM, $limit, $newCatId, $newStartTimeH, $newStartTimeM, $newEndTimeH, $newEndTimeM, $newLimit, ) = pnVarCleanFromInput('id', 'del', 'catid', 'starttimeh', 'starttimem', 'endtimeh', 'endtimem', 'limit', 'newcatid', 'newstarttimeh', 'newstarttimem', 'newendtimeh', 'newendtimem', 'newlimit');
    $updates = array();
    if (isset($id)) {
        foreach ($id as $k => $i) {
            $found = false;
            if (count($del)) {
                foreach ($del as $d) {
                    if ($i == $d) {
                        $found = true;
                        break;
                    }
                }
            }
            if (!$found) {
                $start = date("H:i:s", mktime($startTimeH[$k], $startTimeM[$k], 0));
                $end = date("H:i:s", mktime($endTimeH[$k], $endTimeM[$k], 0));
                $update_sql = "UPDATE {$pntable['postcalendar_limits']}\n\t\t                             SET pc_catid='" . pnVarPrepForStore($catId[$k]) . "',\n\t\t                                 pc_starttime='" . pnVarPrepForStore($start) . "',\n\t\t                                 pc_endtime='" . pnVarPrepForStore($end) . "',\n\t\t                                 pc_limit='" . pnVarPrepForStore($limit[$k]) . "'\n\t\t                             WHERE pc_limitid={$i}";
                array_push($updates, $update_sql);
            }
        }
    }
    $dels = implode(",", $del);
    $delete = "DELETE FROM {$pntable['postcalendar_limits']} WHERE pc_limitid IN ({$dels})";
    $e = $msg = '';
    if (!pnModAPIFunc(__POSTCALENDAR__, 'admin', 'updateCategoryLimit', array('updates' => $updates))) {
        $e .= 'UPDATE FAILED';
    }
    if (isset($dels)) {
        if (!pnModAPIFunc(__POSTCALENDAR__, 'admin', 'deleteCategoryLimit', array('delete' => $delete))) {
            $e .= 'DELETE FAILED';
        }
    }
    if (isset($newLimit) && $newLimit > 0) {
        $start = date("H:i:s", mktime($newStartTimeH, $newStartTimeM, 0));
        $end = date("H:i:s", mktime($newEndTimeH, $newEndTimeM, 0));
        if (!pnModAPIFunc(__POSTCALENDAR__, 'admin', 'addCategoryLimit', array('catid' => $newCatId, 'starttime' => $start, 'endtime' => $end, 'limit' => $newLimit))) {
            $e .= 'INSERT FAILED';
        }
    }
    if (empty($e)) {
        $msg = 'DONE';
    }
    $output->Text(postcalendar_admin_categoryLimits($msg, $e));
    return $output->GetOutput();
}
Exemple #28
0
function Lenses_admin_viewall_companies()
{
    // Permission check.
    if (!pnSecAuthAction(0, 'Lenses::', '::', ACCESS_ADMIN)) {
        return pnVarPrepHTMLDisplay(_MODULENOAUTH);
    }
    // Start a new output object.
    $pnRender =& new pnRender('Lenses');
    // Call API function to get all companies.
    $companies = pnModAPIFunc('Lenses', 'user', 'getall', array('item_type' => 'companies'));
    // Assign $companies to template.
    $pnRender->assign('companies', $companies);
    // Return templated output.
    return $pnRender->fetch('lenses_admin_viewall_companies.htm');
}
Exemple #29
0
function Meds_userapi_getall_selects()
{
    $selects = array();
    $selects['preserves'] = pnModAPIFunc('Meds', 'user', 'DBselect', array('from' => 'preserve'));
    $selects['companies'] = pnModAPIFunc('Meds', 'user', 'DBselect', array('from' => 'company'));
    $selects['chemicals'] = pnModAPIFunc('Meds', 'user', 'DBselect', array('from' => 'chem'));
    $selects['methods'] = pnModAPIFunc('Meds', 'user', 'DBselect', array('from' => 'moa'));
    $selects['medtypes'] = pnModAPIFunc('Meds', 'user', 'select_medtypes');
    $selects['medforms'] = pnModAPIFunc('Meds', 'user', 'select_medforms');
    $selects['pregclasses'] = pnModAPIFunc('Meds', 'user', 'select_pregclasses');
    $selects['schedules'] = pnModAPIFunc('Meds', 'user', 'select_schedule');
    $selects['generics'] = pnModAPIFunc('Meds', 'user', 'select_generics');
    $selects['peds'] = pnModAPIFunc('Meds', 'user', 'select_peds');
    $selects['ped_texts'] = pnModAPIFunc('Meds', 'user', 'select_pedtexts');
    return $selects;
}
Exemple #30
0
/**
 * carry out hook operations for module
 * @param hookobject the object the hook is called for - either 'item' or 'category'
 * @param hookaction the action the hook is called for - one of 'create', 'delete', 'transform', or 'display'
 * @param hookid the id of the object the hook is called for (module-specific)
 * @param extrainfo extra information for the hook, dependent on hookaction
 * @returns string
 * @return output from hooks
 */
function pnModCallHooks($hookobject, $hookaction, $hookid, $extrainfo)
{
    // Get database info
    list($dbconn) = pnDBGetConn();
    $pntable = pnDBGetTables();
    $hookstable = $pntable['hooks'];
    $hookscolumn =& $pntable['hooks_column'];
    // Get applicable hooks
    $sql = "SELECT {$hookscolumn['tarea']},\n                   {$hookscolumn['tmodule']},\n                   {$hookscolumn['ttype']},\n                   {$hookscolumn['tfunc']}\n            FROM {$hookstable}\n            WHERE {$hookscolumn['smodule']} = '" . pnVarPrepForStore(pnModGetName()) . "'\n            AND {$hookscolumn['object']} = '" . pnVarPrepForStore($hookobject) . "'\n            AND {$hookscolumn['action']} = '" . pnVarPrepForStore($hookaction) . "'";
    $result = $dbconn->Execute($sql);
    if ($dbconn->ErrorNo() != 0) {
        return null;
    }
    $output = '';
    // Call each hook
    for (; !$result->EOF; $result->MoveNext()) {
        list($hookarea, $hookmodule, $hooktype, $hookfunc) = $result->fields;
        if ($hookarea == 'GUI') {
            if (pnModAvailable($hookmodule, $hooktype) && pnModLoad($hookmodule, $hooktype)) {
                $output .= pnModFunc($hookmodule, $hooktype, $hookfunc, array('objectid' => $hookid, 'extrainfo' => $extrainfo));
            }
        } else {
            if (pnModAvailable($hookmodule, $hooktype) && pnModAPILoad($hookmodule, $hooktype)) {
                $extrainfo = pnModAPIFunc($hookmodule, $hooktype, $hookfunc, array('objectid' => $hookid, 'extrainfo' => $extrainfo));
            }
        }
    }
    if ($hookaction == 'display') {
        return $output;
    } else {
        return $extrainfo;
    }
}