Edit an existing blog
@return void
503954
public function edit()
    {
        if (!userHasPermission('admin:blog:blog:edit')) {

            unauthorised();
        }

        // --------------------------------------------------------------------------

        $this->data['blog'] = $this->blog_model->getById($this->uri->segment(5));

        if (empty($this->data['blog'])) {

            show404();
        }

        // --------------------------------------------------------------------------

        $this->data['page']->title = 'Manage Blogs &rsaquo; Edit "' . $this->data['blog']->label . '"';

        // --------------------------------------------------------------------------

        //  Handle POST
        if ($this->input->post()) {

            $oFormValidation = Factory::service('FormValidation');
            $oFormValidation->set_rules('label', '', 'required');
            $oFormValidation->set_rules('description', '', '');
            $oFormValidation->set_message('required', lang('fv_required'));

            if ($oFormValidation->run()) {

                $aUpdateData                = array();
                $aUpdateData['label']       = $this->input->post('label');
                $aUpdateData['description'] = $this->input->post('description');

                if ($this->blog_model->update($this->uri->segment(5), $aUpdateData)) {

                    $status  = 'success';
                    $message = 'Blog was updated successfully.';
                    $this->session->set_flashdata($status, $message);
                    redirect('admin/blog/blog/index');

                } else {

                    $this->data['error']  = 'Failed to create blog. ';
                    $this->data['error'] .= $this->blog_model->lastError();
                }

            } else {

                $this->data['error'] = lang('fv_there_were_errors');
            }
        }

        // --------------------------------------------------------------------------

        //  Load views
        Helper::loadView('edit');
    }
1222452
function Save()
    {
        $this->pageRights->Save();
        if (!$this->rights)
        {
            $this->rights = new BackendSiteRights();
        }
        
        $this->rights->SetEdit($this->Value('Edit'));
        $this->rights->SetRemove($this->Value('Remove'));
        $this->rights->SetPageRights($this->pageRights->Rights());
        $this->rights->Save();
    }
1325479
protected function wizardAddPage()
    {
        // Required
        $this->validatePrompt('title', $this->text('Title'), 'page');
        $this->validatePrompt('description', $this->text('Description'), 'page');
        $this->validatePrompt('store_id', $this->text('Store ID'), 'page');

        // Optional
        $this->validatePrompt('user_id', $this->text('User ID'), 'page', 0);
        $this->validatePrompt('meta_title', $this->text('Meta title'), 'page', '');
        $this->validatePrompt('meta_description', $this->text('Meta description'), 'page', '');
        $this->validatePrompt('category_id', $this->text('Category ID'), 'page', 0);
        $this->validatePrompt('blog_post', $this->text('Blog post'), 'page', 0);
        $this->validatePrompt('status', $this->text('Status'), 'page', 0);

        $this->validateComponent('page');
        $this->addPage();
    }
234848
public function change()
    {
        $table = $this->table('permissions');
        
        $table->addColumn('owner_model', 'string', [
            'default' => null,
            'null' => false,
            'limit' => 50,
        ]);

        $table->removeColumn('user_id');
        $table->removeColumn('is_active');

        $table->addColumn('owner_foreign_key', 'char', [
            'default' => null,
            'null' => false,
            'limit' => 36 
        ]);

        $table->save();
    }
