Example #1
0
 public static function isViewer($formID, $username = NULL)
 {
     if (isnull($username)) {
         $username = sessionGet("username");
     }
     return self::getCount($formID, $username, mfcs::AUTH_VIEW) || self::isEditor($formID, $username);
 }
Example #2
0
 public static function formListing()
 {
     $forms = forms::getObjectForms();
     $output = '<option value="NULL">-- Select a Form --</option>';
     foreach ($forms as $form) {
         $output .= sprintf('<option value="%s" %s>%s</option>', $form['ID'], $form['ID'] == sessionGet("lastSearchForm") ? "selected" : "", $form['title']);
     }
     return $output;
 }
function smarty_function_andropage($params, &$smarty)
{
    if (count($params) == 0) {
        $smarty->trigger_error('AndroPage: Missing Arguments');
        return;
    }
    if (!isset($params['filters'])) {
        $smarty->trigger_error('AndroPage: Missing filters argument');
        return;
    }
    $filters = array();
    $x1 = explode("|", $params['filters']);
    foreach ($x1 as $x) {
        $x2 = explode("=", $x);
        $filters[$x2[0]] = $x2[1];
    }
    $url = 'index.php?gp_page=' . $params['page'] . '&gp_post=smarty&gp_uid=' . sessionGet('UID') . '&st2login=1&gp_pwd=' . sessionGET('PWD');
    foreach ($filters as $filterName => $filterVal) {
        $url .= '&ap_' . $filterName . '=' . $filterVal;
    }
    echo file_get_contents('http://' . $_SERVER['SERVER_NAME'] . '/' . $GLOBALS['AG']['tmpPathInsert'] . $url);
}
Example #4
0
<?php

$currentProjectsIDs = array_keys(sessionGet('currentProject'));
$projectListHTML = '<ul id="selectProjectsList">';
try {
    if (($projects = projects::getProjects()) === FALSE) {
        throw new Exception("Error retrieving project list.");
    }
    foreach ($projects as $project) {
        $projectListHTML .= sprintf("<li><label><input type='checkbox' value='%s' data-label='%s'%s> %s</label></li>", $project['ID'], $project['projectName'], in_array($project['ID'], $currentProjectsIDs) ? " checked='checked'" : '', $project['projectName']);
    }
} catch (Exception $e) {
    $projectListHTML .= "<li>" . $e->getMessage() . "</li>";
}
$projectListHTML .= '</ul>';
localvars::add('projectModalList', $projectListHTML);
?>
{engine name="csrf"}
<!-- Modal - Select Current Projects -->
<div id="selectProjectsModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-header">
		<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
		<h3>Your current projects:</h3>
	</div>
	<div class="modal-body">{local var="projectModalList"}</div>
	<div class="modal-footer">
		<button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button>
		<button class="btn btn-primary" onclick="saveSelectedProjects();">Save changes</button>
	</div>
</div>
Example #5
0
 public static function updateUserProjects()
 {
     $currentProjectsIDs = array_keys(sessionGet('currentProject'));
     $submittedProjectsIDs = isset(mfcs::$engine->cleanPost['MYSQL']['selectedProjects']) ? mfcs::$engine->cleanPost['MYSQL']['selectedProjects'] : array();
     try {
         // Delete project IDs that disappeared
         $deletedIDs = array_diff($currentProjectsIDs, $submittedProjectsIDs);
         if (sizeof($deletedIDs)) {
             $deleteSQL = sprintf("DELETE FROM users_projects WHERE userID='%s' AND projectID IN (%s)", users::user('ID'), implode(',', $deletedIDs));
             $deleteSQLResult = mfcs::$engine->openDB->query($deleteSQL);
             if (!$deleteSQLResult['result']) {
                 throw new Exception("MySQL Error - " . $deleteSQLResult['error']);
             }
         }
         // Add project IDs that appeared
         $addedIDs = array_diff($submittedProjectsIDs, $currentProjectsIDs);
         if (sizeof($addedIDs)) {
             $keyPairs = array();
             foreach ($addedIDs as $addedID) {
                 $keyPairs[] = sprintf("('%s','%s')", users::user('ID'), $addedID);
             }
             $insertSQL = sprintf("INSERT INTO  users_projects (userID,projectID) VALUES %s", implode(',', $keyPairs));
             $insertSQLResult = mfcs::$engine->openDB->query($insertSQL);
             if (!$insertSQLResult['result']) {
                 throw new Exception("MySQL Error - " . $insertSQLResult['error']);
             }
         }
         // If we get here either nothing happened, or everything worked (no errors happened)
         $result = array('success' => TRUE, 'deletedIDs' => $deletedIDs, 'addedIDs' => $addedIDs);
     } catch (Exception $e) {
         $result = array('success' => FALSE, 'errorMsg' => $e->getMessage());
     }
     return $result;
 }
Example #6
0
<?php

