public static function cancel_friendship($touser) { $idfrom = OCSUser::id(); $info = OCSUser::server_get_user_info($touser); $id = $info[0]["id"]; //creating new table object $ocs_friendinvitation = new EModel("ocs_friendship"); EDatabase::q("DELETE FROM ocs_friendship WHERE (id1={$idfrom} AND id2={$id}) OR (id2={$idfrom} AND id1={$id}) LIMIT 2"); }
public function isfan($content) { $fant = new EModel("ocs_fan"); $person = OCSUser::id(); $r = $fant->find("*", "where person={$person} and content={$content}"); if (!empty($r)) { return true; } else { return false; } }
public function updated() { OCSActivity::add(OCSUser::id(), 6, OCSUser::login() . " updated " . $this->name); }
public function ocs_activity_list($user, $page = 1, $pagesize = 10) { if (empty($page)) { $page = 1; } //setting dynamic page size $page = ($page - 1) * $pagesize; $id = OCSUser::id(); $q = "SELECT a.id, a.type, a.person, a.timestamp, a.message, p.login, p.firstname, p.lastname, p.email FROM ocs_activity AS a JOIN ocs_person AS p ON a.person=p.id WHERE a.person IN (SELECT f.id2 FROM ocs_friendship AS f JOIN ocs_person AS p on (f.id1 = p.id) WHERE p.login='******') LIMIT {$page},{$pagesize};"; $r = EDatabase::q($q); $result = array(); $i = 0; while ($row = mysqli_fetch_assoc($r)) { $result[$i]["id"] = $row["id"]; $result[$i]["firstname"] = $row["firstname"]; $result[$i]["lastname"] = $row["lastname"]; $result[$i]["personid"] = $row["login"]; $result[$i]["timestamp"] = $row["timestamp"]; $result[$i]["type"] = $row["type"]; $result[$i]["message"] = $row["message"]; $i += 1; } return $result; }
/** * add a comment * @param string $format * @param string $content * @param string $parent * @param string $subject * @param string $message * @return string xml/json */ private function commentsadd($format, $type, $content, $content2, $parent, $subject, $message) { $user = $this->checkpassword(true); $this->checktrafficlimit($user); $data['parent'] = strip_tags(addslashes($parent)); $data['subject'] = strip_tags(addslashes($subject)); $data['message'] = strip_tags(addslashes($message)); $data['content'] = strip_tags(addslashes($content)); $data['content2'] = strip_tags(addslashes($content2)); $data['type'] = strip_tags(addslashes($type)); $data['owner'] = OCSUser::id(); //types // just 1 is accepted // 1 - content //setting content type as default if (!in_array($data['type'], array(1, 4, 7, 8))) { $data['type'] = 1; } if ($user != '') { if ($data['message'] != '' and $data['subject'] != '') { if ($data['content'] != 0) { $comment = new OCSComment(); //creating new object $comment->set_data($data); //loading new data for comment $comment->save_to_db(); $id = $comment->id(); $xml[0]['id'] = $id; echo $this->generatexml($format, 'ok', 100, '', $xml, 'comment', '', 2); } else { echo $this->generatexml($format, 'failed', 101, 'content must not be empty'); } } else { echo $this->generatexml($format, 'failed', 102, 'message or subject must not be empty'); } } else { echo $this->generatexml($format, 'failed', 103, 'no permission to add a comment'); } }
public static function server_checklogin($login, $passwd) { //autoload if necessary if (is_null(OCSUser::$persons)) { OCSUser::server_load(); } //checklogin $r = OCSUser::$persons->count("login", "login='******' and password='******'"); if ($r == 0) { OCSUser::$logged = false; return false; } else { OCSUser::$logged = true; $data = OCSUser::$persons->find("*", "where login='******' and password='******'"); OCSUser::$id = $data[0]["id"]; OCSUser::$login = $data[0]["login"]; OCSUser::$firstname = $data[0]["firstname"]; OCSUser::$lastname = $data[0]["lastname"]; OCSUser::$email = $data[0]["email"]; return $login; } }