Example #1
0
 public function insert($data)
 {
     // Cria novo album de fotos
     if ($this->albumModel) {
         $data->album = $this->albumModel->insert($data);
     }
     $this->mapping->fields['name'] = 'accountFirstName';
     $this->mapping->fields['surname'] = 'accountLastName';
     $this->mapping->fields['sex'] = 'accountSex';
     $this->mapping->fields['email'] = 'accountEmail';
     $this->mapping->fields['password'] = '******';
     $this->mapping->fields['news'] = 'accountNews';
     $this->mapping->fields['album'] = 'albumID';
     // Tratamento adicional de dados
     $data->password = md5($data->password);
     $data->news = (int) $data->news;
     try {
         $this->dbh->beginTransaction();
         $newID = parent::insert($data);
         $this->dbh->commit();
         return $newID;
     } catch (PDOException $exception) {
         $this->dbh->rollback();
         $this->modelException(Text::read('message.model.error.insert'), $exception);
     }
 }
Example #2
0
 public function insert($pa_options = null)
 {
     $this->_generateSortableValue();
     // populate sort field
     // invalidate get() prefetch cache
     SearchResult::clearResultCacheForTable($this->tableName());
     return parent::insert($pa_options);
 }
Example #3
0
 public function insert($data)
 {
     $this->mapping->table = 'users_roles';
     $this->mapping->fields['user'] = '******';
     $this->mapping->fields['role'] = 'roleID';
     try {
         parent::insert($data);
     } catch (PDOException $exception) {
         $this->dbh->rollback();
         $this->modelException(get_called_class() . "::" . __FUNCTION__, Text::read('message.model.error.insert'), $exception);
     }
 }
Example #4
0
 public function insert($data)
 {
     $this->mapping->fields['id'] = 'typeID';
     $this->mapping->fields['feature'] = 'featureTitle';
     try {
         $this->dbh->beginTransaction();
         $newID = parent::insert($data);
         $this->dbh->commit();
         return $newID;
     } catch (PDOException $exception) {
         $this->dbh->rollback();
         $this->modelException(Text::read('message.model.error.insert'), $exception);
     }
 }
Example #5
0
 public function insert($data)
 {
     $this->mapping->fields['text'] = 'messageText';
     $this->mapping->fields['product'] = 'productID';
     $this->mapping->fields['account'] = 'accountID';
     $this->mapping->fields['parent'] = 'messageParentID';
     try {
         $this->dbh->beginTransaction();
         $newID = parent::insert($data);
         $this->dbh->commit();
         return $newID;
     } catch (PDOException $exception) {
         $this->dbh->rollback();
         $this->modelException(Text::read('message.model.error.insert'), $exception);
     }
 }
Example #6
0
 public function insert($data)
 {
     $this->mapping->fields['title'] = 'faqTitle';
     $this->mapping->fields['text'] = 'faqText';
     $this->mapping->fields['user'] = '******';
     // Tratamento adicional de dados
     $data->user = $_SESSION['admLogin']->getUserID();
     try {
         $this->dbh->beginTransaction();
         $newID = parent::insert($data);
         $this->dbh->commit();
         return $newID;
     } catch (PDOException $exception) {
         $this->dbh->rollback();
         $this->modelException(get_called_class() . "::" . __FUNCTION__, Text::read('message.model.error.insert'), $exception);
     }
 }
Example #7
0
 public function insert($data)
 {
     $this->mapping->fields['title'] = 'inboxTitle';
     $this->mapping->fields['text'] = 'inboxText';
     $this->mapping->fields['type'] = 'inboxType';
     $this->mapping->fields['reference'] = 'inboxReference';
     $this->mapping->fields['account'] = 'accountID';
     try {
         $this->dbh->beginTransaction();
         $newID = parent::insert($data);
         $this->dbh->commit();
         return $newID;
     } catch (PDOException $exception) {
         $this->dbh->rollback();
         $this->modelException(Text::read('message.model.error.insert'), $exception);
     }
     var_dump($this->getTechnicalMessage());
 }
Example #8
0
 public function insert($data)
 {
     // Cria novo album de fotos
     $data->album = $this->albumModel->insert($data);
     $this->mapping->fields['title'] = 'brandTitle';
     $this->mapping->fields['album'] = 'albumID';
     $this->mapping->fields['user'] = '******';
     // Tratamento adicional de dados
     $data->user = $_SESSION['admLogin']->getUserID();
     try {
         $this->dbh->beginTransaction();
         $newID = parent::insert($data);
         $this->dbh->commit();
         return $newID;
     } catch (PDOException $exception) {
         $this->dbh->rollback();
         $this->modelException(Text::read('message.model.error.insert'), $exception);
     }
 }