$currentProjects = sessionGet('currentProject');
if (isset($currentProjects) and sizeof($currentProjects)) {
    localvars::add('currentProjectNames', implode(', ', array_values($currentProjects)));
    localvars::add('currentProjectIDs', implode(',', array_keys($currentProjects)));
} else {
    localvars::add('currentProjectNames', '<span style="color: #999; font-style: italic;">None Selected</span>');
    localvars::add('currentProjectIDs', '');
}
?>
<ul class="nav">
	<li class="dropdown">
		<a href="#" class="dropdown-toggle" data-toggle="dropdown">
			Navigation
			<b class="caret"></b>
		</a>
		<ul class="dropdown-menu">
			<li><a href="{local var="siteRoot"}">Home</a></li>
			<li class="dropdown-submenu">
				<a href="#" class="dropdown-toggle" data-toggle="dropdown">Object Management<b class="caret"></b></a>
				<ul class="dropdown-menu">
					<li><a href="{local var="siteRoot"}dataEntry/selectForm.php">Create</a></li>
					<li><a href="{local var="siteRoot"}dataView/list.php">List</a></li>
					<li><a href="{local var="siteRoot"}dataView/search.php">Search</a></li>
				</ul>
			</li>
			<li class="dropdown-submenu">
				<a tabindex="-1" href="#">Form Management</a>
				<ul class="dropdown-menu">
					<li><a href="{local var="siteRoot"}formCreator/">New Form</a></li>
Example #7
0
 public static function checkFormInCurrentProjects($formID)
 {
     foreach (sessionGet('currentProject') as $projectID => $project) {
         if (self::checkFormInProject($projectID, $formID) === TRUE) {
             return TRUE;
         }
     }
     localVars::add("projectWarning", '<div class="alert">This form is not associated with one of your current projects</div>');
     return FALSE;
 }
