Exemplo n.º 1
0
 public function beforeUpdate()
 {
     if (!Observer::notify('layout_before_edit', $this)) {
         return false;
     }
     $this->updated_by_id = AuthUser::getId();
     $this->updated_on = date('Y-m-d H:i:s');
     return true;
 }
Exemplo n.º 2
0
 private static function _checkPermission()
 {
     AuthUser::load();
     if (!AuthUser::isLoggedIn()) {
         redirect(get_url('login'));
     } else {
         if (!AuthUser::getId() == 1) {
             Flash::set('error', __('You do not have permission to access the requested page!'));
             redirect(get_url());
         }
     }
 }
Exemplo n.º 3
0
 public function beforeUpdate()
 {
     /* TODO: Figure out logic behind xxx_on_time variables
        $this->created_on = $this->created_on . ' ' . $this->created_on_time;
        unset($this->created_on_time);
        */
     if (!empty($this->published_on)) {
         /*
         $this->published_on = $this->published_on . ' ' . $this->published_on_time;
         unset($this->published_on_time);
         */
     } else {
         if ($this->status_id == Page::STATUS_PUBLISHED) {
             $this->published_on = date('Y-m-d H:i:s');
         }
     }
     $this->updated_by_id = AuthUser::getId();
     $this->updated_on = date('Y-m-d H:i:s');
     return true;
 }
Exemplo n.º 4
0
 public function edit($id)
 {
     if ($_POST["action"] == "edit") {
         $data = $_POST['event'];
         Flash::set('postdata', $data);
         $event = Record::findByIdFrom('Event', $id);
         if (!$event) {
             Flash::set('error', __('Event not found!'));
             redirect(get_url('event'));
         }
         $save = true;
         // verification
         if (empty($data['title'])) {
             Flash::set('error', __('You have to specify a event title!'));
             redirect(get_url('event/view/' . $id));
         }
         if (empty($data['url'])) {
             Flash::set('error', __('You have to specify the "Read More" URL!'));
             redirect(get_url('event/view/' . $id));
         }
         $event->setFromData($data);
         $event->updated_by_id = AuthUser::getId();
         $event->updated_on = date('Y-m-d H:i:s');
         if (!$event->save()) {
             Flash::set('error', __('Event is not updated!'));
             redirect(get_url('event/view/' . $id));
         } else {
             $this->upload($id);
             Flash::set('success', __('Event has been updated!'));
             if (isset($_POST['commit'])) {
                 redirect(get_url('event'));
             } else {
                 redirect(get_url('event/view/' . $id));
             }
         }
     }
 }
 function _insert_log($message)
 {
     $log_data = array("message" => $message, "user_id" => AuthUser::getId());
     $record = Record::insert('ecommerce_log', $log_data);
 }
Exemplo n.º 6
0
    echo __('Memory usage:');
    ?>
 <?php 
    echo memory_usage();
    ?>
        </p>
<?php 
}
?>

      <p id="site-links">
        <?php 
echo __('You are currently logged in as');
?>
 <a href="<?php 
echo get_url('user/edit/' . AuthUser::getId());
?>
"><?php 
echo AuthUser::getRecord()->name;
?>
</a>
        <span class="separator"> | </span>
        <a id="site-view-link" href="<?php 
echo URL_PUBLIC;
?>
" target="_blank"><?php 
echo __('View Site');
?>
</a>
		<span class="separator"> | </span>
        <a href="<?php 
Exemplo n.º 7
0
 public function edit($id)
 {
     if ($_POST["action"] == "edit") {
         $data = $_POST['news'];
         Flash::set('postdata', $data);
         $news = Record::findByIdFrom('News', $id);
         if (!$news) {
             Flash::set('error', __('Promo could not be found!'));
             redirect(get_url('news'));
         }
         $save = true;
         // verification
         if (empty($data['title'])) {
             Flash::set('error', __('You have to specify a news title!'));
             redirect(get_url('news/view/' . $id));
         }
         // if (empty($data['url'])){
         // 	Flash::set('error', __('You have to specify the URL!'));
         // 	redirect(get_url('news/view/'.$id));
         // }
         $news->setFromData($data);
         $news->updated_by_id = AuthUser::getId();
         $news->updated_on = date('Y-m-d H:i:s');
         if (!$news->save()) {
             Flash::set('error', __('Promo is not updated!'));
             redirect(get_url('news/view/' . $id));
         } else {
             $this->upload($id);
             Flash::set('success', __('Promo has been updated!'));
             if (isset($_POST['commit'])) {
                 redirect(get_url('news'));
             } else {
                 redirect(get_url('news/view/' . $id));
             }
         }
     }
 }
