public function testIsNew()
 {
     $user = new User();
     $this->assertTrue($user->isNew());
     $user->setName('daniel');
     $user->save();
     $this->assertFalse($user->isNew());
 }
Example #2
0
 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param      PropelPDO $con
  * @return     int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws     PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aUser !== null) {
             if ($this->aUser->isModified() || $this->aUser->isNew()) {
                 $affectedRows += $this->aUser->save($con);
             }
             $this->setUser($this->aUser);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
             } else {
                 $this->doUpdate($con);
             }
             $affectedRows += 1;
             $this->resetModified();
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
Example #3
0
 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param      PropelPDO $con
  * @return     int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws     PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aUser !== null) {
             if ($this->aUser->isModified() || $this->aUser->isNew()) {
                 $affectedRows += $this->aUser->save($con);
             }
             $this->setUser($this->aUser);
         }
         // If this object has been modified, then save it to the database.
         if ($this->isModified()) {
             if ($this->isNew()) {
                 $pk = UserFbPeer::doInsert($this, $con);
                 $affectedRows += 1;
                 // we are assuming that there is only 1 row per doInsert() which
                 // should always be true here (even though technically
                 // BasePeer::doInsert() can insert multiple rows).
                 $this->setNew(false);
             } else {
                 $affectedRows += UserFbPeer::doUpdate($this, $con);
             }
             $this->resetModified();
             // [HL] After being saved an object is no longer 'modified'
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
Example #4
0
 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param      PropelPDO $con
  * @return     int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws     PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aUser !== null) {
             if ($this->aUser->isModified() || $this->aUser->isNew()) {
                 $affectedRows += $this->aUser->save($con);
             }
             $this->setUser($this->aUser);
         }
         // If this object has been modified, then save it to the database.
         if ($this->isModified()) {
             if ($this->isNew()) {
                 $criteria = $this->buildCriteria();
                 $pk = BasePeer::doInsert($criteria, $con);
                 $affectedRows += 1;
                 $this->setNew(false);
             } else {
                 $affectedRows += WebdavLockPeer::doUpdate($this, $con);
             }
             $this->resetModified();
             // [HL] After being saved an object is no longer 'modified'
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
Example #5
0
 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param      PropelPDO $con
  * @return     int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws     PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aUserRelatedByLeadId !== null) {
             if ($this->aUserRelatedByLeadId->isModified() || $this->aUserRelatedByLeadId->isNew()) {
                 $affectedRows += $this->aUserRelatedByLeadId->save($con);
             }
             $this->setUserRelatedByLeadId($this->aUserRelatedByLeadId);
         }
         if ($this->aUserRelatedByUserId !== null) {
             if ($this->aUserRelatedByUserId->isModified() || $this->aUserRelatedByUserId->isNew()) {
                 $affectedRows += $this->aUserRelatedByUserId->save($con);
             }
             $this->setUserRelatedByUserId($this->aUserRelatedByUserId);
         }
         if ($this->isNew()) {
             $this->modifiedColumns[] = ProjectPeer::ID;
         }
         // If this object has been modified, then save it to the database.
         if ($this->isModified()) {
             if ($this->isNew()) {
                 $pk = ProjectPeer::doInsert($this, $con);
                 $affectedRows += 1;
                 // we are assuming that there is only 1 row per doInsert() which
                 // should always be true here (even though technically
                 // BasePeer::doInsert() can insert multiple rows).
                 $this->setId($pk);
                 //[IMV] update autoincrement primary key
                 $this->setNew(false);
             } else {
                 $affectedRows += ProjectPeer::doUpdate($this, $con);
             }
             $this->resetModified();
             // [HL] After being saved an object is no longer 'modified'
         }
         if ($this->collTasks !== null) {
             foreach ($this->collTasks as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->collBuilds !== null) {
             foreach ($this->collBuilds as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
Example #6
0
 function executeSave()
 {
     $request = fvRequest::getInstance();
     if (!($User = UserManager::getInstance()->getByPk($request->getRequestParameter('id')))) {
         $User = new User();
     }
     $m = $request->getRequestParameter('m');
     if (!$User->isNew() && strlen($m['password']) == 0) {
         unset($m['password']);
         unset($m['password1']);
     }
     $User->updateFromRequest($m);
     if ($User->save()) {
         fvResponce::getInstance()->setHeader('Id', $User->getPk());
         $this->setFlash("Данные успешно сохранены", self::$FLASH_SUCCESS);
     } else {
         fvResponce::getInstance()->setHeader('X-JSON', json_encode($User->getValidationResult()));
         $this->setFlash("Ошибка при сохранении данных проверте правильность введенных данных", self::$FLASH_ERROR);
     }
     if ($request->getRequestParameter('redirect')) {
         fvResponce::getInstance()->setHeader('redirect', fvSite::$fvConfig->get('dir_web_root') . $request->getRequestParameter('module') . "/");
     }
     if (fvRequest::getInstance()->isXmlHttpRequest()) {
         return self::$FV_AJAX_CALL;
     } else {
         return self::$FV_OK;
     }
 }
 /**
  * Send welcome message
  *
  * @param void
  * @return null
  */
 function send_welcome_message()
 {
     if ($this->active_user->isNew()) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     if (!$this->active_user->canSendWelcomeMessage($this->logged_user)) {
         $this->httpError(HTTP_ERR_FORBIDDEN);
     }
     // if
     $this->skip_layout = $this->request->isAsyncCall();
     $welcome_message_data = $this->request->post('welcome_message');
     if (!is_array($welcome_message_data)) {
         $welcome_message_data = array('message' => UserConfigOptions::getValue('welcome_message', $this->active_user));
     }
     // if
     $this->smarty->assign('welcome_message_data', $welcome_message_data);
     if ($this->request->isSubmitted()) {
         $welcome_message = trim(array_var($welcome_message_data, 'message'));
         if ($welcome_message) {
             UserConfigOptions::setValue('welcome_message', $welcome_message, $this->active_user);
         } else {
             UserConfigOptions::removeValue('welcome_message', $this->active_user);
         }
         // if
         $password = make_password(11);
         $this->active_user->setPassword($password);
         $save = $this->active_user->save();
         if ($save && !is_error($save)) {
             $welcome_message_sent = ApplicationMailer::send(array($this->active_user), 'system/new_user', array('created_by_id' => $this->logged_user->getId(), 'created_by_name' => $this->logged_user->getDisplayName(), 'created_by_url' => $this->logged_user->getViewUrl(), 'email' => $this->active_user->getEmail(), 'password' => $password, 'login_url' => assemble_url('login'), 'welcome_body' => $welcome_message ? nl2br(clean($welcome_message)) : ''));
             if ($welcome_message_sent) {
                 $message = lang('Welcome message has been sent to :name', array('name' => $this->active_user->getDisplayName()));
             } else {
                 $message = lang('Failed to send welcome message to :name. Please try again later', array('name' => $this->active_user->getDisplayName()));
             }
             // if
             if ($this->request->isAsyncCall()) {
                 die($message);
             } else {
                 flash_success($message);
                 $this->redirectToUrl($this->active_user->getViewUrl());
             }
             // if
         } else {
             if ($this->request->isAsyncCall()) {
                 $this->httpError(HTTP_ERR_OPERATION_FAILED);
             } else {
                 flash_error($message);
                 $this->redirectToUrl($this->active_user->getViewUrl());
             }
             // if
         }
         // if
     }
     // if
 }
Example #8
0
 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param PropelPDO $con
  * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their corresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aUserRelatedByCreatedBy !== null) {
             if ($this->aUserRelatedByCreatedBy->isModified() || $this->aUserRelatedByCreatedBy->isNew()) {
                 $affectedRows += $this->aUserRelatedByCreatedBy->save($con);
             }
             $this->setUserRelatedByCreatedBy($this->aUserRelatedByCreatedBy);
         }
         if ($this->aUserRelatedByUpdatedBy !== null) {
             if ($this->aUserRelatedByUpdatedBy->isModified() || $this->aUserRelatedByUpdatedBy->isNew()) {
                 $affectedRows += $this->aUserRelatedByUpdatedBy->save($con);
             }
             $this->setUserRelatedByUpdatedBy($this->aUserRelatedByUpdatedBy);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
             } else {
                 $this->doUpdate($con);
             }
             $affectedRows += 1;
             // Rewind the data LOB column, since PDO does not rewind after inserting value.
             if ($this->data !== null && is_resource($this->data)) {
                 rewind($this->data);
             }
             $this->resetModified();
         }
         if ($this->documentsScheduledForDeletion !== null) {
             if (!$this->documentsScheduledForDeletion->isEmpty()) {
                 DocumentQuery::create()->filterByPrimaryKeys($this->documentsScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->documentsScheduledForDeletion = null;
             }
         }
         if ($this->collDocuments !== null) {
             foreach ($this->collDocuments as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param PropelPDO $con
  * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their corresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aContentObject !== null) {
             if ($this->aContentObject->isModified() || $this->aContentObject->isNew()) {
                 $affectedRows += $this->aContentObject->save($con);
             }
             $this->setContentObject($this->aContentObject);
         }
         if ($this->aLanguage !== null) {
             if ($this->aLanguage->isModified() || $this->aLanguage->isNew()) {
                 $affectedRows += $this->aLanguage->save($con);
             }
             $this->setLanguage($this->aLanguage);
         }
         if ($this->aUserRelatedByCreatedBy !== null) {
             if ($this->aUserRelatedByCreatedBy->isModified() || $this->aUserRelatedByCreatedBy->isNew()) {
                 $affectedRows += $this->aUserRelatedByCreatedBy->save($con);
             }
             $this->setUserRelatedByCreatedBy($this->aUserRelatedByCreatedBy);
         }
         if ($this->aUserRelatedByUpdatedBy !== null) {
             if ($this->aUserRelatedByUpdatedBy->isModified() || $this->aUserRelatedByUpdatedBy->isNew()) {
                 $affectedRows += $this->aUserRelatedByUpdatedBy->save($con);
             }
             $this->setUserRelatedByUpdatedBy($this->aUserRelatedByUpdatedBy);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
             } else {
                 $this->doUpdate($con);
             }
             $affectedRows += 1;
             // Rewind the data LOB column, since PDO does not rewind after inserting value.
             if ($this->data !== null && is_resource($this->data)) {
                 rewind($this->data);
             }
             $this->resetModified();
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
Example #10
0
 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param PropelPDO $con
  * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their corresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aUserRelatedByCreatedBy !== null) {
             if ($this->aUserRelatedByCreatedBy->isModified() || $this->aUserRelatedByCreatedBy->isNew()) {
                 $affectedRows += $this->aUserRelatedByCreatedBy->save($con);
             }
             $this->setUserRelatedByCreatedBy($this->aUserRelatedByCreatedBy);
         }
         if ($this->aUserRelatedByUpdatedBy !== null) {
             if ($this->aUserRelatedByUpdatedBy->isModified() || $this->aUserRelatedByUpdatedBy->isNew()) {
                 $affectedRows += $this->aUserRelatedByUpdatedBy->save($con);
             }
             $this->setUserRelatedByUpdatedBy($this->aUserRelatedByUpdatedBy);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
             } else {
                 $this->doUpdate($con);
             }
             $affectedRows += 1;
             $this->resetModified();
         }
         if ($this->documentsScheduledForDeletion !== null) {
             if (!$this->documentsScheduledForDeletion->isEmpty()) {
                 foreach ($this->documentsScheduledForDeletion as $document) {
                     // need to save related object because we set the relation to null
                     $document->save($con);
                 }
                 $this->documentsScheduledForDeletion = null;
             }
         }
         if ($this->collDocuments !== null) {
             foreach ($this->collDocuments as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
Example #11
0
 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param      PropelPDO $con
  * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aUser !== null) {
             if ($this->aUser->isModified() || $this->aUser->isNew()) {
                 $affectedRows += $this->aUser->save($con);
             }
             $this->setUser($this->aUser);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
             } else {
                 $this->doUpdate($con);
             }
             $affectedRows += 1;
             // Rewind the data LOB column, since PDO does not rewind after inserting value.
             if ($this->data !== null && is_resource($this->data)) {
                 rewind($this->data);
             }
             $this->resetModified();
         }
         if ($this->singleSignOnKeysScheduledForDeletion !== null) {
             if (!$this->singleSignOnKeysScheduledForDeletion->isEmpty()) {
                 foreach ($this->singleSignOnKeysScheduledForDeletion as $singleSignOnKey) {
                     // need to save related object because we set the relation to null
                     $singleSignOnKey->save($con);
                 }
                 $this->singleSignOnKeysScheduledForDeletion = null;
             }
         }
         if ($this->collSingleSignOnKeys !== null) {
             foreach ($this->collSingleSignOnKeys as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param      PropelPDO $con
  * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aSystemEvent !== null) {
             if ($this->aSystemEvent->isModified() || $this->aSystemEvent->isNew()) {
                 $affectedRows += $this->aSystemEvent->save($con);
             }
             $this->setSystemEvent($this->aSystemEvent);
         }
         if ($this->aUser !== null) {
             if ($this->aUser->isModified() || $this->aUser->isNew()) {
                 $affectedRows += $this->aUser->save($con);
             }
             $this->setUser($this->aUser);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
             } else {
                 $this->doUpdate($con);
             }
             $affectedRows += 1;
             $this->resetModified();
         }
         if ($this->systemEventInstanceMessagesScheduledForDeletion !== null) {
             if (!$this->systemEventInstanceMessagesScheduledForDeletion->isEmpty()) {
                 SystemEventInstanceMessageQuery::create()->filterByPrimaryKeys($this->systemEventInstanceMessagesScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->systemEventInstanceMessagesScheduledForDeletion = null;
             }
         }
         if ($this->collSystemEventInstanceMessages !== null) {
             foreach ($this->collSystemEventInstanceMessages as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param      PropelPDO $con
  * @return     int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws     PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aGroup !== null) {
             if ($this->aGroup->isModified() || $this->aGroup->isNew()) {
                 $affectedRows += $this->aGroup->save($con);
             }
             $this->setGroup($this->aGroup);
         }
         if ($this->aUser !== null) {
             if ($this->aUser->isModified() || $this->aUser->isNew()) {
                 $affectedRows += $this->aUser->save($con);
             }
             $this->setUser($this->aUser);
         }
         if ($this->isNew()) {
             $this->modifiedColumns[] = DirectoryPermissionPeer::ID;
         }
         // If this object has been modified, then save it to the database.
         if ($this->isModified()) {
             if ($this->isNew()) {
                 $criteria = $this->buildCriteria();
                 if ($criteria->keyContainsValue(DirectoryPermissionPeer::ID)) {
                     throw new PropelException('Cannot insert a value for auto-increment primary key (' . DirectoryPermissionPeer::ID . ')');
                 }
                 $pk = BasePeer::doInsert($criteria, $con);
                 $affectedRows += 1;
                 $this->setId($pk);
                 //[IMV] update autoincrement primary key
                 $this->setNew(false);
             } else {
                 $affectedRows += DirectoryPermissionPeer::doUpdate($this, $con);
             }
             $this->resetModified();
             // [HL] After being saved an object is no longer 'modified'
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
Example #14
0
 public function update(User $object)
 {
     $q = "UPDATE " . self::TABLE . " SET `firstName`='" . Singleton::create("NullConverter")->fromDOMtoDB($object->getFirstName()) . "', `lastName`='" . Singleton::create("NullConverter")->fromDOMtoDB($object->getLastName()) . "', `createDate`='" . Singleton::create("DateConverter")->fromDOMtoDB($object->getCreateDate()) . "', `default`='" . Singleton::create("BooleanConverter")->fromDOMtoDB($object->isDefault()) . "' WHERE id='" . addslashes($object->getId()) . "'";
     $pk = $object->getId();
     if ($object->isNew()) {
         if (empty($pk)) {
             $q = "INSERT INTO " . self::TABLE . " (`firstName`, `lastName`, `createDate`, `default`) VALUES ('" . Singleton::create("NullConverter")->fromDOMtoDB($object->getFirstName()) . "', '" . Singleton::create("NullConverter")->fromDOMtoDB($object->getLastName()) . "', '" . Singleton::create("DateConverter")->fromDOMtoDB($object->getCreateDate()) . "', '" . Singleton::create("BooleanConverter")->fromDOMtoDB($object->isDefault()) . "')";
         } else {
             $q = "INSERT INTO " . self::TABLE . " (`firstName`, `lastName`, `createDate`, `default`) VALUES ('" . Singleton::create("NullConverter")->fromDOMtoDB($object->getId()) . "', '" . Singleton::create("NullConverter")->fromDOMtoDB($object->getFirstName()) . "', '" . Singleton::create("NullConverter")->fromDOMtoDB($object->getLastName()) . "', '" . Singleton::create("DateConverter")->fromDOMtoDB($object->getCreateDate()) . "', '" . Singleton::create("BooleanConverter")->fromDOMtoDB($object->isDefault()) . "')";
         }
     }
     $this->db->updateQuery($q);
     if (empty($pk)) {
         $pk = $this->db->selectQuery("SELECT id from " . self::TABLE . " ORDER BY id DESC limit 1")->getSingleton();
     }
     $result = $this->findByPrimaryKey($pk);
     parent::$dbCache->resetEntity("User");
     parent::$dbCache->setSingle("User", $pk, $result);
     return $result;
 }
Example #15
0
 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param PropelPDO $con
  * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their corresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aPageRelatedByCanonicalId !== null) {
             if ($this->aPageRelatedByCanonicalId->isModified() || $this->aPageRelatedByCanonicalId->isNew()) {
                 $affectedRows += $this->aPageRelatedByCanonicalId->save($con);
             }
             $this->setPageRelatedByCanonicalId($this->aPageRelatedByCanonicalId);
         }
         if ($this->aUserRelatedByCreatedBy !== null) {
             if ($this->aUserRelatedByCreatedBy->isModified() || $this->aUserRelatedByCreatedBy->isNew()) {
                 $affectedRows += $this->aUserRelatedByCreatedBy->save($con);
             }
             $this->setUserRelatedByCreatedBy($this->aUserRelatedByCreatedBy);
         }
         if ($this->aUserRelatedByUpdatedBy !== null) {
             if ($this->aUserRelatedByUpdatedBy->isModified() || $this->aUserRelatedByUpdatedBy->isNew()) {
                 $affectedRows += $this->aUserRelatedByUpdatedBy->save($con);
             }
             $this->setUserRelatedByUpdatedBy($this->aUserRelatedByUpdatedBy);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
             } else {
                 $this->doUpdate($con);
             }
             $affectedRows += 1;
             $this->resetModified();
         }
         if ($this->pagesRelatedByIdScheduledForDeletion !== null) {
             if (!$this->pagesRelatedByIdScheduledForDeletion->isEmpty()) {
                 foreach ($this->pagesRelatedByIdScheduledForDeletion as $pageRelatedById) {
                     // need to save related object because we set the relation to null
                     $pageRelatedById->save($con);
                 }
                 $this->pagesRelatedByIdScheduledForDeletion = null;
             }
         }
         if ($this->collPagesRelatedById !== null) {
             foreach ($this->collPagesRelatedById as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->pagePropertysScheduledForDeletion !== null) {
             if (!$this->pagePropertysScheduledForDeletion->isEmpty()) {
                 PagePropertyQuery::create()->filterByPrimaryKeys($this->pagePropertysScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->pagePropertysScheduledForDeletion = null;
             }
         }
         if ($this->collPagePropertys !== null) {
             foreach ($this->collPagePropertys as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->pageStringsScheduledForDeletion !== null) {
             if (!$this->pageStringsScheduledForDeletion->isEmpty()) {
                 PageStringQuery::create()->filterByPrimaryKeys($this->pageStringsScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->pageStringsScheduledForDeletion = null;
             }
         }
         if ($this->collPageStrings !== null) {
             foreach ($this->collPageStrings as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->contentObjectsScheduledForDeletion !== null) {
             if (!$this->contentObjectsScheduledForDeletion->isEmpty()) {
                 ContentObjectQuery::create()->filterByPrimaryKeys($this->contentObjectsScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->contentObjectsScheduledForDeletion = null;
             }
         }
         if ($this->collContentObjects !== null) {
             foreach ($this->collContentObjects as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->rightsScheduledForDeletion !== null) {
             if (!$this->rightsScheduledForDeletion->isEmpty()) {
                 RightQuery::create()->filterByPrimaryKeys($this->rightsScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->rightsScheduledForDeletion = null;
             }
         }
         if ($this->collRights !== null) {
             foreach ($this->collRights as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
Example #16
0
 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param PropelPDO $con
  * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aUserRelatedByCreatorId !== null) {
             if ($this->aUserRelatedByCreatorId->isModified() || $this->aUserRelatedByCreatorId->isNew()) {
                 $affectedRows += $this->aUserRelatedByCreatorId->save($con);
             }
             $this->setUserRelatedByCreatorId($this->aUserRelatedByCreatorId);
         }
         if ($this->aClockingType !== null) {
             if ($this->aClockingType->isModified() || $this->aClockingType->isNew()) {
                 $affectedRows += $this->aClockingType->save($con);
             }
             $this->setClockingType($this->aClockingType);
         }
         if ($this->aUserRelatedByUserId !== null) {
             if ($this->aUserRelatedByUserId->isModified() || $this->aUserRelatedByUserId->isNew()) {
                 $affectedRows += $this->aUserRelatedByUserId->save($con);
             }
             $this->setUserRelatedByUserId($this->aUserRelatedByUserId);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
             } else {
                 $this->doUpdate($con);
             }
             $affectedRows += 1;
             $this->resetModified();
         }
         if ($this->transactionClockingsScheduledForDeletion !== null) {
             if (!$this->transactionClockingsScheduledForDeletion->isEmpty()) {
                 TransactionClockingQuery::create()->filterByPrimaryKeys($this->transactionClockingsScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->transactionClockingsScheduledForDeletion = null;
             }
         }
         if ($this->collTransactionClockings !== null) {
             foreach ($this->collTransactionClockings as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
 /**
  * getUser
  *
  */
 function getUser($username, $password)
 {
     // the sql should be like this:
     // select somefield as email from sometable where anotherfield = $username limit 1
     // the expression 'as email' is important because the field is referenced as 'email'
     $sql = config_option('authdb sql', '');
     $sql = str_replace('$username', $username, $sql);
     $sql = str_replace('$password', $password, $sql);
     $result = mysql_query($sql, $this->link);
     if ($result) {
         $limit = mysql_num_rows($result);
         if ($limit == 1) {
             $row = mysql_fetch_assoc($result);
             $pass = array_var($row, 'password', $password);
             $email = array_var($row, 'email', '*****@*****.**');
             $user = Users::getByUsername($username, owner_company());
             if (!$user instanceof User) {
                 // option 1
                 // create a new user when authenticated
                 $user = new User();
                 // option 2
                 // allow only login for existing PP user
                 // throw new Error('invalid login data');
             }
             // if
             $user->setPassword($pass);
             $user->setEmail($email);
             if ($user->isNew()) {
                 $user->setUsername($username);
                 $user->setIsAdmin(0);
                 $user->setAutoAssign(0);
                 $user->setUseLDAP(0);
             }
             $user->save();
             return $user;
         }
     }
     throw new Error('invalid login data');
 }
Example #18
0
 /**
  * Save user.
  *
  * @param User $user
  * @param Curry_Form_ModelForm $form
  */
 protected function saveUser(User $user, Curry_Form_ModelForm $form)
 {
     $values = $form->getValues();
     $password = $values['password'];
     if ($password || $user->isNew()) {
         $user->setPlainPassword($password);
     }
     $form->removeElement('password');
     $form->fillModel($user);
     $user->save();
     $home = self::getUserHome($user, true);
     if ($values['create_home_folder']) {
         $folder = Curry_Core::$config->curry->wwwPath . DIRECTORY_SEPARATOR;
         $folder .= str_replace('/', DIRECTORY_SEPARATOR, rtrim($home->getPath(), '/'));
         if (!file_exists($folder)) {
             @mkdir($folder, 0777, true);
         }
         if ($home->isNew()) {
             $home->setWrite(true);
             $home->save();
         }
     } else {
         if ($home && !$home->isNew()) {
             $home->delete();
         }
     }
 }
Example #19
0
 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param PropelPDO $con
  * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aUser !== null) {
             if ($this->aUser->isModified() || $this->aUser->isNew()) {
                 $affectedRows += $this->aUser->save($con);
             }
             $this->setUser($this->aUser);
         }
         if ($this->aOrganization !== null) {
             if ($this->aOrganization->isModified() || $this->aOrganization->isNew()) {
                 $affectedRows += $this->aOrganization->save($con);
             }
             $this->setOrganization($this->aOrganization);
         }
         if ($this->aChartRelatedByForkedFrom !== null) {
             if ($this->aChartRelatedByForkedFrom->isModified() || $this->aChartRelatedByForkedFrom->isNew()) {
                 $affectedRows += $this->aChartRelatedByForkedFrom->save($con);
             }
             $this->setChartRelatedByForkedFrom($this->aChartRelatedByForkedFrom);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
             } else {
                 $this->doUpdate($con);
             }
             $affectedRows += 1;
             $this->resetModified();
         }
         if ($this->chartsRelatedByIdScheduledForDeletion !== null) {
             if (!$this->chartsRelatedByIdScheduledForDeletion->isEmpty()) {
                 foreach ($this->chartsRelatedByIdScheduledForDeletion as $chartRelatedById) {
                     // need to save related object because we set the relation to null
                     $chartRelatedById->save($con);
                 }
                 $this->chartsRelatedByIdScheduledForDeletion = null;
             }
         }
         if ($this->collChartsRelatedById !== null) {
             foreach ($this->collChartsRelatedById as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->jobsScheduledForDeletion !== null) {
             if (!$this->jobsScheduledForDeletion->isEmpty()) {
                 JobQuery::create()->filterByPrimaryKeys($this->jobsScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->jobsScheduledForDeletion = null;
             }
         }
         if ($this->collJobs !== null) {
             foreach ($this->collJobs as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
Example #20
0
 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param PropelPDO $con
  * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their corresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aLanguage !== null) {
             if ($this->aLanguage->isModified() || $this->aLanguage->isNew()) {
                 $affectedRows += $this->aLanguage->save($con);
             }
             $this->setLanguage($this->aLanguage);
         }
         if ($this->aUserRelatedByOwnerId !== null) {
             if ($this->aUserRelatedByOwnerId->isModified() || $this->aUserRelatedByOwnerId->isNew()) {
                 $affectedRows += $this->aUserRelatedByOwnerId->save($con);
             }
             $this->setUserRelatedByOwnerId($this->aUserRelatedByOwnerId);
         }
         if ($this->aDocumentType !== null) {
             if ($this->aDocumentType->isModified() || $this->aDocumentType->isNew()) {
                 $affectedRows += $this->aDocumentType->save($con);
             }
             $this->setDocumentType($this->aDocumentType);
         }
         if ($this->aDocumentCategory !== null) {
             if ($this->aDocumentCategory->isModified() || $this->aDocumentCategory->isNew()) {
                 $affectedRows += $this->aDocumentCategory->save($con);
             }
             $this->setDocumentCategory($this->aDocumentCategory);
         }
         if ($this->aDocumentData !== null) {
             if ($this->aDocumentData->isModified() || $this->aDocumentData->isNew()) {
                 $affectedRows += $this->aDocumentData->save($con);
             }
             $this->setDocumentData($this->aDocumentData);
         }
         if ($this->aUserRelatedByCreatedBy !== null) {
             if ($this->aUserRelatedByCreatedBy->isModified() || $this->aUserRelatedByCreatedBy->isNew()) {
                 $affectedRows += $this->aUserRelatedByCreatedBy->save($con);
             }
             $this->setUserRelatedByCreatedBy($this->aUserRelatedByCreatedBy);
         }
         if ($this->aUserRelatedByUpdatedBy !== null) {
             if ($this->aUserRelatedByUpdatedBy->isModified() || $this->aUserRelatedByUpdatedBy->isNew()) {
                 $affectedRows += $this->aUserRelatedByUpdatedBy->save($con);
             }
             $this->setUserRelatedByUpdatedBy($this->aUserRelatedByUpdatedBy);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
             } else {
                 $this->doUpdate($con);
             }
             $affectedRows += 1;
             $this->resetModified();
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }