00001 <?php
00002
00012 class AuthEmailTemplate extends AuthModelBase {
00014 public static $ATTRIBUTES = array(
00015 'body' => array(
00016 'nullable' => false,
00017 'type' => 'string'
00018 ),
00019 'name' => array(
00020 'nullable' => false,
00021 'type' => 'string'
00022 ),
00023 'id' => array(
00024 'nullable' => false,
00025 'commit' => SModel2::COMMIT_NEVER,
00026 'type' => 'int'
00027 ),
00028 'title' => array(
00029 'nullable' => false,
00030 'type' => 'string'
00031 ),
00032 'description' => array(
00033 'nullable' => false,
00034 'type' => 'string'
00035 )
00036 );
00037
00046 public function __construct($constraints = null) {
00047 parent::__construct();
00048
00049 $this->registerAttributes(self::$ATTRIBUTES);
00050 $this->registerTableName('EmailTemplate');
00051 $this->registerPrimaryKey('id', true);
00052
00053 if($constraints !== null)
00054 $this->populate($constraints);
00055 }
00056
00068 public static function retrieve($constraints = array(), $checkOnly = false) {
00069 $list = self::getList($constraints, array(1), array(), $checkOnly);
00070 if(!$list || count($list) == 0)
00071 return $checkOnly ? false : null;
00072 else if($checkOnly)
00073 return $list > 0;
00074 else
00075 return $list[0];
00076 }
00077
00086 public static function exists($constraints = array()) {
00087 return self::retrieve($constraints, true);
00088 }
00089
00103 public static function getList($constraints = array(), $limit = array(), $order = array(), $count = false) {
00104 return parent::getListBase(self::getDBI(), $constraints, $limit, $order, $count, 'AuthEmailTemplate', true);
00105 }
00106
00116 public static function getAttributesStatic() {
00117 return self::$ATTRIBUTES;
00118 }
00119
00125 public static function getTableNameStatic() {
00126 return 'EmailTemplate';
00127 }
00128
00129
00146 public function listEmailHeaders($constraints = array(), $limit = array(), $order = array(), $count = false) {
00147 return parent::getListBase(self::getDBI(),
00148 array_merge($constraints, array('EmailHeader.emailTemplateId' => $this->id)),
00149 $limit, $order, $count, 'AuthEmailHeader', true);
00150 }
00151
00170 public function listEmailHeadersMulti($constraints = array(), $limit = array(), $order = array(), $count = false, $depth = 1) {
00171 return parent::getListBaseMulti(self::getDBI(),
00172 array_merge($constraints, array('Base.emailTemplateId' => $this->id)),
00173 $limit, $order, $count, 'AuthEmailHeader', true, $depth);
00174 }
00175
00191 public function addEmailHeader($name = '', $value = '') {
00192 $obj = new AuthEmailHeader();
00193
00194 if($name != '')
00195 $obj->name = $name;
00196 if($value != '')
00197 $obj->value = $value;
00198 $obj->emailTemplateId = $this->id;
00199
00200 if(!$obj->commit())
00201 return null;
00202
00203 return $obj;
00204 }
00205 }
00206
00207 ?>