796555
private function edit()
    {
        $item = Eresus_CMS::getLegacyKernel()->db->selectItem('users', "`id`='".arg('id')."'");
        $form = array(
            'name' => 'UserForm',
            'caption' => admUsersChangeUser.' №'.$item['id'],
            'width' => '400px',
            'fields' => array (
                array('type'=>'hidden','name'=>'update', 'value'=>$item['id']),
                array('type'=>'edit','name'=>'name','label'=>admUsersName,'maxlength'=>32,'width'=>'100%',
                    'value'=>$item['name'], 'pattern'=>'/.+/', 'errormsg'=>admUsersNameInvalid),
                array('type'=>'edit','name'=>'login','label'=>admUsersLogin,'maxlength'=>16,'width'=>'100%',
                    'value'=>$item['login'], 'pattern'=>'/^[a-z\d_]+$/', 'errormsg'=>admUsersLoginInvalid,
                    'access'=>ADMIN),
                array('type'=>'select','name'=>'access','label'=>admAccessLevel,
                    'values'=>array('2','3','4'),'items'=>array(ACCESSLEVEL2, ACCESSLEVEL3, ACCESSLEVEL4),
                    'value'=>$item['access'], 'disabled'=>$item['access'] == ROOT, 'access'=>ADMIN),
                array('type'=>'checkbox','name'=>'active','label'=>admUsersAccountState,
                    'value'=>$item['active'], 'access'=>ADMIN),
                array('type'=>'edit','name'=>'loginErrors','label'=>admUsersLoginErrors,'maxlength'=>2,
                    'width'=>'30px','value'=>$item['loginErrors'], 'access'=>ADMIN),
                array('type' => 'edit', 'name' => 'mail', 'label' => admUsersMail,
                    'maxlength' => 32, 'width' => '100%', 'value' => $item['mail'],
                    'access' => ADMIN),
            ),
            'buttons' => array(UserRights($this->access)?'ok':'', 'apply', 'cancel'),
        );

        $pswd = array(
            'name' => 'PasswordForm',
            'caption' => admUsersChangePassword,
            'width' => '400px',
            'fields' => array (
                array('type'=>'hidden','name'=>'password', 'value'=>$item['id']),
                array('type'=>'password','name'=>'pswd1','label'=>admUsersPassword,'maxlength'=>32,
                    'width'=>'100%'),
                array('type'=>'password','name'=>'pswd2','label'=>admUsersConfirmation,'maxlength'=>32,
                    'width'=>'100%', 'equal'=>'pswd1', 'errormsg'=>admUsersConfirmInvalid),
            ),
            'buttons' => array(UserRights($this->access)?'ok':'apply', 'cancel'),
        );

        /** @var TAdminUI $page */
        $page = Eresus_Kernel::app()->getPage();
        $result = $page->renderForm($form) . "<br />\n" . $page->renderForm($pswd);
        return $result;
    }
111394
public function editAction()
    {
        $id = $this->params()->fromRoute('id');
        if (! is_numeric($id)) {
            $this->flashMessenger()->addMessage(
                $this->scTranslate('The article identifier was not specified.')
            );
            return $this->redirect()
                ->toRoute('sc-admin/content-manager')
                ->setStatusCode(303);
        }

        try {
            $article = $this->getArticleService()->getArticle($id);
        } catch (RuntimeException $e) {
            $this->flashMessenger()->addMessage($e->getMessage());
            return $this->redirect()
                ->toRoute('sc-admin/content-manager')
                ->setStatusCode(303);
        }

        $form = $this->getArticleForm();
        $form->setAttribute(
            'action',
            $this->url()->fromRoute('sc-admin/article/edit', ['id' => $id])
        );
        $form->bind($article);
        if ($this->getRequest()->isPost()) {
            $form->setData($this->getRequest()->getPost());
            if ($form->isValid()) {
                $this->getArticleService()->saveContent($form->getData());
            }
        }

        return new ViewModel([
            'content' => $article,
            'form' => $form,
        ]);
    }
792442
public function edit()
    {
        if (!userHasPermission('admin:invoice:customer:edit')) {
            unauthorised();
        }

        $oCustomerModel = Factory::model('Customer', 'nails/module-invoice');
        $oUri           = Factory::service('Uri');

        $itemId             = (int) $oUri->segment(5);
        $this->data['item'] = $oCustomerModel->getById(
            $itemId,
            ['expand' => $oCustomerModel::EXPAND_ALL]
        );

        if (empty($this->data['item'])) {
            show404();
        }

        // --------------------------------------------------------------------------

        $oInput = Factory::service('Input');
        if ($oInput->post()) {

            try {

                $this->formValidation();

                if (!$oCustomerModel->update($itemId, $this->prepPostData())) {
                    throw new NailsException('Failed to update item. ' . $oCustomerModel->lastError(), 1);
                }

                $oSession = Factory::service('Session', 'nails/module-auth');
                $oSession->setFlashData('success', 'Item updated successfully.');
                redirect('admin/invoice/customer');

            } catch (\Exception $e) {
                $this->data['error'] = $e->getMessage();
            }
        }

        // --------------------------------------------------------------------------

        $this->data['page']->title = 'Edit customer';
        Helper::loadView('edit');
    }
42145
public function change()
    {
        $table = $this->table('notices');
        $table->addColumn('author', 'string', array('limit' => 16))
              ->addColumn('text', 'integer')
              ->addColumn('start_time', 'datetime')
              ->addColumn('end_time', 'datetime')
              ->addColumn('hidden', 'boolean', array('null' => false, 'default' => 0))
              ->addColumn('frontpage', 'boolean', array('null' => false, 'default' => 1))
              ->addColumn('sort_order', 'integer')
              ->create();

        $table->addForeignKey('text', 'text_story', 'id', array('delete'=> 'CASCADE', 'update'=> 'CASCADE'))
              ->addForeignKey('author', 'user', 'user', array('delete'=> 'CASCADE', 'update'=> 'CASCADE'))
              ->save();

    }