Exemplo n.º 8
0
 public function add_sidebarlink()
 {
     $this->_checkPermission();
     $data = $_POST['sidebarlink'];
     Flash::set('postdata', $data);
     $image = $_POST['upload'];
     $path = str_replace('..', '', $image['path']);
     $overwrite = false;
     // verification
     if (empty($data['type'])) {
         Flash::set('error', __('You have to specify the sidebar link type!'));
         redirect(get_url('sidebarlink/create'));
     }
     //For sidebarlink image
     if (empty($_FILES['upload_file']['name'])) {
         Flash::set('error', __('You have to select a image to be uploaded!'));
         redirect(get_url('sidebarlink/create'));
     }
     $sidebarlink = new SidebarLink($data);
     $sidebarlink->created_by_id = AuthUser::getId();
     $sidebarlink->created_on = date('Y-m-d H:i:s');
     if (!$sidebarlink->save()) {
         Flash::set('error', __('Sidebar link is not added!'));
         redirect(get_url('sidebarlink', 'create'));
     } else {
         if (isset($_FILES)) {
             $id = $sidebarlink->lastInsertId();
             $file = $this->upload_file($_FILES['upload_file']['name'], FILES_DIR . '/sidebarlink/images/', $_FILES['upload_file']['tmp_name'], $overwrite, $id);
             if ($file === false) {
                 Flash::set('error', __('File has not been uploaded!'));
             }
         }
         Flash::set('success', __('Sidebar link has been added!'));
     }
     redirect(get_url('sidebarlink'));
 }
Exemplo n.º 9
0
 private function _edit($id)
 {
     $data = $_POST['user'];
     // CSRF checks
     if (isset($_POST['csrf_token'])) {
         $csrf_token = $_POST['csrf_token'];
         if (!SecureToken::validateToken($csrf_token, BASE_URL . 'user/edit')) {
             Flash::set('error', __('Invalid CSRF token found!'));
             redirect(get_url('user/add'));
         }
     } else {
         Flash::set('error', __('No CSRF token found!'));
         redirect(get_url('user/edit'));
     }
     // check if user want to change the password
     if (strlen($data['password']) > 0) {
         // check if pass and confirm are egal and >= 5 chars
         if (strlen($data['password']) >= 5 && $data['password'] == $data['confirm']) {
             unset($data['confirm']);
         } else {
             Flash::set('error', __('Password and Confirm are not the same or too small!'));
             redirect(get_url('user/edit/' . $id));
         }
     } else {
         unset($data['password'], $data['confirm']);
     }
     $user = Record::findByIdFrom('User', $id);
     if (isset($data['password'])) {
         $data['password'] = AuthUser::generateHashedPassword($data['password'], $user->salt);
     }
     $user->setFromData($data);
     if ($user->save()) {
         if (AuthUser::hasPermission('administrator')) {
             // now we need to add permissions
             $data = isset($_POST['user_permission']) ? $_POST['user_permission'] : array();
             UserPermission::setPermissionsFor($user->id, $data);
         }
         Flash::set('success', __('User has been saved!'));
     } else {
         Flash::set('error', __('User has not been saved!'));
     }
     if (AuthUser::getId() == $id) {
         redirect(get_url('user/edit/' . $id));
     } else {
         redirect(get_url('user'));
     }
 }
