correct which entities have flags,
authorkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Sun, 25 Apr 2010 11:26:16 +0000 (11:26 +0000)
committerkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Sun, 25 Apr 2010 11:26:16 +0000 (11:26 +0000)
translate flags to "canuse" bool flag

git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@439 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33

wob/customer.wolf
wob/event.wolf
wob/order.wolf
wob/template.wolf
www/inc/machine/session.php

index 8a305e5..b82fda5 100644 (file)
@@ -22,7 +22,6 @@
                <Column name="firstname" type="string" notnull="yes"/>
                <Column name="name" type="string" notnull="yes"/>
                <Column name="comments" type="text"/>
-               <Column name="flags" type="string"/>
                <!--online login data-->
                <Column name="email" type="string" null="yes"/>
                <Column name="passwd" type="string:64" null="yes"/> <!-- salted SHA-1 hash of passwd -->
                <Property name="firstname" type="string"/>
                <Property name="name" type="string"/>
                <Property name="comments" type="string"/>
-               <Property name="flags" type="string"/>
                <!--online login data-->
                <Property name="email" type="string"/>
                <!-- password is never sent from server to client -->
                        <Map column="firstname"/>
                        <Map column="name"/>
                        <Map column="comments"/>
-                       <Map column="flags"/>
                        <Map column="email"/>
                        <Map property="addresses">
                                <Call lang="php" method="WOAddress::fromTableArrayaddress(WTaddress::selectFromDB('customerid='.$GLOBALS['db']->escapeInt($table->customerid)))"/>
index 11ba054..b3a6c01 100644 (file)
                <Column name="roomid" type="string:64" primarykey="yes">Name of the room</Column>
                <Column name="capacity" type="int32" notnull="yes">Amount of people fitting into the room, zero means unlimited, this can be overridden per event.</Column>
                <Column name="description" type="text">A short description of the room to help users. Currently not used extensively.</Column>
+               <Column name="flags" type="string">filter flags: defines who can use this room for new events (ignored once it is attached to an event)</Column>
        </Table>
        
        <Table name="seatplan" backup="yes">
+               <Doc>stores seating arrangements</Doc>
                <Column name="seatplanid" type="seq32" primarykey="yes"/>
-               <!-- display name -->
-               <Column name="name" type="string"/>
-               <!-- XML form of the plan -->
-               <Column name="plan" type="text"/>
+               <Column name="roomid" type="string:64" foreignkey="room:roomid">the room this seating arrangement belongs to</Column>
+               <Column name="name" type="string">display name of the seating arrangement</Column>
+               <Column name="plan" type="text">XML representation of the seating arrangements</Column>
+               <Column name="flags" type="string">filter flags: defines who can use this arrangement for new events (ignored once it is attached to an event)</Column>
        </Table>
        
        <Table name="pricecategory" backup="yes">
@@ -27,7 +29,7 @@
                <Column name="name" type="string" notnull="yes"/>
                <Column name="abbreviation" type="string:10" notnull="yes"/>
                <Column name="formula" type="string"/>
-               <Column name="flags" type="string"/>
+               <Column name="flags" type="string">filter flags: defines who can use the category to define a new event (ignored once it is attached to an event)</Column>
                
                <Preset>
                        <V col="pricecategoryid" val="1"/>
@@ -43,6 +45,7 @@
                <Column name="artistname" type="string" notnull="yes"/>
                <Column name="description" type="text"/>
                <Column name="comment" type="text"/>
+               <Column name="flags" type="string">filter flags: defines who can create events with this artist (ignored once it is attached to an event)</Column>
        </Table>
        
        <Table name="event" backup="yes">
@@ -61,7 +64,7 @@
                <Column name="capacity" type="int32" notnull="yes"/>
                <!-- flags -->
                <Column name="iscancelled" type="bool" default="0"/>
-               <Column name="flags" type="string"/>
+               <Column name="flags" type="string">filter: who can sell tickets for this event</Column>
                <Column name="tax" type="int32"/>
                <!-- reason the event has been cancelled-->
                <Column name="cancelreason" type="string"/>
@@ -72,7 +75,7 @@
                <Column name="pricecategoryid" type="int32" primarykey="yes" foreignkey="pricecategory:pricecategoryid"/>
                <Column name="maxavailable" type="int32" notnull="yes"/>
                <Column name="price" type="int32" notnull="yes"/>
-               <Column name="flags" type="string"/>
+               <Column name="flags" type="string">filter: who can sell tickets in this category for this event</Column>
        </Table>
        
        <Class name="Artist">
                <Property name="name" type="string"/>
                <Property name="description" type="string"/>
                <Property name="comment" type="string"/>
+               <Property name="flags" type="astring"/>
+               <Property name="canuse" type="bool"/>
                
                <Mapping table="artist">
                        <Map column="artistid" property="id"/>
                        <Map column="artistname" property="name"/>
                        <Map column="description"/>
                        <Map column="comment"/>
+                       <Map column="flags"/>
+                       <Map property="canuse">
+                               <Call lang="php" method="$GLOBALS['session']->checkFlags($data->getflags())"/>
+                       </Map>
                </Mapping>
        </Class>
        
                <Property name="abbreviation" type="astring"/>
                <Property name="formula" type="string"/>
                <Property name="flags" type="string"/>
+               <Property name="canuse" type="bool"/>
                <Mapping table="pricecategory">
                        <Map column="pricecategoryid"/>
                        <Map column="name"/>
                        <Map column="abbreviation"/>
                        <Map column="formula"/>
                        <Map column="flags"/>
+                       <Map property="canuse">
+                               <Call lang="php" method="$GLOBALS['session']->checkFlags($data->getflags())"/>
+                       </Map>
                </Mapping>
        </Class>
        
                <Property name="maxavailable" type="int32"/>
                <Property name="price" type="int32"/>
                <Property name="flags" type="string"/>
