<?php

use Utils\Database\OcDb;
$rootpath = '../';
require_once $rootpath . 'lib/common.inc.php';
require_once __DIR__ . '/../lib/ClassPathDictionary.php';
require_once $rootpath . 'lib/cache_owners.inc.php';
$db = OcDb::instance();
$db->beginTransaction();
$pco = new OrgCacheOwners($db);
$pco->populateAll();
$db->commit();
Esempio n. 2
0
 // wybor wlasciciela - mozna zmieniac tylko swoje skrzynki... chyba, ze jest sie czlonkiem oc team
 if (isset($_GET['cacheid']) && (isUserOwner($usr['userid'], $_GET['cacheid']) && !isset($_GET['abort']) && !isset($_GET['accept']))) {
     tpl_set_var('cachename', getCacheName($_GET['cacheid']));
     tpl_set_var('cacheid', $_GET['cacheid']);
     $tplname = "chowner_chooseuser";
 } else {
     if (isset($_GET['accept']) && $_GET['accept'] == 1) {
         $sql = "SELECT count(id) FROM chowner WHERE cache_id = :1 AND user_id = :2";
         $potwierdzenie = $db->multiVariableQueryValue($sql, 0, $_GET['cacheid'], $usr['userid']);
         if ($potwierdzenie > 0) {
             // zmiana wlasciciela
             tpl_set_var("error_msg", tr('adopt_30'));
             tpl_set_var("info_msg", "");
             $db->beginTransaction();
             require_once $rootpath . 'lib/cache_owners.inc.php';
             $pco = new OrgCacheOwners($db);
             $pco->populateForCache($_GET['cacheid']);
             $oldOwnerId = getCacheOwner($_GET['cacheid']);
             $isCachePublished = isCachePublished($_GET['cacheid']);
             $sql = "DELETE FROM chowner WHERE cache_id = :1 AND user_id = :2";
             $db->multiVariableQuery($sql, $_GET['cacheid'], $usr['userid']);
             if ($isCachePublished) {
                 $sql = "UPDATE caches SET user_id = :2, org_user_id = IF(org_user_id IS NULL, :3, org_user_id) WHERE cache_id= :1";
                 $db->multiVariableQuery($sql, $_GET['cacheid'], $usr['userid'], $oldOwnerId);
             } else {
                 $sql = "UPDATE caches SET user_id = :2 WHERE cache_id= :1";
                 $db->multiVariableQuery($sql, $_GET['cacheid'], $usr['userid']);
             }
             $sql = "UPDATE pictures SET user_id = :2 WHERE object_id = :1";
             $db->multiVariableQuery($sql, $_GET['cacheid'], $usr['userid']);
             // this should be kept consistent by a trigger