Exemplo n.º 10
0
 public function addAction()
 {
     global $tpl;
     //如果是分表则通过$_POST['content'], $_POST['content_part']区分
     //$data = isset($_POST['article']) ? $_POST['article'] : array();
     $data = array();
     if (isset($_POST['add']) || isset($_POST['save'])) {
         $data = $_POST['content'];
         //判断ID是否存在
         if (!$data['id']) {
             //add
             $data['slug'] = !empty($data['slug']) ? dealWords($data['slug']) : null;
             $data['created_uid'] = AuthUser::getId();
             $data['created_date'] = time();
             $article = new Article($data);
             if ($article->save()) {
                 $data_part = array();
                 $data_part = $_POST['content_part'];
                 $data_part['id'] = $article->id;
                 $content_part = new ContentPart($data_part);
                 $content_part->insert();
                 $article->content = $content_part->content;
                 //save tags
                 $article->saveTags(trim($_POST['tags']));
                 //update category
                 $category = new Category('id', $article->cid);
                 $category->count++;
                 $category->save();
                 $article->category = $category->name;
                 $article->category_slug = $category->slug;
                 //删除上一篇缓存
                 $prev = $article->previous();
                 $this->delPostHtml($prev->id);
             }
         } else {
             //update
             $data['updated_uid'] = AuthUser::getId();
             $data['updated_date'] = time();
             $old_article = new Article('id', $data['id']);
             $article = new Article($data);
             if ($article->save()) {
                 $data_part = array();
                 $data_part = $_POST['content_part'];
                 $data_part['id'] = $article->id;
                 $content_part = new ContentPart($data_part);
                 $content_part->save();
                 $article->content = $content_part->content;
                 $article->saveTags($_POST['tags']);
                 //更新文章分类统计
                 if ($old_article->cid != $article->cid) {
                     $c1 = new Category('id', $article->cid);
                     $c1->count++;
                     $c1->save();
                     $c2 = new Category('id', $old_article->cid);
                     $c2->count--;
                     $c2->save();
                 }
             }
         }
         //$_POST = array();
         $tpl->assign('article', $article);
         //生成静态页面
         $status = isset($data['status']) ? $data['status'] : 'draft';
         if ($status == 'publish') {
             $this->createPostHtml($article);
         } else {
             if ($status == 'draft') {
                 $this->delPostHtml($article->id);
             }
         }
         del_cache();
         if (isset($_POST['add'])) {
             header('location:index.php?job=admin_article');
         }
     }
     $categories = Category::findAll();
     $tpl->assign('cats', $categories);
     $tpl->display('admin/article_add.html');
 }
Exemplo n.º 11
0
 public function edit($id)
 {
     if ($_POST["action"] == "edit") {
         $data = $_POST['dine'];
         Flash::set('postdata', $data);
         $dine = Record::findByIdFrom('Dine', $id);
         if (!$dine) {
             Flash::set('error', __('Dine could not be found!'));
             redirect(get_url('dine'));
         }
         $save = true;
         // verification
         if (empty($data['title'])) {
             Flash::set('error', __('You have to specify a dine title!'));
             redirect(get_url('dine/view/' . $id));
         }
         $dine->setFromData($data);
         $dine->updated_by_id = AuthUser::getId();
         $dine->updated_on = date('Y-m-d H:i:s');
         if (!$dine->save()) {
             Flash::set('error', __('Dine is not updated!'));
             redirect(get_url('dine/view/' . $id));
         } else {
             $this->upload($id);
             Flash::set('success', __('Dine has been updated!'));
             if (isset($_POST['commit'])) {
                 redirect(get_url('dine'));
             } else {
                 redirect(get_url('dine/view/' . $id));
             }
         }
     }
 }
Exemplo n.º 12
0
 public function beforeUpdate()
 {
     if (!Observer::notify('page_edit_before_save', $this)) {
         return false;
     }
     if (!strpos($this->created_on, " ") && $this->created_on_time) {
         $this->created_on = $this->created_on . ' ' . $this->created_on_time;
         unset($this->created_on_time);
     }
     if (!empty($this->published_on)) {
         if (!strpos($this->published_on, " ") && $this->published_on_time) {
             $this->published_on = $this->published_on . ' ' . $this->published_on_time;
             unset($this->published_on_time);
         }
     } else {
         if ($this->status_id == Page::STATUS_PUBLISHED) {
             $this->published_on = date('Y-m-d H:i:s');
         }
     }
     $this->updated_by_id = AuthUser::getId();
     $this->updated_on = date('Y-m-d H:i:s');
     return true;
 }