+               <Property name="canuse" type="bool"/>
                
                <Property name="amounttickets" type="int">calculated property: contains the amount of tickets currently contained in this price, ignored if sent from client</Property>
                <Property name="amountticketsblock" type="int">calculated property: contains the amount of tickets currently contained in this price that are actually usable or reserved, ignored if sent from client</Property>
                        <Map property="amountticketsblock">
                                <Call lang="php" method="$data->getAmountTicketsBlockFromDB()"/>
                        </Map>
+                       <Map property="canuse">
+                               <Call lang="php" method="$GLOBALS['session']->checkFlags($data->getflags())"/>
+                       </Map>
                </Mapping>
        </Class>
        
                <Property name="description" type="string"/>
                <Property name="comment" type="string"/>
                <Property name="tax" type="int"/>
+               <Property name="flags" type="string"/>
+               <Property name="canuse" type="bool"/>
                
                <Mapping table="event">
                        <Map column="eventid" property="id"/>
                        <Map property="amountReserved">
                                <Call lang="php" method="$data->getAmountReservedFromDB()"/>
                        </Map>
+                       <Map property="canuse">
+                               <Call lang="php" method="$GLOBALS['session']->checkFlags($data->getflags())"/>
+                       </Map>
                </Mapping>
        </Class>
        
index bee6109..7c32d03 100644 (file)
@@ -19,6 +19,7 @@
                <Column name="paytype" type="string:64" primarykey="yes"/>
                <Column name="description" type="string"/>
                <Column name="dataname" type="string:64" null="yes"/>
+               <Column name="flags" type="string">filter: who can log payments with this method</Column>
                
                <Preset><V col="paytype" val="cash"/><V col="description" val="default paytype: cash"/></Preset>
        </Table>
                </Column>
                <Column name="price" type="int32" notnull="yes"/>
                <Column name="barcode" type="string" null="yes">usually the EAN code</Column>
-               <Column name="flags" type="string"/>
+               <Column name="flags" type="string">filter: who can sell this product</Column>
                <Column name="tax" type="int32"/>
        </Table>
        <Table name="item" backup="yes" audit="yes">
                <Property name="shipid" type="int"/>
                <Property name="cost" type="int"/>
                <Property name="flags" type="string"/>
+               <Property name="canuse" type="bool"/>
                <Property name="description" type="string"/>
                <Mapping table="shipping">
                        <Map column="shipid"/>
                        <Map column="cost"/>
                        <Map column="flags"/>
                        <Map column="description"/>
+                       <Map property="canuse">
+                               <Call lang="php" method="$GLOBALS['session']->checkFlags($data->getflags())"/>
+                       </Map>
                </Mapping>
        </Class>
        
index 3467d9c..d367a67 100644 (file)
@@ -13,7 +13,7 @@
                <Column name="content" type="blob"/>
                <Column name="hash" type="string:32" notnull="yes"/> <!--md5-->
                <Column name="dolog" type="bool" default="0"/>
-               <Column name="flags" type="string"/>
+               <Column name="flags" type="string">filter: who can use this template</Column>
        </Table>
        
        <Class name="Template">
@@ -24,6 +24,7 @@
                <Property name="hash" type="astring"/> <!--md5-->
                <Property name="dolog" type="bool"/>
                <Property name="flags" type="string"/>
+               <Property name="canuse" type="bool"/>
                <Mapping table="template">
                        <Map column="filename"/>
                        <Map column="description"/>
                        <Map column="hash"/>
                        <Map column="dolog"/>
                        <Map column="flags"/>
+                       <Map property="canuse">
+                               <Call lang="php" method="$GLOBALS['session']->checkFlags($data->getflags())"/>
+                       </Map>
+                       <Map property="canuse">
+                               <Call lang="php" method="$GLOBALS['session']->checkFlags($data->getflags())"/>
+                       </Map>
                </Mapping>
        </Class>
        
                <Property name="filename" type="astring"/>
                <Property name="description" type="string"/>
                <Property name="hash" type="astring"/> <!--md5-->
+               <Property name="flags" type="astring"/>
                <Mapping table="template">
                        <Map column="filename"/>
                        <Map column="description"/>
                        <Map column="hash"/>
+                       <Map column="flags"/>
+                       <Map property="canuse">
+                               <Call lang="php" method="$GLOBALS['session']->checkFlags($data->getflags())"/>
+                       </Map>
                </Mapping>
        </Class>
        
index 41e51a9..4b99538 100644 (file)
@@ -238,21 +238,28 @@ class Session
        /**checks the given flags item pattern (string or array of strings) and returns true if they match*/
        public function checkFlags($iflg)
        {
-               //admin shortcut
+               //admin shortcut: allow everything
                if($this->hasFlag("_admin"))return true;
-               if(in_array("_admin",$this-roles))return true;
-               //actual check
+               if(in_array("_admin",$this->roles))return true;
+               //actual check for "mere mortals"
                if(is_array($iflg))$fp=$iflg;
                else $fp=explode(" ",$iflg);
                foreach($fp as $f){
+                       //discard dummies
+                       $f=trim($f);
+                       if($f=="")continue;
+                       // flag starting with "+": check that user has it
                        if($f[0]=="+"){
                                if(!$this->hasFlag(substr($f,1)))return false;
                        }else
+                       // flag starting with "-": check that user does not have it
                        if($f[0]=="-"){
                                if($this->hasFlag(substr($f,1)))return false;
                        }
+                       // flag starting with anything else: errrm. error out
                        else return false;
                }
+               //no matches, must be ok then
                return true;
        }
 };