Example #9
0
 /**
  * Creates new user record. You must set all required user fields before calling this method. If errors occur you can use the standard Table class error handling methods to figure out what went wrong.
  *
  * Required fields are user_name, password, fname and lname.
  *
  * @access public 
  * @return bool Returns true if no error, false if error occurred
  */
 public function insert($pa_options = null)
 {
     if (!caCheckEmailAddress($this->get('email'))) {
         $this->postError(922, _t("Invalid email address"), 'ca_users->insert()');
         return false;
     }
     # Confirmation key is an md5 hash than can be used as a confirmation token. The idea
     # is that you create a new user record with the 'active' field set to false. You then
     # send the confirmation key to the new user (usually via e-mail) and ask them to respond
     # with the key. If they do, you know that the e-mail address is valid.
     if (function_exists('mcrypt_create_iv')) {
         $vs_confirmation_key = md5(mcrypt_create_iv(24, MCRYPT_DEV_URANDOM));
     } else {
         $vs_confirmation_key = md5(uniqid(mt_rand(), true));
     }
     $this->set("confirmation_key", $vs_confirmation_key);
     try {
         $vs_backend_password = AuthenticationManager::createUserAndGetPassword($this->get('user_name'), $this->get('password'));
         $this->set('password', $vs_backend_password);
     } catch (AuthClassFeatureException $e) {
         // auth class does not implement creating users at all
         $this->postError(925, _t("Current authentication adapter does not support creating new users."), 'ca_users->insert()');
         return false;
     } catch (Exception $e) {
         // some other error in auth class, e.g. user couldn't be found in directory
         $this->postError(925, $e->getMessage(), 'ca_users->insert()');
         $this->opo_log->log(array('CODE' => 'SYS', 'SOURCE' => 'ca_users/insert', 'MESSAGE' => _t('Authentication adapter could not create user. Message was: %1', $e->getMessage())));
         return false;
     }
     # set user vars (the set() method automatically serializes the vars array)
     $this->set("vars", $this->opa_user_vars);
     $this->set("volatile_vars", $this->opa_volatile_user_vars);
     return parent::insert($pa_options);
 }
Example #10
0
 public function insert($data)
 {
     $this->mapping->fields['login'] = '******';
     $this->mapping->fields['name'] = 'userName';
     $this->mapping->fields['email'] = 'userEmail';
     $this->mapping->fields['password'] = '******';
     $this->mapping->fields['blocked'] = 'userBlocked';
     $this->mapping->fields['user'] = '******';
     // Tratamento adicional de dados
     $data->password = md5($data->password);
     $data->blocked = $data->blocked ? 1 : 0;
     $data->user = $_SESSION['admLogin']->getUserID();
     try {
         $this->dbh->beginTransaction();
         $newID = parent::insert($data);
         if (is_array($data->roles)) {
             // Adiciona funções do usuário
             $roleData = new stdclass();
             $roleData->user = $newID;
             foreach ($data->roles as $role) {
                 $roleData->role = $role;
                 $this->roleModel->insert($roleData);
             }
         }
         $this->dbh->commit();
         return $newID;
     } catch (PDOException $exception) {
         $this->dbh->rollback();
         $this->modelException(get_called_class() . "::" . __FUNCTION__, Text::read('message.model.error.insert'), $exception);
     }
 }
Example #11
0
 public function insert(array $data)
 {
     if ($this->config['useAcl']) {
         // check rights
         if (!$this->user->isAllowed(Acl::RESOURCE_USER, Acl::PRIVILEGE_ADD)) {
             throw new OperationNotAllowedException();
         }
     }
     $data['token'] = md5($data['email'] . $data['username']);
     $data['registered'] = dibi::datetime();
     if (isset($data['roles'])) {
         $roles = $data['roles'];
         unset($data['roles']);
     }
     if (isset($data['client_logo'])) {
         $clientLogo = $data['client_logo'];
         unset($data['client_logo']);
     }
     // create user and update his password - needed because getHasherParamsFromUserData() requires $userId
     try {
         dibi::begin();
         // save random password temporarily
         $realPassword = $data['password'];
         $data['password'] = Basic::randomizer(40);
         $userId = parent::insert($data);
         $data['password'] = $realPassword;
         $this->update($userId, $data);
         dibi::commit();
     } catch (DibiDriverException $e) {
         dibi::rollback();
         throw $e;
     }
     if (isset($roles)) {
         $this->getRolesModel()->updateUserRoles($userId, (array) $roles);
     }
     if (!empty($clientLogo)) {
         $this->saveClientLogo($userId, $clientLogo);
     }
     return $userId;
 }