Exemplo n.º 13
0
 public function _edit_category($id)
 {
     $data = $_POST['cat'];
     Flash::set('postdata', $data);
     $category_rec = Record::query('select * from ' . TABLE_PREFIX . 'newscategory where id=' . $id);
     $cat = $category_rec->fetchObject();
     if (!$cat) {
         Flash::set('error', __('News category could not be found!'));
         redirect(get_url('news'));
     }
     $save = true;
     // verification
     if (empty($data['title'])) {
         Flash::set('error', __('You have to specify a category name!'));
         redirect(get_url('news/edit_category/' . $id));
     }
     $title = $data['title'];
     $status = $data['status'];
     $cat = Record::query('Update ' . TABLE_PREFIX . 'newscategory set title=' . $title . ', status="' . $status . '", updated_by_id=' . AuthUser::getId() . ',updated_on="' . date('Y-m-d H:i:s') . '" where id="' . $id . '"');
     $cat->execute();
     Flash::set('success', __('Category has been updated!'));
     if (isset($_POST['commit'])) {
         redirect(get_url('news'));
     } else {
         redirect(get_url('news/edit_category/' . $id));
     }
 }
Exemplo n.º 14
0
function registered_users_page_found($page)
{
    $PDO = Record::getConnection();
    // If login is required for the page
    if ($page->getLoginNeeded() == Page::LOGIN_REQUIRED) {
        AuthUser::load();
        // Not Logged In
        if (!AuthUser::isLoggedIn()) {
            // Get the current page id
            $requested_page_id = $page->id();
            // Let's get the page that is set as the login page to prevent any loopbacks
            $getloginpage = 'SELECT * FROM ' . TABLE_PREFIX . "page WHERE behavior_id='login_page'";
            $getloginpage = $PDO->prepare($getloginpage);
            $getloginpage->execute();
            while ($loginpage = $getloginpage->fetchObject()) {
                $slug = $loginpage->slug;
                print_r($loginpage);
            }
            if ($requested_page_id != $loginpage_id) {
                header('Location: ' . BASE_URL . $slug);
            }
        } else {
            // We need to check if the user has permission to access the page
            // Get requested page id
            $requested_page_id = $page->id();
            // Get permissions that are required for this page
            $permissions_check = "SELECT * FROM " . TABLE_PREFIX . "permission_page WHERE page_id='{$requested_page_id}'";
            $permissions_check = $PDO->prepare($permissions_check);
            $permissions_check->execute();
            $permission_array = array();
            while ($permission = $permissions_check->fetchObject()) {
                $page_permission = $permission->permission_id;
                array_push($permission_array, $page_permission);
            }
            $permissions_count = count($permission_array);
            AuthUser::load();
            $userid = AuthUser::getRecord()->id;
            // Get permissions that this user has
            /*
            			$user_permissions_check = "SELECT * FROM ".TABLE_PREFIX."user_permission WHERE user_id='$userid'";
            			$user_permissions_check = $__CMS_CONN__->prepare($user_permissions_check);
            			$user_permissions_check->execute();
            
            			$user_permissions_array = array();
            
            			while ($user_permissions = $user_permissions_check->fetchObject()) {
            				$user_permission = $user_permissions->permission_id;
            				array_push($user_permissions_array, $user_permission);
            			}*/
            $roles = AuthUser::getRecord()->roles();
            foreach ($roles as $role) {
                $user_permissions_array[] = $role->id;
            }
            $permission_result = array_intersect($permission_array, $user_permissions_array);
            $permission_result_count = count($permission_result);
            if ($permission_result_count < 1 && AuthUser::getId() != 1) {
                // Let's get the authorisation required page
                $auth_required_page = Plugin::getSetting("auth_required_page", "registered_users");
                header('Location: ' . URL_PUBLIC . '' . $auth_required_page . '');
            }
        }
    }
}
Exemplo n.º 15
0
 /**
  * @todo merge _add() and _edit() into one _store()
  *
  * @param <type> $id
  */
 private function _edit($id)
 {
     use_helper('Validate');
     $data = $_POST['user'];
     Flash::set('post_data', (object) $data);
     // Add pre-save checks here
     $errors = false;
     // CSRF checks
     if (isset($_POST['csrf_token'])) {
         $csrf_token = $_POST['csrf_token'];
         if (!SecureToken::validateToken($csrf_token, BASE_URL . 'user/edit')) {
             Flash::set('error', __('Invalid CSRF token found!'));
             redirect(get_url('user/edit/' . $id));
         }
     } else {
         Flash::set('error', __('No CSRF token found!'));
         redirect(get_url('user/edit/' . $id));
     }
     // check if user want to change the password
     if (strlen($data['password']) > 0) {
         // check if pass and confirm are egal and >= 5 chars
         if (strlen($data['password']) >= 5 && $data['password'] == $data['confirm']) {
             unset($data['confirm']);
         } else {
             Flash::set('error', __('Password and Confirm are not the same or too small!'));
             redirect(get_url('user/edit/' . $id));
         }
     } else {
         unset($data['password'], $data['confirm']);
     }
     // Check alphanumerical fields
     $fields = array('username');
     foreach ($fields as $field) {
         if (!empty($data[$field]) && !Validate::alphanum_space($data[$field])) {
             $errors[] = __('Illegal value for :fieldname field!', array(':fieldname' => $field));
         }
     }
     if (!empty($data['name']) && !Validate::alphanum_space($data['name'], true)) {
         $errors[] = __('Illegal value for :fieldname field!', array(':fieldname' => 'name'));
     }
     if (!empty($data['email']) && !Validate::email($data['email'])) {
         $errors[] = __('Illegal value for :fieldname field!', array(':fieldname' => 'email'));
     }
     if (!empty($data['language']) && !Validate::alpha($data['language'])) {
         $errors[] = __('Illegal value for :fieldname field!', array(':fieldname' => 'language'));
     }
     if ($errors !== false) {
         // Set the errors to be displayed.
         Flash::set('error', implode('<br/>', $errors));
         redirect(get_url('user/edit/' . $id));
     }
     $user = Record::findByIdFrom('User', $id);
     if (isset($data['password'])) {
         if (empty($user->salt)) {
             $user->salt = AuthUser::generateSalt();
         }
         $data['password'] = AuthUser::generateHashedPassword($data['password'], $user->salt);
     }
     $user->setFromData($data);
     if ($user->save()) {
         if (AuthUser::hasPermission('user_edit')) {
             // now we need to add permissions
             $data = isset($_POST['user_permission']) ? $_POST['user_permission'] : array();
             UserRole::setPermissionsFor($user->id, $data);
         }
         Flash::set('success', __('User has been saved!'));
         Observer::notify('user_after_edit', $user->name);
     } else {
         Flash::set('error', __('User has not been saved!'));
     }
     if (AuthUser::getId() == $id) {
         redirect(get_url('user/edit/' . $id));
     } else {
         redirect(get_url('user'));
     }
 }
 public function beforeSave()
 {
     if (empty($this->created_by_id)) {
         $user_id = AuthUser::getId();
         if ($user_id === false) {
             return false;
         } else {
             $this->created_by_id = $user_id;
         }
     }
     if ($this->checkData()) {
         return parent::beforeSave();
     } else {
         return false;
     }
 }
