Example #1
0
 function update($data, Criteria $c)
 {
     parent::update($data, $c);
     $comment = $this->find($c);
     $siteId = $comment->siteId;
     $this->updateSiteCommentsCount($siteId);
 }
Example #2
0
 public function edit($postArr)
 {
     if (empty($postArr['Id'])) {
         return array('status' => -1, 'msg' => '请选择要更新的问卷', 'href' => 1);
     }
     if (empty($postArr['title'])) {
         return array('status' => -1, 'msg' => '请填写标题', 'href' => 1);
     }
     if (empty($postArr['description'])) {
         return array('status' => -1, 'msg' => '请填写描述', 'href' => 1);
     }
     if (empty($postArr['start_time'])) {
         return array('status' => -1, 'msg' => '请选择开始时间', 'href' => 1);
     }
     if (empty($postArr['end_time'])) {
         return array('status' => -1, 'msg' => '请选择结束时间', 'href' => 1);
     }
     $this->_utilRbac = $this->_getGlobalData('Util_Rbac', 'object');
     $userClass = $this->_utilRbac->getUserClass();
     $updateArr = array();
     $updateArr['title'] = $postArr['title'];
     $updateArr['description'] = $postArr['description'];
     $updateArr['start_time'] = strtotime($postArr['start_time']);
     $updateArr['end_time'] = strtotime($postArr['end_time']);
     $updateArr['status'] = $postArr['status'];
     $updateArr['user_id'] = $userClass['_id'];
     if (parent::update($updateArr, "Id={$postArr['Id']}")) {
         return array('status' => 1, 'msg' => false, 'href' => 1);
     } else {
         return array('status' => -2, 'msg' => '编辑问卷失败', 'href' => 1);
     }
 }
Example #3
0
 /**
  *
  */
 public function update($data, $cond = null, $bind_params = null)
 {
     $cond = 'WHERE id = :id';
     $bind_params = array(':id' => $data[$this->table_name]['id']);
     $res = parent::update($data, $cond, $bind_params);
     return $res;
 }
Example #4
0
 /**
  * Save user data
  * 
  * @param type $userInfo
  * @return int userId
  */
 public function save($userInfo)
 {
     if (isset($userInfo["id"]) && (int) $userInfo["id"] > 0) {
         return parent::update($userInfo, array('id' => $userInfo["id"]));
     } else {
         return parent::create($userInfo);
     }
 }
 public function setLoginDetails()
 {
     $where = array("user='******'user']}'");
     $updateData['login_count'] = array('login_count+1');
     $updateData['last_ip'] = Tool::getIP();
     $updateData['last_time'] = Tool::getDate();
     parent::update($where, $updateData);
 }
 public function selected()
 {
     $where = array("id='{$this->R['id']}'");
     if (!$this->check->checkOne($this, $where)) {
         $this->check->showError();
     }
     parent::update(array("user='******'user']}'"), array('selected' => 0));
     return parent::update($where, array('selected' => 1));
 }
 public function setFirst()
 {
     $where = array("id='{$this->R['id']}'");
     if (!$this->check->checkOne($this, array("id='{$this->R['id']}'"))) {
         $this->check->showError();
     }
     parent::update(array("first=1"), array('first' => 0));
     return parent::update($where, array('first' => 1));
 }
Example #8
0
 /**
  * @param $id
  * @param array $values
  * @param array $valuesUnescaped
  * @throws DbalException
  * @return bool|int|string
  */
 public function updateById($id, $values = array(), $valuesUnescaped = array())
 {
     if (!intval($id)) {
         throw new DbalException('Id required');
     }
     $this->deleteNonExistingColumns($values);
     $this->deleteNonExistingColumns($valuesUnescaped);
     return $this->model->update($this->table, $this->idColum, intval($id), $values, $valuesUnescaped);
 }
Example #9
0
 /**
  * 更新用户信息
  *
  * @param int $uid
  * @param array $setdata
  * @return bool
  */
 public function updateUser($uid, $setdata)
 {
     $updata = array();
     foreach ($setdata as $key => $val) {
         $updata[$key] = addslashes(trim($val));
     }
     unset($setdata);
     $where = $this->getAdapter()->bind('uid = ?', $uid);
     return parent::update($updata, $where);
 }
Example #10
0
 public static function edit($fields, $id)
 {
     ///clean all fields so they are not harmful to the database
     $fields = Model::cleanData($fields);
     //construct sql query to update username
     $sql = 'UPDATE posts SET title = "' . $fields['title'] . '", text = "' . $fields['text'] . '" WHERE id = ' . $id;
     $results = Model::update($sql);
     //return results to controller
     return $results;
 }
