Пример #1
0
 public function countTemplateRecords($criteria = null, $distinct = false, $con = null)
 {
     include_once 'lib/model/om/BaseTemplateRecordPeer.php';
     if ($criteria === null) {
         $criteria = new Criteria();
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     $criteria->add(TemplateRecordPeer::TEMPLATE_ID, $this->getId());
     return TemplateRecordPeer::doCount($criteria, $distinct, $con);
 }
 public static function retrieveByPKs($pks, $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(self::DATABASE_NAME);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria();
         $criteria->add(TemplateRecordPeer::ID, $pks, Criteria::IN);
         $objs = TemplateRecordPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Пример #3
0
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = TemplateRecordPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setTemplateId($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setName($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setType($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setContent($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setTtl($arr[$keys[5]]);
     }
     if (array_key_exists($keys[6], $arr)) {
         $this->setPrio($arr[$keys[6]]);
     }
 }
Пример #4
0
 /**
  * Edit
  */
 public function executeEdit()
 {
     if ($this->isGET()) {
         return $this->renderJson(array("success" => false, "info" => "POST Only."));
     } else {
         $template = $this->template;
         $template->setName($this->getRequestParameter('name'));
         $template->setType($this->getRequestParameter('type'));
         $template->save();
         $ids = array();
         foreach ($this->getRequestParameter('record') as $data) {
             if (!($record = TemplateRecordPeer::retrieveByPK($data['id']))) {
                 $record = new TemplateRecord();
                 $record->setTemplateId($template->getId());
             }
             $record->setName($data['name']);
             $record->setType($data['type']);
             $record->setContent($data['content']);
             $record->setTtl($data['ttl']);
             if ($data['type'] == 'MX') {
                 $record->setPrio($data['prio']);
             }
             $record->save();
             $ids[] = $record->getId();
         }
         $c = new Criteria();
         $c->add(TemplateRecordPeer::TEMPLATE_ID, $template->getId());
         $c->add(TemplateRecordPeer::ID, $ids, Criteria::NOT_IN);
         TemplateRecordPeer::doDelete($c);
         return $this->renderJson(array("success" => true, "info" => "Template updated."));
     }
 }