pax_global_header 0000666 0000000 0000000 00000000064 12061431535 0014512 g ustar 00root root 0000000 0000000 52 comment=2376c444f0cce32806315a3a921180354b080aeb
php-horde-sesha-1.0.0~beta1/ 0000775 0000000 0000000 00000000000 12061431535 0015612 5 ustar 00root root 0000000 0000000 php-horde-sesha-1.0.0~beta1/package.xml 0000664 0000000 0000000 00000043066 12061431535 0017740 0 ustar 00root root 0000000 0000000
seshapear.horde.orgA simple Inventory App for HordeSesha allows you to define categories with a rich set of attributes to manage your inventory stockJan Schneiderjanjan@horde.orgyesRalf Langrlanglang@b1-systems.deyes2012-08-081.0.0beta11.0.0beta1betabetaGPL-2.0
* [rla] Use Horde 5's CSS for sidebar icons.
* [rla] Use Horde 5's New button for the Add Stock menu entry.
5.3.01.7.0hordepear.horde.org5.0.0beta16.0.0alpha16.0.0alpha1Horde_Authpear.horde.org2.0.0beta13.0.0alpha13.0.0alpha1Horde_Autoloaderpear.horde.org2.0.0beta13.0.0alpha13.0.0alpha1Horde_Corepear.horde.org2.0.0beta13.0.0alpha13.0.0alpha1Horde_Dbpear.horde.org2.0.0beta13.0.0alpha13.0.0alpha1Horde_Exceptionpear.horde.org2.0.0beta13.0.0alpha13.0.0alpha1Horde_Formpear.horde.org2.0.0beta13.0.0alpha13.0.0alpha1Horde_Permspear.horde.org2.0.0beta13.0.0alpha13.0.0alpha1Horde_Prefspear.horde.org2.0.0beta13.0.0alpha13.0.0alpha1Horde_Rdopear.horde.org2.0.0beta13.0.0alpha13.0.0alpha1hordeRolepear.horde.org1.0.0alpha11.0.0alpha1alphaalpha2012-07-10GPL-2.0
* First alpha release.
* [rla] Use Horde_View in place of Horde_Template.
* [rla] change backend from Sql driver to Rdo driver with enhanced search capabilities.
* [jan] Add Finnish translation (Leena Heino <liinu@uta.fi>).
* [rla] Convert to Horde 5 Framework.
1.0.0beta11.0.0beta1betabeta2012-08-08GPL-2.0
* [rla] Use Horde 5's CSS for sidebar icons.
* [rla] Use Horde 5's New button for the Add Stock menu entry.
php-horde-sesha-1.0.0~beta1/sesha-1.0.0beta1/ 0000775 0000000 0000000 00000000000 12061431535 0020264 5 ustar 00root root 0000000 0000000 php-horde-sesha-1.0.0~beta1/sesha-1.0.0beta1/COPYING 0000664 0000000 0000000 00000035457 12061431535 0021335 0 ustar 00root root 0000000 0000000 GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program 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.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public 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.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
php-horde-sesha-1.0.0~beta1/sesha-1.0.0beta1/README 0000664 0000000 0000000 00000004154 12061431535 0021150 0 ustar 00root root 0000000 0000000 ================
What is Sesha?
================
:Contact: horde@lists.horde.org
.. contents:: Contents
.. section-numbering::
Sesha is the Horde Inventory Manager. It is an application designed to track a
multitude of items. It can organize stockable items into multiple categories,
each with unique properties.
This software is OSI Certified Open Source Software. OSI Certified is a
certification mark of the `Open Source Initiative`_.
.. _`Open Source Initiative`: http://www.opensource.org/
Obtaining Sesha
===============
Further information on Sesha and the latest version can be obtained at
http://www.horde.org/apps/sesha
Documentation
=============
The following documentation is available in the Sesha distribution:
:README_: This file
:COPYING_: Copyright and license information
:`docs/CHANGES`_: Changes by release
:`docs/CREDITS`_: Project developers
:`docs/INSTALL`_: Installation instructions and notes
:`docs/TODO`_: Development TODO list
:`docs/UPGRADING`_: Pointers on upgrading from previous Sesha versions
Installation
============
Instructions for installing Sesha can be found in the file INSTALL_ in the
``docs/`` directory of the Sesha distribution.
Assistance
==========
If you encounter problems with Sesha, help is available!
The Horde Frequently Asked Questions List (FAQ), available on the Web at
http://wiki.horde.org/FAQ
Horde LLC runs a number of mailing lists, for individual applications
and for issues relating to the project as a whole. Information, archives, and
subscription information can be found at
http://www.horde.org/community/mail
Lastly, Horde developers, contributors and users also make occasional
appearances on IRC, on the channel #horde on the Freenode Network
(irc.freenode.net).
Licensing
=========
For licensing and copyright information, please see the file COPYING_ in the
Sesha distribution.
Thanks,
The Sesha Team
.. _README: README
.. _COPYING: http://www.horde.org/licenses/gpl
.. _docs/CHANGES: CHANGES
.. _docs/CREDITS: CREDITS
.. _INSTALL:
.. _docs/INSTALL: INSTALL
.. _docs/TODO: TODO
.. _docs/UPGRADING: UPGRADING
php-horde-sesha-1.0.0~beta1/sesha-1.0.0beta1/admin.php 0000664 0000000 0000000 00000026012 12061431535 0022066 0 ustar 00root root 0000000 0000000
*/
require_once __DIR__ . '/lib/Application.php';
Horde_Registry::appInit('sesha');
$perms = $GLOBALS['injector']->getInstance('Horde_Perms');
$sesha_driver = $GLOBALS['injector']->getInstance('Sesha_Factory_Driver')->create();
$vars = Horde_Variables::getDefaultVariables();
$category_id = $vars->get('category_id');
$property_id = $vars->get('property_id');
$actionID = $vars->get('actionID');
// Admin actions.
$baseUrl = $registry->get('webroot', 'sesha');
$adminurl = Horde::url('admin.php', true);
$tabs = new Horde_Core_Ui_Tabs('actionID', $vars);
$tabs->addTab(_("Manage Categories"), $adminurl, 'list_categories');
$tabs->addTab(_("Manage Properties"), $adminurl, 'list_properties');
if (!Sesha::isAdmin(Horde_Perms::DELETE)) {
$notification->push(_("You are no administrator"), 'horde.warning');
header('Location: ' . Horde::url('list.php', true));
exit;
}
/* Run through the action handlers. */
switch ($actionID) {
case 'add_category':
$url = Horde_Util::addParameter('admin.php', 'actionID', 'list_categories');
$title = _("Add a category");
$vars->set('actionID', $actionID);
$renderer = new Horde_Form_Renderer();
$form = new Sesha_Form_Category($vars);
if ($form->validate($vars)) {
$form->getInfo($vars, $info);
// Save category details.
try {
$category_id = $sesha_driver->addCategory($info);
} catch (Sesha_Exception $e) {
$notification->push(_("Could not add new category.") . $e->getMessage(), 'horde.warning');
header('Location: ' . Horde::url($baseUrl . $url, true));
exit;
}
try {
$result = $sesha_driver->setPropertiesForCategory($category_id,
$vars->get('properties'));
} catch (Sesha_Exception $e) {
$notification->push(_("Could not add properties to new category: %s, %s") . $category_id->getMessage(), $result->getMessage(), 'horde.warning');
header('Location: ' . Horde::url($baseUrl . $url, true));
exit;
}
$notification->push(_("New category added successfully."), 'horde.success');
header('Location: ' . Horde::url($url, true));
exit;
}
break;
case 'edit_category':
$url = Horde_Util::addParameter($baseUrl . '/admin.php', 'actionID', 'list_categories');
try {
$category = $sesha_driver->getCategory($category_id);
} catch (Sesha_Exception $e) {
$notification->push(_('Could not retrieve category') . $e->getMessage, 'horde.error');
header('Location: ' . Horde::url($baseUrl . $url, true));
exit;
}
$renderer = new Horde_Form_Renderer();
if ($vars->get('submitbutton') == _("Edit Category") ||
$vars->get('submitbutton') == _("Save Category")) {
$title = sprintf(_("Modifying %s"), $category['category']);
$vars->set('actionID', $actionID);
$form = new Sesha_Form_Category($vars);
$form->setTitle($title);
if ($form->validate($vars)) {
// Save category details.
$form->getInfo($vars, $info);
try {
$result = $sesha_driver->updateCategory($info);
} catch (Sesha_Exception $e) {
$notification->push(_("Could not update category details."), 'horde.warning');
header('Location: ' . Horde::url($url, true));
exit;
}
try {
$result = $sesha_driver->setPropertiesForCategory($vars->get('category_id'), $vars->get('properties'));
} catch (Sesha_Exception $e) {
$notification->push(_("Could not update properties for this category."), 'horde.warning');
header('Location: ' . Horde::url($url, true));
exit;
}
$notification->push(_("Updated category successfully."), 'horde.success');
header('Location: ' . Horde::url($url, true));
exit;
} else {
foreach ($category as $key => $val) {
$vars->set($key, $val);
}
}
} elseif ($vars->get('submitbutton') == _("Delete Category")) {
$title = sprintf(_("Delete Category \"%s\""), $category['category']);
$vars->set('actionID', 'delete_category');
$form = new Sesha_Form_CategoryDelete($vars);
$form->setTitle($title);
}
break;
case 'delete_category':
$url = Horde_Util::addParameter($baseUrl . '/admin.php', 'actionID', 'list_categories');
if ($vars->get('confirm') == 'yes') {
try {
$sesha_driver->deleteCategory($category_id);
} catch (Sesha_Exception $e) {
$notification->push(_("There was an error removing the category."), 'horde.warning');
header('Location: ' . Horde::url($url, true));
exit;
}
$notification->push(_("The category was deleted."), 'horde.success');
} else {
$notification->push(_("The category was not deleted."), 'horde.warning');
}
header('Location: ' . Horde::url($url, true));
exit;
case 'edit_property':
$url = Horde_Util::addParameter($baseUrl . '/admin.php', 'actionID', 'list_properties');
try {
$property = $sesha_driver->getProperty($property_id);
} catch (Sesha_Exception $e) {
$notification->push(_('Property not found'), 'horde.warning');
header('Location: ' . Horde::url($url, true));
exit;
}
$renderer = new Horde_Form_Renderer();
if ($vars->get('submitbutton') == _("Delete Property")) {
$title = sprintf(_("Delete Property \"%s\""), $property['property']);
$vars->set('actionID', 'delete_property');
$form = new Sesha_Form_PropertyDelete($vars);
$form->setTitle($title);
} else {
$title = sprintf(_("Modifying property \"%s\""), $property['property']);
$vars->set('actionID', $actionID);
$form = new Sesha_Form_Property($vars);
$form->setTitle($title);
if ($form->validate($vars)) {
// Save property details.
$form->getInfo($vars, $info);
try {
$result = $sesha_driver->updateProperty($info);
} catch (Sesha_Exception $e) {
$notification->push(_("Could not update property details."), 'horde.warning');
header('Location: ' . Horde::url($url, true));
exit;
}
$notification->push(_("Updated property successfully."), 'horde.success');
header('Location: ' . Horde::url($url, true));
exit;
} elseif ($vars->get('datatype') == $vars->get('__old_datatype')) {
foreach ($property as $key => $val) {
$vars->set($key, $val);
}
}
}
break;
case 'delete_property':
$url = Horde_Util::addParameter($baseUrl . '/admin.php', 'actionID', 'list_properties');
if ($vars->get('confirm') == 'yes') {
try {
$sesha_driver->deleteProperty($property_id);
} catch (Sesha_Exception $e) {
$notification->push(_("There was an error removing the property."), 'horde.warning');
header('Location: ' . Horde::url($url, true));
exit;
}
$notification->push(_("The property was deleted."), 'horde.success');
} else {
$notification->push(_("The property was not deleted."), 'horde.warning');
}
header('Location: ' . Horde::url($url, true));
exit;
case 'add_property':
$url = Horde_Util::addParameter($baseUrl . '/admin.php', 'actionID', 'list_properties');
$title = _("Add a property");
$vars->set('actionID', $actionID);
$renderer = new Horde_Form_Renderer();
$form = new Sesha_Form_Property($vars);
$form->setTitle(_("Add a new property"));
if ($form->validate($vars)) {
// Save property details.
$form->getInfo($vars, $info);
try {
$property_id = $sesha_driver->addProperty($info);
} catch (Sesha_Exception $e) {
$notification->push(_("Could not add property.") . $property_id->getMessage(), 'horde.warning');
header('Location: ' . Horde::url($url, true));
exit;
}
$notification->push(_("New property added successfully."), 'horde.success');
header('Location: ' . Horde::url($url, true));
exit;
}
break;
default:
case 'list_categories':
$url = Horde_Util::addParameter($baseUrl . '/admin.php', 'actionID', 'edit_category');
$vars->set('actionID', 'edit_category');
$renderer = new Horde_Form_Renderer();
$form = new Sesha_Form_CategoryList($vars, 'admin.php', 'post');
$valid = $form->validate($vars);
if ($valid) {
// Redirect to the category list form.
$url = Horde_Util::addParameter($url, 'category_id', $vars->get('category_id'));
header('Location: ' . Horde::url($url, true));
exit;
}
$vars2 = Horde_Variables::getDefaultVariables();
$form2 = new Sesha_Form_Category($vars2, 'admin.php', 'post');
$form2->setTitle(_("Add a new category"));
$vars2->set('actionID', 'add_category');
$valid = $form2->validate($vars2);
if ($valid) {
// Redirect to the category form.
$url = Horde_Util::addParameter($baseUrl . '/admin.php', 'actionID', 'list_categories');
header('Location: ' . Horde::url($url, true));
exit;
}
break;
case 'list_properties':
$vars->set('actionID', 'edit_property');
$renderer = new Horde_Form_Renderer();
$form = new Sesha_Form_PropertyList($vars, 'admin.php', 'post');
$valid = $form->validate($vars);
if ($valid) {
// Redirect to the property list form.
$url = Horde_Util::addParameter($baseUrl . '/admin.php', 'actionID', 'edit_property');
$url = Horde_Util::addParameter($url, 'property_id', $vars->get('property_id'));
header('Location: ' . Horde::url($url, true));
exit;
}
$vars2 = Horde_Variables::getDefaultVariables();
$vars2->set('actionID', 'add_property');
$form2 = new Sesha_Form_Property($vars2, 'admin.php', 'post');
$form2->setTitle(_("Add a new property"));
$valid = $form2->validate($vars2);
if ($valid) {
// Redirect to the property form.
$url = Horde_Util::addParameter($baseUrl . '/admin.php', 'actionID', 'list_properties');
header('Location: ' . Horde::url($url, true));
exit;
}
break;
}
$page_output->header(array(
'title' => $title
));
require SESHA_TEMPLATES . '/menu.inc';
echo $tabs->render(strpos($actionID, 'propert') === false ? 'list_categories' : 'list_properties');
// Render forms if they are defined.
if (isset($form)) {
$form->renderActive($renderer, $vars, Horde::url('admin.php'), 'post');
}
if (isset($form2)) {
echo ' ';
$form2->renderActive($renderer, $vars2, Horde::url('admin.php'), 'post');
}
$page_output->footer();
php-horde-sesha-1.0.0~beta1/sesha-1.0.0beta1/bin/ 0000775 0000000 0000000 00000000000 12061431535 0021034 5 ustar 00root root 0000000 0000000 php-horde-sesha-1.0.0~beta1/sesha-1.0.0beta1/bin/sesha-add-stock 0000775 0000000 0000000 00000003344 12061431535 0023740 0 ustar 00root root 0000000 0000000 #!/usr/bin/env php
*/
if (file_exists(__DIR__ . '/../../sesha/lib/Application.php')) {
$baseDir = __DIR__ . '/../';
} else {
require_once 'PEAR/Config.php';
$baseDir = PEAR_Config::singleton()
->get('horde_dir', null, 'pear.horde.org') . '/sesha/';
}
require_once $baseDir . 'lib/Application.php';
Horde_Registry::appInit('sesha', array('cli' => true));
// Read command line parameters.
if (count($argv) < 4 || count($argv) > 6) {
$cli->message('Too many or too few parameters.', 'cli.error');
usage();
}
list($script, $name, $categories, $description, $attributes) = $argv;
/* Currently we only support one category per item added with this script */
if (!is_array($categories)) {
$categories = array($categories);
}
$driver = $GLOBALS['injector']->getInstance('Sesha_Factory_Driver')->create();
/* Find the categories */
$categoryList = $driver->getCategories(null, $categories);
if ($categoryList->count() == 0) {
$GLOBALS['cli']->message(_('Could not find the requested categories'), 'cli.error');
exit;
}
$properties = array();
foreach ($categoryList as $category) {
foreach ($category->properties as $property) {
$properties[] = $property;
}
print $category->hasRelation('properties', $properties[0]);
}
$cli->message($name, 'cli.success');
function usage()
{
$GLOBALS['cli']->writeln('Usage: sesha-add-stock "name" "category" "description" "prop1:val1,prop2:val2"');
exit;
}
php-horde-sesha-1.0.0~beta1/sesha-1.0.0beta1/config/ 0000775 0000000 0000000 00000000000 12061431535 0021531 5 ustar 00root root 0000000 0000000 php-horde-sesha-1.0.0~beta1/sesha-1.0.0beta1/config/conf.xml 0000664 0000000 0000000 00000003374 12061431535 0023207 0 ustar 00root root 0000000 0000000
Storage System Settingsrdo
Data Typesint, text, boolean, creditcard, cellphone, client, date, dblookup, description, email, enum, file, header, hourminutesecond, html, image, intlist, ipaddress, link, longtext, matrix, mlenum, monthdayyear, monthyear, multienum, number, obrowser, octal, password, radio, set, timeTicketsfalseClientsnameMenu settingstrue
php-horde-sesha-1.0.0~beta1/sesha-1.0.0beta1/config/prefs.php 0000664 0000000 0000000 00000004340 12061431535 0023362 0 ustar 00root root 0000000 0000000 _("General Options"),
'label' => _("Display Options"),
'desc' => _("Change your inventory sorting and display options."),
'members' => array('sortby', 'sortdir', 'list_properties', 'sesha_default_view')
);
// user preferred sorting column
$_prefs['sortby'] = array(
'value' => Sesha::SORT_STOCKID,
'locked' => false,
'type' => 'enum',
'enum' => array(Sesha::SORT_STOCKID => _("Stock ID"),
Sesha::SORT_NAME => _("Item Name"),
Sesha::SORT_NOTE => _("Note")),
'desc' => _("Default sorting criteria:")
);
// user preferred sorting direction
$_prefs['sortdir'] = array(
'value' => Sesha::SORT_ASCEND,
'locked' => false,
'type' => 'enum',
'enum' => array(Sesha::SORT_ASCEND => _("Ascending"),
Sesha::SORT_DESCEND => _("Descending")),
'desc' => _("Default sorting direction:")
);
// default view
$_prefs['sesha_default_view'] = array(
'value' => 'list',
'locked' => false,
'type' => 'enum',
'enum' => array(
'list' => _("List"),
'search' => _("Search"),
'stock' => _("Stock")
),
'desc' => _("Select the view to display after login:")
);
// properties to show in lists
$_prefs['list_properties'] = array(
'value' => array(),
'locked' => false,
'type' => 'multienum',
'enum' => array(),
'desc' => _("Select properties that you would like to see in the list view. All other properties are only shown on individual item screens:")
);
$sesha_driver = $GLOBALS['injector']->getInstance('Sesha_Factory_Driver')->create();
foreach ($sesha_driver->getProperties() as $property) {
$_prefs['list_properties']['enum'][$property['property_id']] = $property['property'];
}
php-horde-sesha-1.0.0~beta1/sesha-1.0.0beta1/docs/ 0000775 0000000 0000000 00000000000 12061431535 0021214 5 ustar 00root root 0000000 0000000 php-horde-sesha-1.0.0~beta1/sesha-1.0.0beta1/docs/CHANGES 0000664 0000000 0000000 00000003002 12061431535 0022202 0 ustar 00root root 0000000 0000000 -----------
v1.0.0beta1
-----------
[rla] Use Horde 5's CSS for sidebar icons.
[rla] Use Horde 5's New button for the Add Stock menu entry.
------------
v1.0.0alpha1
------------
[rla] Use Horde_View in place of Horde_Template.
[rla] Change backend from Sql driver to Rdo driver with enhanced search
capabilities.
[jan] Add Finnish translation (Leena Heino ).
[rla] Convert to Horde 5 Framework.
[jan] Add Latvian translation (Jānis Eisaks).
[cjh] Add sort priorities to categories.
[cjh] Add a preference for showing properties on the Stock List.
[jan] Add Spanish translation (Manuel Perez Ayala ).
[cjh] Separate permission to add stock from general admin permissions
(Manilal K M ).
[jan] Add configuration for address book field used for the client listings.
(Request #3816).
[jan] Remove default categories (vilius@lnk.lt, Request #3430).
[ben] Better support for MS-SQL.
[jan] Add support for dynamic re-sorting of the stock inventory, including
saving the sort preferences on any changes.
[jan] Allow set local administrators through permission interface
(rbreiddal@presinet.com, Request #2523).
[jan] Provide queues (categories) and versions (stock items) for Whups.
[jan] Add interface to set any additional parameters that some data types need.
[mas] Change any output of and tags to and for better
accessibility support.
[jan] Add Lithuanian translation (Vilius Sumskas ).
php-horde-sesha-1.0.0~beta1/sesha-1.0.0beta1/docs/CREDITS 0000664 0000000 0000000 00000001360 12061431535 0022234 0 ustar 00root root 0000000 0000000 ========================
Sesha Development Team
========================
Core Developers
===============
- Jan Schneider
- Ralf Lang
Localization
============
===================== ===============================================
Finnish Leena Heino
Latvian Jānis Eisaks
Lithuanian Vilius Šumskas
Spanish Manuel Perez Ayala
Juan C. Blanco
===================== ===============================================
Inactive Developers
===================
- Bo Daley
- Andrew Coleman
php-horde-sesha-1.0.0~beta1/sesha-1.0.0beta1/docs/INSTALL 0000664 0000000 0000000 00000013335 12061431535 0022252 0 ustar 00root root 0000000 0000000 ======================
Installing Sesha 1.0
======================
:Contact: horde@lists.horde.org
.. contents:: Contents
.. section-numbering::
This document contains instructions for installing the Sesha web-based
inventory application on your system.
For information on the capabilities and features of Sesha, see the file
README_ in the top-level directory of the Sesha distribution.
Prerequisites
=============
To function properly, Sesha **requires** the following:
1. A working Horde installation.
Sesha runs within the `Horde Application Framework`_, a set of common
tools for Web applications written in PHP. You must install Horde before
installing Sesha.
.. Important:: Sesha 1.0 requires version 5.0+ of the Horde Framework -
earlier versions of Horde will **not** work.
.. Important:: Be sure to have completed all of the steps in the
`horde/docs/INSTALL`_ file for the Horde Framework before
installing Sesha. Many of Sesha's prerequisites are
also Horde prerequisites. Additionally, many of Sesha's
optional features are configured via the Horde install.
.. _`Horde Application Framework`: http://www.horde.org/apps/horde
2. SQL support in PHP
Sesha stores its data in a backend - currently only SQL database is
supported.
Build PHP with whichever SQL driver you require; see the Horde
`horde/docs/INSTALL`_ file for more details on using databases with Horde.
Installing Sesha
================
The **RECOMMENDED** way to install Sesha is using the PEAR installer.
Alternatively, if you want to run the latest development code or get the
latest not yet released fixes, you can install Sesha from Git.
Installing with PEAR
~~~~~~~~~~~~~~~~~~~~
First follow the instructions in `horde/docs/INSTALL`_ to prepare a PEAR
environment for Horde and install the Horde Framework.
When installing Sesha through PEAR now, the installer will automatically
install any dependencies of Sesha too. If you want to install Sesha
with all optional dependencies, but without the binary PECL packages that need
to be compiled, specify both the ``-a`` and the ``-B`` flag::
pear install -a -B horde/sesha-alpha
By default, only the required dependencies will be installed::
pear install horde/sesha-alpha
If you want to install Sesha even with all binary dependencies, you need to
remove the ``-B`` flag. Please note that this might also try to install PHP
extensions through PECL that might need further configuration or activation in
your PHP configuration::
pear install -a horde/sesha-alpha
Installing from Git
~~~~~~~~~~~~~~~~~~~
See http://www.horde.org/source/git.php
Configuring Sesha
=====================
1. Configuring Horde for Sesha
Sesha requires an SQL backend for the Rdo storage driver. If you didn't
setup an SQL backend yet, go to the configuration interface, select Horde
from the list of applications and select the ``Database`` tab.
2. Configuring Sesha
You must login to Horde as a Horde Administrator to finish the configuration
of Sesha. Use the Horde ``Administration`` menu item to get to the
administration page, and then click on the ``Configuration`` icon to get the
configuration page. Select ``Inventory`` from the selection list of
applications. Fill in or change any configuration values as needed. When
done click on ``Generate Inventory Configuration`` to generate the
``conf.php`` file. If your web server doesn't have write permissions to the
Sesha configuration directory or file, it will not be able to write the
file. In this case, go back to ``Configuration`` and choose one of the
other methods to create the configuration file ``sesha/config/conf.php``.
Documentation on the format and purpose of the other configuration files in
the ``config/`` directory can be found in each file. You may create
``*.local.php`` versions of these files if you wish to customize Sesha's
appearance and behavior. See the header of the configuration files for
details and examples. The defaults will be correct for most sites.
3. Creating the database tables
Once you finished the configuration in the previous step, you can create all
database tables by clicking the ``DB schema is out of date.`` link in the
Sesha row of the configuration screen.
Alternatively creating the Sesha database tables can be accomplished with
Horde's ``horde-db-migrate`` utility. If your database is properly setup in
the Horde configuration, just run the following::
horde/bin/horde-db-migrate sesha
4. Testing Sesha
Use Sesha to create, modify, and delete categories and stock. Test at least
the following:
- Creating a new property
- Creating an inventory category
- Creating an inventory stock item
- Modifying an item
- Deleting an item
Obtaining Support
=================
If you encounter problems with Sesha, help is available!
The Horde Frequently Asked Questions List (FAQ), available on the Web at
http://wiki.horde.org/FAQ
The Horde Project runs a number of mailing lists, for individual applications
and for issues relating to the project as a whole. Information, archives, and
subscription information can be found at
http://www.horde.org/community/mail
Lastly, Horde developers, contributors and users may also be found on IRC,
on the channel #horde on the Freenode Network (irc.freenode.net).
Please keep in mind that Sesha is free software written by volunteers.
For information on reasonable support expectations, please read
http://www.horde.org/community/support
Thanks for using Sesha!
The Horde team
.. _README: README
.. _`horde/docs/INSTALL`: ../../horde/docs/INSTALL
.. _`horde/docs/TRANSLATIONS`: ../../horde/docs/TRANSLATIONS
php-horde-sesha-1.0.0~beta1/sesha-1.0.0beta1/docs/RELEASE_NOTES 0000664 0000000 0000000 00000003212 12061431535 0023165 0 ustar 00root root 0000000 0000000 notes['fm']['focus'] = array(Horde_Release::FOCUS_MINORFEATURE);
/* Mailing list release notes. */
$this->notes['ml']['changes'] = <<notes['fm']['changes'] = <<notes['name'] = 'Sesha';
$this->notes['list'] = 'horde';
$this->notes['fm']['project'] = 'sesha';
$this->notes['fm']['branch'] = 'Horde 5';
php-horde-sesha-1.0.0~beta1/sesha-1.0.0beta1/docs/TODO 0000664 0000000 0000000 00000002361 12061431535 0021706 0 ustar 00root root 0000000 0000000 Sesha is mostly complete, especially for just keeping track of inventory.
Here is an incomplete list of features that would be cool to have.
* Remember previous category after editing a stock item
* Search by Property Names, not just values
* Implement API for adding, updating & getting properties for items in inventory
* Add a few new Horde_Form_Types like IP address and Turba contact so that all i
of the previous functionality from Sesha is present in this version.
* More help(?)
* Maybe a better summary that will include a set of user-defined properties to
show (probably will lag too much to implement)
* Add another data field to allow an item to be purchased or not (or another
table all together)
* Add a field allowing user to indicate how many of an item are in stock.
* Consider crossover of this app with Merk (shopping cart)
These are not set in stone, but if Sesha is going to be used to keep up with a
*store's* inventory, these features would be nice to have. If it is nothing
more than to keep track of a few things that are lying around, Sesha is
already set to rock and roll.
Cheers,
Coleman
mercury [at] appisolutions [dot] net
* Horde 5 Ajax view
* Utilisation of the Rdo driver's enhanced search capabilities
Ralf Lang php-horde-sesha-1.0.0~beta1/sesha-1.0.0beta1/index.php 0000664 0000000 0000000 00000001003 12061431535 0022076 0 ustar 00root root 0000000 0000000
* Copyright 2011 Horde LLC
* @author Ralf Lang
*
* See the enclosed file COPYING for license information (GPL). If you
* did not receive this file, see http://www.horde.org/licenses/gpl.
*/
require_once __DIR__ . '/lib/Application.php';
Horde_Registry::appInit('sesha');
require basename($prefs->getValue('sesha_default_view') . '.php');
php-horde-sesha-1.0.0~beta1/sesha-1.0.0beta1/lib/ 0000775 0000000 0000000 00000000000 12061431535 0021032 5 ustar 00root root 0000000 0000000 php-horde-sesha-1.0.0~beta1/sesha-1.0.0beta1/lib/Api.php 0000664 0000000 0000000 00000006356 12061431535 0022266 0 ustar 00root root 0000000 0000000
* @package Sesha
*/
class Sesha_Api extends Horde_Registry_Api
{
/**
* List categories as ticket queues
* @return array a list of ticket queues with category id as key and category caption as value
*/
public function listQueues()
{
$queues = array();
$categories = $GLOBALS['backend']->getCategories();
foreach ($categories as $category) {
$queues[$category->category_id] = $category->category;
}
asort($queues);
return $queues;
}
/**
* Get a queueDetails hash for a queue (category)
* @param integer $queue_id The Queue for which to build the details hash
* @return array A hash of category id as id, category label as name, category description as description, a link, a list of subjects as configured
*/
public function getQueueDetails($queue_id)
{
global $registry;
$category = $GLOBALS['backend']->getCategory($queue_id);
return array('id' => $queue_id,
'name' => $category->category,
'description' => $category->description,
'link' => Horde_Util::addParameter(Horde::applicationUrl('list.php', true), 'display_category', $queue_id - 1, false),
'subjectlist' => $GLOBALS['conf']['tickets']['subjects'],
'versioned' => $registry->hasMethod('tickets/listVersions') == $registry->getApp(),
'readonly' => true);
}
/**
* List Stock items as versions for a queue (category)
* @param integer $queue_id The category id (queue) for which we want to fetch versions
* @return array A hash containing stock id as id, stock name as name, stock note as description
*/
public function listVersions($queue_id)
{
$inventory = $GLOBALS['backend']->findStock(array('categories' => $queue_id));
$versions = array();
foreach ($inventory as $item) {
$versions[] = array('id' => $item->stock_id,
'name' => $item->stock_name,
'description' => $item->note,
'readonly' => true);
}
Horde_Array::arraySort($versions, 'name', 0, false);
return $versions;
}
/**
* return a version details hash by version id
* @param integer $version_id The ID of the stock item to display as a version
* @return array The version hash containing stock name as name, stock note as description and a link
*/
public function getVersionDetails($version_id)
{
$item = $GLOBALS['backend']->fetch($version_id);
return array('id' => $version_id,
'name' => $item->stock_name,
'description' => $item->note,
'link' => Horde_Util::addParameter(Horde::applicationUrl('stock.php', true), array('stock_id' => $version_id, 'actionId' => 'view_stock'), null, false),
'readonly' => true);
}
}
php-horde-sesha-1.0.0~beta1/sesha-1.0.0beta1/lib/Application.php 0000664 0000000 0000000 00000004430 12061431535 0024007 0 ustar 00root root 0000000 0000000 array(
'title' => _("Administration"),
),
'addStock' => array(
'title' => _("Add Stock")
)
);
return $permissions;
}
/**
* Sesha's application specific sidebar menu
* In earlier horde versions, this was a top menu
* Client pages amend and output this via Sesha::menu
* @param Horde_Menu $menu A menu object
*/
public function menu($menu)
{
global $conf, $injector;
$menu->add(Horde::url('list.php'), _("_List Stock"), 'sesha-list', null, null, null, basename($_SERVER['PHP_SELF']) == 'index.php' ? 'current' : null);
/* Search. */
$menu->add(Horde::url('search.php'), _("_Search"), 'sesha-search');
if (Sesha::isAdmin(Horde_Perms::READ)|| $perms->hasPermission('sesha:addStock', $GLOBALS['registry']->getAuth(), Horde_Perms::READ)) {
$menu->add(Horde::url('admin.php'), _("Administration"), 'sesha-admin');
}
}
}
php-horde-sesha-1.0.0~beta1/sesha-1.0.0beta1/lib/Driver.php 0000664 0000000 0000000 00000021421 12061431535 0022776 0 ustar 00root root 0000000 0000000
* Copyright 2011-2012 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (GPL). If you
* did not receive this file, see http://www.horde.org/licenses/gpl.
*
* @author Andrew Coleman
* @author Ralf Lang
* @package Sesha
*/
abstract class Sesha_Driver
{
protected $_params;
/**
* Variable holding the items in the inventory.
*
* @var array
*/
protected $_stock;
public function __construct($params = array())
{
$this->_params = $params;
}
/**
* This function retrieves a single stock item from the backend.
*
* @param integer $stock_id The numeric ID of the stock item to fetch.
*
* @return Sesha_Entity_Stock a stock item
* @throws Sesha_Exception
*/
abstract public function fetch($stock_id);
/**
* Removes a stock entry from the backend. Also removes all related
* category and property information.
*
* @param integer $stock_id The ID of the item to delete.
*
* @return boolean True on success
* @throws Sesha_Exception
*
*/
abstract public function delete($stock_id);
/**
* This will add a new item to the inventory.
*
* @param array $stock A hash of values for the stock item.
*
* @return Sesha_Entity_Stock The newly added item or false.
* @throws Sesha_Exception
*/
abstract public function add($stock);
/**
* This function will modify a pre-existing stock entry with new values.
*
* @param array $stock The hash of values for the inventory item.
*
* @return boolean True on success.
* @throws Sesha_Exception
*/
abstract public function modify($stock_id, $stock);
/**
* This will return the category found matching a specific id.
*
* @param integer|array $category_id The integer ID or key => value hash of the category to find.
*
* @return Sesha_Entity_Category The category on success
*/
abstract public function getCategory($category_id);
/**
* This function returns all the categories matching an id or category list.
*
* @param integer $stock_id The stock ID of categories to fetch.
* Overrides category_ids
* @param integer $category_ids The numeric IDs of the categories to find.
* If both $stock_id and $category_ids are null,
* all categories are returned
* @return array The list of matching categories
*/
abstract public function getCategories($stock_id = null, array $category_ids = null);
/**
* This will find all the available properties matching a specified IDs.
*
* @param array $property_ids The numeric ID of properties to find.
* Matches all properties when null.
*
* @return array matching properties on success
* @throws Sesha_Exception
*/
abstract public function getProperties($property_ids = array());
/**
* Finds the first matching property for a specified property ID.
*
* @param integer $property_id The numeric ID of properties to find.
*
* @return mixed The specified property on success
* @throws Sesha_Exception
*/
abstract public function getProperty($property_id);
/**
* Updates the attributes stored by a category.
*
* @param array $info Updated category attributes.
*
* @return integer Number of objects updated.
* @throws Sesha_Exception
*/
abstract public function updateCategory($info);
/**
* Adds a new category for classifying inventory.
*
* @param array $info The new category's attributes.
*
* @return integer The ID of the new of the category on success
* @throws Sesha_Exception
*/
abstract public function addCategory($info);
/**
* Deletes a category.
*
* @param integer $category_id The numeric ID of the category to delete. Also accepts Sesha_Entity_Category
*
* @return integer The number of categories deleted
*/
abstract public function deleteCategory($category_id);
/**
* Determines if a category exists in the storage backend.
*
* @param string $category The string representation of the category to
* find.
*
* @return boolean True on success; false otherwise.
*/
abstract public function categoryExists($category);
/**
* Updates a property with new attributes.
*
* @param array $info Array with updated property values.
*
* @return Sesha_Inventory_Property The changed Sesha_Inventory_Property object.
*/
abstract public function updateProperty(array $info);
/**
* Adds a new property to the storage backend.
*
* @param array $info Array with new property values.
*
* @return Sesha_Entity_Property
*/
abstract public function addProperty($info);
/**
* Deletes a property from the storage backend.
*
* @param integer $property_id The numeric ID of the property to delete. Also accepts a Sesha_Inventory_Property object
*
* @return integer Number of objects deleted.
*/
abstract public function deleteProperty($property_id);
/**
* This will return a set of properties for a set of specified categories.
*
* @param array $categories The set of categories to fetch properties.
*
* @return mixed An array of properties on success
* @throws Sesha_Exception
*/
abstract public function getPropertiesForCategories($categories = array());
/**
* Updates a category with a set of properties.
*
* @param integer $category_id The numeric ID of the category to update.
* @param array $properties An array of property ID's to add.
*
* @throws Sesha_Exception
*/
abstract public function setPropertiesForCategory($category_id, $properties = array());
/**
* Removes all properties for a specified category.
*
* @param integer $category_id The numeric ID of the category to update.
*
* @return integer The number of deleted properties
* @throws Sesha_Exception
*/
abstract public function clearPropertiesForCategory($category_id);
/**
* Returns a set of properties for a particular stock ID number.
*
* @param integer $stock_id The numeric ID of the stock to find the
* properties for.
*
* @return array of Sesha_Inventory_Property objects
* @throws Sesha_Exception
*/
abstract public function getPropertiesForStock($stock_id);
/**
* Returns a set of Value Objects for a particular stock ID number.
*
* @param integer $stock_id The numeric ID of the stock to find the
* properties for.
* You can also pass a Sesha_Entity_Stock item
*
* @return array the list of Sesha_Entity_Value objects
* @throws Sesha_Exception
*/
abstract public function getValuesForStock($stock_id);
/**
* Removes categories from a particular stock item.
*
* @param integer $stock_id The numeric ID of the stock item to update.
* @param array $categories The array of categories to remove.
*
* @return integer the number of categories removed
* @throws Sesha_Exception
*/
abstract public function clearPropertiesForStock($stock_id, $categories = array());
/**
* Updates the set of properties for a particular stock item.
*
* @param integer $stock_id The numeric ID of the stock to update.
* @param array $properties The hash of properties to update.
*
* @throws Sesha_Exception
*/
abstract public function updatePropertiesForStock($stock_id, $properties = array());
/**
* Updates the set of categories for a specified stock item.
*
* @param integer $stock_id The numeric stock ID to update.
* @param array $categories The array of categories to change.
*
*/
abstract public function updateCategoriesForStock($stock_id, $categories = array());
/**
* Inventory search
* @param array filters a list of filter hashes, each having keys
* string type ('note', 'stock_name', 'stock_id', 'categories', 'properties')
* string test
* mixed value (string fore note, stock_name)
* @return array List of Stock items
*/
abstract public function findStock($filters = array());
}
php-horde-sesha-1.0.0~beta1/sesha-1.0.0beta1/lib/Driver/ 0000775 0000000 0000000 00000000000 12061431535 0022265 5 ustar 00root root 0000000 0000000 php-horde-sesha-1.0.0~beta1/sesha-1.0.0beta1/lib/Driver/Rdo.php 0000664 0000000 0000000 00000050515 12061431535 0023530 0 ustar 00root root 0000000 0000000
* 'db' The Horde_Db adapter
*
* Copyright 2003-2012 Horde LLC (http://www.horde.org/)
* Based on the original Sql driver
* Copyright 2004-2007 Andrew Coleman
*
* See the enclosed file COPYING for license information (GPL). If you
* did not receive this file, see http://www.horde.org/licenses/gpl.
*
* @author Bo Daley
* @author Andrew Coleman
* @author Ralf Lang
* @package Sesha
*/
class Sesha_Driver_Rdo extends Sesha_Driver
{
/**
* Handle for the database connection.
* @var DB
* @access protected
*/
protected $_db;
/**
* The mapper factory
* @var Horde_Rdo_Factory
* @access protected
*/
protected $_mappers;
/**
* This is the basic constructor for the Rdo driver.
*
* @param array $params Hash containing the connection parameters.
*/
public function __construct($params = array())
{
$this->_db = $params['db'];
$this->_mappers = new Horde_Rdo_Factory($this->_db);
}
/**
* This function retrieves a single stock item from the database.
*
* @param integer $stock_id The numeric ID of the stock item to fetch.
*
* @return Sesha_Entity_Stock a stock item
* @throws Sesha_Exception
*/
public function fetch($stock_id)
{
$sm = $this->_mappers->create('Sesha_Entity_StockMapper');
return $sm->findOne($stock_id);
}
/**
* Removes a stock entry from the database. Also removes all related
* category and property information.
*
* @param integer $stock_id The ID of the item to delete.
*
* @return boolean True on success
* @throws Sesha_Exception
*
*/
public function delete($stock_id)
{
$sm = $this->_mappers->create('Sesha_Entity_StockMapper');
return $sm->delete($stock_id);
}
/**
* This will add a new item to the inventory.
*
* @param array $stock A hash of values for the stock item.
*
* @return Sesha_Entity_Stock The newly added item or false.
* @throws Sesha_Exception
*/
public function add($stock)
{
$sm = $this->_mappers->create('Sesha_Entity_StockMapper');
return $sm->create($stock);
}
/**
* This function will modify a pre-existing stock entry with new values.
*
* @param array $stock The hash of values for the inventory item.
*
* @return boolean True on success.
* @throws Sesha_Exception
*/
public function modify($stock_id, $stock)
{
$sm = $this->_mappers->create('Sesha_Entity_StockMapper');
return $sm->update($stock_id, $stock);
}
/**
* This will return the category found matching a specific id.
*
* @param integer|array $category_id The integer ID or key => value hash of the category to find.
*
* @return Sesha_Entity_Category The category on success
*/
public function getCategory($category_id)
{
return $this->_mappers->create('Sesha_Entity_CategoryMapper')->findOne($category_id);
}
/**
* This function returns all the categories matching an id or category list.
*
* @param integer $stock_id The stock ID of categories to fetch.
* Overrides category_ids
* @param integer $category_ids The numeric IDs of the categories to find.
* If both $stock_id and $category_ids are null,
* all categories are returned
* @return array The list of matching categories
*/
public function getCategories($stock_id = null, array $category_ids = null)
{
$cm = $this->_mappers->create('Sesha_Entity_CategoryMapper');
if ((int)$stock_id > 0) {
$sm = $this->_mappers->create('Sesha_Entity_StockMapper');
$stock = $sm->findOne($stock_id);
return $stock->categories;
} elseif (is_int($category_ids)) {
return $cm->find($category_ids);
}
elseif (is_array($category_ids)) {
$query = new Horde_Rdo_Query($cm);
$query->addTest('category_id', 'IN', $category_ids);
return $cm->find($query);
} else {
return iterator_to_array($cm->find(), true);
}
}
/**
* This will find all the available properties matching a specified IDs.
*
* @param array $property_ids The numeric ID of properties to find.
* Matches all properties when null.
*
* @return array matching properties on success
* @throws Sesha_Exception
*/
public function getProperties($property_ids = array())
{
$pm = $this->_mappers->create('Sesha_Entity_PropertyMapper');
if (empty($property_ids)) {
return iterator_to_array($pm->find());
}
$query = new Horde_Rdo_Query($pm);
$query->addTest('property_id', 'IN', $property_ids);
return iterator_to_array($pm->find($query));
}
/**
* Finds the first matching property for a specified property ID.
*
* @param integer $property_id The numeric ID of properties to find.
*
* @return mixed The specified property on success
* @throws Sesha_Exception
*/
public function getProperty($property_id)
{
$result = $this->getProperties(array($property_id));
return array_shift($result);
}
/**
* Updates the attributes stored by a category.
*
* @param array $info Updated category attributes.
*
* @return integer Number of objects updated.
* @throws Sesha_Exception
*/
public function updateCategory($info)
{
$cm = $this->_mappers->create('Sesha_Entity_CategoryMapper');
return $cm->update($info['category_id'], $info);
}
/**
* Adds a new category for classifying inventory.
*
* @param array $info The new category's attributes.
*
* @return Sesha_Entity_Category The category on success
* @throws Sesha_Exception
*/
public function addCategory($info)
{
$cm = $this->_mappers->create('Sesha_Entity_CategoryMapper');
return $cm->create($info);
}
/**
* Deletes a category.
*
* @param integer $category_id The numeric ID of the category to delete. Also accepts Sesha_Entity_Category
*
* @return integer The number of categories deleted
*/
public function deleteCategory($category_id)
{
$cm = $this->_mappers->create('Sesha_Entity_CategoryMapper');
if ($category_id instanceof Sesha_Inventory_Category) {
$category = $category_id;
$category_id = $category->category_id;
} else {
$category = $cm->findOne($category_id);
}
if (empty($category)) throw new Sesha_Exception(sprintf(_('The category %d could not be found', $category_id)));
return $category->delete();
}
/**
* Determines if a category exists in the storage backend.
*
* @param string $category The string representation of the category to
* find.
*
* @return boolean True on success; false otherwise.
*/
public function categoryExists($category)
{
$cm = $this->_mappers->create('Sesha_Entity_CategoryMapper');
if ($category instanceof Sesha_Inventory_Category) {
$category = $category->category;
}
return (boolean) $cm->findOne(array('category' => $category));
}
/**
* Updates a property with new attributes.
*
* @param array $info Array with updated property values.
*
* @return Sesha_Inventory_Property The changed Sesha_Inventory_Property object.
*/
public function updateProperty(array $info)
{
$pm = $this->_mappers->create('Sesha_Entity_PropertyMapper');
$property = $pm->findOne($info['property_id']);
if (empty($property)) throw new Sesha_Exception(sprintf(_('The property %d could not be loaded', $info['property_id'])));
$property->property = $info['property'];
$property->datatype = $info['datatype'];
$property->parameters = $info['parameters'];
$property->unit = $info['unit'];
$property->description = $info['description'];
$property->priority = $info['priority'];
$property->save();
return $property;
}
/**
* Adds a new property to the storage backend.
*
* @param array $info Array with new property values.
*
* @return Sesha_Entity_Property
*/
public function addProperty($info)
{
$pm = $this->_mappers->create('Sesha_Entity_PropertyMapper');
$property = $pm->create($info);
return $property;
}
/**
* Deletes a property from the storage backend.
*
* @param integer $property_id The numeric ID of the property to delete. Also accepts a Sesha_Inventory_Property object
*
* @return integer Number of objects deleted.
*/
public function deleteProperty($property_id)
{
$pm = $this->_mappers->create('Sesha_Entity_PropertyMapper');
if ($property_id instanceof Sesha_Inventory_Property) {
$property = $property_id;
$property_id = $property->property_id;
} else {
$property = $pm->findOne($property_id);
}
if (empty($property)) throw new Sesha_Exception(sprintf(_('The property %d could not be found', $property_id)));
return $property->delete();
}
/**
* This will return a set of properties for a set of specified categories.
*
* @param array $categories The set of categories to fetch properties.
*
* @return mixed An array of properties on success
* @throws Sesha_Exception
*/
public function getPropertiesForCategories($categories = array())
{
$properties = array();
foreach ($categories as $category) {
if (!($category instanceof Sesha_Entity_Category)) {
$cm = $this->_mappers->create('Sesha_Entity_CategoryMapper');
$category = $cm->findOne($category);
}
foreach ($category->properties as $property) {
$properties[$property->property_id] = $property;
}
}
return $properties;
}
/**
* Updates a category with a set of properties.
*
* @param integer $category_id The numeric ID of the category to update.
* @param array $properties An array of property ID's to add.
*
* @throws Sesha_Exception
*/
public function setPropertiesForCategory($category_id, $properties = array())
{
$cm = $this->_mappers->create('Sesha_Entity_CategoryMapper');
if ($category_id instanceof Sesha_Entity_Category) {
$category = $category_id;
} else {
$category = $cm->findOne($category_id);
}
$pm = $this->_mappers->create('Sesha_Entity_PropertyMapper');
$this->clearPropertiesForCategory($category);
foreach ($properties as $property) {
if (!($property instanceof Sesha_Entity_Property)) {
$property = $pm->findOne($property);
$category->addRelation('properties', $property);
}
}
}
/**
* Removes all properties for a specified category.
*
* @param integer $category_id The numeric ID of the category to update.
*
* @return integer The number of deleted properties
* @throws Sesha_Exception
*/
public function clearPropertiesForCategory($category_id)
{
$cm = $this->_mappers->create('Sesha_Entity_CategoryMapper');
if ($category_id instanceof Sesha_Entity_Category) {
$category = $category_id;
} else {
$category = $cm->findOne($category_id);
}
return $category->removeRelation('properties');
}
/**
* Returns a set of properties for a particular stock ID number.
*
* @param integer $stock_id The numeric ID of the stock to find the
* properties for.
*
* @return array of Sesha_Inventory_Property objects
* @throws Sesha_Exception
*/
public function getPropertiesForStock($stock_id)
{
if (($stock_id instanceof Sesha_Entity_Stock)) {
$stock = $stock_id;
$stock_id = $stock->stock_id;
} else {
$sm = $this->_mappers->create('Sesha_Entity_StockMapper');
$stock = $sm->findOne($stock_id);
}
return $this->getPropertiesForCategories($stock->categories);
}
/**
* Returns a set of Value Objects for a particular stock ID number.
*
* @param integer $stock_id The numeric ID of the stock to find the
* properties for.
* You can also pass a Sesha_Entity_Stock item
*
* @return array the list of Sesha_Entity_Value objects
* @throws Sesha_Exception
*/
public function getValuesForStock($stock_id)
{
if (($stock_id instanceof Sesha_Entity_Stock)) {
$stock = $stock_id;
$stock_id = $stock->stock_id;
} else {
$sm = $this->_mappers->create('Sesha_Entity_StockMapper');
$stock = $sm->findOne($stock_id);
}
return iterator_to_array($stock->values);
}
/**
* Removes categories from a particular stock item.
*
* @param integer $stock_id The numeric ID of the stock item to update.
* @param array $categories The array of categories to remove.
*
* @return integer the number of categories removed
* @throws Sesha_Exception
*/
public function clearPropertiesForStock($stock_id, $categories = array())
{
if ($stock_id instanceof Sesha_Entity_Stock) {
$stock_id = $stock_id->stock_id;
}
if (!is_array($categories)) {
$categories = array(0 => array('category_id' => $categories));
}
/* Get list of properties for this set of categories. */
try {
$properties = $this->getPropertiesForCategories($categories);
} catch (Horde_Db_Exception $e) {
throw new Sesha_Exception($e);
}
$vm = $this->_mappers->create('Sesha_Entity_ValueMapper');
$query = Horde_Rdo_Query::create(array('stock_id' => $stock_id), $vm);
$query->addTest(array(
'field' => 'property_id',
'test' => 'IN',
'value' => array_keys($properties)
)
);
$count = 0;
foreach ($vm->find($query) as $value) {
$value->delete();
$count++;
}
return $count;
}
/**
* Updates the set of properties for a particular stock item.
*
* @param integer $stock_id The numeric ID of the stock to update.
* @param array $properties The hash of properties to update.
*
* @throws Sesha_Exception
*/
public function updatePropertiesForStock($stock_id, $properties = array())
{
if ($stock_id instanceof Sesha_Entity_Stock) {
$stock_id = $stock_id->stock_id;
}
$vm = $this->_mappers->create('Sesha_Entity_ValueMapper');
foreach ($properties as $property_id => $property_value) {
$value = $vm->findOne(array('stock_id' => $stock_id, 'property_id' => $property_id));
if (!$value) {
$value = $vm->create(array('stock_id' => $stock_id, 'property_id' => $property_id));
}
$value->setDataValue($property_value);
$value->save();
}
}
/**
* Updates the set of categories for a specified stock item.
*
* @param integer $stock_id The numeric stock ID to update.
* @param array $categories The array of categories to change.
*
*/
public function updateCategoriesForStock($stock_id, $categories = array())
{
$sm = $this->_mappers->create('Sesha_Entity_StockMapper');
$cm = $this->_mappers->create('Sesha_Entity_CategoryMapper');
if (!is_array($categories)) {
$categories = array($categories);
}
if (($stock_id instanceof Sesha_Entity_Stock)) {
$stock = $stock_id;
$stock_id = $stock->stock_id;
} else {
$stock = $sm->findOne($stock_id);
}
/* First clear any categories that might be set for this item. */
$stock->removeRelation('categories');
foreach ($categories as $category) {
if (!($category instanceof Sesha_Entity_Category)) {
$category = $cm->findOne($category);
}
$stock->addRelation('categories', $category);
}
}
/**
* Inventory search
* @param array filters a list of filter hashes, each having keys
* string type ('note', 'stock_name', 'stock_id', 'categories', 'values')
* string test
* mixed value (string for note, stock_name)
* For the 'values' structure, value, value is a map of [values] and optional [property]}
* @return array List of Stock items
*/
public function findStock($filters = array())
{
$sm = $this->_mappers->create('Sesha_Entity_StockMapper');
if (empty($filters)) {
return iterator_to_array($sm->find());
}
$query = new Horde_Rdo_Query($sm);
foreach ($filters as $filter) {
switch ($filter['type']) {
case 'note':
case 'stock_name':
case 'stock_id':
$test = array(
'field' => $filter['type'],
'test' => $filter['test'] ? $filter['test'] : 'IN',
'value' => is_array($filter['value']) ? $filter['value'] : array($filter['value'])
);
$query->addTest($test['field'], $test['test'], $test['value']);
break;
case 'categories':
$cm = $this->_mappers->create('Sesha_Entity_CategoryMapper');
$categories = is_array($filter['value']) ? $filter['value'] : array($filter['value']);
$items = array();
foreach ($categories as $category) {
if ($category instanceof Sesha_Entity_Category) {
$category_id = $category->category_id;
} else {
$category_id = $category;
$category = $cm->findOne($category_id);
}
foreach ($category->stock as $item) {
/* prevent duplicates when an item has several categories */
$items[$item->stock_id] = $item;
}
}
if (count($filters == 1)) {
return $items;
}
$query->addTest('stock_id',$filter['test'] ? $filter['test'] : 'IN', array_keys($items));
break;
case 'values':
$vm = $this->_mappers->create('Sesha_Entity_ValueMapper');
$items = array();
foreach ($filter['value'] as $propTest) {
$values = is_array($propTest['values']) ? $propTest['values'] : array($propTest['values']);
$valueQuery = new Horde_Rdo_Query($vm);
if ($propTest['property']) {
$valueQuery->addTest('property_id', '=', $propTest['property']);
}
$valueQuery->addTest('txt_datavalue', 'IN', $values);
foreach ($vm->find($valueQuery) as $value) {
$items[$value->stock_id] = $value->stock;
}
}
if (count($filters == 1)) {
return $items;
}
$query->addTest('stock_id',$filter['test'] ? $filter['test'] : 'IN', array_keys($items));
break;
}
}
return iterator_to_array($sm->find($query));
}
}
php-horde-sesha-1.0.0~beta1/sesha-1.0.0beta1/lib/Entity/ 0000775 0000000 0000000 00000000000 12061431535 0022306 5 ustar 00root root 0000000 0000000 php-horde-sesha-1.0.0~beta1/sesha-1.0.0beta1/lib/Entity/Category.php 0000664 0000000 0000000 00000000076 12061431535 0024577 0 ustar 00root root 0000000 0000000
* @category Horde
* @package Sesha
* @license http://www.horde.org/licenses/gpl GPL
*/
/**
* The Sesha_Entity_CategoryMapper class contains all functions related to handling
* category mapping in Sesha.
*
* Copyright 2012-2012 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (GPL). If you
* did not receive this file, see http://www.horde.org/licenses/gpl.
*
* @author Ralf Lang
* @category Horde
* @package Sesha
* @license http://www.horde.org/licenses/gpl GPL
*/
class Sesha_Entity_CategoryMapper extends Horde_Rdo_Mapper
{
/**
* Inflector doesn't support Horde-style tables yet
* @var string
* @access protected
*/
protected $_table = 'sesha_categories';
/**
* Relationships loaded on-demand
* @var array
* @access protected
*/
protected $_lazyRelationships = array(
'properties' => array('type' => Horde_Rdo::MANY_TO_MANY,
'mapper' => 'Sesha_Entity_PropertyMapper',
'through' => 'sesha_relations'),
'stock' => array('type' => Horde_Rdo::MANY_TO_MANY,
'mapper' => 'Sesha_Entity_StockMapper',
'through' => 'sesha_inventory_categories')
);
}
php-horde-sesha-1.0.0~beta1/sesha-1.0.0beta1/lib/Entity/Property.php 0000664 0000000 0000000 00000001766 12061431535 0024655 0 ustar 00root root 0000000 0000000 _fields['parameters']);
}
/**
* Explicit setter for the parameters variable interface.
* Internalizes the (un)serialization of the parameters array for backend storage
* returns mixed
*/
public function setParameters($parameters)
{
return $this->_fields['parameters'] = serialize($parameters);
}
/**
* Save any changes to the backend.
* Overridden because the default save() method passes the external representation to backend, not the serialized representation
* @return boolean Success.
*/
public function save()
{
return $this->getMapper()->update($this->property_id, $this->_fields) == 1;
}
}
php-horde-sesha-1.0.0~beta1/sesha-1.0.0beta1/lib/Entity/PropertyMapper.php 0000664 0000000 0000000 00000007661 12061431535 0026022 0 ustar 00root root 0000000 0000000
* @category Horde
* @package Sesha
* @license http://www.horde.org/licenses/gpl GPL
*/
/**
* The Sesha_Entity_PropertyMapper class contains all functions related to handling
* property mapping in Sesha.
*
* Copyright 2012-2012 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (GPL). If you
* did not receive this file, see http://www.horde.org/licenses/gpl.
*
* @author Ralf Lang
* @category Horde
* @package Sesha
* @license http://www.horde.org/licenses/gpl GPL
*/
class Sesha_Entity_PropertyMapper extends Horde_Rdo_Mapper
{
/**
* Inflector doesn't support Horde-style tables yet
* @var string
* @access protected
*/
protected $_table = 'sesha_properties';
/**
* Relationships loaded on-demand
* @var array
* @access protected
*/
protected $_lazyRelationships = array(
'categories' => array('type' => Horde_Rdo::MANY_TO_MANY,
'mapper' => 'Sesha_Entity_CategoryMapper',
'through' => 'sesha_relations'),
'values' => array('type' => Horde_Rdo::ONE_TO_MANY,
'mapper' => 'Sesha_Entity_ValueMapper',
'foreignKey' => 'property_id',
),
);
/**
* Creates a property definition in the backend.
* This wraps folding of the 'parameters' structure
*
* @param array $property An array with the property definition.
* Keys may be
* property_id Integer (autogenerated)
* property string The property name
* datatype string The property type
* parameters mixed Type definition parameters will be serialized
* unit string The unit to display
* description string
* priority integer
*
* @return Sesha_Entity_Property The property created.
*/
public function create(array $property)
{
if (!is_string($property['parameters'])) {
$property['parameters'] = serialize($property['parameters']);
}
return parent::create($property);
}
/**
* Updates a record in the backend. $object can be either a
* primary key or an Rdo object. If $object is an Rdo instance
* then $fields will be ignored as values will be pulled from the
* object.
*
* @param string|Rdo $object The Rdo instance or unique id to update.
* @param array $fields If passing a unique id, the array of field properties
* to set for $object.
*
* @return integer Number of objects updated.
*/
/**
* Deletes a property definition from the backend. $object can be either a
* primary key, an Rdo_Query object, or a Sesha_Entity_Property object.
* This also cleans up attachment attributes of this property type and category links
*
* @param string|Sesha_Entity_Property|Horde_Rdo_Query $object The Rdo object,
* Horde_Rdo_Query, or unique id to delete.
*
* @return integer Number of objects deleted.
*/
public function delete($object)
{
if (!($object instanceof Sesha_Entity_Property)) {
$object = $this->findOne($object);
}
foreach ($object->values as $value) {
$value->delete();
}
$object->removeRelation('categories');
return parent::delete($object);
}
}
php-horde-sesha-1.0.0~beta1/sesha-1.0.0beta1/lib/Entity/Stock.php 0000664 0000000 0000000 00000001165 12061431535 0024105 0 ustar 00root root 0000000 0000000 _mapper->factory->create('Sesha_Entity_ValueMapper');
return $am->findOne(array(
'stock_id' => $this->stock_id,
'property_id' => $property instanceof Sesha_Entity_Property ? $property->property_id : $property
)
);
}
}
php-horde-sesha-1.0.0~beta1/sesha-1.0.0beta1/lib/Entity/StockMapper.php 0000664 0000000 0000000 00000004610 12061431535 0025250 0 ustar 00root root 0000000 0000000
* @category Horde
* @package Sesha
* @license http://www.horde.org/licenses/gpl GPL
*/
/**
* The Sesha_Entity_StockMapper class contains all functions related to handling
* stock mapping in Sesha.
*
* Copyright 2012-2012 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (GPL). If you
* did not receive this file, see http://www.horde.org/licenses/gpl.
*
* @author Ralf Lang
* @category Horde
* @package Sesha
* @license http://www.horde.org/licenses/gpl GPL
*/
class Sesha_Entity_StockMapper extends Horde_Rdo_Mapper
{
/**
* Inflector doesn't support Horde-style tables yet
* @var string
* @access protected
*/
protected $_table = 'sesha_inventory';
/**
* Relationships loaded on-demand
* @var array
* @access protected
*/
protected $_lazyRelationships = array(
'categories' => array('type' => Horde_Rdo::MANY_TO_MANY,
'mapper' => 'Sesha_Entity_CategoryMapper',
'through' => 'sesha_inventory_categories'),
'values' => array('type' => Horde_Rdo::ONE_TO_MANY,
'mapper' => 'Sesha_Entity_ValueMapper',
'foreignKey' => 'stock_id',
),
);
/**
* Deletes a stock item from the backend. $object can be either a
* primary key, an Rdo_Query object, or a Sesha_Entity_Stock object.
* This also cleans up attached attributes and categories
*
* @param string|Sesha_Entity_Stock|Horde_Rdo_Query $object The Rdo object,
* Horde_Rdo_Query, or unique id to delete.
*
* @return integer Number of objects deleted.
*/
public function delete($object)
{
if (!($object instanceof Sesha_Entity_Stock)) {
$object = $this->findOne($object);
}
foreach ($object->values as $value) {
$value->delete();
}
$object->removeRelation('categories');
return parent::delete($object);
}
}
php-horde-sesha-1.0.0~beta1/sesha-1.0.0beta1/lib/Entity/Value.php 0000664 0000000 0000000 00000001312 12061431535 0024070 0 ustar 00root root 0000000 0000000
* @category Horde
* @package Sesha
*/
class Sesha_Entity_Value extends Horde_Rdo_Base
{
/**
* Retrieve the txt_datavalue or int_datavalue depending on context
*/
public function getDataValue()
{
return $this->txt_datavalue;
}
/**
* Save the txt_datavalue or int_datavalue depending on context
*/
public function setDataValue($value)
{
return $this->txt_datavalue = $value;
}
}
php-horde-sesha-1.0.0~beta1/sesha-1.0.0beta1/lib/Entity/ValueMapper.php 0000664 0000000 0000000 00000003345 12061431535 0025245 0 ustar 00root root 0000000 0000000
* @category Horde
* @package Sesha
* @license http://www.horde.org/licenses/gpl GPL
*/
/**
* The Sesha_Entity_ValueMapper class contains all functions related to handling
* a property's value for a specific stock item in Sesha.
*
* Copyright 2012-2012 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (GPL). If you
* did not receive this file, see http://www.horde.org/licenses/gpl.
*
* @author Ralf Lang
* @category Horde
* @package Sesha
* @license http://www.horde.org/licenses/gpl GPL
*/
class Sesha_Entity_ValueMapper extends Horde_Rdo_Mapper
{
/**
* Inflector doesn't support Horde-style tables yet
* @var string
* @access protected
*/
protected $_table = 'sesha_inventory_properties';
/**
* Relationships loaded on-demand
* @var array
* @access protected
*/
protected $_lazyRelationships = array(
'stock' => array(
'type' => Horde_Rdo::ONE_TO_ONE,
'foreignKey' => 'stock_id',
'mapper' => 'Sesha_Entity_StockMapper'
),
'property' => array(
'type' => Horde_Rdo::ONE_TO_ONE,
'foreignKey' => 'property_id',
'mapper' => 'Sesha_Entity_PropertyMapper'
),
);
}
php-horde-sesha-1.0.0~beta1/sesha-1.0.0beta1/lib/Exception.php 0000664 0000000 0000000 00000000516 12061431535 0023503 0 ustar 00root root 0000000 0000000 _instances[$name])) {
if (!empty($params['driver'])) {
$driver = $params['driver'];
unset($params['driver']);
} else {
$driver = $GLOBALS['conf']['storage']['driver'];
$params = Horde::getDriverConfig('storage', $driver);
}
$class = 'Sesha_Driver_' . ucfirst(basename($driver));
if (!class_exists($class)) {
throw new Sesha_Exception(sprintf('Unable to load the definition of %s.', $class));
}
switch ($class) {
case 'Sesha_Driver_Rdo':
if (empty($params['db'])) {
$params['db'] = $this->_injector->getInstance('Horde_Core_Factory_Db')->create('sesha', $params);
}
break;
}
$this->_instances[$name] = new $class($params);
}
return $this->_instances[$name];
}
}
php-horde-sesha-1.0.0~beta1/sesha-1.0.0beta1/lib/Form/ 0000775 0000000 0000000 00000000000 12061431535 0021735 5 ustar 00root root 0000000 0000000 php-horde-sesha-1.0.0~beta1/sesha-1.0.0beta1/lib/Form/Category.php 0000664 0000000 0000000 00000005051 12061431535 0024224 0 ustar 00root root 0000000 0000000
* @package Sesha
*/
class Sesha_Form_Category extends Horde_Form
{
public function __construct($vars)
{
parent::__construct($vars);
// This is probably wrong. The library should get the driver
// or the properties passed
$sesha_driver = $GLOBALS['injector']->getInstance('Sesha_Factory_Driver')->create();
$this->appendButtons(_("Save Category"));
$category_id = $vars->get('category_id');
$priorities = array();
for ($i = 0; $i < 100; $i++) {
$priorities[] = $i;
}
try {
$allproperties = $sesha_driver->getProperties();
}
catch (Sesha_Exception $e) {
throw new Sesha_Exception($e);
}
$a = array();
foreach ($allproperties as $p) {
$a[$p['property_id']] = $p['property'];
}
if (!empty($category_id)) {
try {
$properties = $sesha_driver->getPropertiesForCategories($category_id);
} catch (Sesha_Exception $e) {
throw new Sesha_Exception($e);
}
$current = array();
foreach ($properties as $s) {
$current[$s['property_id']] = $s['property'];
}
}
$this->addHidden('', 'actionID', 'text', false, false, null);
$this->addHidden('', 'category_id', 'text', false, false, null);
$this->addHidden('', 'submitbutton', 'text', false, false, null);
$this->addVariable(_("Category Name"), 'category', 'text', true);
$this->addVariable(_("Description"), 'description', 'longtext', false);
$this->addVariable(_("Sort Weight"), 'priority', 'enum', false, false, _("When categories are displayed, they will be shown in weight order from highest to lowest"), array($priorities));
if (!count($a)) {
$fieldtype = 'invalid';
$a = _("No properties are currently configured. Use the \"Manage Properties\" tab above to add some.");
} else {
$fieldtype = 'multienum';
}
$mp = &$this->addVariable(_("Properties"), 'properties', $fieldtype, true, false, null, array($a));
if (!empty($current)) {
$mp->setDefault(array_keys($current));
}
$action = Horde_Form_Action::factory('submit');
}
}
php-horde-sesha-1.0.0~beta1/sesha-1.0.0beta1/lib/Form/CategoryDelete.php 0000664 0000000 0000000 00000001557 12061431535 0025356 0 ustar 00root root 0000000 0000000
* @package Sesha
*/
class Sesha_Form_CategoryDelete extends Horde_Form {
public function __construct($vars)
{
parent::__construct($vars);
$this->appendButtons(_("Delete Category"));
$params = array('yes' => _("Yes"),
'no' => _("No"));
$desc = _("Really delete this category?");
$this->addHidden('', 'actionID', 'text', false, false, null, array('delete_category'));
$this->addHidden('', 'category_id', 'text', false, false, null);
$this->addVariable(_("Confirm"), 'confirm', 'enum', true, false, $desc, array($params));
}
}
php-horde-sesha-1.0.0~beta1/sesha-1.0.0beta1/lib/Form/CategoryList.php 0000664 0000000 0000000 00000002655 12061431535 0025067 0 ustar 00root root 0000000 0000000
* @package Sesha
*/
class Sesha_Form_CategoryList extends Horde_Form {
public function __construct($vars)
{
parent::__construct($vars);
// This is probably wrong. The library should get the driver
// or the properties passed
$sesha_driver = $GLOBALS['injector']->getInstance('Sesha_Factory_Driver')->create();
$this->setButtons(array(_("Edit Category"),
_("Delete Category")));
$categories = $sesha_driver->getCategories();
$params = array();
foreach ($categories as $category) {
$params[$category->category_id] = $category->category;
}
$title = !empty($title) ? $title : _("Edit a category");
$this->setTitle($title);
$this->addHidden('', 'actionID', 'text', false, false, null, array('edit_category'));
if (!count($params)) {
$fieldtype = 'invalid';
$params = _("No categories are currently configured. Use the form below to add one.");
} else {
$fieldtype = 'enum';
}
$this->addVariable(_("Category"), 'category_id', $fieldtype, true, false, null, array($params));
}
}
php-horde-sesha-1.0.0~beta1/sesha-1.0.0beta1/lib/Form/Property.php 0000664 0000000 0000000 00000012546 12061431535 0024302 0 ustar 00root root 0000000 0000000
* @package Sesha
*/
class Sesha_Form_Property extends Horde_Form
{
public function __construct($vars)
{
parent::__construct($vars);
$this->appendButtons(_("Save Property"));
$types = array();
$datatypes = $GLOBALS['conf']['datatypes']['types'];
foreach ($datatypes as $d) {
$types[$d] = $d;
}
$priorities = array();
for ($i = 0; $i < 100; $i++) {
$priorities[] = $i;
}
$this->addHidden('', 'actionID', 'text', false, false, null);
$this->addHidden('', 'property_id', 'text', false, false, null);
$this->addVariable(_("Property Name"), 'property', 'text', true);
$action = Horde_Form_Action::factory('submit');
$v = $this->addVariable(_("Data Type"), 'datatype', 'enum', true, false, null, array($types, true));
$v->setAction($action);
$v->setOption('trackchange', true);
$this->addVariable(_("Unit"), 'unit', 'text', false);
$this->addVariable(_("Description"), 'description', 'longtext', false);
$this->addVariable(_("Sort Weight"), 'priority', 'enum', false, false, _("When properties are displayed, they will be shown in weight order from highest to lowest"), array($priorities));
}
/**
* Validates the form, checking if it really has been submitted by calling
* isSubmitted() and if true does any onSubmit() calls for variable types
* in the form. The _submitted variable is then rechecked.
*
* @param Variables $vars A Variables instance, optional since Horde
* 3.2.
* @param boolean $canAutofill Can the form be valid without being
* submitted?
*
* @return boolean True if the form is valid.
*/
public function validate($vars, $canAutoFill = false)
{
$this->_addParameters($vars);
return parent::validate($vars, $canAutoFill);
}
/**
* Renders the form for editing.
*
* @param Horde_Form_Renderer $renderer A renderer instance, optional
* since Horde 3.2.
* @param Variables $vars A Variables instance, optional
* since Horde 3.2.
* @param string $action The form action (url).
* @param string $method The form method, usually either
* 'get' or 'post'.
* @param string $enctype The form encoding type. Determined
* automatically if null.
* @param boolean $focus Focus the first form field?
*/
public function renderActive($renderer, $vars, $action, $method = 'get', $enctype = null, $focus = true)
{
if ($vars->get('old_datatype') === null) {
$this->_addParameters($vars);
}
parent::renderActive($renderer, $vars, $action, $method, $enctype, $focus);
}
protected function _addParameters($vars)
{
$dataType = $vars->get('datatype');
$className = $this->_buildTypeClassname($dataType);
if (empty($dataType)) {
// Noop.
} elseif (!$className) {
$GLOBALS['notification']->push(sprintf(_("The form field type \"%s\" doesn't exist."), $dataType), 'horde.error');
} else {
$params = call_user_func(array($className, 'about'));
if (isset($params['params'])) {
foreach ($params['params'] as $name => $param) {
$field_id = 'parameters[' . $name . ']';
$param['required'] = isset($param['required'])
? $param['required']
: null;
$param['readonly'] = isset($param['readonly'])
? $param['readonly']
: null;
$param['desc'] = isset($param['desc'])
? $param['desc']
: null;
$this->insertVariableBefore('unit', $param['label'],
$field_id, $param['type'],
$param['required'],
$param['readonly'],
$param['desc']);
$vars->set('old_datatype', $dataType);
}
}
}
}
/**
* Helper method to build either h3 style class names as seen in Horde_Form_Type_ccc
* or autoloadable class names used in Sesha
*
* @param string $dataType The type identifier to turn into a class name
*
* @return string A class name or an empty string
*
*/
protected function _buildTypeClassname($dataType)
{
if (class_exists('Horde_Form_Type_' . $dataType)) {
return 'Horde_Form_Type_' . $dataType;
} elseif (class_exists('Sesha_Form_Type_' . ucfirst($dataType))) {
return 'Sesha_Form_Type_' . ucfirst($dataType);
} else {
return '';
}
}
}
php-horde-sesha-1.0.0~beta1/sesha-1.0.0beta1/lib/Form/PropertyDelete.php 0000664 0000000 0000000 00000001556 12061431535 0025424 0 ustar 00root root 0000000 0000000
* @package Sesha
*/
class Sesha_Form_PropertyDelete extends Horde_Form
{
public function __construct($vars)
{
parent::__construct($vars);
$this->appendButtons(_("Delete Property"));
$params = array('yes' => _("Yes"),
'no' => _("No"));
$desc = _("Really delete this property?");
$this->addHidden('', 'actionID', 'text', false, false, null, array('delete_property'));
$this->addHidden('', 'property_id', 'text', false, false, null);
$this->addVariable(_("Confirm"), 'confirm', 'enum', true, false, $desc, array($params));
}
}
php-horde-sesha-1.0.0~beta1/sesha-1.0.0beta1/lib/Form/PropertyList.php 0000664 0000000 0000000 00000002621 12061431535 0025127 0 ustar 00root root 0000000 0000000
* @package Sesha
*/
class Sesha_Form_PropertyList extends Horde_Form
{
public function __construct($vars)
{
parent::Horde_Form($vars);
// This is probably wrong. The library should get the driver
// or the properties passed
$sesha_driver = $GLOBALS['injector']->getInstance('Sesha_Factory_Driver')->create();
$this->setButtons(array(_("Edit Property"), _("Delete Property")));
$properties = $sesha_driver->getProperties();
$params = array();
foreach ($properties as $property) {
$params[$property['property_id']] = $property['property'];
}
$title = !empty($title) ? $title : _("Edit a property");
$this->setTitle($title);
$this->addHidden('', 'actionID', 'text', false, false, null, array('edit_property'));
if (!count($params)) {
$fieldtype = 'invalid';
$params = _("No properties are currently configured. Use the form below to add one.");
} else {
$fieldtype = 'enum';
}
$this->addVariable(_("Property"), 'property_id', $fieldtype, true, false, null, array($params));
}
}
php-horde-sesha-1.0.0~beta1/sesha-1.0.0beta1/lib/Form/Search.php 0000664 0000000 0000000 00000002430 12061431535 0023652 0 ustar 00root root 0000000 0000000
* Copyright 2004-2011 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (GPL). If you
* did not receive this file, see http://www.horde.org/licenses/gpl.
*
* @author Andrew Coleman
* @package Sesha
*/
class Sesha_Form_Search extends Horde_Form {
/**
* Basic constructor for the SearchForm.
*
* @param Horde_Variables $vars The default variables to use.
*/
public function __construct($vars)
{
parent::__construct($vars, _("Search The Inventory"));
$this->appendButtons(_("Search"));
$this->addHidden('', 'actionId', 'text', true);
$this->addVariable(_("Search these properties"), 'location', 'multienum', true,
false, null, array(array(
Sesha::SEARCH_ID => _("Stock ID"),
Sesha::SEARCH_NAME => _("Item Name"),
Sesha::SEARCH_NOTE => _("Item Note"),
Sesha::SEARCH_PROPERTY => _("Property Value"))));
$this->addVariable(_("For this value"), 'criteria', 'text', true);
}
}
php-horde-sesha-1.0.0~beta1/sesha-1.0.0beta1/lib/Form/Stock.php 0000664 0000000 0000000 00000007751 12061431535 0023543 0 ustar 00root root 0000000 0000000
* Copyright 2004-2011 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (GPL). If you
* did not receive this file, see http://www.horde.org/licenses/gpl.
*
* @author Andrew Coleman
* @since Sesha 1
* @package Sesha
*/
class Sesha_Form_Stock extends Horde_Form {
/**
* The default constructor for the StockForm class.
*
* @param Horde_Variables $vars The default variables to use.
*/
public function __construct($vars)
{
parent::__construct($vars);
$sesha_driver = $GLOBALS['injector']->getInstance('Sesha_Factory_Driver')->create();
// Buttons and hidden configuration
$this->setButtons(_("Save Item"));
$this->addHidden('', 'actionId', 'text', true);
// Prepare the categories
$cat = array();
$categories = $sesha_driver->getCategories();
foreach ($categories as $c) {
$cat[$c->category_id] = $c->category;
}
// Get the list of selected categories
$categoryIds = array();
$t = $vars->get('category_id');
if (!is_array($t)) {
$t = array($t);
}
$categoryIds = array_merge($categoryIds, $t);
// The stock ID should only be editable if you are adding a new item;
// otherwise let the user know what the stock_id is, and then make a
// read-only required hidden variable
if ($vars->get('actionId') == 'add_stock') {
$this->addVariable(_("Stock ID"), 'stock_id', 'int', false, false);
} else {
$this->addVariable(_("Stock ID"), 'stock_id', 'int', false, true);
$this->addHidden('', 'stock_id', 'int', true, true);
}
// Basic variables for any stock item
$this->addVariable(_("Name"), 'stock_name', 'text', false, false);
if (!count($cat)) {
$fieldtype = 'invalid';
$cat = _("No categories are currently configured. Click \"Administration\" on the left to add some.");
} else {
$fieldtype = 'multienum';
}
$categoryVar = $this->addVariable(_("Category"), 'category_id',
$fieldtype, true, false, null,
array($cat));
// Set the variables already stored in the Driver, if applicable
try {
$properties = $sesha_driver->getPropertiesForCategories($categoryIds);
} catch (Sesha_Exception $e) {
throw new Sesha_Exception($e);
}
foreach ($properties as $property) {
$fieldname = 'property[' . $property->property_id . ']';
$fieldtitle = $property->property;
$fielddesc = $property->description;
if (!empty($property->unit)) {
if (!empty($fielddesc)) {
$fielddesc .= ' -- ';
}
$fielddesc .= _("Unit: ") . $property->unit;
}
$fieldtype = $property->datatype;
$fieldparams = array();
if (is_array($property->parameters)) {
$fieldparams = $property->parameters;
if (in_array($fieldtype, array('link', 'enum', 'multienum', 'mlenum', 'radio', 'set', 'sorter'))) {
$fieldparams->values = Sesha::getStringlistArray($fieldparams->values);
}
}
$this->addVariable($fieldtitle, $fieldname, $fieldtype,
false, false, $fielddesc, $fieldparams);
}
$this->addVariable(_("Note"), 'note', 'longtext', false);
// Default action
$action = Horde_Form_Action::factory('submit');
$categoryVar->setAction($action);
$categoryVar->setOption('trackchange', true);
}
}
php-horde-sesha-1.0.0~beta1/sesha-1.0.0beta1/lib/Form/Type/ 0000775 0000000 0000000 00000000000 12061431535 0022656 5 ustar 00root root 0000000 0000000 php-horde-sesha-1.0.0~beta1/sesha-1.0.0beta1/lib/Form/Type/Client.php 0000664 0000000 0000000 00000003016 12061431535 0024605 0 ustar 00root root 0000000 0000000
* Copyright 2004-2011 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (GPL). If you
* did not receive this file, see http://www.horde.org/licenses/gpl.
*
* @author Andrew Coleman
* @since Sesha 1
* @package Sesha
*/
class Sesha_Form_Type_Client extends Horde_Form_Type_enum {
public function init($values = null, $prompt = null)
{
global $conf, $registry;
// Get list of clients, if available.
if ($registry->hasMethod('clients/getClientSource')) {
$source = $registry->call('clients/getClientSource');
if (!empty($source)) {
$results = $registry->call('clients/searchClients', array(array('')));
$clientlist = $results[''];
$clients = array();
foreach ($clientlist as $client) {
$key = isset($client['id']) ? $client['id'] : $client['__key'];
$clients[$key] = isset($client[$conf['client']['field']]) ? $client[$conf['client']['field']] : '';
}
asort($clients);
parent::init($clients);
}
}
}
/**
* Return info about field type.
*/
public function about()
{
$about = array();
$about['name'] = _("Client");
return $about;
}
}
php-horde-sesha-1.0.0~beta1/sesha-1.0.0beta1/lib/Sesha.php 0000664 0000000 0000000 00000014551 12061431535 0022614 0 ustar 00root root 0000000 0000000
* Copyright 2007-2012 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (GPL). If you
* did not receive this file, see http://www.horde.org/licenses/gpl.
*
* @author Andrew Coleman
* @package Sesha
*/
class Sesha
{
/** Sort by stock id. */
const SORT_STOCKID = 100;
/** Sort by stock name. */
const SORT_NAME = 101;
/** Sort by stock note. */
const SORT_NOTE = 102;
/** Sort in ascending order. */
const SORT_ASCEND = 0;
/** Sort in descending order. */
const SORT_DESCEND = 1;
// Search Field Constants
const SEARCH_ID = 1;
const SEARCH_NAME = 2;
const SEARCH_NOTE = 4;
const SEARCH_PROPERTY = 8;
/**
* This function will return the list of available categories.
*
* @return mixed Array of categories on success; PEAR_Error on failure.
*/
public function listCategories()
{
$sesha_driver = $GLOBALS['injector']->getInstance('Sesha_Factory_Driver')->create();
return $sesha_driver->getCategories();
}
/**
* Returns a Hord_Form_Type_stringlist value split to an array.
*
* @param string $string A comma separated string list.
*
* @return array The string list as an array.
*/
public function getStringlistArray($string)
{
$string = str_replace("'", "\'", $string);
$values = explode(',', $string);
foreach ($values as $value) {
$value = trim($value);
$value_array[$value] = $value;
}
return $value_array;
}
/**
* Comparison function for sorting inventory stock by id.
*
* @param array $a Item one.
* @param array $b Item two.
*
* @return integer 1 if item one is greater, -1 if item two is greater;
* 0 if they are equal.
*/
protected function _sortByStockID($a, $b)
{
if ($a['stock_id'] == $b['stock_id']) return 0;
return ($a['stock_id'] > $b['stock_id']) ? 1 : -1;
}
/**
* Comparison function for reverse sorting stock by id.
*
* @param array $a Item one.
* @param array $b Item two.
*
* @return integer -1 if item one is greater, 1 if item two is greater;
* 0 if they are equal.
*/
protected function _rsortByStockID($a, $b)
{
if ($a['stock_id'] == $b['stock_id']) return 0;
return ($a['stock_id'] > $b['stock_id']) ? -1 : 1;
}
/**
* Comparison function for sorting inventory stock by name.
*
* @param array $a Item one.
* @param array $b Item two.
*
* @return integer 1 if item one is greater, -1 if item two is greater;
* 0 if they are equal.
*/
protected function _sortByName($a, $b)
{
if ($a['stock_name'] == $b['stock_name']) return 0;
return ($a['stock_name'] > $b['stock_name']) ? 1 : -1;
}
/**
* Comparison function for reverse sorting stock by name.
*
* @param array $a Item one.
* @param array $b Item two.
*
* @return integer -1 if item one is greater, 1 if item two is greater;
* 0 if they are equal.
*/
protected function _rsortByName($a, $b)
{
if ($a['stock_name'] == $b['stock_name']) return 0;
return ($a['stock_name'] > $b['stock_name']) ? -1 : 1;
}
/**
* Comparison function for sorting inventory stock by a property.
*
* @param array $a Item one.
* @param array $b Item two.
*
* @return integer 1 if item one is greater, -1 if item two is greater;
* 0 if they are equal.
*/
protected function _sortByProperty($a, $b)
{
if ($a[$GLOBALS['_sort_property']] == $b[$GLOBALS['_sort_property']]) return 0;
return ($a[$GLOBALS['_sort_property']] > $b[$GLOBALS['_sort_property']]) ? 1 : -1;
}
/**
* Comparison function for reverse sorting stock by a property.
*
* @param array $a Item one.
* @param array $b Item two.
*
* @return integer -1 if item one is greater, 1 if item two is greater;
* 0 if they are equal.
*/
protected function _rsortByProperty($a, $b)
{
if ($a[$GLOBALS['_sort_property']] == $b[$GLOBALS['_sort_property']]) return 0;
return ($a[$GLOBALS['_sort_property']] > $b[$GLOBALS['_sort_property']]) ? -1 : 1;
}
/**
* Comparison function for sorting inventory stock by note.
*
* @param array $a Item one.
* @param array $b Item two.
*
* @return integer 1 if item one is greater, -1 if item two is greater;
* 0 if they are equal.
*/
protected function _sortByNote($a, $b)
{
if ($a['note'] == $b['note']) return 0;
return ($a['note'] > $b['note']) ? 1 : -1;
}
/**
* Comparison function for reverse sorting stock by note.
*
* @param array $a Item one.
* @param array $b Item two.
*
* @return integer -1 if item one is greater, 1 if item two is greater;
* 0 if they are equal.
*/
protected function _rsortByNote($a, $b)
{
if ($a['note'] == $b['note']) return 0;
return ($a['note'] > $b['note']) ? -1 : 1;
}
/**
* Amend Sesha's list of menu items with a new button and generate output.
*/
public static function menu()
{
$sidebar = Horde::menu(array('menu_ob' => true))->render();
$perms = $GLOBALS['injector']->getInstance('Horde_Core_Perms');
if (Sesha::isAdmin(Horde_Perms::READ) ||
$perms->hasPermission('sesha:addStock', $GLOBALS['registry']->getAuth(), Horde_Perms::READ)) {
$sidebar->addNewButton(
_("_Add Stock"),
Horde::url('stock.php')->add('actionId', 'add_stock'));
}
Horde::startBuffer();
return $GLOBALS['injector']->getInstance('Horde_View_Topbar')->render()
. $sidebar . Horde::endBuffer();
}
public static function isAdmin($permLevel = Horde_Perms::DELETE)
{
return ($GLOBALS['registry']->isAdmin() || $GLOBALS['injector']->getInstance('Horde_Perms')->hasPermission('sesha:admin', $GLOBALS['registry']->getAuth(), $permLevel));
}
}
php-horde-sesha-1.0.0~beta1/sesha-1.0.0beta1/lib/Ui/ 0000775 0000000 0000000 00000000000 12061431535 0021407 5 ustar 00root root 0000000 0000000 php-horde-sesha-1.0.0~beta1/sesha-1.0.0beta1/lib/Ui/VarRenderer/ 0000775 0000000 0000000 00000000000 12061431535 0023626 5 ustar 00root root 0000000 0000000 php-horde-sesha-1.0.0~beta1/sesha-1.0.0beta1/lib/Ui/VarRenderer/Stockedit_Html.php 0000664 0000000 0000000 00000000774 12061431535 0027264 0 ustar 00root root 0000000 0000000
* @package Sesha
*/
class Horde_Core_UI_VarRenderer_Stockedit_Html extends Horde_Core_Ui_VarRenderer_Html {
protected function _renderVarInput_client($form, $var, $vars)
{
return $this->_renderVarInput_enum($form, $var, $vars);
}
}
php-horde-sesha-1.0.0~beta1/sesha-1.0.0beta1/lib/View/ 0000775 0000000 0000000 00000000000 12061431535 0021744 5 ustar 00root root 0000000 0000000 php-horde-sesha-1.0.0~beta1/sesha-1.0.0beta1/lib/View/Base.php 0000664 0000000 0000000 00000001772 12061431535 0023336 0 ustar 00root root 0000000 0000000
* @category Horde
* @package Sesha
* @license http://www.horde.org/licenses/gpl GPL
*/
/**
* The Sesha_View_Base class contains all functions shared among
* views in Sesha.
*
* Copyright 2012-2012 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (GPL). If you
* did not receive this file, see http://www.horde.org/licenses/gpl.
*
* @author Ralf Lang
* @category Horde
* @package Sesha
* @license http://www.horde.org/licenses/gpl GPL
*/
class Sesha_View_Base extends Horde_View
{
/**
* The page title
* @var string
* @access public
*/
public $title = '';
}
php-horde-sesha-1.0.0~beta1/sesha-1.0.0beta1/lib/View/List.php 0000664 0000000 0000000 00000020450 12061431535 0023371 0 ustar 00root root 0000000 0000000
* @category Horde
* @package Sesha
* @license http://www.horde.org/licenses/gpl GPL
*/
class Sesha_View_List extends Sesha_View_Base
{
public function __construct(array $config)
{
if (!is_null($what) && !is_null($where)) {
$title = _("Search Inventory");
$this->header = _("Matching Inventory");
} else {
$this->header = $category_id
? sprintf(_("Available Inventory in %s"),
$selectedCategory->category)
: _("Available Inventory");
}
$this->title = _("Inventory List");
$this->selectedCategories = is_array($config['selectedCategories'])
? $config['selectedCategories']
: array($config['selectedCategories']);
if (empty($this->selectedCategories[0])) {
array_shift($this->selectedCategories);
}
$this->shownProperties = $this->properties($config['propertyIds']);
$this->columnHeaders = $this->columnHeaders($config['sortDir'],
$config['sortBy']);
$filters = array();
if (!empty($this->selectedCategories)) {
$filters[] = array('type' => 'categories',
'value' => $this->selectedCategories);
}
if (in_array(Sesha::SEARCH_ID, $config['loc'])) {
$filters[] = array('type' => 'stock_id',
'value' => $config['what']);
}
if (in_array(Sesha::SEARCH_NAME, $config['loc'])) {
$filters[] = array('type' => 'stock_name',
'value' => $config['what']);
}
if (in_array(Sesha::SEARCH_NOTE, $config['loc'])) {
$filters[] = array('type' => 'note',
'value' => $config['what']);
}
if (in_array(Sesha::SEARCH_PROPERTY, $config['loc'])) {
$filters[] = array(
'type' => 'values',
'value' => array(array('values' => array($config['what']))));
}
$this->shownStock = $this->stock($filters);
parent::__construct($config);
}
/**
* Retrieves all categories from driver.
*
* @return array List of Sesha_Entity_Category objects.
*/
public function allCategories()
{
return Sesha::listCategories();
}
/**
* Builds column header array out of the list of properties and default
* attributes.
*/
protected function columnHeaders($sortDir, $sortBy)
{
$prefs_url = Horde::url($GLOBALS['registry']->get('webroot', 'horde') . '/services/prefs/', true);
$sortdirclass = $sortDir ? 'sortup' : 'sortdown';
$baseurl = Horde::url('list.php');
$column_headers = array(
array('id' => 's' . Sesha::SORT_STOCKID,
'class' => $sortBy == Sesha::SORT_STOCKID ? ' class="' . $sortdirclass . '"' : '',
'link' => Horde::link(Horde_Util::addParameter($baseurl, 'sortby', Sesha::SORT_STOCKID), _("Sort by stock ID"), 'sortlink') . _("Stock ID") . '',
'width' => ' width="5%"'),
array('id' => 's' . Sesha::SORT_NAME,
'class' => $sortBy == Sesha::SORT_NAME ? ' class="' . $sortdirclass . '"' : '',
'link' => Horde::link(Horde_Util::addParameter($baseurl, 'sortby', Sesha::SORT_NAME), _("Sort by item name"), 'sortlink') . _("Item Name") . '',
'width' => '')
);
foreach ($this->shownProperties as $property) {
$column_headers[] = array(
'id' => 'sp' . $property->property_id,
'class' => $sortBy == 'p' . $property->property_id ? ' class="' . $sortdirclass . '"' : '',
'link' => Horde::link(Horde_Util::addParameter($baseurl, 'sortby', 'p' . $property->property_id), sprintf(_("Sort by %s"), htmlspecialchars($property->property)), 'sortlink') . htmlspecialchars($property->property) . '',
'width' => '',
);
}
$column_headers[] = array(
'id' => 's' . Sesha::SORT_NOTE,
'class' => $sortby == Sesha::SORT_NOTE ? ' class="' . $sortdirclass . '"' : '',
'link' => Horde::link(Horde_Util::addParameter($baseurl, 'sortby', Sesha::SORT_NOTE), _("Sort by note"), 'sortlink') . _("Note") . '',
'width' => '',
);
return $column_headers;
}
/**
* Returns the list of property objects to display.
*/
protected function properties($propertyIds = array())
{
if (empty($propertyIds)) {
/* The driver understands an empty filter as "all" but if none are
* selected, we want none. */
return array();
}
try {
return $GLOBALS['injector']
->getInstance('Sesha_Factory_Driver')
->create()
->getProperties($propertyIds);
} catch (Sesha_Exception $e) {
return array();
}
}
/**
* Returns the items which match the category or search criteria.
*/
protected function stock($filters = array())
{
$driver = $GLOBALS['injector']
->getInstance('Sesha_Factory_Driver')
->create();
// Get the inventory
$stock = $driver->findStock($filters);
$isAdminEdit = Sesha::isAdmin(Horde_Perms::EDIT);
$itemEditImg = Horde::img('edit.png', _("Edit Item"));
$isAdminDelete = Sesha::isAdmin(Horde_Perms::DELETE);
$adminDeleteImg = Horde::img('delete.png', _("Delete Item"));
$stock_url = Horde::url('stock.php');
foreach ($stock as $item) {
$url = $stock_url->add('stock_id', $item->stock_id);
$columns = array();
// icons
$icons = '';
if ($isAdminEdit) {
$icons .= $url->copy()
->add('actionId', 'update_stock')
->link(array('title' => _("Edit Item")))
. $itemEditImg . '';
}
if ($isAdminDelete) {
$icons .= $url->copy()
->add('actionId', 'remove_stock')
->link(array('title' => _("Delete Item")))
. $adminDeleteImg . '';
}
$columns[] = array('class' => ' class="nowrap"',
'column' => $icons);
// stock_id
$columns[] = array(
'class' => '',
'column' => $url->copy()
->add('actionId', 'view_stock')
->link(array('title' => _("View Item")))
. htmlspecialchars($item->stock_id) . '');
// name
$columns[] = array(
'class' => '',
'column' => $url->copy()
->add('actionId', 'view_stock')
->link(array('title' => _("View Item")))
. htmlspecialchars($item->stock_name) . '');
// properties
foreach ($this->shownProperties as $property) {
$value = $item->getValue($property);
$columns[] = array(
'class' => '',
'column' => $value
? htmlspecialchars($value->getDataValue())
: ' ');
}
// note
$columns[] = array(
'class' => '',
'column' => $item->note
? htmlspecialchars($item->note)
: ' ');
$items[] = array('columns' => $columns);
}
return $items;
}
}
php-horde-sesha-1.0.0~beta1/sesha-1.0.0beta1/list.php 0000664 0000000 0000000 00000003056 12061431535 0021754 0 ustar 00root root 0000000 0000000 SESHA_TEMPLATES . '/view/',
'selectedCategories' => array(Horde_Util::getFormData('category_id')),
'sortDir' => Horde_Util::getFormData('sortdir'),
'sortBy' => Horde_Util::getFormData('sortby'),
'propertyIds' => @unserialize($prefs->getValue('list_properties')),
'what' => Horde_Util::getFormData('criteria'),
'loc' => Horde_Util::getFormData('location')
)
);
$page_output->addScriptFile('prototype.js', 'horde');
$page_output->addScriptFile('tables.js', 'horde');
$page_output->header(array(
'title' => $view->title
));
require SESHA_TEMPLATES . '/menu.inc';
echo $view->render('list.php');
$page_output->footer();
php-horde-sesha-1.0.0~beta1/sesha-1.0.0beta1/locale/ 0000775 0000000 0000000 00000000000 12061431535 0021523 5 ustar 00root root 0000000 0000000 php-horde-sesha-1.0.0~beta1/sesha-1.0.0beta1/locale/de/ 0000775 0000000 0000000 00000000000 12061431535 0022113 5 ustar 00root root 0000000 0000000 php-horde-sesha-1.0.0~beta1/sesha-1.0.0beta1/locale/de/LC_MESSAGES/ 0000775 0000000 0000000 00000000000 12061431535 0023700 5 ustar 00root root 0000000 0000000 php-horde-sesha-1.0.0~beta1/sesha-1.0.0beta1/locale/de/LC_MESSAGES/sesha.mo 0000664 0000000 0000000 00000221555 12061431535 0025352 0 ustar 00root root 0000000 0000000 ; O $ O ) O O &