Example #11
0
 function update()
 {
     // clear all null keys (use array_filter?)
     foreach ($this->rs as $k => $v) {
         if (is_null($v)) {
             unset($this->rs[$k]);
         }
     }
     $this->rs['updated'] = time('now');
     return parent::update();
 }
Example #12
0
 private function updateData()
 {
     $tempData = reset($this->modelInstance->getWithField2($this->secondaryKey, $this->modelData[$this->secondaryKey]));
     if ($tempData !== false) {
         if ($this->tertiaryKey != "") {
             $this->modelData[$this->primaryKey] = $tempData[$this->primaryKey];
             $this->modelData[$this->tertiaryKey] = $tempData[$this->tertiaryKey];
         }
         $validated = $this->modelInstance->setData($this->modelData, $this->primaryKey, $tempData[$this->primaryKey]);
         if ($validated === true) {
             $this->modelInstance->update($this->primaryKey, $tempData[$this->primaryKey]);
             $this->updated++;
             return 'Updated';
         } else {
             return $validated;
         }
     } else {
         return $this->addData();
     }
 }
 public function update()
 {
     $where = array("id='{$this->R['id']}'");
     if (!$this->check->checkOne($this, $where)) {
         $this->check->showError();
     }
     if (!$this->check->checkUpdate($this)) {
         $this->check->showError();
     }
     $updateData = $this->getRequest()->filter($this->fields);
     return parent::update($where, $updateData);
 }
Example #14
0
 public function update()
 {
     $_where = array("id='{$this->_R['id']}'");
     if (!$this->_check->oneCheck($this, $_where)) {
         $this->_check->error();
     }
     if (!$this->_check->updateCheck($this)) {
         $this->_check->error();
     }
     $_updateData = $this->getRequest()->filter($this->_fields);
     return parent::update($_where, $_updateData);
 }
 public function update()
 {
     $where = array("id='{$this->R['id']}'");
     if (!$this->check->checkOne($this, $where)) {
         $this->check->showError();
     }
     if (!$this->check->checkUpdate($this, array("id<>'{$this->R['id']}'", "name='{$this->R['name']}'"))) {
         $this->check->showError();
     }
     $updateData = $this->getRequest()->filter($this->fields);
     $updateData['nav'] = implode(',', $updateData['nav']);
     return parent::update($where, $updateData);
 }
Example #16
0
 public function update($keyvalue, $conditions)
 {
     parent::update($keyvalue, $conditions);
     #------记录日志(生成msg)-------#
     $logArr = array();
     array_push($logArr, '修改了一条FAQ分类');
     array_push($logArr, "修改FAQ分类名称[{$keyvalue['name']}]");
     array_push($logArr, "FAQ分类ID [{$conditions}]");
     $msg = Tools::formatLog($logArr);
     Tools::addLog($msg, true);
     return true;
     #------记录日志(生成msg)-------#
 }
Example #17
0
 function website()
 {
     global $db;
     //判断是否登陆
     !isset($_SESSION['user']) && exit('Please login!');
     if (isset($_POST['edit'])) {
         $Model = new Model('website_info');
         $rs = $Model->update();
         $Model->msg($rs, '修改网站信息成功!', '修改网站信息失败!');
     }
     $rs_website = $db->row_query_one("SELECT * FROM website_info");
     tpl('website', 'rs_website', $rs_website);
 }
Example #18
0
 public function selected()
 {
     $_where = array("user='******'user']}'");
     $_updateData['selected'] = 0;
     parent::update($_where, $_updateData);
     if (isset($_GET['id'])) {
         $_where = array("id='{$this->_R['id']}'");
     } else {
         $_id = $this->select(array('id'), array('limit' => '1', 'order' => 'id DESC', 'where' => array("user='******'user']}'")));
         $_where = array("user='******'user']}'", "id='{$_id[0]->id}'");
     }
     $_updateData['selected'] = 1;
     return parent::update($_where, $_updateData);
 }
