Browse Source

merge from main branch

pull/16/head
gnulos 10 years ago
parent
commit
8b49b664c5
  1. 1635
      app/assets/documents/Doxyfile
  2. 47
      app/assets/documents/Makefile
  3. 6
      app/assets/documents/colors.txt
  4. 451
      app/assets/documents/fdl.texi
  5. BIN
      app/assets/documents/movim.png
  6. 594
      app/assets/documents/movim.texi
  7. 60
      app/assets/documents/texi.css
  8. 1
      app/assets/documents/texi2htmlrc
  9. 170
      app/assets/js/movim_rpc.js
  10. 8
      app/assets/js/movim_tpl.js
  11. 14
      app/assets/js/movim_utils.js
  12. 19
      app/assets/js/movim_websocket.js
  13. 11
      app/controllers/FeedController.php
  14. 10
      app/controllers/RoomController.php
  15. 2
      app/helpers/StringHelper.php
  16. 6
      app/helpers/TimezoneHelper.php
  17. 4
      app/models/config/Config.php
  18. 6
      app/models/config/ConfigDAO.php
  19. 23
      app/models/contact/Contact.php
  20. 20
      app/models/contact/ContactDAO.php
  21. 42
      app/models/message/Message.php
  22. 6
      app/models/message/MessageDAO.php
  23. 30
      app/models/postn/PostnDAO.php
  24. 19
      app/models/presence/Presence.php
  25. 24
      app/models/presence/PresenceDAO.php
  26. 8
      app/models/sessionx/Sessionx.php
  27. 20
      app/models/sessionx/SessionxDAO.php
  28. 1
      app/views/about.tpl
  29. 1
      app/views/feed.tpl
  30. 1
      app/views/group.tpl
  31. 1
      app/views/news.tpl
  32. 11
      app/views/room.tpl
  33. 8
      app/widgets/About/About.php
  34. 2
      app/widgets/About/about.tpl
  35. 40
      app/widgets/Account/Account.php
  36. 32
      app/widgets/Account/_account_form.tpl
  37. 91
      app/widgets/AccountError/AccountError.php
  38. 1
      app/widgets/AccountError/accounterror.tpl
  39. 10
      app/widgets/AccountError/locales.ini
  40. 14
      app/widgets/AccountNext/AccountNext.php
  41. 2
      app/widgets/AccountNext/accountnext.css
  42. 10
      app/widgets/AccountNext/accountnext.tpl
  43. 42
      app/widgets/AdminMain/adminmain.tpl
  44. 2
      app/widgets/AdminTest/admintest.css
  45. 5
      app/widgets/AdminTest/admintest.js
  46. 20
      app/widgets/AdminTest/admintest.tpl
  47. 3
      app/widgets/AdminTest/locales.ini
  48. 2
      app/widgets/Api/Api.php
  49. 2
      app/widgets/Avatar/avatar.js
  50. 19
      app/widgets/Blog/Blog.php
  51. 55
      app/widgets/Blog/blog.tpl
  52. 51
      app/widgets/Chat/Chat.php
  53. 5
      app/widgets/Chat/_chat.tpl
  54. 27
      app/widgets/Chat/_chat_empty.tpl
  55. 42
      app/widgets/Chat/_chat_header_room.tpl
  56. 8
      app/widgets/Chat/chat.css
  57. 12
      app/widgets/Chat/chat.js
  58. 1
      app/widgets/Chat/locales.ini
  59. 47
      app/widgets/Chats/Chats.php
  60. 8
      app/widgets/Chats/_chats.tpl
  61. 3
      app/widgets/Chats/_chats_add.tpl
  62. 1
      app/widgets/Chats/_chats_add_extend.tpl
  63. 8
      app/widgets/Chats/_chats_item.tpl
  64. 3
      app/widgets/Chats/locales.ini
  65. 54
      app/widgets/Contact/Contact.php
  66. 50
      app/widgets/Contact/_contact.tpl
  67. 37
      app/widgets/Contact/_contact_explore.tpl
  68. 44
      app/widgets/Contact/_contact_public.tpl
  69. 11
      app/widgets/Contact/locales.ini
  70. 42
      app/widgets/Group/Group.php
  71. 12
      app/widgets/Group/_group_empty.tpl
  72. 9
      app/widgets/Group/_group_posts.tpl
  73. 2
      app/widgets/Group/_group_publish.tpl
  74. 4
      app/widgets/Group/group.js
  75. 9
      app/widgets/Group/group.tpl
  76. 1
      app/widgets/Group/locales.ini
  77. 39
      app/widgets/Groups/Groups.php
  78. 2
      app/widgets/Groups/_groups_server.tpl
  79. 1
      app/widgets/Groups/_groups_subscriptions.tpl
  80. 3
      app/widgets/Groups/groups.js
  81. 2
      app/widgets/Groups/locales.ini
  82. 2
      app/widgets/Header/Header.php
  83. 6
      app/widgets/Header/_header_about.tpl
  84. 2
      app/widgets/Header/_header_main.tpl
  85. 4
      app/widgets/Header/_header_news.tpl
  86. 4
      app/widgets/Header/_header_room.tpl
  87. 4
      app/widgets/Header/locales.ini
  88. 2
      app/widgets/Hello/Hello.php
  89. 13
      app/widgets/Hello/hello.tpl
  90. 3
      app/widgets/Init/Init.php
  91. 52
      app/widgets/Login/Login.php
  92. 6
      app/widgets/Login/_login_sessions.tpl
  93. 1
      app/widgets/Login/locales.ini
  94. 11
      app/widgets/Login/login.js
  95. 1
      app/widgets/Login/login.tpl
  96. 59
      app/widgets/LoginAnonymous/LoginAnonymous.php
  97. 2
      app/widgets/LoginAnonymous/locales.ini
  98. 8
      app/widgets/LoginAnonymous/loginanonymous.js
  99. 1
      app/widgets/LoginAnonymous/loginanonymous.tpl
  100. 186
      app/widgets/Media/Media.php

1635
app/assets/documents/Doxyfile
File diff suppressed because it is too large
View File

47
app/assets/documents/Makefile

@ -1,47 +0,0 @@
HTMLER=texi2html
PDF=texi2pdf
DVI=texi2dvi
INFO=makeinfo
TEXI_OPT=-c -b
SRC=movim.texi
HTML_OUTP=bookhtml/
HTML_OPT=--no-menu --init-file texi2htmlrc --css-include=texi.css
HTML_OPT_DIR=--split=chapter --output=$(HTML_OUTP)
DOXYGEN=doxygen
.PHONY: all htmlmulti htmlmono dvi pdf reference
all: dvi pdf htmlmono htmlmulti reference info
clean:
rm -rf bookhtml reference movim.dvi movim.pdf movim.info movim.html
htmlmulti: bookhtml/movim.html
htmlmono: movim.html
dvi: movim.dvi
pdf: movim.pdf
info: movim.info
reference: reference/html/index.html
movim.html: movim.texi fdl.texi
$(HTMLER) $(HTML_OPT) $(SRC)
bookhtml/movim.html: movim.texi fdl.texi
$(HTMLER) $(HTML_OPT) $(HTML_OPT_DIR) $(SRC)
movim.dvi: movim.texi fdl.texi
$(DVI) $(TEXI_OPT) $(SRC)
movim.pdf: movim.texi fdl.texi
$(PDF) $(TEXI_OPT) $(SRC)
movim.info: movim.texi fdl.texi
$(INFO) $(SRC)
reference/html/index.html: Doxyfile
$(DOXYGEN) Doxyfile

6
app/assets/documents/colors.txt

@ -1,6 +0,0 @@
red : #D92727
orange : #FC8F12
yellow : #FFE433
green : #6FCC43
blue : #0DB8B5
purple : #442178

451
app/assets/documents/fdl.texi