589971
def do_edit(self, args):
        """"""
        if 'EDITOR' not in os.environ:
            print('*** $EDITOR not set')
        else:
            path = os.path.join(utils.CONFIG_DIR, 'sql')
            cmd = os.environ['EDITOR']
            try:
                os.system(cmd + ' ' + path)
                if os.path.exists(path):
                    with open(path, 'r') as f:
                        sql = f.read()
                        if sql:
                            self.default(sql)
            finally:
                if os.path.exists(path):
                    os.remove(path)
1130162
public function index()
    {
        if (!userHasPermission('admin:blog:settings:\d+:update')) {

            unauthorised();
        }

        // --------------------------------------------------------------------------

        //  Load models
        $this->load->model('blog/blog_model');
        $oSkinModel = Factory::model('Skin', 'nails/module-blog');

        // --------------------------------------------------------------------------

        $this->data['blogs'] = $this->blog_model->getAllFlat();

        if (empty($this->data['blogs'])) {

            if (userHasPermission('admin:blog:blog:create')) {

                $status   = 'message';
                $message  = '<strong>You don\'t have a blog!</strong> Create a new blog ';
                $message .= 'in order to configure blog settings.';
                $oSession = Factory::service('Session', 'nails/module-auth');
                $oSession->setFlashData($status, $message);
                redirect('admin/blog/blog/create');

            } else {

                show404();
            }
        }

        if (count($this->data['blogs']) == 1) {

            reset($this->data['blogs']);
            $this->data['selectedBlogId'] = key($this->data['blogs']);

        } elseif ($this->input->get('blog_id')) {

            if (!empty($this->data['blogs'][$this->input->get('blog_id')])) {

                $this->data['selectedBlogId'] = $this->input->get('blog_id');
            }

            if (empty($this->data['selectedBlogId'])) {

                $this->data['error'] = 'There is no blog by that ID.';
            }
        }

        //  Check user has permission
        if (!empty($this->data['selectedBlogId'])) {

            if (!userHasPermission('admin:blog:settings:' . $this->data['selectedBlogId'] . ':update')) {

                unauthorised();
            }
        }

        //  Set up the skin model for this blog
        //  @todo; work out a cleaner way of handling this
        $oSkinModel->init($this->data['selectedBlogId']);

        // --------------------------------------------------------------------------

        //  Process POST
        if ($this->input->post()) {

            //  Prepare update
            $settings                       = array();
            $settings['name']               = $this->input->post('name');
            $settings['url']                = $this->input->post('url');
            $settings['postName']           = strtolower($this->input->post('postName'));
            $settings['postNamePlural']     = strtolower($this->input->post('postNamePlural'));
            $settings['use_excerpts']       = (bool) $this->input->post('use_excerpts');
            $settings['gallery_enabled']    = (bool) $this->input->post('gallery_enabled');
            $settings['categories_enabled'] = (bool) $this->input->post('categories_enabled');
            $settings['tags_enabled']       = (bool) $this->input->post('tags_enabled');
            $settings['rss_enabled']        = (bool) $this->input->post('rss_enabled');

            //  Skin settings
            $settings['skin'] = $this->input->post('skin');

            //  Commenting settings
            $settings['comments_enabled']          = $this->input->post('comments_enabled');
            $settings['comments_engine']           = $this->input->post('comments_engine');
            $settings['comments_disqus_shortname'] = $this->input->post('comments_disqus_shortname');

            //  Social settings
            $settings['social_facebook_enabled']   = (bool) $this->input->post('social_facebook_enabled');
            $settings['social_twitter_enabled']    = (bool) $this->input->post('social_twitter_enabled');
            $settings['social_twitter_via']        = $this->input->post('social_twitter_via');
            $settings['social_googleplus_enabled'] = (bool) $this->input->post('social_googleplus_enabled');
            $settings['social_pinterest_enabled']  = (bool) $this->input->post('social_pinterest_enabled');
            $settings['social_skin']               = $this->input->post('social_skin');
            $settings['social_layout']             = $this->input->post('social_layout');
            $settings['social_layout_single_text'] = $this->input->post('social_layout_single_text');
            $settings['social_counters']           = (bool) $this->input->post('social_counters');

            //  If any of the above are enabled, then social is enabled.
            $settings['social_enabled'] = $settings['social_facebook_enabled'] || $settings['social_twitter_enabled'] || $settings['social_googleplus_enabled'] || $settings['social_pinterest_enabled'];

            //  Sidebar
            $settings['sidebar_latest_posts']  = (bool) $this->input->post('sidebar_latest_posts');
            $settings['sidebar_categories']    = (bool) $this->input->post('sidebar_categories');
            $settings['sidebar_tags']          = (bool) $this->input->post('sidebar_tags');
            $settings['sidebar_popular_posts'] = (bool) $this->input->post('sidebar_popular_posts');

            //  @todo: Associations

            // --------------------------------------------------------------------------

            //  Sanitize blog url
            $settings['url'] .= substr($settings['url'], -1) != '/' ? '/' : '';

            // --------------------------------------------------------------------------

            //  Save
            $oAppSettingService = Factory::service('AppSetting');

            if ($oAppSettingService->set($settings, 'blog-' . $this->input->get('blog_id'))) {

                $this->data['success'] = 'Blog settings have been saved.';

                $oRoutesService = Factory::service('Routes');

                if (!$oRoutesService->update()) {

                    $this->data['warning']  = '<strong>Warning:</strong> while the blog settings were updated, the ';
                    $this->data['warning'] .= 'routes file could not be updated. The blog may not behave as expected,';
                }

            } else {

                $this->data['error'] = 'There was a problem saving settings.';
            }
        }

        // --------------------------------------------------------------------------

        //  Get data
        $this->data['skins']        = $oSkinModel->getAll();
        $this->data['skinSelected'] = $oSkinModel->getEnabled();

        if (!empty($this->data['selectedBlogId'])) {

            $this->data['settings'] = appSetting(null, 'blog-' . $this->data['selectedBlogId'], true);
        }

        // --------------------------------------------------------------------------

        //  Load assets
        $oAsset = Factory::service('Asset');
        $oAsset->load('admin.settings.min.js', 'nails/module-blog');

        // --------------------------------------------------------------------------

        //  Set page title
        $this->data['page']->title = 'Settings &rsaquo; Blog';

        if (!empty($this->data['blogs'][$this->input->get('blog_id')])) {

            $this->data['page']->title .= ' &rsaquo; ' . $this->data['blogs'][$this->input->get('blog_id')];
        }

        // --------------------------------------------------------------------------

        //  Add a header button
        if (userHasPermission('admin:blog:blog:manage')) {
            Helper::addHeaderButton(
                'admin/blog/blog/index',
                'Manage Blogs'
            );
        }

        // --------------------------------------------------------------------------

        Helper::loadView('index');
    }