Exemplo n.º 17
0
 public function beforeUpdate()
 {
     $this->created_on = $this->created_on . ' ' . $this->created_on_time;
     unset($this->created_on_time);
     if (!empty($this->published_on)) {
         $this->published_on = $this->published_on . ' ' . $this->published_on_time;
         unset($this->published_on_time);
     } else {
         if ($this->status_id == Page::STATUS_PUBLISHED) {
             $this->published_on = date('Y-m-d H:i:s');
         }
     }
     if (!empty($this->valid_until)) {
         $this->valid_until = $this->valid_until . ' ' . $this->valid_until_time;
         unset($this->valid_until_time);
         if ($this->valid_until < date('Y-m-d H:i:s')) {
             $this->status_id = Page::STATUS_ARCHIVED;
         }
     }
     unset($this->valid_until_time);
     $this->updated_by_id = AuthUser::getId();
     $this->updated_on = date('Y-m-d H:i:s');
     unset($this->url);
     unset($this->level);
     unset($this->tags);
     unset($this->parent);
     return true;
 }
Exemplo n.º 18
0
 public function edit($id)
 {
     if ($_POST["action"] == "edit") {
         $data = $_POST['career'];
         Flash::set('postdata', $data);
         $career = Record::findByIdFrom('Career', $id);
         if (!$career) {
             Flash::set('error', __('Career not found!'));
             redirect(get_url('career'));
         }
         $save = true;
         // verification
         if (empty($data['title'])) {
             Flash::set('error', __('You have to specify a job title!'));
             redirect(get_url('career/view/' . $id));
         }
         // if (empty($data['contact_person'])){
         // 	Flash::set('error', __('You have to specify the contact email!'));
         // 	redirect(get_url('career/view/'.$id));
         // }
         if (empty($data['posted_date'])) {
             Flash::set('error', __('You have to specify the posted date!'));
             redirect(get_url('career/view/' . $id));
         }
         if (empty($data['closing_date'])) {
             Flash::set('error', __('You have to specify the closing date!'));
             redirect(get_url('career/view/' . $id));
         }
         $career->setFromData($data);
         $career->posted_date = date("Y-m-d", strtotime($career->posted_date));
         $career->closing_date = date("Y-m-d", strtotime($career->closing_date));
         $career->updated_by_id = AuthUser::getId();
         $career->updated_on = date('Y-m-d H:i:s');
         if (!$career->save()) {
             Flash::set('error', __('Career is not updated!'));
             redirect(get_url('career/view/' . $id));
         } else {
             Flash::set('success', __('Career has been updated!'));
             if (isset($_POST['commit'])) {
                 redirect(get_url('career'));
             } else {
                 redirect(get_url('career/view/' . $id));
             }
         }
     }
 }
