/**
  * 更新类别
  *
  * @param array $data 类别信息数组
  */
 public function update(array $data)
 {
     $node['cate_name'] = $data['cate_name'];
     $node['parent_id'] = $data['parent_id'];
     $node['sort_order'] = $data['sort_order'];
     $node['is_show'] = $data['is_show'];
     // 更新路径信息
     $node['path'] = $this->getPath($node['parent_id']) . $data['cate_id'] . ';';
     $where = $this->db->quoteInto('cate_id = ?', $data['cate_id']);
     $this->db->update('category', $node, $where);
     if (isset($data['is_show'])) {
         // 继承设置显示状态
         $childs = $this->getAllChilds($data['cate_id']);
         if (!empty($childs)) {
             $where = $this->db->quoteInto('cate_id in (?)', $childs);
             $this->db->update('category', array('is_show' => $data['is_show']), $where);
         }
     }
     $this->_allCates = null;
 }
Exemple #2
0
 /**
  * 重命名文件
  *
  * @return bool
  * @author weizhifeng
  **/
 protected function act_rename()
 {
     if (!$this->check_time_out()) {
         $this->time_error_msg(Kohana::lang('o_kc.time_out'));
     }
     if ($this->config['readonly'] || !isset($this->post['file']) || !isset($this->post['new_name']) || !isset($this->post['file_id']) || !isset($this->post['dir_id'])) {
         $this->error_msg(Kohana::lang('o_kc.file_not_exist'));
     }
     $file_id = (int) $this->post['file_id'];
     $new_name = trim($this->post['new_name']);
     $old_name = trim($this->post['file']);
     $dir_id = (int) $this->post['dir_id'];
     if (!strlen($new_name)) {
         $this->error_msg(Kohana::lang('o_kc.enter_new_file_name'));
     }
     if (preg_match('/[\\/\\\\]/s', $new_name)) {
         $this->error_msg(Kohana::lang('file_name_have_unallow_char'));
     }
     if (substr($new_name, 0, 1) == ".") {
         $this->error_msg(Kohana::lang('o_kc.file_name_begin_with'));
     }
     if (strlen($new_name) >= 254) {
         $this->error_msg(Kohana::lang('o_kc.file_name_too_long'));
     }
     // 文件检查
     if ($new_name != $old_name and $this->file_exists(1, $dir_id, $new_name)) {
         $this->error_msg(Kohana::lang('o_kc.file_name_exist'));
     }
     $ext = kc_file::get_extension($new_name);
     if (!$this->validate_extension($ext, $this->type)) {
         $this->error_msg(Kohana::lang('o_kc.denied_file_extension'));
     }
     $data = array('image_name' => $new_name, 'date_upd' => date('Y-m-d H:i:s'));
     if ($this->kc_image->update($file_id, $data) === FALSE) {
         $this->error_msg(Kohana::lang('o_kc.file_rename_failed'));
     }
     $this->template->content = new View("kc_rename");
 }
Exemple #3
0
function saveFBdetails()
{
    $obj = new obj();
    $data = false;
    $_SESSION['fb_login'] = true;
    $_SESSION['fb_lastname'] = $_POST['fb_lastname'];
    $_SESSION['fb_firstname'] = $_POST['fb_firstname'];
    $_SESSION['fb_email'] = $_POST['fb_email'];
    $_SESSION['fb_pic'] = $_POST['fb_pic'];
    //CHECK IF EMAIL EXISTS
    $checkUser = $obj->singleData($_SESSION['fb_email'], "email", "tbl_ut_pass");
    if ($checkUser != NULL) {
        extract($checkUser);
        //IF ALREADY HAVE LC ACCOUNT
        if ($usertype == 1) {
            $usertype = 3;
            $fb_update = array('usertype' => $usertype);
            $obj->update('tbl_ut_pass', $fb_update, "WHERE uid = " . $uid);
            $_SESSION['uid'] = $uid;
        } else {
            $_SESSION['uid'] = $uid;
        }
    } else {
        $usertype = 2;
        $obj->newReg($_SESSION['fb_firstname'], $_SESSION['fb_lastname'], "tbl_ut_user");
        foreach ($obj->showLastId("tbl_ut_user", "uid") as $value) {
            extract($value);
            $_SESSION['uid'] = $value['uid'];
        }
        $fb_data = array('uid' => $uid, 'email' => $_SESSION['fb_email'], 'usertype' => $usertype);
        $obj->insert('tbl_ut_pass', $fb_data);
    }
    $_SESSION['user_lastname'] = $_POST['fb_lastname'];
    $_SESSION['user_firstname'] = $_POST['fb_firstname'];
    $_SESSION['user_pic'] = $_POST['fb_pic'];
    $data = $_SESSION['uid'];
    echo json_encode($data);
}