1281721
public function editInstall()
    {
        $this->controlAccessInstall();
        $this->translation->set($this->install_language, null);
        $this->setTitleEditInstall();

        $requirements = $this->getRequirementsInstall();
        $issues = $this->getRequirementErrorsInstall($requirements);

        $this->setData('issues', $issues);
        $this->setData('requirements', $requirements);
        $this->setData('settings.installer', 'default');
        $this->setData('timezones', gplcart_timezones());
        $this->setData('language', $this->install_language);
        $this->setData('handlers', $this->install->getHandlers());
        $this->setData('languages', $this->getLanguagesInstall());
        $this->setData('severity', $this->getSeverityInstall($issues));
        $this->setData('settings.store.language', $this->install_language);

        $this->submitEditInstall();
        $this->outputEditInstall();
    }
811631
public function Add() {
		if(!$this->_Permission())
			return;

      $this->Title(T('Add Role'));

      // Use the edit form with no roleid specified.
      $this->View = 'Edit';
      $this->Edit();
   }
390808
public function edit()
    {
        $id = $this->Auth->user('id');
        $user = $this->Users->find()->where(['id' => $id])->first();
        if (!$user) {
            throw new NotFoundException('User could not be found');
        }
            
        $user->accessible('password', true);
        if ($this->request->is(['post', 'put'])) {
            $user = $this->Users->patchEntity($user, $this->request->data);
            $this->Users->save($user);
        }
        $this->set(compact('user'));
    }