Example #12
0
 public function insert($pa_options = null)
 {
     $this->_generateSortableValue();
     // populate sort field
     return parent::insert($pa_options);
 }
Example #13
0
 public function insert($data)
 {
     // Cria novo album de fotos
     $data->album = $this->albumModel->insert($data);
     // Converte preço para formato do Banco
     $data->price = str_replace(',', '.', $data->price);
     $data->discount = str_replace(',', '.', $data->discount);
     $this->mapping->fields['name'] = 'productName';
     $this->mapping->fields['text'] = 'productDescription';
     $this->mapping->fields['type'] = 'typeID';
     $this->mapping->fields['subtype'] = 'subTypeID';
     $this->mapping->fields['brand'] = 'brandID';
     $this->mapping->fields['price'] = 'productPrice';
     $this->mapping->fields['discount'] = 'productDiscount';
     $this->mapping->fields['account'] = 'accountID';
     $this->mapping->fields['album'] = 'albumID';
     try {
         $this->dbh->beginTransaction();
         $newID = parent::insert($data);
         $this->dbh->commit();
         return $newID;
     } catch (PDOException $exception) {
         $this->dbh->rollback();
         $this->modelException(Text::read('message.model.error.insert'), $exception);
     }
 }
Example #14
0
 public function insert($data)
 {
     $this->mapping->fields['product'] = 'productID';
     $this->mapping->fields['buyer'] = 'buyerID';
     $this->mapping->fields['vendor'] = 'vendorID';
     $this->mapping->fields['shipping'] = 'orderShippingType';
     if ($this->addressModel) {
         $this->mapping->fields = array_merge($this->mapping->fields, $this->addressModel->addressMapping());
     }
     try {
         $this->dbh->beginTransaction();
         $newID = parent::insert($data);
         $this->dbh->commit();
         return $newID;
     } catch (PDOException $exception) {
         $this->dbh->rollback();
         $this->modelException(Text::read('message.model.error.insert'), $exception);
     }
 }
 /**
  *
  */
 public function insert($pa_options = null)
 {
     $t_trans = new ca_commerce_transactions($this->get('transaction_id'));
     if ($t_trans->getPrimaryKey()) {
         if ($vn_set_id = $t_trans->get('set_id')) {
             $t_set = new ca_sets($vn_set_id);
             if ($t_set->getPrimaryKey()) {
                 $va_row_ids = $t_set->getItemRowIDs();
                 $this->set('set_snapshot', array('table_num' => $t_set->get('table_num'), 'set_id' => $vn_set_id, 'datetime' => time(), 'items' => $va_row_ids));
             }
         }
         return parent::insert($pa_options);
     } else {
         $this->postError(1500, _t('Transaction does not exist'), 'ca_commerce_communications->insert()');
         return false;
     }
 }
Example #16
0
 /**
  * Creates new user record. You must set all required user fields before calling this method. If errors occur you can use the standard Table class error handling methods to figure out what went wrong.
  *
  * Required fields are user_name, password, fname and lname.
  *
  * @access public 
  * @return bool Returns true if no error, false if error occurred
  */
 public function insert($pa_options = null)
 {
     # Confirmation key is an md5 hash than can be used as a confirmation token. The idea
     # is that you create a new user record with the 'active' field set to false. You then
     # send the confirmation key to the new user (usually via e-mail) and ask them to respond
     # with the key. If they do, you know that the e-mail address is valid.
     $vs_confirmation_key = md5(tempnam(caGetTempDirPath(), "meow") . time() . rand(1000, 999999999));
     $this->set("confirmation_key", $vs_confirmation_key);
     # set user vars (the set() method automatically serializes the vars array)
     $this->set("vars", $this->opa_user_vars);
     $this->set("volatile_vars", $this->opa_volatile_user_vars);
     return parent::insert($pa_options);
 }