Example #8
0
            log::insert("Data View: Search: get saved search");
            $searchQuery = sessionGET('searchQuery');
            try {
                $results = mfcsSearch::search($searchQuery);
                if ($results === FALSE) {
                    throw new Exception("Error retrieving results");
                }
                sessionSet("searchResults", $results);
            } catch (Exception $e) {
                log::insert("Data View: Search: Error", 0, 0, $e->getMessage());
                errorHandle::errorMsg($e->getMessage());
            }
        } else {
            if (isset($engine->cleanGet['MYSQL']['page'])) {
                log::insert("Data View: Search: page");
                $searchPOST = sessionGet('searchPOST');
                if ($searchPOST) {
                    $results = mfcsSearch::search($searchPOST);
                    if ($results === FALSE) {
                        throw new Exception("Error retrieving results");
                    }
                }
            } else {
                log::insert("Data View: Search: Delete post");
                sessionDelete('searchPOST');
            }
        }
    }
}
if (isset($results)) {
    localvars::add("objectTable", listGenerator::createAllObjectList(0, 50, NULL, $results));
Example #9
0
function mosShowListMenu($menutype)
{
    // -------------------------------------------------------
    // Andromeda Code: If we are in an Andromeda situation
    // then everything is vastly simplified, we already have
    // the menu and we don't do much conversion
    // -------------------------------------------------------
    if (defined('_ANDROMEDA_JOOMLA')) {
        if (!LoggedIn()) {
            return;
        }
        // KFD 7/6/07, cache the menu so we don't have to do
        // this on every call.
        // Cachegrind cost to build menu          : 259 / 199
        // Cachegrind cost logging in             : 140
        // Cachegrind cost login, cache to session: 2!!!!
        // Cachegrind cost to cache to disk       : 400!
        # KFD 4/17/08, rebuild menu if they switched modes
        # KFD 6/21/08, simplify this by just looking at x4Welcome
        #$menu_mode = gpExists('x4Page')
        #  ? (vgfGet('x4menu',false)==true ? 'x4' : 'classic')
        #  : 'classic';
        $menu_mode = configGet('x4welcome', 'N') == 'Y' ? 'x4' : 'classic';
        vgfSet('menu_mode', $menu_mode);
        # KFD 6/21/08 (END)
        if ($menu_mode != SessionGet('menu_mode')) {
            sessionSet('menu', '');
            sessionSet('menu_mode', $menu_mode);
        }
        $menu = SessionGet('menu', '');
        if ($menu != '') {
            echo $menu;
            return;
        }
        ob_start();
        $children = array();
        $open = array();
        $indents = array(array("<ul>", "<li>", "</li>", "</ul>"));
        $class_sfx = null;
        $hilightid = SessionGET('AGMENU_MODULE');
        $hilightid = '';
        $menus = SessionGET("AGMENU");
        foreach ($menus as $menuid => $menuinfo) {
            //if($menuid=='datadict') continue;
            //if($menuid=='sysref')   continue;
            $x = new joomla_fake();
            $x->type = 'url';
            $x->id = $menuid;
            if (sessionGet('menu_mode') == 'x4') {
                $x->link = 'javascript:void(0);';
            } else {
                $x->link = "?x_module=" . urlencode($menuid);
            }
            $x->browserNav = '';
            $x->name = $menuinfo['description'];
            $children[0][] = $x;
            foreach ($menuinfo['items'] as $page => $pageinfo) {
                $x = new joomla_fake();
                $x->type = 'url';
                $x->id = $page;
                # KFD 6/26/08, the vgfX(x4) was experimental, get rid of it
                #if(vgfGet('x4')===true) {
                #    $pd = $pageinfo['description'];
                #    $x->link="javascript:x4Page('$page','$pd')";
                #}
                #else {
                # KFD 6/26/08, work out the menu mode first
                $xmode = 'x2';
                if (sessionGet('menu_mode') == 'x4') {
                    $xmode = a($pageinfo, 'uix2', 'N') == 'Y' ? 'x2' : 'x4';
                }
                if ($xmode == 'x4') {
                    $x->link = '?x4Page=' . urlencode($page);
                    $x->link .= '&x4Return=' . vgaGet('nopage', 'menu');
                } else {
                    $x->link = "?x_module={$menuid}&x2=1&gp_page=" . urlencode($page);
                }
                if (ArraySafe($pageinfo, 'menu_parms') != '') {
                    $x->link .= '&' . urlencode($pageinfo['menu_parms']);
                }
                #}
                $x->browserNav = '';
                $x->name = $pageinfo['description'];
                $children[$menuid][] = $x;
            }
        }
        mosRecurseListMenu(0, 0, $children, $open, $indents, $class_sfx, $hilightid);
        $menu = ob_get_clean();
        echo $menu;
        SessionSet('menu', $menu);
        //$fsMenuFileHTML=ob_get_clean();
        //file_put_contents($fsMenuFile,$fsMenuFileHTML);
        //echo $fsMenuFileHTML;
        return;
    }
    // -------------------------------------------------------
    // Andromeda Code: END
    // -------------------------------------------------------
    global $database, $my, $cur_template, $Itemid;
    global $mosConfig_absolute_path, $mosConfig_live_site, $mosConfig_shownoauth;
    $class_sfx = null;
    $hilightid = null;
    /* If a user has signed in, get their user type */
    $intUserType = 0;
    if ($my->gid) {
        switch ($my->usertype) {
            case 'Super Administrator':
                $intUserType = 0;
                break;
            case 'Administrator':
                $intUserType = 1;
                break;
            case 'Editor':
                $intUserType = 2;
                break;
            case 'Registered':
                $intUserType = 3;
                break;
            case 'Author':
                $intUserType = 4;
                break;
            case 'Publisher':
                $intUserType = 5;
                break;
            case 'Manager':
                $intUserType = 6;
                break;
        }
    } else {
        /* user isn't logged in so make their usertype 0 */
        $intUserType = 0;
    }
    if ($mosConfig_shownoauth) {
        $database->setQuery("SELECT m.*, count(p.parent) as cnt" . "\nFROM #__menu AS m" . "\nLEFT JOIN #__menu AS p ON p.parent = m.id" . "\nWHERE m.menutype='{$menutype}' AND m.published='1'" . "\nGROUP BY m.id ORDER BY m.parent, m.ordering ");
    } else {
        $database->setQuery("SELECT m.*, sum(case when p.published=1 then 1 else 0 end) as cnt" . "\nFROM #__menu AS m" . "\nLEFT JOIN #__menu AS p ON p.parent = m.id" . "\nWHERE m.menutype='{$menutype}' AND m.published='1' AND m.access <= '{$my->gid}'" . "\nGROUP BY m.id ORDER BY m.parent, m.ordering ");
    }
    $rows = $database->loadObjectList('id');
    echo $database->getErrorMsg();
    //work out if this should be highlighted
    $sql = "SELECT m.* FROM #__menu AS m" . "\nWHERE menutype='" . $menutype . "' AND m.published='1'";
    $database->setQuery($sql);
    $subrows = $database->loadObjectList('id');
    $maxrecurse = 5;
    $parentid = $Itemid;
    //this makes sure toplevel stays hilighted when submenu active
    while ($maxrecurse-- > 0) {
        $parentid = getParentRow($subrows, $parentid);
        if (isset($parentid) && $parentid >= 0 && $subrows[$parentid]) {
            if (vgfGet('menu_mode') != 'x4') {
                $hilightid = $parentid;
            }
        } else {
            break;
        }
    }
    if (vgfGet('menu_mode') == 'x4') {
        $hilightid = '';
    }
    //echo "<!--[if lte IE 7]>\n";
    include_once "{$mosConfig_absolute_path}/templates/" . $cur_template . "/js/ie.js";
    //echo "<![endif]-->\n";
    $indents = array(array("<ul>", "<li>", "</li>", "</ul>"));
    // establish the hierarchy of the menu
    $children = array();
    // first pass - collect children
    foreach ($rows as $v) {
        $pt = $v->parent;
        $list = @$children[$pt] ? $children[$pt] : array();
        array_push($list, $v);
        $children[$pt] = $list;
    }
    // second pass - collect 'open' menus
    $open = array($Itemid);
    $count = 20;
    // maximum levels - to prevent runaway loop
    $id = $Itemid;
    while (--$count) {
        if (isset($rows[$id]) && $rows[$id]->parent > 0) {
            $id = $rows[$id]->parent;
            $open[] = $id;
        } else {
            break;
        }
    }
    $class_sfx = null;
    mosRecurseListMenu(0, 0, $children, $open, $indents, $class_sfx, $hilightid);
}