public function AddAttach($result, $destination, $type = REALTION_ATTACH) { $data = array('attach_filename' => $result['value']['name'], 'attach_size' => $result['value']['size'], 'attach_ext' => $result['value']['ext'], 'attach_location' => $result['value']['path'], 'attach_time' => time(), 'attach_label' => $_POST['label'], 'attach_url' => str_replace('../upload/', UR_UPLOAD, $result['value']['path'])); $id = $this->Create($data); $rel = TRelation::GetInstance(); return $rel->Add($id, $destination, $type); }
public function GetAttached($destination, $type = REALTION_ATTACH) { $rel = TRelation::GetInstance(); $result = $rel->GetByDestination($destination, $type); if (count($result) > 0) { $sql = "SELECT attach_label,attach_id FROM %table% WHERE attach_id IN(" . implode(',', $result) . ') ;'; $result = $this->db->select($sql, array('attach')); } return $result; }
/** * Get categories of a destination * @param int $destination destination id * @param int $type */ public function GetCategories($destination, $type = RELATION_CATEGORY) { // Pre hook _hk('P' . ':' . __CLASS__ . ':' . __FUNCTION__, $this, $destination, $type); $rel = TRelation::GetInstance(); $sources = $rel->GetByDestination($destination, $type); $result = $this->GetCheckedCategories($sources); // result hook _hk('R' . ':' . __CLASS__ . ':' . __FUNCTION__, $this, $result); return $result; }
<?php $topix = GetTopicByLiker($url[1], 10); $smarty->assign('topix', $topix); $r = TRelation::GetInstance(); $member['likes'] = $r->GetSourceCount($url[1], REALTION_LIKE); $member['frinds'] = $r->GetSourceCount($url[1], REALTION_FRIEND); $member['comz'] = GetCount('comment', ' comment_member_id = ' . (int) $_COOKIE['mid']); $smarty->assign('member', $member); $smarty->assign('frindz', GetFrienz($url[1])); $idd = isset($_COOKIE['mid']) ? $_COOKIE['mid'] : 0; $smarty->assign('is_f', $r->Has($idd, $url[1], REALTION_FRIEND));
public function CatSync($id) { $rel = TRelation::GetInstance(); $rel->Sync($_POST['category'], $id, RELATION_CATEGORY); unset($_POST['category']); }
function GetAttached($destination, $type = REALTION_ATTACH) { global $database_handle; $rel = TRelation::GetInstance(); $result = $rel->GetByDestination($destination, $type); if (count($result) > 0) { $sql = "SELECT attach_filename,attach_url FROM %table% WHERE attach_id IN(" . implode(',', $result) . ') ;'; $result = $database_handle->select($sql, array('attach')); } return $result; }
<?php $rel_cls = TRelation::GetInstance(); function GetRelDst($typ, $table, $arg = array()) { // get global array global $ID, $database_handle; $fields = isset($arg['fields']) ? $arg['fields'] : '*'; $prefix = isset($arg['prefix']) ? $arg['prefix'] : $table . '_'; $order = isset($arg['order']) ? $arg['order'] : $prefix . 'id DESC'; $filter = isset($arg['rule']) ? ' AND ' . $arg['rule'] : null; $rule = isset($arg['rule']) ? ' AND ' . $arg['rule'] : null; $sql = "SELECT o.{$fields} FROM " . DB_PREFIX . "relation AS r " . "JOIN %table% AS o ON r.src = o.{$prefix}id WHERE " . "r.dst = {$ID} AND r.typ = {$typ} {$rule} {$filter} ORDER BY {$order} ;"; // die($sql); return $database_handle->Select($sql, array($table)); } function GetRelSrc($typ, $table, $arg = array()) { // get global array global $ID, $database_handle; $fields = isset($arg['fields']) ? $arg['fields'] : '*'; $prefix = isset($arg['prefix']) ? $arg['prefix'] : $table . '_'; $order = isset($arg['order']) ? $arg['order'] : $prefix . 'id DESC'; $filter = isset($arg['filter']) ? ' AND ' . $arg['filter'] : null; $rule = isset($arg['rule']) ? ' AND ' . $arg['rule'] : null; $sql = "SELECT o.{$fields} FROM " . DB_PREFIX . "relation AS r " . "JOIN %table% AS o ON r.dst = o.{$prefix}id WHERE " . "r.src = {$ID} AND r.typ = {$typ} {$rule} {$filter} ORDER BY {$order} ;"; // die($sql); return $database_handle->Select($sql, array($table)); } function GetTag($suffix = null, $arg = array()) {
public function RemoveAttach($attach_id, $destination, $type = REALTION_ATTACH) { $rel = TRelation::GetInstance(); $rel->Remove($attach_id, $destination, $type); GoBack(); }