Exemple #1
0
    /**
     * Create List Inbox Table
     *
     * @param type $data
     * @return type
     *
     */
    public function create($data, $isSelfService = false)
    {
        $con = Propel::getConnection( ListInboxPeer::DATABASE_NAME );
        try {
            $this->fromArray( $data, BasePeer::TYPE_FIELDNAME );
            if ($this->validate()) {
                $result = $this->save();
            } else {
                $e = new Exception( "Failed Validation in class " . get_class( $this ) . "." );
                $e->aValidationFailures = $this->getValidationFailures();
                throw ($e);
            }
            $con->commit();

            // create participated history
            $listParticipatedHistory = new ListParticipatedHistory();
            $listParticipatedHistory->remove($data['APP_UID'],$data['DEL_INDEX']);
            $listParticipatedHistory = new ListParticipatedHistory();
            $listParticipatedHistory->create($data);

            // create participated history
            $listMyInbox = new ListMyInbox();
            $listMyInbox->refresh($data);

            // remove and create participated last
            if (!$isSelfService) {
                $oCriteria = new Criteria('workflow');
                $oCriteria->add(ListParticipatedLastPeer::APP_UID, $data['APP_UID']);
                $oCriteria->add(ListParticipatedLastPeer::USR_UID, $data['USR_UID']);
                $exit = ListParticipatedLastPeer::doCount($oCriteria);
                if ($exit) {
                    $oCriteria = new Criteria('workflow');
                    $oCriteria->add(ListParticipatedLastPeer::APP_UID, $data['APP_UID']);
                    $oCriteria->add(ListParticipatedLastPeer::USR_UID, $data['USR_UID']);
                    ListParticipatedLastPeer::doDelete($oCriteria);
                    $users = new Users();
                    $users->refreshTotal($data['USR_UID'], 'removed', 'participated');
                }

                $listParticipatedLast = new ListParticipatedLast();
                $listParticipatedLast->create($data);
                $listParticipatedLast = new ListParticipatedLast();
                $listParticipatedLast->refresh($data);
            } else {
                $data['USR_UID'] = $data['DEL_PREVIOUS_USR_UID'];
                $data['DEL_CURRENT_USR_LASTNAME'] = '';
                $data['DEL_CURRENT_USR_USERNAME'] = '';
                $data['DEL_CURRENT_USR_FIRSTNAME'] = '';

                $listParticipatedLast = new ListParticipatedLast();
                $listParticipatedLast->refresh($data, $isSelfService);
                $data['USR_UID'] = 'SELF_SERVICES';
                $listParticipatedLast = new ListParticipatedLast();
                $listParticipatedLast->create($data);
                $listParticipatedLast = new ListParticipatedLast();
                $listParticipatedLast->refresh($data, $isSelfService);
            }

            return $result;
        } catch(Exception $e) {
            $con->rollback();
            throw ($e);
        }
    }
 public function countTotal ($usr_uid, $filters = array())
 {
     $criteria = new Criteria();
     $criteria->add( ListParticipatedLastPeer::USR_UID, $usr_uid, Criteria::EQUAL );
     self::loadFilters($criteria, $filters);
     $total = ListParticipatedLastPeer::doCount( $criteria );
     return (int)$total;
 }