<?xml version="1.0" encoding="ISO-8859-1"?>

<!--| This is the main vie definition.                             |-->
<!--| It has a title and a name. Separate name with dots for Menu. |-->
<!--| The name is used to generate the menu.                       |-->
<!--| The menu attribute is used so determine if shown in menu.    |-->
<!--| Idem for security.                                           |-->
<!--| "defaultlistorder" gives the default column to sort by.      |-->
<view name="links.links" title="Links" menu="1" security="0" defaultlistorder="title ASC">

 <fields>

  <!--| Each field has different attributes. There should be only one field having the ID attribute set to 1, otherwise the last one is taken!  |-->
  <!--| The DELETE attribute is used to form the delete ask string. There should be only one too!                                               |-->
  <!--| The NULL attribute specifies wheather the field must contain a value while in edit mode or not.                                         |-->
  <!--| Set the LIST attribute to 1 to make the field visible in list mode and the EDIT attribute for edit mode. A field may have both ones set |-->
  <!--| 0. ATTENTION: The field thta has ID=1 must have EDIT=1 too!!!                                                                           |-->
  <!--| The name attribute is the name of the column you retrieve from the query. Title is used for display only.                               |-->
  <!--| The type attribute specifies the type of the field. The following ones are accepted:                                                    |-->
  <!--|     text           field is a text                                                                OK                                    |-->
  <!--|     password       field is a *-text                                                              OK                                    |-->
  <!--|     select         field is a value of a sub-qeury, specified in the QUERY attribute              OK                                    |-->
  <!--|                    The first column of the result is the key, the second one the shown value. All other ones are ignored!               |-->
  <!--|                    This query MAY NOT YET contain any variables!!!                                                                      |-->
  <!--|     checkbox       field is a set of values of a sub-qeury, specified in the QUERY attribute      not yet implemented                   |-->
  <!--|     radio          field is a set of values of a sub-qeury, specified in the QUERY attribute      not yet implemented                   |-->
  <!--|     textarea       field is a long text                                                                                                 |-->
  <!--|     boolean        field is a boolean. I list mode booleans are show as graphics!                                                       |-->
  <!--| The query attribute is only used if type is in (select,radio,checkbox). Otherwise it is ignored.                                        |-->
  <field id="1" delete="0" null="0" list="0" edit="1" name="id_link"    title="ID"       type="hidden"  query=""/>
  <field id="0" delete="1" null="0" list="1" edit="1" name="title"      title="title"    type="text"    query=""/>
  <field id="0" delete="0" null="0" list="1" edit="1" name="id_cat"     title="cat"      type="select"  query="SELECT id_cat,title_fr FROM mccl_categories"/>
  <field id="0" delete="0" null="1" list="0" edit="1" name="desc_fr"    title="desc_fr"  type="text"    query=""/>
  <field id="0" delete="0" null="1" list="0" edit="1" name="desc_de"    title="desc_de"  type="text"    query=""/>
  <field id="0" delete="0" null="1" list="0" edit="1" name="desc_lb"    title="desc_lb"  type="text"    query=""/>
  <field id="0" delete="0" null="1" list="0" edit="1" name="desc_en"    title="desc_en"  type="text"    query=""/>
  <field id="0" delete="0" null="0" list="1" edit="1" name="url"        title="url"      type="text"    query=""/>
  <field id="0" delete="0" null="0" list="1" edit="0" name="desc_fr_l"  title="LENGTH"   type="boolean" query=""/>
 </fields>

 <!--| This section contains parameters that the file could be passed with. |-->
 <!--| Attention with the defaultvalue. If var is a string, use the %       |-->
 <!--| if other, just use the fielldname.                                   |-->
 <params>
  <param name="test" defaultvalue="%"/>
  <param name="any" defaultvalue="any"/>
 </params>

 <!--| Here comes the section with the selects       |-->
 <!--| Any queries (select, insert of update) may    |-->
 <!--| contains field variables. The grammar is as   |-->
 <!--| follows: ${field.name}, ie: $myField          |-->
 <!--| ATTENTION: case sensitivity !!!               |-->
 <selects>
  <!--| First of all the select for the list mode... |-->
  <list>
   SELECT *, IF(LENGTH(desc_fr)>0,1,0) "desc_fr_l" FROM mccl_links
  </list>
  <!--| ... and then the select for the edit mode    |-->
  <edit>
   SELECT * FROM mccl_links WHERE id_link=$id_link
  </edit>
 </selects>

 <!--| Here are the queries for the inserts          |-->
 <inserts>
  <insert>
   INSERT INTO mccl_links (title,id_cat,desc_fr,desc_de,desc_lb,desc_en,url) VALUES ('$title',$id_catm'$desc_fr','$desc_de','$desc_lb','$desc_en','$url')
  </insert>
 </inserts>

 <!--| And there ones are for the updates            |-->
 <updates>
  <update>
   UPDATE mccl_links SET title='$title', id_cat=$id_cat, desc_fr='$desc_fr', desc_de='$desc_de', desc_lb='$desc_lb', desc_en='$desc_en', url='$url' WHERE id_link=$id_link
  </update>
 </updates>

 <!--| This queries are used for deleting a line.    |-->
 <deletes>
  <delete>
   DELETE FROM mccl_links WHERE id_link=$id_link
  </delete>
 </deletes>

 <!--| Specific actions can be performed upon event.                      |-->
 <!--|          event     may be one of (edit,list,insert,update,delete)  |-->
 <!--|          name      actually jhust a name (no further use YET       |-->
 <!--|          content   code to be executed for the specific event      |-->
 <actions>
  <action name="log" event="delete">
   echo "Add to LOG: someone deleted the link.id_link=$id_link!!!";
  </action>
 </actions>


 <!--| This is the security section. If security=0 in the view it will not be used. |-->
 <!--| Besides the Title, it needs the query which verifies the user.               |-->
 <!--| ($user,$password) is the couple of vars that PHP will offer you.             |-->
 <security title="Usercheck" query="SELECT * FROM mccl_users u, mccl_contains c, mccl_groups g WHERE u.status=1 AND u.username='$user' AND u.password=PASSWORD('$password') AND g.groupname='$group' AND u.username=c.username AND c.groupname=g.groupname">

  <!--| Checks are event specific, that means that you can assign different rights for every event. |-->
  <check event="list" group="ADMINISTRATORS"/>
  <check event="catch" group="ADMINISTRATORS"/>
  <check event="insert" group="ADMINISTRATORS"/>
  <check event="edit" group="ADMINISTRATORS"/>
  <check event="delete" group="ADMINISTRATORS"/>
  <check event="update" group="ADMINISTRATORS"/>
 </security>

</view>
