/** * 删除文章分类 * * @access public */ public function delete() { if (!($id = Request::input('id'))) { return responseJson(Lang::get('common.action_error')); } if (!is_array($id)) { $id = array($id); } $id = array_map('intval', $id); if ($this->tagProcess->delete($id)) { $this->setActionLog(['id' => $id]); return responseJson(Lang::get('common.action_success'), true); } return responseJson($this->tagProcess->getErrorMessage()); }
/** * 编辑工作流步骤 * * @param object $data * @access public * @return boolean true|false */ public function editWorkflowStep(\App\Services\Admin\Workflow\Param\WorkflowStepSave $data) { if (!isset($data->id)) { return $this->setErrorMsg(Lang::get('common.action_error')); } if (!empty($data['step_level'])) { if (!in_array($data['step_level'], array_fetch($this->workflowStepLevelList(), 'step_level'))) { return $this->setErrorMsg(Lang::get('common.illegal_operation')); } } $id = $data->id; unset($data->id); if (!$id) { return $this->setErrorMsg(Lang::get('common.illegal_operation')); } if (!$this->workflowStepValidate->edit($data)) { return $this->setErrorMsg($this->workflowStepValidate->getErrorMessage()); } if (!empty($data->code)) { $checkCode = $this->workflowStepModel->getWorkflowStepInfo(['code' => $data->code, 'self' => false, 'self_id' => $id]); if (!empty($checkCode)) { return $this->setErrorMsg(Lang::get('workflow.code_exists')); } } if ($this->workflowStepModel->editWorkflowStep($data->toArray(), $id) !== false) { return true; } return $this->setErrorMsg(Lang::get('common.action_error')); }
/** * 编辑文章入库处理 * * @access private */ private function updateDatasToDatabase() { $httpReferer = Session::getOldInput('http_referer'); $data = (array) Request::input('data'); $data['tags'] = explode(';', $data['tags']); $this->contentSave->setAttributes($data); $id = intval(Request::input('id')); if ($this->contentProcess->editContent($this->contentSave, $id) !== false) { $this->setActionLog(['param' => $this->contentSave]); $backUrl = !empty($httpReferer) ? $httpReferer : R('common', 'blog.content.index'); return Js::locate($backUrl, 'parent'); } return Js::error($this->contentProcess->getErrorMessage()); }
/** * Constructor. * * @param object $ArtifactType The ArtifactType object to which this ArtifactFieldSetFactory is associated * @return boolean success. */ function ArtifactFieldSetFactory($ArtifactType) { $this->Error(); if ($ArtifactType) { if ($ArtifactType->isError()) { $this->setError('ArtifactFieldSetFactory:: ' . $ArtifactType->getErrorMessage()); return false; } $this->ArtifactType = $ArtifactType; $this->ArtifactFieldSets = array(); $this->fetchData($this->ArtifactType->getID()); } return true; }
/** * 删除工作流 * * @access public */ public function delete() { $id = Request::input('id'); if (!$id) { return responseJson(Lang::get('common.action_error')); } $id = array_map('intval', (array) $id); $info = $this->workflowProcess->workflowInfos(['ids' => $id]); if ($this->workflowProcess->deleteWorkflow(['ids' => $id])) { $this->setActionLog(['workflowInfo' => $info]); return responseJson(Lang::get('common.action_success'), true); } return responseJson($this->workflowProcess->getErrorMessage()); }
/** * 回复评论 */ private function commentReply() { $data['object_id'] = (int) Request::input('objectid'); $data['object_type'] = (int) Request::input('object_type'); $data['nickname'] = strip_tags(Request::input('nickname')); $data['content'] = strip_tags(Request::input('comment')); $data['replyid'] = (int) Request::input('replyid'); $insertId = $this->commentProcess->addComment($data); if ($insertId !== false) { $this->setActionLog(['replyid' => $data['replyid'], 'object_id' => $data['object_id'], 'content' => $data['content']]); return Js::execute('window.parent.loadComment(' . $insertId . ');'); } return Js::error($this->commentProcess->getErrorMessage()) . Js::execute('window.parent.reloadDialogTitle();'); }
/** * 编辑推荐位 * * @param object $data * @access public * @return boolean true|false */ public function editPosition(\App\Services\Admin\Position\Param\PositionSave $data) { if (!isset($data['id'])) { return $this->setErrorMsg(Lang::get('common.action_error')); } $id = intval($data['id']); unset($data['id']); if (!$this->positionValidate->edit($data)) { return $this->setErrorMsg($this->positionValidate->getErrorMessage()); } if ($this->positionModel->editPosition($data->toArray(), $id) !== false) { return true; } return $this->setErrorMsg(Lang::get('common.action_error')); }
/** * 修改自己的密码 * * @param object $params * @return true|false */ public function modifyPassword(UserModifyPassword $params) { if (!$this->userValidate->password($params)) { return $this->setErrorMsg($this->userValidate->getErrorMessage()); } $userInfo = SC::getLoginSession(); if ($userInfo->password != md5($params->oldPassword)) { return $this->setErrorMsg(Lang::get('user.old_password_wrong')); } $updateData = ['password' => md5($params->newPassword)]; if ($this->userModel->editUser($updateData, $userInfo->id) !== false) { return true; } return $this->setErrorMsg(Lang::get('common.action_error')); }
/** * 删除推荐位关联文章 */ public function delrelation() { if (!($prid = Request::input('prid'))) { return responseJson(Lang::get('common.action_error')); } if (!is_array($prid)) { $prid = array($prid); } $posArticle = $this->prModel->getPositionArticleInIds($prid); if ($this->pProcess->delRelation($prid)) { $this->setActionLog(['posArticle' => $posArticle]); return responseJson(Lang::get('common.action_success'), true); } return responseJson($this->pProcess->getErrorMessage()); }
/** * 编辑店铺分类 * * @param object $data * @return boolean true|false * @access public */ public function editShopCategory(CategorySave $data) { $id = intval($data->category_id); unset($data->category_id); if (!$this->productCategoryValidate->edit($data)) { return $this->setErrorMsg($this->productCategoryValidate->getErrorMessage()); } if ($this->productCategoryModel->checkIfIsExists($data->category_name, false, $id)) { return $this->setErrorMsg(Lang::get('shopcategory.name_exists')); } $data = $data->toArray(); if ($this->productCategoryModel->editShopCategory($data, $id) === false) { return $this->setErrorMsg(Lang::get('common.action_error')); } return true; }
/** * 修改自己的密码 * * @param object $params * @return true|false */ public function modifyPassword(\App\Services\Admin\User\Param\UserModifyPassword $params) { if (!$this->userValidate->password($params)) { return $this->setErrorMsg($this->userValidate->getErrorMessage()); } $loginProcess = new \App\Services\Admin\Login\Process(); $userInfo = \App\Services\Admin\SC::getLoginSession(); if ($userInfo->password != md5($params->oldPassword)) { return $this->setErrorMsg(Lang::get('user.old_password_wrong')); } $updateData = ['password' => md5($params->newPassword)]; if (app('model.admin.user')->editUser($updateData, $userInfo->id) !== false) { return true; } return $this->setErrorMsg(Lang::get('common.action_error')); }
/** * 编辑权限菜单 * * @param object $data * @return boolean true|false * @access public */ public function editAcl(AclSave $data) { $id = intval(url_param_decode($data->id)); unset($data->id); if (!$id) { return $this->setErrorMsg(Lang::get('common.illegal_operation')); } if (!$this->aclValidate->edit($data)) { return $this->setErrorMsg($this->aclValidate->getErrorMessage()); } if ($this->permissionModel->checkIfIsExists($data->module, $data->class, $data->action, false, $id)) { return $this->setErrorMsg(Lang::get('acl.acl_exists')); } $data = $data->toArray(); if ($this->permissionModel->editPermission($data, intval($id)) === false) { return $this->setErrorMsg(Lang::get('common.action_error')); } return true; }
/** * 编辑权限菜单 * * @param string $data * @access public * @return boolean true|false */ public function editAcl(\App\Services\Admin\Acl\Param\AclSave $data) { $id = intval(url_param_decode($data->id)); unset($data->id); if (!$id) { return $this->setErrorMsg(Lang::get('common.illegal_operation')); } if (!$this->aclValidate->edit($data)) { return $this->setErrorMsg($this->aclValidate->getErrorMessage()); } if ($this->permissionModel->checkIfIsExists($data->module, $data->class, $data->action, false, $id)) { return $this->setErrorMsg(Lang::get('acl.acl_exists')); } $info = $this->permissionModel->getOnePermissionById(intval($data->pid)); $data = $data->toArray(); $data['level'] = $info['level'] + 1; if ($this->permissionModel->editPermission($data, intval($id)) !== false) { return true; } return $this->setErrorMsg(Lang::get('common.action_error')); }
/** * 编辑工作流步骤 * * @param string $data * @access public * @return boolean true|false */ public function editWorkflowStep(\App\Services\Admin\Workflow\Param\WorkflowStepSave $data) { if (!isset($data->id)) { return $this->setErrorMsg(Lang::get('common.action_error')); } if (!in_array($data['step_level'], array_fetch($this->workflowStepLevelList(), 'step_level'))) { return $this->setErrorMsg(Lang::get('common.illegal_operation')); } $id = $data->id; unset($data->id); if (!$id) { return $this->setErrorMsg(Lang::get('common.illegal_operation')); } if (!$this->workflowStepValidate->edit($data)) { return $this->setErrorMsg($this->workflowStepValidate->getErrorMessage()); } if ($this->workflowStepModel->editWorkflowStep($data->toArray(), $id) !== false) { return true; } return $this->setErrorMsg(Lang::get('common.action_error')); }
/** * 编辑文章 * * @param string $data * @access public * @return boolean true|false */ public function editContent(\App\Services\Admin\Content\Param\ContentSave $data, $id) { if (!$this->contentValidate->edit($data)) { return $this->setErrorMsg($this->contentValidate->getErrorMessage()); } $object = new \stdClass(); $object->contentAutoId = $id; try { $result = \DB::transaction(function () use($data, $id, $object) { $this->updateContent($data, $id); $this->updateContentDetail($data, $id); $this->saveArticleTags($object, $data['tags']); $this->saveArticleClassify($object, $data['classify']); $this->saveSeachFullText($object, $data, true); return true; }); } catch (\Exception $e) { $result = false; } return !$result ? $this->setErrorMsg(Lang::get('common.action_error')) : true; }
/** * 编辑用户组 * * @param object $data * @return boolean true|false * @access public */ public function editGroup(GroupSave $data) { if (!isset($data->id)) { return $this->setErrorMsg(Lang::get('common.action_error')); } $id = intval(url_param_decode($data->id)); unset($data->id); if (!$id) { return $this->setErrorMsg(Lang::get('common.illegal_operation')); } if (!$this->groupValidate->edit($data)) { return $this->setErrorMsg($this->groupValidate->getErrorMessage()); } if (!$this->acl->checkGroupLevelPermission($data->level, Acl::GROUP_LEVEL_TYPE_LEVEL)) { return $this->setErrorMsg(Lang::get('common.account_level_deny')); } if ($this->groupModel->editGroup($data->toArray(), $id) === false) { return $this->setErrorMsg(Lang::get('common.action_error')); } return true; }
/** * 编辑用户组 * * @param object $data * @access public * @return boolean true|false */ public function editGroup(\App\Services\Admin\Group\Param\GroupSave $data) { if (!isset($data->id)) { return $this->setErrorMsg(Lang::get('common.action_error')); } $id = intval(url_param_decode($data->id)); unset($data->id); if (!$id) { return $this->setErrorMsg(Lang::get('common.illegal_operation')); } if (!$this->groupValidate->edit($data)) { return $this->setErrorMsg($this->groupValidate->getErrorMessage()); } //检查当前用户的权限是否能增加这个用户 if (!app('admin.acl')->checkGroupLevelPermission($data->level, Acl::GROUP_LEVEL_TYPE_LEVEL)) { return $this->setErrorMsg(Lang::get('common.account_level_deny')); } if (app('model.admin.group')->editGroup($data->toArray(), $id) !== false) { return true; } return $this->setErrorMsg(Lang::get('common.action_error')); }
/** * 设置审核步骤与用户的关联 * * @access private */ private function setRelation() { $this->checkFormHash(); $stepId = (int) Request::input('stepId'); $workflowId = (int) Request::input('workflowId'); $userIds = Request::input('ids'); if (!$userIds) { return Js::error(Lang::get('workflow.relation_user_empty')); } if (!$stepId or !$workflowId or !is_array($userIds)) { return Js::error(Lang::get('common.illegal_operation')); } $userIds = array_map('intval', $userIds); $stepInfo = $this->workflowProcess->workflowStepInfo(['id' => $stepId]); if (empty($stepInfo)) { return Js::error(Lang::get('common.illegal_operation')); } if ($this->workflowProcess->setRelation($workflowId, $stepId, $userIds)) { $this->setActionLog(['userIds' => $userIds, 'stepInfo' => $stepInfo]); return Js::alert(Lang::get('common.action_success')); } return Js::error($this->workflowProcess->getErrorMessage()); }
/** * 编辑文章 * * @param object $data 文章的信息 * @param int $id 文章的ID * @access public * @return boolean */ public function editContent(ContentSave $data, $id) { if (!$this->contentValidate->edit($data)) { $unValidateMsg = $this->contentValidate->getErrorMessage(); return $this->setErrorMsg($unValidateMsg); } $articleObj = new \stdClass(); $articleObj->autoId = $id; try { $this->updateContent($data, $id); $this->updateContentDetail($data, $id); $this->saveArticleTags($articleObj, $data['tags']); $this->saveArticleClassify($articleObj, $data['classify']); $this->saveSeachFullText($articleObj, $data, true); $result = true; } catch (Exception $e) { $result = false; } if (!$result) { return $this->setErrorMsg(Lang::get('common.action_error')); } return true; }