Exemplo n.º 19
0
 public function beforeUpdate()
 {
     $this->created_on = $this->created_on . ' ' . $this->created_on_time;
     unset($this->created_on_time);
     if (!empty($this->published_on)) {
         $this->published_on = $this->published_on . ' ' . $this->published_on_time;
         unset($this->published_on_time);
     } else {
         if ($this->status_id == Page::STATUS_PUBLISHED) {
             $this->published_on = date('Y-m-d H:i:s');
         }
     }
     $this->updated_by_id = AuthUser::getId();
     $this->updated_on = date('Y-m-d H:i:s');
     return true;
 }
Exemplo n.º 20
0
 function _edit($id)
 {
     $data = $_POST['user'];
     // check if user want to change the password
     if (strlen($data['password']) > 0) {
         // check if pass and confirm are egal and >= 5 chars
         if (strlen($data['password']) >= 5 && $data['password'] == $data['confirm']) {
             $data['password'] = sha1($data['password']);
             unset($data['confirm']);
         } else {
             Flash::set('error', __('Password and Confirm are not the same or too small!'));
             redirect(get_url('user/edit/' . $id));
         }
     } else {
         unset($data['password'], $data['confirm']);
     }
     $user = User::findById($id);
     $user->setFromData($data);
     if ($user->save()) {
         if (AuthUser::hasPermission('administrator')) {
             // now we need to add permissions
             $data = isset($_POST['user_permission']) ? $_POST['user_permission'] : array();
             UserPermission::setPermissionsFor($user->id, $data);
         }
         Flash::set('success', __('User has been saved!'));
     } else {
         Flash::set('error', __('User has not been saved!'));
     }
     if (AuthUser::getId() == $id) {
         redirect(get_url('user/edit/' . $id));
     } else {
         redirect(get_url('user'));
     }
 }
Exemplo n.º 21
0
 private function _edit($id)
 {
     use_helper('Validate');
     $data = $_POST['testimonial'];
     Flash::set('testimonial_postdata', $data);
     $errors = false;
     // CSRF checks
     if (isset($_POST['csrf_token'])) {
         $csrf_token = $_POST['csrf_token'];
         if (!SecureToken::validateToken($csrf_token, BASE_URL . 'testimonial/edit/' . $id)) {
             Flash::set('error', __('Invalid CSRF token found!'));
             redirect(get_url('testimonial/edit/' . $id));
         }
     } else {
         Flash::set('error', __('No CSRF token found!'));
         redirect(get_url('testimonial/edit/' . $id));
     }
     if (empty($data['name'])) {
         Flash::set('error', __('You have to specify a name!'));
         redirect(get_url('testimonial/add'));
     }
     if ($errors !== false) {
         // Set the errors to be displayed.
         Flash::set('error', implode('<br/>', $errors));
         redirect(get_url('testimonial/edit/' . $id));
     }
     $testimonial = Record::findByIdFrom('Testimonial', $id);
     $testimonial->setFromData($data);
     $testimonial->updated_by_id = AuthUser::getId();
     $testimonial->updated_on = date('Y-m-d H:i:s');
     if ($testimonial->save()) {
         // print_r($_FILES);exit;
         /*if (isset($_FILES)) {
         			if(strlen($_FILES['upload_file']['name'])>0||strlen($_FILES['upload_file_home']['name'])>0){
         				$overwrite=false;
         				
         				if(strlen($_FILES['upload_file']['name'])>0){
         					$file = $this->upload_pdf_file($id, $_FILES['upload_file']['name'], FILES_DIR.'/testimonial/images/', $_FILES['upload_file']['tmp_name'], $overwrite);
         				}
         				if(strlen($_FILES['upload_file_home']['name'])>0){
         					$file2 = $this->upload_pdf_file2($id, $_FILES['upload_file_home']['name'], FILES_DIR.'/testimonial/home/', $_FILES['upload_file_home']['tmp_name'], $overwrite);
         				}
         				
         				if ($file === false||$file2 === false)
         				Flash::set('error', __('File has not been uploaded!'));
         	            redirect(get_url('testimonial/edit/'.$id));
                 	}
         		}*/
         Flash::set('success', __('Testimonial has been saved!'));
         Observer::notify('testimonial_after_edit', $testimonial->name);
     } else {
         Flash::set('error', __('Testimonial has not been saved1!'));
     }
     // save and quit or save and continue editing?
     if (isset($_POST['commit'])) {
         redirect(get_url('testimonial'));
     } else {
         redirect(get_url('testimonial/edit/' . $id));
     }
 }