Example #19
0
File: row.php Project: pnixx/boot
 /**
  * Сохраняет данные
  * @return bool|int
  */
 public function save()
 {
     //Если был прочитан из базы
     if (isset($this->_row->id) && count($this->_row_update) > 0) {
         $update = array();
         //Собираем массив
         foreach ($this->_row_update as $column) {
             $update[$column] = $this->_row->{$column};
         }
         //Обновляем
         $result = $this->_model_instance->update($update, "id = " . $this->_row->id);
         $this->_row_update = array();
         return $result;
     }
     return false;
 }
 /**
  * Save values in the *_field_values table
  * @param array $params Structured array with the values to save
  * @param boolean $show_query Whether to show the insert query (passed to the parent save() method)
  * @result mixed The result sent from the parent method
  * @assert (array()) === false
  */
 public function save($params, $show_query = false)
 {
     $extra_field = $this->getExtraField();
     // Setting value to insert.
     $value = $params['value'];
     $value_to_insert = null;
     if (is_array($value)) {
         $value_to_insert = implode(';', $value);
     } else {
         $value_to_insert = Database::escape_string($value);
     }
     $params['value'] = $value_to_insert;
     // If field id exists
     if (isset($params['field_id'])) {
         $extraFieldInfo = $extra_field->get($params['field_id']);
     } else {
         // Try the variable
         $extraFieldInfo = $extra_field->get_handler_field_info_by_field_variable($params['variable']);
         $params['field_id'] = $extraFieldInfo['id'];
     }
     if ($extraFieldInfo) {
         switch ($extraFieldInfo['field_type']) {
             case ExtraField::FIELD_TYPE_RADIO:
             case ExtraField::FIELD_TYPE_SELECT:
                 break;
             case ExtraField::FIELD_TYPE_SELECT_MULTIPLE:
                 //$field_options = $session_field_option->get_field_options_by_field($params['field_id']);
                 //$params['field_value'] = split(';', $value_to_insert);
                 /*
                                         if ($field_options) {
                                             $check = false;
                                             foreach ($field_options as $option) {
                                                 if (in_array($option['option_value'], $values)) {
                                                     $check = true;
                                                     break;
                                                 }
                                            }
                                            if (!$check) {
                                                return false; //option value not found
                                            }
                                        } else {
                                            return false; //enumerated type but no option found
                                        }*/
                 break;
             case ExtraField::FIELD_TYPE_TEXT:
             case ExtraField::FIELD_TYPE_TEXTAREA:
                 break;
             case ExtraField::FIELD_TYPE_DOUBLE_SELECT:
                 if (is_array($value)) {
                     if (isset($value['extra_' . $extraFieldInfo['variable']]) && isset($value['extra_' . $extraFieldInfo['variable'] . '_second'])) {
                         $value_to_insert = $value['extra_' . $extraFieldInfo['variable']] . '::' . $value['extra_' . $extraFieldInfo['variable'] . '_second'];
                     } else {
                         $value_to_insert = null;
                     }
                 }
                 break;
             default:
                 break;
         }
         if ($extraFieldInfo['field_type'] == ExtraField::FIELD_TYPE_TAG) {
             $field_values = self::getAllValuesByItemAndFieldAndValue($params['item_id'], $params['field_id'], $value);
         } else {
             $field_values = self::get_values_by_handler_and_field_id($params['item_id'], $params['field_id']);
         }
         $params['value'] = $value_to_insert;
         $params['author_id'] = api_get_user_id();
         // Insert
         if (empty($field_values)) {
             /* Enable this when field_loggeable is introduced as a table field (2.0)
                if ($extraFieldInfo['field_loggeable'] == 1) {
                */
             if (false) {
                 global $app;
                 switch ($this->type) {
                     case 'question':
                         $extraFieldValue = new ChamiloLMS\Entity\QuestionFieldValues();
                         $extraFieldValue->setUserId(api_get_user_id());
                         $extraFieldValue->setQuestionId($params[$this->handler_id]);
                         break;
                     case 'course':
                         $extraFieldValue = new ChamiloLMS\Entity\CourseFieldValues();
                         $extraFieldValue->setUserId(api_get_user_id());
                         $extraFieldValue->setQuestionId($params[$this->handler_id]);
                         break;
                     case 'user':
                         $extraFieldValue = new ChamiloLMS\Entity\UserFieldValues();
                         $extraFieldValue->setUserId($params[$this->handler_id]);
                         $extraFieldValue->setAuthorId(api_get_user_id());
                         break;
                     case 'session':
                         $extraFieldValue = new ChamiloLMS\Entity\SessionFieldValues();
                         $extraFieldValue->setUserId(api_get_user_id());
                         $extraFieldValue->setSessionId($params[$this->handler_id]);
                         break;
                 }
                 if (isset($extraFieldValue)) {
                     if (!empty($params['value'])) {
                         $extraFieldValue->setComment($params['comment']);
                         $extraFieldValue->setFieldValue($params['value']);
                         $extraFieldValue->setFieldId($params['field_id']);
                         $extraFieldValue->setTms(api_get_utc_datetime(null, false, true));
                         $app['orm.ems']['db_write']->persist($extraFieldValue);
                         $app['orm.ems']['db_write']->flush();
                     }
                 }
             } else {
                 if ($extraFieldInfo['field_type'] == ExtraField::FIELD_TYPE_TAG) {
                     $option = new ExtraFieldOption($this->type);
                     $optionExists = $option->get($params['value']);
                     if (empty($optionExists)) {
                         $optionParams = array('field_id' => $params['field_id'], 'option_value' => $params['value']);
                         $optionId = $option->saveOptions($optionParams);
                     } else {
                         $optionId = $optionExists['id'];
                     }
                     $params['value'] = $optionId;
                     if ($optionId) {
                         return parent::save($params, $show_query);
                     }
                 } else {
                     return parent::save($params, $show_query);
                 }
             }
         } else {
             // Update
             /* Enable this when field_loggeable is introduced as a table field (2.0)
                if ($extraFieldInfo['field_loggeable'] == 1) {
                */
             if (false) {
                 global $app;
                 switch ($this->type) {
                     case 'question':
                         $extraFieldValue = $app['orm.ems']['db_write']->getRepository('ChamiloLMS\\Entity\\QuestionFieldValues')->find($field_values['id']);
                         $extraFieldValue->setUserId(api_get_user_id());
                         $extraFieldValue->setQuestionId($params[$this->handler_id]);
                         break;
                     case 'course':
                         $extraFieldValue = $app['orm.ems']['db_write']->getRepository('ChamiloLMS\\Entity\\CourseFieldValues')->find($field_values['id']);
                         $extraFieldValue->setUserId(api_get_user_id());
                         $extraFieldValue->setCourseCode($params[$this->handler_id]);
                         break;
                     case 'user':
                         $extraFieldValue = $app['orm.ems']['db_write']->getRepository('ChamiloLMS\\Entity\\UserFieldValues')->find($field_values['id']);
                         $extraFieldValue->setUserId(api_get_user_id());
                         $extraFieldValue->setAuthorId(api_get_user_id());
                         break;
                     case 'session':
                         $extraFieldValue = $app['orm.ems']['db_write']->getRepository('ChamiloLMS\\Entity\\SessionFieldValues')->find($field_values['id']);
                         $extraFieldValue->setUserId(api_get_user_id());
                         $extraFieldValue->setSessionId($params[$this->handler_id]);
                         break;
                 }
                 if (isset($extraFieldValue)) {
                     if (!empty($params['value'])) {
                         /*
                          *  If the field value is similar to the previous value then the comment will be the same
                             in order to no save in the log an empty record
                         */
                         if ($extraFieldValue->getFieldValue() == $params['value']) {
                             if (empty($params['comment'])) {
                                 $params['comment'] = $extraFieldValue->getComment();
                             }
                         }
                         $extraFieldValue->setComment($params['comment']);
                         $extraFieldValue->setFieldValue($params['value']);
                         $extraFieldValue->setFieldId($params['field_id']);
                         $extraFieldValue->setTms(api_get_utc_datetime(null, false, true));
                         $app['orm.ems']['db_write']->persist($extraFieldValue);
                         $app['orm.ems']['db_write']->flush();
                     }
                 }
             } else {
                 $params['id'] = $field_values['id'];
                 return parent::update($params, $show_query);
             }
         }
     }
 }
