function deleteContent($data, $fields)
 {
     $obj = new Content();
     $ConCategory = $fields['CON_CATEGORY'];
     $ConParent = $fields['CON_PARENT'];
     $ConId = $fields['CON_ID'];
     $ConLang = $fields['CON_LANG'];
     try {
         //$res = $obj->load($ConCategory, $ConParent, $ConId, $ConLang );
         $content = ContentPeer::retrieveByPK($ConCategory, $ConParent, $ConId, $ConLang);
         if ($content) {
             $content->delete();
         }
     } catch (Exception $e) {
         return $e;
     }
     return $res;
 }
Esempio n. 2
0
 function removeLanguageContent($lanId)
 {
     try {
         $c = new Criteria();
         $c->addSelectColumn(ContentPeer::CON_CATEGORY);
         $c->addSelectColumn(ContentPeer::CON_PARENT);
         $c->addSelectColumn(ContentPeer::CON_ID);
         $c->addSelectColumn(ContentPeer::CON_LANG);
         $c->add(ContentPeer::CON_LANG, $lanId);
         $result = ContentPeer::doSelectRS($c);
         $result->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $result->next();
         $row = $result->getRow();
         while (is_array($row)) {
             $content = ContentPeer::retrieveByPK($row['CON_CATEGORY'], '', $row['CON_ID'], $lanId);
             if ($content !== null) {
                 $content->delete();
             }
             $result->next();
             $row = $result->getRow();
         }
     } catch (Exception $e) {
         throw $e;
     }
 }
Esempio n. 3
0
 /**
  * Implementation for 'DELETE' method for Rest API
  *
  * @param  mixed $conCategory, $conParent, $conId, $conLang Primary key
  *
  * @return array $result Returns array within multiple records or a single record depending if
  *                       a single selection was requested passing id(s) as param
  */
 protected function delete($conCategory, $conParent, $conId, $conLang)
 {
     $conn = Propel::getConnection(ContentPeer::DATABASE_NAME);
     try {
         $conn->begin();
         $obj = ContentPeer::retrieveByPK($conCategory, $conParent, $conId, $conLang);
         if (!is_object($obj)) {
             throw new RestException(412, G::LoadTranslation('ID_RECORD_DOES_NOT_EXIST'));
         }
         $obj->delete();
         $conn->commit();
     } catch (Exception $e) {
         $conn->rollback();
         throw new RestException(412, $e->getMessage());
     }
 }
Esempio n. 4
0
 public function updateInsertContent($content, $field, $value)
 {
     if (isset($content[$field]['en'])) {
         //update
         $con = ContentPeer::retrieveByPK($field, '', $this->getAppUid(), 'en');
         $con->setConValue($value);
         if ($con->validate()) {
             $res = $con->save();
         }
     } else {
         //insert
         $con = new Content();
         $con->setConCategory($field);
         $con->setConParent('');
         $con->setConId($this->getAppUid());
         $con->setConLang('en');
         $con->setConValue($value);
         if ($con->validate()) {
             $res = $con->save();
         }
     }
 }
Esempio n. 5
0
 /**
  * Implementation for 'DELETE' method for Rest API
  *
  * @param  mixed $conCategory, $conParent, $conId, $conLang Primary key
  *
  * @return array $result Returns array within multiple records or a single record depending if
  *                       a single selection was requested passing id(s) as param
  */
 protected function delete($conCategory, $conParent, $conId, $conLang)
 {
     $conn = Propel::getConnection(ContentPeer::DATABASE_NAME);
     try {
         $conn->begin();
         $obj = ContentPeer::retrieveByPK($conCategory, $conParent, $conId, $conLang);
         if (!is_object($obj)) {
             throw new RestException(412, 'Record does not exist.');
         }
         $obj->delete();
         $conn->commit();
     } catch (Exception $e) {
         $conn->rollback();
         throw new RestException(412, $e->getMessage());
     }
 }