示例#1
0
 function SaveAction()
 {
     $request = Project::getRequest();
     $user_id = (int) Project::getUser()->getDbUser()->id;
     $model = new UserModel();
     $model->load($request->id);
     $do_save = true;
     $this->_view->clearFlashMessages();
     if (!strlen(trim($request->login))) {
         $this->_view->addFlashMessage(FM::ERROR, "Не заполнено поле логин");
         $do_save = false;
     }
     if ($request->unbann) {
         $ban_model = new BanHistoryModel();
         $ban_model->unban($request->id, $user_id);
     }
     if ($request->bann) {
         if (strlen($request->warning)) {
             $ban_date = $request->ban_date;
             if (strlen($ban_date) && strtotime($ban_date) > time()) {
                 $warning_model = new WarningModel();
                 $warning_id = $warning_model->add($request->id, $request->warning);
                 $ban_model = new BanHistoryModel();
                 $ban_model->ban($request->id, $user_id, $warning_id, $request->ban_date);
             } else {
                 $this->_view->addFlashMessage(FM::ERROR, "Неверная дата бана");
                 $do_save = false;
             }
         } else {
             $this->_view->addFlashMessage(FM::ERROR, "Не заполнено предупреждение");
             $do_save = false;
         }
     }
     if ($do_save) {
         $this->_view->clearFlashMessages();
         $model->login = $request->login;
         $model->user_type_id = $request->user_group;
         if ($request->bann) {
             $model->banned = 1;
             $model->banned_date = strtotime($request->ban_date);
         } else {
             $model->banned = 0;
         }
         $ban_date = $request->ban_date;
         if (strlen($ban_date)) {
             //$ban_model = new Ban
         }
         $id = $model->save();
         $model = new UserTypeModel();
         $info = array();
         $info['group_list'] = $model->loadAll();
         $info['edit_controller'] = null;
         $info['edit_action'] = 'Edit';
         $this->makeUserList($info);
         $this->_view->AjaxList($info);
     }
     $this->_view->ajax();
 }
示例#2
0
 /**
  * WarningModel::addStock()
  * 生成海外备货清单
  * @param string $ids
  * @param string $purchase
  * @return  bool
  */
 public static function addStock($ids, $purchase)
 {
     self::initDB();
     require_once WEB_PATH . "model/purchaseOrder.model.php";
     $sql = "SELECT sku,goodsCost FROM " . self::$prefix . self::$showtab . " WHERE id IN ({$ids})";
     $query = self::$dbConn->query($sql);
     if ($query) {
         $ret = self::$dbConn->fetch_array_all($query);
         $nowtime = time();
         $stocksn = PurchaseOrderModel::autoCreateOrderSn(66, 3);
         $sqlstock = "INSERT INTO " . self::$prefix . self::$owtab . "(ordersn,adduser,addtime,status) VALUES('{$stocksn}','{$purchase}','{$nowtime}','1')";
         $query = self::$dbConn->query($sqlstock);
         foreach ($ret as $v) {
             $skusql = "INSERT INTO " . self::$prefix . self::$owdetailtab . "(ordersn,sku,cost) VALUES('{$stocksn}', '{$v['sku']}', '{$v['goodsCost']}')";
             $query = self::$dbConn->query($skusql);
         }
         return true;
     } else {
         self::$errCode = "1060";
         self::$errMsg = "获取数据失败";
         return false;
     }
 }
示例#3
0
 public function EditCommentAction()
 {
     $request = Project::getRequest();
     $user = Project::getUser()->getDbUser();
     $isAdmin = $user->user_type_id == 1 ? true : false;
     $item_name = $request->item_name;
     switch ($item_name) {
         case 'article':
             $item_controller = 'Article';
             $item_action = 'ArticleView';
             break;
         case 'questions':
             $item_controller = 'QuestionAnswer';
             $item_action = 'ViewQuestion';
             break;
         case 'photo':
             $item_controller = 'Photo';
             $item_action = 'View';
             break;
         case 'bookmarks':
             $item_controller = 'Bookmarks';
             $item_action = 'BookmarksView';
             break;
         case 'social':
             $item_controller = 'Social';
             $item_action = 'SocialView';
             break;
         case 'blog':
             $item_controller = 'Blog';
             $item_action = 'Comments';
             break;
     }
     $comment_model = new CommentModel($item_name . '_comment', $item_name . '_id', $request->comment_id);
     if ($request->change_comment && ($isAdmin || $comment_model->user_id == $user->id)) {
         $warning_id = 0;
         if ($request->warning_text) {
             $warningModel = new WarningModel();
             $warning_id = $warningModel->add($comment_model->user_id, $request->warning_text);
         }
         $comment_model->editComment($comment_model->user_id, $warning_id, $request->editCommentArea, (int) $isAdmin);
     }
     Project::getResponse()->redirect($request->createUrl($item_controller, $item_action, array($request->element_id)));
 }