Example #17
0
 public function insert($data)
 {
     $this->mapping->fields['id'] = 'photoID';
     $this->mapping->fields['album'] = 'albumID';
     $this->mapping->fields['url'] = 'photoUrl';
     $this->mapping->fields['vertical'] = 'isVertical';
     try {
         $this->dbh->beginTransaction();
         $newID = parent::insert($data);
         $this->dbh->commit();
         return $newID;
     } catch (PDOException $exception) {
         $this->dbh->rollback();
         $this->modelException(Text::read('message.model.error.insert'), $exception);
     }
 }
 public function insert($pa_options = null)
 {
     $vb_we_set_transaction = false;
     if (!$this->inTransaction()) {
         $this->setTransaction(new Transaction($this->getDb()));
         $vb_we_set_transaction = true;
     }
     $vb_web_set_change_log_unit_id = BaseModel::setChangeLogUnitID();
     if (!is_array($pa_options)) {
         $pa_options = array();
     }
     $pa_options['dont_do_search_indexing'] = true;
     $va_field_values = $this->getFieldValuesArray();
     // get pre-insert field values (including attribute values)
     // change status for attributes is only available **before** insert
     $va_fields_changed_array = $this->_FIELD_VALUE_CHANGED;
     if ($vn_id = parent::insert($pa_options)) {
         $this->_commitAttributes($this->getTransaction());
         if (sizeof($this->opa_failed_attribute_inserts)) {
             if ($vb_we_set_transaction) {
                 $this->removeTransaction(false);
             }
             $this->_FIELD_VALUES[$this->primaryKey()] = null;
             // clear primary key set by BaseModel::insert()
             return false;
         }
         $va_field_values_with_updated_attributes = $this->addAttributesToFieldValuesArray();
         // copy committed attribute values to field values array
         // set changed flag for attributes that have changed
         foreach ($va_field_values_with_updated_attributes as $vs_k => $vs_v) {
             if (!isset($va_field_values[$vs_k])) {
                 $va_field_values[$vs_k] = null;
             }
             if ($va_field_values[$vs_k] != $vs_v) {
                 $this->_FIELD_VALUE_CHANGED[$vs_k] = true;
             }
         }
         // set the field values array for this instance
         //$this->setFieldValuesArray($va_field_values_with_updated_attributes);
         $this->doSearchIndexing(array_merge($this->getFieldValuesArray(true), $va_fields_changed_array), false, array('isNewRow' => true));
         if ($vb_web_set_change_log_unit_id) {
             BaseModel::unsetChangeLogUnitID();
         }
         if ($this->numErrors() > 0) {
             if ($vb_we_set_transaction) {
                 $this->removeTransaction(false);
             }
             $this->_FIELD_VALUES[$this->primaryKey()] = null;
             // clear primary key set by BaseModel::insert()
             return false;
         }
         if ($vb_we_set_transaction) {
             $this->removeTransaction(true);
         }
         return $vn_id;
     } else {
         // push all attributes onto errored list
         $va_inserted_attributes_that_errored = array();
         foreach ($this->opa_attributes_to_add as $va_info) {
             $va_inserted_attributes_that_errored[$va_info['element']][] = $va_info['values'];
         }
         foreach ($va_inserted_attributes_that_errored as $vs_element => $va_list) {
             $this->setFailedAttributeInserts($vs_element, $va_list);
         }
     }
     if ($vb_web_set_change_log_unit_id) {
         BaseModel::unsetChangeLogUnitID();
     }
     if ($vb_we_set_transaction) {
         $this->removeTransaction(false);
     }
     $this->_FIELD_VALUES[$this->primaryKey()] = null;
     // clear primary key set by BaseModel::insert()
     return false;
 }
Example #19
0
 public function insert($pa_options = null)
 {
     $vm_rc = parent::insert($pa_options);
     $this->flushLocaleListCache();
     return $vm_rc;
 }
 public function insert($pa_options = null)
 {
     $this->set('ip_addr', $_SERVER['REMOTE_ADDR']);
     return parent::insert($pa_options);
 }
 public function insert($pa_options = null)
 {
     if (!$this->_preSaveActions()) {
         return false;
     }
     $vn_rc = parent::insert($pa_options);
     $this->_postSaveActions();
     return $vn_rc;
 }
Example #22
0
 public function insert($pa_options = null)
 {
     if (!$this->_preSaveActions()) {
         return false;
     }
     if ($vn_rc = parent::insert($pa_options)) {
         $this->sendStatusChangeEmailNotification(null, null, null);
         $this->set('order_number', ca_commerce_orders::generateOrderNumber($this->getPrimaryKey(), $this->get('created_on', array('GET_DIRECT_DATE' => true))));
         parent::update();
     }
     return $vn_rc;
 }