Example #21
0
 /**
  * @inheritdoc
  */
 public function update($values)
 {
     $values['updated_on'] = api_get_utc_datetime();
     $values['group_type'] = isset($values['group_type']) ? self::SOCIAL_CLASS : self::NORMAL_CLASS;
     if (isset($values['id'])) {
         $picture = isset($_FILES['picture']) ? $_FILES['picture'] : null;
         if (!empty($picture)) {
             $picture = $this->manageFileUpload($values['id'], $picture);
             if ($picture) {
                 $values['picture'] = $picture;
             }
         }
         if (isset($values['delete_picture'])) {
             $values['picture'] = null;
         }
     }
     parent::update($values);
     if (isset($values['delete_picture'])) {
         $this->delete_group_picture($values['id']);
     }
     return true;
 }
if (isset($_POST['submit'])) {
    for ($i = 1; $i <= $_POST['total_session']; $i++) {
        if ($_POST['trainer1_' . "{$i}"] == "Select Trainer 1" && $_POST['trainer2_' . "{$i}"] == "Select Trainer 2") {
            $tablename = 'session_entry';
            $set_value = "trainer_1='', trainer_2=''";
            $condition = "session_no='" . $_POST['session_no_' . "{$i}"] . "' and batch_id='" . $_POST['batch_id_' . "{$i}"] . "' and name_of_erp_course='" . $_POST['erp_course_' . "{$i}"] . "'";
            $result = Model::update($tablename, $set_value, $condition);
            if ($result) {
                if ($_POST['user_type'] == 'tc/tp') {
                    header('location:assign_trainer1.php');
                } else {
                    header('location:assign_trainer.php');
                }
            }
        } else {
            $trainer_1 = explode('_', $_POST['trainer1_' . "{$i}"]);
            $trainer_2 = explode('_', $_POST['trainer2_' . "{$i}"]);
            $tablename = 'session_entry';
            $set_value = "trainer_1='{$trainer_1['0']}', trainer_2='{$trainer_2['0']}', amount_term='" . $_POST['amount_term_' . "{$i}"] . "'";
            $condition = "session_no='" . $_POST['session_no_' . "{$i}"] . "' and batch_id='" . $_POST['batch_id_' . "{$i}"] . "' and name_of_erp_course='" . $_POST['erp_course_' . "{$i}"] . "'";
            $result = Model::update($tablename, $set_value, $condition);
            if ($result) {
                if ($_POST['user_type'] == 'tc/tp') {
                    header('location:assign_trainer1.php');
                } else {
                    header('location:assign_trainer.php');
                }
            }
        }
    }
}
 public function update($where, $data)
 {
     return parent::update($where, $data);
 }
