/**
  *
  * Edits current topic
  */
 public function edit_topic($cid, $tid, $pid, $title, $imessage, $omessage, $topic_status = Forum::APPROVED)
 {
     $tid = (int) $tid;
     $pid = (int) $pid;
     $title = \CODOF\Format::title($title);
     $qry = 'UPDATE ' . PREFIX . 'codo_topics SET cat_id=:cat_id, title=:title, topic_updated=:time, topic_status=:topic_status ' . 'WHERE topic_id=:tid';
     $t_stmt = $this->db->prepare($qry);
     $t_stmt->execute(array(":cat_id" => $cid, ":title" => $title, ":time" => time(), ":tid" => $tid, ":topic_status" => $topic_status));
     $qry = 'UPDATE ' . PREFIX . 'codo_posts SET cat_id=:cat_id,imessage=:imesg, omessage=:omesg,' . 'post_modified=:time WHERE post_id=:pid';
     $p_stmt = $this->db->prepare($qry);
     $p_stmt->execute(array(":cat_id" => $cid, ":imesg" => \CODOF\Format::imessage($imessage), ":omesg" => \CODOF\Format::omessage($omessage), ":time" => time(), ":pid" => $pid));
 }
Beispiel #2
0
 /**
  * Inserts a new post in codo_posts
  * 
  * @param type $catid
  * @param type $tid
  * @param type $imesg
  * @param type $omesg
  */
 public function ins_post($catid, $tid, $imesg, $omesg, $needsModeration = false)
 {
     \CODOF\Hook::call('before_post_insert');
     $time = time();
     $uid = $_SESSION[UID . 'USER']['id'];
     $post_status = Topic::APPROVED;
     if ($needsModeration) {
         $post_status = Topic::MODERATION_BY_FILTER;
     }
     //$message = \CODOF\Filter::msg_safe($mesg);
     //$mesg = nl2br($message);
     $qry = 'INSERT INTO codo_posts (topic_id,cat_id,uid,imessage,omessage,post_created,post_status) ' . 'VALUES(:tid, :cid, :uid, :imesg, :omesg, :post_created,:post_status)';
     $stmt = $this->db->prepare($qry);
     $params = array(":tid" => $tid, ":cid" => $catid, ":uid" => $uid, ":imesg" => \CODOF\Format::imessage($imesg), ":omesg" => \CODOF\Format::omessage($omesg), ":post_created" => $time, ":post_status" => $post_status);
     $this->success = $stmt->execute($params);
     $pid = $this->db->lastInsertId();
     if ($this->success && !$needsModeration) {
         $this->incPostCount($catid, $tid, $uid);
         \CODOF\Hook::call('after_post_insert', $pid);
         return $pid;
     }
     return false;
 }
Beispiel #3
0
 public function edit_profile($id)
 {
     $edit = \CODOF\User\User::get();
     $id = (int) $id;
     if (!$this->can_edit_profile($id)) {
         $this->view = 'access_denied';
         return false;
     }
     $values = array("name" => \CODOF\Filter::msg_safe($_POST['name']), "signature" => \CODOF\Format::omessage($_POST['signature']));
     $success = true;
     if (isset($_FILES) && $_FILES['avatar']['error'] != UPLOAD_ERR_NO_FILE) {
         $success = false;
         \CODOF\File\Upload::$width = 128;
         \CODOF\File\Upload::$height = 128;
         \CODOF\File\Upload::$resizeImage = true;
         \CODOF\File\Upload::$resizeIconPath = DATA_PATH . PROFILE_ICON_PATH;
         $result = \CODOF\File\Upload::do_upload($_FILES['avatar'], PROFILE_IMG_PATH);
         if (\CODOF\File\Upload::$error) {
             $this->smarty->assign('file_upload_error', $result);
         } else {
             $values["avatar"] = $result['name'];
             $success = true;
         }
     }
     $edited = $edit->set($values);
     if (!$edited) {
         Util::log("Failed to update user details profile/id/edit");
         $success = false;
     }
     $this->smarty->assign('user_profile_edit', $success);
     $this->profile($id, 'edit');
 }