Exemplo n.º 22
0
 private function _edit($id)
 {
     use_helper('Validate');
     $data = $_POST['experience'];
     Flash::set('experience_postdata', $data);
     $errors = false;
     // CSRF checks
     if (isset($_POST['csrf_token'])) {
         $csrf_token = $_POST['csrf_token'];
         if (!SecureToken::validateToken($csrf_token, BASE_URL . 'experience/edit/' . $id)) {
             Flash::set('error', __('Invalid CSRF token found!'));
             redirect(get_url('experience/edit/' . $id));
         }
     } else {
         Flash::set('error', __('No CSRF token found!'));
         redirect(get_url('experience/edit/' . $id));
     }
     if (empty($data['name'])) {
         Flash::set('error', __('You have to specify a name!'));
         redirect(get_url('experience/add'));
     }
     if ($errors !== false) {
         // Set the errors to be displayed.
         Flash::set('error', implode('<br/>', $errors));
         redirect(get_url('experience/edit/' . $id));
     }
     $experience = Record::findByIdFrom('Experience', $id);
     $experience->setFromData($data);
     $experience->updated_by_id = AuthUser::getId();
     $experience->updated_on = date('Y-m-d H:i:s');
     if ($experience->save()) {
         // print_r($_FILES);exit;
         if (isset($_FILES)) {
             if (strlen($_FILES['upload_file']['name']) > 0) {
                 //okstmtcc 20150827 Replace image filename spaces
                 $_FILES['upload_file']['name'] = str_replace(array(" ", "(", ")"), array("_", "", ""), $_FILES['upload_file']['name']);
                 $overwrite = false;
                 $file = $this->upload_experience_main_image($id, $_FILES['upload_file']['name'], FILES_DIR . '/experience/images/', $_FILES['upload_file']['tmp_name'], $overwrite);
                 if ($file === false) {
                     Flash::set('error', __('File has not been uploaded!'));
                 }
                 redirect(get_url('experience/edit/' . $id));
             }
         }
         Flash::set('success', __('Experience has been saved!'));
         Observer::notify('experience_after_edit', $experience->name);
     } else {
         Flash::set('error', __('Experience has not been saved!'));
     }
     // save and quit or save and continue editing?
     if (isset($_POST['commit'])) {
         redirect(get_url('experience'));
     } else {
         redirect(get_url('experience/edit/' . $id));
     }
 }
Exemplo n.º 23
0
 public function beforeUpdate()
 {
     $this->updated_by_id = AuthUser::getId();
     $this->updated_on = date('Y-m-d H:i:s');
     return true;
 }
 public function beforeSave()
 {
     if ($this->checkData()) {
         /* if creator's id is known, then just return true */
         if (empty($this->created_by_id)) {
             /* if it's not known -- get it */
             $user_id = AuthUser::getId();
             if ($user_id === false) {
                 return false;
             } else {
                 $this->created_by_id = $user_id;
             }
         }
         /* everything is ok */
         return true;
     } else {
         return false;
     }
 }