Ejemplo n.º 1
0
$db = \Utils\Database\OcDb::instance();
$projectId = $_REQUEST['projectId'];
$userId = $_REQUEST['userId'];
if (is_numeric($userId)) {
    $queryParam = ' user_id = ';
} else {
    $queryParam = ' username LIKE ';
}
$query = 'SELECT user_id, username FROM user WHERE ' . $queryParam . ' :1 LIMIT 1';
$s = $db->multiVariableQuery($query, $userId);
$userResult = $db->dbResultFetchOneRowOnly($s);
$addQuery = "INSERT INTO `PowerTrail_owners`(`PowerTrailId`, `userId`, `privileages`) VALUES (:1,:2,:3)";
$db->multiVariableQuery($addQuery, $projectId, $userResult['user_id'], 1);
$logQuery = 'INSERT INTO `PowerTrail_actionsLog`(`PowerTrailId`, `userId`, `actionDateTime`, `actionType`, `description`, `cacheId`) VALUES (:1,:2,NOW(),4,:3,:4)';
$db->multiVariableQuery($logQuery, $projectId, $_SESSION['user_id'], $ptAPI->logActionTypes[4]['type'] . ' new owner is: ' . $userResult['user_id'], $userResult['user_id']);
$powerTrail = new \lib\Objects\PowerTrail\PowerTrail(array('id' => $projectId));
$ptOwners = displayPtOwnerList($powerTrail->getOwners());
echo $ptOwners;
function displayPtOwnerList($ptOwners)
{
    $ownerList = '';
    foreach ($ptOwners as $user) {
        $ownerList .= '<a href="viewprofile.php?userid=' . $user->getUserId() . '">' . $user->getUsername() . '</a>';
        if ($user->getUserId() != $_SESSION['user_id']) {
            $ownerList .= '<span style="display: none" class="removeUserIcon"><img onclick="ajaxRemoveUserFromPt(' . $user->getUserId() . ');" src="tpl/stdstyle/images/free_icons/cross.png" width=10 " /></span>, ';
        } else {
            $ownerList .= ', ';
        }
    }
    return substr($ownerList, 0, -2);
}
Ejemplo n.º 2
0
/**
 * This function look for 'pt' param in request and set proper tpl var
 *
 * @param
 *            loadDetails - if set to true name, icon and link etc.
 *            of the geopath will be load to template
 */
function parsePowerTrailFilter($loadDetails = false)
{
    global $powerTrailModuleSwitchOn;
    if (!$powerTrailModuleSwitchOn) {
        // powerTrails disabled in settings.inc.php
        tpl_set_var("powertrail_ids", "");
        tpl_set_var("pt_filter_enabled", '0', false);
        return;
    }
    if (!isset($_REQUEST['pt']) || !preg_match('/^[0-9]+(\\|[0-9]+)*$/', $_REQUEST['pt'])) {
        // no param or improper param value
        tpl_set_var("pt_filter_enabled", '0', false);
        tpl_set_var("powertrail_ids", "");
        return;
    }
    // set powertrails_ids param
    tpl_set_var("powertrail_ids", $_REQUEST['pt']);
    if (!$loadDetails) {
        tpl_set_var("pt_filter_enabled", '0', false);
        return;
    }
    // load powertrail details
    $powertrailsIds = explode('|', $_REQUEST['pt']);
    if (!is_array($powertrailsIds) || count($powertrailsIds) == 0) {
        tpl_set_var("pt_filter_enabled", '0', false);
        return;
    }
    if (count($powertrailsIds) > 1) {
        // many powertrails are selected
        // TODO...
        tpl_set_var("pt_filter_enabled", '1', false);
        tpl_set_var("pt_name", "HowDoYouFindIt - you're hacker! TBD");
    } else {
        $ptObj = new \lib\Objects\PowerTrail\PowerTrail(array('id' => (int) $powertrailsIds[0], 'fieldsStr' => 'id,name,type'));
        if ($ptObj->isDataLoaded()) {
            tpl_set_var("pt_filter_enabled", '1', false);
            tpl_set_var("pt_url", $ptObj->getPowerTrailUrl());
            tpl_set_var("pt_name", $ptObj->getName());
            tpl_set_var("pt_icon", $ptObj->getFootIcon());
        } else {
            tpl_set_var("pt_filter_enabled", '0', false);
        }
    }
}
Ejemplo n.º 3
0
     tpl_set_var('mapCenterLon', $main_page_map_center_lon);
     tpl_set_var('mapZoom', 6);
     tpl_set_var('PowerTrails', $ptListData[0]);
     tpl_set_var('ptList4map', $ptListData[1]);
     tpl_set_var('displayPowerTrails', 'block');
     if ($pt->getPowerTrailOwn() === false) {
         tpl_set_var('statusOrPoints', tr('pt037'));
     } else {
         tpl_set_var('statusOrPoints', tr('pt040'));
     }
     tpl_set_var('mapOuterdiv', 'block');
     tpl_set_var('mapInit', 1);
     tpl_set_var('fullCountryMap', '1');
     break;
 case 'showSerie':
     $powerTrail = new lib\Objects\PowerTrail\PowerTrail(array('id' => (int) $_GET['ptrail']));
     $ptOwners = $pt->getPtOwners();
     $_SESSION['ptName'] = powerTrailBase::clearPtNames($powerTrail->getName());
     tpl_set_var('powerTrailId', $powerTrail->getId());
     if (!$usr && $hide_coords) {
         tpl_set_var('mapOuterdiv', 'none');
     } else {
         tpl_set_var('mapOuterdiv', 'block');
     }
     $userIsOwner = $powerTrail->isUserOwner($usr['userid']);
     if ($powerTrail->getStatus() == 1 || $userIsOwner || $appContainer->getLoggedUser() !== false && $appContainer->getLoggedUser()->getIsAdmin()) {
         $ptTypesArr = powerTrailBase::getPowerTrailTypes();
         $ptStatusArr = \lib\Controllers\PowerTrailController::getPowerTrailStatus();
         $foundCachsByUser = $powerTrail->getFoundCachsByUser($usr['userid']);
         $leadingUser = powerTrailBase::getLeadingUser($powerTrail->getId());
         if ($powerTrail->getConquestedCount() > 0) {