CMS  Version 3.9
merge_code.inc
Go to the documentation of this file.
1 <?php
7 /**************************************************************
8 
9  Copyright (c) 2010 Sonjara, Inc
10 
11  Permission is hereby granted, free of charge, to any person
12  obtaining a copy of this software and associated documentation
13  files (the "Software"), to deal in the Software without
14  restriction, including without limitation the rights to use,
15  copy, modify, merge, publish, distribute, sublicense, and/or sell
16  copies of the Software, and to permit persons to whom the
17  Software is furnished to do so, subject to the following
18  conditions:
19 
20  The above copyright notice and this permission notice shall be
21  included in all copies or substantial portions of the Software.
22 
23  Except as contained in this notice, the name(s) of the above
24  copyright holders shall not be used in advertising or otherwise
25  to promote the sale, use or other dealings in this Software
26  without prior written authorization.
27 
28  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
29  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
30  OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
31  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
32  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
33  WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
34  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
35  OTHER DEALINGS IN THE SOFTWARE.
36 
37 *****************************************************************/
38 
39 class MergeCode extends DataItem
40 {
41  var $fields = array(
42  "class_name" => String,
43  "merge_code_id" => Number,
44  "name" => String,
45  "description" => Text,
46  "map" => String
47  );
48 
58  static function setDefaultMergeCode($name, $map, $class_name, $description = "")
59  {
60  $mergeCodes = Query::create(MergeCode, "WHERE name=:name AND class_name=:class_name")
61  ->bind(":name", $name, ":class_name", $class_name)
62  ->execute();
63 
64  if(count($mergeCodes))
65  {
66  return;
67  }
68 
69  $mergeCode = new MergeCode();
70  $mergeCode->name = $name;
71  $mergeCode->map = $map;
72  $mergeCode->class_name = $class_name;
73  $mergeCode->description = $description;
74  $mergeCode->save();
75  }
76 
77  function MergeCode()
78  {
79  $this->table = "merge_code";
80  $this->primary_key = "merge_code_id";
81 
82  $this->DataItem(func_get_args());
83  }
84 }
85 
86 
87 /*
88  * Dummy data model (no table) to draw data list view.
89  */
90 class MergeCodeHelp extends DataItem
91 {
92  var $fields = array(
93  "help_id" => Number,
94  "usage" => String,
95  "example" => String
96  );
97 
98  function MergeCodeHelp()
99  {
100  $this->table = "merge_code";
101  $this->primary_key = "help_id";
102 
103  }
104 
105  static function getHelp()
106  {
107  $helps = array();
108  $help = new MergeCodeHelp();
109  $help->usage = "To get a <b>field</b> in the sending class object, a merge code record is not needed; use '[field_name]' as the merge code";
110  $help->example = "N/A";
111  $helps[0] = $help;
112 
113  $help = new MergeCodeHelp();
114  $help->usage = "To get a <b>field</b> in a <b>related</b> class object, enter the related class name as defined in the DataModel. Use the dot separator to link to the field name. The map does not allow links to relations of relations.";
115  $help->example = "MyRelation.my_field";
116  $helps[1] = $help;
117 
118  $help = new MergeCodeHelp();
119  $help->usage = "To get a value from a <b>function</b> in the DataModel of the sending class, enter the function name.";
120  $help->example = "myFunction";
121  $helps[2] = $help;
122 
123  $help = new MergeCodeHelp();
124  $help->usage = "To get a value from a <b>function</b> in a <b>related</b> class, enter the related class name as defined in the DataModel with a dot separator and function name. The map does not allow links to relations of relations.";
125  $help->example = "MyRelation.myFunction";
126  $helps[3] = $help;
127 
128  $help = new MergeCodeHelp();
129  $help->usage = "To get a value from a <b>callback</b> function, the map must state the name of the function. The function must be available from the calling script. The callback function will receive the sending object as a parameter.";
130  $help->example = "myCallbackFunction";
131  $helps[4] = $help;
132 
133  $help = new MergeCodeHelp();
134  $help->usage = "To get a value from a static <b>function</b> of a <b>non-DataItem</b> class, enter the class name, dot separator, and static function name. The class definition must be included in the calling script. The static function will receive the sending object as a parameter.";
135  $help->example = "myClassName.myStaticFunction";
136  $helps[5] = $help;
137 
138  return $helps;
139  }
140 }
141 
142 
143 class RelationHelp extends DataItem
144 {
145  var $fields = array(
146  "relation_id" => Number,
147  "name" => String,
148  "class_name" => String
149  );
150 
151  function RelationHelp()
152  {
153  $this->table = "relation";
154  $this->primary_key = "relation_id";
155  }
156 
157 }?>
$name
Definition: upload.inc:54
static getHelp()
Definition: merge_code.inc:105
static setDefaultMergeCode($name, $map, $class_name, $description="")
Create a default merge codes for emails that are sent through Fakoli components (e....
Definition: merge_code.inc:58
$mergeCode
$mergeCodes