@ -1,451 +0,0 @@
@c The GNU Free Documentation License.
@center Version 1.2, November 2002
@c This file is intended to be included within another document,
@c hence no sectioning command or @node.
@display
Copyright @copyright{} 2000,2001,2002 Free Software Foundation, Inc.
51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
@end display
@enumerate 0
@item
PREAMBLE
The purpose of this License is to make a manual, textbook, or other
functional and useful document @dfn{free} in the sense of freedom: to
assure everyone the effective freedom to copy and redistribute it,
with or without modifying it, either commercially or noncommercially.
Secondarily, this License preserves for the author and publisher a way
to get credit for their work, while not being considered responsible
for modifications made by others.
This License is a kind of ``copyleft'', which means that derivative
works of the document must themselves be free in the same sense. It
complements the GNU General Public License, which is a copyleft
license designed for free software.
We have designed this License in order to use it for manuals for free
software, because free software needs free documentation: a free
program should come with manuals providing the same freedoms that the
software does. But this License is not limited to software manuals;
it can be used for any textual work, regardless of subject matter or
whether it is published as a printed book. We recommend this License
principally for works whose purpose is instruction or reference.
@item
APPLICABILITY AND DEFINITIONS
This License applies to any manual or other work, in any medium, that
contains a notice placed by the copyright holder saying it can be
distributed under the terms of this License. Such a notice grants a
world-wide, royalty-free license, unlimited in duration, to use that
work under the conditions stated herein. The ``Document'', below,
refers to any such manual or work. Any member of the public is a
licensee, and is addressed as ``you''. You accept the license if you
copy, modify or distribute the work in a way requiring permission
under copyright law.
A ``Modified Version'' of the Document means any work containing the
Document or a portion of it, either copied verbatim, or with
modifications and/or translated into another language.
A ``Secondary Section'' is a named appendix or a front-matter section
of the Document that deals exclusively with the relationship of the
publishers or authors of the Document to the Document's overall
subject (or to related matters) and contains nothing that could fall
directly within that overall subject. (Thus, if the Document is in
part a textbook of mathematics, a Secondary Section may not explain
any mathematics.) The relationship could be a matter of historical
connection with the subject or with related matters, or of legal,
commercial, philosophical, ethical or political position regarding
them.
The ``Invariant Sections'' are certain Secondary Sections whose titles
are designated, as being those of Invariant Sections, in the notice
that says that the Document is released under this License. If a
section does not fit the above definition of Secondary then it is not
allowed to be designated as Invariant. The Document may contain zero
Invariant Sections. If the Document does not identify any Invariant
Sections then there are none.
The ``Cover Texts'' are certain short passages of text that are listed,
as Front-Cover Texts or Back-Cover Texts, in the notice that says that
the Document is released under this License. A Front-Cover Text may
be at most 5 words, and a Back-Cover Text may be at most 25 words.
A ``Transparent'' copy of the Document means a machine-readable copy,
represented in a format whose specification is available to the
general public, that is suitable for revising the document
straightforwardly with generic text editors or (for images composed of
pixels) generic paint programs or (for drawings) some widely available
drawing editor, and that is suitable for input to text formatters or
for automatic translation to a variety of formats suitable for input
to text formatters. A copy made in an otherwise Transparent file
format whose markup, or absence of markup, has been arranged to thwart
or discourage subsequent modification by readers is not Transparent.
An image format is not Transparent if used for any substantial amount
of text. A copy that is not ``Transparent'' is called ``Opaque''.
Examples of suitable formats for Transparent copies include plain
@sc{ascii} without markup, Texinfo input format, La@TeX{} input
format, @acronym{SGML} or @acronym{XML} using a publicly available
@acronym{DTD}, and standard-conforming simple @acronym{HTML},
PostScript or @acronym{PDF} designed for human modification. Examples
of transparent image formats include @acronym{PNG}, @acronym{XCF} and
@acronym{JPG}. Opaque formats include proprietary formats that can be
read and edited only by proprietary word processors, @acronym{SGML} or
@acronym{XML} for which the @acronym{DTD} and/or processing tools are
not generally available, and the machine-generated @acronym{HTML},
PostScript or @acronym{PDF} produced by some word processors for
output purposes only.
The ``Title Page'' means, for a printed book, the title page itself,
plus such following pages as are needed to hold, legibly, the material
this License requires to appear in the title page. For works in
formats which do not have any title page as such, ``Title Page'' means
the text near the most prominent appearance of the work's title,
preceding the beginning of the body of the text.
A section ``Entitled XYZ'' means a named subunit of the Document whose
title either is precisely XYZ or contains XYZ in parentheses following
text that translates XYZ in another language. (Here XYZ stands for a
specific section name mentioned below, such as ``Acknowledgements'',
``Dedications'', ``Endorsements'', or ``History''.) To ``Preserve the Title''
of such a section when you modify the Document means that it remains a
section ``Entitled XYZ'' according to this definition.
The Document may include Warranty Disclaimers next to the notice which
states that this License applies to the Document. These Warranty
Disclaimers are considered to be included by reference in this
License, but only as regards disclaiming warranties: any other
implication that these Warranty Disclaimers may have is void and has
no effect on the meaning of this License.
@item
VERBATIM COPYING
You may copy and distribute the Document in any medium, either
commercially or noncommercially, provided that this License, the
copyright notices, and the license notice saying this License applies
to the Document are reproduced in all copies, and that you add no other
conditions whatsoever to those of this License. You may not use
technical measures to obstruct or control the reading or further
copying of the copies you make or distribute. However, you may accept
compensation in exchange for copies. If you distribute a large enough
number of copies you must also follow the conditions in section 3.
You may also lend copies, under the same conditions stated above, and
you may publicly display copies.
@item
COPYING IN QUANTITY
If you publish printed copies (or copies in media that commonly have
printed covers) of the Document, numbering more than 100, and the
Document's license notice requires Cover Texts, you must enclose the
copies in covers that carry, clearly and legibly, all these Cover
Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
the back cover. Both covers must also clearly and legibly identify
you as the publisher of these copies. The front cover must present
the full title with all words of the title equally prominent and
visible. You may add other material on the covers in addition.
Copying with changes limited to the covers, as long as they preserve
the title of the Document and satisfy these conditions, can be treated
as verbatim copying in other respects.
If the required texts for either cover are too voluminous to fit
legibly, you should put the first ones listed (as many as fit
reasonably) on the actual cover, and continue the rest onto adjacent
pages.
If you publish or distribute Opaque copies of the Document numbering
more than 100, you must either include a machine-readable Transparent
copy along with each Opaque copy, or state in or with each Opaque copy
a computer-network location from which the general network-using
public has access to download using public-standard network protocols
a complete Transparent copy of the Document, free of added material.
If you use the latter option, you must take reasonably prudent steps,
when you begin distribution of Opaque copies in quantity, to ensure
that this Transparent copy will remain thus accessible at the stated
location until at least one year after the last time you distribute an
Opaque copy (directly or through your agents or retailers) of that
edition to the public.
It is requested, but not required, that you contact the authors of the
Document well before redistributing any large number of copies, to give
them a chance to provide you with an updated version of the Document.
@item
MODIFICATIONS
You may copy and distribute a Modified Version of the Document under
the conditions of sections 2 and 3 above, provided that you release
the Modified Version under precisely this License, with the Modified
Version filling the role of the Document, thus licensing distribution
and modification of the Modified Version to whoever possesses a copy
of it. In addition, you must do these things in the Modified Version:
@enumerate A
@item
Use in the Title Page (and on the covers, if any) a title distinct
from that of the Document, and from those of previous versions
(which should, if there were any, be listed in the History section
of the Document). You may use the same title as a previous version
if the original publisher of that version gives permission.
@item
List on the Title Page, as authors, one or more persons or entities
responsible for authorship of the modifications in the Modified
Version, together with at least five of the principal authors of the
Document (all of its principal authors, if it has fewer than five),
unless they release you from this requirement.
@item
State on the Title page the name of the publisher of the
Modified Version, as the publisher.
@item
Preserve all the copyright notices of the Document.
@item
Add an appropriate copyright notice for your modifications
adjacent to the other copyright notices.
@item
Include, immediately after the copyright notices, a license notice
giving the public permission to use the Modified Version under the
terms of this License, in the form shown in the Addendum below.
@item
Preserve in that license notice the full lists of Invariant Sections
and required Cover Texts given in the Document's license notice.
@item
Include an unaltered copy of this License.
@item
Preserve the section Entitled ``History'', Preserve its Title, and add
to it an item stating at least the title, year, new authors, and
publisher of the Modified Version as given on the Title Page. If
there is no section Entitled ``History'' in the Document, create one
stating the title, year, authors, and publisher of the Document as
given on its Title Page, then add an item describing the Modified
Version as stated in the previous sentence.
@item
Preserve the network location, if any, given in the Document for
public access to a Transparent copy of the Document, and likewise
the network locations given in the Document for previous versions
it was based on. These may be placed in the ``History'' section.
You may omit a network location for a work that was published at
least four years before the Document itself, or if the original
publisher of the version it refers to gives permission.
@item
For any section Entitled ``Acknowledgements'' or ``Dedications'', Preserve
the Title of the section, and preserve in the section all the
substance and tone of each of the contributor acknowledgements and/or
dedications given therein.
@item
Preserve all the Invariant Sections of the Document,
unaltered in their text and in their titles. Section numbers
or the equivalent are not considered part of the section titles.
@item
Delete any section Entitled ``Endorsements''. Such a section
may not be included in the Modified Version.
@item
Do not retitle any existing section to be Entitled ``Endorsements'' or
to conflict in title with any Invariant Section.
@item
Preserve any Warranty Disclaimers.
@end enumerate
If the Modified Version includes new front-matter sections or
appendices that qualify as Secondary Sections and contain no material
copied from the Document, you may at your option designate some or all
of these sections as invariant. To do this, add their titles to the
list of Invariant Sections in the Modified Version's license notice.
These titles must be distinct from any other section titles.
You may add a section Entitled ``Endorsements'', provided it contains
nothing but endorsements of your Modified Version by various
parties---for example, statements of peer review or that the text has
been approved by an organization as the authoritative definition of a
standard.
You may add a passage of up to five words as a Front-Cover Text, and a
passage of up to 25 words as a Back-Cover Text, to the end of the list
of Cover Texts in the Modified Version. Only one passage of
Front-Cover Text and one of Back-Cover Text may be added by (or
through arrangements made by) any one entity. If the Document already
includes a cover text for the same cover, previously added by you or
by arrangement made by the same entity you are acting on behalf of,
you may not add another; but you may replace the old one, on explicit
permission from the previous publisher that added the old one.
The author(s) and publisher(s) of the Document do not by this License
give permission to use their names for publicity for or to assert or
imply endorsement of any Modified Version.
@item
COMBINING DOCUMENTS
You may combine the Document with other documents released under this
License, under the terms defined in section 4 above for modified
versions, provided that you include in the combination all of the
Invariant Sections of all of the original documents, unmodified, and
list them all as Invariant Sections of your combined work in its
license notice, and that you preserve all their Warranty Disclaimers.
The combined work need only contain one copy of this License, and
multiple identical Invariant Sections may be replaced with a single
copy. If there are multiple Invariant Sections with the same name but
different contents, make the title of each such section unique by
adding at the end of it, in parentheses, the name of the original
author or publisher of that section if known, or else a unique number.
Make the same adjustment to the section titles in the list of
Invariant Sections in the license notice of the combined work.
In the combination, you must combine any sections Entitled ``History''
in the various original documents, forming one section Entitled
``History''; likewise combine any sections Entitled ``Acknowledgements'',
and any sections Entitled ``Dedications''. You must delete all
sections Entitled ``Endorsements.''
@item
COLLECTIONS OF DOCUMENTS
You may make a collection consisting of the Document and other documents
released under this License, and replace the individual copies of this
License in the various documents with a single copy that is included in
the collection, provided that you follow the rules of this License for
verbatim copying of each of the documents in all other respects.
You may extract a single document from such a collection, and distribute
it individually under this License, provided you insert a copy of this
License into the extracted document, and follow this License in all
other respects regarding verbatim copying of that document.
@item
AGGREGATION WITH INDEPENDENT WORKS
A compilation of the Document or its derivatives with other separate
and independent documents or works, in or on a volume of a storage or
distribution medium, is called an ``aggregate'' if the copyright
resulting from the compilation is not used to limit the legal rights
of the compilation's users beyond what the individual works permit.
When the Document is included in an aggregate, this License does not
apply to the other works in the aggregate which are not themselves
derivative works of the Document.
If the Cover Text requirement of section 3 is applicable to these
copies of the Document, then if the Document is less than one half of
the entire aggregate, the Document's Cover Texts may be placed on
covers that bracket the Document within the aggregate, or the
electronic equivalent of covers if the Document is in electronic form.
Otherwise they must appear on printed covers that bracket the whole
aggregate.
@item
TRANSLATION
Translation is considered a kind of modification, so you may
distribute translations of the Document under the terms of section 4.
Replacing Invariant Sections with translations requires special
permission from their copyright holders, but you may include
translations of some or all Invariant Sections in addition to the
original versions of these Invariant Sections. You may include a
translation of this License, and all the license notices in the
Document, and any Warranty Disclaimers, provided that you also include
the original English version of this License and the original versions
of those notices and disclaimers. In case of a disagreement between
the translation and the original version of this License or a notice
or disclaimer, the original version will prevail.
If a section in the Document is Entitled ``Acknowledgements'',
``Dedications'', or ``History'', the requirement (section 4) to Preserve
its Title (section 1) will typically require changing the actual
title.
@item
TERMINATION
You may not copy, modify, sublicense, or distribute the Document except
as expressly provided for under this License. Any other attempt to
copy, modify, sublicense or distribute the Document is void, and will
automatically terminate your rights under this License. However,
parties who have received copies, or rights, from you under this
License will not have their licenses terminated so long as such
parties remain in full compliance.
@item
FUTURE REVISIONS OF THIS LICENSE
The Free Software Foundation may publish new, revised versions
of the GNU Free Documentation License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns. See
@uref{http://www.gnu.org/copyleft/}.
Each version of the License is given a distinguishing version number.
If the Document specifies that a particular numbered version of this
License ``or any later version'' applies to it, you have the option of
following the terms and conditions either of that specified version or
of any later version that has been published (not as a draft) by the
Free Software Foundation. If the Document does not specify a version
number of this License, you may choose any version ever published (not
as a draft) by the Free Software Foundation.
@end enumerate
@page
@heading ADDENDUM: How to use this License for your documents
To use this License in a document you have written, include a copy of
the License in the document and put the following copyright and
license notices just after the title page:
@smallexample
@group
Copyright (C) @var{year} @var{your name}.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.2
or any later version published by the Free Software Foundation;
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
Texts. A copy of the license is included in the section entitled ``GNU
Free Documentation License''.
@end group
@end smallexample
If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
replace the ``with@dots{}Texts.'' line with this:
@smallexample
@group
with the Invariant Sections being @var{list their titles}, with
the Front-Cover Texts being @var{list}, and with the Back-Cover Texts
being @var{list}.
@end group
@end smallexample
If you have Invariant Sections without Cover Texts, or some other
combination of the three, merge those two alternatives to suit the
situation.
If your document contains nontrivial examples of program code, we
recommend releasing these examples in parallel under your choice of
free software license, such as the GNU General Public License,
to permit their use in free software.
@c Local Variables:
@c ispell-local-pdict: "ispell-dict"
@c End:

BIN
app/assets/documents/movim.png

Before

Width: 650  |  Height: 650  |  Size: 51 KiB

594
app/assets/documents/movim.texi

@ -1,594 +0,0 @@
\input texinfo @c -*-texinfo-*-
@c %**start of header
@documentencoding UTF-8
@setfilename movim-reference.info
@settitle movim-reference
@setchapternewpage on
@c %**end of header
@set VERSION 0.2
@set UPDATED 28 May 2011
@copying
This manual documents Movim (version @value{VERSION}, @value{UPDATED}).
Copyright @copyright{} 2009-2011 MOVIM project.
@sp 1
@quotation
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.2
or any later version published by the Free Software Foundation;
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
Texts. A copy of the license is included in the section entitled ``GNU
Free Documentation License''.
@end quotation
@end copying
@titlepage
@title MOVIM Reference Manual
@subtitle version @value{VERSION}, @value{UPDATED}
@vskip 4cm
@center{@image{movim, 15cm}}
@author Guillaume Pasquet, Timothée Jaussoin
@c Copyright page
@page
@vskip 0pt plus 1filll
@insertcopying
@end titlepage
@contents
@ifnottex
@node Top
@top MOVIM
This is Movim @value{VERSION}'s manual.
@end ifnottex
@menu
* foreword:: What this document is all about
* introduction:: What is Movim and how to use this document
* structure:: A description of Movim's internals
* Widgets API:: Documentation of the widget's API
* MovimRPC:: The specification of Movim's remote procedure call
@end menu
@node foreword
@chapter Foreword
Movim is an XMPP-based communication platform. It uses a widget-based UI
system. A widget is a combination of server-side and client-side scripts that
interact though a custom xmlrpc protocol.
This document describes the principles on which Movim is built, and the API to
build new widgets.
@node introduction
@chapter Introduction
Movim's core is designed to ease the implementation of XMPP web-based clients,
using massively asynchronous javascript and abstracting XMPP calls into an
events-based API.
The widgets API doesn't only provide the necessary abstraction and framework to
communicate through XMPP, it also features a javascript abstration system that
lets you write as little javascript as possible. Moreover, widgets can embed
their own resources --- pictures, css, javascript.
@section Requirements
Movim runs on any web server with PHP and Curl. The detailed requirements are:
@itemize @bullet
@item
PHP5.3 or greater with the Curl, JSON, SimpleXML and SQLite3 extensions.
@item
A web server: apache, lighttpd (Note that other web servers should work, with
the possible exception of IIS, which hasn't been tested.)
@end itemize
An XMPP web server with Bosh is also necessary, but you don't need to install
one, you can use and existing server. We provide such a server at
@url{movim.eu}.
@section Getting Movim
Movim may be downloaded from @url{http://www.movim.eu}.
You can also get the latest development version on our git branch at
@url{http://gitorious.org/movim}. Be advised that this version is not stable and
in fact it isn't even guaranteed to work.
@section Installing Movim
After downloading the Movim archive, simply extract it somewhere in your
web server's root directory. You will need to give read/write rights to the
webserver on the folder where Movim is installed.
You should see the installer when you visit your Movim folder from your web
browser. Follow the steps.
Then you should be able to log in on the website's interface with your XMPP
credentials.
Please note that not every XMPP server will work with Movim. Your server needs
to have Bosh enabled for this. You can register an account on the server we
provide @url{movim.eu} to try out Movim.
@section Helping out
Movim is Free software under the AGPL license. You can check out the latest
code at @url{http://gitorious.org/movim}. Feel free to send in merge requests if
you want to lend a hand.
All bug reports and feedback are welcome at
@url{http://codingteam.net/project/movim}. You can also help us translating
Movim so more people may benefit from our Free social network (on the same
website).
@node structure
@chapter Internal structure
Understanding Movim's internals isn't necessary to use it. However, it may
help finding out problems and developing more efficiently.
Movim is consists of a widgets system and an XMPP abstration that
communicate together through an asynchronous event handler. This is all
triggered by a controller, which is loaded depending on the page you visit.
@section XMPP connection
The XMPP connection is managed by the JAXL library. It abstracts the raw sending
and receiving of XML messages. Each message is handled and pops up as an
event.
@section Widgets
Widgets are small pieces of software that plug into Movim to provide extra
ability to the system. These are mostly graphical, and generate ajax code
automatically.
Movim comes with several widgets. These sit in the @file{lib/widgets}
directory. User-defined widgets should be in the @file{widgets} directory. Note
that user-defined widgets always shadow the system widgets.
Widgets can declare ajax functions and XMPP event handlers in order to interact
with their GUI part and the XMPP subsystem. @xref{Widget API} for more
information.
Note that almost everything in Movim is a widget. Even things like the menu and
the configuration panel. One notable exception is the login page, which is
mostly static.
@section Events manager
The XMPP connection is not aware of the widgets, nor is it able to access
them. However, the event manager knows what widgets are loaded on the client's
interface at any time. When the XMPP connection triggers an event in the event
manager, it loops through all the loaded widgets and executes all handlers that
are attached to this event.
@node Widget API
@chapter Widget API
Widgets inherit from the @emph{WidgetBase} base class. The base class automagically
generates ajax calls and javascript functions for you.
The basic template of a Movim widget is as follows:
@cartouche
@verbatim
class MyWidget extends WidgetBase
{
function load()
{
$this->registerEvent('incomemessage', 'onIncomingMessage');
}
function onIncomingMessage($data)
{
RPC::call('movim_prepend',
'chatMessages',
RPC::cdata($data['message']));
}
function build()
{
?>
<div id="chatMessages">
</div>
<?
}
}
@end verbatim
@end cartouche
Note that the constructor must not be shadowed. Instead the parent class
provides a @code{load()} function that is called right at the end of the
parent constructor.
Event handlers must be defined into @code{load()}.
The @code{build()} function is called when the widget is being written onto the
interface. That's typically where you should put your HTML code.
@section Events
XMPP triggers many different kinds of events that are run against all the loaded
widgets. In order to process an event, you may register one or more handlers in
your widget.
@subsection Handling events
An event handler is a public method that only takes one parameter:
@code{$data}, which usually is an array that contains the data returned by the
XMPP server.
Your handlers must be registered in @code{load()} using the method:
@cartouche
@verbatim
WidgetBase::registerEvent($eventType, $handler)
@end verbatim
@end cartouche
@code{$handler} is a the name of the method as a string, and @code{$eventType}
is the name of the event as a string.
@subsection Event types
The XMPP subsystem currently raises the following events:
@table @code
@item postdisconnected
Event that is triggered immediately after the account has been
disconnected on the user's request.
@item incomingemptybody
A message that comes in without body. This is typically a presence ping.
@item myvcardreceived
Your vcard was received.
@item vcardreceived
The user's vcard was received. @code{$data} contains the vcard as a base64
encoded string.
@item rosterreceived
The roster's list was received. @code{$data} is an array of groups and
users.
@item incomeactive
The contact is currently looking at his message list.
@item incomecomposing
The contact is writing a message.
@item incomemessage
A new message was received (contained in @code{$data}).
@item incomeoffline
A contact as gone offline.
@item incomeaway
A contact is now marked as away.
@item incomednd
A contact is now marked as @emph{do not disturb}.
@item incomeonline
A contact is now online.
@item serverdisconnect
The server has gone offline.
@end table
One additional event type is availble: @code{allEvents}. This type of event is a
catchall that is always executed before the other event handlers in the widget.
The event handling process cannot be interrupted. All loaded widgets will be
requested to run their eventhandlers, unless of course a fatal error occurs.
@node MovimRPC
@section MovimRPC
Movim's javascript and PHP parts communicate through a custom xmlrpc
protocol. It is implemented in the class @code{MovimRPC} on the PHP side.
MovimRPC exposes two static functions to the widget:
@table @code
@item RPC::call(funcname, ...)
Calls the javascript function @emph{funcname} with the rest of arguments.
@item RPC::cdata(text)
Packs text into a cdata container. This is useful when passing through
strings containing messy characters (like HTML).
@end table
You can define your own javascript functions on a per-widget basis, or use one
of the standard functions (@xref{Standard javascript callbacks}).
@node Standard javascript callbacks
@subsection Standard javascript callbacks
You may define your own javascript callback functions and use them as
appropriate. Alternatively, Movim comes with a standard set of javascript
callbacks that allow simple operations on HTML elements (picked up by ID).
@table @code
@item movim_append(target, string)
Appends @code{string} to the html element with ID @code{target}.
@item movim_prepend(target, string)
Prepends @code{string} to the html element with ID @code{target}.
@item movim_fill(target, string)
Fills @code{string} to the html element with ID @code{target}.
@item movim_drop()
Doesn't do anything.
@end table
@node ajaxcalls
@section Ajax calls
Any method defined in your widget that starts with @code{ajax} will have a
javascript ajax call automatically generated.
This ajax call can be explicitely called upon with the method:
@cartouche
@verbatim
WidgetBase::callAjax($funcname, ...)
@end verbatim
@end cartouche
@code{$funcname} is the name of the ajax function. The rest of paramters are
passed to the ajax-called PHP function.
It is important to understand how the ajax calls work in Movim. Movim uses a
custom-designed xmlrpc protocol to callback PHP functions directly. Therefore,
making an ajax call is very similar to making a straight callback in PHP.
So for example if you have defined an ajax function
@code{ajaxMyfunction($param)}
you can call it with
@code{$this->callAjax('ajaxMyfunction', "'myparam'")}.
Here is a complete example of a widget that implements an ajax call:
@cartouche
@verbatim
class MyWidget extends WidgetBase
{
function ajaxTest($param1, $param2)
{
RPC::call('movim_append', 'test',
RPC::cdata('<p>Test</p>'));
}
function build()
{
?>
<div id="test"></div>
<input type="button"
onclick="<? $this->callAjax(
'ajaxTest',
'"param1"',
'2');?>"/>
<?
}
}
@end verbatim
@end cartouche
Note that string parameters passed to the ajax method must be double-quoted. The
reason for this is that javascript will remove the first set of quotes. Thus
single-quoted parameters will be javascript objects.
The drawback of @code{WidgetBase::callAjax()} is that it prints the ajax call
straight away. It is sometimes desirable to have it return the generated
call. Another variant of the function exists that does this:
@cartouche
@verbatim
WidgetBase::call($funcname, $callback, $target, ...)
@end verbatim
@end cartouche
@node widget-resource
@section Widget resource
Widgets can come along with their own resources, in particular their CSS and
javascript.
The @code{Widget} base class includes two methods to ease the integration of
custom javascript and css:
@cartouche
@verbatim
WidgetBase::addjs($jsfile)
WidgetBase::addcss($cssfile)
@end verbatim
@end cartouche
The file paths given to these functions are relative to the widget's directory.
For resources, you can use the function:
@cartouche
@verbatim
WidgetBase::respath($file, $fspath = false)
@end verbatim
@end cartouche
This returns the URL to the specified file. The optional parameter
@code{$fspath} will make the function return the file-system path rather than
the URL to the file.
@node IWC
@section Inter-Widget Communication
Widgets can communicate at two different levels. They can communicate through
the server using MovimRPC, but this is an awkward route for messages need to get
down to the server, then up to the other widget. Another manner is to use the
IWC.
The IWC is basically a javascript-level event manager. In order to use it, your
widget can either add event handlers so that others can communicate with it, or
it can send events to other widgets.
This means that you will not be able to use IWC from PHP. You'll need to add a
javascript resource file along with your widget and define the handlers in it.
Handlers are defined with the function @code{movim_add_event_handler(event_type,
func)}. An example of it could be:
@cartouche
@verbatim
function bar() {
// Do things
}
// Adding handler
movim_add_event_handler('foo', bar);
@end verbatim
@end cartouche
You may however trigger events from anywhere, including the widget's body with
the function @code{movim_events_emit(event_type)}.
@cartouche
@verbatim
<input type="button" onclick="movim_events_emit('foo')" />
@end verbatim
@end cartouche
@node session
@section Session
Movim has moved away from using PHP's sessions, which couldn't provide an
efficient locking and handling of Movim's multi-threaded behaviour.
If you need to store data in session, use Movim's Session class rather than
PHP's session. The class provides you the following methods.
@table @code
@item static Session::start($name)
Starts a session container named $name. Returns the session handle.
@item Session::get($varname)
Retrieves the value of $varname.
@item Session::set($varname, $value)
Sets the value of $varname to $value.
@item Session::remove($varname)
Deletes $varname from the session.
@item Session::delete_container()
Deletes the physical storage of the container.
@item static Session::dispose($name)
Deletes the container $name along with its physical storage.
@end table
@node cache
@section Cache
Movim uses caching heavily in order to minimise load-time. Depending on how your
widget works, it might be convenient for you to cache parts of it, or even the
whole of its html output, rather than regenerate it every time.
Movim's cache is user-specific. So you don't have to worry about your cached
data being accessible to others.
Movim's Cache provides the following methods:
@table @code
@item static Cache::create()
Gets a cache handle.
@item Cache::handle($key, ...)
Retrieves or stores one or more objects depending on the way it's
called. If only $key is provided, handle() will return the corresponding
cached object. If one or more extra objects are provided, they are cached
under $key.
@item static Cache::c($key, ...)
Shorthand for the two previous functions.
@end table
Here is an example of how to use Cache in its two different forms:
@cartouche
@verbatim
$cache = Cache::create();
// Storing some object.
$cache->handle('foo', 'bar', 'baz');
// Retrieving data
list($bar, $baz) = $cache->handle('foo');
// Using the shorthand
Cache::c('foo', $bar);
// Usual cache routine
if(!$bar = Cache::c('foo')) {
Cache::c('foo', $bar);
}
@end verbatim
@end cartouche
@node MovimRPC spec
@chapter MovimRPC specification
Movim's interface is highly dynamic and composed of two parts, the server-side
written in PHP that provides the XMPP connection and the Javascript-side that
provides the GUI.
Both systems communicate through Ajax. The javascript interface keeps polling
the server for new calls on the url:
@url{http://mymovim.tld/jajax.php?do=poll}
Whenever an event occurs, a MovimRPC call is sent though this interface. The GUI
also communicates directly with the server through the same protocol.
@section Function calls
MovimRPC consists in sending XML-formatted strings that describe a function
call. Both communicating systems need to be aware of each other's functions set
as no return is available on a function call.
Instead of returning data after a function call, the called system triggers a
movimRPC call to the calling system, feeding it the appropriate data as
paramaters.
Messy strings parameters (e.g. those containing HTML code) need to be enclosed
in CDATA markups.
One MovimRPC document can contain more than one function call. All function
calls need to be enclosed in @code{<movimcontainer>} tags. Function calls are
defined with the @code{<funcall>}. Each function parameter is enclosed in
@code{<param>} tags.
Function calls must have a @code{NAME} parameter, and accept a @code{WIDGET}
parameter.
Here is an example of a call to the function @code{myfunc} of the widget
@code{MyWidget} with the relevant parameters.
@cartouche
@verbatim
<?xml version="1.0" encoding="UTF-8" ?>
<movimcontainer>
<funcall name="myfunc" widget="MyWidget">
<param>foo</param>
<param>bar</param>
</funcall>
</movimcontainer>
@end verbatim
@end cartouche
@section Parameters
The parameters passed to a function aren't typed. The required type needs to be
known by the caller.
Arrays can be passed within parameters. Arrays may be associative or mixed or
not. They are declared within @code{<array>} tags. Each element in the array is
enclosed by @code{<arrayelt>} tags. Elements can be associated to a key with the
@code{NAME} parameter.
An example of two function calls with an associative array.
@cartouche
@verbatim
<?xml version="1.0" encoding="UTF-8" ?>
<movimcontainer>
<funcall name="myfunc" widget="MyWidget">
<param>foo</param>
<param>bar</param>
</funcall>
<funcall name="toto">
<param>foo</param>
<param>
<array>
<arrayelt name="elt1">1</arrayelt>
<arrayelt name="2">associative</arrayelt>
<arrayelt>sequential</arrayelt>
</array>
</param>
</funcall>
</movimcontainer>
@end verbatim
@end cartouche
@node license
@comment node-name, next, previous, up
@chapter GNU Free Documentation License
@include fdl.texi
@bye

60
app/assets/documents/texi.css

@ -1,60 +0,0 @@
body {
font-size: 10pt;
text-align: left;
width: 900px;
margin: auto auto;
background: white;
/* Borders */
border-right: 5px solid #999;
border-bottom: 5px solid #999;
border-left: 5px solid #999;
padding: 10px;
/* Rounded corners */
border-bottom-right-radius: 10px;
border-bottom-left-radius: 10px;
-moz-border-radius-bottomright: 10px;
-moz-border-radius-bottomleft: 10px;
}
/* Text styles */
h1 {
color: #555;
font-size: 200%;
}
h2 {
color: #666;
font-size: 150%;
}
h3, h4, h5 {
color: #777;
}
code {
background: #EEE;
font-family: Monaco,monospace;
font-size: 10pt;
border: 1px solid #999;
padding: 0 0.2em;
}
.cartouche {
background: #EEE;
border: 1px solid #999;
border-collapse: collapse;
margin: auto;
}
.cartouche td .verbatim {
padding: 0 1em;
}
hr {
background: #999;
border: 1px solid #AAA;
}
a {
color: #385D7C;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
a img {
border: none;
}

1
app/assets/documents/texi2htmlrc

@ -1 +0,0 @@
@SECTION_BUTTONS=()

170
app/assets/js/movim_rpc.js

@ -1,170 +0,0 @@
/**
* Movim RPC class.
*
* Implements an abstraction to access MOVIM's RPC system. This includes
* facilities to simply call functions.
*
* This also includes functions to make arrays etc.
*/
var movim_xmlhttp;
var movim_xmlhttp_hash = {};
function MovimRPC()
{
/* Methods */
/**
* Generates a new XMLHttpRequest object in a portable fashion.
*/
this.make_xmlhttp = function()
{
if (window.XMLHttpRequest) {// code for real browsers
return new XMLHttpRequest();
} else {// code for IE6, IE5
return new ActiveXObject("Microsoft.XMLHTTP");
}
};
this.startRequest = function(key)
{
movim_xmlhttp_hash[this.key] = 1;
}
this.endRequest = function(key)
{
delete movim_xmlhttp_hash[this.key];
}
/**
* Sends data to the movim server through ajax.
*
* The provided mode determines what will become of the returned data. It
* can either be processed by a callback function provided as modeopt or
* it can append, prepend or fill the contents of the element which ID is
* modeopt.
*/
this.commit = function()
{
movim_xmlhttp = this.make_xmlhttp();
if(FAIL_SAFE)
var fail_safe = '?fail_safe=1';
else
var fail_safe = '';
movim_xmlhttp.open('POST', BASE_URI+'jajax.php'+fail_safe, true);
movim_xmlhttp = this.set_key(movim_xmlhttp);
movim_xmlhttp.addEventListener('loadstart', this.startRequest, false);
movim_xmlhttp.addEventListener('loadend', this.endRequest, false);
var handler = this.handle_rpc_json;
movim_xmlhttp.onreadystatechange = function() {
if(movim_xmlhttp.readyState == 4 && movim_xmlhttp.status == 500)
movim_disconnect('internal');
else if(movim_xmlhttp.readyState == 4) {
handler(movim_xmlhttp.response);
}
};
movim_xmlhttp.setRequestHeader("Content-Type", "application/json; charset=utf-8");
var json = this.generate_json();
movim_xmlhttp.send(json);
};
/**
* Attach a key to the object
*/
this.set_key = function(movim_xmlhttp)
{
movim_xmlhttp.key = Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 5);
return movim_xmlhttp;
};
/**
* What widget do we call?
*/
this.set_widget = function(widgetname)
{
this.widget = widgetname;
};
/**
* What function to call in Movim?
*/
this.set_func = function(funcname)
{
this.func = funcname;
};
/**
* Adds a parameter to the called function.
*/
this.add_param = function(param)
{
this.params.push(param);
};
/**
* Sets all movim call parameters at once.
*/
this.set_call = function(widget, func, params)
{
this.set_widget(widget);
this.set_func(func);
this.params = params;
};
/**
* Handles returns (xmlrpc)
*/
this.handle_rpc_json = function(json)
{
var funcalls = eval(json);
if(funcalls != null) {
for(h = 0; h < funcalls.length; h++) {
var funcall = funcalls[h];
if(funcall.func != null && eval("typeof " + funcall.func) == "function") {
var funcs = funcall.func.split('.');
try {
if(funcs.length == 1)
window[funcs[0]](funcall.params);
else if(funcs.length == 2)
window[funcs[0]][funcs[1]](funcall.params);
}
catch(err) {
console.log("Error caught: " + err.toString() + " - " +funcall.func);
}
}
}
}
}
/**
* Generates the JSON document corresponding to the provided parameters.
*/
this.generate_json = function()
{
return JSON.stringify(this);
};
/* Properties */
this.widget = '';
this.func = '';
this.params = [];
}
/**
* Putting it all together.
*/
function movim_ajaxSend(widget, func, parameters)
{
rpc.set_call(widget, func, parameters);
rpc.commit();
}
var rpc = new MovimRPC(); // Initialising global rpc handler.

8
app/assets/js/movim_tpl.js

@ -73,6 +73,12 @@ var MovimTpl = {
//if(inner != null) inner.innerHTML = '';
//else document.querySelector(selector).innerHTML = '';
},
fill : function(selector, html) {
target = document.querySelector(selector);
if(target) {
target.innerHTML = html;
}
},
isPanel : function() {
if(movim_has_class('main section > div:first-child:nth-last-child(2) ~ div', 'enabled')) {
return true;
@ -122,7 +128,7 @@ var MovimTpl = {
back : function() {
// If the contect menu is show
var cm = document.querySelector('ul.context_menu');
if(cm != null && cm.className.contains('shown')) {
if(cm != null && cm.className.includes('shown')) {
MovimTpl.toggleContextMenu(document);
}
// If a dialog box is show

14
app/assets/js/movim_utils.js

@ -21,15 +21,10 @@ function movim_get_node(str) {
/**
* @brief Force Movim to go back to the login page
* @param string error
*/
function movim_disconnect(error)
function movim_disconnect()
{
if(error == null) {
window.location.replace(ERROR_URI);
} else {
window.location.replace(ERROR_URI + error);
}
window.location.replace(ERROR_URI);
}
/**
@ -137,8 +132,9 @@ function movim_textarea_autoheight(textbox) {
* @param string the class to check
*/
function movim_has_class(element,classname) {
var element = movim_get_node(element);
return element.className.match(new RegExp('(\\s|^)'+classname+'(\\s|$)'));
var node = movim_get_node(element);
if(!node) console.log('Node ' + element + ' not found');
return node.className.match(new RegExp('(\\s|^)'+classname+'(\\s|$)'));
}
/**

19
app/assets/js/movim_websocket.js

@ -8,6 +8,10 @@ WebSocket.prototype.unregister = function() {
this.send(JSON.stringify({'func' : 'unregister'}));
};
WebSocket.prototype.register = function(host) {
this.send(JSON.stringify({'func' : 'register', 'host' : host}));
};
WebSocket.prototype.admin = function(key) {
this.send(JSON.stringify({'func' : 'admin', 'key' : key}));
};
@ -20,6 +24,7 @@ WebSocket.prototype.admin = function(key) {
var MovimWebsocket = {
connection: null,
attached: new Array(),
registered: new Array(),
unregistered: false,
launchAttached : function() {
@ -28,6 +33,12 @@ var MovimWebsocket = {
}
},
launchRegistered : function() {
for(var i = 0; i < MovimWebsocket.registered.length; i++) {
MovimWebsocket.registered[i]();
}
},
init : function() {
if(SECURE_WEBSOCKET) {
var uri = 'wss://' + BASE_HOST + '/ws/';
@ -49,7 +60,7 @@ var MovimWebsocket = {
if(obj != null) {
if(obj.func == 'registered') {
MovimWebsocket.launchAttached();
MovimWebsocket.launchRegistered();
}
if(obj.func == 'disconnected') {
@ -101,6 +112,12 @@ var MovimWebsocket = {
}
},
register : function(func) {
if(typeof(func) === "function") {
this.registered.push(func);
}
},
clearAttached : function() {
this.attached = new Array();
},

11
app/controllers/FeedController.php

@ -0,0 +1,11 @@
<?php
class FeedController extends BaseController {
function load() {
$this->session_only = false;
$this->raw = true;
}
function dispatch() {
}
}

10
app/controllers/RoomController.php

@ -0,0 +1,10 @@
<?php
class RoomController extends BaseController {
function load() {
}
function dispatch() {
$this->page->setTitle(__('page.room'));
}
}

2
app/helpers/StringHelper.php

@ -233,7 +233,7 @@ function explodeJid($jid)
*/
function stringToUri($url) {
$url = utf8_decode($url);
$url = strtolower(strtr($url, utf8_decode('ÀÁÂÃÄÅàáâãäåÒÓÔÕÖØòóôõöøÈÉÊËèéêëÇçÌÍÎÏìíîïÙÚÛÜùúûüÿÑñ()[]\'"~$&%*@ç!?;,:/\^¨€{}<>|+- '), 'aaaaaaaaaaaaooooooooooooeeeeeeeecciiiiiiiiuuuuuuuuynn -- c --- e --'));
$url = strtolower(strtr($url, utf8_decode('ÀÁÂÃÄÅàáâãäåÒÓÔÕÖØòóôõöøÈÉÊËèéêëÇçÌÍÎÏìíîïÙÚÛÜùúûüÿÑñ()[]\'"~$&%*@ç!?;,:/\^¨€{}<>|+- .'), 'aaaaaaaaaaaaooooooooooooeeeeeeeecciiiiiiiiuuuuuuuuynn -- c --- e --_'));
$url = str_replace(' ', '', $url);
$url = str_replace('---', '-', $url);
$url = str_replace('--', '-', $url);

6
app/helpers/TimezoneHelper.php

@ -16,7 +16,8 @@ function getTimezoneList()
function getTimezoneOffset($timezone)
{
$tz = new DateTimeZone($timezone);
return $tz->getOffset(new DateTime);
$utc = new DateTimeZone('UTC');
return $tz->getOffset(new DateTime('now', $utc));
}
/*
@ -46,7 +47,8 @@ function getTimezoneOffset($timezone)
foreach( $timezones as $timezone )
{
$tz = new DateTimeZone($timezone);
$timezone_offsets[$timezone] = $tz->getOffset(new DateTime);
$utc = new DateTimeZone('UTC');
$timezone_offsets[$timezone] = $tz->getOffset(new DateTime('now', $utc));
}
// sort timezone by timezone name

4
app/models/config/Config.php

@ -10,7 +10,6 @@ class Config extends Model {
public $maxusers;
public $loglevel;
public $timezone;
public $websocketurl;
public $xmppwhitelist;
public $info;
public $unregister;
@ -36,8 +35,6 @@ class Config extends Model {
{"type":"string", "size":16, "mandatory":true },
"timezone" :
{"type":"string", "size":16, "mandatory":true },
"websocketurl" :
{"type":"string", "size":128, "mandatory":true },
"xmppwhitelist" :
{"type":"text" },
"info" :
@ -63,7 +60,6 @@ class Config extends Model {
$this->maxusers = -1;
$this->loglevel = 'empty';
$this->timezone = 'Etc/GMT';
$this->websocketurl = 'ws://localhost:5280';
$this->xmppwhitelist = '';
$this->info = '';
$this->unregister = false;

6
app/models/config/ConfigDAO.php

@ -4,7 +4,6 @@ namespace Modl;
class ConfigDAO extends SQL {
function set(Config $c) {
\movim_log('hop');
$this->_sql = '
update config
set environment = :environment,
@ -14,7 +13,6 @@ class ConfigDAO extends SQL {
maxusers = :maxusers,
loglevel = :loglevel,
timezone = :timezone,
websocketurl = :websocketurl,
xmppwhitelist = :xmppwhitelist,
info = :info,
unregister = :unregister,
@ -33,7 +31,6 @@ class ConfigDAO extends SQL {
'maxusers' => $c->maxusers,
'loglevel' => $c->loglevel,
'timezone' => $c->timezone,
'websocketurl' => $c->websocketurl,
'xmppwhitelist'=> $c->xmppwhitelist,
'info' => $c->info,
'unregister' => $c->unregister,
@ -68,7 +65,6 @@ class ConfigDAO extends SQL {
maxusers,
loglevel,
timezone,
websocketurl,
xmppwhitelist,
info,
unregister,
@ -86,7 +82,6 @@ class ConfigDAO extends SQL {
:maxusers,
:loglevel,
:timezone,
:websocketurl,
:xmppwhitelist,
:info,
:unregister,
@ -107,7 +102,6 @@ class ConfigDAO extends SQL {
'maxusers' => $c->maxusers,
'loglevel' => $c->loglevel,
'timezone' => $c->timezone,
'websocketurl' => $c->websocketurl,
'xmppwhitelist'=> $c->xmppwhitelist,
'info' => $c->info,
'unregister' => $c->unregister,

23
app/models/contact/Contact.php

@ -365,6 +365,7 @@ class Contact extends Model {
if(isset($this->date)
&& $this->date != '0000-00-00T00:00:00+0000'
&& $this->date != '1970-01-01 00:00:00'
&& $this->date != '1970-01-01 01:00:00'
&& $this->date != '1970-01-01T00:00:00+0000') {
$age = intval(substr(date('Ymd') - date('Ymd', strtotime($this->date)), 0, -4));
if($age != 0)
@ -392,6 +393,7 @@ class Contact extends Model {
return array(
'jid' => $this->jid,
'rostername' => $this->rostername,
'rostername' => $this->rostername,
'groupname' => $this->groupname,
'status' => $this->status,
'resource' => $this->resource,
@ -405,12 +407,30 @@ class Contact extends Model {
&& $this->date == null
&& $this->url == null
&& $this->email == null
&& $this->created == null
&& $this->updated == null
&& $this->description == null) {
return true;
} else {
return false;
}
}
function isOld() {
if(strtotime($this->updated) < mktime( // We update the 3 days old vcards
0,
0,
0,
gmdate("m"),
gmdate("d")-3,
gmdate("Y")
)
) {
return true;
} else {
return false;
}
}
}
class PresenceContact extends Contact {
@ -485,6 +505,7 @@ class RosterContact extends Contact {
protected $publickey;
protected $muc;
protected $rosterask;
protected $rostersubscription;
protected $node;
protected $ver;
protected $category;
@ -498,6 +519,8 @@ class RosterContact extends Contact {
{'type':'string', 'size':128 },
'rosterask' :
{'type':'string', 'size':128 },
'rostersubscription' :
{'type':'string', 'size':8 },
'groupname' :
{'type':'string', 'size':128 },
'resource' :

20
app/models/contact/ContactDAO.php

@ -373,7 +373,7 @@ class ContactDAO extends SQL {
left outer join privacy
on contact.jid = privacy.pkey
where privacy.value = 1
order by created desc';
order by updated desc';
if($limitr)
$this->_sql = $this->_sql.' limit '.$limitr.' offset '.$limitf;
@ -381,6 +381,21 @@ class ContactDAO extends SQL {
$this->prepare('Contact');
return $this->run('Contact');
}
function countAllPublic() {
$this->_sql =
'select count(*) from contact
left outer join privacy
on contact.jid = privacy.pkey
where privacy.value = 1';
$this->prepare('Contact');
$results = $this->run(null, 'array');
$results = array_values($results[0]);
return (int)$results[0];
}
function cleanRoster() {
$this->_sql = '
@ -407,6 +422,7 @@ class ContactDAO extends SQL {
contact.tuneartist,
contact.tunetitle,
rosterlink.rostername,
rosterlink.rostersubscription,
rosterlink.groupname,
rosterlink.chaton,
presence.status,
@ -445,6 +461,7 @@ class ContactDAO extends SQL {
contact.tuneartist,
contact.tunetitle,
rosterlink.rostername,
rosterlink.rostersubscription,
rosterlink.groupname,
rosterlink.chaton
from rosterlink
@ -516,6 +533,7 @@ class ContactDAO extends SQL {
contact.tuneartist,
contact.tunetitle,
rosterlink.rostername,
rosterlink.rostersubscription,
rosterlink.groupname,
rosterlink.chaton,
presence.status,

42
app/models/message/Message.php

@ -21,7 +21,8 @@ class Message extends Model {
public $color; // Only for chatroom purpose
public function __construct() {
public function __construct()
{
$this->_struct = '
{
"session" :
@ -50,4 +51,43 @@ class Message extends Model {
parent::__construct();
}
public function set($stanza, $parent = false)
{
if($stanza->body || $stanza->subject) {
$jid = explode('/',(string)$stanza->attributes()->from);
$to = current(explode('/',(string)$stanza->attributes()->to));
// This is not very beautiful
$user = new \User;
$this->session = $user->getLogin();
$this->jidto = $to;
$this->jidfrom = $jid[0];
if(isset($jid[1]))
$this->resource = $jid[1];
$this->type = 'chat';
if($stanza->attributes()->type) {
$this->type = (string)$stanza->attributes()->type;
}
$this->body = (string)$stanza->body;
$this->subject = (string)$stanza->subject;
if($stanza->html) {
$this->html = \cleanHTMLTags($stanza->html->body->asXML());
$this->html = \fixSelfClosing($this->html);
}
if($stanza->delay)
$this->published = gmdate('Y-m-d H:i:s', strtotime($stanza->delay->attributes()->stamp));
elseif($parent && $parent->delay)
$this->published = gmdate('Y-m-d H:i:s', strtotime($parent->delay->attributes()->stamp));
else
$this->published = gmdate('Y-m-d H:i:s');
$this->delivered = gmdate('Y-m-d H:i:s');
}
}
}

6
app/models/message/MessageDAO.php

@ -35,7 +35,7 @@ class MessageDAO extends SQL {
$this->prepare(
'Message',
array(
'session' => $this->_user,
'session' => $message->session,
'jidto' => $message->jidto,
'jidfrom' => $message->jidfrom,
'resource' => $message->resource,
@ -77,7 +77,7 @@ class MessageDAO extends SQL {
function deleteContact($jid) {
$this->_sql = '
delete from message
delete from message
where session = :session
and (jidfrom = :jidfrom
or jidto = :jidto)';
@ -114,7 +114,7 @@ class MessageDAO extends SQL {
function clearMessage() {
$this->_sql = '
delete from message
delete from message
where session = :session';
$this->prepare(

30
app/models/postn/PostnDAO.php

@ -174,7 +174,7 @@ class PostnDAO extends SQL {
)
);
return $this->run('Message');
return $this->run('Postn');
}
function deleteNode($origin, $node) {
@ -191,7 +191,7 @@ class PostnDAO extends SQL {
)
);
return $this->run('Message');
return $this->run('Postn');
}
function getNode($from, $node, $limitf = false, $limitr = false) {
@ -383,6 +383,32 @@ class PostnDAO extends SQL {
return $this->run('ContactPostn');
}
function getPublicItem($origin, $node, $nodeid, $limitf = false, $limitr = false) {
$this->_sql = '
select *, postn.aid, privacy.value as privacy from postn
left outer join contact on postn.aid = contact.jid
left outer join privacy on postn.nodeid = privacy.pkey
where postn.origin = :origin
and postn.node = :node
and privacy.value = 1
and postn.nodeid = :nodeid
order by postn.published desc';
if($limitr)
$this->_sql = $this->_sql.' limit '.$limitr.' offset '.$limitf;
$this->prepare(
'Postn',
array(
'origin' => $origin,
'node' => $node,
'nodeid' => $nodeid,
)
);
return $this->run('ContactPostn');
}
// TODO: fixme
function getComments($posts) {
$commentsid = '';

19
app/models/presence/Presence.php

@ -30,6 +30,9 @@ class Presence extends Model {
protected $mucjid;
protected $mucaffiliation;
protected $mucrole;
// vcard-temp:x:update, not saved in the DB
public $photo = false;
public function __construct() {
$this->_struct = '
@ -113,24 +116,30 @@ class Presence extends Model {
// Specific XEP
if($stanza->x) {
foreach($stanza->children() as $name => $c) {
$ns = $c->getNamespaces(true);
switch($ns['']) {
switch($c->attributes()->xmlns) {
case 'jabber:x:signed' :
$this->publickey = (string)$c;
break;
case 'http://jabber.org/protocol/muc#user' :
$this->muc = true;
$this->mucjid = cleanJid((string)$c->item->attributes()->jid);
$this->muc = true;
if($c->item->attributes()->jid)
$this->mucjid = cleanJid((string)$c->item->attributes()->jid);
else
$this->mucjid = (string)$stanza->attributes()->from;
$this->mucrole = (string)$c->item->attributes()->role;
$this->mucaffiliation = (string)$c->item->attributes()->affiliation;
break;
case 'vcard-temp:x:update' :
$this->photo = true;
break;
}
}
}
if($stanza->delay) {
$this->delay =
date(
gmdate(
'Y-m-d H:i:s',
strtotime(
(string)$stanza->delay->attributes()->stamp

24
app/models/presence/PresenceDAO.php

@ -113,7 +113,29 @@ class PresenceDAO extends SQL {
$this->run('Presence');
}
}
function delete(Presence $presence)
{
$id = sha1(
$presence->session.
$presence->jid.
$presence->resource
);
$this->_sql = '
delete from presence
where id = :id';
$this->prepare(
'Presence',
array(
'id' => $id
)
);
return $this->run('Presence');
}
function getAll() {
$this->_sql = '
select * from presence;

8
app/models/sessionx/Sessionx.php

@ -11,7 +11,6 @@ class Sessionx extends Model {
public $rid;
public $sid;
public $id;
public $url;
public $port;
public $host;
public $domain;
@ -19,6 +18,7 @@ class Sessionx extends Model {
public $active;
public $start;
public $timestamp;
public $mechanism;
public function __construct() {
$this->_struct = '
@ -39,8 +39,6 @@ class Sessionx extends Model {
{"type":"string", "size":64 },
"id" :
{"type":"int", "size":8, "mandatory":true },
"url" :
{"type":"string", "size":128, "mandatory":true },
"port" :
{"type":"int", "size":5, "mandatory":true },
"host" :
@ -54,7 +52,9 @@ class Sessionx extends Model {
"start" :
{"type":"date" },
"timestamp" :
{"type":"date" }
{"type":"date" },
"mechanism" :
{"type":"string", "size":64 }
}';
parent::__construct();

20
app/models/sessionx/SessionxDAO.php

@ -13,14 +13,14 @@ class SessionxDAO extends SQL {
rid = :rid,
sid = :sid,
id = :id,
url = :url,
port = :port,
host = :host,
domain = :domain,
config = :config,
active = :active,
start = :start,
timestamp = :timestamp
timestamp = :timestamp,
mechanism = :mechanism
where session = :session';
$this->prepare(
@ -34,14 +34,14 @@ class SessionxDAO extends SQL {
'rid' => $s->rid,
'sid' => $s->sid,
'id' => $s->id,
'url' => $s->url,
'port' => $s->port,
'host' => $s->host,
'domain' => $s->domain,
'config' => $s->config,
'active' => $s->active,
'start' => $s->start,
'timestamp' => $s->timestamp
'timestamp' => $s->timestamp,
'mechanism' => $s->mechanism
)
);
@ -58,14 +58,14 @@ class SessionxDAO extends SQL {
rid,
sid,
id,
url,
port,
host,
domain,
config,
active,
start,
timestamp)
timestamp,
mechanism)
values
(:session,
:username,
@ -75,14 +75,14 @@ class SessionxDAO extends SQL {
:rid,
:sid,
:id,
:url,
:port,
:host,
:domain,
:config,
:active,
:start,
:timestamp)';
:timestamp,
:mechanism)';
$this->prepare(
'Sessionx',
@ -95,14 +95,14 @@ class SessionxDAO extends SQL {
'rid' => $s->rid,
'sid' => $s->sid,
'id' => $s->id,
'url' => $s->url,
'port' => $s->port,
'host' => $s->host,
'domain' => $s->domain,
'config' => $s->config,
'active' => $s->active,
'start' => $s->start,
'timestamp' => $s->timestamp
'timestamp' => $s->timestamp,
'mechanism' => $s->mechanism
)
);

1
app/views/about.tpl

@ -1,4 +1,5 @@
<main>
<?php $this->widget('Header'); ?>
<section>
<div>
<?php $this->widget('Tabs');?>

1
app/views/feed.tpl

@ -0,0 +1 @@
<?php $this->widget('Syndication');?>

1
app/views/group.tpl

@ -8,5 +8,6 @@
<section>
<?php $this->widget('Groups'); ?>
<?php $this->widget('Group'); ?>
<?php $this->widget('Publish'); ?>
</section>
</main>

1
app/views/news.tpl

@ -10,5 +10,6 @@
<section>
<?php $this->widget('Menu');?>
<?php $this->widget('Post');?>
<?php $this->widget('Publish');?>
</section>
</main>

11
app/views/room.tpl

@ -0,0 +1,11 @@
<?php $this->widget('Presence'); ?>
<?php $this->widget('LoginAnonymous'); ?>
<main>
<?php $this->widget('Header');?>
<section>
<div>
<?php $this->widget('Rooms'); ?>
</div>
<?php $this->widget('Chat'); ?>
</section>
</main>

8
app/widgets/About/About.php

@ -15,6 +15,12 @@
class About extends WidgetBase
{
function load() {
function load()
{
}
function display()
{
$this->view->assign('version', APP_VERSION);
}
}

2
app/widgets/About/about.tpl

@ -1,5 +1,5 @@
<div class="tabelem" title="{$c->__('page.about')}" id="about">
<h2 class="padded_top_bottom">{$c->__('page.about')} </h2>
<h2 class="padded_top_bottom">Movim {$version} - {$c->__('page.about')} </h2>
<ul class="thick divided">
<li class="condensed">

40
app/widgets/Account/Account.php

@ -2,6 +2,7 @@
use Moxl\Xec\Action\Register\ChangePassword;
use Moxl\Xec\Action\Register\Remove;
use Moxl\Xec\Action\Register\Get;
use Respect\Validation\Validator;
class Account extends WidgetBase
@ -11,6 +12,7 @@ class Account extends WidgetBase
$this->addjs('account.js');
$this->registerEvent('register_changepassword_handle', 'onPasswordChanged');
$this->registerEvent('register_remove_handle', 'onRemoved');
//$this->registerEvent('register_get_handle', 'onRegister');
}
function onPasswordChanged()
@ -28,6 +30,28 @@ class Account extends WidgetBase
RPC::call('Account.clearAccount');
}
function onRegister($package)
{
$content = $package->content;
$view = $this->tpl();
if(isset($content->x)) {
$xml = new \XMPPtoForm();
$form = $xml->getHTML($content->x->asXML());
$view->assign('form', $form);
$view->assign('attributes', $content->attributes());
$view->assign('actions', null);
if(isset($content->actions)) {
$view->assign('actions', $content->actions);
}
Dialog::fill($view->draw('_account_form', true), true);
}
}
function ajaxChangePassword($form)
{
$validate = Validator::string()->length(6, 40);
@ -67,6 +91,22 @@ class Account extends WidgetBase
$da->request();
}
function ajaxRegister($server)
{
if(!$this->validateServer($server)) return;
$da = new Get;
$da->setTo($server)
->request();
}
private function validateServer($server)
{
$validate_server = Validator::string()->noWhitespace()->length(6, 80);
if(!$validate_server->validate($server)) return false;
else return true;
}
function display()
{
}

32
app/widgets/Account/_account_form.tpl

@ -0,0 +1,32 @@
<section class="scroll">
<form name="command" data-sessionid="{$attributes->sessionid}" data-node="{$attributes->node}">
{$form}
</form>
</section>
<div>
<a onclick="Dialog.clear()" class="button flat">
{$c->__('button.close')}
</a>
{if="$actions != null"}
{if="isset($actions->next)"}
<a onclick="AdHoc.submit()" class="button flat">
{$c->__('button.next')}
</a>
{/if}
{if="isset($actions->previous)"}
<a onclick="" class="button flat">
{$c->__('button.previous')}
</a>
{/if}
{if="isset($actions->cancel)"}
<a onclick="" class="button flat">
{$c->__('button.cancel')}
</a>
{/if}
{if="isset($actions->complete)"}
<!--<a onclick="" class="button flat">
{$c->__('button.submit')}
</a>-->
{/if}
{/if}
</div>

91
app/widgets/AccountError/AccountError.php

@ -1,91 +0,0 @@
<?php
/**
* @package Widgets
*
* @file AccountError.php
* This file is part of MOVIM.
*
* @brief The account creation widget error.
*
* @author Timothée Jaussoin <edhelas@gmail.com>
*
* @version 1.0
* @date 25 November 2011
*
* Copyright (C)2010 MOVIM project
*
* See COPYING for licensing information.
*/
class AccountError extends WidgetBase {
function load()
{
}
function display()
{
$warning = '';
if(isset($_GET['err']))
switch ($_GET['err']) {
case 'datamissing':
$warning = '
<div class="message warning">
'.$this->__('error.data_missing').'
</div> ';
break;
case 'jiderror':
$warning = '
<div class="message warning">
'.$this->__('error.jid_error').'
</div> ';
break;
case 'passworddiff':
$warning = '
<div class="message info">
'.$this->__('error.password_diff').'
</div> ';
break;
case 'nameerr':
$warning = '
<div class="message warning">
'.$this->__('error.name_error').'
</div> ';
break;
case 'notacceptable':
$warning = '
<div class="message error">
'.$this->__('error.not_acceptable').'
</div> ';
break;
case 'userconflict':
$warning = '
<div class="message warning">
'.$this->__('error.user_conflict').'
</div> ';
break;
case 'xmppconnect':
$warning = '
<div class="message error">
'.$this->__('error.xmpp_connect').'
</div> ';
break;
case 'xmppcomm':
$warning = '
<div class="message error">
'.$this->__('error.xmpp_communicate').'
</div> ';
break;
case 'unknown':
$warning = '
<div class="message error">
'.$this->__('error.unknown').'
</div> ';
break;
}
$this->view->assign('warning', $warning);
}
}

1
app/widgets/AccountError/accounterror.tpl

@ -1 +0,0 @@
{$warning}

10
app/widgets/AccountError/locales.ini

@ -1,10 +0,0 @@
error.data_missing = 'Some data are missing !'
error.jid_error = 'Wrong ID'
error.password_diff = 'You entered different passwords'
error.name_error = 'Invalid name'
error.not_acceptable = 'Request not acceptable'
error.user_conflict = 'Username already taken'
error.xmpp_connect = 'Could not connect to the XMPP server'
error.xmpp_communicate = 'Could not communicate with the XMPP server'
error.unknown = 'Unknown error'

14
app/widgets/AccountNext/AccountNext.php

@ -19,8 +19,9 @@ class AccountNext extends WidgetBase {
function display()
{
$host = $_GET['s'];
$host = $this->get('s');
$this->view->assign('init', $this->call('ajaxInit', "'".$host."'"));
$this->view->assign('getsubscriptionform', $this->call('ajaxGetForm', "'".$host."'"));
$this->view->assign('host', $host);
}
@ -31,8 +32,7 @@ class AccountNext extends WidgetBase {
$xtf = new \XMPPtoForm();
if(!empty($form->x)){
$ns = $form->x->getNamespaces();
switch($ns['']) {
switch($form->x->attributes()->xmlns) {
case 'jabber:x:data' :
$formview = $this->tpl();
@ -91,6 +91,12 @@ class AccountNext extends WidgetBase {
function ajaxGetForm($host)
{
$domain = \Moxl\Utils::getDomain($host);
// We create a new session or clear the old one
$s = Sessionx::start();
$s->init(null, null, $host, $domain);
\Moxl\Stanza\Stream::init($host);
}

2
app/widgets/AccountNext/accountnext.css

@ -1,3 +1,3 @@
#subscription_form form > div {
padding-left: 2rem;
left: 2rem;
}

10
app/widgets/AccountNext/accountnext.tpl

@ -1,5 +1,5 @@
<div id="subscribe">
<div id="subscription_form">
<div id="subscription_form" class="padded_right">
<ul class="simple thick">
<li>
<span>{$c->__('create.title')} {$c->__('on')} {$host}</span>
@ -10,9 +10,13 @@
<script type="text/javascript">
MovimWebsocket.attach(function()
{
{$getsubscriptionform}
MovimWebsocket.connection.register('{$host}');
AccountNext.host = '{$host}';
});
MovimWebsocket.register(function()
{
{$getsubscriptionform}
});
</script>
</div>

42
app/widgets/AdminMain/adminmain.tpl

@ -35,12 +35,12 @@
</div>
</div>
<!--
<div>
<input type="text" name="sizelimit" id="sizelimit" value="{$conf->sizelimit}" />
<label for="sizelimit">{$c->__('general.limit')}</label>
</div>
-->
<div>
<div class="select">
<select id="loglevel" name="loglevel">
@ -76,44 +76,6 @@
</div>
<br />
<h3>{$c->__('websocket.title')}</h3>
<!--{if="!$c->testBosh($conf->boshurl)"}
<div class="message error">
{$c->__('bosh.not_recheable')}
</div>
{/if}-->
<div>
<input type="text" id="websocketurl" name="websocketurl" placeholder="{$c->__('websocket.label')}" value="{$conf->websocketurl}"/>
<label for="websocketurl">{$c->__('websocket.label')}</label>
</div>
{if="isset($websockets)"}
<div class="element simple">
<label for="websocketurl">
{$c->__('websocket.publics')} -
<a target="_blank" href="https://api.movim.eu/">Movim API</a>
</label>
<dl>
{loop="$websockets->websockets"}
<dt>{$value->name}</dt>
<dd>{$value->url}</dd>
{/loop}
</dl>
</div>
{/if}
<ul class="thick">
<li class="condensed">
<span class="icon bubble color orange">
<i class="md md-warning"></i>
</span>
<span>{$c->__('websocket.info')}: <code>ws(s)://domain:port</code></span>
<p>{$c->__('websocket.save_info')}</p>
</li>
</ul>
<h3>{$c->__('whitelist.title')}</h3>

2
app/widgets/AdminTest/admintest.css

@ -102,7 +102,7 @@ figure div.link#browser-daemon {
top: 20%;
}
figure div.link#daemon-xmpp {
figure div.link#xmpp-daemon {
left: 60%;
top: 20%;
}

5
app/widgets/AdminTest/admintest.js

@ -20,6 +20,7 @@ var AdminTest = {
movim_remove_class('figure #browser-daemon', 'error');
movim_add_class('figure #browser-daemon', 'success');
movim_add_class('div #xmpp-daemon', 'success');
movim_remove_class('li.admindb', 'disabled');
movim_get_node('#websocket_error').style.display = 'none';
@ -36,7 +37,7 @@ var AdminTest = {
this.movimOK = false;
movim_add_class('figure #movim_block', 'error');
},
}/*,
testXMPPWebsocket : function(url) {
this.connection = new WebSocket(url, 'xmpp');
@ -46,7 +47,7 @@ var AdminTest = {
movim_add_class('figure #daemon-xmpp', 'success');
movim_get_node('#xmpp_websocket_error').style.display = 'none';
};
}
}*/
}
MovimWebsocket.attach(function() {

20
app/widgets/AdminTest/admintest.tpl

@ -7,7 +7,7 @@
<div id="movim-daemon" class="link vertical disabled"><i class="md md-settings"></i></div>
<div id="movim-browser" class="link horizontal success"><i class="md md-open-in-browser"></i></div>
<div id="browser-daemon" class="link horizontal error"><i class="md md-settings-ethernet"></i></div>
<div id="daemon-xmpp" class="link horizontal error"><i class="md md-import-export"></i></div>
<div id="xmpp-daemon" class="link horizontal"><i class="md md-import-export"></i></div>
<div id="movim-database" class="link vertical {if="$dbconnected"}success {if="$dbinfos > 0"}warning{/if} {else}error{/if}">
<i class="md md-data-usage"></i>
</div>
@ -64,14 +64,14 @@
</span>
</li>
<li id="xmpp_websocket_error">
<!--<li id="xmpp_websocket_error">
<span class="icon bubble color red">
<i class="md md-settings-ethernet"></i>
</span>
<span>
{$c->__('compatibility.xmpp_websocket')} <code>{$websocketurl}</code>
</span>
</li>
</li>-->
{if="!$c->version()"}
<li class="condensed">
@ -96,6 +96,18 @@
<script type="text/javascript">AdminTest.disableMovim()</script>
{/if}
{if="!extension_loaded('gd')"}
<li>
<span class="icon color bubble red">
<i class="md md-image"></i>
</span>
<span>
{$c->__('compatibility.gd')}
</span>
</div>
<script type="text/javascript">AdminTest.disableMovim()</script>
{/if}
{if="!$c->testDir(DOCUMENT_ROOT)"}
<li>
<span class="icon color bubble red">
@ -115,5 +127,5 @@
</li>
{/if}
</ul>
<script type="text/javascript">AdminTest.testXMPPWebsocket('{$websocketurl}');</script>
<!--<script type="text/javascript">AdminTest.testXMPPWebsocket('{$websocketurl}');</script>-->
</div>

3
app/widgets/AdminTest/locales.ini

@ -6,9 +6,10 @@ compatibility.php1 = 'Update your PHP-Version: %s'
compatibility.php2 = 'Required: 5.3.0'
compatibility.curl = 'Install the php5-curl library'
compatibility.imagick = 'Install the php5-imagick library'
compatibility.gd = 'Install the php5-gd library'
compatibility.rights = "Read and write rights for the webserver in Movim's root directory"
compatibility.rewrite = 'The URL Rewriting support is currently disabled'
compatibility.db = 'The database need to be updated, go to the database panel to fix this'
compatibility.db = 'The database need to be updated, go to the database panel to fix this'
compatibility.websocket = 'WebSocket connection error, check if the Movim Daemon is running and is reacheable'
compatibility.xmpp_websocket = 'XMPP Websocket connection error, please check the validity of the URL given in the General Configuration'

2
app/widgets/Api/Api.php

@ -65,7 +65,7 @@ class Api extends WidgetBase {
array(
'uri' => BASE_URI,
'rewrite' => $rewrite));
\movim_log($json);
$json = json_decode($json);
if(isset($json) && $json->status == 200) {

2
app/widgets/Avatar/avatar.js

@ -31,7 +31,7 @@ var Avatar = {
}
}
var base64 = canvas.toDataURL('image/jpeg', 0.8);
var base64 = canvas.toDataURL('image/jpeg', 0.7);
var preview = document.querySelector('form[name=avatarform] img');
var input = document.querySelector('input[name="photobin"]');

19
app/widgets/Blog/Blog.php

@ -1,6 +1,6 @@
<?php
class Blog extends WidgetCommon {
class Blog extends WidgetBase {
function load()
{
@ -24,8 +24,21 @@ class Blog extends WidgetCommon {
$this->view->assign('contact', $c);
$pd = new \modl\PostnDAO();
$messages = $pd->getPublic($from, $node, 10, 0);
if($id = $this->get('i')) {
$messages = $pd->getPublicItem($from, $node, $id, 10, 0);
} else {
$messages = $pd->getPublic($from, $node, 10, 0);
}
$this->view->assign('posts', $messages);
}
function getComments($post)
{
$pd = new \Modl\PostnDAO();
return $pd->getComments($post);
//$view = $this->tpl();
//$view->assign('comments', $comments);
}
}

55
app/widgets/Blog/blog.tpl

@ -15,9 +15,17 @@
</span>
<span>
{if="$contact"}
<h2>{$c->__('blog.title', $contact->getTrueName())}</h2>
<h2>
<a href="{$c->route('blog', array($contact->jid))}">
{$c->__('blog.title', $contact->getTrueName())}
</a>
</h2>
{else}
<h2>{$c->__('page.blog')}</h2>
<h2>
<a href="{$c->route('blog', array($contact->jid))}">
{$c->__('page.blog')}
</a>
</h2>
{/if}
</span>
</li>
@ -39,11 +47,13 @@
</span>
{/if}
<h2>
{if="$value->title != null"}
{$value->title}
{else}
{$c->__('post.default_title')}
{/if}
<a href="{$c->route('blog', array($value->origin, $value->nodeid))}">
{if="$value->title != null"}
{$value->title}
{else}
{$c->__('post.default_title')}
{/if}
</a>
</h2>
<p>
{if="$value->node == 'urn:xmpp:microblog:0' && $value->getContact()->getTrueName() != ''"}
@ -87,7 +97,38 @@
{/if}
</ul>
</footer>
{$comments = $c->getComments($value)}
{if="$comments"}
<ul class="spaced middle">
<li class="subheader">
{$c->__('post.comments')}
<span class="info">{$comments|count}</span>
</li>
{loop="$comments"}
<li class="condensed">
{$url = $value->getContact()->getPhoto('s')}
{if="$url"}
<span class="icon bubble">
<img src="{$url}">
</span>
{else}
<span class="icon bubble color {$value->getContact()->jid|stringToColor}">
<i class="md md-person"></i>
</span>
{/if}
<span class="info">{$value->published|strtotime|prepareDate}</span>
<span>
{$value->getContact()->getTrueName()}
</span>
<p>
{$value->content}
</p>
</li>
{/loop}
</ul>
{/if}
</article>
{/loop}
{if="$posts == null"}
<ul class="simple thick">

51
app/widgets/Chat/Chat.php

@ -10,7 +10,7 @@ use Moxl\Xec\Action\Muc\SetSubject;
use Respect\Validation\Validator;
class Chat extends WidgetCommon
class Chat extends WidgetBase
{
function load()
{
@ -19,6 +19,7 @@ class Chat extends WidgetCommon
$this->addcss('chat.css');
$this->registerEvent('carbons', 'onMessage');
$this->registerEvent('message', 'onMessage');
$this->registerEvent('mamresult', 'onMessageHistory');
$this->registerEvent('composing', 'onComposing');
$this->registerEvent('paused', 'onPaused');
$this->registerEvent('gone', 'onGone');
@ -48,13 +49,18 @@ class Chat extends WidgetCommon
}
}
}*/
function onMessageHistory($packet)
{
$this->onMessage($packet, true);
}
function onMessage($packet, $mine = false)
function onMessage($packet, $history = false)
{
$message = $packet->content;
$cd = new \Modl\ContactDAO;
if($message->session == $message->jidto) {
if($message->session == $message->jidto && !$history) {
$from = $message->jidfrom;
$contact = $cd->getRosterItem($from);
@ -71,21 +77,17 @@ class Chat extends WidgetCommon
RPC::call('movim_fill', $from.'_state', '');
// If the message is from me
} else {
} /*else {
$from = $message->jidto;
$contact = $cd->get();
}
}*
$me = $cd->get();
if($me == null) {
$me = new \Modl\Contact;
}
}*/
if(preg_match('#^\?OTR#', $message->body)) {
if(!$mine) {
//RPC::call('ChatOTR.receiveMessage', $message->body);
}
} else {
if(!preg_match('#^\?OTR#', $message->body)) {
RPC::call('Chat.appendMessage', $this->prepareMessage($message));
}
RPC::call('MovimTpl.scrollPanel');
@ -174,13 +176,16 @@ class Chat extends WidgetCommon
/**
* @brief Get a discussion
* @parem string $jid
* @param string $jid
*/
function ajaxGet($jid = null)
{
if($jid == null) {
RPC::call('movim_fill', 'chat_widget', $this->prepareEmpty());
} else {
$chats = new Chats;
$chats->ajaxGetHistory($jid);
$html = $this->prepareChat($jid);
$header = $this->prepareHeader($jid);
@ -196,7 +201,7 @@ class Chat extends WidgetCommon
/**
* @brief Get a chatroom
* @parem string $jid
* @param string $jid
*/
function ajaxGetRoom($room)
{
@ -237,7 +242,14 @@ class Chat extends WidgetCommon
if($muc) {
$m->type = 'groupchat';
$m->resource = $session->user;
$s = Session::start();
$m->resource = $s->get('username');
if($m->resource == null) {
$m->resource = $session->user;
}
$m->jidfrom = $to;
}
@ -253,7 +265,7 @@ class Chat extends WidgetCommon
/* Is it really clean ? */
$packet = new Moxl\Xec\Payload\Packet;
$packet->content = $m;
$this->onMessage($packet, true);
$this->onMessage($packet/*, true*/);
if($resource != false) {
$to = $to . '/' . $resource;
@ -488,6 +500,9 @@ class Chat extends WidgetCommon
function prepareEmpty()
{
$view = $this->tpl();
$cd = new \Modl\ContactDAO;
$view->assign('top', $cd->getTop(10));
return $view->draw('_chat_empty', true);
}
@ -498,17 +513,15 @@ class Chat extends WidgetCommon
*/
private function validateJid($jid)
{
$validate_jid = Validator::email()->noWhitespace()->length(6, 60);
$validate_jid = Validator::string()->noWhitespace()->length(6, 60);
if(!$validate_jid->validate($jid)) return false;
else return true;
}
function display()
{
$validate_jid = Validator::email()->length(6, 40);
$this->view->assign('jid', false);
if($validate_jid->validate($this->get('f'))) {
if($this->validateJid($this->get('f'))) {
$this->view->assign('jid', $this->get('f'));
}
}

5
app/widgets/Chat/_chat.tpl

@ -10,7 +10,7 @@
<span class="icon gray emojis_open" onclick="Chat_ajaxSmiley()">
{$c->ajaxSmileyGet('😃')}
</span>
<div class="action" onclick="Chat.sendMessage('{$jid}', {if="$muc"}true{else}false{/if})">
<div class="action" data-jid="{$jid}" onclick="Chat.sendMessage(this.dataset.jid, {if="$muc"}true{else}false{/if})">
<i class="md md-send"></i>
</div>
<form>
@ -18,10 +18,11 @@
<textarea
rows="1"
id="chat_textarea"
data-jid="{$jid}"
onkeypress="
if(event.keyCode == 13) {
state = 0;
Chat.sendMessage('{$jid}', {if="$muc"}true{else}false{/if});
Chat.sendMessage(this.dataset.jid, {if="$muc"}true{else}false{/if});
return false;
} else {
{if="!$muc"}

27
app/widgets/Chat/_chat_empty.tpl

@ -2,3 +2,30 @@
<h1>{$c->__('chat.empty_title')}</h1>
<h4>{$c->__('chat.empty_text')}</h4>
</div>
<br />
<ul class="flex middle active">
<li class="subheader block large">{$c->__('chat.frequent')}</li>
{loop="$top"}
<li class="condensed block {if="$value->last > 60"} inactive{/if}"
onclick="Chats_ajaxOpen('{$value->jid}'); Chat_ajaxGet('{$value->jid}');">
{$url = $value->getPhoto('s')}
{if="$url"}
<span class="icon bubble
{if="$value->value"}
status {$presencestxt[$value->value]}
{/if}">
<img src="{$url}">
</span>
{else}
<span class="icon bubble color {$value->jid|stringToColor}
{if="$value->value"}
status {$presencestxt[$value->value]}
{/if}">
<i class="md md-person"></i>
</span>
{/if}
<span>{$value->getTrueName()}</span>
<p class="wrap">{$value->jid}</p>
</li>
{/loop}
</ul>

42
app/widgets/Chat/_chat_header_room.tpl

@ -1,17 +1,24 @@
{$anon = $c->supported('anonymous')}
<div>
<ul class="active">
<li onclick="Rooms_ajaxAdd()">
<span class="icon">
<i class="md md-group-add"></i>
</span>
</li>
</ul>
{if="!$anon"}
<ul class="active">
<li onclick="Rooms_ajaxAdd()">
<span class="icon">
<i class="md md-group-add"></i>
</span>
</li>
</ul>
{/if}
<span class="on_desktop icon"><i class="md md-forum"></i></span>
<h2>{$c->__('page.chats')}</h2>
{if="!$anon"}
<h2>{$c->__('page.chats')}</h2>
{else}
<h2>{$c->__('page.room')}</h2>
{/if}
</div>
<div>
<ul class="active">
<li onclick="Rooms_ajaxExit('{$room}'); MovimTpl.hidePanel();">
<li onclick="Rooms_ajaxExit('{$room}'); MovimTpl.hidePanel(); {if="$anon"}Presence_ajaxLogout(){/if}">
<span class="icon">
<i class="md md-close"></i>
</span>
@ -22,8 +29,17 @@
</span>
</li>
</ul>
<div class="return active r2 {if="$subject != null"}condensed{/if}" onclick="MovimTpl.hidePanel(); Chat_ajaxGet();">
<span id="back" class="icon" ><i class="md md-arrow-back"></i></span>
<div
class="return {if="!$anon"}active{/if} r2 {if="$subject != null"}condensed{/if}"
{if="!$anon"}onclick="MovimTpl.hidePanel(); Chat_ajaxGet();"{/if}>
<span id="back" class="icon" >
{if="!$anon"}
<i class="md md-arrow-back"></i>
{else}
<i class="md md-chat"></i>
{/if}
</span>
{if="$conference != null && $conference->name"}
<h2 title="{$room}">{$conference->name}</h2>
{else}
@ -37,10 +53,12 @@
<li onclick="Rooms_ajaxList('{$room}')">
<span>{$c->__('chatroom.members')}</span>
</li>
{if="$presence != null && $presence->mucrole == 'moderator'"}
{if="!$anon"}
<li onclick="Rooms_ajaxRemoveConfirm('{$room}')">
<span>{$c->__('button.delete')}</span>
</li>
{/if}
{if="$presence != null && $presence->mucrole == 'moderator' && !$anon"}
<li onclick="Chat_ajaxGetRoomConfig('{$room}')">
<span>{$c->__('chatroom.config')}</span>
</li>

8
app/widgets/Chat/chat.css

@ -70,12 +70,20 @@
line-height: 3rem;
}
#chat_widget li.room span {
white-space: initial;
}
#chat_widget li.room span.user {
font-weight: 700;
float: left;
margin-right: 1rem;
}
#chat_widget li.room span.user:hover {
cursor: pointer;
}
#chat_widget .placeholder {
padding-top: 37em;
background-size: 35rem 35rem;

12
app/widgets/Chat/chat.js

@ -52,7 +52,8 @@ var Chat = {
var id = null;
if(message.type == 'groupchat') {
bubble = Chat.room;
bubble = Chat.room.cloneNode(true);
id = message.jidfrom + '_conversation';
if(message.body.match(/^\/me/)) {
@ -63,9 +64,16 @@ var Chat = {
bubble.querySelector('div').innerHTML = message.body;
bubble.querySelector('span.info').innerHTML = message.published;
bubble.querySelector('span.user').className = 'user ' + message.color;
bubble.querySelector('span.user').onclick = function(n) {
var textarea = document.querySelector('#chat_textarea');
textarea.value = this.innerHTML + ', ' + textarea.value;
textarea.focus();
};
bubble.querySelector('span.user').innerHTML = message.resource;
movim_append(id, bubble.outerHTML);
document.getElementById(id).appendChild(bubble);
bubble.querySelector('div').className = '';
} else {
if(message.session == message.jidfrom) {

1
app/widgets/Chat/locales.ini

@ -11,6 +11,7 @@ chat.placeholder = 'Your message here...'
chat.smileys = 'Smileys'
chat.empty_title = 'Chat'
chat.empty_text = 'Discuss with your contacts'
chat.frequent = 'Frequent contacts'
chatroom.members = 'Members'
chatroom.connected = 'Connected to the chatroom'

47
app/widgets/Chats/Chats.php

@ -6,7 +6,7 @@ use Moxl\Xec\Action\Bookmark\Set;
use Respect\Validation\Validator;
class Chats extends WidgetCommon
class Chats extends WidgetBase
{
function load()
{
@ -59,6 +59,26 @@ class Chats extends WidgetCommon
}
}
/**
* @brief Get history
*/
function ajaxGetHistory($jid)
{
if(!$this->validateJid($jid)) return;
$md = new \Modl\MessageDAO();
$messages = $md->getContact(echapJid($jid), 0, 1);
$g = new \Moxl\Xec\Action\MAM\Get;
$g->setJid($jid);
if(!empty($messages)) {
$g->setStart(strtotime($messages[0]->published));
}
$g->request();
}
function ajaxOpen($jid)
{
if(!$this->validateJid($jid)) return;
@ -66,21 +86,25 @@ class Chats extends WidgetCommon
$chats = Cache::c('chats');
if($chats == null) $chats = array();
unset($chats[$jid]);
if(!array_key_exists($jid, $chats)
&& $jid != $this->user->getLogin()) {
$chats[$jid] = 1;
} else {
unset($chats[$jid]);
}
$chats[$jid] = 1;
$this->ajaxGetHistory($jid);
Cache::c('chats', $chats);
Cache::c('chats', $chats);
RPC::call('movim_delete', $jid.'_chat_item');
RPC::call('movim_delete', $jid.'_chat_item');
RPC::call('movim_prepend', 'chats_widget_list', $this->prepareChat($jid));
RPC::call('Chats.refresh');
RPC::call('movim_prepend', 'chats_widget_list', $this->prepareChat($jid));
RPC::call('Chats.refresh');
}/* else {
unset($chats[$jid]);
}
$chats[$jid] = 1;*/
}
function ajaxClose($jid)
@ -145,6 +169,7 @@ class Chats extends WidgetCommon
$cd = new \Modl\ContactDAO;
$md = new \modl\MessageDAO();
$cad = new \modl\CapsDAO();
$presencestxt = getPresencesTxt();
@ -154,8 +179,10 @@ class Chats extends WidgetCommon
$view->assign('presence', $presencestxt[$cr->value]);
}
$view->assign('contact', $cr);
$view->assign('caps', $cad->get($cr->node.'#'.$cr->ver));
} else {
$view->assign('contact', $cd->get($jid));
$view->assign('caps', null);
}
$m = $md->getContact($jid, 0, 1);
@ -168,7 +195,7 @@ class Chats extends WidgetCommon
private function validateJid($jid)
{
$validate_jid = Validator::email()->noWhitespace()->length(6, 40);
$validate_jid = Validator::string()->noWhitespace()->length(6, 40);
if($validate_jid->validate($jid)) return true;
else return false;

8
app/widgets/Chats/_chats.tpl

@ -1,8 +1,8 @@
{if="$chats == null"}
<li class="condensed">
<span class="icon green"><i class="md md-chat"></i></span>
<p>{$c->__('chats.empty')}</p>
</li>
<div class="placeholder icon">
<h1>{$c->__('chats.empty_title')}</h1>
<h4>{$c->__('chats.empty')}</h4>
</div>
{/if}
{loop="$chats"}

3
app/widgets/Chats/_chats_add.tpl

@ -3,7 +3,8 @@
<ul class="active" id="add_extend">
<li class="subheader">{$c->__('chats.frequent')}</li>
{loop="$top"}
<li class="condensed" onclick="Chats_ajaxOpen('{$value->jid}'); Dialog.clear()">
<li class="condensed {if="$value->last > 60"} inactive{/if}"
onclick="Chats_ajaxOpen('{$value->jid}'); Dialog.clear()">
{$url = $value->getPhoto('s')}
{if="$url"}
<span class="icon bubble

1
app/widgets/Chats/_chats_add_extend.tpl

@ -1,4 +1,5 @@
<br />
{$group = ''}
{loop="$contacts"}
{if="$group != $value->groupname"}
<li class="subheader">{$value->groupname}</li>

8
app/widgets/Chats/_chats_item.tpl

@ -4,8 +4,16 @@
class="
{if="isset($message)"}condensed{/if}
{if="$contact->last > 60"} inactive{/if}
{if="$caps && in_array($caps->type, array('handheld', 'phone'))"}
action
{/if}
"
title="{$contact->jid}">
{if="$caps && in_array($caps->type, array('handheld', 'phone'))"}
<div class="action">
<i class="md md-smartphone"></i>
</div>
{/if}
<span data-key="chat|{$contact->jid}" class="counter bottom"></span>
{$url = $contact->getPhoto('s')}
{if="$url"}

3
app/widgets/Chats/locales.ini

@ -1,5 +1,6 @@
[chats]
chats.empty = 'Open a new conversation by clicking on the plus button bellow'
chats.empty_title = 'No chats yet...'
chats.empty = 'Open a new conversation by clicking on the plus button bellow or visit the Contacts page.'
chats.add = 'Chat with a contact'
chats.frequent = 'Frequent contacts'
chats.more = 'Load more contacts'

54
app/widgets/Contact/Contact.php

@ -1,16 +1,19 @@
<?php
use Moxl\Xec\Action\Roster\UpdateItem;
use Moxl\Xec\Action\Vcard\Get;
use Moxl\Xec\Action\Vcard4\Get;
use Respect\Validation\Validator;
use Moxl\Xec\Action\Pubsub\GetItems;
class Contact extends WidgetCommon
class Contact extends WidgetBase
{
private $_paging = 10;
function load()
{
$this->registerEvent('roster_updateitem_handle', 'onContactEdited');
$this->registerEvent('vcard_get_handle', 'onVcardReceived');
$this->registerEvent('vcard4_get_handle', 'onVcardReceived');
}
public function onVcardReceived($packet)
@ -45,10 +48,10 @@ class Contact extends WidgetCommon
function ajaxEditSubmit($form)
{
$rd = new UpdateItem;
$rd->setTo(echapJid($form['jid']))
$rd->setTo(echapJid($form->jid->value))
->setFrom($this->user->getLogin())
->setName(htmlspecialchars($form['alias']))
->setGroup(htmlspecialchars($form['group']))
->setName($form->alias->value)
->setGroup($form->group->value)
->request();
}
@ -66,6 +69,9 @@ class Contact extends WidgetCommon
{
if(!$this->validateJid($jid)) return;
$a = new Moxl\Xec\Action\Avatar\Get;
$a->setTo(echapJid($jid))->request();
$r = new Get;
$r->setTo(echapJid($jid))->request();
}
@ -84,7 +90,7 @@ class Contact extends WidgetCommon
$view->assign('submit',
$this->call(
'ajaxEditSubmit',
"movim_parse_form('manage')"));
"movim_form_to_json('manage')"));
$view->assign('contact', $rl);
$view->assign('groups', $groups);
}
@ -151,10 +157,10 @@ class Contact extends WidgetCommon
{
if($jid == null) {
$cd = new \modl\ContactDAO();
$users = $cd->getAllPublic(0, 10);
if($users != null){
$count = $cd->countAllPublic();
if($count != 0){
$view = $this->tpl();
$view->assign('users', array_reverse($users));
$view->assign('users', $this->preparePublic());
return $view->draw('_contact_explore', true);
} else {
return '';
@ -166,6 +172,28 @@ class Contact extends WidgetCommon
}
}
function ajaxPublic($page = 0)
{
$validate_page = Validator::int();
if(!$validate_page->validate($page)) return;
RPC::call('MovimTpl.fill', '#public_list', $this->preparePublic($page));
}
private function preparePublic($page = 0)
{
$cd = new \modl\ContactDAO();
$users = $cd->getAllPublic($page*$this->_paging, $this->_paging);
$count = $cd->countAllPublic();
if($users != null){
$view = $this->tpl();
$view->assign('pages', array_fill(0, (int)($count/$this->_paging), 'p'));
$view->assign('users', array_reverse($users));
$view->assign('page', $page);
return $view->draw('_contact_public', true);
}
}
function prepareContact($jid)
{
if(!$this->validateJid($jid)) return;
@ -173,10 +201,12 @@ class Contact extends WidgetCommon
$cd = new \Modl\ContactDAO;
$c = $cd->get($jid, true);
if($c == null || $c->created == null || $c->isEmpty()) {
if($c == null
|| $c->created == null
|| $c->isEmpty()
|| $c->isOld()) {
$c = new \Modl\Contact;
$c->jid = $jid;
$this->ajaxRefreshVcard($jid);
}
@ -267,7 +297,7 @@ class Contact extends WidgetCommon
*/
private function validateJid($jid)
{
$validate_jid = Validator::email()->noWhitespace()->length(6, 60);
$validate_jid = Validator::string()->noWhitespace()->length(6, 60);
if(!$validate_jid->validate($jid)) return false;
else return true;
}

50
app/widgets/Contact/_contact.tpl

@ -86,7 +86,13 @@
<li class="condensed block">
<span class="icon gray"><i class="md md-link"></i></span>
<span>{$c->__('general.website')}</span>
<p class="wrap"><a href="{$contact->url}" target="_blank">{$contact->url}</a></p>
<p class="wrap">
{if="filter_var($contact->url, FILTER_VALIDATE_URL)"}
<a href="{$contact->url}" target="_blank">{$contact->url}</a>
{else}
{$contact->url}
{/if}
</p>
</li>
{/if}
@ -126,7 +132,7 @@
<li class="condensed block">
<span class="icon gray"><i class="md md-format-align-justify"></i></span>
<span>{$c->__('general.about')}</span>
<p>{$contact->description}</p>
<p class="all">{$contact->description}</p>
</li>
{/if}
@ -295,6 +301,46 @@
</ul>
{/if}
{if="$contactr->rostersubscription != 'both'"}
<div class="card">
<ul class="middle">
<li class="condensed">
{if="$contactr->rostersubscription == 'to'"}
<span class="icon gray">
<i class="md md-call-received"></i>
</span>
<span>{$c->__('subscription.to')}</span>
<p>{$c->__('subscription.to_text')}</p>
<a class="button flat" onclick="Notifs_ajaxAccept('{$contactr->jid}')">
{$c->__('subscription.to_button')}
</a>
{/if}
{if="$contactr->rostersubscription == 'from'"}
<span class="icon gray">
<i class="md md-call-made"></i>
</span>
<span>{$c->__('subscription.from')}</span>
<p>{$c->__('subscription.from_text')}</p>
<a class="button flat" onclick="Notifs_ajaxAsk('{$contactr->jid}')">
{$c->__('subscription.from_button')}
</a>
{/if}
{if="$contactr->rostersubscription == 'none'"}
<span class="icon gray">
<i class="md md-do-not-disturb"></i>
</span>
<span>{$c->__('subscription.none')}</span>
<p>{$c->__('subscription.none_text')}</p>
<a class="button flat" onclick="Notifs_ajaxAsk('{$contactr->jid}')">
{$c->__('subscription.none_button')}
</a>
{/if}
</li>
</ul>
</div>
{/if}
<a onclick="{$chat}" class="button action color red">
<i class="md md-chat"></i>
</a>

37
app/widgets/Contact/_contact_explore.tpl

@ -1,39 +1,6 @@
<br />
<h2>{$c->__('explore')}</h2>
<ul class="flex card active thick">
{loop="$users"}
<li class="{if="$value->description != ''"}condensed{/if} block" style="background-image: url();" onclick="Contact_ajaxGetContact('{$value->jid}');">
{$url = $value->getPhoto('s')}
{if="$url"}
<span class="icon bubble">
<img src="{$url}">
</span>
{else}
<span class="icon bubble color {$value->jid|stringToColor}">
<i class="md md-person"></i>
</span>
{/if}
<span>{$value->getTrueName()}</span>
{if="$value->getAge()"}
<span class="info">{$c->__('age.years', $value->getAge())}</span>
{/if}
{if="$value->getGender()"}
<span class="info">{$value->getGender()}</span>
{/if}
<!--
{if="$value->getMarital()"}
<span class="info">{$value->getMarital()}</span>
{/if}
-->
{if="$value->description != ''"}
<p>
{$value->description|strip_tags}
</p>
{/if}
</li>
{/loop}
<ul id="public_list" class="flex card active middle">
{$users}
</ul>

44
app/widgets/Contact/_contact_public.tpl

@ -0,0 +1,44 @@
{loop="$users"}
<li class="{if="$value->description != ''"}condensed{/if} block" style="background-image: url();" onclick="Contact_ajaxGetContact('{$value->jid}');">
{$url = $value->getPhoto('s')}
{if="$url"}
<span class="icon bubble">
<img src="{$url}">
</span>
{else}
<span class="icon bubble color {$value->jid|stringToColor}">
<i class="md md-person"></i>
</span>
{/if}
<span>{$value->getTrueName()}</span>
{if="$value->getAge()"}
<span class="info">{$c->__('age.years', $value->getAge())}</span>
{/if}
{if="$value->getGender()"}
<span class="info">{$value->getGender()}</span>
{/if}
<!--
{if="$value->getMarital()"}
<span class="info">{$value->getMarital()}</span>
{/if}
-->
{if="$value->description != ''"}
<p>
{$value->description|strip_tags}
</p>
{/if}
</li>
{/loop}
{if="$pages"}
<li class="block condensed">
<span class="icon gray">
<i class="md md-my-library-books"></i>
</span>
{loop="$pages"}
<a onclick="Contact_ajaxPublic('{$key}');" class="button flat {if="$key == $page"}on{/if}">{$key+1}</a>
{/loop}
</li>
{/if}

11
app/widgets/Contact/locales.ini

@ -49,3 +49,14 @@ age.years = '%s years'
[blog]
blog.last = 'Last public post'
[subscription]
subscription.to = 'You can see this contact status'
subscription.to_button = 'Share my status'
subscription.to_text = 'But this contact cannot see yours'
subscription.from = 'You are not subscribed to this contact'
subscription.from_button= 'Ask to subscribe'
subscription.from_text = 'But this contact can still see if you are online'
subscription.none = 'No subscriptions'
subscription.none_button= 'Invite'
subscription.none_text = 'This contact is in your contact list but there is no subscriptions between the two accounts'

42
app/widgets/Group/Group.php

@ -14,7 +14,7 @@ use Moxl\Xec\Action\Pubsub\Delete;
use Respect\Validation\Validator;
class Group extends WidgetCommon
class Group extends WidgetBase
{
private $_paging = 15;
private $_role = null;
@ -42,8 +42,10 @@ class Group extends WidgetCommon
function onItems($packet)
{
$arr = $packet->content;
$this->displayItems($arr['server'], $arr['node']);
list($server, $node) = array_values($packet->content);
$this->displayItems($server, $node);
RPC::call('Group.clearLoad');
RPC::call('MovimTpl.showPanel');
}
@ -68,6 +70,7 @@ class Group extends WidgetCommon
Notification::append(false, $this->__('group.empty'));
$this->ajaxDelete($server, $node, true);
$this->ajaxGetAffiliations($server, $node);
// Display an error message
RPC::call('Group.clearLoad');
}
@ -83,11 +86,13 @@ class Group extends WidgetCommon
Header::fill($this->prepareHeader($server, $node));
if(isset($this->_role)
&& ($this->_role == 'owner' || $this->_role == 'publisher')) {
$view = $this->tpl();
RPC::call('movim_append', 'group_widget', $view->draw('_group_publish', true));
}
//if(isset($this->_role)
//&& ($this->_role == 'owner' || $this->_role == 'publisher')) {
// $view = $this->tpl();
// $view->assign('server', $server);
// $view->assign('node', $node);
// RPC::call('movim_append', 'group_widget', $view->draw('_group_publish', true));
//}
}
function onSubscriptions($packet)
@ -166,11 +171,17 @@ class Group extends WidgetCommon
if(!$this->validateServerNode($server, $node)) return;
$html = $this->prepareGroup($server, $node);
$view = $this->tpl();
$view->assign('server', $server);
$view->assign('node', $node);
$html .= $view->draw('_group_publish', true);
$header = $this->prepareHeader($server, $node);
Header::fill($header);
RPC::call('movim_fill', 'group_widget', $html);
RPC::call('MovimTpl.fill', '#group_widget.'.stringToUri($server.'_'.$node), $html);
RPC::call('Group.enableVideos');
}
@ -228,13 +239,13 @@ class Group extends WidgetCommon
{
if(!$this->validateServerNode($server, $node)) return;
RPC::call('Group.addLoad', stringToUri($server.'_'.$node));
$r = new GetItemsId;
$r->setTo($server)
->setNode($node);
$r->request();
RPC::call('Group.addLoad');
}
function ajaxGetHistory($server, $node, $page)
@ -341,7 +352,10 @@ class Group extends WidgetCommon
function prepareEmpty()
{
$id = new \modl\ItemDAO();
$view = $this->tpl();
$view->assign('servers', $id->getGroupServers());
$html = $view->draw('_group_empty', true);
return $html;
@ -392,5 +406,11 @@ class Group extends WidgetCommon
function display()
{
$this->view->assign('server', false);
$this->view->assign('node', false);
if($this->validateServerNode($this->get('s'), $this->get('n'))) {
$this->view->assign('server', $this->get('s'));
$this->view->assign('node', $this->get('n'));
}
}
}

12
app/widgets/Group/_group_empty.tpl

@ -2,3 +2,15 @@
<h1>{$c->__('group.empty_title')}</h1>
<h4>{$c->__('group.empty_text')}</h4>
</div>
<br />
<ul class="flex middle active">
{loop="$servers"}
{if="!filter_var($value->server, FILTER_VALIDATE_EMAIL)"}
<li class="block condensed" onclick="Groups_ajaxDisco('{$value->server}')">
<span class="icon bubble color {$value->server|stringToColor}">{$value->server|firstLetterCapitalize}</span>
<span>{$value->server}</span>
<p>{$c->__('group.counter', $value->number)}</p>
</li>
{/if}
{/loop}
</ul>

9
app/widgets/Group/_group_posts.tpl

@ -19,8 +19,11 @@
{/if}
</h2>
<p>
{if="$value->node == 'urn:xmpp:microblog:0' && $value->getContact()->getTrueName() != ''"}
{$value->getContact()->getTrueName()} -
{if="$value->getContact()->getTrueName() != ''"}
<a href="{$c->route('contact', $value->getContact()->jid)}">
{$value->getContact()->getTrueName()}
</a>
-
{/if}
{$value->published|strtotime|prepareDate}
</p>
@ -34,12 +37,14 @@
<ul class="thin">
{if="isset($value->getAttachements().links)"}
{loop="$value->getAttachements().links"}
{if="substr($value.href, 0, 5) != 'xmpp:'"}
<li>
<span class="icon small"><img src="http://icons.duckduckgo.com/ip2/{$value.url.host}.ico"/></span>
<a href="{$value.href}" class="alternate" target="_blank">
<span>{$value.href|urldecode}</span>
</a>
</li>
{/if}
{/loop}
{/if}
{if="isset($value->getAttachements().files)"}

2
app/widgets/Group/_group_publish.tpl

@ -1,3 +1,3 @@
<a onclick="Group_ajaxPublish()" class="button action color">
<a onclick="Publish_ajaxTestPublish('{$server}','{$node}')" class="button action color">
<i class="md md-create"></i>
</a>

4
app/widgets/Group/group.js

@ -1,6 +1,8 @@
var Group = {
addLoad: function() {
addLoad: function(id) {
document.querySelector('#group_widget').className = 'divided spinner';
movim_add_class('#group_widget', 'on');
movim_add_class('#group_widget', id);
},
clearLoad: function() {

9
app/widgets/Group/group.tpl

@ -1,3 +1,12 @@
<div id="group_widget" class="divided spinner">
{$c->prepareEmpty()}
{if="$server && $node"}
<script type="text/javascript">
MovimWebsocket.attach(function() {
Group_ajaxGetItems('{$server}', '{$node}');
Group_ajaxGetMetadata('{$server}', '{$node}');
Group_ajaxGetAffiliations('{$server}', '{$node}');
});
</script>
{/if}
</div>

1
app/widgets/Group/locales.ini

@ -13,6 +13,7 @@ group.config_saved = 'Group configuration saved'
group.delete_title = 'Delete the group'
group.delete_text = 'You are going to delete the following group. Please confirm your action.'
group.delete_clean_text = "It seems that this group doesn't exists anymore. Do you want to remove it from your subscriptions?"
group.counter = '%s groups on this server'
group.configuration = 'Configuration'
group.subscriptions = 'Subscriptions'

39
app/widgets/Groups/Groups.php

@ -4,8 +4,9 @@ use Moxl\Xec\Action\Pubsub\GetItems;
use Moxl\Xec\Action\Pubsub\DiscoItems;
use Respect\Validation\Validator;
use Moxl\Xec\Action\Pubsub\Create;
use Moxl\Xec\Action\Pubsub\TestCreate;
class Groups extends WidgetCommon
class Groups extends WidgetBase
{
private $_list_server;
@ -14,6 +15,8 @@ class Groups extends WidgetCommon
$this->registerEvent('pubsub_discoitems_handle', 'onDisco');
$this->registerEvent('pubsub_discoitems_error', 'onDiscoError');
$this->registerEvent('pubsub_create_handle', 'onCreate');
$this->registerEvent('pubsub_testcreate_handle', 'onTestCreate');
$this->registerEvent('pubsub_testcreate_error', 'onTestCreateError');
$this->registerEvent('pubsub_delete_handle', 'onDelete');
$this->registerEvent('pubsub_delete_error', 'onDeleteError');
$this->addjs('groups.js');
@ -57,6 +60,21 @@ class Groups extends WidgetCommon
// Display a nice error
}
function onTestCreate($packet)
{
$server = $packet->content;
$view = $this->tpl();
$view->assign('server', $server);
Dialog::fill($view->draw('_groups_add', true));
}
function onTestCreateError($packet)
{
Notification::append(null, $this->__('groups.no_creation'));
}
function ajaxHeader()
{
$id = new \modl\ItemDAO();
@ -84,22 +102,27 @@ class Groups extends WidgetCommon
$r->setTo($server)->request();
}
function ajaxAdd($server)
/*
* Seriously ? We need to put this hack because of buggy XEP-0060...
*/
function ajaxTestAdd($server)
{
if(!$this->validateServer($server)) return;
$view = $this->tpl();
$view->assign('server', $server);
Dialog::fill($view->draw('_groups_add', true));
$t = new TestCreate;
$t->setTo($server)
->request();
}
function ajaxAddConfirm($server, $form)
{
if(!$this->validateServer($server)) return;
$validate_name = Validator::string()->length(6, 80);
if(!$validate_name->validate($form->name->value)) return;
$validate_name = Validator::string()->length(4, 80);
if(!$validate_name->validate($form->name->value)) {
Notification::append(null, $this->__('groups.name_error'));
return;
}
$uri = stringToUri($form->name->value);

2
app/widgets/Groups/_groups_server.tpl

@ -37,6 +37,6 @@
</li>
{/loop}
</ul>
<a onclick="Groups_ajaxAdd('{$server}')" class="button action color">
<a onclick="Groups_ajaxTestAdd('{$server}')" class="button action color">
<i class="md md-add"></i>
</a>

1
app/widgets/Groups/_groups_subscriptions.tpl

@ -18,6 +18,7 @@
{if="$value->description"}class="condensed"{/if}
data-server="{$value->server}"
data-node="{$value->node}"
title="{$value->server} - {$value->node}"
>
<span class="icon bubble color {$value->node|stringToColor}">{$value->node|firstLetterCapitalize}</span>
<span>

3
app/widgets/Groups/groups.js

@ -8,8 +8,9 @@ var Groups = {
items[i].onclick = function(e) {
MovimTpl.scrollPanelTop();
Group_ajaxGetItems(this.dataset.server, this.dataset.node);
Group_ajaxGetAffiliations(this.dataset.server, this.dataset.node);
Group_ajaxGetMetadata(this.dataset.server, this.dataset.node);
Group_ajaxGetAffiliations(this.dataset.server, this.dataset.node);
//Group_ajaxGetSubscriptions(this.dataset.server, this.dataset.node);
Groups.reset(items);
movim_add_class(this, 'active');
}

2
app/widgets/Groups/locales.ini

@ -8,6 +8,8 @@ groups.name = 'Group name'
groups.name_example = 'My Little Pony - Fan Club'
groups.created = 'Group created successfully'
groups.deleted = 'Group deleted successfully'
groups.name_error = 'Please provide a valid group name (4 characters minimum)'
groups.no_creation = 'You cannot create a new Group on this server'
groups.sub = '%s subscribers'
groups.num = '%s posts'

2
app/widgets/Header/Header.php

@ -1,6 +1,6 @@
<?php
class Header extends WidgetCommon
class Header extends WidgetBase
{
function load()
{

6
app/widgets/Header/_header_about.tpl

@ -0,0 +1,6 @@
<div>
<a href="{$c->route('main')}" class="classic">
<span id="menu" class="icon"><i class="md md-home"></i></span>
</a>
<h2>{$c->__('page.about')}</h2>
</div>

2
app/widgets/Header/_header_main.tpl

@ -1,5 +1,5 @@
<div>
<span id="menu" class="on_mobile icon active" onclick="MovimTpl.toggleMenu()"><i class="md md-menu"></i></span>
<span class="on_desktop icon"><i class="md md-view-list"></i></span>
<span class="on_desktop icon"><i class="md md-home"></i></span>
<h2 class="r1">{$c->__('page.home')}</h2>
</div>

4
app/widgets/Header/_header_news.tpl

@ -1,12 +1,12 @@
<div>
<span id="menu" class="on_mobile icon active" onclick="MovimTpl.toggleMenu()"><i class="md md-menu"></i></span>
<span class="on_desktop icon"><i class="md md-view-list"></i></span>
<span class="on_desktop icon"><i class="md md-filter-list"></i></span>
<form>
<div>
<div class="select">
<select onchange="window[this.value].apply()" name="language" id="language">
<option value="Menu_ajaxGetAll" selected="selected">{$c->__('menu.all')}</option>
<option value="Menu_ajaxGetNews" >{$c->__('menu.news')}</option>
<option value="Menu_ajaxGetNews" >{$c->__('menu.groups')}</option>
<option value="Menu_ajaxGetFeed" >{$c->__('menu.contacts')}</option>
</select>
</div>

4
app/widgets/Header/_header_room.tpl

@ -0,0 +1,4 @@
<div>
<span class="icon"><i class="md md-forum"></i></span>
<h2 class="r1">{$c->__('page.room')}</h2>
</div>

4
app/widgets/Header/locales.ini

@ -1,8 +1,8 @@
[menu]
menu.all = 'All'
menu.news = 'News'
menu.groups = 'Groups'
menu.contacts = 'Contacts'
menu.refresh = 'Refresh all the streams'
[roster]
roster.search = 'Search'
roster.search = 'Search in your contacts'

2
app/widgets/Hello/Hello.php

@ -1,6 +1,6 @@
<?php
class Hello extends WidgetCommon
class Hello extends WidgetBase
{
function load()
{

13
app/widgets/Hello/hello.tpl

@ -2,7 +2,7 @@
<ul class="flex active middle">
<li class="subheader block large">Active contacts</li>
{loop="$top"}
<li tabindex="{$key+1}" class="block action {if="$value->getPlace()"}condensed{/if}"
<li tabindex="{$key+1}" class="block action {if="$value->status"}condensed{/if}"
onclick="Hello_ajaxChat('{$value->jid}')">
{$url = $value->getPhoto('s')}
{if="$url"}
@ -24,11 +24,14 @@
{/if}
<span>{$value->getTrueName()}</span>
<p class="wrap">{$value->getPlace()}</p>
<p class="wrap">{$value->status}</p>
</li>
{/loop}
<a class="block large" href="{$c->route('chat')}">
<li>
<li class="action">
<div class="action">
<i class="md md-chevron-right"></i>
</div>
<span class="icon">
<i class="md md-forum"></i>
</span>
@ -90,14 +93,14 @@
<i class="md md-chevron-right"></i>
</div>
<span class="icon">
<i class="md md-view-list"></i>
<i class="md md-receipt"></i>
</span>
<span>{$c->__('hello.news')}</span>
</li>
</a>
</ul>
<br />
<ul class="active thick">
<ul class="active thick on_desktop">
<a href="{$c->route('blog', array($jid))}" target="_blank">
<li class="condensed action">
<div class="action">

3
app/widgets/Init/Init.php

@ -4,7 +4,8 @@ use Moxl\Xec\Action\Pubsub\ConfigurePersistentStorage;
use Moxl\Xec\Action\Pubsub\CreatePersistentStorage;
use Moxl\Xec\Action\Storage\Set;
class Init extends WidgetCommon {
class Init extends WidgetBase
{
function load()
{
$this->addjs('init.js');

52
app/widgets/Login/Login.php

@ -27,7 +27,6 @@ class Login extends WidgetBase
{
$this->addcss('login.css');
$this->addjs('login.js');
$this->registerEvent('moxlerror', 'onMoxlError');
$this->registerEvent('session_start_handle', 'onStart');
$this->registerEvent('saslfailure', 'onSASLFailure');
$this->registerEvent('storage_get_handle', 'onConfig');
@ -39,17 +38,22 @@ class Login extends WidgetBase
$pd = new \Modl\PresenceDAO();
$pd->clearPresence($this->user->getLogin());
// http://xmpp.org/extensions/xep-0280.html
\Moxl\Stanza\Carbons::enable();
$session = \Sessionx::start();
$session->load();
// We refresh the roster
$r = new GetList;
$r->request();
if($session->mechanism != 'ANONYMOUS') {
// http://xmpp.org/extensions/xep-0280.html
\Moxl\Stanza\Carbons::enable();
// We get the configuration
$s = new Get;
$s->setXmlns('movim:prefs')
->request();
// We refresh the roster
$r = new GetList;
$r->request();
// We get the configuration
$s = new Get;
$s->setXmlns('movim:prefs')
->request();
}
}
function onConfig($packet)
@ -106,11 +110,7 @@ class Login extends WidgetBase
return $view->draw('_login_error', true);
}
function onMoxlError($error) {
RPC::call('movim_redirect', Route::urlize('disconnect', $error[1]));
}
function onSASLFailure($packet)
{
switch($packet->content) {
@ -137,18 +137,6 @@ class Login extends WidgetBase
$this->showErrorBlock($error);
}
function ajaxCheckLogin($jid)
{
list($username, $host) = explode('@', $jid);
$sd = new \Modl\SessionxDAO;
$here = $sd->checkConnected($username, $host);
if($here) {
$message = $this->__('error.impossible') . ' : '.$this->__('error.conflict');
Notification::append(null, $message);
}
}
function ajaxLogin($form)
{
// We get the Server Configuration
@ -188,7 +176,6 @@ class Login extends WidgetBase
// We check if we already have an open session
$sd = new \Modl\SessionxDAO;
//$here = $sd->checkConnected($username, $host);
$here = $sd->getHash(sha1($username.$password.$host));
if($here) {
@ -199,13 +186,10 @@ class Login extends WidgetBase
}
// We try to get the domain
$dns = dns_get_record('_xmpp-client._tcp.'.$host);
$domain = \Moxl\Utils::getDomain($host);
if(isset($dns[0]['target']) && $dns[0]['target'] != null)
$domain = $dns[0]['target'];
else {
$domain = $host;
}
// We launch the XMPP socket
RPC::call('register', $host);
// We create a new session or clear the old one
$s = Sessionx::start();

6
app/widgets/Login/_login_sessions.tpl

@ -3,7 +3,7 @@
<br />
<ul class="active">
{loop="$sessions"}
<li id="{$value->jid}" class="action">
<li id="{$value->jid}" class="action condensed" title="{$value->jid}">
<div class="action">
<i class="md md-close"></i>
</div>
@ -18,11 +18,15 @@
</span>
{/if}
<span>{$value->getTrueName()}</span>
<p>{$value->jid}</p>
</li>
{/loop}
</ul>
</section>
<div>
<a class="button flat" href="{$c->route('about')}">
<i class="md md-help"></i>
</a>
<a class="button flat" href="{$c->route('admin')}">
<i class="md md-pages"></i>
</a>

1
app/widgets/Login/locales.ini

@ -4,7 +4,6 @@ error.empty_challenge = 'Empty Challenge from the server'
error.dns = 'XMPP Domain error, your account is not a correct Jabber ID'
error.data_missings = 'Some data are missing !'
error.wrong_password = 'Wrong password'
error.bosh_invalid = 'The current BOSH URL is invalid'
error.internal = 'Internal server error'
error.session = 'Session error'
error.account_created = 'Account successfully created'

11
app/widgets/Login/login.js

@ -13,10 +13,11 @@ var Login = {
form.onsubmit = function(e) {
e.preventDefault();
// We register the socket
MovimWebsocket.connection.register(this.querySelector('input#login').value.replace(/.*@/, ""));
var button = this.querySelector('input[type=submit]');
button.value = button.dataset.loading;
eval(this.dataset.action);
localStorage.username = document.querySelector('#login').value;
Login.rememberSession(localStorage.username);
@ -157,6 +158,12 @@ MovimWebsocket.attach(function()
}
});
MovimWebsocket.register(function()
{
form = document.querySelector('form[name="login"]');
eval(form.dataset.action);
});
movim_add_onload(function() {
/* Dump cache variables in localStorage */
for ( var i = 0, len = localStorage.length; i < len; ++i ) {

1
app/widgets/Login/login.tpl

@ -15,7 +15,6 @@
name="login">
<div>
<input type="email" name="login" id="login" autofocus required disabled
onblur="Login_ajaxCheckLogin(this.value)"
placeholder="{$c->__('form.username')}"/>
<label for="login">{$c->__('form.username')}</label>
</div>

59
app/widgets/LoginAnonymous/LoginAnonymous.php

@ -0,0 +1,59 @@
<?php
use Respect\Validation\Validator;
class LoginAnonymous extends WidgetBase
{
function load()
{
$this->addjs('loginanonymous.js');
$this->registerEvent('session_start_handle', 'onStart');
}
function onStart($packet)
{
$session = \Sessionx::start();
$session->load();
if($session->mechanism == 'ANONYMOUS') {
RPC::call('Rooms.anonymousJoin');
}
}
function display()
{
}
function ajaxLogin($username)
{
$validate_user = Validator::string()->length(4, 40);
if(!$validate_user->validate($username)) {
Notification::append(null, $this->__('login_anonymous.bad_username'));
return;
}
// We get the Server Configuration
$cd = new \Modl\ConfigDAO;
$config = $cd->get();
$host = 'anonymous.jappix.com';
$password = 'AmISnowden?';
// We try to get the domain
$domain = \Moxl\Utils::getDomain($host);
// We launch the XMPP socket
RPC::call('register', $host);
// We set the username in the session
$s = Session::start();
$s->set('username', $username);
// We create a new session or clear the old one
$s = Sessionx::start();
$s->init($username, $password, $host, $domain);
\Moxl\Stanza\Stream::init($host);
}
}

2
app/widgets/LoginAnonymous/locales.ini

@ -0,0 +1,2 @@
[login_anonymous]
login_anonymous.bad_username = 'Bad nickname (between 4 and 40 characters)'

8
app/widgets/LoginAnonymous/loginanonymous.js

@ -0,0 +1,8 @@
window.onbeforeunload = function() {
//Presence_ajaxLogout();
}
MovimWebsocket.attach(function() {
// We register the socket
MovimWebsocket.connection.register('anonymous.jappix.com');
});

1
app/widgets/LoginAnonymous/loginanonymous.tpl

@ -0,0 +1 @@

186
app/widgets/Media/Media.php

@ -1,186 +0,0 @@
<?php
/**
* @package Widgets
*
* @file Media.php
* This file is part of MOVIM.
*
* @brief The media manager.
*
* @author Timothée Jaussoin <edhelas@gmail.com>
*
* @version 1.0
* @date 07 December 2011
*
* Copyright (C)2010 MOVIM project
*
* See COPYING for licensing information.
*/
class Media extends WidgetBase {
function load()
{
$this->addcss('media.css');
$this->addjs('media.js');
if(isset($this->user)
&& !is_dir($this->user->userdir)
&& $this->user->userdir != '') {
mkdir($this->user->userdir);
touch($this->user->userdir.'index.html');
}
$this->registerEvent('media', 'onMediaUploaded');
}
function display() {
$this->view->assign('refresh', $this->call('ajaxRefreshMedia'));
}
function ajaxRefreshMedia()
{
$html = $this->mainFolder();
RPC::call('movim_fill', 'media', $html);
RPC::commit();
}
function ajaxDeleteItem($name)
{
unlink($this->user->userdir.$name);
$this->ajaxRefreshMedia();
}
function listFiles()
{
if(empty($this->user->getDir())) {
$mediaempty = $this->tpl();
return $mediaempty->draw('_media_empty', true);
}
$html = '<ul class="thumb">';
foreach($this->user->getDir() as $file) {
$p = new \Picture;
// Just to prevent issue when you update from an old Movim version
if($p->get($this->user->userdir.$file, 300) == false) {
$p->fromPath($this->user->userdir.$file);
$p->set($this->user->userdir.$file);
}
$html .=
'<li style="background-image: url('.$p->get($this->user->userdir.$file, 300).');">
<a href="'.Route::urlize('media', $file).'">
</a>
<div
class="remove"
onclick="'.
$this->call(
'ajaxDeleteItem',
"'".$file."'"
).'">
<i class="fa fa-times"></i>
</div>
</li>
';
}
$html .= '</ul>';
return $html;
}
function mainFolder()
{
$percent = number_format(($this->user->dirSize()/$this->user->sizelimit)*100, 2);
$html =
$this->listFiles().'
<span class="size"
title="'.sizeToCleanSize($this->user->dirSize()).' '.$this->__('media.on').' '.sizeToCleanSize($this->user->sizelimit).'"
>'.
$percent.'%
</span>';
return $html;
}
function pictureViewer($f)
{
if(file_exists($this->user->userdir.$f) && getimagesize($this->user->userdir.$f) != 0) {
$er = @exif_read_data($this->user->userdir.$f);
$exif = '';
if($er) {
if(isset($er['FileName']))
$exif .= '
<li>
<span>'.$this->__('media.name').'</span>'.
$er['FileName'].'
</li>';
if(isset($er['COMPUTED']['Width']) && isset($er['COMPUTED']['Height']))
$exif .= '
<li>
<span>'.$this->__('media.resolution').'</span>'.
$er['COMPUTED']['Width'].'x'.$er['COMPUTED']['Height'].'
</li>';
if(isset($er['FileSize']))
$exif .= '
<li>
<span>'.$this->__('media.size').'</span>'.
sizeToCleanSize($er['FileSize']).'
</li>';
if(isset($er['DateTime']))
$exif .= '
<li>
<span>'.$this->__('media.date').'</span>'.
prepareDate(strtotime($er['DateTime'])).'
</li>';
if(isset($er['ISOSpeedRatings']))
$exif .= '
<li>
<span>'.$this->__('media.iso').'</span>'.
$er['ISOSpeedRatings'].'
</li>';
if(isset($er['Model']))
$exif .= '
<li>
<span>'.$this->__('media.camera').'</span>'.
$er['Model'].'
</li>';
if(isset($er['Artist']))
$exif .= '
<li>
<span>'.$this->__('media.artist').'</span>'.
$er['Artist'].'
</li>';
}
$exif .= '
<li>
<span>'.$this->__('media.original').'</span>
<a target="_blank" href="'.$this->user->useruri.$f.'">'.
$this->__('media.link').'
</a>
</li>';
$html = '
<div class="viewer">
<img src="'.$this->user->useruri.$f.'" style="max-width: '.$er['COMPUTED']['Width'].'px"/>
<div class="exif">
<ul>
'.$exif.'
</ul>
</div>
</div>';
return $html;
}
}
}

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save