Example #24
0
 public function update($params)
 {
     $params = self::clean_parameters($params);
     if (isset($params['id'])) {
         $field_option = new ExtraFieldOption($this->type);
         $params['field_id'] = $params['id'];
         $field_option->save($params);
     }
     parent::update($params);
 }
 public function setLoginDetails($userid)
 {
     $where = array("user='******'user']}'");
     if (isset($_POST['keep'])) {
         setcookie('user', $this->R['user'], time() + 604800);
         setcookie('userid', $userid, time() + 604800);
     } else {
         setcookie('user', $this->R['user']);
         setcookie('userid', $userid);
     }
     $updateData['last_ip'] = Tool::getIP();
     $updateData['login_time'] = Tool::getDate();
     parent::update($where, $updateData);
 }
Example #26
0
 /**
  * 更新等级信息
  *
  * @param int $id
  * @param array $setdata
  * @return bool
  */
 public function updateLevel($level, $exp)
 {
     $where = $this->getAdapter()->bind('level=?', $level);
     return parent::update(array('exp' => intval($exp)), $where);
 }
 public function update()
 {
     $where = array("id='{$this->R['id']}'");
     $updateData = $this->getRequest()->filter($this->fields);
     if ($this->R['is_record'] == 0 && $this->R['order_delivery'] == '已发货') {
         $this->tables = array(DB_FREFIX . 'record');
         foreach ($_POST['goods_id'] as $key => $value) {
             $recordDate['goods_id'] = $value;
             $recordDate['user'] = $_POST['user'];
             $recordDate['name'] = $_POST['goods_name'][$value];
             $recordDate['num'] = $_POST['goods_num'][$value];
             $recordDate['attr'] = $_POST['goods_attr'][$value];
             $recordDate['price'] = $_POST['goods_price_sale'][$value];
             $recordDate['date'] = tool::getDate();
             parent::add($recordDate);
         }
     }
     if ($this->R['order_state'] == '已取消' || $this->R['refund'] == 2) {
         $order_goods = parent::select(array('id', 'goods'), array('where' => $where));
         $goods = unserialize(htmlspecialchars_decode($order_goods[0]->goods));
         $this->tables = array(DB_FREFIX . 'goods');
         foreach ($goods as $key => $value) {
             $value = unserialize($value);
             parent::update(array("id='{$key}'"), array('inventory' => array('inventory+' . $value[num]), 'sale_count' => array('sale_count-' . $value[num])));
         }
     }
     $this->tables = array(DB_FREFIX . 'order');
     $updateData['is_record'] = 1;
     return parent::update($where, $updateData);
 }
Example #28
0
 public static function update($params)
 {
     if (self::checkReverseComplement($params)) {
         throw new Exception('Food Complement already exists');
     }
     return parent::update($params);
 }
Example #29
0
 function update($data, Criteria $c)
 {
     parent::update($data, $c);
     Cacher::getInstance()->clean("tag", array("user"));
 }
Example #30
0
 /**
  * Overrides update to remove PK checking when performing an update.
  */
 public function update()
 {
     static::disable_primary_key_check();
     $result = parent::update();
     static::enable_primary_key_check();
     return $result;
 }