936450
public function edit()
    {
        if (!userHasPermission('admin:invoice:invoice:edit')) {
            unauthorised();
        }

        // --------------------------------------------------------------------------

        $oUri   = Factory::service('Uri');
        $oInput = Factory::service('Input');

        $iInvoiceId            = (int) $oUri->segment(5);
        $oModel                = $this->oInvoiceModel;
        $this->data['invoice'] = $oModel->getById(
            $iInvoiceId,
            ['expand' => $oModel::EXPAND_ALL]
        );

        if (!$this->data['invoice'] || $this->data['invoice']->state->id != 'DRAFT') {
            show404();
        }

        // --------------------------------------------------------------------------

        //  Page Title
        $this->data['page']->title = 'Edit Invoice &rsaquo; ' . $this->data['invoice']->ref;

        // --------------------------------------------------------------------------

        if ($oInput->post()) {
            if ($this->validatePost()) {
                if ($oModel->update($this->data['invoice']->id, $this->getObjectFromPost())) {

                    //  Send invoice if needed
                    $oInvoice = $oModel->getById($this->data['invoice']->id);
                    $this->sendInvoice($oInvoice);

                    $oSession = Factory::service('Session', 'nails/module-auth');
                    $oSession->setFlashData('success', 'Invoice was saved successfully.');

                    redirect('admin/invoice/invoice/index');

                } else {
                    $this->data['error'] = 'Failed to update invoice. ' . $oModel->lastError();
                }
            } else {
                $this->data['error'] = lang('fv_there_were_errors');
            }
        }

        // --------------------------------------------------------------------------

        //  Page data
        $aItemUnits = $this->oInvoiceItemModel->getUnits();
        $aTaxes     = $this->oTaxModel->getAll();

        $this->data['invoiceStates'] = $oModel->getSelectableStates();

        // --------------------------------------------------------------------------

        //  Invoice Items
        if ($oInput->post()) {

            $aItems = $oInput->post('items') ?: [];
            //  Tidy up post data as expected by JS
            foreach ($aItems as &$aItem) {

                $aItem['label'] = html_entity_decode($aItem['label'], ENT_QUOTES, 'UTF-8');
                $aItem['body']  = html_entity_decode($aItem['body'], ENT_QUOTES, 'UTF-8');

                $sUnitCost                     = $aItem['unit_cost'];
                $aItem['unit_cost']            = new \stdClass();
                $aItem['unit_cost']->formatted = new \stdClass();
                $aItem['unit_cost']->formatted = !empty($sUnitCost) ? $sUnitCost : null;

                $aItem['tax']     = new \stdClass();
                $aItem['tax']->id = !empty($aItem['tax_id']) ? (int) $aItem['tax_id'] : null;

                $sUnit             = !empty($aItem['unit']) ? $aItem['unit'] : null;
                $aItem['unit']     = new \stdClass();
                $aItem['unit']->id = $sUnit;
            }

        } else {
            $aItems = $this->data['invoice']->items->data;
        }

        // --------------------------------------------------------------------------

        $oCurrency                = Factory::service('Currency', 'nails/module-currency');
        $aCurrencies              = $oCurrency->getAllEnabled();
        $this->data['currencies'] = $aCurrencies;
        //  A customer ID can be specified when creating an invoice; this prevents undefined var errors
        $this->data['customer_id'] = null;

        // --------------------------------------------------------------------------

        $oAsset = Factory::service('Asset');
        //  @todo (Pablo - 2018-11-30) - Load the minified version once the JS bundling has been sorted
        $oAsset->load('invoice.edit.js', 'nails/module-invoice');
        $oAsset->inline(
            'ko.applyBindings(
                new invoiceEdit(
                    ' . json_encode($aItemUnits) . ',
                    ' . json_encode($aTaxes) . ',
                    ' . json_encode($aItems) . ',
                    ' . json_encode($aCurrencies) . '
                )
            );',
            'JS'
        );

        //  Load views
        Helper::loadView('edit');
    }
1367674
public function editUrl()
    {
        $route = 'admin::edit-'.Str::singular($this->getTable());
        if (Route::has($route)) {
            return route($route, $this->id);
        }

        return route('dashboard');
    }
858944
public function edit( $args, $assoc_args ) {
		$post = $this->fetcher->get_check( $args[0] );

		$result = $this->_edit( $post->post_content, "WP-CLI post {$post->ID}" );

		if ( false === $result ) {
			WP_CLI::warning( 'No change made to post content.', 'Aborted' );
		} else {
			$this->update( $args, [ 'post_content' => $result ] );
		}
	}
965146
public function editAction()
    {
        $model = $this->loadModel();
        if ($model->isObjectNew()) {
            $this->_forward('noroute');
            return;
        }

        if ($this->getRequest()->isPost()) {
            $postData = $this->getRequest()->getPost();
            try {
                foreach ($this->preprocessPostData($postData) as $key => $value) {
                    $model->setDataUsingMethod($key, $value);
                }
                $model->save();
                $this->_redirectUrl($this->getHelper()->getGridUrl());
                $this->_getSession()->addSuccess('Saved Successfully');
                return;
            } catch (Exception $e) {
                if ($e instanceof Zend_Db_Statement_Exception && $e->getChainedException() instanceof PDOException) {
                    $e = $e->getChainedException();
                }
                Mage::logException($e);
                $this->_getSession()->addError($e->getMessage());
            }
        }

        $this->loadLayout();
        $this->renderLayout();
    }