Пример #1
0
/**
 * add the where condition for listing the record
 * @param type $dgModule
 * @return string
 */
function loadPermittedRecordWhere(ClsAuieoSQL &$objSQL, $data_item_type)
{
    $access_level = Users::getInstance()->getUserInfo("access_level");
    if ($access_level == 500) {
        return;
    }
    $from = $objSQL->getDefaultFrom();
    if (getSharingAccess($data_item_type) <= 0) {
        $obj = Users::getInstance();
        $objSQL->setWhereGroupStart();
        $objSQL->setWhereGroupStart();
        //$arrTmpWhere[]="({$dgTable}.owner = ".$_SESSION["CATS"]->getUserID()." and {$dgTable}.ownertype=0)";
        $objSQL->addWhere($from, "owner", $_SESSION["CATS"]->getUserID());
        $whr1 = $objSQL->addWhere($from, "ownertype", 0);
        $whr1->setBoolean("OR");
        $objSQL->setWhereGroupEnd();
        $objSQL->setWhereGroupStart();
        $arrUserAllowed = $obj->getChildRolesUsers();
        if ($arrUserAllowed) {
            foreach ($arrUserAllowed as $userAllowed) {
                $objSQL->setWhereGroupStart();
                $objSQL->addWhere($from, "owner", $userAllowed);
                $whr2 = $objSQL->addWhere($from, "ownertype", 0);
                $whr2->setBoolean("OR");
                $objSQL->setWhereGroupEnd();
            }
        }
        $arrGroup = $obj->getAllGroups();
        if ($arrGroup) {
            foreach ($arrGroup as $group) {
                $objSQL->setWhereGroupStart();
                $objSQL->addWhere($from, "owner", $group);
                $whr3 = $objSQL->addWhere($from, "ownertype", 1);
                $whr3->setBoolean("OR");
                $objSQL->setWhereGroupend();
            }
        }
        $objSQL->setWhereGroupEnd();
    }
}