Пример #1
0
 /**
  * 保存账号
  */
 public function action_save()
 {
     $this->_autoRender = FALSE;
     $givenName = Arr::get($_POST, 'given_name', '');
     $name = Arr::get($_POST, 'name', '');
     $password = Arr::get($_POST, 'password', '');
     $email = Arr::get($_POST, 'email', '');
     $mobile = Arr::get($_POST, 'mobile', '');
     $phone = Arr::get($_POST, 'phone', '');
     if ($givenName == '') {
         return Prompt::jsonWarning('姓名不能为空');
     }
     if ($name == '') {
         return Prompt::jsonWarning('用户名不能为空');
     }
     if ($password == '') {
         return Prompt::jsonWarning('密码不能为空');
     }
     if ($email == '') {
         return Prompt::jsonWarning('邮箱不能为空');
     }
     $values = array('given_name' => $givenName, 'name' => $name, 'password' => md5($password), 'email' => $email, 'mobile' => $mobile, 'phone' => $phone);
     try {
         $result = Model::factory('Account')->create($values)->getArray();
         if (!$result[0]) {
             //TODO 日志
             return Prompt::jsonError('添加账号失败');
         }
     } catch (Exception $e) {
         //TODO 日志
         return Prompt::jsonError('添加账号失败');
     }
     //TODO 日志
     return Prompt::jsonSuccess('添加账号成功', URL::site('account/add'));
 }
Пример #2
0
 /**
  * 添加保存
  */
 public function action_save()
 {
     $this->_autoRender = FALSE;
     $name = Arr::get($_POST, 'name', '');
     $describe = Arr::get($_POST, 'describe', '');
     if (!$name) {
         return Prompt::jsonWarning('名称不能为空');
     }
     if (!$describe) {
         return Prompt::jsonWarning('描述不能为空');
     }
     $values = array('name' => $name, 'describe' => $describe, 'account_id' => 0);
     try {
         $result = Model::factory('Project')->create($values)->getArray();
         if (!$result) {
             //TODO 日志
             return Prompt::jsonError('添加项目失败');
         }
     } catch (Exception $e) {
         //TODO 日志
         return Prompt::jsonError('添加项目失败');
     }
     //TODO 日志
     return Prompt::jsonSuccess('添加项目成功', URL::site('project/add'));
 }
Пример #3
0
 /**
  * 添加保存
  */
 public function action_save()
 {
     $this->_autoRender = FALSE;
     $name = Arr::get($_POST, 'name', '');
     if ($name == '') {
         Prompt::jsonWarning('角色名称不能为空!');
     }
     $values = array('name' => $name);
     try {
         $result = Model::factory('Role')->create($values)->getArray();
         if (!$result) {
             //日志
             Prompt::jsonError('添加角色失败');
         }
     } catch (Exception $e) {
         //日志
         Logger::factory('run_log')->write('添加角色失败 ' . $e->getMessage())->execute();
         Prompt::jsonError('添加角色失败');
     }
     //日志
     Prompt::jsonSuccess('添加角色成功', URL::site('role/add'));
 }
Пример #4
0
 /**
  * 添加保存
  */
 public function action_save()
 {
     $name = Arr::get($_POST, 'name', '');
     $module = Arr::get($_POST, 'module', '');
     if ($name == '') {
         return Prompt::jsonWarning('名称不能为空');
     }
     if ($module == '') {
         return Prompt::jsonWarning('模块不能为空');
     }
     $values = array('name' => $name, 'module' => $module);
     try {
         $result = Model::factory('module')->create($values)->getArray();
         if (!$result) {
             //Todo 日志
             return Prompt::jsonError('添加模块失败');
         }
     } catch (Exception $e) {
         //TODO 日志
         return Prompt::jsonError('添加模块失败');
     }
     //TODO 日志
     return Prompt::jsonSuccess('添加模块成功', URL::site('module/add'));
 }
Пример #5
0
 /**
  * 添加保存
  */
 public function action_save()
 {
     $name = Arr::get($_POST, 'name', '');
     $type = Arr::get($_POST, 'type', '');
     $parentId = Arr::get($_POST, 'parent_id', 0);
     $controller = Arr::get($_POST, 'controller', '');
     $action = Arr::get($_POST, 'action', '');
     $icon = Arr::get($_POST, 'icon', '');
     $isDisplay = Arr::get($_POST, 'is_display', 1);
     $sequence = Arr::get($_POST, 'sequence', 0);
     if (!$name) {
         return Prompt::jsonWarning('权限名称不能为空');
     }
     if ($type != 'menu' && $type != 'navigator' && $type != 'controller') {
         return Prompt::jsonWarning('类型选择错误' . $type);
     }
     //导航-- 没有上级,控制器,动作都为空
     if ($type == 'navigator') {
         if ($parentId != 0) {
             return Prompt::jsonWarning('导航不用选择上级');
         }
         if ($controller) {
             return Prompt::jsonWarning('导航没有控制器');
         }
         if ($action) {
             return Prompt::jsonWarning('导航没有动作');
         }
     }
     //菜单 -- 有上级,无控制器,方法
     if ($type == 'menu') {
         if ($controller) {
             return Prompt::jsonWarning('菜单没有控制器');
         }
         if ($action) {
             return Prompt::jsonWarning('菜单没有动作');
         }
     }
     //控制器。必须有上级,控制器,方法
     if ($type == 'controller') {
         if ($parentId == 0) {
             return Prompt::jsonWarning('控制器上级必须是菜单');
         }
         if (!$controller) {
             return Prompt::jsonWarning('控制器必须填写');
         }
         if (!$action) {
             return Prompt::jsonWarning('控制器必须有动作');
         }
     }
     if ($sequence === '') {
         $sequence = 0;
     }
     if ($sequence && !is_numeric($sequence)) {
         return Prompt::jsonWarning('排序必须是数字');
     }
     $values = array('name' => $name, 'type' => $type, 'parent_id' => $parentId, 'controller' => $controller, 'action' => $action, 'icon' => $icon, 'is_display' => $isDisplay, 'sequence' => $sequence);
     try {
         $result = Model::factory('Privilege')->create($values)->getArray();
         if (!$result) {
             //TODO 日志
             return Prompt::jsonError('添加权限失败');
         }
     } catch (Exception $e) {
         //TODO 日志
         echo $e->getMessage();
         exit;
         return Prompt::jsonError('添加权限失败' . $e->getMessage());
     }
     //TODO 日志
     return Prompt::jsonSuccess('添加权限成功', URL::site('privilege/add'));
 }
Пример #6
0
 /**
  * 保存任务
  */
 public function action_save()
 {
     Prompt::jsonSuccess('任务添加成功', URL::site('task/add'));
 }