Index: openacs-4/packages/contacts/catalog/contacts.de_DE.ISO-8859-1.xml =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/catalog/contacts.de_DE.ISO-8859-1.xml,v diff -u -N -r1.2 -r1.2.2.1 --- openacs-4/packages/contacts/catalog/contacts.de_DE.ISO-8859-1.xml 24 Feb 2005 13:33:06 -0000 1.2 +++ openacs-4/packages/contacts/catalog/contacts.de_DE.ISO-8859-1.xml 30 Nov 2005 15:31:01 -0000 1.2.2.1 @@ -1,42 +1,519 @@ - + + -- eine Gruppe markieren -- + -- Neue Nachricht erstellen -- + -- Keine -- + -- Bitte ausw�hlen -- Aktion - Person hinzuf�gen - Organisation hinzuf�gen - Ausgew�hlte Kontakte einer Kategorie hinzuf�gen - Einer Kategorie hinzuf�gen + Aktionen + Hinzuf�gen: + Hinzuf�gen + Eine Gruppe hinzuf�gen + Eine Person hinzuf�gen + Eine Organisation hinzuf�gen + Einen Kommentar hinzuf�gen + Eine Beschwerde hinzuf�gen f�r + Bedingung hinzuf�gen + e-Mail Nachricht hinzuf�gen + Gruppe hinzuf�gen + Brief hinzuf�gen + Nachricht hinzuf�gen + Neuen hinzuf�gen + Eine neue %object_type% Gruppen zuteilen + Neuer Kunde + Neuer Kundenkontakt + Suche hinzuf�gen + Eine Signatur hinzuf�gen + Den ausgew�hlten Kontakt zu einer Kategorie hinzuweisen + Zu einer Kategorie zuweisen + Zur Gruppe hinzuf�gen + Zur Gruppe hinzuf�gen + Zu folgenden Gruppen hinzuf�gen + User hinzuf�gen + Adresse + Verwaltung + Kontakte verwalten + Expertensuche + Erweiterte Suchen + Zusammenfassen + Zusammenfassen nach + zusammengefasst nach: Alle + Daten �ndern + Alle Kontakte + und Antwort - Archivieren - Markierten Kontakt archivieren + jede/r + Archiv + Die markierten Kontakte archivieren Archiviert + Gebietsschl�ssel ist -> + Gebietsschl�ssel ist nicht -> + Art der Beziehung + Angeh�ngte Dateien: + um Attribut + Attribut -&gt; Attribute - Zurzeit ausgew�hlte Kategorie leeren - Die ausgew�hlte Suche leeren + Verf�gbare Attribute + Verf�gbare Optionen + Geh�rt zu + Haupttext + Massen Update + Abbrechen + Eine Kopie an mehrere Empf�nger E-Mails getrennt durch ";" versenden. + Ge�ndertes Datum: + �nderungen + Ausw�hlen/Entfernen + Leeren + Die zurzeit markierte Kategorie l�schen + Den zurzeit markierte Suche l�schen + Hinzugef�gter Kommentar + Kommentare + Beschwerde + Umfangreiche Beschreibung der Beschwerde, besonders warum die Beschwerde eingereicht wurde. + Wie viel wurde an den Lieferanten gezahlt + Rabatt in Prozent, der aufgrund einer Beschwerde gegeben werden musste + Betrag der an den Kunden zur�ck gezahlt wurde + Was ist der Status der Beschwerde + Kurze Bezeichnung, um die Beschwerde zu identifizieren + Umsatz, der mit dem Kunden im Bezug auf diese Beschwerde gemacht wurde + Beschwerden/Reklamationen: + KOnfigurationsfehler Kontakt + Kontakt -&gt; + Kontakt ist in -> + Kontakt ist nicht in -> + Kontakt Beziehung Kontakttyp - Jetzige - e-mail Adresse + Kontakttyp eins + Kontakttyp zwei + Kontakte + Kontakte + enth�lt -&gt; + Kopieren + Land + Landeskennziffer ist -> + Land ist -> + Land ist nicht -> + Erzeugen + Eine Nachricht anlegen + Eine Rolle anlegen + Eine Signatur erstellen + F�r diesen User einen User Account erzeugen + e-Mail anlegen + Einen Brief anlegen + Neues Projekt anlegen + Rolle anlegen + User anlegen + CSV + Derzeitig + Kunde: + Kunde hat keine Angestellten + Datum + Tage + L�schen + L�schen + Beschreibung: + Eine kurze Beschreibung, was die (Unter)Abfrage macht + Details + enth�lt nicht -&gt; + existiert nicht + Erledigt + Bearbeiten + Eine Signatur ver�ndern + Beschwerde ver�ndern + Details �ndern + �ndere %group_name% + e-Mail + EMail + e-Mail Adresse + Angestellter + Angestellte + Arbeitgeber + Arbeitgeber + Fehler + gleich + existiert + existieren mindestens + existieren h�chstens + Option erweitern # %extend_id% gel�scht. + Die Ergebnisliste um die folgende Attribute erweitern + Erweiterte Suchoptionen + falsch + Datei + Dateien + Dateien + Vorname Vornamen + Fu�zeile + Freelancer + Von + Lade + Glossare + Suche + Zu den Suchergebnissen gehen + Gruppe + Gruppe -&gt; + Gruppenname + Gruppen + Gruppen + hat sich eingeloggt + hat sich niemals eingeloggt + Kopfzeile Hilfetext - Nachname - Kontakte limitieren auf + Historie + Suchen + in der Suche + Unberechtigt + ung�ltiger Objekttyp + irrelevant + ist -> + ist nach -> + ist vor -> + ist gr��er als -> + ist kleiner als -> + ist mehr als -> + ist nicht -> + ist nicht eingerichtet + ist eingerichtet + letztes + Nachnamen + Letzte �nderung + Sp�tester + Brief + Brief + Briefkopf + Einschr�nkung der Kontakte auf + -- Gruppen -------------------------- + -- Meine Suchen --------------------- + -- keine Signatur einbinden -- + -- k�rzlich durchgef�hrte Suchen -- + -- Gruppe erste Ebene -- + Eine neue %object_type% hinzuf�gen und den ausgew�hlten Gruppen zuordnen + Hinzuf�gen neuer %rels.relationship% + Hinzuf�gen Beziehungstyp + Zu markierter/n Gruppe/n hinzuf�gen + Erweiterte Suchen sind sehr vielf�ltig, aber sie ben�tigen spezifischen Input + Alle Suchen beachten keine Gro�- und Kleinschreibung. Wenn mehr als ein Kontakt der Suche entspricht, so wird eine Ergebnisliste angezeigt. Wenn nur ein Kontakt den Suchkriterien entspricht, dann wird dieser direkt angezeigt. + Wenigstens %times% %role% sind verwandt + %attribute_pretty% Gebietskennziffer ist: <strong>%option_pretty%</strong> + %attribute_pretty% Gebiteskennziffer ist nicht: <strong>%option_pretty%</strong> + %attribute_pretty% enth�lt: <strong>%value%</strong> + %attribute_pretty% L�nderkennziffer ist: <strong>%option_pretty%</strong> + %attribute_pretty% L�nderkennziffer ist nicht: <strong>%option_pretty%</strong> + %attribute_pretty% Land ist: <strong>%country_pretty%</strong> + %attribute_pretty% Land ist nicht: <strong>%country_pretty%</strong> + %attribute_pretty% enth�lt nicht: <strong>%value%</strong> + %attribute_pretty% ist nach: <strong>[lc_time_fmt %value% %q]</strong> + %attribute_pretty% ist vor: <strong>[lc_time_fmt %value% %q]</strong> + %attribute_pretty% is gr��er als: <strong>%value%</strong> + %attribute_pretty% ist weniger als: <strong>%value%</strong> + %attribute_pretty% is weniger als <strong>%interval%</strong> ago + %attribute_pretty% ist nicht gesetzt + %attribute_pretty% ist nicht: <strong>%option_pretty%</strong> + %attribute_pretty% ist gesetzt + %attribute_pretty% ist: <strong>%option_pretty%</strong> + %attribute_pretty% ist: <strong>%value%</strong> + %attribute_pretty% Bundesland/Bezirk ist: <strong>%value%</strong> + %attribute_pretty% Bundesland/Bezirk ist nicht: <strong>%value%</strong> + %attribute_pretty% PLZ startet mit: <strong>%value%</strong> + %attribute_pretty% PLZ startet nicht mit: <strong>%value%</strong> + <br><br>Diese Suche speichern unter + Die ausgew�hlten Kontakte �ndern + Kommentare in den letzten -> + %comments.pretty_date% an %comments.pretty_time% - + Verwaltung der Kontakte + Kontakt wurde im Zeitintervall kommentiert: <strong>%interval%</strong> + Kontakt erstellt in den letzten: <strong>%interval%</strong> + Kontakt hat sich eingeloggt + Der Kontakt hat sich innerhalb der letzten: <strong>%interval%</strong> eingeloggt + Kontakt hat sich nie eingeloggt + Kontakt hat sich in den letzten <strong>%interval%</strong> nicht eingeloggt. + In der Suche %search_link% + Zu dem Kontakt wurde seit <strong>%interval%</strong> kein Kommentar hinterlassen. + Der Kontakt wurde nicht innerhalb der letzten <strong>%interval%</strong> erstellt. + Der Kontakt wurde seit <strong>%interval%</strong> nicht upgedatet + Kontakt Rel Arbeitverh�ltnis + Kontakt Beziehungen + Kontakt Rels Arbeitsverh�ltnisse + Der Kontakt wurde in den letzten <strong>%interval%</strong> upgedatet. + %contacts@ wurden gel�scht + L�nderkennziffer ist nicht -> + Erstellt in den letzten -> + Zurzeit ist die Gruppe in der Lage, die folgenden Beziehungstypen zu nutzen: + Debugging Code - Nur SW Admins sehen dies + Definition eines neuen Beziehungstyps + Selektierte Kontakte l�schen + L�schen der markierten Dateien + Diesen Kontakt komplett l�schen (nicht wieder r�ckg�ngig machbare Aktion!) + Selektierten Kontakten eine E-mail or einen Brief schreiben + Einen Text in einer normalen Suchbox zu schreiben, bedeutet dass eine Suche ausgef�hrt wird wo: + Bestehende Beziehungen + "First Names" enth�lt "Search_Word" oder + Vorname ist erfoderlich + Gruppe'%group_name%' erstellt + Gruppe '%group_name%' upgedated +Deutsch(DE) + Gruppen Informationen gespeichert. + hat sich eingeloggt innerhalb -> + hat sich nicht eingeloggt innerhalb -> + In einer normalen Suche suchen wir nach "D Jane". Das erste Suchwort ("D") findet Kontakt 123 (via "Doe"), 234 (via "Doe") und 345 (via "Alfred"). Das zweite Suchwort ("Jane") finder nur den Kontakt 123. Daher entspricht nur ein Kontakt beiden Suchkriterien und nur "Jane Doe" (Kontakt 123) wird vom System angezeigt. + Wenn mehrere W�rter verwendet werden, dann m�ssen alle W�rter den o.g. Kriterien entsprechen. Wenn z.B. unsere Kontaktdatenbank die folgenden Eintr�ge enth�lt: + Instanz Berechtigungen - !NOCH UNFERTIG! + Ungen�gende Berechtigungen + Ung�ltige Eingabe, Sie gaben f�r die Eingabemaske '%form%'an, sollten aber nur eingeben: top, bottom, none + Labels wurden bisher nicht implementiert + "Last Name" enth�lt "Search_Word" oder + Nachname notwendig + Letztes Update: %update_date% + <li> Die von Ihnen eingegebene Rolle \"%pretty_name%\" oder der Plural \"%pretty_plural%\" existieren bereits. + Gehen Sie sicher, dass Sie nicht die gleichen Attribute zu mehreren Gruppen hinzuf�gen + Weder der Personen- noch der Organisationstypus ist g�ltig, was ist da passiert Admin? + nicht kommentiert in den letzten -> + nicht erstellt in den letzten -> + nicht upgedatet in den letzten -> + der folgenden Bedingungen:<br> + Sobald Sie diese Briefe ausgedruckt haben k�nnen Sie <a href="%return_url%">dorthin zur�ckkehren wo Sie waren</a>. + Sobald der Release ansteht, wird dieses im Softwarecode ber�cksichtigt. + "Organization Name" enth�lt "Search_Word" oder + Organisationsbeziehung + Organisationsbeziehungen + "Party ID" entspricht "Search_Word" + Personen oder Organisationen + Person - Registrierter User + Personen und Organisationen + %pretty_plural_list_name% gefunden bei der Suche, bitte versuchen Sie es erneut oder erstellen einen neuen Kontakt + Bei der Erstellung k�nnen sie nutzen: &lt;a href=&quot;message-help&quot;&gt;mail merge substitutions&lt;/a&gt;. Die gebr�uchlichsten Platzhalter sind \{name\} \{first_names\}, \{last_name\}, \{home_address\} und \{date\} + Entfernen von markierter/n Gruppe(n) + Von Gruppe entfernen + %role% existiert + %role% ist in der Suche %search_link% + %role% nicht in der Suche %search_link% + Einige der notwendigen Elemente f�r dieses Formular fehlen. Bitte kontaktieren Sie einen Adminstrator und gehen Sie sicher, dass die folgenden Attribute in dem Formular der Standardgruppe f�r diesen Objekttypen vorhanden sind: + Einige der notwendigen Elemente dieses Formulars fehlen. Bitte kontaktieren Sie einen Adminstrator und gehen Sie sicher, dass die folgenden Attribute eingebunden sind: + Bundesland/Region ist nicht -> + Der Objekttyp %contact_link% wurde hinzugef�gt + Die Aktion ist nicht g�ltig + Der Kontakt ist in der Gruppe: <strong>%group_pretty%</strong> + Der Kontakt ist nicht in der Gruppe: <strong>%group_pretty%</strong> + Der spezifizierte KOntakt existiert nicht + Der spezifizierte Kontakt ist keiner der Kontakte in dieser Beziehung + Die Standardgruppe muss den Vornamen und den Nachnamen f�r ein Personenformblatt enthalten sowie einen Organisationsnamen f�r ein Organisationsformblatt, beide ben�tigen eine E-Mail Adresse. + Die Datei %message% wurde erfolgreich upgeloadet + Die Dateien %message% wurden erfolgreich upgeloadet + Der erste spezifizierte Kontakt existiert nicht + Die erste spezifizierte Rolle existiert nicht + Der Parameter RecentOnTopP ist f�r das General Comments Package nicht korrekt gesetzt, bitte geben Sie entweder eine '0' oder eine '1' ein. + Die party_id existiert nicht + Die Abfrage \"%type% %var_list%\" ist nicht l�nger g�ltig, da: %error_message + Die Abfrage \"%type% %var_list%\" ist nicht l�nger g�ltig. Kontaktieren Sie einen Administrator. + Der Name des Empf�ngers und seine Anschriftdaten werden automatisch eingef�gt. Es ist m�glich mit UMschl�gen mit Sichtfenstern zu arbeiten. + Der zweite spezifizierte Kontakt existiert nicht + Die zweite spezifizierte Rolle existiert nicht + Es gab ein Problem mit Ihrer Eingabe. Dieser Beziehungstyp kann nicht existieren. + Diese Aktion kann nicht f�r nicht zugewiesene (unmapped) Gruppen durchgef�hrt werden + Dieser Kontakt ist kein Mitglied einer Gruppe + Diese Gruppe ist bereits der Standard + Diese Gruppe wurde schon zugewiesen (mapped) + Dies ist meine Standard Signatur + Die spezifizierte Signatur existiert entweder nicht oder sie geh�rt nicht zu Ihnen + Der User wartet noch auf Genehmigung vom Administrator + Dieser User wurde noch nicht genehmigt + Der Titel wird in der Nachricht nicht angezeigt, er wird daf�r genutzt, die richtige Nachricht auszuw�hlen. + Nicht m�glich die group-id abzurufen + Upgedatet in den letzten -> + Dieser Person als User registrieren/ upgraden + What role does %contact_name_one% have when %contact_name_two% is a %secondary_role_pretty%: + Sie k�nnen diesen Kontakt nicht zu mehr Gruppen zuweisen. + Sie k�nnen keine Untergruppen als Standardgruppe bestimmen + Sie k�nnen keine Gruppen zuweisen (mappen), deren Eltern-Gruppen nicht zugewiesen (mapped) sind + Sie k�nnen keinen Brief an den folgenden Kontakt schicken: %invalid_recipients% + Sie k�nnen keine Nachricht an die folgenden Kontakte schicken: %invalid_recipients% + Sie k�nnen keine e-Mail an die folgenden Kontakte schicken: %invalid_recipients% + Sie k�nnen die Standardgruppe nicht l�sen (unmap) + Sie haben keine Berechtigung daf�r, User Gruppen zuzuweisen + Sie haben keinen g�ltigen Kontakttypen spezifiziert + Sie haben einen ung�ltigen Objekttypen spezifiziert + Sie haben eine ung�ltige Gr��e f�r eine Textfl�che spezifiziert + Sie m�ssen einige Kontakte markieren, um einen Massen-Update durchf�hren zu k�nnen + Ihr Administrator muss eine Standardgruppe auf den Seiten <a href="admin">admin pages</a> zuweisen und hinzuf�gen + Sie m�ssen einige Kontakte bereitstellen, um eine Nachricht senden zu k�nnen + Sie haben einen ung�ltigen Nachrichtentyp angebenen + PLZ startet nicht mit -> + PLZ startet mit -> + Mailing + Adresszusammenstellung + Resultate der Mail Zusammenfassung (mail merge) + Dateien an Kontakt schicken aktuell machen - Markierte Kontakte auf "aktuell" setzen + ver�ffentlichen + Die markierten Kontakte aktuell machen + Kategorien f�r diese Gruppe + Nachricht + Nachricht wird ben�tigt + Vorlagen + Mitteilungen + mein- + Modifiziert durch: + Meine Nachrichten: + Meine Suchen + Meine Signaturen Name + Name wird ben�tigt + Neue/r + N�chster Parameter + (keine) + Normale Suchen: + Nicht konfiguriert + niucht in der Suche Anzahl an Spalten + Objekt: + object_id + ungerade von - Sortierung + Angebote + Offen + oder + Reihenfolge Organisation + Organisationen Formblatt + Organisationen + Organisationen + Andere Optionen + Ergebnis + Besitzer + Gezahlt: + Papiertyp + �bergeordnete Gruppe + Teil von + Party Revision + Party Versionen + Kontakte + Personen + Personen oder Organisationen + Personen oder Organisationen + Rabatt in Prozent: + Berechtigungen + Zugriffsrechte f�r Standardgruppe Person - ben�tigt - Suche - e-mail Nachricht an markierte Kontakte schicken - e-Mail schicken - zeigen - sortieren nach + Personen Formblatt + Angezeigter Name + Der Name der bei dieser Liste als �berschrift angezeigt wird. + Voransicht + Drucken + Brief drucken + Prozesse + PROJEKT + Projekt: + Projekte + Projektaufgaben + �ffentlicher + �ffentliche Nachrichten + �ffentliche Seite + �ffentlich verf�gbare Suchen + Abfrage + LESEN SIE BITTE DIESES + Empf�nger + R�ckerstattung + Beziehung + Beziehung hinzugef�gt + Beziehung gel�scht + Beziehungstypen + Beziehung upgedatet + Beziehungen + Beziehungen + Standard (Default) entfernen + Entferne erweirterte Optionen, die als Standard f�r die search_id #%search_id% gesetzt sind + Von Gruppe entfernen + Von Gruppe entfernen + Von Gruppe entfernen + Erforderlich + Ergebnisse: + Zur�ck zu %title% + Rolle + Rollenname + Rolle eins + Rolle Singular + Rolle zwei + Rollen + Speichern + Speichern und Weiteren hinzuf�gen + Speichern als + Nachricht speichern als + Speichern dieser Suche + Gespeicherte Suchen + Suchen + Existierenden suchen + Suche nach + Suche nach allen <strong>%object_type%</strong> wo + Suche nach allen %object_type% die + Suchhilfe + Suchen + Markieren + Senden + Eine e-Mail Nachricht an die markierten Kontakte schicken + e-Mail senden + Standard (Default) setzen + Standard (Default) setzen + Einstellungen + Gemeinsam genutzte Suchen + Anzeigen: + Anzeigen + Signatur + Signaturen + Sortieren nach + Sortieren nach: + Bundesland ist -> Status - "Widget" + Gespeicherte erweiterte Optionen + Erweiterte Optionen, die als Standard f�r die search_id #%search_id% gesetzt werden k�nnen + Betreff + Betreff muss ausgef�llt werden + (Unter)Abfrage + Die (Unter)Abfrage, die durchgef�hrt wird, um das Ergebnis zu holen. + �bersicht + �berblick + Bearbeiter: + Tabelle + Aufgaben + Die spezifizierte Aktion ist ung�ltig + Der Fehler war: %errmsg + Die Nachricht %title% wurde zu Ihren Nachrichten kopiert + Die Nachricht %title% wurde gel�scht + Die Nachricht %title% wurde ver�ffentlicht + Die spezifizierte owner_id ist nicht g�ltig + Die Suche "%title%" wurde zu Ihren Suchen kopiert + Die Suche "%title%" wurde gel�scht + Die Suche "%title%" wurde �ffentlich zur Verf�gung gestellt + Dieser Kunde hat keine E-Mail Addresse daher wird die Addresse des Arbeitgebers benutzt (%emp_addr%) + Dieser "Variablen Name" existiert schon + Zeiten + Titel + Grund: + zu + richtig + Auftragswert: + Typ + Update + Update Dateinamen + Update durch + Update am + Datei hochladen + Mehrere Dateien uploaden + Informationen zu dem User Account + Berechtigt + Variablen Name + Name der Variable, die in der erweiterten Suche verwendent werden soll. + Alle Rollen ansehen + N�chstes sehen + Zum Kundenportal + Alle Ver�nderungen ansehen + die �bereinstimmen mit + Widget + mit + Sie k�nnen diese Suche ausweiten durch: + Ihre Nachricht wurde an: <strong>%recipients%</strong> gesendet. + Ihre Signaturen Index: openacs-4/packages/contacts/catalog/contacts.en_US.ISO-8859-1.xml =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/catalog/contacts.en_US.ISO-8859-1.xml,v diff -u -N -r1.2 -r1.2.2.1 --- openacs-4/packages/contacts/catalog/contacts.en_US.ISO-8859-1.xml 13 Jan 2005 13:56:59 -0000 1.2 +++ openacs-4/packages/contacts/catalog/contacts.en_US.ISO-8859-1.xml 30 Nov 2005 15:31:01 -0000 1.2.2.1 @@ -1,42 +1,531 @@ - + + -- select a group -- + -- Create New Message -- + -- None -- + --select one-- Action + Actions + Add: + Add + Add a Group Add a Person Add an Organization + Add Comment + Add complaint to + Add Condition + Add Email Message + Add Group + Add Letter Message + Add Message + Add New + Add new %object_type% selected groups + Add Organization + Add Person + Add Search + Add Signature Add the selected contacts to a category Add to Category + Add to Group + Add to group + Add to Groups + Add User + Address + Admin + Administer Contacts + Advanced Search + Advanced Searches + Aggregate + Aggregate by + Aggregated + aggregated by: + Set it to true if you want to use this extend in "Aggregated Result Page" All + All / Edit + All Contacts + and Answer + Any Archive Archive the checked contacts Archived + area code is -> + area code is not -> + Type of Relationship + Associated Files: + at Attribute + Attribute -> + Attribute Name Attributes + Available Attributes + Available Options + Belongs to + Body + Bulk Update + Cancel + CC + Send copy to multiple addresses separated by ";" + Changed Date: + Changes + Check/Uncheck + Clear Clear the currently selected Category Clear the currently selected Search + Comment Added + Comments + Complaint + Extensive description of the complaint, especially why it was given. + How much was paid to the supplier + Rebate in percent that has had to be given due to the complaint + Amount paid back to the customer + What is the status of the complaint + Short name for identifying the complaint + Turnover that was made with the customer with regards to the complaint + Complaints + Configuration Error Contact + Contact -> + contact is in -> + contact is not in -> + Contact Relationship Contact Type + Contact Type One + Contact Type Two + Contacts + contacts + contains -> + Copy + country code is -> + country is -> + country is not -> + Create + Create a message + Create a role + Create a Signature + Create a user account for this person + Create Email + Create Letter + Create project + Create role + Create User + CSV Current + Customer: + Customer has no employees. + Date + days + Default + Default attributes + Delete + Delete + Description: + A short description of what the subquery does. + Details + does not contain -> + does not exist + Done + Edit + Edit a Signature + Edit complaint + Edit Details + Edit %group_name% + Email + EMail Email Address + Employee + Employees + Employer + Employers + Error + even + exists + exists at least + exists at most + Extend Option # %extend_id% deleted. + The "Extended Query" return an error + Extend result list by + extended by: + Extended Search Options + False + File + Files + files + First Name First Names + Footer + Freelancers + From + Get + Glossars + Go + Go to search results + Group + Group -> + Group Name + Groups + groups + has logged in + has never logged in + Header Help Text + History + Searches + in the search + Invalid + Invalid Object Type + irrelevant + is -> + is after -> + is before -> + is greater than -> + is less than -> + is more than -> + is not -> + is not set + is set + last Last Name + Last updated + Latest + Letter + Letter + Letterhead Limit Contacts to + -- Groups -------------------------- + -- My Searches --------------------- + -- no not include a signature -- + -- Recent Searches -- + -- top level group -- + Add new %object_type% and insert into selected groups + Add new %rels.relationship% + Add relationship type + Add to Selected Group(s) + Advanced searches are very powerful but in return they require very specific input... + All searches are case insensitive, capitalization does not matter. If more than one contact match the search a list of results is returned. If only one contact meets the search criteria you are redirected to that contact. + At least %times% %role% are related + %attribute_pretty% area code is: <strong>%option_pretty%</strong> + %attribute_pretty% area code is not: <strong>%option_pretty%</strong> + %attribute_pretty% contains: <strong>%value%</strong> + %attribute_pretty% country code is: <strong>%option_pretty%</strong> + %attribute_pretty% country code is not: <strong>%option_pretty%</strong> + %attribute_pretty% country is: <strong>%country_pretty%</strong> + %attribute_pretty% country is not: <strong>%country_pretty%</strong> + %attribute_pretty% does not contain: <strong>%value%</strong> + %attribute_pretty% is after: <strong>[lc_time_fmt %value% %q]</strong> + %attribute_pretty% is before: <strong>[lc_time_fmt %value% %q]</strong> + %attribute_pretty% is greater than: <strong>%value%</strong> + %attribute_pretty% is less than: <strong>%value%</strong> + %attribute_pretty% is less than <strong>%interval%</strong> ago + %attribute_pretty% is not set + %attribute_pretty% is not: <strong>%option_pretty%</strong> + %attribute_pretty% is set + %attribute_pretty% is: <strong>%option_pretty%</strong> + %attribute_pretty% is: <strong>%value%</strong> + %attribute_pretty% state/province is: <strong>%value%</strong> + %attribute_pretty% state/province is not: <strong>%value%</strong> + %attribute_pretty% zip/postal starts with: <strong>%value%</strong> + %attribute_pretty% zip/postal does not start with: <strong>%value%</strong> + <br><br>save this search as + Bulk update the selected contacts + commented on in last -> + %comments.pretty_date% at %comments.pretty_time% - + Contact Administration + Contact commented on in the last: <strong>%interval%</strong> + Contact created in the last: <strong>%interval%</strong> + Contact has logged in + Contact has logged in within the last: <strong>%interval%</strong> + Contact has never logged in + Contact has not logged in within the last: <strong>%interval%</strong> + in the search %search_link% + Contact not commented on in the last: <strong>%interval%</strong> + Contact not created in the last: <strong>%interval%</strong> + Contact not updated in the last: <strong>%interval%</strong> + Contact Rel Employment + Contact Relationships + Contact Rels Employment + Contact updated in the last: <strong>%interval%</strong> + The contact was removed from the group + %contacts@ were deleted + country code is not -> + created in the last -> + Currently, the group is able to handle the following types of relationships: + Debugging Code - Only SW Admins See This + Define a new relationship type + Delete the selected Contacts + Delete the selectted files + Completely delete this contact (irreversible action) + E-mail or Mail the selected contacts + Entering a string in the normal search box means that a search will be performed where: + Existing Relationships + "First Names" contains "Search_Word" or + First Names is required + Group '%group_name%' Created + Group '%group_name%' Updated + Group Information Saved. + has logged in within -> + has not logged in within -> + If in a normal search we search for "D Jane". The first Search_Word ("D") matches contacts 123 (via "Doe"), 234 (via "Doe"), and 345 (via "Alfred"). And the second Search_Word ("Jane") matches only contact 123. Thus only one contact meets both requirements and "Jane Doe" (contact 123) is returned. + If multiple words are used then all words must match the above critera. So, for example if our contacts database contains these entries: + Instance Permissions - Not done yet + Insufficient Permissions + Invalid input, you specified form as '%form%' but should only specify: top, bottom, none + labels are not implemented yet + "Last Name" contains "Search_Word" or + Last Name is required + Last updated: %update_date% + <li> The role you entered \"%pretty_name%\" or the plural \"%pretty_plural%\" already exists. + Make sure you do not add the same attribute to multiple groups + neither person nor org type is valid, what happened admin? + not commented on in last -> + not created in the last -> + not updated in the last -> + of the following conditions:<br> + Once you have printed these letters you may <a href="%return_url%">return to where you were</a>. + Once ready for release this will be taken care of in code + "Organization Name" contains "Search_Word" or + Organization Relationship + Organization Relationships + "Party ID" equals "Search_Word" + People or Organizations + Person - Registered Users + Person or Organization + %pretty_plural_list_name% found in search, please try again or add a new contact + remember that you can use mail merge substitutions. The most common wildcards are {name} {first_names}, {last_name}, {salutation}, {home_address} and {date} + Remove from Selected Group(s) + Remove from this Group + %role% exists + %role% in the search %search_link% + %role% not in the search %search_link% + Some of the required elements for this form are missing. Please contact an administrator and make sure that the following attributes are included in the default group's form for this object type: + Some of the required elements for this form are missing. Please contact an administrator and make sure that the following attributes are included: + state/province is not -> + The object type %contact_link% was added + the action supplied is not valid + The contact is in the group: <strong>%group_pretty%</strong> + The contact is NOT in the group: <strong>%group_pretty%</strong> + The contact specified does not exist + The contact specified is not one of the contacts in this relationship + The default group must have first_names and last_name for person objects and name for organization objects, both of them need email + The file %message% was successfully uploaded + The files %message% were successfully uploaded + The first contact specified does not exist + The first role specified does not exist + The parameter RecentOnTopP is not set correctly for the General Comments package, please enter either a '0' or a '1' + The party_id specified does not exist + The query \"%type% %var_list%\" is no longer valid because: %error_message + The query \"%type% %var_list%\" is no longer valid. Contact an admin. + The recipeints name and mailing address will automatically be included so that they work with window envelopes + The second contact specified does not exist + The second role specified does not exist + There was a problem with your input. this type of relationship cannot exist. + There was an error processing your request + This action cannot be taken for unmapped groups + This contact is not part of any groups + This group is already the default + This group is already mapped + this is my default signature + This signature specified either does not exist or does not belong to you + This user is awaiting administrator approval + This users has not been approved + Title is not shown in the message, it is used to select the appropriate message. + Unable to retrieve group_id + updated in the last -> + Upgrade this person to a user + What role does %contact_name_one% have when %contact_name_two% is a %secondary_role_pretty%: + You cannot add this contact to more groups. + You cannot make sub groups the default group + You cannot map groups whose parent groups are not mapped + You cannot send a letter to the following contacts: %invalid_recipients% + You are unable to send a message to the following contacts: %invalid_recipients% + You cannot send an email message to the following contacts: %invalid_recipients% + You cannot unmap the default group + You do not have permission to add users to groups + You have not specified a valid contact type + You have specified an invalid Object Type + You have specified an invalid size for the textarea + You need to select some contacts to bulk update + Your administrator must map and add a default group in the <a href="admin">admin pages</a> + Your need to provide some contacts to send a message + Your provided an invalid Message Type + zip/postal does not start with -> + zip/postal starts with -> + Mail + Mail Merge + Mail Merge Results + Mail to contact Make Current + Make Public Make the checked contacts current + Manage Group Categories + Message + Message is required + Messages + messages + mine- + Modify By: + My Messages + My Searches + My Signatures Name + Name is required + New + Next + (none) + Normal Searches + Not Configured + not in the search Number of Rows + Object: + Object_id + odd of + Offers + Open + or Ordering Organization + Organization Form + Organizations + organizations + Other Options + Output + Owner + Paid: + Paper Type + Parent Group + Part of + Party Revision + Party Revisions + People + people + People or Organizations + people or organizations + Percent: + Permissions + Permissions for default group Person + Person Form + Pretty Name + The Pretty Name to use in the list label. + Preview + Print + Print Letter + Processes + PROJECT + Project: + Projects + Project Tasks + Public + Public Messages + Public Page + Public Searches + Query + READ THESE + Recipients + Refund + Relationship + Relationship Added + Relationship Deleted + Relationship types + Relationship Updated + Relationships + relationships + Remove Default + Remove extended options set as default for search_id #%search_id% + Remove From Group + Remove from Group + Remove from Group Required + Results + Return to %title% + Role + Role Name + Role One + Role Singular + Role Two + Roles + Save + Save and Add Another + Save As + Save Message As + Save this Search + Saved Searches Search + Search Existing + Search for + Search for all <strong>%object_type%</strong> where + Search for all %object_type% who are + Search for <b>people or organizations</b> + Search Help + Search List + searches + Select + Send Send an email message to the selected contacts Send Email + Set Default + Set default + Settings + Shared Searches + Show Showing + Signature + signatures Sort By + Sort by + state/province is -> Status + Stored Extended Options + Extended Options to set as default for search_id #%search_id% + Subject + Subject is required + Subquery + The subquery to be executed to grab the result. + Summary + Summary View + Supplier: + Table + Tasks + The action specified is invalid + The error was: %errmsg + The message %title% was copied to your messages + The message %title% was deleted + The message %title% was made public + The owner_id specified is not valid + The search "%title%" was copied to your searches + The search "%title%" was deleted + The search "%title%" was made public + This contact doesn't have an email, you are going to use it's employer email (%emp_addr%) + This "Variable Name" is already present + times + Title + Title: + To + True + Turnover: + Type + Update + Update filenames + Updated By + Updated On + Upload File + Upload File + Upload More + User Account Information + Valid + Variable Name + Name of the variable to use in the extend search. + View all roles + View next + Visit Club + Watch all changes + which match Widget + with + Working Project Tasks + You can extend this search by: + Your message was sent to: <strong>%recipients%</strong> + your signatures Index: openacs-4/packages/contacts/sql/postgresql/attributes-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/sql/postgresql/Attic/attributes-create.sql,v diff -u -N --- openacs-4/packages/contacts/sql/postgresql/attributes-create.sql 13 Jan 2005 13:57:00 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,138 +0,0 @@ --- attributes-create.sql --- --- @author Matthew Geddert openacs@geddert.com --- @creation-date 2004-07-28 --- @cvs-id $Id: attributes-create.sql,v 1.2 2005/01/13 13:57:00 jeffd Exp $ --- --- - -create table contact_storage_types ( - storage_column varchar(20) - constraint contact_storage_type_nn not null - constraint contact_storage_type_pk primary key -); - -create sequence contact_widget_id_seq; -create table contact_widgets ( - widget_id integer not null - constraint contact_widgets_attr_name_pk primary key, - storage_column varchar(20) - constraint contact_widgets_storage_type_fk references contact_storage_types(storage_column), - description varchar(1000) not null, - widget varchar(20) not null, - datatype varchar(20) not null, - help_p boolean default 'f', - html varchar(255), - format varchar(100), - multiple_p boolean default 'f', - nospell_p boolean default 'f' -); - --- there is the table to store contact_attributes, since import/exports and the like require --- certain fields that are statically mapped by the tcl api we don't actually delete any --- attributes, we simple mark them deleted_p = 't'. - -create table contact_attributes ( - attribute_id integer not null - constraint contact_attributes_attribute_id_fk references acs_objects(object_id) - constraint contact_attributes_attribute_id_pk primary key, - attribute varchar(100) not null, - widget_id integer not null - constraint contact_attributes_widget_id_fk references contact_widgets (widget_id), - depreciated_p boolean default 'f' not null -); - - --- create index contact_attributes_id on contact_attributes(attribute_id); - -create table contact_attribute_names ( - attribute_id integer not null - constraint contact_attribute_names_attribute_id_fk references contact_attributes(attribute_id), - locale varchar(5) not null - constraint contact_attribute_names_locale_fk references ad_locales(locale), - name varchar(100) not null, - help_text varchar(1000), - UNIQUE(attribute_id,locale) -); - -create table contact_attribute_object_map ( - object_id integer not null - constraint contact_attribute_object_map_object_id_fk references acs_objects(object_id), - attribute_id integer not null - constraint contact_attribute_object_map_attribute_id_fk references contact_attributes(attribute_id), - sort_order integer not null, - required_p boolean default'f' not null, - heading varchar(1000), - UNIQUE(object_id,attribute_id) -); - - - -create sequence contact_attribute_options_id_seq; - -create table contact_attribute_options ( - attribute_id integer - constraint contact_choice_types_attr_id_nn not null - constraint contact_choice_types_attr_id_fk references contact_attributes (attribute_id), - option_id integer - constraint contact_choice_types_id_nn not null - constraint contact_choice_types_id_nn primary key, - option varchar(1000) - constraint contact_choice_types_choice_nn not null, - sort_order integer -); - -create sequence contact_attribute_option_map_id_seq; - -create table contact_attribute_option_map_ids ( - option_map_id integer - constraint contact_attribute_option_map_ids_option_map_id_pk primary key -); - - -create table contact_attribute_option_map ( - option_map_id integer - constraint contact_attribute_option_map_option_map_id_nn not null, - party_id integer - constraint contact_attribute_option_map_party_id_fk references parties(party_id), - option_id integer - constraint contact_attribute_option_map_option_id_fk references contact_attribute_options(option_id) -); - -CREATE or REPLACE FUNCTION contact__option_map_id_trigger_proc () RETURNS TRIGGER AS ' -BEGIN - delete from contact_attribute_option_map_ids where option_map_id = NEW.option_map_id; - insert into contact_attribute_option_map_ids (option_map_id) values (NEW.option_map_id); - RETURN NEW; -END; -' LANGUAGE 'plpgsql'; -create trigger contact__option_map_id_trigger before insert or update on contact_attribute_option_map - for each row execute procedure contact__option_map_id_trigger_proc(); - - --- create index contact_attr_choice_attr_id on contact_attribute_choices(attribute_id); --- create index contact_attr_sort_order on contact_attribute_choices(sort_order); - -create table contact_attribute_values ( - party_id integer not null - constraint contact_attribute_values_party_id_fk references parties(party_id), - attribute_id integer not null - constraint contact_attribute_values_attribute_id_fk references contact_attributes(attribute_id), - option_map_id integer - constraint contact_attribute_values_option_id_fk references contact_attribute_option_map_ids(option_map_id), - address_id integer - constraint contact_attribute_values_address_id_fk references postal_addresses(address_id), - number_id integer - constraint contact_attribute_values_number_id_fk references telecom_numbers(number_id), - time timestamptz, - value text, - value_format character varying(50), - deleted_p boolean not null - default 'f', - creation_date timestamptz default now(), - creation_user integer not null - constraint contact_attribute_values_creation_user references users(user_id), - creation_ip varchar -); - --- create index contact_attribute_values_index on contact_attribute_values (party_id, attribute_id); Index: openacs-4/packages/contacts/sql/postgresql/attributes-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/sql/postgresql/Attic/attributes-drop.sql,v diff -u -N --- openacs-4/packages/contacts/sql/postgresql/attributes-drop.sql 13 Jan 2005 13:57:00 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,34 +0,0 @@ --- attributes-drop.sql --- --- @author Matthew Geddert openacs@geddert.com --- @creation-date 2004-07-28 --- @cvs-id $Id: attributes-drop.sql,v 1.2 2005/01/13 13:57:00 jeffd Exp $ --- --- - -drop table contact_attribute_object_map; -drop table contact_attribute_values; -drop table contact_attribute_option_map; -drop table contact_attribute_option_map_ids; -drop table contact_attribute_options; -drop table contact_attribute_names; -drop table contact_attributes; -drop table contact_widgets; -drop table contact_storage_types; - -drop sequence contact_widget_id_seq; -drop sequence contact_attribute_options_id_seq; -drop sequence contact_attribute_option_map_id_seq; - -delete from acs_objects where object_type = 'contact_attribute'; -create function inline_0 () -returns integer as ' -begin - - PERFORM acs_object_type__drop_type (''contact_attribute'',''f''); - - return 0; -end;' language 'plpgsql'; - -select inline_0 (); -drop function inline_0 (); Index: openacs-4/packages/contacts/sql/postgresql/attributes-package-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/sql/postgresql/Attic/attributes-package-create.sql,v diff -u -N --- openacs-4/packages/contacts/sql/postgresql/attributes-package-create.sql 13 Jan 2005 13:57:00 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,307 +0,0 @@ --- attributes-package-create.sql --- --- @author Matthew Geddert openacs@geddert.com --- @creation-date 2004-07-28 --- @cvs-id $Id: attributes-package-create.sql,v 1.2 2005/01/13 13:57:00 jeffd Exp $ --- --- - - -create function inline_1 () -returns integer as ' -begin - - PERFORM acs_object_type__create_type ( - ''contact_attribute'', - ''Contact Attribute'', - ''Contact Attributes'', - ''acs_object'', - ''contact_attributes'', - ''attribute_id'', - null, - ''f'', - null, - ''contact__attribute_name'' - ); - - return 0; - -end;' language 'plpgsql'; -select inline_1 (); -drop function inline_1 (); - - - -create or replace function contact__widget_create (varchar,varchar,varchar,varchar,boolean,varchar,varchar,boolean,boolean) -returns integer as ' -declare - p_storage_column alias for $1; - p_description alias for $2; - p_widget alias for $3; - p_datatype alias for $4; - p_help_p alias for $5; - p_html alias for $6; - p_format alias for $7; - p_multiple_p alias for $8; - p_nospell_p alias for $9; - v_widget_id integer; -begin - v_widget_id := nextval(''contact_widget_id_seq''); - - insert into contact_widgets - (widget_id,storage_column,description,widget,datatype,help_p,html,format,multiple_p,nospell_p) - values - (v_widget_id,p_storage_column,p_description,p_widget,p_datatype,p_help_p,p_html,p_format,p_multiple_p,p_nospell_p); - - return v_widget_id; -end;' language 'plpgsql'; - - - - - -create or replace function contact__attribute_create (integer,varchar,integer,boolean,timestamptz,integer,varchar,integer) -returns integer as ' -declare - p_attribute_id alias for $1; - p_attribute alias for $2; - p_widget_id alias for $3; - p_depreciated_p alias for $4; - p_creation_date alias for $5; - p_creation_user alias for $6; - p_creation_ip alias for $7; - p_context_id alias for $8; - v_attribute_id integer; -begin - v_attribute_id := acs_object__new ( - p_attribute_id, - ''contact_attribute'', - p_creation_date, - p_creation_user, - P_creation_ip, - p_context_id - ); - - insert into contact_attributes - (attribute_id,attribute,widget_id,depreciated_p) - values - (v_attribute_id,p_attribute,p_widget_id,p_depreciated_p); - - return v_attribute_id; -end;' language 'plpgsql'; - -create or replace function contact__attribute_name_save(integer,varchar,varchar,varchar) -returns integer as ' -declare - p_attribute_id alias for $1; - p_locale alias for $2; - p_name alias for $3; - p_help_text alias for $4; -begin - - delete from contact_attribute_names where attribute_id = p_attribute_id and locale = p_locale; - - insert into contact_attribute_names - (attribute_id,locale,name,help_text) - values - (p_attribute_id,p_locale,p_name,p_help_text); - - return ''1''; -end;' language 'plpgsql'; - - - - - - - - - - -create or replace function contact__attribute_object_map_save(integer,integer,integer,boolean,varchar) -returns integer as ' -declare - p_object_id alias for $1; - p_attribute_id alias for $2; - p_sort_order alias for $3; - p_required_p alias for $4; - p_heading alias for $5; -begin - - delete from contact_attribute_object_map where attribute_id = p_attribute_id and object_id = p_object_id; - - insert into contact_attribute_object_map - (object_id,attribute_id,sort_order,required_p,heading) - values - (p_object_id,p_attribute_id,p_sort_order,p_required_p,p_heading); - - return ''1''; -end;' language 'plpgsql'; - - - - - -create or replace function contact__attribute_name (integer) -returns varchar as ' -declare - p_attribute_id alias for $1; - v_name varchar; -begin - v_name := attribute from contact_attributes where attribute_id = p_attribute_id; - return v_name; -end;' language 'plpgsql'; - -create or replace function contact__attribute_delete (integer) -returns integer as ' -declare - p_attribute_id alias for $1; -begin - update contact_attributes set deleted_p = ''t'' where attribute_id = p_attribute_id; - return 0; -end;' language 'plpgsql'; - --- raise NOTICE ''v_count: %'', v_count; - - -create or replace function contact__attribute_value_save (integer,integer,integer,integer,integer,timestamptz,text,boolean,timestamptz,integer,varchar) -returns integer as ' -declare - p_party_id alias for $1; - p_attribute_id alias for $2; - p_option_map_id alias for $3; - p_address_id alias for $4; - p_number_id alias for $5; - p_time alias for $6; - p_value alias for $7; - p_deleted_p alias for $8; - p_creation_date alias for $9; - p_creation_user alias for $10; - p_creation_ip alias for $11; - v_count integer; - v_option_map_id integer; - v_address_id integer; - v_number_id integer; - v_time timestamptz; - v_value text; - v_edit_p boolean; -begin - - v_count := count(*) from contact_attribute_values where party_id = p_party_id and attribute_id = p_attribute_id and not deleted_p; - - if v_count = ''0'' then - - if p_option_map_id is not null - or p_address_id is not null - or p_number_id is not null - or p_time is not null - or p_value is not null - then - - insert into contact_attribute_values - (party_id,attribute_id,option_map_id,address_id,number_id,time,value,deleted_p,creation_date,creation_user,creation_ip) - values - (p_party_id,p_attribute_id,p_option_map_id,p_address_id,p_number_id,p_time,p_value,p_deleted_p,p_creation_date,p_creation_user,p_creation_ip); - end if; - - else - - - select option_map_id, - address_id, - number_id, - time, - value - into v_option_map_id, - v_address_id, - v_number_id, - v_time, - v_value - from contact_attribute_values - where party_id = p_party_id - and attribute_id = p_attribute_id - and not deleted_p; - - if p_option_map_id is null - and p_address_id is null - and p_number_id is null - and p_time is null - and p_value is null - then - - update contact_attribute_values set deleted_p = ''t'' where attribute_id = p_attribute_id and party_id = p_party_id; - - - end if; - - - - if v_option_map_id != p_option_map_id - or v_address_id != p_address_id - or v_number_id != p_number_id - or v_time != p_time - or v_value != p_value - then - - update contact_attribute_values set deleted_p = ''t'' where attribute_id = p_attribute_id and party_id = p_party_id; - - if p_option_map_id is not null - or p_address_id is not null - or p_number_id is not null - or p_time is not null - or p_value is not null - then - insert into contact_attribute_values - (party_id,attribute_id,option_map_id,address_id,number_id,time,value,deleted_p,creation_date,creation_user,creation_ip) - values - (p_party_id,p_attribute_id,p_option_map_id,p_address_id,p_number_id,p_time,p_value,p_deleted_p,p_creation_date,p_creation_user,p_creation_ip); - end if; - - end if; - - end if; - - - - - return 0; -end;' language 'plpgsql'; - - - - - - - - - -create or replace function contact__attribute_option_create (integer,varchar,integer) -returns integer as ' -declare - p_attribute_id alias for $1; - p_option alias for $2; - p_sort_order alias for $3; - v_option_id integer; -begin - - select nextval(''contact_attribute_options_id_seq'') - into v_option_id; - - insert into contact_attribute_options - (option_id,attribute_id,option,sort_order) - values - (v_option_id,p_attribute_id,p_option,p_sort_order); - -return v_option_id; -end;' language 'plpgsql'; - -create or replace function contact__attribute_option_delete (integer) -returns integer as ' -declare - p_option_id alias for $1; -begin - update contact_attribute_options set deleted_p = ''t'' where option_id = p_option_id; -return 0; -end;' language 'plpgsql'; - - Index: openacs-4/packages/contacts/sql/postgresql/attributes-populate.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/sql/postgresql/Attic/attributes-populate.sql,v diff -u -N --- openacs-4/packages/contacts/sql/postgresql/attributes-populate.sql 13 Jan 2005 13:57:00 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,484 +0,0 @@ --- attributes-populate.sql --- --- @author Matthew Geddert openacs@geddert.com --- @creation-date 2004-07-28 --- @cvs-id $Id: attributes-populate.sql,v 1.2 2005/01/13 13:57:00 jeffd Exp $ --- --- - - --- now we populate the database with standard info - -create function inline_1 () -returns integer as ' -declare - v_attribute_id integer; - v_package_id integer; - v_organization_object_id integer; - v_person_object_id integer; - v_widget_id integer; -begin - -v_package_id := package_id from apm_packages where package_key = ''contacts''; - -v_organization_object_id := contact__object_type_create(null,''organization'',null,null,null,null); -v_person_object_id := contact__object_type_create(null,''person'',null,null,null,null); - -insert into contact_storage_types ( storage_column ) values ( ''number_id'' ); -insert into contact_storage_types ( storage_column ) values ( ''address_id'' ); -insert into contact_storage_types ( storage_column ) values ( ''option_map_id'' ); -insert into contact_storage_types ( storage_column ) values ( ''time'' ); -insert into contact_storage_types ( storage_column ) values ( ''value'' ); - - - - - -v_widget_id := contact__widget_create (''address_id'',''Address'',''address'',''address'',null,null,null,null,null); - v_attribute_id := contact__attribute_create (null, -''home_address'', - v_widget_id,''f'',now(),null,null,v_package_id); - PERFORM contact__attribute_name_save (v_attribute_id,''en_US'', -''Home Address'', - null - ); - PERFORM contact__attribute_object_map_save( -v_person_object_id,v_attribute_id, -''140'',''f'', -''Personal Information''); - - v_attribute_id := contact__attribute_create (null, -''organization_address'', - v_widget_id,''f'',now(),null,null,v_package_id); - PERFORM contact__attribute_name_save (v_attribute_id,''en_US'', -''Organization Address'', - null - ); - PERFORM contact__attribute_object_map_save( -v_person_object_id,v_attribute_id, -''210'',''f'',null); - PERFORM contact__attribute_object_map_save( -v_organization_object_id,v_attribute_id, -''50'',''f'',null); - - - - - - - - - - - - - - - -v_widget_id := contact__widget_create (''number_id'',''Phone Number'',''text'',''text'',null,''size 12 maxlength 50'',null,null,null); - - v_attribute_id := contact__attribute_create (null, -''home_phone'', - v_widget_id,''f'',now(),null,null,v_package_id); - PERFORM contact__attribute_name_save (v_attribute_id,''en_US'', -''Home Phone'', - null - ); - PERFORM contact__attribute_object_map_save( -v_person_object_id,v_attribute_id, -''80'',''f'', -''Phone Numbers''); - - v_attribute_id := contact__attribute_create (null, -''home_fax'', - v_widget_id,''f'',now(),null,null,v_package_id); - PERFORM contact__attribute_name_save (v_attribute_id,''en_US'', -''Home Fax'', - null - ); - PERFORM contact__attribute_object_map_save( -v_person_object_id,v_attribute_id, -''90'',''f'',null); - - v_attribute_id := contact__attribute_create (null, -''personal_mobile_phone'', - v_widget_id,''f'',now(),null,null,v_package_id); - PERFORM contact__attribute_name_save (v_attribute_id,''en_US'', -''Personal Mobile Phone'', - null - ); - PERFORM contact__attribute_object_map_save( -v_person_object_id,v_attribute_id, -''100'',''f'',null); - - v_attribute_id := contact__attribute_create (null, -''work_phone'', - v_widget_id,''f'',now(),null,null,v_package_id); - PERFORM contact__attribute_name_save (v_attribute_id,''en_US'', -''Work Phone'', - null - ); - PERFORM contact__attribute_object_map_save( -v_person_object_id,v_attribute_id, -''110'',''f'',null); - - v_attribute_id := contact__attribute_create (null, -''work_fax'', - v_widget_id,''f'',now(),null,null,v_package_id); - PERFORM contact__attribute_name_save (v_attribute_id,''en_US'', -''Work Fax'', - null - ); - PERFORM contact__attribute_object_map_save( -v_person_object_id,v_attribute_id, -''120'',''f'',null); - - v_attribute_id := contact__attribute_create (null, -''work_mobile_phone'', - v_widget_id,''f'',now(),null,null,v_package_id); - PERFORM contact__attribute_name_save (v_attribute_id,''en_US'', -''Work Mobile Phone'', - null - ); - PERFORM contact__attribute_object_map_save( -v_person_object_id,v_attribute_id, -''130'',''f'',null); - - v_attribute_id := contact__attribute_create (null, -''organization_switchboard'', - v_widget_id,''f'',now(),null,null,v_package_id); - PERFORM contact__attribute_name_save (v_attribute_id,''en_US'', -''Organization Switchboard'', - null - ); - PERFORM contact__attribute_object_map_save( -v_person_object_id,v_attribute_id, -''220'',''f'',null); - PERFORM contact__attribute_object_map_save( -v_organization_object_id,v_attribute_id, -''60'',''f'',null); - - - v_attribute_id := contact__attribute_create (null, -''assistants_phone'', - v_widget_id,''f'',now(),null,null,v_package_id); - PERFORM contact__attribute_name_save (v_attribute_id,''en_US'', -''Assistant''''s Phone'', - null - ); - PERFORM contact__attribute_object_map_save( -v_person_object_id,v_attribute_id, -''260'',''f'',null); - - v_attribute_id := contact__attribute_create (null, -''managers_phone'', - v_widget_id,''f'',now(),null,null,v_package_id); - PERFORM contact__attribute_name_save (v_attribute_id,''en_US'', -''Manager''''s Phone'', - null - ); - PERFORM contact__attribute_object_map_save( -v_person_object_id,v_attribute_id, -''240'',''f'',null); - - - - - - - - - -v_widget_id := contact__widget_create (''time'',''Date - MONTH DD, YYYY'',''date'',''date'',''t'',null,''MONTH DD, YYYY'',null,null); - v_attribute_id := contact__attribute_create (null, -''birthday'', - v_widget_id,''f'',now(),null,null,v_package_id); - PERFORM contact__attribute_name_save (v_attribute_id,''en_US'', -''Birthday'', - null - ); - PERFORM contact__attribute_object_map_save( -v_person_object_id,v_attribute_id, -''150'',''f'',null); - - v_attribute_id := contact__attribute_create (null, -''anniversary'', - v_widget_id,''f'',now(),null,null,v_package_id); - PERFORM contact__attribute_name_save (v_attribute_id,''en_US'', -''Anniversary'', - null - ); - PERFORM contact__attribute_object_map_save( -v_person_object_id,v_attribute_id, -''180'',''f'',null); - - - - - - -v_widget_id := contact__widget_create (''option_map_id'',''Choice - radio'',''radio'',''integer'',null,null,null,null,null); - v_attribute_id := contact__attribute_create (null, -''gender'', - v_widget_id,''f'',now(),null,null,v_package_id); - PERFORM contact__attribute_name_save (v_attribute_id,''en_US'', -''Gender'', - null - ); - PERFORM contact__attribute_object_map_save( -v_person_object_id,v_attribute_id, -''160'',''f'',null); -PERFORM contact__attribute_option_create(v_attribute_id,''Male'',''1''); -PERFORM contact__attribute_option_create(v_attribute_id,''Female'',''2''); - - -v_widget_id := contact__widget_create (''option_map_id'',''Choice - select'',''select'',''integer'',null,null,null,null,null); -v_widget_id := contact__widget_create (''option_map_id'',''Choice - checkbox'',''checkbox'',''integer'',null,null,null,''t'',null); - v_attribute_id := contact__attribute_create (null, -''organization_type'', - v_widget_id,''f'',now(),null,null,v_package_id); - PERFORM contact__attribute_name_save (v_attribute_id,''en_US'', -''Organization Type'', - null - ); - PERFORM contact__attribute_object_map_save( -v_organization_object_id,v_attribute_id, -''80'',''f'',null); -PERFORM contact__attribute_option_create(v_attribute_id,''Customer'',''1''); -PERFORM contact__attribute_option_create(v_attribute_id,''Other'',''2''); -PERFORM contact__attribute_option_create(v_attribute_id,''Prospect'',''3''); -PERFORM contact__attribute_option_create(v_attribute_id,''Vendor'',''4''); - - - - - - - - - - - - - - -v_widget_id := contact__widget_create (''value'',''Number - numeric small (i.e. decimals are okay)'',''text'',''numeric'',null,''size 3'',null,null,null); -v_widget_id := contact__widget_create (''value'',''Number - numeric large (i.e. decimals are okay)'',''text'',''numeric'',null,''size 10'',null,null,null); -v_widget_id := contact__widget_create (''value'',''Number - integer small'',''text'',''integer'',null,''size 3'',null,null,null); -v_widget_id := contact__widget_create (''value'',''Number - integer large'',''text'',''integer'',null,''size 10'',null,null,null); -v_widget_id := contact__widget_create (''value'',''Textbox - tiny'',''text'',''text'',null,''size 3'',null,null,null); -v_widget_id := contact__widget_create (''value'',''Textbox - small'',''text'',''text'',null,''size 20'',null,null,null); -v_widget_id := contact__widget_create (''value'',''Textbox - medium'',''text'',''text'',null,''size 35'',null,null,null); - - v_attribute_id := contact__attribute_create (null, -''first_names'', - v_widget_id,''f'',now(),null,null,v_package_id); - PERFORM contact__attribute_name_save (v_attribute_id,''en_US'', -''First Name(s)'', - null - ); - PERFORM contact__attribute_object_map_save( -v_person_object_id,v_attribute_id, -''10'',''f'',null); - - v_attribute_id := contact__attribute_create (null, -''middle_names'', - v_widget_id,''f'',now(),null,null,v_package_id); - PERFORM contact__attribute_name_save (v_attribute_id,''en_US'', -''Middle Name(s)'', - null - ); - PERFORM contact__attribute_object_map_save( -v_person_object_id,v_attribute_id, -''20'',''f'',null); - - v_attribute_id := contact__attribute_create (null, -''last_name'', - v_widget_id,''f'',now(),null,null,v_package_id); - PERFORM contact__attribute_name_save (v_attribute_id,''en_US'', -''Last Name'', - null - ); - PERFORM contact__attribute_object_map_save( -v_person_object_id,v_attribute_id, -''30'',''f'',null); - - - - - v_attribute_id := contact__attribute_create (null, -''spouse'', - v_widget_id,''f'',now(),null,null,v_package_id); - PERFORM contact__attribute_name_save (v_attribute_id,''en_US'', -''Spouse'', - null - ); - PERFORM contact__attribute_object_map_save( -v_person_object_id,v_attribute_id, -''170'',''f'',null); - - v_attribute_id := contact__attribute_create (null, -''organization_name'', - v_widget_id,''f'',now(),null,null,v_package_id); - PERFORM contact__attribute_name_save (v_attribute_id,''en_US'', -''Organization'', - null - ); - PERFORM contact__attribute_object_map_save( -v_person_object_id,v_attribute_id, -''200'',''f'',''Work Information''); - PERFORM contact__attribute_object_map_save( -v_organization_object_id,v_attribute_id, -''10'',''f'',null); - - - - - v_attribute_id := contact__attribute_create (null, -''legal_name'', - v_widget_id,''f'',now(),null,null,v_package_id); - PERFORM contact__attribute_name_save (v_attribute_id,''en_US'', -''Legal Name'', - null - ); - PERFORM contact__attribute_object_map_save( -v_organization_object_id,v_attribute_id, -''20'',''f'',null); - - v_attribute_id := contact__attribute_create (null, -''reg_number'', - v_widget_id,''f'',now(),null,null,v_package_id); - PERFORM contact__attribute_name_save (v_attribute_id,''en_US'', -''Registration number (ein/ssn/vat/etc)'', - null - ); - PERFORM contact__attribute_object_map_save( -v_organization_object_id,v_attribute_id, -''70'',''f'',null); - - v_attribute_id := contact__attribute_create (null, -''managers_name'', - v_widget_id,''f'',now(),null,null,v_package_id); - PERFORM contact__attribute_name_save (v_attribute_id,''en_US'', -''Manager''''s Name'', - null - ); - PERFORM contact__attribute_object_map_save( -v_person_object_id,v_attribute_id, -''230'',''f'',null); - v_attribute_id := contact__attribute_create (null, -''assistants_name'', - v_widget_id,''f'',now(),null,null,v_package_id); - PERFORM contact__attribute_name_save (v_attribute_id,''en_US'', -''Assistant''''s Name'', - null - ); - PERFORM contact__attribute_object_map_save( -v_person_object_id,v_attribute_id, -''250'',''f'',null); - - - - - - - - -v_widget_id := contact__widget_create (''value'',''Email Address'',''text'',''email'',null,''size 35'',null,null,null); - v_attribute_id := contact__attribute_create (null, -''email'', - v_widget_id,''f'',now(),null,null,v_package_id); - PERFORM contact__attribute_name_save (v_attribute_id,''en_US'', -''Email Address'', - null - ); - PERFORM contact__attribute_object_map_save( -v_person_object_id,v_attribute_id, -''40'',''f'',null); - PERFORM contact__attribute_object_map_save( -v_organization_object_id,v_attribute_id, -''30'',''f'',null); - - - - - - - - - - - - - - - -v_widget_id := contact__widget_create (''value'',''Website'',''text'',''url'',null,''size 35'',null,null,null); - v_attribute_id := contact__attribute_create (null, -''url'', - v_widget_id,''f'',now(),null,null,v_package_id); - PERFORM contact__attribute_name_save (v_attribute_id,''en_US'', -''Website'', - null - ); - PERFORM contact__attribute_object_map_save( -v_person_object_id,v_attribute_id, -''70'',''f'',null); - PERFORM contact__attribute_object_map_save( -v_organization_object_id,v_attribute_id, -''40'',''f'',null); - - - - - - - - - -v_widget_id := contact__widget_create (''value'',''Textbox - large'',''text'',''text'',null,''size 55'',null,null,null); - v_attribute_id := contact__attribute_create (null, -''children'', - v_widget_id,''f'',now(),null,null,v_package_id); - PERFORM contact__attribute_name_save (v_attribute_id,''en_US'', -''Children'', - null - ); - PERFORM contact__attribute_object_map_save( -v_person_object_id,v_attribute_id, -''190'',''f'',null); - - - - -v_widget_id := contact__widget_create (''value'',''Textarea - short and small'',''textarea'',''text'',null,''cols 40 rows 2 wrap virtual'',null,null,null); -v_widget_id := contact__widget_create (''value'',''Textarea - medium'',''textarea'',''text'',null,''cols 45 rows 6 wrap virtual'',null,null,null); -v_widget_id := contact__widget_create (''value'',''Textarea - large'',''textarea'',''text'',null,''cols 55 rows 12 wrap virtual'',null,null,null); -v_widget_id := contact__widget_create (''value'',''Textarea - No Spellcheck - short and small'',''textarea'',''text'',null,''cols 40 rows 2 wrap virtual'',null,null,''t''); -v_widget_id := contact__widget_create (''value'',''Textarea - No Spellcheck - medium'',''textarea'',''text'',null,''cols 45 rows 6 wrap virtual'',null,null,''t''); -v_widget_id := contact__widget_create (''value'',''Textarea - No Spellcheck - large'',''textarea'',''text'',null,''cols 55 rows 12 wrap virtual'',null,null,''t''); -v_widget_id := contact__widget_create (''value'',''Richtext - medium'',''richtext'',''richtext'',null,''cols 45 rows 6 wrap virtual'',null,null,null); -v_widget_id := contact__widget_create (''value'',''Richtext - large'',''richtext'',''richtext'',null,''cols 55 rows 12 wrap virtual'',null,null,null); - - - -return 0; - -end;' language 'plpgsql'; - -select inline_1 (); -drop function inline_1 (); - --- v_attribute_id := contact__attribute_create (null, ---'''', --- v_widget_id,''f'',now(),null,null,v_package_id); --- PERFORM contact__attribute_name_save (v_attribute_id,''en_US'', ---'''', --- null --- ); --- PERFORM contact__attribute_object_map_save( ---v_organization_object_id,v_attribute_id, ---'''',''f'',null); - - - Index: openacs-4/packages/contacts/sql/postgresql/contacts-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/sql/postgresql/contacts-create.sql,v diff -u -N -r1.2 -r1.2.2.1 --- openacs-4/packages/contacts/sql/postgresql/contacts-create.sql 13 Jan 2005 13:57:00 -0000 1.2 +++ openacs-4/packages/contacts/sql/postgresql/contacts-create.sql 30 Nov 2005 15:31:01 -0000 1.2.2.1 @@ -7,70 +7,129 @@ -- -create table contact_archives ( - party_id integer - constraint contact_archives_party_id_fk references parties(party_id) - constraint contact_archives_party_id_pk primary key +-- all contacts are parties. we are making parties content repository items, +-- so we need party revisions + +create table contact_party_revisions ( + party_revision_id integer + constraint contact_party_revisions_id_fk references cr_revisions(revision_id) + constraint contact_party_revisions_id_pk primary key ); --- this is used to create forms for orgs and persons (since they need object_ids) to map to. -create table contact_object_types ( - object_id integer not null - constraint contact_object_type_object_id_fk references acs_objects(object_id) - constraint contact_object_type_object_id_pk primary key, - object_type varchar(100) not null, - UNIQUE(object_type) +-- create the content type +select content_type__create_type ( + 'contact_party_revision', -- content_type + 'content_revision', -- supertype + '#contacts.Party_Revision#', -- pretty_name + '#contacts.Party_Revisions#', -- pretty_plural + 'contact_party_revisions', -- table_name + 'party_revision_id', -- id_column + 'contact_party_revision__name' -- name_method ); +-- i need to create the content_folder contact_parties, it is not bound to a package_id +-- since the package_id is not used by contacts - which uses the groups system for package +-- maintenance. +-- contrary to "most" packages that use the content repository, we will not be +-- specifying new item_ids. Since all contacts are parties, we are going to set +-- all parties that use the contacts system to have an content_items(item_id) +-- that is equal to the parties(party_id). -\i contacts-package-create.sql +-- since all contacts are parties we already have good "group" mechanisms built into the core +-- however, we do not want people to view all groups at once, so the calendar instance +-- administrator can selectively give certain calendar instances access to certain groups +-- +-- by default each new contacts instance will be given access to its subsite's group. For +-- example: all users on a default openacs install are memembers of the "Main Site Members" +-- group. If a calendar instance were mounted under that subsite, all "Main Site Members" +-- would be accessible to that calendar instance. +-- +-- just as is the case with the calendar package all "users" of contacts (i.e. users that +-- have write access to at least one contacts instance will be assigned a private calendar) +-- +-- which calendars can be viewed by which calendar instance is handled via parameters - unlike +-- many packages. This allows for more flexable instance and sharing management - where +-- one instances shared calendar can also be accesible to another instance. -create view contacts as - select organization_id as party_id, - 'organization' as object_type, - name, - name as organization_name, - legal_name, - reg_number, - null as first_names, - null as last_name, - name as sort_first_names, - name as sort_last_name, - contact__party_email(organization_id) as email, - contact__party_url(organization_id) as url, - 'f' as user_p, - contact__status(organization_id) as status - from organizations -union - select person_id as party_id, - 'person' as object_type, - first_names || ' ' || last_name as name, - null as organization_name, - null as legal_name, - null as reg_number, - first_names as first_names, - last_name as last_name, - first_names || ' ' || last_name as sort_first_names, - last_name || ', ' || first_names as sort_last_name, - contact__party_email(person_id) as email, - contact__party_url(person_id) as url, - contact__person_is_user_p(person_id) as user_p, - contact__status(person_id) as status - from persons - where person_id != '0' +create table contact_groups ( + group_id integer + constraint contact_groups_id_fk references groups(group_id) + constraint contact_groups_id_nn not null, + default_p boolean default 'f' + constraint contact_groups_default_p_nn not null, + package_id integer + constraint contact_groups_package_id_fk references apm_packages(package_id) + constraint contact_groups_package_id_nn not null, + unique(group_id,package_id) +); + +create table contact_groups_allowed_rels ( + group_id integer + constraint contact_groups_id_fk references groups(group_id) + constraint contact_groups_id_nn not null, + rel_type varchar(100) + constraint contact_groups_allowed_rels_type_fk references acs_rel_types(rel_type), + package_id integer + constraint contact_groups_package_id_fk references apm_packages(package_id) + constraint contact_groups_package_id_nn not null, + unique(group_id,package_id) +); + + +create table contact_signatures ( + signature_id integer + constraint contact_signatures_id_pk primary key, + title varchar(255) + constraint contact_signatures_title_nn not null, + signature varchar(1000) + constraint contact_signatures_signature_nn not null, + default_p boolean default 'f' + constraint contact_signatures_default_p_nn not null, + party_id integer + constraint contact_signatures_party_id_fk references parties(party_id) + constraint contact_signatures_party_id_nn not null, + unique(party_id,title,signature) +); + +-- this view greatly simplifies getting available roles for various contact types +create view contact_rel_types as +( select rel_type, + object_type_one as primary_object_type, + role_one as primary_role, + object_type_two as secondary_object_type, + role_two as secondary_role + from acs_rel_types + where rel_type in ( select object_type from acs_object_types where supertype = 'contact_rel') +) +UNION +( select rel_type, + object_type_two as primary_object_type, + role_two as primary_role, + object_type_one as secondary_object_type, + role_one as secondary_role + from acs_rel_types + where rel_type in ( select object_type from acs_object_types where supertype = 'contact_rel') +) ; +create table contact_rels ( + rel_id integer + constraint contact_rels_rel_id_fk references acs_rels(rel_id) on delete cascade + constraint contact_rels_rel_id_pk primary key +); --- The attribute structure. -\i attributes-create.sql -\i attributes-package-create.sql +create table organization_rels ( + rel_id integer + constraint organization_rels_rel_id_fk references membership_rels(rel_id) on delete cascade + constraint organization_rels_rel_id_pk primary key +); -\i attributes-populate.sql +\i contacts-package-create.sql +\i contacts-search-create.sql +\i contacts-messages-create.sql -\i views-create.sql -\i telecom-number-missing-plsql.sql Index: openacs-4/packages/contacts/sql/postgresql/contacts-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/sql/postgresql/contacts-drop.sql,v diff -u -N -r1.2 -r1.2.2.1 --- openacs-4/packages/contacts/sql/postgresql/contacts-drop.sql 13 Jan 2005 13:57:00 -0000 1.2 +++ openacs-4/packages/contacts/sql/postgresql/contacts-drop.sql 30 Nov 2005 15:31:01 -0000 1.2.2.1 @@ -6,30 +6,30 @@ -- -- +drop table contact_search_extend_map; +drop table contact_search_conditions; +drop table contact_searches; +drop table contact_extend_options; +select drop_package('contact_search'); +select acs_object__delete(search_id) from contact_searches; +select acs_object_type__drop_type('contact_search','t'); --- The view structure. -\i views-drop.sql +drop view contact_rel_types; +drop table contact_signatures; +drop table contact_groups; +drop table contact_rels; +drop table organization_rels; +drop table contact_complaint_track; --- The attribute structure. -\i attributes-drop.sql +select content_type__drop_type ('contact_party_revision','t','t'); +--drop table contact_party_revisions; +select acs_rel_type__drop_type('organization_rel','t'); +select acs_rel_type__drop_type(object_type,'t') from acs_object_types where supertype = 'contact_rel'; +select acs_rel_type__drop_type('contact_rel','t'); - -drop view contacts; -drop table contact_archives; -drop table contact_object_types; - +-- procedure drop_type select drop_package('contact'); +select drop_package('contact_rel'); +select drop_package('contact_party_revision'); -delete from acs_objects where object_type = 'contact_object_type'; -create function inline_0 () -returns integer as ' -begin - - PERFORM acs_object_type__drop_type (''contact_object_type'',''f''); - - return 0; -end;' language 'plpgsql'; - -select inline_0 (); -drop function inline_0 (); - +drop sequence contact_extend_search_seq; \ No newline at end of file Index: openacs-4/packages/contacts/sql/postgresql/contacts-messages-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/sql/postgresql/contacts-messages-create.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/sql/postgresql/contacts-messages-create.sql 30 Nov 2005 15:31:01 -0000 1.4.2.2 @@ -0,0 +1,88 @@ +-- contacts/sql/postgresql/contacts-messages-create.sql +-- +-- @author Matthew Geddert openacs@geddert.com +-- @creation-date 2005-06-29 +-- @cvs-id $Id: contacts-messages-create.sql,v 1.4.2.2 2005/11/30 15:31:01 miguelm Exp $ +-- +-- + +create table contact_message_types ( + message_type varchar(20) + constraint contact_message_types_pk primary key, + pretty_name varchar(100) + constraint contact_message_types_pretty_name_nn not null +); +insert into contact_message_types (message_type,pretty_name) values ('email','#contacts.Email#'); +insert into contact_message_types (message_type,pretty_name) values ('letter','#contacts.Letter#'); +insert into contact_message_types (message_type,pretty_name) values ('header','#contacts.Header#'); +insert into contact_message_types (message_type,pretty_name) values ('footer','#contacts.Footer#'); + + +create table contact_message_items ( + item_id integer + constraint contact_message_items_id_fk references cr_items(item_id) + constraint contact_message_items_id_pk primary key, + owner_id integer + constraint contact_message_items_owner_id_fk references acs_objects(object_id) on delete cascade + constraint contact_message_items_owner_id_nn not null, + message_type varchar(20) + constraint contact_message_items_message_type_fk references contact_message_types(message_type) + constraint contact_message_items_message_type_nn not null, + locale varchar(30) + constraint contact_message_items_locale_fk references ad_locales(locale) +); + +create view contact_messages as + select cmi.item_id, + cmi.owner_id, + cmi.message_type, + cmi.locale, + cr.title, + cr.description, + cr.content, + cr.mime_type as content_format + from contact_message_items cmi, cr_items ci, cr_revisions cr + where cmi.item_id = cr.item_id + and ci.publish_status not in ( 'expired' ) + and ci.live_revision = cr.revision_id +; + + +create table contact_message_log ( + message_id integer + constraint contact_message_log_message_id_pk primary key + constraint contact_message_log_message_id_fk references acs_objects(object_id), + message_type varchar(20) + constraint contact_message_log_message_type_fk references contact_message_types(message_type) + constraint contact_message_log_message_type_nn not null, + sender_id integer + constraint contact_message_sender_id_fk references users(user_id) + constraint contact_message_sender_id_nn not null, + recipient_id integer + constraint contact_message_recipient_id_fk references parties(party_id) + constraint contact_message_recipient_id_nn not null, + sent_date timestamptz + constraint contact_message_sent_date_nn not null, + title varchar(1000), + description text, + content text + constraint contact_message_log_content_nn not null, + content_format varchar(200) + constraint contact_message_log_content_format_fk references cr_mime_types(mime_type) + constraint contact_message_log_content_format_nn not null +); + + + +select acs_object_type__create_type ( + 'contact_message_log', -- content_type + 'Contacts Message Log', -- pretty_name + 'Contacts Messages Logs', -- pretty_plural + 'acs_object', -- supertype + 'contact_message_log', -- table_name + 'object_id', -- id_column + 'contact_messages_log', -- package_name + 'f', -- abstract_p + NULL, -- type_extension_table + NULL -- name_method +); Index: openacs-4/packages/contacts/sql/postgresql/contacts-package-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/sql/postgresql/contacts-package-create.sql,v diff -u -N -r1.2 -r1.2.2.1 --- openacs-4/packages/contacts/sql/postgresql/contacts-package-create.sql 13 Jan 2005 13:57:01 -0000 1.2 +++ openacs-4/packages/contacts/sql/postgresql/contacts-package-create.sql 30 Nov 2005 15:31:01 -0000 1.2.2.1 @@ -7,130 +7,288 @@ -- -create function inline_1 () -returns integer as ' +select define_function_args('contact_party_revision__new', 'party_id,party_revision_id,creation_date;now(),creation_user,creation_ip'); + + +create or replace function contact_party_revision__new ( + integer, -- party_id + integer, -- party_revision_id + timestamptz, -- creation_date + integer, -- creation_user + varchar -- creation_ip +) returns integer +as ' +declare + p_party_id alias for $1; + p_party_revision_id alias for $2; + p_creation_date alias for $3; + p_creation_user alias for $4; + p_creation_ip alias for $5; + v_party_revision_id cr_revisions.revision_id%TYPE; + v_party_id cr_items.item_id%TYPE; begin - PERFORM acs_object_type__create_type ( - ''contact_object_type'', - ''Contact Object Type'', - ''Contact Object Types'', - ''acs_object'', - ''contact_object_types'', - ''object_id'', - null, - ''f'', - null, - ''contact__object_type_name'' - ); + v_party_id := contact_party_revision__item_id ( + p_party_id, + p_creation_date, + p_creation_user, + p_creation_ip + ); - return 0; + v_party_revision_id := content_revision__new ( + NULL, -- title + NULL, -- description + now(), -- publish_date + NULL, -- mime_type + NULL, -- nls_language + NULL, -- data + v_party_id, -- item_id + p_party_revision_id, -- revision_id + p_creation_date, -- creation_date + p_creation_user, -- creation_user + p_creation_ip -- creation_ip + ); + PERFORM content_item__set_live_revision (v_party_revision_id); + + insert into contact_party_revisions ( party_revision_id ) values ( v_party_revision_id ); + + return v_party_revision_id; end;' language 'plpgsql'; -select inline_1 (); -drop function inline_1 (); +create or replace function contact_party_revision__item_id ( + integer, -- party_id + timestamptz, -- creation_date + integer, -- creation_user + varchar -- creation_ip +) returns integer +as ' +declare + p_party_id alias for $1; + p_creation_date alias for $2; + p_creation_user alias for $3; + p_creation_ip alias for $4; + v_exists_p boolean; +begin + v_exists_p := ''1'' from cr_items where item_id = p_party_id; + if v_exists_p is not true then + insert into cr_items + (item_id,parent_id,name,content_type) + values + (p_party_id,contact__folder_id(),p_party_id::varchar,''contact_party_revision''); + end if; -create or replace function contact__object_type_create (integer,varchar,timestamptz,integer,varchar,integer) -returns integer as ' + return p_party_id; +end;' language 'plpgsql'; + +create or replace function contact_party_revision__name ( + integer -- revision_id +) returns varchar +as ' declare - p_object_id alias for $1; - p_object_type alias for $2; - p_creation_date alias for $3; - p_creation_user alias for $4; - p_creation_ip alias for $5; - p_context_id alias for $6; - v_object_id integer; + p_revision_id alias for $1; + v_first_names varchar; + v_last_name varchar; + v_organization varchar; + v_name varchar; begin - v_object_id := acs_object__new ( - p_object_id, - ''contact_object_type'', - p_creation_date, - p_creation_user, - P_creation_ip, - p_context_id - ); + v_name := contact__name(item_id) || '' revision '' || to_char(revision_id,''FM9999999999999999999'') from cr_revisions where item_id = p_revision_id; + return v_name; +end;' language 'plpgsql'; +create or replace function contact__folder_id () returns integer +as ' +declare + v_folder_id integer; +begin - insert into contact_object_types - (object_id,object_type) - values - (v_object_id,p_object_type); + v_folder_id := cf.folder_id from cr_items ci, cr_folders cf + where ci.item_id = cf.folder_id + and ci.parent_id = ''0'' + and ci.name = ''contacts''; - return v_object_id; + if v_folder_id is null then + v_folder_id := content_folder__new ( + ''contacts'', + ''Contacts'', + NULL, + ''0'' + ); + end if; + + return v_folder_id; end;' language 'plpgsql'; +select content_folder__register_content_type(contact__folder_id(),'content_revision','t'); - -create or replace function contact__object_type_name (integer) -returns varchar as ' +create or replace function contact__name ( + varchar, -- first_names + varchar, -- last_name + varchar, -- organization + boolean -- recursive_p +) returns varchar +as ' declare - p_object_id alias for $1; - v_name varchar; + p_first_names alias for $1; + p_last_name alias for $2; + p_organization alias for $3; + p_recursive_p alias for $4; + v_name varchar; begin - v_name := object_type from contact_object_types where object_id = p_object_id; + + if p_recursive_p then + if p_first_names is null and p_last_name is null then + v_name := p_organization; + else + v_name := p_last_name; + if p_first_names is not null and p_last_name is not null then + v_name := v_name || '', ''; + end if; + v_name := v_name || p_first_names; + end if; + else + if p_first_names is null and p_last_name is null then + v_name := p_organization; + else + v_name := p_first_names; + if p_first_names is not null and p_last_name is not null then + v_name := v_name || '' ''; + end if; + v_name := v_name || p_last_name; + end if; + end if; + return v_name; end;' language 'plpgsql'; +create or replace function contact__name ( + integer -- party_id +) returns varchar +as ' +declare + p_party_id alias for $1; + v_name varchar; +begin + v_name := contact__name(p_party_id,''f''); + return v_name; +end;' language 'plpgsql'; +create or replace function contact__name ( + integer, -- party_id + boolean -- recursive_p +) returns varchar +as ' +declare + p_party_id alias for $1; + p_recursive_p alias for $2; + v_first_names varchar; + v_last_name varchar; + v_organization varchar; + v_name varchar; +begin + select first_names, last_name + into v_first_names, v_last_name + from persons where person_id = p_party_id; + select name + into v_organization + from organizations where organization_id = p_party_id; -create or replace function contact__party_email (integer) -returns varchar as ' -declare - email__party_id alias for $1; -begin + v_name := contact__name(v_first_names,v_last_name,v_organization,p_recursive_p); - return email from parties where party_id = email__party_id; + return v_name; +end;' language 'plpgsql'; -end;' language 'plpgsql' stable strict; -create or replace function contact__party_url (integer) -returns varchar as ' +create or replace function contact_group__member_count ( + integer -- group_id +) returns integer +as ' declare - url__party_id alias for $1; + p_group_id alias for $1; + v_member_count integer; begin + v_member_count := count(*) from group_distinct_member_map where group_id = p_group_id ; - return url from parties where party_id = url__party_id; + return v_member_count; +end;' language 'plpgsql'; -end;' language 'plpgsql' stable strict; -create or replace function contact__status (integer) -returns varchar as ' +create or replace function contact_group__member_p (integer,integer) returns boolean +as ' declare - p_party_id alias for $1; - v_archived_p boolean; + p_group_id alias for $1; + p_member_id alias for $2; + v_member_p boolean; begin - v_archived_p := ''1'' from contact_archives where party_id = p_party_id; + v_member_p := ''1'' from group_distinct_member_map where group_id = p_group_id and member_id = p_member_id; - if v_archived_p then - return ''archived''; - else - return ''current''; - end if; + if v_member_p is true then + v_member_p := ''1''; + else + v_member_p := ''0''; + end if; -end;' language 'plpgsql' stable strict; + return v_member_p; +end;' language 'plpgsql'; -create or replace function contact__person_is_user_p (integer) -returns boolean as ' +-- create functions for organization_rels +select define_function_args('organization_rel__new','rel_id,rel_type;organization_rel,object_id_one,object_id_two,creation_user,creation_ip'); + +create or replace function organization_rel__new (integer,varchar,integer,integer,integer,varchar) +returns integer as ' declare - p_person_id alias for $1; - v_result boolean; + new__rel_id alias for $1; -- default null + rel_type alias for $2; -- default ''organization_rel'' + object_id_one alias for $3; + object_id_two alias for $4; + creation_user alias for $5; -- default null + creation_ip alias for $6; -- default null + v_rel_id integer; begin + v_rel_id := acs_rel__new ( + new__rel_id, + rel_type, + object_id_one, + object_id_two, + object_id_one, + creation_user, + creation_ip + ); - v_result := ''1'' from users where user_id = p_person_id; + return v_rel_id; + +end;' language 'plpgsql'; - if v_result then - return ''t''; - else - return ''f''; - end if; +-- function new +create or replace function organization_rel__new (integer,integer) +returns integer as ' +declare + object_id_one alias for $1; + object_id_two alias for $2; +begin + return organization_rel__new(null, + ''organization_rel'', + object_id_one, + object_id_two, + null, + null); +end;' language 'plpgsql'; -end;' language 'plpgsql' stable strict; +-- procedure delete +create or replace function organization_rel__delete (integer) +returns integer as ' +declare + rel_id alias for $1; +begin + PERFORM acs_rel__delete(rel_id); + + return 0; +end;' language 'plpgsql'; Index: openacs-4/packages/contacts/sql/postgresql/contacts-search-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/sql/postgresql/contacts-search-create.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/sql/postgresql/contacts-search-create.sql 30 Nov 2005 15:31:01 -0000 1.10.2.2 @@ -0,0 +1,180 @@ +-- contacts-search-create.sql +-- +-- @author Matthew Geddert openacs@geddert.com +-- @creation-date 2004-07-28 +-- @cvs-id $Id: contacts-search-create.sql,v 1.10.2.2 2005/11/30 15:31:01 miguelm Exp $ +-- +-- + +create table contact_searches ( + search_id integer + constraint contact_searches_id_fk references acs_objects(object_id) on delete cascade + constraint contact_searches_id_pk primary key, + title varchar(255), + owner_id integer + constraint contact_searches_owner_id_fk references acs_objects(object_id) on delete cascade + constraint contact_searches_owner_id_nn not null, + all_or_any varchar(20) + constraint contact_searches_and_or_all_nn not null, + object_type varchar(1000) + constraint contact_searches_object_type_nn not null, + deleted_p boolean default 'f' + constraint contact_searches_deleted_p_nn not null, + aggregated_attribute integer +); + +-- create the content type +select acs_object_type__create_type ( + 'contact_search', -- content_type + 'Contacts Search', -- pretty_name + 'Contacts Searches', -- pretty_plural + 'acs_object', -- supertype + 'contact_searches', -- table_name (should this be pm_task?) + 'search_id', -- id_column + 'contact_search', -- package_name + 'f', -- abstract_p + NULL, -- type_extension_table + NULL -- name_method +); + +create table contact_search_conditions ( + condition_id integer + constraint contact_search_conditions_id_pk primary key, + search_id integer + constraint contact_search_conditions_search_id_fk references contact_searches(search_id) on delete cascade + constraint contact_search_conditions_search_id_nn not null, + type varchar(255) + constraint contact_search_conditions_type_nn not null, + var_list text + constraint contact_search_conditions_var_list_nn not null +); + +create table contact_search_log ( + search_id integer + constraint contact_search_log_search_id_fk references contact_searches(search_id) on delete cascade + constraint contact_search_logs_search_id_nn not null, + user_id integer + constraint contact_search_log_user_id_fk references users(user_id) on delete cascade + constraint contact_search_log_user_id_nn not null, + n_searches integer + constraint contact_search_log_n_searches_nn not null, + last_search timestamptz + constraint contact_search_log_last_search_nn not null, + unique(search_id,user_id) +); + +select define_function_args ('contact_search__new', 'search_id,title,owner_id,all_or_any,object_type,deleted_p;f,creation_date,creation_user,creation_ip,context_id'); + +create or replace function contact_search__new (integer,varchar,integer,varchar,varchar,boolean,timestamptz,integer,varchar,integer) +returns integer as ' +declare + p_search_id alias for $1; + p_title alias for $2; + p_owner_id alias for $3; + p_all_or_any alias for $4; + p_object_type alias for $5; + p_deleted_p alias for $6; + p_creation_date alias for $7; + p_creation_user alias for $8; + p_creation_ip alias for $9; + p_context_id alias for $10; + v_search_id contact_searches.search_id%TYPE; +begin + v_search_id := acs_object__new( + p_search_id, + ''contact_search'', + p_creation_date, + p_creation_user, + p_creation_ip, + coalesce(p_context_id, p_owner_id) + ); + + insert into contact_searches + (search_id,title,owner_id,all_or_any,object_type,deleted_p) + values + (v_search_id,p_title,p_owner_id,p_all_or_any,p_object_type,p_deleted_p); + + return v_search_id; + +end;' language 'plpgsql'; + + + +create or replace function contact_search__log (integer,integer) +returns integer as ' +declare + p_search_id alias for $1; + p_user_id alias for $2; + v_last_search_id integer; + v_exists_p boolean; +begin + -- if the user has used this search in the last 60 minutes we do not log it as a new search + v_last_search_id := search_id + from contact_search_log + where user_id = p_user_id + and last_search > now() - ''1 hour''::interval + order by last_search desc + limit 1; + + if v_last_search_id != p_search_id or v_last_search_id is null then + -- this is a new search we need to log + v_exists_p := ''1''::boolean + from contact_search_log + where search_id = p_search_id + and user_id = p_user_id; + + if v_exists_p then + update contact_search_log + set n_searches = n_searches + 1, + last_search = now() + where search_id = p_search_id + and user_id = p_user_id; + else + insert into contact_search_log + (search_id,user_id,n_searches,last_search) + values + (p_search_id,p_user_id,''1''::integer,now()); + end if; + else + -- we just update the last search time but no n_sesions + update contact_search_log + set last_search = now() + where search_id = p_search_id + and user_id = p_user_id; + end if; + + return ''1''; +end;' language 'plpgsql'; + + +-- Create a sequence and a table for extended searches. + +create sequence contact_extend_search_seq; + +create table contact_extend_options ( + extend_id integer + constraint contact_extend_options_pk primary key, + var_name varchar(100) unique not null, + pretty_name varchar(100) not null, + subquery varchar(5000) not null, + aggregated_p char default 'f' constraint check_aggregate_p check (aggregated_p in ('t','f')), + description varchar(500) +); + +-- Creates a table to map contact_extend_options(extend_id)'s to +-- contact_searches(search_id) + +create table contact_search_extend_map ( + search_id integer + constraint contact_search_extend_map_search_id_fk + references contact_searches (search_id) + on delete cascade, + extend_id integer + constraint contact_search_extend_map_extend_id_fk + references contact_extend_options (extend_id) + on delete cascade, + attribute_id integer + constraint contact_search_extend_map_attribute_id_fk + references acs_attributes (attribute_id) + on delete cascade +); \ No newline at end of file Index: openacs-4/packages/contacts/sql/postgresql/telecom-number-missing-plsql.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/sql/postgresql/Attic/telecom-number-missing-plsql.sql,v diff -u -N --- openacs-4/packages/contacts/sql/postgresql/telecom-number-missing-plsql.sql 13 Jan 2005 13:57:01 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,37 +0,0 @@ --- telecom-number-missing-plsql.sql --- --- @author Matthew Geddert openacs@geddert.com --- @creation-date 2004-07-28 --- @cvs-id $Id: telecom-number-missing-plsql.sql,v 1.2 2005/01/13 13:57:01 jeffd Exp $ --- - - -create function inline_0 () -returns integer as ' -declare - v_telecom_number_p boolean; -begin - v_telecom_number_p := ''1'' from acs_object_types where object_type = ''telecom_number''; - - if v_telecom_number_p then - else - PERFORM acs_object_type__create_type ( - ''telecom_number'', -- object_type - ''Telecom Number'', -- pretty_name - ''Telecom Number'', -- pretty_plural - ''acs_object'', -- supertype - ''telecom_numbers'', -- table_name - ''number_id'', -- id_column - ''telecom_number'', -- package_name - ''f'', -- abstract_p - null, -- type_extension_table - null -- name_method - ); - end if; - - return 0; -end;' language 'plpgsql'; - -select inline_0 (); - -drop function inline_0 (); Index: openacs-4/packages/contacts/sql/postgresql/views-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/sql/postgresql/Attic/views-create.sql,v diff -u -N --- openacs-4/packages/contacts/sql/postgresql/views-create.sql 13 Jan 2005 13:57:01 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,132 +0,0 @@ --- views-create.sql --- --- @author Matthew Geddert openacs@geddert.com --- @creation-date 2004-07-28 --- @cvs-id $Id: views-create.sql,v 1.2 2005/01/13 13:57:01 jeffd Exp $ --- --- - -create table contact_views ( - view_id integer - constraint contact_views_view_id_fk references acs_objects(object_id) - constraint contact_views_view_id_pk primary key, - src varchar(255) - constraint contact_views_src_nn not null, - privilege_required varchar(100) - constraint contact_views_privilege_required_fk references acs_privileges(privilege) - constraint contact_views_privilege_required_nn not null, - privilege_object_id integer - constraint contact_views_privilege_object_id_fk references acs_objects(object_id) - constraint contact_views_privilege_object_id_nn not null, - contact_object_type varchar(100) - constraint contact_views_object_type_id_fk references contact_object_types(object_type) - constraint contact_views_object_type_id_nn not null, - package_id integer - constraint contact_views_package_id_fk references apm_packages(package_id) - constraint contact_views_package_id_nn not null, - sort_order integer not null -); - - - - -create table contact_view_names ( - view_id integer not null - constraint contact_attribute_names_view_id_fk references contact_views(view_id), - locale varchar(5) not null - constraint contact_attribute_names_locale_fk references ad_locales(locale), - name varchar(100) not null, - UNIQUE(view_id,locale) -); - - -create function inline_1 () -returns integer as ' -begin - - PERFORM acs_object_type__create_type ( - ''contact_view'', -- object_type - ''Contacct View'', -- pretty_name - ''Contact Views'', -- pretty_plural - ''acs_object'', -- supertype - ''contact_views'', -- table_name - ''view_id'', -- id_column - null, -- package_name - ''f'', -- abstract_p - null, -- type_extension_table - null -- name_method - ); - - return 0; - -end;' language 'plpgsql'; - -select inline_1 (); -drop function inline_1 (); - - -create or replace function contact__view_create (integer,varchar,varchar,integer,varchar,integer,integer,timestamptz,integer,varchar,integer) -returns integer as ' -declare - p_view_id alias for $1; - p_src alias for $2; - p_privilege_required alias for $3; - p_privilege_object_id alias for $4; - p_contact_object_type alias for $5; - p_package_id alias for $6; - p_sort_order alias for $7; - p_creation_date alias for $8; - p_creation_user alias for $9; - p_creation_ip alias for $10; - p_context_id alias for $11; - v_view_id integer; -begin - v_view_id := acs_object__new ( - p_view_id, - ''contact_view'', - p_creation_date, - p_creation_user, - P_creation_ip, - p_context_id - ); - - insert into contact_views - (view_id,src,privilege_required,privilege_object_id,contact_object_type,package_id,sort_order) - values - (v_view_id,p_src,p_privilege_required,p_privilege_object_id,p_contact_object_type,p_package_id,p_sort_order); - - return v_view_id; -end;' language 'plpgsql'; - -create or replace function contact__view_delete (integer) -returns integer as ' -declare - p_view_id alias for $1; -begin - delete from contact_view_names where view_id = p_view_id; - delete from contact_views where view_id = p_view_id; - delete from acs_objects where object_id = view_id; - - return ''1''; -end;' language 'plpgsql'; - -create or replace function contact__view_name_save(integer,varchar,varchar) -returns integer as ' -declare - p_view_id alias for $1; - p_locale alias for $2; - p_name alias for $3; -begin - - delete from contact_view_names where view_id = p_view_id and locale = p_locale; - - insert into contact_view_names - (view_id,locale,name) - values - (p_view_id,p_locale,p_name); - - return ''1''; -end;' language 'plpgsql'; - - - Index: openacs-4/packages/contacts/sql/postgresql/views-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/sql/postgresql/Attic/views-drop.sql,v diff -u -N --- openacs-4/packages/contacts/sql/postgresql/views-drop.sql 13 Jan 2005 13:57:01 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,23 +0,0 @@ --- views-drop.sql --- --- @author Matthew Geddert openacs@geddert.com --- @creation-date 2004-07-28 --- @cvs-id $Id: views-drop.sql,v 1.2 2005/01/13 13:57:01 jeffd Exp $ --- --- - -drop table contact_view_names; -drop table contact_views; - -delete from acs_objects where object_type = 'contact_view'; -create function inline_0 () -returns integer as ' -begin - - PERFORM acs_object_type__drop_type (''contact_view'',''f''); - - return 0; -end;' language 'plpgsql'; - -select inline_0 (); -drop function inline_0 (); Index: openacs-4/packages/contacts/tcl/address-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/tcl/Attic/address-procs-postgresql.xql,v diff -u -N --- openacs-4/packages/contacts/tcl/address-procs-postgresql.xql 27 Feb 2005 17:07:18 -0000 1.3 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,21 +0,0 @@ - - - -postgresql7.2 - - - - select default_name, iso from countries order by default_name - - - - - - - select 1 from us_states where abbrev = upper(:region) or state_name = upper(:region) - - - - - - Index: openacs-4/packages/contacts/tcl/address-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/tcl/Attic/address-procs.tcl,v diff -u -N --- openacs-4/packages/contacts/tcl/address-procs.tcl 13 Jan 2005 13:57:01 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,270 +0,0 @@ -ad_library { - Address input widget and datatype for the OpenACS templating system. - - @author Matthew Geddert openacs@geddert.com - @creation-date 2004-07-28 - @cvs-id $Id: address-procs.tcl,v 1.2 2005/01/13 13:57:01 jeffd Exp $ - -} - -namespace eval template {} -namespace eval template::data {} -namespace eval template::data::transform {} -namespace eval template::data::validate {} -namespace eval template::util {} -namespace eval template::util::address {} -namespace eval template::widget {} - -ad_proc -public template::util::address { command args } { - Dispatch procedure for the address object -} { - eval template::util::address::$command $args -} - -ad_proc -public template::util::address::create { - {contents {}} - {format {}} -} { - return [list $contents $format] -} - -ad_proc -public template::util::address::acquire { type { value "" } } { - Create a new address value with some predefined value - Basically, create and set the address value -} { - set address_list [template::util::address::create] - return [template::util::address::set_property $type $address_list $value] -} - -ad_proc -public template::util::address::formats {} { - Returns a list of valid address formats -} { -# MGEDDERT NOTE: there needs to be a way to implement a way to portray addresses differently by country - return { US CA DE } -} - -ad_proc -public template::util::address::country_options {} { - Returns the country list - - - - -} { - -# MGEDDERT NOTE: This should be pulled from the db and cached on restart - set countries_list [db_list_of_lists get_countries {}] - return $countries_list - -} - -ad_proc -public template::data::validate::address { value_ref message_ref } { - - upvar 2 $message_ref message $value_ref address_list - - set delivery_address [lindex $address_list 0] - set municipality [lindex $address_list 1] - set region [lindex $address_list 2] - set postal_code [lindex $address_list 3] - set country_code [lindex $address_list 4] - - if { $country_code == "US" } { - if { ![db_0or1row validate_state { - select 1 from us_states where abbrev = upper(:region) or state_name = upper(:region) -} ] } { - set message "\"$region\" is not a valid US State." - return 0 - } - } - - return 1 -} - -ad_proc -public template::data::transform::address { element_ref } { - - upvar $element_ref element - set element_id $element(id) - -# set contents [ns_queryget $element_id] -# set format [ns_queryget $element_id.format] - - set delivery_address [ns_queryget $element_id] - set municipality [ns_queryget $element_id.municipality] - set region [ns_queryget $element_id.region] - set postal_code [ns_queryget $element_id.postal_code] - set country_code [ns_queryget $element_id.country_code] - - - - if { [empty_string_p $delivery_address] } { - # We need to return the empty list in order for form builder to think of it - # as a non-value in case of a required element. - return [list] - } else { - return [list [list $delivery_address $municipality $region $postal_code $country_code]] - } -} - -ad_proc -public template::util::address::set_property { what address_list value } { - Set a property of the address datatype. - - @param what One of - - - @param address_list the address list to modify - @param value the new value - - @return the modified list -} { - set contents [lindex $address_list 0] - set format [lindex $address_list 1] - - switch $what { - contents - content - text { - # Replace contents with value - return [list $value $format] - } - format - mime_type { - # Replace format with value - return [list $contents $value] - } - default { - error "Invalid property $what, valid properties are text (synonyms content, contents), mime_type (synonym format)." - } - } -} - -ad_proc -public template::util::address::get_property { what address_list } { - - Get a property of the address datatype. Valid properties are: - - @param what the name of the property. Must be one of: - - @param address_list a address datatype value, usually created with ad_form. -} { - set delivery_address [lindex $address_list 0] - set municipality [lindex $address_list 1] - set region [lindex $address_list 2] - set postal_code [lindex $address_list 3] - set country_code [lindex $address_list 4] - - - switch $what { - delivery_address - street_address { - return $delivery_address - } - postal_code - zip_code - zip { - return $postal_code - } - municipality - city - town { - return $municipality - } - region - state - province { - return $region - } - country_code - country { - return $country_code - } - - default { - error "Parameter supplied to util::address::get_property 'what' must be one of: 'delivery_address', 'postal_code', 'municipality', 'region', 'country_code'. You specified: '$what'." - } - } -} - -ad_proc -public template::widget::address { element_reference tag_attributes } { - Implements the address widget. - - If the acs-templating.UseHtmlAreaForAddressP parameter is set to true (1), this will use the htmlArea WYSIWYG editor widget. - Otherwise, it will use a normal textarea, with a drop-down to select a format. The available formats are: - - You can also parameterize the address widget with a 'htmlarea_p' attribute, which can be true or false, and which will override the parameter setting. -} { - - upvar $element_reference element - -# if { [info exists element(html)] } { -# array set attributes $element(html) -# } - -# array set attributes $tag_attributes - - if { [info exists element(value)] } { - set delivery_address [template::util::address::get_property delivery_address $element(value)] - set postal_code [template::util::address::get_property postal_code $element(value)] - set municipality [template::util::address::get_property municipality $element(value)] - set region [template::util::address::get_property region $element(value)] - set country_code [template::util::address::get_property country_code $element(value)] - } else { - set delivery_address {} - set postal_code {} - set municipality {} - set region {} - set country_code {US} - } - - set output {} - - if { [string equal $element(mode) "edit"] } { - - - set attributes(id) \"address__$element(form_id)__$element(id)\" - - append output " - - - - - - - - - - - - - - - - - - - - - - - -
Street
      
CityState/ProvinceZip/Postal Code
[menu $element(id).country_code [template::util::address::country_options] $country_code attributes]
Country
- -" - - -# append output [textarea_internal "$element(id)" attributes $delivery_address] -# append output "
City: " -# append output "
State: " -# append output "
Country: [menu "$element(id).country_code" [template::util::address::country_options] $country_code attributes]" - - } else { - # Display mode - if { [info exists element(value)] } { - append output [template::util::address::get_property html_value $element(value)] - append output "" - append output "" - } - } - - return $output -} Index: openacs-4/packages/contacts/tcl/attribute-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/tcl/attribute-procs-postgresql.xql,v diff -u -N -r1.3 -r1.3.2.1 --- openacs-4/packages/contacts/tcl/attribute-procs-postgresql.xql 27 Feb 2005 17:07:18 -0000 1.3 +++ openacs-4/packages/contacts/tcl/attribute-procs-postgresql.xql 30 Nov 2005 15:31:01 -0000 1.3.2.1 @@ -1,122 +1,135 @@ - - - -postgresql7.2 - - - - select contact__attribute_create ( - null, - :widget_id, - :label, - :help_text, - :help_p, - :html, - :format, - now(), - :creation_user, - :creation_ip - ) - - - - - - - select contact__attribute_delete ( - :attribute_id - ) - - - - - - - select name from contact_attribute_names where attribute_id = :attribute_id and locale = :locale - - - - - - - select name from contact_view_names where attribute_id = :attribute_id and locale = :locale - - - - - - - select contact__attribute_value_save ( - :party_id, - :attribute_id, - :option_map_id, - :address_id, - :number_id, - :time, - :value, - :deleted_p, - now(), - :creation_user, - :creation_ip - ) - - - - - - - select postal_address__new ( - :additional_text, - null, - :country_code, - :delivery_address, - :municipality, - null, - :postal_code, - :postal_type, - :region, - :creation_user, - :creation_ip, - null - ) - - - - - - - select * from postal_addresses where address_id = :address_id - - - - - - - select telecom_number__new ( - :area_city_code, - :best_contact_time, - :extension, - :itu_id, - :location, - :national_number, - null, - null, - null, - :sms_enabled_p, - :subscriber_number, - :creation_user, - :creation_ip, - null - ) - - - - - - - select * from telecom_numbers where number_id = :number_id - - - - - + + + + + + + select contact__attribute_create ( + null, + :widget_id, + :label, + :help_text, + :help_p, + :html, + :format, + now(), + :creation_user, + :creation_ip + ) + + + + + + + select contact__attribute_delete ( + :attribute_id + ) + + + + + + + select name from contact_attribute_names where attribute_id = :attribute_id and locale = :locale + + + + + + + select name from contact_view_names where attribute_id = :attribute_id and locale = :locale + + + + + + + select contact__attribute_value_save ( + :party_id, + :attribute_id, + :option_map_id, + :address_id, + :number_id, + :time, + :value, + :deleted_p, + now(), + :creation_user, + :creation_ip + ) + + + + + + + select postal_address__new ( + :additional_text, + null, + :country_code, + :delivery_address, + :municipality, + null, + :postal_code, + :postal_type, + :region, + :creation_user, + :creation_ip, + null + ) + + + + + + + select * from postal_addresses where address_id = :address_id + + + + + + + select telecom_number__new ( + :area_city_code, + :best_contact_time, + :extension, + :itu_id, + :location, + :national_number, + null, + null, + null, + :sms_enabled_p, + :subscriber_number, + :creation_user, + :creation_ip, + null + ) + + + + + + + select * from telecom_numbers where number_id = :number_id + + + + + + select + distinct + a.pretty_name, + ot.attribute_id + from + ams_option_types ot, + ams_attributes a + where + ot.attribute_id = a.attribute_id + order by a.pretty_name asc + + + + Index: openacs-4/packages/contacts/tcl/attribute-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/tcl/attribute-procs.tcl,v diff -u -N -r1.2 -r1.2.2.1 --- openacs-4/packages/contacts/tcl/attribute-procs.tcl 13 Jan 2005 13:57:02 -0000 1.2 +++ openacs-4/packages/contacts/tcl/attribute-procs.tcl 30 Nov 2005 15:31:01 -0000 1.2.2.1 @@ -57,9 +57,17 @@ } + ad_proc -public options_attribute { + } { + Returns a list of only the attributes that have + multiple choices of the format {pretty_name attribute_id} + } { + set options [db_list_of_lists get_option_attributes { }] + lappend options [list "[_ contacts.Country]" "-1"] + lappend options [list "[_ contacts.Relationship]" "-2"] + return $options + } - - } Index: openacs-4/packages/contacts/tcl/category-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/tcl/category-procs-postgresql.xql,v diff -u -N -r1.3 -r1.3.2.1 --- openacs-4/packages/contacts/tcl/category-procs-postgresql.xql 27 Feb 2005 17:07:18 -0000 1.3 +++ openacs-4/packages/contacts/tcl/category-procs-postgresql.xql 30 Nov 2005 15:31:01 -0000 1.3.2.1 @@ -1,31 +1,29 @@ - - - -postgresql7.2 - - - - SELECT - t.name as cat_name, - t.category_id as cat_id, - tm.tree_id, - tt.name as tree_name - FROM - category_tree_map tm, - categories c, - category_translations t, - category_tree_translations tt - WHERE - c.tree_id = tm.tree_id and - c.category_id = t.category_id and - tm.object_id = :package_id and - tm.tree_id = tt.tree_id and - c.deprecated_p = 'f' - ORDER BY - tt.name, - t.name - - - - - + + + + + + SELECT + t.name as cat_name, + t.category_id as cat_id, + tm.tree_id, + tt.name as tree_name + FROM + category_tree_map tm, + categories c, + category_translations t, + category_tree_translations tt + WHERE + c.tree_id = tm.tree_id and + c.category_id = t.category_id and + tm.object_id = :package_id and + tm.tree_id = tt.tree_id and + c.deprecated_p = 'f' + ORDER BY + tt.name, + t.name + + + + + Index: openacs-4/packages/contacts/tcl/contact-complaint-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/tcl/contact-complaint-procs.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/tcl/contact-complaint-procs.tcl 30 Nov 2005 15:31:01 -0000 1.4.2.2 @@ -0,0 +1,85 @@ +ad_library { + + @author Miguel Marin (miguelmarin@viaro.net) + @author Viaro Networks www.viaro.net +} + + +namespace eval contact::complaint:: {} + +ad_proc -public contact::complaint::new { + {-complaint_id ""} + {-title ""} + -customer_id:required + -turnover:required + -percent:required + {-description ""} + -supplier_id:required + -paid:required + -complaint_object_id:required + {-state "open"} + {-employee_id ""} + {-refund_amount ""} +} { + Inserts a new complaint. Creates a new revision if complaint_id is not present, + otherwise creates a new item and revision for the complaint. + + @param complaint_id The revision_id of the complaint_id, if not provided then it will create a new one. + @param title The title of the item. + @param customer_id + @param turnover + @param percent + @param description + @param supplier_id + @param paid + @param complaint_object_id The complaint is being made over this object_id + @param state + @param employee_id + @param refund_amount + +} { + if { [empty_string_p $complaint_id] } { + # We create a new cr_item and revision + set item_id [content::item::new \ + -name $title \ + -creation_user [ad_conn user_id] \ + -package_id [ad_conn package_id] \ + -description $description \ + -title $title \ + -is_live t] + set complaint_id [content::item::get_live_revision -item_id $item_id] + + } else { + # Create only a new revision + set item_id [db_string get_item_id { }] + set complaint_id [content::revision::new \ + -item_id $item_id \ + -title $title \ + -description $description \ + -creation_user [ad_conn user_id] \ + -package_id [ad_conn package_id]] + + } + + # Insert extra information the table + db_dml insert_complaint { } + +} + +ad_proc -public contact::complaint::check_name { + -name:required + {-parent_id "-100"} + {-complaint_id ""} +} { + Check if the name you are giving to the complaint already exists, if it does returns 1 otherwise returns 0 + + @param name The name of the item to check + @param parent_id The id of the parent item_id if exist, using -100 by default + @param complaint_id To figure out if is a new item or a new revision. If it's a revision, return 0 +} { + if {![empty_string_p $complaint_id] } { + return 0 + } else { + return [db_string check_name { } -default 0] + } +} \ No newline at end of file Index: openacs-4/packages/contacts/tcl/contact-complaint-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/tcl/contact-complaint-procs.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/tcl/contact-complaint-procs.xql 30 Nov 2005 15:31:01 -0000 1.4.2.2 @@ -0,0 +1,39 @@ + + + + + + + insert into + contact_complaint_track + (complaint_id,customer_id,turnover,percent,supplier_id,paid,complaint_object_id,state,employee_id,refund_amount) + values + (:complaint_id,:customer_id,:turnover,:percent,:supplier_id,:paid,:complaint_object_id,:state,:employee_id,:refund_amount) + + + + + + select + item_id + from + cr_revisions + where + revision_id = :complaint_id + + + + + + select + 1 + from + cr_items + where + name = :name + and parent_id = :parent_id + + + + + Index: openacs-4/packages/contacts/tcl/contact-extend-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/tcl/contact-extend-procs-postgresql.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/tcl/contact-extend-procs-postgresql.xql 30 Nov 2005 15:31:01 -0000 1.3.2.2 @@ -0,0 +1,71 @@ + + + + + + delete from + contact_extend_options + where + extend_id = :extend_id + + + + + + insert into contact_extend_options (extend_id,var_name,pretty_name,subquery,description,aggregated_p) + values (:extend_id,:var_name,:pretty_name,:subquery,:description,:aggregated_p) + + + + + + update contact_extend_options + set var_name = :var_name, + pretty_name = :pretty_name, + subquery = :subquery, + description = :description, + aggregated_p = :aggregated_p + where extend_id = :extend_id + + + + + + select + 1 + from + contact_extend_options + where + var_name = :var_name + + + + + + select + pretty_name, + extend_id + from + contact_extend_options + $extra_query + and aggregated_p = :aggregated_p + + + + + + select + var_name, + pretty_name, + subquery, + description, + aggregated_p + from + contact_extend_options + where + extend_id = :extend_id + + + + + Index: openacs-4/packages/contacts/tcl/contact-extend-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/tcl/contact-extend-procs.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/tcl/contact-extend-procs.tcl 30 Nov 2005 15:31:01 -0000 1.4.2.2 @@ -0,0 +1,85 @@ +ad_library { + + @author Miguel Marin (miguelmarin@viaro.net) + @author Viaro Networks www.viaro.net + @creation-date 2005-09-08 +} + +namespace eval contact::extend:: {} + +ad_proc -public contact::extend::delete { + -extend_id:required +} { + Deletes one contact extend option + @param extend_id The extend_id to delete +} { + db_dml extend_delete { } +} + +ad_proc -public contact::extend::new { + -extend_id:required + -var_name:required + -pretty_name:required + -subquery:required + {-description ""} + {-aggregated_p "f"} +} { + Creates a new contact extend option +} { + set var_name [string tolower $var_name] + db_dml new_extend_option { } +} + + +ad_proc -public contact::extend::update { + -extend_id:required + -var_name:required + -pretty_name:required + -subquery:required + {-description ""} + {-aggregated_p "f"} +} { + Updates one contact extend option +} { + set var_name [string tolower $var_name] + db_dml update_extend_option { } +} + +ad_proc -public contact::extend::var_name_check { + -var_name:required +} { + Checks if the name is already present on the contact_extend_options table or not +} { + set var_name [string tolower $var_name] + return [db_string check_name { } -default "0"] +} + +ad_proc -public contact::extend::get_options { + {-ignore_extends ""} + -search_id:required + -aggregated_p:required +} { + Returns a list of the form { pretty_name extend_id } of all available extend options in + contact_extend_options, if search_id is passed then ignore the extends in + contact_search_extend_map + + @param ignore_extends A list of extend_id's to ignore on the result + @param search_id The id of the search to get the mapped extend options + @param aggregated_p Set it to t or f to get the extends that have aggregated_p set to t or f +} { + set extra_query "where extend_id not in (select extend_id from contact_search_extend_map where search_id = $search_id)" + if { ![empty_string_p $ignore_extends] } { + set ignore_extends [join $ignore_extends ","] + append extra_query "and extend_id not in ($ignore_extends)" + } + + return [db_list_of_lists get_options " "] +} + +ad_proc -public contact::extend::option_info { + -extend_id:required +} { + Returns a list of the form { var_name pretty_name subquery description aggregated_p } of the extend_id +} { + return [db_list_of_lists get_options { }] +} \ No newline at end of file Index: openacs-4/packages/contacts/tcl/contact-message-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/tcl/contact-message-procs-postgresql.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/tcl/contact-message-procs-postgresql.xql 30 Nov 2005 15:31:01 -0000 1.1.2.2 @@ -0,0 +1,29 @@ + + + + + + insert into contact_message_log + ( message_id, message_type, sender_id, recipient_id, sent_date, title, description, content, content_format) + values + ( :object_id, :message_type, :sender_id, :recipient_id, :sent_date, :title, :description, :content, :content_format) + + + + + + + select + acs_object__new ( + null, + 'contact_message_log', + :sent_date, + :sender_id, + :creation_ip, + :package_id + ) + + + + + Index: openacs-4/packages/contacts/tcl/contact-message-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/tcl/contact-message-procs.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/tcl/contact-message-procs.tcl 30 Nov 2005 15:31:01 -0000 1.7.2.2 @@ -0,0 +1,257 @@ +ad_library { + + Support procs for the contacts package + + @author Matthew Geddert openacs@geddert.com + @creation-date 2004-07-28 + @cvs-id $Id: contact-message-procs.tcl,v 1.7.2.2 2005/11/30 15:31:01 miguelm Exp $ +} + +namespace eval contact:: {} +namespace eval contact::message:: {} +namespace eval contact::signature:: {} + +ad_proc -public contact::signature::get { + {-signature_id:required} +} { + Get a signature +} { + return [db_string get_signature "select signature from contact_signatures where signature_id = :signature_id" -default {}] +} + +ad_proc -private contact::message::root_folder { +} { + returns the cr_folder for contacts +} { + return [db_string get_root_folder { select contact__folder_id() }] +} + +ad_proc -public contact::message::get { + {-item_id:required} + {-array:required} +} { + Get the info on a contact message +} { + upvar 1 $array row + db_1row select_message_info { select * from contact_messages where item_id = :item_id } -column_array row +} + +ad_proc -private contact::message::save { + {-item_id:required} + {-owner_id:required} + {-message_type:required} + {-title:required} + {-description ""} + {-content:required} + {-content_format "text/plain"} + {-locale ""} +} { + save a contact message +} { + if { ![db_0or1row item_exists_p { select '1' from contact_message_items where item_id = :item_id }] } { + if { [db_0or1row item_exists_p { select '1' from acs_objects where object_id = :item_id }] } { + error "The item_id specified is not a contact_message_item but already exists as an acs_object. This is not a valid item_id." + } + # we need to create the content item + content::item::new \ + -name "message.${item_id}" \ + -parent_id [contact::message::root_folder] \ + -item_id $item_id \ + -creation_user [ad_conn user_id] \ + -creation_ip [ad_conn peeraddr] \ + -content_type "content_revision" \ + -storage_type "text" + + db_dml insert_into_message_items { + insert into contact_message_items + ( item_id, owner_id, message_type, locale ) + values + ( :item_id, :owner_id, :message_type, :locale ) + } + } else { + db_dml update_message_item { + update contact_message_items set owner_id = :owner_id, message_type = :message_type, locale = :locale where item_id = :item_id + } + } + + set revision_id [content::revision::new \ + -item_id $item_id \ + -title $title \ + -description $description \ + -content $content \ + -mime_type $content_format \ + -is_live "t"] + + return $revision_id +} + + + +ad_proc -private contact::message::log { + {-message_type:required} + {-sender_id ""} + {-recipient_id:required} + {-sent_date ""} + {-title ""} + {-description ""} + {-content:required} + {-content_format "text/plain"} + {-item_id ""} +} { + Logs a message into contact_message_log table. + + @param message_type The message_type of this message (e.g email, letter). + @param sender_id The party_id of the sender of the message. + @recipient_id The party_id of the reciever of the message. + @sent_date The date when the message was sent. Default to now. + @title The title of the logged message. + @description The description of the logged message. + @content The content of the message. + @content_format The format of the content. + @item_id The item_id of the message from the default messages. + +} { + if { ![exists_and_not_null sender_id] } { + set sender_id [ad_conn user_id] + } + if { ![exists_and_not_null sent_date] } { + set sent_date [db_string get_current_timestamp { select now() }] + } + set creation_ip [ad_conn peeraddr] + set package_id [ad_conn package_id] + + # First we check the parameter to see if the emails are going to be logged or not, + # if they are then we check if the message is a default one (message_id). + + if { ![string equal $message_type "email"] } { + + # We make every message logged in this table an acs_object + set object_id [db_string create_acs_object { }] + db_dml log_message { } + + } elseif { [parameter::get -parameter "LogEmailsP"] && [exists_and_not_null item_id] } { + + # We log all emails that used a default email message. + set object_id [db_string create_acs_object { }] + db_dml log_message { } + + } +} + +ad_proc -private contact::message::email_address_exists_p { + {-party_id:required} +} { + Does a email address exist for this party. Cached +} { + return [util_memoize [list ::contact::message::email_address_exists_p_not_cached -party_id $party_id]] +} + +ad_proc -private contact::message::email_address_exists_p_not_cached { + {-party_id:required} +} { + Does a email address exist for this party +} { + return [string is false [empty_string_p [contact::email -party_id $party_id]]] +} + +ad_proc -private contact::message::mailing_address_exists_p { + {-party_id:required} +} { + Does a mailing address exist for this party. Cached +} { + return [util_memoize [list ::contact::message::mailing_address_exists_p_not_cached -party_id $party_id]] +} + +ad_proc -private contact::message::mailing_address_exists_p_not_cached { + {-party_id:required} +} { + Does a mailing address exist for this party +} { + set attribute_ids [contact::message::mailing_address_attribute_id_priority] + set revision_id [contact::live_revision -party_id $party_id] + if { [llength $attribute_ids] > 0 } { + if { [db_0or1row mailing_address_exists_p " select '1' from ams_attribute_values where object_id = :revision_id and attribute_id in ('[join $attribute_ids {','}]') limit 1 "] } { + return 1 + } else { + return 0 + } + } else { + return 0 + } +} + + +ad_proc -private contact::message::mailing_address { + {-party_id:required} + {-format "text/plain"} +} { + Does a mailing address exist for this party +} { + regsub -all "text/" $format "" format + if { $format != "html" } { + set format "text" + } + + set attribute_ids [contact::message::mailing_address_attribute_id_priority] + set revision_id [contact::live_revision -party_id $party_id] + set mailing_address {} + db_foreach mailing_address_values " + select attribute_id, + ams_attribute_value__value(attribute_id,value_id) as value + from ams_attribute_values + where object_id = :revision_id + and attribute_id in ('[join $attribute_ids {','}]') + " { + set attribute_value($attribute_id) $value + } + foreach attribute $attribute_ids { + if { [info exists attribute_value($attribute)] } { + set mailing_address [ams::widget \ + -widget postal_address \ + -request "value_${format}" \ + -value $value \ + ] + + break + } + } + return $mailing_address +} + +ad_proc -private contact::message::mailing_address_attribute_id_priority { +} { + Returns the order of priority of attribute_ids for the letter mailing address +} { + set attribute_ids [parameter::get -parameter "MailingAddressAttributeIdOrder" -default {}] + if { [llength $attribute_ids] == 0 } { + # no attribute_id preference was specified so we get all postal_address attribute types and order them + set postal_address_attributes [db_list_of_lists get_postal_address_attributes { select pretty_name, attribute_id from ams_attributes where widget = 'postal_address'}] + set postal_address_attributes [ams::util::localize_and_sort_list_of_lists -list $postal_address_attributes] + set attribute_ids [list] + foreach attribute $postal_address_attributes { + lappend attribute_ids [lindex $attribute 1] + } + } + return $attribute_ids +} + + + +ad_proc -private contact::message::interpolate { + {-values:required} + {-text:required} +} { + Interpolates a set of values into a string. This is directly copied from the bulk mail package + + @param values a list of key, value pairs, each one consisting of a + target string and the value it is to be replaced with. + @param text the string that is to be interpolated + + @return the interpolated string +} { + foreach pair $values { + regsub -all [lindex $pair 0] $text [lindex $pair 1] text + } + return $text +} + Index: openacs-4/packages/contacts/tcl/contact-search-condition-type-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/tcl/contact-search-condition-type-procs.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/tcl/contact-search-condition-type-procs.tcl 30 Nov 2005 15:31:01 -0000 1.10.2.2 @@ -0,0 +1,976 @@ +ad_library { + + Contact search condition type procs + + @author Matthew Geddert openacs@geddert.com + @creation-date 2005-07-18 + @cvs-id $Id: contact-search-condition-type-procs.tcl,v 1.10.2.2 2005/11/30 15:31:01 miguelm Exp $ + +} + +namespace eval contacts:: {} +namespace eval contacts::search:: {} +namespace eval contacts::search::condition_type:: {} + +ad_proc -public contacts::search::condition_type { + -type:required + -request:required + {-var_list ""} + {-form_name ""} + {-party_id "party_id"} + {-revision_id "revision_id"} + {-object_type "party"} + {-prefix "condition"} +} { + This proc defers its responses to all other contacts::search::condition_type::${type} procs. + + @param type type contacts::search::condition_type::${type} we defer to + @param request + must be one of the following: + + @param form_name The name of the template_form or ad_form being used +} { + + if { [contacts::search::condition_type_exists_p -type $type] } { + switch $request { + ad_form_widgets { + } + form_var_list { + } + sql { + } + pretty { + } + type_name { + } + } + return [contacts::search::condition_type::${type} -request $request -form_name $form_name -var_list $var_list -party_id $party_id -revision_id $revision_id -object_type $object_type -prefix $prefix] + } else { + # the widget requested did not exist + ns_log Debug "Contacts: the contacts search condition type \"${type}\" was requested and the associated ::contacts::search::condition_type::${type} procedure does not exist" + } +} + +ad_proc -private contacts::search::condition_types { +} { + Return all widget procs. Each list element is a list of the first then pretty_name then the widget +} { + set condition_types [list] + set all_procs [::info procs "::contacts::search::condition_type::*"] + foreach condition_type $all_procs { + if { [string is false [regsub {__arg_parser} $condition_type {} condition_type]] } { + regsub {::contacts::search::condition_type::} $condition_type {} condition_type + lappend condition_types [list [contacts::search::condition_type -type $condition_type -request "type_name"] $condition_type] + } + } + return [::ams::util::localize_and_sort_list_of_lists -list $condition_types] +} + +ad_proc -private contacts::search::condition_type_exists_p { + {-type} +} { + Return 1 if it exists and 0 if not +} { + return [string is false [empty_string_p [info procs "::contacts::search::condition_type::${type}"]]] +} + + + +ad_proc -private contacts::search::condition_type::attribute { + -request:required + {-var_list ""} + {-form_name ""} + {-party_id ""} + {-revision_id ""} + {-object_type ""} + {-prefix ""} + {-without_arrow_p "f"} + {-only_multiple_p "f"} + {-null_display "- - - - - -"} +} { + Return all widget procs. Each list element is a list of the first then pretty_name then the widget + @param without_arrow_p Show the elementes in the select menu without the "->" + @param only_multiple_p Only show those elements that have multiple choices +} { + switch $request { + ad_form_widgets { + set attribute_id [ns_queryget ${prefix}attribute_id] + + if { [exists_and_not_null attribute_id] } { + ams::attribute::get -attribute_id $attribute_id -array "attr_info" + set value_method [ams::widget -widget $attr_info(widget) -request "value_method"] + set attrprefix "${prefix}$attr_info(attribute_name)__" + set operand [ns_queryget "${attrprefix}operand"] + # we must use the operand in the var prefix because + # this will rest the vars if somebody changes the operand + set var1 "${attrprefix}${operand}__var1" + set var2 "${attrprefix}${operand}__var2" + set ${var1} [ns_queryget ${var1}] + if { [template::element::exists $form_name $var1] } { + if { [template::element::get_property $form_name $var1 widget] == "date" } { + set ${var1} [join \ + [template::util::date::get_property linear_date_no_time \ + [template::element::get_value $form_name $var1] \ + ] \ + "-"] + } + } + set ${var2} [ns_queryget ${var2}] + set var_elements [list] + + switch $value_method { + ams_value__options { + set operand_options [list \ + [list "$null_display" ""] \ + [list "[_ contacts.is_-]" "selected"] \ + [list "[_ contacts.is_not_-]" "not_selected"] \ + ] + + if { $operand == "selected" || $operand == "not_selected" } { + set option_options [ams::widget_options -attribute_id $attribute_id] + lappend var_elements [list ${var1}:text(select) [list label {}] [list options $option_options]] + } + } + ams_value__telecom_number { + set operand_options [list \ + [list "$null_display" ""] \ + [list "[_ contacts.area_code_is_-]" "area_code_equals"] \ + [list "[_ contacts.area_code_is_not_-]" "not_area_code_equals"] \ + [list "[_ contacts.country_code_is_-]" "country_code_equals"] \ + [list "[_ contacts.lt_country_code_is_not_-]" "not_country_code_equals"] \ + ] + if { [exists_and_not_null operand] } { + lappend var_elements [list ${var1}:integer(text) [list label {}] [list html [list size 3 maxlength 3]]] + } + } + ams_value__text { + set operand_options [list \ + [list "$null_display" ""] \ + [list "[_ contacts.contains_-]" "contains"] \ + [list "[_ contacts.does_not_contain_-]" "not_contains"] \ + ] + if { [exists_and_not_null operand] } { + lappend var_elements [list ${var1}:text(text) [list label {}]] + } + } + ams_value__postal_address { + set operand_options [list \ + [list "$null_display" ""] \ + [list "[_ contacts.country_is_-]" "country_is"] \ + [list "[_ contacts.country_is_not_-]" "country_is_not"] \ + [list "[_ contacts.stateprovince_is_-]" "state_is"] \ + [list "[_ contacts.lt_stateprovince_is_not_]" "state_is_not"] \ + [list "[_ contacts.lt_zippostal_starts_with]" "zip_is"] \ + [list "[_ contacts.lt_zippostal_does_not_st]" "zip_is_not"] \ + ] + + if { $operand == "state_is" || $operand == "state_is_not" } { + lappend var_elements [list ${var1}:text(text) [list label {}] [list html [list size 2 maxlength 2]]] + } elseif { $operand == "country_is" || $operand == "country_is_not" } { + set country_options [template::util::address::country_options] + lappend var_elements [list ${var1}:text(select) [list label {}] [list options $country_options]] + } elseif { $operand == "zip_is" || $operand == "zip_is_not" } { + lappend var_elements [list ${var1}:text(text) [list label {}] [list html [list size 7 maxlength 7]]] + } + } + ams_value__number { + set operand_options [list \ + [list "[_ contacts.is_-]" "is"] \ + [list "[_ contacts.is_greater_than_-]" "greater_than"] \ + [list "[_ contacts.is_less_than_-]" "less_than"] \ + ] + if { [exists_and_not_null operand] } { + lappend var_elements [list ${var1}:integer(text) [list label {}] [list html [list size 4 maxlength 20]]] + } + } + ams_value__time { + set operand_options [list \ + [list "$null_display" ""] \ + [list "[_ contacts.is_less_than_-]" "less_than"] \ + [list "[_ contacts.is_more_than_-]" "more_than"] \ + [list "[_ contacts.is_after_-]" "after"] \ + [list "[_ contacts.is_before_-]" "before"] \ + ] + if { $operand == "more_than" || $operand == "less_than" } { + set interval_options [list \ + [list years years] \ + [list months months] \ + [list days days] \ + ] + lappend var_elements [list \ + ${var1}:integer(text) \ + [list label {}] \ + [list html [list size 2 maxlength 3]] \ + ] + lappend var_elements [list \ + ${var2}:text(select) \ + [list label {}] \ + [list options $interval_options] \ + [list after_html [list ago]] \ + ] + } elseif { [exists_and_not_null operand] } { + lappend var_elements [list ${var1}:date(date) [list label {}]] + } + } + } + } + + set form_elements [list] + + if { !$only_multiple_p } { + set attribute_options [db_list_of_lists get_attributes { + select pretty_name, attribute_id + from ams_attributes + where object_type in ('organization','party','person','user') + and ams_attribute_id is not null + }] + } else { + set attribute_options [contacts::attribute::options_attribute] + } + set sorted_options [ams::util::localize_and_sort_list_of_lists -list $attribute_options] + set attribute_options [list [list "$null_display" ""]] + foreach op $sorted_options { + if { $without_arrow_p } { + lappend attribute_options [list "[lindex $op 0]" "[lindex $op 1]"] + } else { + lappend attribute_options [list "[lindex $op 0] ->" "[lindex $op 1]"] + } + } + lappend form_elements [list \ + ${prefix}attribute_id:text(select),optional \ + [list label {}] \ + [list options $attribute_options] \ + [list html [list onChange "javascript:acs_FormRefresh('$form_name')"]] \ + [list value $attribute_id] \ + ] + + if { [exists_and_not_null attribute_id] } { + # now we add operand options that are available to anybody + lappend operand_options [list "[_ contacts.is_set]" "set"] [list "[_ contacts.is_not_set]" "not_set"] + + lappend form_elements [list \ + ${attrprefix}operand:text(select),optional \ + [list label {}] \ + [list options [concat $operand_options]] \ + [list html [list onChange "javascript:acs_FormRefresh('$form_name')"]] \ + ] + + if { $operand != "set" && $operand != "not_set" } { + # there could be variable elements so we add them here + set form_elements [concat $form_elements $var_elements] + } + } + return $form_elements + } + form_var_list { + set attribute_id [ns_queryget ${prefix}attribute_id] + if { [exists_and_not_null attribute_id] } { + ams::attribute::get -attribute_id $attribute_id -array "attr_info" + set value_method [ams::widget -widget $attr_info(widget) -request "value_method"] + set prefix "${prefix}$attr_info(attribute_name)__" + set operand [ns_queryget "${prefix}operand"] + + if { $operand == "set" || $operand == "not_set" } { + return [list $attribute_id $operand] + } elseif { [exists_and_not_null operand] } { + set var1 "${prefix}${operand}__var1" + set var2 "${prefix}${operand}__var2" + set ${var1} [ns_queryget ${var1}] + if { [template::element::exists $form_name $var1] } { + if { [template::element::get_property $form_name $var1 widget] == "date" } { + set ${var1} [join \ + [template::util::date::get_property linear_date_no_time \ + [template::element::get_value $form_name $var1] \ + ] \ + "-"] + } + } + set ${var2} [ns_queryget ${var2}] + if { [exists_and_not_null ${var1}] } { + set results [list $attribute_id $operand] + lappend results [set ${var1}] + if { [exists_and_not_null ${var2}] } { + lappend results [set ${var2}] + } + return $results + } else { + return {} + } + } else { + return {} + } + } + } + sql - pretty { + set attribute_id [lindex $var_list 0] + if { $request == "pretty" } { + set attribute_pretty [attribute::pretty_name -attribute_id $attribute_id] + } else { + set attribute_pretty "[_ contacts.irrelevant]" + } + + set operand [lindex $var_list 1] + set value [string tolower [lindex $var_list 2]] + + switch $operand { + set { + set output_pretty "[_ contacts.lt_attribute_pretty_is_s]" + set output_code "$revision_id in (\n\select aav${attribute_id}.object_id\n from ams_attribute_values aav${attribute_id}\n where aav${attribute_id}.attribute_id = '${attribute_id}' )" + } + not_set { + set output_pretty "[_ contacts.lt_attribute_pretty_is_n]" + set output_code "$revision_id not in (\n\select aav${attribute_id}.object_id\n from ams_attribute_values aav${attribute_id}\n where aav${attribute_id}.attribute_id = '${attribute_id}' )" + } + default { + ams::attribute::get -attribute_id $attribute_id -array "attr_info" + set value_method [ams::widget -widget $attr_info(widget) -request "value_method"] + + switch $value_method { + ams_value__options { + if { $request == "pretty" } { + set option_pretty [ams::option::name -option_id $value] + } else { + set option_pretty "" + } + + switch $operand { + selected { + set output_pretty "[_ contacts.lt_attribute_pretty_is_s_1]" + set output_code "$revision_id in (\n\select aav${attribute_id}.object_id\n from ams_attribute_values aav${attribute_id}, ams_options ao${attribute_id}\n where aav${attribute_id}.attribute_id = '${attribute_id}' and aav${attribute_id}.value_id = ao${attribute_id}.value_id and ao${attribute_id}.option_id = '$value' )" + } + not_selected { + set output_pretty "[_ contacts.lt_attribute_pretty_is_n_1]" + set output_code "$revision_id not in (\n\select aav${attribute_id}.object_id\n from ams_attribute_values aav${attribute_id}, ams_options ao${attribute_id}\n where aav${attribute_id}.attribute_id = '${attribute_id}' and aav${attribute_id}.value_id = ao${attribute_id}.value_id and ao${attribute_id}.option_id = '$value' )" + } + } + } + ams_value__telecom_number { + switch $operand { + area_code_equals { + set output_pretty "[_ contacts.lt_attribute_pretty_area]" + set output_code "$revision_id in (\n\select aav${attribute_id}.object_id\n from ams_attribute_values aav${attribute_id}, telecom_numbers tn${attribute_id}\n where aav${attribute_id}.attribute_id = '${attribute_id}' and aav.${attribute_id}.value_id = tn${attribute_id}.number_id and tn${attribute_id}.area_city_code = '$value' )" + } + not_area_code_equals { + set output_pretty "[_ contacts.lt_attribute_pretty_area_1]" + set output_code "$revision_id not in (\n\select aav${attribute_id}.object_id\n from ams_attribute_values aav${attribute_id}, telecom_numbers tn${attribute_id}\n where aav${attribute_id}.attribute_id = '${attribute_id}' and aav.${attribute_id}.value_id = tn${attribute_id}.number_id and tn${attribute_id}.area_city_code = '$value' )" + } + country_code_equals { + set output_pretty "[_ contacts.lt_attribute_pretty_coun]" + set output_code "$revision_id in (\n\select aav${attribute_id}.object_id\n from ams_attribute_values aav${attribute_id}, telecom_numbers tn${attribute_id}\n where aav${attribute_id}.attribute_id = '${attribute_id}' and aav.${attribute_id}.value_id = tn${attribute_id}.number_id and tn${attribute_id}.country_code = '$value' )" + } + not_country_code_equals { + set output_pretty "[_ contacts.lt_attribute_pretty_coun_1]" + set output_code "$revision_id in (\n\select aav${attribute_id}.object_id\n from ams_attribute_values aav${attribute_id}, telecom_numbers tn${attribute_id}\n where aav${attribute_id}.attribute_id = '${attribute_id}' and aav.${attribute_id}.value_id = tn${attribute_id}.number_id and tn${attribute_id}.area_city_code = '$value' )" + } + } + } + ams_value__text { + switch $operand { + contains { + set output_pretty "[_ contacts.lt_attribute_pretty_cont]" + set output_code "$revision_id in (\n\select aav${attribute_id}.object_id\n from ams_attribute_values aav${attribute_id}, ams_texts at${attribute_id}\n where aav${attribute_id}.attribute_id = '${attribute_id}'\n and aav${attribute_id}.value_id = at${attribute_id}.value_id\n and lower(at${attribute_id}.text) like ('\%$value\%')\n)" + } + not_contains { + set output_pretty "[_ contacts.lt_attribute_pretty_does]" + set output_code "$revision_id in (\n\select aav${attribute_id}.object_id\n from ams_attribute_values aav${attribute_id}, ams_texts at${attribute_id}\n where aav${attribute_id}.attribute_id = '${attribute_id}'\n and aav${attribute_id}.value_id = at${attribute_id}.value_id\n and lower(at${attribute_id}.text) not like ('\%$value\%')\n)" + } + } + } + ams_value__postal_address { + set value [string toupper $value] + switch $operand { + country_is { + set country_pretty [_ ref-countries.$value] + set output_pretty "[_ contacts.lt_attribute_pretty_coun_2]" + set output_code "$revision_id in (\n\select aav${attribute_id}.object_id\n from ams_attribute_values aav${attribute_id}, postal_addresses pa${attribute_id}\n where aav${attribute_id}.attribute_id = '${attribute_id}' and aav${attribute_id}.value_id = pa${attribute_id}.address_id and pa${attribute_id}.country_code = '$value' )" + } + country_is_not { + set country_pretty [_ ref-countries.$value] + set output_pretty "[_ contacts.lt_attribute_pretty_coun_3]" + set output_code "$revision_id in (\n\select aav${attribute_id}.object_id\n from ams_attribute_values aav${attribute_id}, postal_addresses pa${attribute_id}\n where aav${attribute_id}.attribute_id = '${attribute_id}' and aav${attribute_id}.value_id = pa${attribute_id}.address_id and pa${attribute_id}.country_code = '$value' )" + } + state_is { + set output_pretty "[_ contacts.lt_attribute_pretty_stat]" + set output_code "$revision_id in (\n\select aav${attribute_id}.object_id\n from ams_attribute_values aav${attribute_id}, postal_addresses pa${attribute_id}\n where aav${attribute_id}.attribute_id = '${attribute_id}' and aav${attribute_id}.value_id = pa${attribute_id}.address_id and pa${attribute_id}.region = '$value' )" + } + state_is_not { + set output_pretty "[_ contacts.lt_attribute_pretty_stat_1]" + set output_code "$revision_id in (\n\select aav${attribute_id}.object_id\n from ams_attribute_values aav${attribute_id}, postal_addresses pa${attribute_id}\n where aav${attribute_id}.attribute_id = '${attribute_id}' and aav${attribute_id}.value_id = pa${attribute_id}.address_id and pa${attribute_id}.region = '$value' )" + } + zip_is { + set output_pretty "[_ contacts.lt_attribute_pretty_zipp]" + set output_code "$revision_id in (\n\select aav${attribute_id}.object_id\n from ams_attribute_values aav${attribute_id}, postal_addresses pa${attribute_id}\n where aav${attribute_id}.attribute_id = '${attribute_id}' and aav${attribute_id}.value_id = pa${attribute_id}.address_id and pa${attribute_id}.postal_code like ('$value\%') )" + } + zip_is_not { + set output_pretty "[_ contacts.lt_attribute_pretty_zipp_1]" + set output_code "$revision_id in (\n\select aav${attribute_id}.object_id\n from ams_attribute_values aav${attribute_id}, postal_addresses pa${attribute_id}\n where aav${attribute_id}.attribute_id = '${attribute_id}' and aav${attribute_id}.value_id = pa${attribute_id}.address_id and pa${attribute_id}.postal_code like ('$value\%') )" + } + } + } + ams_value__number { + switch $operand { + is { + set output_pretty "[_ contacts.lt_attribute_pretty_is_s_2]" + set output_code "$revision_id in (\n\select aav${attribute_id}.object_id\n from ams_attribute_values aav${attribute_id}, ams_numbers an${attribute_id}\n where aav${attribute_id}.attribute_id = '${attribute_id}'\n and aav${attribute_id}.value_id = an${attribute_id}.value_id\n and an${attribute_id}.number = '$value' )" + } + greater_than { + set output_pretty "[_ contacts.lt_attribute_pretty_is_g]" + set output_code "$revision_id in (\n\select aav${attribute_id}.object_id\n from ams_attribute_values aav${attribute_id}, ams_numbers an${attribute_id}\n where aav${attribute_id}.attribute_id = '${attribute_id}'\n and aav${attribute_id}.value_id = an${attribute_id}.value_id\n and an${attribute_id}.number > '$value' )" + } + less_than { + set output_pretty "[_ contacts.lt_attribute_pretty_is_l]" + set output_code "$revision_id in (\n\select aav${attribute_id}.object_id\n from ams_attribute_values aav${attribute_id}, ams_numbers an${attribute_id}\n where aav${attribute_id}.attribute_id = '${attribute_id}'\n and aav${attribute_id}.value_id = an${attribute_id}.value_id\n and an${attribute_id}.number < '$value' )" + } + } + } + ams_value__time { + set value_pretty [lc_time_fmt $value "%q"] + set interval "$value [string tolower [lindex $var_list 3]]" + switch $operand { + less_than { + set output_pretty "[_ contacts.lt_attribute_pretty_is_l_1]" + set output_code "$revision_id in (\n\select aav${attribute_id}.object_id\n from ams_attribute_values aav${attribute_id}, ams_times at${attribute_id}\n where aav${attribute_id}.attribute_id = '${attribute_id}'\n and aav${attribute_id}.value_id = at${attribute_id}.value_id\n and at${attribute_id}.time > ( now() - '$interval'::interval ) )" + } + more_than { + set output_pretty "[_ contacts.lt_attribute_pretty_is_l_1]" + set output_code "$revision_id in (\n\select aav${attribute_id}.object_id\n from ams_attribute_values aav${attribute_id}, ams_times at${attribute_id}\n where aav${attribute_id}.attribute_id = '${attribute_id}'\n and aav${attribute_id}.value_id = at${attribute_id}.value_id\n and at${attribute_id}.time < ( now() - '$interval'::interval ) )" + } + after { + # + # its a lot cleaner to not try and do a hack as below to get the date formatted in a lang key, instead change the key to use value_pretty + # + set value_pretty [lc_time_fmt $value "%q"] + set output_pretty "[_ contacts.lt_attribute_pretty_is_a]" + # We need to evalute the date_part since the i18N message doesn't + # execute the tcl code. +# regexp -nocase {lc_time_fmt [0-9]*-[0-9]*-[0-9]* %[a-z]*} $output_pretty date_part +# set date_result [eval $date_part] +# regsub -nocase {\[lc_time_fmt [0-9]*-[0-9]*-[0-9]* %[a-z]*\]} $output_pretty $date_result output_pretty + + set output_code "$revision_id in (\n\select aav${attribute_id}.object_id\n from ams_attribute_values aav${attribute_id}, ams_times at${attribute_id}\n where aav${attribute_id}.attribute_id = '${attribute_id}'\n and aav${attribute_id}.value_id = at${attribute_id}.value_id\n and at${attribute_id}.time > '$value'::timestamptz )" + } + before { + # + # its a lot cleaner to not try and do a hack as below to get the date formatted in a lang key, instead change the key to use value_pretty + # + set value_pretty [lc_time_fmt $value "%q"] + # We need to evalute the date_part since the i18N message doesn't + # execute the tcl code. + set output_pretty "[_ contacts.lt_attribute_pretty_is_a]" +# regexp -nocase {lc_time_fmt [0-9]*-[0-9]*-[0-9]* %[a-z]*} $output_pretty date_part +# set date_result [eval $date_part] +# regsub -nocase {\[lc_time_fmt [0-9]*-[0-9]*-[0-9]* %[a-z]*\]} $output_pretty $date_result output_pretty + set output_code "$revision_id in (\n\select aav${attribute_id}.object_id\n from ams_attribute_values aav${attribute_id}, ams_times at${attribute_id}\n where aav${attribute_id}.attribute_id = '${attribute_id}'\n and aav${attribute_id}.value_id = at${attribute_id}.value_id\n and at${attribute_id}.time < '$value'::timestamptz )" + } + } + } + } + } + } + + if { $request == "pretty" } { + return $output_pretty + } else { + return $output_code + } + } + type_name { + return [_ contacts.Attribute] + } + } +} + + + + + + + + + + + + + + + + +ad_proc -private contacts::search::condition_type::contact { + -request:required + {-var_list ""} + {-form_name ""} + {-party_id ""} + {-revision_id ""} + {-prefix "contact"} + {-object_type ""} +} { + Return all widget procs. Each list element is a list of the first then pretty_name then the widget +} { + set operand [ns_queryget "${prefix}operand"] + set var1 "${prefix}${operand}var1" + set var2 "${prefix}${operand}var2" + set ${var1} [ns_queryget ${var1}] + set ${var2} [ns_queryget ${var2}] + + switch $request { + ad_form_widgets { + + set form_elements [list] + set contact_options [list \ + [list "[_ contacts.in_the_search] ->" "in_search"] \ + [list "[_ contacts.not_in_the_search] ->" "not_in_search"] \ + [list "[_ contacts.lt_updated_in_the_last_-]" "update"] \ + [list "[_ contacts.lt_not_updated_in_the_la]" "not_update"] \ + [list "[_ contacts.lt_commented_on_in_last_]" "comment"] \ + [list "[_ contacts.lt_not_commented_on_in_l]" "not_comment"] \ + [list "[_ contacts.lt_created_in_the_last_-]" "created"] \ + [list "[_ contacts.lt_not_created_in_the_la]" "not_created"] \ + ] + if { $object_type == "person" } { + lappend contact_options [list "[_ contacts.has_logged_in]" "login"] + lappend contact_options [list "[_ contacts.has_never_logged_in]" "not_login"] + lappend contact_options [list "[_ contacts.lt_has_logged_in_within_]" "login_time"] + lappend contact_options [list "[_ contacts.lt_has_not_logged_in_wit]" "not_login_time"] + } + lappend form_elements [list \ + ${prefix}operand:text(select) \ + [list label {}] \ + [list options $contact_options] \ + [list html [list onChange "javascript:acs_FormRefresh('$form_name')"]] \ + ] + + # login and not_login do not need special elements + if { [lsearch [list in_search not_in_search] ${operand}] >= 0 || ${operand} == "" } { + set user_id [ad_conn user_id] + set search_options [db_list_of_lists get_my_searches { + select title, + search_id + from contact_searches + where owner_id = :user_id + and title is not null + and not deleted_p + order by lower(title) + }] + set search_options [concat [list [list "" ""]] $search_options] + lappend form_elements [list \ + ${var1}:integer(select) \ + [list label {}] \ + [list options $search_options] \ + ] + } else { + set interval_options [list \ + [list days days] \ + [list months months] \ + [list years years] \ + ] + lappend form_elements [list ${var1}:integer(text) [list label {}] [list html [list size 3 maxlength 4]]] + lappend form_elements [list ${var2}:text(select) [list label {}] [list options $interval_options]] + } + return $form_elements + } + form_var_list { + if { [exists_and_not_null operand] } { + switch ${operand} { + login - not_login { + return [set ${operand}] + } + in_search - not_in_search { + if { [exists_and_not_null ${var1}] } { + return [list ${operand} [set ${var1}]] + } + } + default { + if { [exists_and_not_null ${var1}] && [exists_and_not_null ${var2}] } { + return [list ${operand} [set ${var1}] [set ${var2}]] + } + } + } + } + } + sql - pretty { + set operand [lindex $var_list 0] + set interval "[lindex $var_list 1] [lindex $var_list 2]" + switch $operand { + in_search { + set search_id [lindex $var_list 1] + set search_link "[contact::search::title -search_id $search_id]" + set output_pretty "[_ contacts.lt_Contact_in_the_search_search_link]" + set output_code [contact::party_id_in_sub_search_clause -search_id $search_id] + } + not_in_search { + set search_id [lindex $var_list 1] + set search_link "[contact::search::title -search_id $search_id]" + set output_pretty "[_ contacts.lt_Contact_not_in_the_search_search_link]" + set output_code [contact::party_id_in_sub_search_clause -search_id $search_id -not] + } + update { + set output_pretty "[_ contacts.lt_Contact_updated_in_th]" + set output_code "CASE WHEN ( select creation_date from acs_objects where object_id = $revision_id ) > ( now() - '$interval'::interval ) THEN 't'::boolean ELSE 'f'::boolean END" + } + not_update { + set output_pretty "[_ contacts.lt_Contact_not_updated_i]" + set output_code "CASE WHEN ( select creation_date from acs_objects where object_id = $revision_id ) > ( now() - '$interval'::interval ) THEN 'f'::boolean ELSE 't'::boolean END" + } + comment { + set output_pretty "[_ contacts.lt_Contact_commented_on_]" + set output_code "CASE WHEN (select creation_date from acs_objects where object_id in ( select comment_id from general_comments where object_id = $party_id ) order by creation_date desc limit 1 ) > ( now() - '$interval'::interval ) THEN 't'::boolean ELSE 'f'::boolean END" + } + not_comment { + set output_pretty "[_ contacts.lt_Contact_not_commented]" + set output_code "CASE WHEN (select creation_date from acs_objects where object_id in ( select comment_id from general_comments where object_id = $party_id ) order by creation_date desc limit 1 ) > ( now() - '$interval'::interval ) THEN 'f'::boolean ELSE 't'::boolean END" + } + created { + set output_pretty "[_ contacts.lt_Contact_created_in_th]" + set output_code "CASE WHEN ( select acs_objects.creation_date from acs_objects where acs_objects.object_id = $party_id ) > ( now() - '$interval'::interval ) THEN 't'::boolean ELSE 'f'::boolean END" + } + not_created { + set output_pretty "[_ contacts.lt_Contact_not_created_i]" + set output_code "CASE WHEN ( select acs_objects.creation_date from acs_objects where acs_objects.object_id = $party_id ) > ( now() - '$interval'::interval ) THEN 'f'::boolean ELSE 't'::boolean END" + } + login { + set output_pretty "[_ contacts.lt_Contact_has_logged_in]" + set output_code "CASE WHEN ( select n_sessions from users where user_id = $party_id ) > 1 or ( select last_visit from users where user_id = $party_id ) is not null THEN 't'::boolean ELSE 'f'::boolean END" + } + not_login { + set output_pretty "[_ contacts.lt_Contact_has_never_log]" + set output_code "CASE WHEN ( select n_sessions from users where user_id = $party_id ) > 1 or ( select last_visit from users where user_id = $party_id ) is not null THEN 'f'::boolean ELSE 't'::boolean END" + } + login_time { + set output_pretty "[_ contacts.lt_Contact_has_logged_in_1]" + set output_code "CASE WHEN ( select last_visit from users where user_id = $party_id ) > ( now() - '$interval'::interval ) THEN 't'::boolean ELSE 'f'::boolean END" + } + not_login_time { + set output_pretty "[_ contacts.lt_Contact_has_not_logge]" + set output_code "CASE WHEN ( select last_visit from users where user_id = $party_id ) > ( now() - '$interval'::interval ) THEN 'f'::boolean ELSE 't'::boolean END" + } + } + if { $request == "pretty" } { + return $output_pretty + } else { + return $output_code + } + } + type_name { + return [_ contacts.Contact] + } + } +} + + + + + +ad_proc -private contacts::search::condition_type::group { + -request:required + {-var_list ""} + {-form_name ""} + {-party_id ""} + {-revision_id ""} + {-prefix "contact"} + {-object_type ""} +} { + Return all widget procs. Each list element is a list of the first then pretty_name then the widget +} { + set prefix "contact" + set operand [ns_queryget "${prefix}operand"] + set group_id [ns_queryget "${prefix}group_id"] + + switch $request { + ad_form_widgets { + set form_elements [list] + set operand_options [list \ + [list "[_ contacts.contact_is_in_-]" "in"] \ + [list "[_ contacts.contact_is_not_in_-]" "not_in"] \ + ] + + set group_options [contact::groups -expand "all" -privilege_required "read"] + lappend form_elements [list ${prefix}operand:text(select) [list label {}] [list options $operand_options] [list value $operand]] + lappend form_elements [list ${prefix}group_id:integer(select) [list label {}] [list options $group_options] [list value $group_id]] + return $form_elements + } + form_var_list { + if { [exists_and_not_null operand] && [exists_and_not_null group_id] } { + return [list $operand $group_id] + } else { + return {} + } + } + sql - pretty { + set operand [lindex $var_list 0] + set group_id [lindex $var_list 1] + if { $request == "pretty" } { + set group_pretty [lang::util::localize [db_string select_group_name { select group_name from groups where group_id = :group_id }]] + } else { + set group_pretty "" + } + switch $operand { + in { + set output_pretty "[_ contacts.lt_The_contact_is_in_the]" + set output_code "$party_id in ( select member_id from group_distinct_member_map where group_id = '$group_id')" + } + not_in { + set output_pretty "[_ contacts.lt_The_contact_is_NOT_in]" + set output_code "$party_id not in ( select member_id from group_distinct_member_map where group_id = '$group_id')" + } + } + if { $request == "pretty" } { + return $output_pretty + } else { + return $output_code + } + } + type_name { + return [_ contacts.Group] + } + } +} + + + +ad_proc -private contacts::search::condition_type::relationship { + -request:required + {-var_list ""} + {-form_name ""} + {-party_id ""} + {-revision_id ""} + {-prefix "contact"} + {-object_type ""} +} { + Return all widget procs. Each list element is a list of the first then pretty_name then the widget +} { + set role [ns_queryget "${prefix}role"] + set operand [ns_queryget "${prefix}operand"] + set times [ns_queryget "${prefix}${role}times"] + set search_id [ns_queryget "${prefix}${role}search_id"] + + if { ![exists_and_not_null object_type] } { + set object_type "party" + } + switch $request { + ad_form_widgets { + set form_elements [list] + + set rel_options [db_list_of_lists get_rels { +select acs_rel_type__role_pretty_name(primary_role) as pretty_name, + primary_role as role + from contact_rel_types + where secondary_object_type in ( :object_type, 'party' ) + group by primary_role + order by upper(acs_rel_type__role_pretty_name(primary_role)) + }] + set rel_options [ams::util::localize_and_sort_list_of_lists -list $rel_options] + set rel_options [concat [list [list "" ""]] $rel_options] + lappend form_elements [list \ + ${prefix}role:text(select) \ + [list label [_ contacts.with]] \ + [list options $rel_options] \ + ] + + set operand_options [list \ + [list "[_ contacts.exists]" "exists"] \ + [list "[_ contacts.does_not_exists]" "not_exists"] \ + [list "[_ contacts.in_the_search] ->" "in_search"] \ + [list "[_ contacts.not_in_the_search] ->" "not_in_search"] \ + ] + +# [list "[_ contacts.exists_at_least] ->" "min_number"] \ +# [list "[_ contacts.exists_at_most] ->" "max_number"] \ + + lappend form_elements [list \ + ${prefix}operand:text(select),optional \ + [list label {}] \ + [list options $operand_options] \ + [list html [list onChange "javascript:acs_FormRefresh('$form_name')"]] \ + ] + + # login and not_login do not need special elements + switch $operand { + min_number - max_number { + lappend form_elements [list ${prefix}${role}times:integer(text) [list label {}] [list html [list size 2 maxlength 4]] [list after_html [_ contacts.Times]]] + } + in_search - not_in_search { + set user_id [ad_conn user_id] + set search_options [db_list_of_lists get_my_searches { + select title, + search_id + from contact_searches + where owner_id = :user_id + and title is not null + and not deleted_p + order by lower(title) + }] + set search_options [concat [list [list "" ""]] $search_options] + lappend form_elements [list \ + ${prefix}${role}search_id:integer(select) \ + [list label {}] \ + [list options $search_options] \ + ] + } + } + return $form_elements + } + form_var_list { + if { [exists_and_not_null role] && [exists_and_not_null operand] } { + set results [list $role $operand] + switch $operand { + min_number - max_number { + if { [exists_and_not_null times] } { + lappend results $times + } else { + set not_complete_p 1 + } + } + in_search - not_in_search { + if { [exists_and_not_null search_id] } { + lappend results $search_id + } else { + set not_complete_p 1 + } + } + } + if { ![exists_and_not_null not_complete_p] } { + return $results + } + } + return {} + } + sql - pretty { + set role [lindex $var_list 0] + set union " +( +( select object_id_one as party_id + from acs_rels where rel_type in ( select rel_type + from acs_rel_types + where rel_type in ( select object_type + from acs_object_types + where supertype = 'contact_rel' ) + and role_two = '$role' ) ) +union +( select object_id_two as party_id + from acs_rels where rel_type in ( select rel_type + from acs_rel_types + where rel_type in ( select object_type + from acs_object_types + where supertype = 'contact_rel' ) + and role_one = '$role' ) ) +) +" + set union_reverse " +( +( select object_id_two as party_id + from acs_rels where rel_type in ( select rel_type + from acs_rel_types + where rel_type in ( select object_type + from acs_object_types + where supertype = 'contact_rel' ) + and role_two = '$role' ) ) +union +( select object_id_one as party_id + from acs_rels where rel_type in ( select rel_type + from acs_rel_types + where rel_type in ( select object_type + from acs_object_types + where supertype = 'contact_rel' ) + and role_one = '$role' ) ) +) +" + + + set operand [lindex $var_list 1] + switch $operand { + min_number - max_number { set times [lindex $var_list 2] } + in_search - not_in_search { set search_id [lindex $var_list 2] } + } + if { $request == "pretty" } { + if { [exists_and_not_null times] } { + if { $times != 1 } { + set role [lang::util::localize [db_string get_pretty_role { select pretty_plural from acs_rel_roles where role = :role } -default {}]] + } else { + set role [lang::util::localize [db_string get_pretty_role { select pretty_name from acs_rel_roles where role = :role } -default {}]] + } + } else { + set role [lang::util::localize [db_string get_pretty_role { select pretty_name from acs_rel_roles where role = :role } -default {}]] + } + } else { + set role "" + } + switch $operand { + exists { + set output_pretty [_ contacts.lt_role_exists] + set output_code "party_id in $union" + } + not_exists { + set output_pretty [_ contacts.lt_role_not_exists] + set output_code "party_id not in $union" + } + max_number { + set output_pretty [_ contacts.lt_At_most_times_role_are_related] + set output_code "party_id in +( select party_id from +( +select count(party_id) as rel_count, party_id from +$union_reverse rels +group by party_id +) rel_count_and_id +where rel_count <= $times )" + } + min_number { + set output_pretty [_ contacts.lt_At_least_times_role_are_related] + set output_code "party_id in +( select party_id from +( +select count(party_id) as rel_count, party_id from +$union_reverse rels +group by party_id +) rel_count_and_id +where rel_count >= $times )" + } + in_search { + set role [lindex $var_list 0] + set search_link "[contact::search::title -search_id $search_id]" + set output_pretty [_ contacts.lt_role_in_the_search_search_link] + set output_code " +party_id in ( select CASE WHEN acs_rel_types.role_two = '$role' THEN acs_rels.object_id_one ELSE acs_rels.object_id_two END as party_id + from acs_rels, acs_rel_types + where acs_rels.rel_type = acs_rel_types.rel_type + and acs_rel_types.rel_type in ( select object_type from acs_object_types where supertype = 'contact_rel' ) + and ( acs_rel_types.role_two = '$role' or acs_rel_types.role_one = '$role' ) + and [contact::party_id_in_sub_search_clause -search_id $search_id -party_id "CASE WHEN acs_rel_types.role_two = '$role' THEN acs_rels.object_id_two ELSE acs_rels.object_id_one END"] + ) +" + + } + not_in_search { + set role [lindex $var_list 0] + set search_link "[contact::search::title -search_id $search_id]" + set output_pretty [_ contacts.lt_role_not_in_the_search_search_link] + set output_code " +party_id in ( select CASE WHEN acs_rel_types.role_two = '$role' THEN acs_rels.object_id_one ELSE acs_rels.object_id_two END as party_id + from acs_rels, acs_rel_types + where acs_rels.rel_type = acs_rel_types.rel_type + and acs_rel_types.rel_type in ( select object_type from acs_object_types where supertype = 'contact_rel' ) + and ( acs_rel_types.role_two = '$role' or acs_rel_types.role_one = '$role' ) + and [contact::party_id_in_sub_search_clause -not -search_id $search_id -party_id "CASE WHEN acs_rel_types.role_two = '$role' THEN acs_rels.object_id_two ELSE acs_rels.object_id_one END"] + ) +" + } + } + if { $request == "pretty" } { + return $output_pretty + } else { + return $output_code + } + } + type_name { + return [_ contacts.Relationship] + } + } +} + + + + + Index: openacs-4/packages/contacts/tcl/contact-search-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/tcl/contact-search-procs.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/tcl/contact-search-procs.tcl 30 Nov 2005 15:31:01 -0000 1.19.2.2 @@ -0,0 +1,502 @@ +ad_library { + + Support procs for the contacts package + + @author Matthew Geddert openacs@geddert.com + @creation-date 2004-07-28 + @cvs-id $Id: contact-search-procs.tcl,v 1.19.2.2 2005/11/30 15:31:01 miguelm Exp $ + +} + +namespace eval contact:: {} +namespace eval contact::search:: {} +namespace eval contact::search::condition:: {} + + +ad_proc -public contact::search::new { + {-search_id ""} + {-title ""} + {-owner_id ""} + {-all_or_any} + {-object_type} + {-deleted_p "f"} +} { + create a contact search +} { + if { [exists_and_not_null owner_id] } { + set owner_id [ad_conn user_id] + } + set var_list [list \ + [list search_id $search_id] \ + [list title $title] \ + [list owner_id $owner_id] \ + [list all_or_any $all_or_any] \ + [list object_type $object_type] \ + [list deleted_p $deleted_p] \ + ] + + return [package_instantiate_object -var_list $var_list contact_search] +} + +ad_proc -public contact::search::title { + {-search_id ""} +} { +} { + return [db_string select_title {} -default {}] +} + +ad_proc -public contact::search::get { + -search_id:required + -array:required +} { + Get the info on an ams_attribute +} { + upvar 1 $array row + db_1row select_search_info {} -column_array row +} + +ad_proc -public contact::search::update { + {-search_id ""} + {-title ""} + {-owner_id ""} + {-all_or_any} +} { + create a contact search +} { + if { [contact::search::exists_p -search_id $search_id] } { + db_dml update_search { + update contact_searches + set title = :title, + owner_id = :owner_id, + all_or_any = :all_or_any + where search_id = :search_id + } + } +} + +ad_proc -public contact::search::delete { + {-search_id ""} +} { + create a contact search +} { + db_dml delete_it { update contact_searches set deleted_p = 't' where search_id = :search_id } +} + +ad_proc -public contact::search::exists_p { + {-search_id ""} +} { + create a contact search +} { + if { [db_0or1row exists_p { select 1 from contact_searches where search_id = :search_id }] } { + return 1 + } else { + return 0 + } +} + +ad_proc -public contact::search::owner_id { + {-search_id ""} +} { + create a contact search +} { + return [db_string get_owner_id { select owner_id from contact_searches where search_id = :search_id } -default {}] +} + +ad_proc -public contact::search::log { + {-search_id} + {-user_id ""} +} { + log a search +} { + if { ![exists_and_not_null user_id] } { + set user_id [ad_conn user_id] + } + if { [contact::search::exists_p -search_id $search_id] } { + db_1row log_search {} + } +} + +ad_proc -public contact::search::results_count { + {-search_id} + {-query ""} +} { + Get the total number of results from a search. Cached. +} { + return [util_memoize [list ::contact::search::results_count_not_cached -search_id $search_id -query $query]] +} + +ad_proc -public contact::search::flush_all { +} { + Flush everything related to a search +} { + db_foreach get_searches { select search_id from contact_searches } { + contact::search::flush -search_id $search_id + } +} + +ad_proc -public contact::search::flush_results_counts { +} { + Flush everything related to a search +} { + util_memoize_flush_regexp -log "contact::search::results_count_not_cached" +} + +ad_proc -public contact::search::flush { + {-search_id} +} { + Flush everything related to a search +} { + util_memoize_flush_regexp -log "contact::search::results_count_not_cached -search_id $search_id" + util_memoize_flush_regexp -log "contact::search::results_count_not_cached -search_id {}" + util_memoize_flush_regexp -log "contact::search_pretty_not_cached -search_id $search_id" + util_memoize_flush_regexp -log "contact::search::where_clause_not_cached -search_id $search_id" +} + +ad_proc -public contact::search::results_count_not_cached { + {-search_id} + {-query ""} +} { + Get the total number of results from a search +} { + + # If we do not have a search_id, limit the list to only users in the default group. + set type_list [list] + if {[exists_and_not_null search_id]} { + set group_where_clause "" + set type_list [db_list get_condition_type {}] + } else { + set group_where_clause "and group_distinct_member_map.group_id = [contacts::default_group]" + } + + if { [string equal [lsearch -exact $type_list "employees"] "-1"] } { + return [db_string select_results_count {}] + } else { + return [db_string select_employees_results_count {}] + } +} + +ad_proc -private contact::party_id_in_sub_search_clause { + {-search_id} + {-party_id "party_id"} + {-not:boolean} +} { +} { + # If we do not have a search_id, limit the list to only users in the default group. + + if {[exists_and_not_null search_id]} { + set group_where_clause "" + } else { + set group_where_clause "and group_distinct_member_map.group_id = [contacts::default_group]" + } + set query " + select parties.party_id + from parties left join cr_items on (parties.party_id = cr_items.item_id) left join cr_revisions on (cr_items.latest_revision = cr_revisions.revision_id ), + group_distinct_member_map + where parties.party_id = group_distinct_member_map.member_id + $group_where_clause + [contact::search_clause -and -search_id $search_id -query "" -party_id "parties.party_id" -revision_id "revision_id"] + " + if { [exists_and_not_null query] } { + set result ${party_id} + if { $not_p } { + append result " not" + } + append result " in ( $query )" + } else { + set result "" + } + return $result +} + + +ad_proc -public contact::search_clause { + {-and:boolean} + {-search_id} + {-query ""} + {-party_id "party_id"} + {-revision_id "revision_id"} +} { + Get the search clause for a search_id + + @param and Set this flag if you want the result to start with an 'and' if the list of where clauses returned is non-empty. +} { + set query [string trim $query] + set search_clauses [list] + set where_clause [contact::search::where_clause -search_id $search_id -party_id $party_id -revision_id $revision_id] + + if { [exists_and_not_null where_clause] } { + lappend search_clauses $where_clause + } + if { [exists_and_not_null query] } { + lappend search_clauses [contact::search::query_clause -query $query -party_id $party_id] + } + + set result {} + if { [llength $search_clauses] > 0 } { + if { $and_p } { + append result "and " + } + if { [llength $search_clauses] > 1 } { + append result "( [join $search_clauses "\n and "] )" + } else { + append result [join $search_clauses "\n and "] + } + } + return $result +} + + +ad_proc -public contact::search_pretty { + {-search_id} + {-format "text/html"} +} { + Get the search in human readable format. Cached +} { + return [util_memoize [list ::contact::search_pretty_not_cached -search_id $search_id -format $format]] +} + + +ad_proc -public contact::search_pretty_not_cached { + {-search_id} + {-format "text/html"} +} { + Get the search in human readable format +} { + + # the reason we do not put this in the db_foreach statement is because we + # can run into problems with the number of database pools we have when a sub + # query is a condition. We are limited to 3 levels of database access for most + # openacs installs so this bypasses that problem + set db_conditions [db_list_of_lists select_conditions {}] + set conditions [list] + foreach condition $db_conditions { + if { ![string equal [lindex $condition 0] "employees"] } { + lappend conditions [contacts::search::condition_type \ + -type [lindex $condition 0] \ + -request pretty \ + -var_list [lindex $condition 1] \ + ] + } else { + lappend conditions employees + } + } + + + if { [llength $conditions] > 0 } { + + contact::search::get -search_id $search_id -array "search_info" + + if { $search_info(object_type) == "person" } { + set object_type [_ contacts.people] + } elseif { $search_info(object_type) == "organization" } { + set object_type [_ contacts.organizations] + } else { + set object_type [_ contacts.people_or_organizations] + } + + if { [llength conditions] == 1 && [string equal $conditions "employees"] } { + set results "[_ contacts.search_for_employee]" + } else { + set results "[_ contacts.Search_for_all_object_type_where]\n" + } + + if { $search_info(all_or_any) == "all" } { + append results [join $conditions "\n[_ contacts.and] "] + } else { + append results [join $conditions "\n[_ contacts.or] "] + } + + + if { $format == "text/html" } { + set results [ad_enhanced_text_to_html $results] + } else { + set results [ad_enhanced_text_to_plain_text $results] + } + + return $results + } else { + return {} + } +} + + +ad_proc -public contact::search::query_clause { + {-and:boolean} + {-query ""} + {-party_id "party_id"} +} { + create a contact search query. If the query supplied is an integer + it searches for the party_id otherwise the search is for contacts + that match all + + @param and Set this flag if you want the result to start with an 'and' if the list of where clauses returned is non-empty. +} { + set query [string trim $query] + regsub -all "'" $query "''" query + set query_clauses [list] + + # If we have a query, we need to do a subselect with an "in" clause. + # We are assuming that people usually want to get a small number of the + # base for the selection, therefore the subselects will return a very small + # number of rows, justifying the union cum in clause. + if { [string is integer $query] } { + lappend query_clauses "$party_id = $query" + } elseif { [exists_and_not_null query] } { + foreach term $query { + + # We want to enable searches with "*", to select all users who's + # last_name starts with "Ab", searching for "Ab*" + # For this we check if the term starts or ends with "*" and if yes + # we do a regsub to replace the "*" with "%" for reuse in SQL + if {[string length [string trim $term "*"]] == [string length $term]} { + set term_clause "%${term}%" + } else { + regsub -all "*" $term "%" term + } + + lappend query_clauses "party_id in (select organization_id from organizations where upper(organizations.name) like upper('%${term}%') union select person_id from persons where upper(last_name) like upper('%${term}%') or upper(first_names) like upper ('%${term}%'))" + } + } + + set result {} + if { [llength $query_clauses] > 0 } { + if { $and_p } { + append result "and " + } + if { [llength $query_clauses] > 1 } { + append result "( [join $query_clauses "\n and "] )" + } else { + append result [join $query_clauses "\n and "] + } + } + return $result +} + +ad_proc -public contact::search::condition::new { + {-search_id} + {-type} + {-var_list} +} { + create a contact search +} { + if { [string is false [contact::search::condition::exists_p -search_id $search_id -type $type -var_list $var_list]] } { + db_dml insert_condition { + insert into contact_search_conditions + ( condition_id, search_id, type, var_list ) + values + ( (select acs_object_id_seq.nextval), :search_id, :type, :var_list ) + } + } +} + + +ad_proc -public contact::search::condition::delete { + {-condition_id} +} { + create a contact search +} { + db_dml insert_condition { + delete from contact_search_conditions where condition_id = :condition_id + } +} + +ad_proc -public contact::search::condition::exists_p { + {-search_id} + {-type} + {-var_list} +} { +} { + if { [db_0or1row exists_p { select 1 from contact_search_conditions where search_id = :search_id and type = :type and var_list = :var_list }] } { + return 1 + } else { + return 0 + } +} + + + + +ad_proc -public contact::search::where_clause { + {-search_id} + {-and:boolean} + {-party_id} + {-revision_id} +} { +} { + if { $and_p } { + return [util_memoize [list ::contact::search::where_clause_not_cached \ + -search_id $search_id \ + -and \ + -party_id $party_id \ + -revision_id $revision_id]] + } else { + return [util_memoize [list ::contact::search::where_clause_not_cached \ + -search_id $search_id \ + -party_id $party_id \ + -revision_id $revision_id]] + } +} + +ad_proc -public contact::search::where_clause_not_cached { + {-search_id} + {-and:boolean} + {-party_id} + {-revision_id} +} { +} { + db_0or1row get_search_info {} + set where_clauses [list] + + if { [exists_and_not_null all_or_any] } { + set result {} + if { $object_type == "person" } { + append result "$party_id = persons.person_id\n" + } elseif { $object_type == "organization" } { + append result "$party_id = organizations.organization_id\n" + } + + # the reason we do not put this in the db_foreach statement is because we + # can run into problems with the number of database pools we have when a sub + # query is a condition. We are limited to 3 levels of database access for most + # openacs installs so this bypasses that problem + set db_conditions [db_list_of_lists select_queries {}] + foreach condition $db_conditions { + lappend where_clauses [contacts::search::condition_type \ + -type [lindex $condition 0] \ + -request sql \ + -var_list [lindex $condition 1] \ + -revision_id $revision_id \ + -party_id $party_id \ + ] + } + + + if { [llength $where_clauses] > 0 } { + if { $all_or_any == "any" } { + set operator "or" + } else { + set operator "and" + } + if { [exists_and_not_null result] } { + append result " and " + } + if { [llength $where_clauses] > 1 } { + append result "( [join $where_clauses "\n $operator "] )" + } else { + append result [lindex $where_clauses 0] + } + } + + if { [exists_and_not_null result] } { + set result "( $result )" + if { $and_p } { + set result "and $result" + } + } + } else { + set result {} + } + + return $result +} + Index: openacs-4/packages/contacts/tcl/contact-search-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/tcl/contact-search-procs.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/tcl/contact-search-procs.xql 30 Nov 2005 15:31:01 -0000 1.9.2.2 @@ -0,0 +1,88 @@ + + + + + + select contact_search__log(:search_id,:user_id) + + + + + + select title + from contact_searches + where search_id = :search_id + + + + + + select * + from contact_searches + where search_id = :search_id + + + + + + + select type, + var_list + from contact_search_conditions + where search_id = :search_id + + + + + + select count(distinct party_id) + from parties left join cr_items on (parties.party_id = cr_items.item_id) left join cr_revisions on (cr_items.latest_revision = cr_revisions.revision_id ) , group_distinct_member_map + where parties.party_id = group_distinct_member_map.member_id + $group_where_clause + [contact::search_clause -and -search_id $search_id -query $query -party_id "parties.party_id" -revision_id "revision_id"] + + + + + + select + distinct type + from + contact_search_conditions + where + search_id = :search_id + + + + + + select + count(object_id_one) + from + acs_rels + where + rel_type = 'contact_rels_employment' + + + + + + select title, + owner_id, + all_or_any, + object_type + from contact_searches + where search_id = :search_id + + + + + + select type, + var_list + from contact_search_conditions + where search_id = :search_id + + + + Index: openacs-4/packages/contacts/tcl/contacts-callback-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/tcl/contacts-callback-procs.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/tcl/contacts-callback-procs.tcl 30 Nov 2005 15:31:01 -0000 1.20.2.2 @@ -0,0 +1,241 @@ +# packages/contacts/tcl/contacts-callback-procs.tcl + +ad_library { + + Callback procs for contacts + + @author Malte Sussdorff (sussdorff@sussdorff.de) + @creation-date 2005-06-15 + @arch-tag: 4267c818-0019-4222-8a50-64edbe7563d1 + @cvs-id $Id: contacts-callback-procs.tcl,v 1.20.2.2 2005/11/30 15:31:01 miguelm Exp $ +} + + +ad_proc -public -callback contact::contact_form { + {-package_id:required} + {-form:required} + {-object_type:required} + {-party_id} + {-group_ids ""} +} { +} + +ad_proc -public -callback contact::contact_form_validate { + {-package_id:required} + {-form:required} + {-object_type:required} + {-party_id} +} { +} + +ad_proc -public -callback contact::organization_new { + {-package_id:required} + {-contact_id:required} + {-name:required} +} { +} + +ad_proc -public -callback contact::person_add { + {-package_id:required} + {-person_id:required} +} { +} + +ad_proc -public -callback contact::person_new_group { + {-person_id:required} + {-group_id:required} +} { + This is a callback that is executed when you add a new person to a group. + This will enable other packages to check if the person is added into a special group and then + do something with them accordingly. +} - + +ad_proc -public -callback contact::organization_new_group { + {-organization_id:required} + {-group_id:required} +} { + This is a callback that is executed when you add a new organization to a group. + This will enable other packages to check if the organization is added into a special group and then + do something with them accordingly. +} - + +ad_proc -public -callback contact::person_new_rel { + {-party_id:required} + {-object_id_two:required} + {-rel_type:required} +} { + This is a callback that is executed when you add a new person in a relationship to an organization. + This will enable other packages to check if the person is added into a special relationship with the + organization and then do something with them accordingly. +} - + +ad_proc -public -callback contact::organization_new_rel { + {-party_id:required} + {-object_id_two:required} + {-rel_type:required} +} { + This is a callback that is executed when you add a new organization in a relationship. + This will enable other packages to check if the organization is added into a special relationship + and then do something with them accordingly. +} - + +ad_proc -public -callback contact::history { + {-party_id:required} + {-multirow:required} + {-truncate_len ""} +} { +} + +ad_proc -public -callback contacts::bulk_actions { + {-multirow:required} +} { +} + +ad_proc -public -callback contacts::email_subject { + {-folder_id:required} +} { +} + +ad_proc -public -callback contact::append_attribute { + {-multirow_name:required} + {-name:required} +} { +} + +ad_proc -public -callback contact::after_instantiate { + {-package_id:required} +} { +} + +ad_proc -public -callback pm::project_new -impl contacts { + {-package_id:required} + {-project_id:required} + {-data:required} +} { + map selected organization to new project +} { + array set callback_data $data + set project_rev_id [pm::project::get_project_id \ + -project_item_id $project_id] + + if {[exists_and_not_null callback_data(organization_id)]} { + application_data_link::new -this_object_id $project_rev_id -target_object_id $callback_data(organization_id) + } +} + +ad_proc -public -callback pm::project_edit -impl contacts { + {-package_id:required} + {-project_id:required} + {-data:required} +} { + map selected organization to updated project +} { + array set callback_data $data + set project_rev_id [pm::project::get_project_id \ + -project_item_id $project_id] + + if {[exists_and_not_null callback_data(organization_id)]} { + application_data_link::new -this_object_id $project_rev_id -target_object_id $callback_data(organization_id) + } +} + +ad_proc -public -callback fs::folder_chunk::add_bulk_actions -impl contacts { + {-bulk_variable:required} + {-folder_id:required} + {-var_export_list:required} +} { + Callback to add a bulk action for sending a mail to the contact with the files attached that are mapped in the folder view + If you have an organization, all persons related to it will be added to the mail sending as well. + + @author Malte Sussdorff (sussdorff@sussdorff.de) + @creation-date 2005-06-15 + + @param bulk_variable The name of the variable to upvar for extending the bulk variable list + + @return + + @error +} { + set community_id [dotlrn_community::get_community_id] + + # Try to retrieve the project_id from the folder + set project_id [db_string get_project_id_from_folder { + select r.object_id_two as project_id + from acs_rels r, cr_items i, cr_items p + where i.item_id = :folder_id + and r.object_id_one = i.parent_id + and r.rel_type = 'application_data_link' + and r.object_id_two = p.item_id + and p.content_type = 'pm_project' + } -default ""] + + if {[empty_string_p $project_id]} { + # no project -> mail to all organization contacts + set contact_organizations [application_data_link::get_linked -from_object_id $community_id -to_object_type "organization"] + set contact_list "" + foreach party_id $contact_organizations { + set contact_list [concat $contact_list [contact::util::get_employees -organization_id $party_id]] + } + } else { + # project -> mail to project contact + db_1row get_project_contact { + select p.contact_id as contact_list + from pm_projects p, cr_items i + where i.latest_revision = p.project_id + and i.item_id = :project_id + } + } + + # A lot of upvar magic is used here to set the variables in the folder-chunk.tcl + # context. + if {[exists_and_not_null contact_list]} { + upvar $bulk_variable local_var + upvar $var_export_list local_list + upvar party_ids contact_ids_loc + set contact_ids_loc $contact_list + + lappend local_var "[_ contacts.Mail_to_contact]" "/contacts/message" "[_ contacts.Mail_to_contact]" + lappend local_list "party_ids" + + # Add the message type automatically + # lappend local_list "message_type" + # upvar message_type message_type_loc + # set message_type_loc "email" + + if {![empty_string_p $project_id]} { + lappend local_list "context_id" + upvar context_id context_id + set context_id $project_id + } + } +} + + +ad_proc -public -callback dotlrn_community::add_members -impl contacts_employees { + {-community_id} +} { + Callback to add the employees of an organization to the club as members + + @author Malte Sussdorff (sussdorff@sussdorff.de) + @creation-date 2005-06-15 + + @param community_id The ID of the community + + @return + + @error +} { + + # Get list of employees and register them within the community + set organization_id [lindex [application_data_link::get_linked -from_object_id $community_id -to_object_type "organization"] 0] + + set employee_list [contact::util::get_employees -organization_id $organization_id] + foreach employee_id $employee_list { + # Only add the user if the user is already in the system as a user, not a person. + if {[contact::user_p $employee_id]} { + # Just to be on the save side, we actually check if the user is already in .LRN + dotlrn::user_add -user_id $employee_id + dotlrn_club::add_user -community_id $club_id -user_id $employee_id + } + } +} \ No newline at end of file Index: openacs-4/packages/contacts/tcl/contacts-init.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/tcl/contacts-init.tcl,v diff -u -N -r1.2 -r1.2.2.1 --- openacs-4/packages/contacts/tcl/contacts-init.tcl 13 Jan 2005 13:57:02 -0000 1.2 +++ openacs-4/packages/contacts/tcl/contacts-init.tcl 30 Nov 2005 15:31:01 -0000 1.2.2.1 @@ -1,11 +1,117 @@ ad_library { - + Init file for contacts - + @author Matthew Geddert (openacs@geddert.com) @creation-date 2004-08-16 - @cvs-id $Id$ } -# set up contacts -contacts::view::init +if {[empty_string_p [info procs callback]]} { + + ns_log notice "CONTACTS: callback proc didn't exist so we are adding it here" + ad_proc -public callback { + -catch:boolean + {-impl *} + callback + args + } { + Placeholder for contacts to work on 5.1 + } { + } +} + + +if { [empty_string_p [info procs rel_types::create_role]] } { + + ns_log notice "CONTACTS: rel_types::create_role proc didn't exist so we are adding it here" + namespace eval rel_types {} + ad_proc -public rel_types::create_role { + {-pretty_name:required} + {-pretty_plural:required} + {-role} + } { + + Create a new Relationship Role + + @author Malte Sussdorff (sussdorff@sussdorff.de) + @creation-date 2005-06-04 + + @param pretty_name + + @param pretty_plural + + @param role + + @return 1 if successful + } { + if {![exists_and_not_null role]} { + set role [util_text_to_url \ + -text $pretty_name \ + -replacement "_" \ + -existing_urls [db_list get_roles {}]] + } + + set return_code 1 + + db_transaction { + + # Force internationalisation of Roles + + # Internationalising of Attributes. This is done by storing the + # attribute with it's acs-lang key + + set message_key "role_${role}" + + # Register the language keys + + lang::message::register en_US contacts $message_key $pretty_name + lang::message::register en_US contacts "${message_key}_plural" $pretty_plural + + # Replace the pretty_name and pretty_plural with the message key, so + # it is inserted correctly in the database + + set pretty_name "#contacts.${message_key}#" + set pretty_plural "#contacts.${message_key}_plural#" + db_exec_plsql create_role { + select acs_rel_type__create_role(:role, :pretty_name, :pretty_plural) + } + } on_error { + error $errmsg + set return_code 0 + } + return $return_code + } + + +} + + +if {[empty_string_p [info procs application_data_link::get_linked]]} { + + ns_log notice "CONTACTS: application_data_link::get_linked proc didn't exist so we are adding it here" + namespace eval application_data_link {} + ad_proc -public application_data_link::get_linked { + args + } { + Placeholder for contacts to work on 5.1 + } { + return {} + } + +} + +if {[empty_string_p [info procs application_link::get_linked]]} { + + ns_log notice "CONTACTS: application_link::get_linked proc didn't exist so we are adding it here" + namespace eval application_link {} + ad_proc -public application_link::get_linked { + args + } { + Placeholder for contacts to work on 5.1 + } { + return {} + } + +} + + Index: openacs-4/packages/contacts/tcl/contacts-install-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/tcl/contacts-install-procs.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/tcl/contacts-install-procs.tcl 30 Nov 2005 15:31:01 -0000 1.16.2.2 @@ -0,0 +1,464 @@ +ad_library { + + Contacts install library + + Procedures that deal with installing, instantiating, mounting. + + @creation-date 2005-05-26 + @author Timo Hentschel (timo@timohentschel.de) + @cvs-id $Id: contacts-install-procs.tcl,v 1.16.2.2 2005/11/30 15:31:01 miguelm Exp $ +} + +namespace eval contacts::install {} + + +ad_proc -public contacts::install::package_install { +} { + @author Malte Sussdorff (sussdorff@sussdorff.de) + @creation-date 2005-06-04 + + @return + + @error +} { + + # Register Relationships + + rel_types::new -table_name "contact_rels" -create_table_p "f" \ + "contact_rel" \ + "[_ contacts.Contact_Relationship]" \ + "[_ contacts.lt_Contact_Relationships]" \ + "party" \ + "0" \ + "" \ + "party" \ + "0" \ + "" + + rel_types::create_role -role "organization" -pretty_name "[_ contacts.Organization]" -pretty_plural "[_ contacts.Organizations]" + + rel_types::new -table_name "organization_rels" -create_table_p "f" \ + "organization_rel" \ + "[_ contacts.lt_Organization_Relation]" \ + "[_ contacts.lt_Organization_Relation_1]" \ + "group" \ + "0" \ + "" \ + "organization" \ + "0" \ + "" + + rel_types::create_role -role "employee" -pretty_name "[_ contacts.Employee]" -pretty_plural "[_ contacts.Employees]" + rel_types::create_role -role "employer" -pretty_name "[_ contacts.Employer]" -pretty_plural "[_ contacts.Employers]" + rel_types::new -table_name "contact_rel_employment" -create_table_p "t" -supertype "contact_rel" -role_one "employee" -role_two "employer" \ + "contact_rels_employment" \ + "[_ contacts.lt_Contact_Rel_Employmen]" \ + "[_ contacts.lt_Contact_Rels_Employme]" \ + "person" \ + "0" \ + "" \ + "organization" \ + "0" \ + "" + + # Creation of contact_complaint_track table + content::type::new -content_type "contact_complaint" \ + -pretty_name "Contact Complaint" \ + -pretty_plural "Contact Complaints" \ + -table_name "contact_complaint_track" \ + -id_column "complaint_id" + + # now set up the attributes that by default we need for the complaints + content::type::attribute::new \ + -content_type "contact_complaint" \ + -attribute_name "customer_id" \ + -datatype "integer" \ + -pretty_name "Customer ID" \ + -sort_order 1 \ + -column_spec "integer constraint contact_complaint_track_customer_fk + references parties(party_id) on delete cascade" + + content::type::attribute::new \ + -content_type "contact_complaint" \ + -attribute_name "turnover" \ + -datatype "money" \ + -pretty_name "Turnover" \ + -sort_order 2 \ + -column_spec "float" + + content::type::attribute::new \ + -content_type "contact_complaint" \ + -attribute_name "percent" \ + -datatype "integer" \ + -pretty_name "Percent" \ + -sort_order 3 \ + -column_spec "integer" + + content::type::attribute::new \ + -content_type "contact_complaint" \ + -attribute_name "supplier_id" \ + -datatype "integer" \ + -pretty_name "Supplier ID" \ + -sort_order 4 \ + -column_spec "integer" + + content::type::attribute::new \ + -content_type "contact_complaint" \ + -attribute_name "paid" \ + -datatype "money" \ + -pretty_name "Paid" \ + -sort_order 5 \ + -column_spec "float" + + content::type::attribute::new \ + -content_type "contact_complaint" \ + -attribute_name "complaint_object_id" \ + -datatype "integer" \ + -pretty_name "Complaint Object ID" \ + -sort_order 6 \ + -column_spec "integer constraint contact_complaint_track_complaint_object_id_fk + references acs_objects(object_id) on delete cascade" + + content::type::attribute::new \ + -content_type "contact_complaint" \ + -attribute_name "state" \ + -datatype "string" \ + -pretty_name "State" \ + -sort_order 7 \ + -column_spec "varchar(7) constraint cct_state_ck + check (state in ('valid','invalid','open'))" + + content::type::attribute::new \ + -content_type "contact_complaint" \ + -attribute_name "employee_id" \ + -datatype "integer" \ + -pretty_name "Employee ID" \ + -sort_order 8 \ + -column_spec "integer constraint contact_complaint_track_employee_fk + references parties(party_id) on delete cascade" + + content::type::attribute::new \ + -content_type "contact_complaint" \ + -attribute_name "refund" \ + -datatype "money" \ + -pretty_name "Refund" \ + -sort_order 9 \ + -column_spec "float" + +} + +ad_proc -public contacts::install::package_instantiate { + {-package_id:required} +} { + + # We want to instantiate the contacts package so that registered + + # users have some attributes mapped by default. This could be extended in custom packages. + + set default_group [contacts::default_group -package_id $package_id] + ams::widgets_init + set list_id [ams::list::new \ + -package_key "contacts" \ + -object_type "person" \ + -list_name "${package_id}__$default_group" \ + -pretty_name "[_ contacts.lt_Person_-_Registered_U]" \ + -description "" \ + -description_mime_type ""] + + set attribute_id [attribute::new \ + -object_type "person" \ + -attribute_name "first_names" \ + -datatype "string" \ + -pretty_name "#acs-translations.person_first_names#" \ + -pretty_plural "#acs-translations.person_first_names_plural#" \ + -table_name "" \ + -column_name "" \ + -default_value "" \ + -min_n_values "0" \ + -max_n_values "1" \ + -sort_order "1" \ + -storage "type_specific" \ + -static_p "f" \ + -if_does_not_exist] + + lang::message::register en_US acs-translations person_last_name "First Names" + lang::message::register en_US acs-translations person_last_name_plural "First Names" + + ams::attribute::new -attribute_id $attribute_id -widget "textbox" -dynamic_p "f" + + ams::list::attribute::map \ + -list_id $list_id \ + -attribute_id $attribute_id \ + -sort_order "1" \ + -required_p "f" \ + -section_heading "" + + set attribute_id [attribute::new \ + -object_type "person" \ + -attribute_name "last_name" \ + -datatype "string" \ + -pretty_name "#acs-translations.person_last_name#" \ + -pretty_plural "#acs-translations.person_last_name_plural#" \ + -table_name "" \ + -column_name "" \ + -default_value "" \ + -min_n_values "0" \ + -max_n_values "1" \ + -sort_order "1" \ + -storage "type_specific" \ + -static_p "f" \ + -if_does_not_exist] + + lang::message::register en_US acs-translations person_first_names "Last Name" + lang::message::register en_US acs-translations person_first_names_plural "Last Names" + + ams::attribute::new -attribute_id $attribute_id -widget "textbox" -dynamic_p "f" + + ams::list::attribute::map \ + -list_id $list_id \ + -attribute_id $attribute_id \ + -sort_order "2" \ + -required_p "f" \ + -section_heading "" + + set attribute_id [attribute::new \ + -object_type "party" \ + -attribute_name "email" \ + -datatype "string" \ + -pretty_name "#acs-translations.party_email#" \ + -pretty_plural "#acs-translations.party_email_plural#" \ + -table_name "" \ + -column_name "" \ + -default_value "" \ + -min_n_values "0" \ + -max_n_values "1" \ + -sort_order "1" \ + -storage "type_specific" \ + -static_p "f" \ + -if_does_not_exist] + + lang::message::register en_US acs-translations party_email "Email Address" + lang::message::register en_US acs-translations party_email_plural "Email Addresses" + + ams::attribute::new -attribute_id $attribute_id -widget "email" -dynamic_p "f" + + ams::list::attribute::map \ + -list_id $list_id \ + -attribute_id $attribute_id \ + -sort_order "3" \ + -required_p "f" \ + -section_heading "" + + # ORGANIZATIONS + + set list_id [ams::list::new \ + -package_key "contacts" \ + -object_type "organization" \ + -list_name "${package_id}__$default_group" \ + -pretty_name "Organization - Registered Users" \ + -description "" \ + -description_mime_type ""] + + set attribute_id [attribute::new \ + -object_type "organization" \ + -attribute_name "name" \ + -datatype "string" \ + -pretty_name "#acs-translations.organization_name#" \ + -pretty_plural "#acs-translations.organization_name_plural#" \ + -table_name "" \ + -column_name "" \ + -default_value "" \ + -min_n_values "1" \ + -max_n_values "1" \ + -sort_order "1" \ + -storage "generic" \ + -static_p "f" \ + -if_does_not_exist] + + lang::message::register en_US acs-translations organization_name "Organization Name" + lang::message::register en_US acs-translations organization_name_plural "Organization Names" + + ams::attribute::new -attribute_id $attribute_id -widget "textbox" -dynamic_p "t" + + ams::list::attribute::map \ + -list_id $list_id \ + -attribute_id $attribute_id \ + -sort_order "1" \ + -required_p "f" \ + -section_heading "" + + # Make the registered users group mapped by default + + contacts::insert_map -group_id "$default_group" -default_p "t" -package_id $package_id +} + +ad_proc -public contacts::install::package_mount { + -package_id + -node_id +} { + + Actions to be executed after mounting the contacts package + + @author Malte Sussdorff (sussdorff@sussdorff.de) + @creation-date 2005-06-04 + + @return + + @error +} { + contacts::populate::crm -package_id $package_id +} + +ad_proc -public contacts::insert_map { + {-group_id:required} + {-default_p:required} + {-package_id:required} +} { + @author Malte Sussdorff (sussdorff@sussdorff.de) + @creation-date 2005-06-03 + + @param group_id + + @param default_p + + @param package_id + + @return + + @error +} { + db_dml insert_map { + insert into contact_groups + (group_id,default_p,package_id) + values + (:group_id,:default_p,:package_id)} +} + +ad_proc -public ::install::xml::action::contacts_pop_crm { + node +} { + Procedure to register the populate crm for the install.xml +} { + set url [apm_required_attribute_value $node url] + array set sn_array [site_node::get -url $url] + contacts::populate::crm -package_id $sn_array(object_id) +} + + +ad_proc -public contacts::install::package_upgrade { + {-from_version_name:required} + {-to_version_name:required} +} { + @author Miguel Marin (miguelmarin@viaro.net) + @author Viaro Networks www.viaro.net + @creation-date 2005-10-05 +} { + apm_upgrade_logic \ + -from_version_name $from_version_name \ + -to_version_name $to_version_name \ + -spec { + 1.0d18 1.0d19 { + + content::type::new -content_type "contact_complaint" \ + -pretty_name "Contact Complaint" \ + -pretty_plural "Contact Complaints" \ + -table_name "contact_complaint_track" \ + -id_column "complaint_id" + + # now set up the attributes that by default we need for the complaints + content::type::attribute::new \ + -content_type "contact_complaint" \ + -attribute_name "customer_id" \ + -datatype "integer" \ + -pretty_name "Customer ID" \ + -sort_order 1 \ + -column_spec "integer constraint contact_complaint_track_customer_fk + references parties(party_id) on delete cascade" + + content::type::attribute::new \ + -content_type "contact_complaint" \ + -attribute_name "turnover" \ + -datatype "money" \ + -pretty_name "Turnover" \ + -sort_order 2 \ + -column_spec "float" + + content::type::attribute::new \ + -content_type "contact_complaint" \ + -attribute_name "percent" \ + -datatype "integer" \ + -pretty_name "Percent" \ + -sort_order 3 \ + -column_spec "integer" + + content::type::attribute::new \ + -content_type "contact_complaint" \ + -attribute_name "supplier_id" \ + -datatype "integer" \ + -pretty_name "Supplier ID" \ + -sort_order 4 \ + -column_spec "integer" + + content::type::attribute::new \ + -content_type "contact_complaint" \ + -attribute_name "paid" \ + -datatype "money" \ + -pretty_name "Paid" \ + -sort_order 5 \ + -column_spec "float" + + content::type::attribute::new \ + -content_type "contact_complaint" \ + -attribute_name "complaint_object_id" \ + -datatype "integer" \ + -pretty_name "Complaint Object ID" \ + -sort_order 6 \ + -column_spec "integer constraint contact_complaint_track_complaint_object_id_fk + references acs_objects(object_id) on delete cascade" + + content::type::attribute::new \ + -content_type "contact_complaint" \ + -attribute_name "state" \ + -datatype "string" \ + -pretty_name "State" \ + -sort_order 7 \ + -column_spec "varchar(7) constraint cct_state_ck + check (state in ('valid','invalid','open'))" + + # Now we need to copy all information on contact_complaint_tracking table (the one we are taking out) + # into the new one called contact_complaint_track with the new fields. This is simple since + # all the collumns have the same datatype, just changed some names. + + db_dml insert_data { + insert into + contact_complaint_track + (complaint_id,customer_id,turnover,percent,supplier_id,paid,complaint_object_id,state) + select * from contact_complaint_tracking + } + + # Now we just delete the table contact_complaint_tracking + db_dml drop_table { drop table contact_complaint_tracking } + } + + 1.0d21 1.0d22 { + + content::type::attribute::new \ + -content_type "contact_complaint" \ + -attribute_name "employee_id" \ + -datatype "integer" \ + -pretty_name "Employee ID" \ + -sort_order 8 \ + -column_spec "integer constraint contact_complaint_track_employee_fk + references parties(party_id) on delete cascade" + + content::type::attribute::new \ + -content_type "contact_complaint" \ + -attribute_name "refund_amount" \ + -datatype "money" \ + -pretty_name "Refund" \ + -sort_order 9 \ + -column_spec "float" + + } + } +} \ No newline at end of file Index: openacs-4/packages/contacts/tcl/contacts-populate-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/tcl/contacts-populate-procs.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/tcl/contacts-populate-procs.tcl 30 Nov 2005 15:31:01 -0000 1.15.2.2 @@ -0,0 +1,1187 @@ +# packages/contacts/tcl/contacts-populate.tcl + +ad_library { + + @author Malte Sussdorff (sussdorff@sussdorff.de) + @creation-date 2005-06-05 + @arch-tag: 81868d37-99f5-48b1-8336-88e22c0e9001 +} + +namespace eval contacts::populate {} + +ad_proc -private -callback contacts::populate::organization::customer_attributes { + {-list_id:required} +} { +} + +ad_proc -public contacts::populate::crm { + {-package_id ""} +} { + Procedure to install ams Attributes for a good CRM solution (at + least in our idea). + + @author Malte Sussdorff (sussdorff@sussdorff.de) + @creation-date 2005-06-05 + + @return + + @error +} { + ams::widgets_init + + if {[empty_string_p $package_id]} { + array set sn_array [site_node::get \ + -url /contacts] + set contacts_package_id $sn_array(object_id) + } else { + set contacts_package_id $package_id + } + + set registered_user_group_id [contacts::default_group -package_id $package_id] + + + set supplier_id [db_string freelancer_group "select group_id from groups where group_name = 'Supplier'"] + +# set supplier_id [group::new -group_name "Supplier" "group"] + set customers_id [group::new \ + -group_name "Customers" "group"] + lang::message::register -update_sync de_DE acs-translations "group_title_${customers_id}" "Kunden" + + set leads_id [group::new \ + -group_name "Leads" "group"] + lang::message::register -update_sync de_DE acs-translations "group_title_${leads_id}" "Leads" + + contact::group::map -group_id $customers_id -package_id $contacts_package_id + contact::group::map -group_id $leads_id -package_id $contacts_package_id + + # Hopefully all is now setup to map the groups accordingly. + + # We already have the registered users lists setup, so we only need + # the list_id.. Actually we should never have to extend registered + # users, but what the heck... + + # Person:: Registered Users + + set list_id [ams::list::get_list_id \ + -package_key "contacts" \ + -object_type "person" \ + -list_name "${contacts_package_id}__${registered_user_group_id}" + ] + + set attribute_id [attribute::new \ + -object_type "person" \ + -attribute_name "first_names" \ + -datatype "string" \ + -pretty_name "First Name(s)" \ + -pretty_plural "First Name(s)" \ + -table_name "" \ + -column_name "" \ + -default_value "" \ + -min_n_values "0" \ + -max_n_values "1" \ + -sort_order "1" \ + -storage "type_specific" \ + -static_p "f" \ + -if_does_not_exist] + + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_name" "Vorname(n)" + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_plural" "Vornamen" + + ams::attribute::new \ + -attribute_id $attribute_id \ + -widget "textbox" \ + -dynamic_p "f" + + ams::list::attribute::map \ + -list_id $list_id \ + -attribute_id $attribute_id \ + -sort_order "10" \ + -required_p "f" \ + -section_heading "" + + set attribute_id [attribute::new \ + -object_type "person" \ + -attribute_name "last_name" \ + -datatype "string" \ + -pretty_name "Last Name" \ + -pretty_plural "Last Names" \ + -table_name "" \ + -column_name "" \ + -default_value "" \ + -min_n_values "0" \ + -max_n_values "1" \ + -sort_order "1" \ + -storage "type_specific" \ + -static_p "f" \ + -if_does_not_exist] + + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_name" "Nachname" + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_plural" "Nachnamen" + + ams::attribute::new \ + -attribute_id $attribute_id \ + -widget "textbox" \ + -dynamic_p "f" + + ams::list::attribute::map \ + -list_id $list_id \ + -attribute_id $attribute_id \ + -sort_order "20" \ + -required_p "f" \ + -section_heading "" + + set attribute_id [attribute::new \ + -object_type "person" \ + -attribute_name "salutation" \ + -datatype "string" \ + -pretty_name "Salutation" \ + -pretty_plural "Salutations" \ + -table_name "" \ + -column_name "" \ + -default_value "" \ + -min_n_values "1" \ + -max_n_values "1" \ + -sort_order "1" \ + -storage "generic" \ + -static_p "f" \ + -if_does_not_exist] + + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_name" "Anrede" + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_plural" "Anreden" + + ams::attribute::new \ + -attribute_id $attribute_id \ + -widget "select" \ + -dynamic_p "t" + + ams::list::attribute::map \ + -list_id $list_id \ + -attribute_id $attribute_id \ + -sort_order "30" \ + -required_p "f" \ + -section_heading "" + + set option_id [ams::option::new \ + -attribute_id $attribute_id \ + -option "Dear Mr. "] + + lang::message::register -update_sync de_DE acs-translations "ams_option_${option_id}" "Sehr geehrter Herr" + + set option_id [ams::option::new \ + -attribute_id $attribute_id \ + -option "Dear Mrs. "] + + lang::message::register -update_sync de_DE acs-translations "ams_option_${option_id}" "Sehr geehrte Frau" + + set option_id [ams::option::new \ + -attribute_id $attribute_id \ + -option "Dear Ms. "] + + lang::message::register -update_sync de_DE acs-translations "ams_option_${option_id}" "Sehr geehrte Frau" + + set option_id [ams::option::new \ + -attribute_id $attribute_id \ + -option "Dear "] + + lang::message::register -update_sync de_DE acs-translations "ams_option_${option_id}" "Sehr geehrter Herr / Frau" + + set option_id [ams::option::new \ + -attribute_id $attribute_id \ + -option "Dear Professor"] + + lang::message::register -update_sync de_DE acs-translations "ams_option_${option_id}" "Sehr geehrter Professor" + + set option_id [ams::option::new \ + -attribute_id $attribute_id \ + -option "Dear Dr."] + + lang::message::register -update_sync de_DE acs-translations "ams_option_${option_id}" "Sehr geehrter Dr." + + set attribute_id [attribute::new \ + -object_type "person" \ + -attribute_name "person_title" \ + -datatype "string" \ + -pretty_name "Title" \ + -pretty_plural "Titles" \ + -table_name "" \ + -column_name "" \ + -default_value "" \ + -min_n_values "1" \ + -max_n_values "1" \ + -sort_order "1" \ + -storage "generic" \ + -static_p "f" \ + -if_does_not_exist] + + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_name" "Titel" + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_plural" "Titel" + + ams::attribute::new \ + -attribute_id $attribute_id \ + -widget "textbox" \ + -dynamic_p "t" + + ams::list::attribute::map \ + -list_id $list_id \ + -attribute_id $attribute_id \ + -sort_order "40" \ + -required_p "f" \ + -section_heading "" + + set attribute_id [attribute::new \ + -object_type "person" \ + -attribute_name "home_address" \ + -datatype "string" \ + -pretty_name "Home Address" \ + -pretty_plural "Home Addresses" \ + -table_name "" \ + -column_name "" \ + -default_value "" \ + -min_n_values "1" \ + -max_n_values "1" \ + -sort_order "1" \ + -storage "generic" \ + -static_p "f" \ + -if_does_not_exist] + + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_name" "Privatanschrift" + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_plural" "Privatanschriften" + + ams::attribute::new \ + -attribute_id $attribute_id \ + -widget "postal_address" \ + -dynamic_p "t" + + ams::list::attribute::map \ + -list_id $list_id \ + -attribute_id $attribute_id \ + -sort_order "50" \ + -required_p "f" \ + -section_heading "" + + set attribute_id [attribute::new \ + -object_type "person" \ + -attribute_name "home_phone" \ + -datatype "string" \ + -pretty_name "Home Phone" \ + -pretty_plural "Home Phones" \ + -table_name "" \ + -column_name "" \ + -default_value "" \ + -min_n_values "1" \ + -max_n_values "1" \ + -sort_order "1" \ + -storage "generic" \ + -static_p "f" \ + -if_does_not_exist] + + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_name" "Telefonnummer (privat)" + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_plural" "Telefonnummer (privat)" + + ams::attribute::new \ + -attribute_id $attribute_id \ + -widget "telecom_number" \ + -dynamic_p "t" + + ams::list::attribute::map \ + -list_id $list_id \ + -attribute_id $attribute_id \ + -sort_order "60" \ + -required_p "f" \ + -section_heading "" + + set attribute_id [attribute::new \ + -object_type "person" \ + -attribute_name "private_fax" \ + -datatype "string" \ + -pretty_name "Private Fax No." \ + -pretty_plural "Private Fax Numbers" \ + -table_name "" \ + -column_name "" \ + -default_value "" \ + -min_n_values "1" \ + -max_n_values "1" \ + -sort_order "1" \ + -storage "generic" \ + -static_p "f" \ + -if_does_not_exist] + + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_name" "Faxnummer (Privat)" + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_plural" "Faxnummer (Privat)" + + ams::attribute::new \ + -attribute_id $attribute_id \ + -widget "telecom_number" \ + -dynamic_p "t" + + ams::list::attribute::map \ + -list_id $list_id \ + -attribute_id $attribute_id \ + -sort_order "70" \ + -required_p "f" \ + -section_heading "" + + set attribute_id [attribute::new \ + -object_type "person" \ + -attribute_name "private_mobile_phone" \ + -datatype "string" \ + -pretty_name "Private Mobile No." \ + -pretty_plural "Private Mobile Numbers" \ + -table_name "" \ + -column_name "" \ + -default_value "" \ + -min_n_values "1" \ + -max_n_values "1" \ + -sort_order "1" \ + -storage "generic" \ + -static_p "f" \ + -if_does_not_exist] + + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_name" "Mobilnummer (Privat)" + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_plural" "Mobilnummern (Privat)" + + ams::attribute::new \ + -attribute_id $attribute_id \ + -widget "telecom_number" \ + -dynamic_p "t" + + ams::list::attribute::map \ + -list_id $list_id \ + -attribute_id $attribute_id \ + -sort_order "80" \ + -required_p "f" \ + -section_heading "" + + set attribute_id [attribute::new \ + -object_type "party" \ + -attribute_name "email" \ + -datatype "string" \ + -pretty_name "Email Address" \ + -pretty_plural "Email Addresses" \ + -table_name "" \ + -column_name "" \ + -default_value "" \ + -min_n_values "0" \ + -max_n_values "1" \ + -sort_order "1" \ + -storage "type_specific" \ + -static_p "f" \ + -if_does_not_exist] + + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_name" "E-Mail Addresse" + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_plural" "E-Mail Addresse" + + ams::attribute::new \ + -attribute_id $attribute_id \ + -widget "email" \ + -dynamic_p "f" + + ams::list::attribute::map \ + -list_id $list_id \ + -attribute_id $attribute_id \ + -sort_order "84" \ + -required_p "f" \ + -section_heading "" + + set attribute_id [attribute::new \ + -object_type "person" \ + -attribute_name "birthdate" \ + -datatype "date" \ + -pretty_name "Birthdate" \ + -pretty_plural "Birthdates" \ + -table_name "" \ + -column_name "" \ + -default_value "" \ + -min_n_values "1" \ + -max_n_values "1" \ + -sort_order "1" \ + -storage "generic" \ + -static_p "f" \ + -if_does_not_exist] + + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_name" "Geburtstag" + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_plural" "Geburtstage" + + ams::attribute::new \ + -attribute_id $attribute_id \ + -widget "date" \ + -dynamic_p "t" + + ams::list::attribute::map \ + -list_id $list_id \ + -attribute_id $attribute_id \ + -sort_order "90" \ + -required_p "f" \ + -section_heading "" + + # ORGA - REG + + set list_id [ams::list::get_list_id \ + -package_key "contacts" \ + -object_type "organization" \ + -list_name "${contacts_package_id}__${registered_user_group_id}" + ] + + set attribute_id [attribute::new \ + -object_type "organization" \ + -attribute_name "name" \ + -datatype "string" \ + -pretty_name "Company Name" \ + -pretty_plural "Organization Names" \ + -table_name "" \ + -column_name "" \ + -default_value "" \ + -min_n_values "1" \ + -max_n_values "1" \ + -sort_order "1" \ + -storage "generic" \ + -static_p "f" \ + -if_does_not_exist] + + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_name" "Firmenname" + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_plural" "Firmennamen" + + ams::attribute::new \ + -attribute_id $attribute_id \ + -widget "textbox" \ + -dynamic_p "t" + + ams::list::attribute::map \ + -list_id $list_id \ + -attribute_id $attribute_id \ + -sort_order "10" \ + -required_p "f" \ + -section_heading "" + + set attribute_id [attribute::new \ + -object_type "organization" \ + -attribute_name "short_name" \ + -datatype "string" \ + -pretty_name "Short Company Name" \ + -pretty_plural "Short Company Names" \ + -table_name "" \ + -column_name "" \ + -default_value "" \ + -min_n_values "1" \ + -max_n_values "1" \ + -sort_order "1" \ + -storage "generic" \ + -static_p "f" \ + -if_does_not_exist] + + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_name" "Firmenkuerzel" + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_plural" "Firmenkuerzel" + + ams::attribute::new \ + -attribute_id $attribute_id \ + -widget "textbox" \ + -dynamic_p "t" + + ams::list::attribute::map \ + -list_id $list_id \ + -attribute_id $attribute_id \ + -sort_order "15" \ + -required_p "f" \ + -section_heading "" + + + set attribute_id [attribute::new \ + -object_type "organization" \ + -attribute_name "company_name_ext" \ + -datatype "string" \ + -pretty_name "Company Name Extensions" \ + -pretty_plural "Company Name Extensions" \ + -table_name "" \ + -column_name "" \ + -default_value "" \ + -min_n_values "1" \ + -max_n_values "1" \ + -sort_order "1" \ + -storage "generic" \ + -static_p "f" \ + -if_does_not_exist] + + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_name" "Erweiterung Firmenname" + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_plural" "Erweiterung Firmenname" + + ams::attribute::new \ + -attribute_id $attribute_id \ + -widget "textbox" \ + -dynamic_p "t" + + ams::list::attribute::map \ + -list_id $list_id \ + -attribute_id $attribute_id \ + -sort_order "20" \ + -required_p "f" \ + -section_heading "" + + set attribute_id [attribute::new \ + -object_type "organization" \ + -attribute_name "company_address" \ + -datatype "string" \ + -pretty_name "Company Address" \ + -pretty_plural "Company Addresses" \ + -table_name "" \ + -column_name "" \ + -default_value "" \ + -min_n_values "1" \ + -max_n_values "1" \ + -sort_order "1" \ + -storage "generic" \ + -static_p "f" \ + -if_does_not_exist] + + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_name" "Firmenanschrift" + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_plural" "Firmenanschrift" + + ams::attribute::new \ + -attribute_id $attribute_id \ + -widget "postal_address" \ + -dynamic_p "t" + + ams::list::attribute::map \ + -list_id $list_id \ + -attribute_id $attribute_id \ + -sort_order "30" \ + -required_p "f" \ + -section_heading "" + + set attribute_id [attribute::new \ + -object_type "organization" \ + -attribute_name "email" \ + -datatype "string" \ + -pretty_name "Email Address" \ + -pretty_plural "Email Addresses" \ + -table_name "" \ + -column_name "" \ + -default_value "" \ + -min_n_values "0" \ + -max_n_values "1" \ + -sort_order "1" \ + -storage "type_specific" \ + -static_p "f" \ + -if_does_not_exist] + + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_name" "E-Mail Adresse" + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_plural" "E-Mail Adresse" + + ams::attribute::new \ + -attribute_id $attribute_id \ + -widget "email" \ + -dynamic_p "f" + + ams::list::attribute::map \ + -list_id $list_id \ + -attribute_id $attribute_id \ + -sort_order "34" \ + -required_p "f" \ + -section_heading "" + + set attribute_id [attribute::new \ + -object_type "organization" \ + -attribute_name "company_url" \ + -datatype "url" \ + -pretty_name "Company URL" \ + -pretty_plural "Company URLs" \ + -table_name "" \ + -column_name "" \ + -default_value "" \ + -min_n_values "1" \ + -max_n_values "1" \ + -sort_order "1" \ + -storage "generic" \ + -static_p "f" \ + -if_does_not_exist] + + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_name" "Webseite" + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_plural" "Webseiten" + + ams::attribute::new \ + -attribute_id $attribute_id \ + -widget "url" \ + -dynamic_p "t" + + ams::list::attribute::map \ + -list_id $list_id \ + -attribute_id $attribute_id \ + -sort_order "40" \ + -required_p "f" \ + -section_heading "" + + set attribute_id [attribute::new \ + -object_type "organization" \ + -attribute_name "company_phone" \ + -datatype "string" \ + -pretty_name "Company Phone No." \ + -pretty_plural "Company Phone Numbers" \ + -table_name "" \ + -column_name "" \ + -default_value "" \ + -min_n_values "1" \ + -max_n_values "1" \ + -sort_order "1" \ + -storage "generic" \ + -static_p "f" \ + -if_does_not_exist] + + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_name" "Telefonnummer (Firma)" + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_plural" "Telefonnummern (Firma)" + + ams::attribute::new \ + -attribute_id $attribute_id \ + -widget "telecom_number" \ + -dynamic_p "t" + + ams::list::attribute::map \ + -list_id $list_id \ + -attribute_id $attribute_id \ + -sort_order "50" \ + -required_p "f" \ + -section_heading "" + + set attribute_id [attribute::new \ + -object_type "organization" \ + -attribute_name "company_fax" \ + -datatype "string" \ + -pretty_name "Company Fax No." \ + -pretty_plural "Company Fax Numbers" \ + -table_name "" \ + -column_name "" \ + -default_value "" \ + -min_n_values "1" \ + -max_n_values "1" \ + -sort_order "1" \ + -storage "generic" \ + -static_p "f" \ + -if_does_not_exist] + + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_name" "Faxnummer (Firma)" + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_plural" "Faxnummern (Firma)" + + ams::attribute::new \ + -attribute_id $attribute_id \ + -widget "telecom_number" \ + -dynamic_p "t" + + ams::list::attribute::map \ + -list_id $list_id \ + -attribute_id $attribute_id \ + -sort_order "55" \ + -required_p "f" \ + -section_heading "" + + set attribute_id [attribute::new \ + -object_type "organization" \ + -attribute_name "industrysector" \ + -datatype "string" \ + -pretty_name "Industry Sector" \ + -pretty_plural "Industry Sectors" \ + -table_name "" \ + -column_name "" \ + -default_value "" \ + -min_n_values "1" \ + -max_n_values "1" \ + -sort_order "1" \ + -storage "generic" \ + -static_p "f" \ + -if_does_not_exist] + + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_name" "Branche" + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_plural" "Branchen" + + ams::attribute::new \ + -attribute_id $attribute_id \ + -widget "select" \ + -dynamic_p "t" + + ams::list::attribute::map \ + -list_id $list_id \ + -attribute_id $attribute_id \ + -sort_order "60" \ + -required_p "f" \ + -section_heading "" + + set option_id [ams::option::new \ + -attribute_id $attribute_id \ + -option "Agency - Full Service"] + + lang::message::register -update_sync de_DE acs-translations "ams_option_${option_id}" "Full Service Agentur" + + set option_id [ams::option::new \ + -attribute_id $attribute_id \ + -option "Agency - Special"] + + lang::message::register -update_sync de_DE acs-translations "ams_option_${option_id}" "Spezialagentur" + + set option_id [ams::option::new \ + -attribute_id $attribute_id \ + -option "Agency - PR"] + + lang::message::register -update_sync de_DE acs-translations "ams_option_${option_id}" "PR-Agentur" + + # Organization - Customer + + set list_id [ams::list::new \ + -package_key "contacts" \ + -object_type "organization" \ + -list_name "${contacts_package_id}__${customers_id}" \ + -pretty_name "Organization - Customer" \ + -description "" \ + -description_mime_type ""] + + set leads_list_id [ams::list::new \ + -package_key "contacts" \ + -object_type "organization" \ + -list_name "${contacts_package_id}__${leads_id}" \ + -pretty_name "Organization - Leads" \ + -description "" \ + -description_mime_type ""] + + set attribute_id [attribute::new \ + -object_type "organization" \ + -attribute_name "clienttype" \ + -datatype "string" \ + -pretty_name "Type of Customer" \ + -pretty_plural "Types of Customer" \ + -table_name "" \ + -column_name "" \ + -default_value "" \ + -min_n_values "1" \ + -max_n_values "1" \ + -sort_order "1" \ + -storage "generic" \ + -static_p "f" \ + -if_does_not_exist] + + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_name" "Kundentyp" + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_plural" "Kundentypen" + + ams::attribute::new \ + -attribute_id $attribute_id \ + -widget "select" \ + -dynamic_p "t" + + ams::list::attribute::map \ + -list_id $list_id \ + -attribute_id $attribute_id \ + -sort_order "10" \ + -required_p "f" \ + -section_heading "" + + set option_id [ams::option::new \ + -attribute_id $attribute_id \ + -option "VIP Customer"] + + lang::message::register -update_sync de_DE acs-translations "ams_option_${option_id}" "VIP Kunde" + + set option_id [ams::option::new \ + -attribute_id $attribute_id \ + -option "Good Customer"] + + lang::message::register -update_sync de_DE acs-translations "ams_option_${option_id}" "Guter Kunde" + + set option_id [ams::option::new \ + -attribute_id $attribute_id \ + -option "Normal Customer"] + + lang::message::register -update_sync de_DE acs-translations "ams_option_${option_id}" "Normaler Kunde" + + set option_id [ams::option::new \ + -attribute_id $attribute_id \ + -option "Sporadic Customer"] + + lang::message::register -update_sync de_DE acs-translations "ams_option_${option_id}" "Gelegentlicher Kunde" + + set option_id [ams::option::new \ + -attribute_id $attribute_id \ + -option "Follow-up Customer"] + + lang::message::register -update_sync de_DE acs-translations "ams_option_${option_id}" "Follow-Up Kunde" + + set attribute_id [attribute::new \ + -object_type "organization" \ + -attribute_name "customer_since" \ + -datatype "date" \ + -pretty_name "Customer Since" \ + -pretty_plural "Customers Since" \ + -table_name "" \ + -column_name "" \ + -default_value "" \ + -min_n_values "1" \ + -max_n_values "1" \ + -sort_order "1" \ + -storage "generic" \ + -static_p "f" \ + -if_does_not_exist] + + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_name" "Kunde seit" + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_plural" "Kunde seit" + + ams::attribute::new \ + -attribute_id $attribute_id \ + -widget "date" \ + -dynamic_p "t" + + ams::list::attribute::map \ + -list_id $list_id \ + -attribute_id $attribute_id \ + -sort_order "20" \ + -required_p "f" \ + -section_heading "" + + callback contacts::populate::organization::customer_attributes -list_id $list_id + + # Person - Customer + + set list_id [ams::list::new \ + -package_key "contacts" \ + -object_type "person" \ + -list_name "${contacts_package_id}__${customers_id}" \ + -pretty_name "Person - Customer" \ + -description "" \ + -description_mime_type ""] + + set leads_list_id [ams::list::new \ + -package_key "contacts" \ + -object_type "person" \ + -list_name "${contacts_package_id}__${leads_id}" \ + -pretty_name "Person - Leads" \ + -description "" \ + -description_mime_type ""] + + set attribute_id [attribute::new \ + -object_type "person" \ + -attribute_name "department" \ + -datatype "string" \ + -pretty_name "Department" \ + -pretty_plural "Departments" \ + -table_name "" \ + -column_name "" \ + -default_value "" \ + -min_n_values "1" \ + -max_n_values "1" \ + -sort_order "1" \ + -storage "generic" \ + -static_p "f" \ + -if_does_not_exist] + + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_name" "Abteilung" + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_plural" "Abteilungen" + + ams::attribute::new \ + -attribute_id $attribute_id \ + -widget "textbox" \ + -dynamic_p "t" + + ams::list::attribute::map \ + -list_id $list_id \ + -attribute_id $attribute_id \ + -sort_order "10" \ + -required_p "f" \ + -section_heading "" + + set attribute_id [attribute::new \ + -object_type "person" \ + -attribute_name "jobtitle" \ + -datatype "string" \ + -pretty_name "Job Title" \ + -pretty_plural "Job Titles" \ + -table_name "" \ + -column_name "" \ + -default_value "" \ + -min_n_values "1" \ + -max_n_values "1" \ + -sort_order "1" \ + -storage "generic" \ + -static_p "f" \ + -if_does_not_exist] + + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_name" "Position" + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_plural" "Positionen" + + ams::attribute::new \ + -attribute_id $attribute_id \ + -widget "textbox" \ + -dynamic_p "t" + + ams::list::attribute::map \ + -list_id $list_id \ + -attribute_id $attribute_id \ + -sort_order "20" \ + -required_p "f" \ + -section_heading "" + + set attribute_id [attribute::new \ + -object_type "person" \ + -attribute_name "directphoneno" \ + -datatype "string" \ + -pretty_name "Direct Phone No." \ + -pretty_plural "Direct Phone Numbers" \ + -table_name "" \ + -column_name "" \ + -default_value "" \ + -min_n_values "1" \ + -max_n_values "1" \ + -sort_order "1" \ + -storage "generic" \ + -static_p "f" \ + -if_does_not_exist] + + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_name" "Durchwahl" + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_plural" "Durchwahlen" + + ams::attribute::new \ + -attribute_id $attribute_id \ + -widget "telecom_number" \ + -dynamic_p "t" + + ams::list::attribute::map \ + -list_id $list_id \ + -attribute_id $attribute_id \ + -sort_order "30" \ + -required_p "f" \ + -section_heading "" + + set attribute_id [attribute::new \ + -object_type "person" \ + -attribute_name "telephone_other" \ + -datatype "string" \ + -pretty_name "Other Tel. No." \ + -pretty_plural "Other Tel. Numbers" \ + -table_name "" \ + -column_name "" \ + -default_value "" \ + -min_n_values "1" \ + -max_n_values "1" \ + -sort_order "1" \ + -storage "generic" \ + -static_p "f" \ + -if_does_not_exist] + + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_name" "Andere Telefonnummer" + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_plural" "Andere Telefonnummern" + + ams::attribute::new \ + -attribute_id $attribute_id \ + -widget "telecom_number" \ + -dynamic_p "t" + + ams::list::attribute::map \ + -list_id $list_id \ + -attribute_id $attribute_id \ + -sort_order "40" \ + -required_p "f" \ + -section_heading "" + + set attribute_id [attribute::new \ + -object_type "person" \ + -attribute_name "directfaxno" \ + -datatype "string" \ + -pretty_name "Direct Fax No." \ + -pretty_plural "Direct Fax Numbers" \ + -table_name "" \ + -column_name "" \ + -default_value "" \ + -min_n_values "1" \ + -max_n_values "1" \ + -sort_order "1" \ + -storage "generic" \ + -static_p "f" \ + -if_does_not_exist] + + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_name" "Direkte Faxnummer" + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_plural" "Direkte Faxnummern" + + ams::attribute::new \ + -attribute_id $attribute_id \ + -widget "telecom_number" \ + -dynamic_p "t" + + ams::list::attribute::map \ + -list_id $list_id \ + -attribute_id $attribute_id \ + -sort_order "50" \ + -required_p "f" \ + -section_heading "" + + set attribute_id [attribute::new \ + -object_type "person" \ + -attribute_name "mobile_phone" \ + -datatype "string" \ + -pretty_name "Mobile Phone No." \ + -pretty_plural "Mobile Phones" \ + -table_name "" \ + -column_name "" \ + -default_value "" \ + -min_n_values "1" \ + -max_n_values "1" \ + -sort_order "1" \ + -storage "generic" \ + -static_p "f" \ + -if_does_not_exist] + + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_name" "Mobilfunk Nummer" + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_plural" "Mobilfunk Nummer" + + ams::attribute::new \ + -attribute_id $attribute_id \ + -widget "telecom_number" \ + -dynamic_p "t" + + ams::list::attribute::map \ + -list_id $list_id \ + -attribute_id $attribute_id \ + -sort_order "60" \ + -required_p "f" \ + -section_heading "" + + set attribute_id [attribute::new \ + -object_type "person" \ + -attribute_name "directemail" \ + -datatype "email" \ + -pretty_name "E-Mail Adress" \ + -pretty_plural "E-Mail Adresses" \ + -table_name "" \ + -column_name "" \ + -default_value "" \ + -min_n_values "1" \ + -max_n_values "1" \ + -sort_order "1" \ + -storage "generic" \ + -static_p "f" \ + -if_does_not_exist] + + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_name" "E-Mail Adresse" + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_plural" "E-Mail Adresse" + + ams::attribute::new \ + -attribute_id $attribute_id \ + -widget "email" \ + -dynamic_p "t" + + ams::list::attribute::map \ + -list_id $list_id \ + -attribute_id $attribute_id \ + -sort_order "70" \ + -required_p "f" \ + -section_heading "" + + set attribute_id [attribute::new \ + -object_type "person" \ + -attribute_name "delivery_address" \ + -datatype "string" \ + -pretty_name "Delivery Address" \ + -pretty_plural "Delivery Addresses" \ + -table_name "" \ + -column_name "" \ + -default_value "" \ + -min_n_values "1" \ + -max_n_values "1" \ + -sort_order "1" \ + -storage "generic" \ + -static_p "f" \ + -if_does_not_exist] + + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_name" "Lieferanschrift" + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_plural" "Lieferanschrift" + + ams::attribute::new \ + -attribute_id $attribute_id \ + -widget "postal_address" \ + -dynamic_p "t" + + ams::list::attribute::map \ + -list_id $list_id \ + -attribute_id $attribute_id \ + -sort_order "80" \ + -required_p "f" \ + -section_heading "" + + set attribute_id [attribute::new \ + -object_type "person" \ + -attribute_name "visitaddress" \ + -datatype "string" \ + -pretty_name "Visit Adress" \ + -pretty_plural "Visit Addresses" \ + -table_name "" \ + -column_name "" \ + -default_value "" \ + -min_n_values "1" \ + -max_n_values "1" \ + -sort_order "1" \ + -storage "generic" \ + -static_p "f" \ + -if_does_not_exist] + + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_name" "Besuchsanschrift" + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_plural" "Besuchsanschrift" + + ams::attribute::new \ + -attribute_id $attribute_id \ + -widget "postal_address" \ + -dynamic_p "t" + + ams::list::attribute::map \ + -list_id $list_id \ + -attribute_id $attribute_id \ + -sort_order "90" \ + -required_p "f" \ + -section_heading "" + + # Register Relationships + + rel_types::create_role -role "parent_company" -pretty_name "Parent Company" -pretty_plural "Parent Companies" + rel_types::create_role -role "subsidiary" -pretty_name "Subsidiary" -pretty_plural "Subsidiaries" + rel_types::new -table_name "contact_rels_subsidiary" -create_table_p "t" -supertype "contact_rel" -role_one "parent_company" -role_two "subsidiary" \ + "contact_rels_subsidiary" \ + "Contact Rel Subsidiary" \ + "Contact Rels Subsidiary" \ + "organization" \ + "0" \ + "" \ + "organization" \ + "0" \ + "" + + # Contact Rels Subsidiary + + set list_id [ams::list::new \ + -package_key "contacts" \ + -object_type "contact_rels_subsidiary" \ + -list_name "$contacts_package_id" \ + -pretty_name "Contact Rels Subsidiary" \ + -description "" \ + -description_mime_type ""] + + set attribute_id [attribute::new \ + -object_type "contact_rels_subsidiary" \ + -attribute_name "shares" \ + -datatype "integer" \ + -pretty_name "Shares" \ + -pretty_plural "Shares" \ + -table_name "" \ + -column_name "" \ + -default_value "" \ + -min_n_values "1" \ + -max_n_values "1" \ + -sort_order "1" \ + -storage "generic" \ + -static_p "f" \ + -if_does_not_exist] + + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_name" "Anteil" + lang::message::register -update_sync de_DE acs-translations "ams_attribute_${attribute_id}_pretty_plural" "Anteile" + + ams::attribute::new \ + -attribute_id $attribute_id \ + -widget "integer" \ + -dynamic_p "t" + + ams::list::attribute::map \ + -list_id $list_id \ + -attribute_id $attribute_id \ + -sort_order "1" \ + -required_p "f" \ + -section_heading "" +} Index: openacs-4/packages/contacts/tcl/contacts-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/tcl/contacts-procs-postgresql.xql,v diff -u -N -r1.3 -r1.3.2.1 --- openacs-4/packages/contacts/tcl/contacts-procs-postgresql.xql 27 Feb 2005 17:07:18 -0000 1.3 +++ openacs-4/packages/contacts/tcl/contacts-procs-postgresql.xql 30 Nov 2005 15:31:01 -0000 1.3.2.1 @@ -1,372 +1,78 @@ -postgresql7.2 - - + - select 1 from contacts where party_id = :party_id + select name + from cr_items + where parent_id = :party_id - - + - select * from contacts where party_id = :party_id + select groups.group_id, + acs_objects.title as group_name, + ( select count(distinct gamm.member_id) from group_approved_member_map gamm where gamm.group_id = groups.group_id ) as member_count, + ( select count(distinct gcm.component_id) from group_component_map gcm where gcm.group_id = groups.group_id) as component_count, + CASE WHEN contact_groups.package_id is not null THEN '1' ELSE '0' END as mapped_p, + CASE WHEN default_p THEN '1' ELSE '0' END as default_p + from groups left join contact_groups on ( groups.group_id = contact_groups.group_id ), acs_objects + where groups.group_id not in ('-1','[contacts::default_group]') + and groups.group_id = acs_objects.object_id + and groups.group_id not in ( select gcm.component_id from group_component_map gcm where gcm.group_id != -1 ) + $filter_clause + order by mapped_p desc, CASE WHEN contact_groups.default_p THEN '000000000' ELSE upper(groups.group_name) END - - + - select * from contacts where party_id = :party_id + select groups.group_id, + groups.group_name, + ( select count(distinct gamm.member_id) from group_approved_member_map gamm where gamm.group_id = groups.group_id ) as member_count, + CASE WHEN package_id is not null THEN '1' ELSE '0' END as mapped_p, + CASE WHEN default_p THEN '1' ELSE '0' END as default_p + from groups left join contact_groups on ( groups.group_id = contact_groups.group_id ), group_component_map + where group_component_map.group_id = :group_id + and group_component_map.component_id = groups.group_id + order by upper(groups.group_name) - - + - select '1' from users where user_id = :party_id + select group_id + from group_component_map + where component_id = :group_id + and group_id != '-1' - - + - select nextval from acs_object_id_seq + select acs_group__new ( + :group_id, + 'group', + now(), + :creation_user, + :creation_ip, + :email, + :url, + :group_name, + :join_policy, + :context_id + ) - - + - select object_id from contact_object_types where object_type = 'organization' - - - - - - - select object_id from contact_object_types where object_type = 'person' - - - - - - - select * - from contact_attributes ca, - contact_widgets cw, - contact_attribute_object_map caom, - contact_attribute_names can - where caom.object_id = :object_id - and ca.attribute_id = can.attribute_id - and can.locale = :locale - and caom.attribute_id = ca.attribute_id - and ca.widget_id = cw.widget_id - and not ca.depreciated_p - and acs_permission__permission_p(ca.attribute_id,:user_id,'write') - order by caom.sort_order - - - - - - - - select ca.attribute_id, - ca.attribute, - cav.option_map_id, - cav.address_id, - cav.number_id, - to_char(cav.time,'YYYY MM DD') as time, - cav.value, - cav.value_format, - cw.storage_column - from contact_attributes ca, - contact_widgets cw, - contact_attribute_object_map caom left join - ( select * - from contact_attribute_values - where party_id = :party_id - and not deleted_p ) cav - on (caom.attribute_id = cav.attribute_id) - where caom.object_id = '$object_id' - and caom.attribute_id = ca.attribute_id - and ca.widget_id = cw.widget_id - and not ca.depreciated_p - and ( - cav.option_map_id is not null - or cav.address_id is not null - or cav.number_id is not null - or cav.value is not null - or cav.time is not null - or ca.attribute in ($custom_field_sql_list) - ) - and acs_permission__permission_p(ca.attribute_id,'$user_id','$permission') - order by caom.sort_order - - - - - - - select name - from organizations - where organization_id = :party_id - - - - - - - select legal_name - from organizations - where organization_id = :party_id - - - - - - - select reg_number - from organizations - where organization_id = :party_id - - - - - - - select first_names - from persons - where person_id = :party_id - - - - - - - select cao.option_id, cao.option - from contact_attribute_options cao, - organization_types ot, - organization_type_map otm - where cao.option = ot.type - and cao.attribute_id = :attribute_id - and otm.organization_type_id = ot.organization_type_id - and otm.organization_id = :party_id - - - - - - - select first_names - from persons - where person_id = :party_id - - - - - - - select last_name - from persons - where person_id = :party_id - - - - - - - select email - from parties - where party_id = :party_id - - - - - - - select url - from parties - where party_id = :party_id - - - - - - - select cao.option, cao.option_id - from contact_attribute_options cao, - contact_attribute_option_map caom - where caom.option_id = cao.option_id - and caom.option_map_id = :option_map_id - - - - - - select * - from contact_attributes ca, - contact_widgets cw, - contact_attribute_object_map caom, - contact_attribute_names can - where caom.object_id = :object_id - and ca.attribute_id = can.attribute_id - and can.locale = :locale - and caom.attribute_id = ca.attribute_id - and ca.widget_id = cw.widget_id - and not ca.depreciated_p - and acs_permission__permission_p(ca.attribute_id,:user_id,'write') - order by caom.sort_order - - - - - - - select cav.address_id as old_address_id - from contact_attribute_values cav, - postal_addresses pa - where cav.party_id = :party_id - and cav.attribute_id = :attribute_id - and not cav.deleted_p - and cav.address_id = pa.address_id - and pa.delivery_address = :delivery_address - and pa.municipality = :municipality - and pa.region = :region - and pa.postal_code = :postal_code - and pa.country_code = :country_code - - - - - - - select cav.number_id as old_number_id - from contact_attribute_values cav, - telecom_numbers tn - where cav.party_id = :party_id - and cav.attribute_id = :attribute_id - and not cav.deleted_p - and cav.number_id = tn.number_id - and tn.subscriber_number = :attribute_value_temp - - - - - - - select option_map_id - from contact_attribute_values - where party_id = :party_id - and attribute_id = :attribute_id and not deleted_p - - - - - - - select option_id - from contact_attribute_option_map - where option_map_id = :option_map_id - - - - - - - select nextval('contact_attribute_option_map_id_seq') as option_map_id - - - - - - - insert into contact_attribute_option_map - (option_map_id,party_id,option_id) + insert into contact_groups + (group_id,default_p,package_id) values - (:option_map_id,:party_id,:option_id) + (:group_id,:default_p,:package_id) - - - - update parties set email = :attribute_value_temp where party_id = :party_id - - - - - - - update parties set url = :attribute_value_temp where party_id = :party_id - - - - - - - update organizations set name = :attribute_value_temp where organization_id = :party_id - - - - - - - update organizations set legal_name = :attribute_value_temp where organization_id = :party_id - - - - - - - update organizations set reg_number = :attribute_value_temp where organization_id = :party_id - - - - - - - delete from organization_type_map where organization_id = :party_id - - - - - - - select organization_type_id - from contact_attribute_options cao, - organization_types ot - where cao.option = ot.type - and cao.option_id = :option_id - - - - - - - insert into organization_type_map - (organization_id, organization_type_id) - values - (:party_id, :organization_type_id) - - - - - - - update persons set first_names = :attribute_value_temp where person_id = :party_id - - - - - - - update persons set last_name = :attribute_value_temp where person_id = :party_id - - - - Index: openacs-4/packages/contacts/tcl/contacts-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/tcl/contacts-procs.tcl,v diff -u -N -r1.2 -r1.2.2.1 --- openacs-4/packages/contacts/tcl/contacts-procs.tcl 13 Jan 2005 13:57:05 -0000 1.2 +++ openacs-4/packages/contacts/tcl/contacts-procs.tcl 30 Nov 2005 15:31:01 -0000 1.2.2.1 @@ -1,725 +1,728 @@ ad_library { - Support procs for the contacts package + Support procs for the contacts package @author Matthew Geddert openacs@geddert.com @creation-date 2004-07-28 @cvs-id $Id$ - } -namespace eval contact:: { +namespace eval contacts:: {} +namespace eval contact:: {} +namespace eval contact::util:: {} +namespace eval contact::group:: {} +namespace eval contact::revision:: {} +namespace eval contact::special_attributes:: {} +namespace eval contact::rels:: {} +namespace eval contact::employee {} - ad_proc -public name { - party_id - } { - this returns the contact's name - } { - return [contact::get::name $party_id] - } - ad_proc -public exists_p { - party_id - } { - this code returns 1 if the party_id exists - } { - return [db_0or1row exists_p {}] +ad_proc -public contacts::default_group { + {-package_id ""} +} { + returns the group_id for which this group is a component, if none then it return null +} { + if {[string is false [exists_and_not_null package_id]]} { + set package_id [ad_conn package_id] } +# return [db_string get_default_group {select group_id from contact_groups where package_id = :package_id and default_p} -default {}] +# return [db_string get_default_group {select group_id from +# application_groups where package_id = :package_id } -default {}] + return "-2" +} - ad_proc -public get { - party_id - } { - get the info on the contact - } { +ad_proc -private contact::util::generate_filename { + {-title:required} + {-extension:required} + {-existing_filenames ""} + {-party_id ""} +} { + Generate a pretty filename that relates to the title supplied - db_0or1row get_contact_info {} + @param party_id if supplied the filenames associated with this party will be used as existing_filenames if existing filenames is not provided - set contact_info [ns_set create] - ns_set put $contact_info party_id $party_id - ns_set put $contact_info object_type $object_type - ns_set put $contact_info name $name - ns_set put $contact_info legal_name $legal_name - ns_set put $contact_info reg_number $reg_number - ns_set put $contact_info first_names $first_names - ns_set put $contact_info last_name $last_name - ns_set put $contact_info sort_first_names $sort_first_names - ns_set put $contact_info sort_last_name $sort_last_name - ns_set put $contact_info email $email - ns_set put $contact_info url $url - ns_set put $contact_info user_p $user_p - - # Now, set the variables in the caller's environment - ad_ns_set_to_tcl_vars -level 2 $contact_info - ns_set free $contact_info - + @param existing_filenames a list of filenames that the generated filename must not be equal to +} { + if {[exists_and_not_null party_id] + && [string is integer $party_id] && ![exists_and_not_null existing_filenames]} { + set existing_filenames [db_list get_parties_existing_filenames {}] } + set filename [util_text_to_url \ + -text ${title} -replacement "_"] + set output_filename "${filename}.${extension}" + set num 1 + while {[lsearch $existing_filenames $output_filename] >= 0} { + set output_filename "${filename}${num}.${extension}" + incr num + } + return $output_filename +} - - +ad_proc -private contact::util::get_file_extension { + {-filename:required} +} { + get the file extension from a file +} { + return [lindex [split $filename "."] end] } -namespace eval contact::get:: { - - ad_proc -public array { - party_id - array + ad_proc -public contact::util::get_employees { + {-organization_id:required} +} { + get employees of an organization +} { + set contact_list {} + db_foreach select_employee_ids { + select CASE WHEN object_id_one = :organization_id + THEN object_id_two + ELSE object_id_one END as other_party_id + from acs_rels, acs_rel_types + where acs_rels.rel_type = acs_rel_types.rel_type + and ( object_id_one = :organization_id or object_id_two = :organization_id ) + and acs_rels.rel_type = 'contact_rels_employment' } { - get the info from addresses - } { - upvar $array row - db_0or1row select_address_info {} -column_array row + lappend contact_list $other_party_id } + return $contact_list +} - ad_proc -public object_type { - party_id - } { - returns the parties object_type - } { - contact::get $party_id - return $object_type - } +ad_proc -public contact::util::get_employers { + {-employee_id:required} +} { + Get employers of an employee - ad_proc -public name { - party_id + @author Al-Faisal El-Dajani (faisal.dajani@gmail.com) + @param employee_id The ID of the employee whom you want to know his/her employer + @creation-date 2005-10-17 + @return List of lists, each containing the ID and name of an employer, or an empty list if no employers exist. +} { + set contact_list [list] + db_foreach select_employer_ids { + select CASE WHEN object_id_one = :employee_id + THEN object_id_two + ELSE object_id_one END as other_party_id + from acs_rels, acs_rel_types + where acs_rels.rel_type = acs_rel_types.rel_type + and ( object_id_one = :employee_id or object_id_two = :employee_id ) + and acs_rels.rel_type = 'contact_rels_employment' } { - returns the parties sort_first_names - } { - contact::get $party_id - return $sort_first_names + set organization_name [contact::name -party_id $other_party_id] + lappend contact_list [list $other_party_id $organization_name] } - ad_proc -public custom_field_list { - party_id - } { - set custom_field_list [list email url] - set object_type [contact::get::object_type $party_id] - if { $object_type == "organization" } { - lappend custom_field_list "organization_type" - lappend custom_field_list "organization_name" - lappend custom_field_list "legal_name" - lappend custom_field_list "reg_number" - } - if { $object_type == "person" } { - lappend custom_field_list "first_names" - lappend custom_field_list "last_name" - } - return $custom_field_list + return $contact_list } +ad_proc -public contact::employee::get { + {-employee_id:required} + {-array:required} + {-organization_id} +} { + Get full employee information. If employee does not have a phone number, fax number, or an e-mail address, the employee will be assigned the corresponding employer value, if an employer exists. + @author Al-Faisal El-Dajani (faisal.dajanim@gmail.com) + @creation-date 2005-10-18 + @param employee_id The ID of the employee whose information you wish to retrieve. + @param array Name of array to upvar contents into. + @param organization_id ID of the organization whose information should be returned if the employee_id is an employee at this organization. If not specified, defaults to first employer relationship found, if any. + @return 1 if user exists, 0 otherwise. +} { + ns_log notice "start processing" + upvar $array local_array + set employer_exist_p 0 + set employee_attributes [list "first_names" "last_name" "salutation" "person_title" "home_phone" "private_fax" "email"] + set employer_attributes [list "name" "company_phone" "company_fax" "email"] -} - - - -namespace eval contacts::util:: { - - ad_proc -public party_is_user_p { - party_id - } { - returns 1 if the party is a user and 0 if not - } { - return [db_0or1row get_party_is_user_p {} ] + # Check if ID belongs to an employee, if not return 0 + if {![person::person_p -party_id $employee_id]} { + ns_log notice "The ID specified does not belong to an employee" + return 0 } + # Get employers, if any + set employers [list] + set employers [contact::util::get_employers -employee_id $employee_id] - ad_proc -public next_object_id { - } { - returns the next available object_id - } { - db_1row get_next_object_id {} - return $nextval + # If employer(s) exist + if {[llength $employers] > 0} { + if {[exists_and_not_null organization_id]} { + # If user sepcified to get information for a certain employer, check if the specified employer exists. If employer specified is not an employer, no organization info will be returned. + foreach single_employer $employers { + if {$organization_id == [lindex $single_employer 0]} { + set employer $single_employer + set employer_exist_p 1 + break + } + } + } else { + # If user didn't specify a certain employer, get first employer. + set employer [lindex $employers 0] + set employer_exist_p 1 + } + # Get best/last revision + set employee_id [content::item::get_best_revision -item_id $employee_id] + set employer_id [content::item::get_best_revision -item_id [lindex $employer 0]] } - - ad_proc -public organization_object_id { - } { - returns the object_id of the organization contact_object_type - } { - db_1row get_organization_object_id {} - return $object_id + # Set the attributes + foreach attribute $employee_attributes { + set value [ams::value \ + -object_id $employee_id \ + -attribute_name $attribute + ] + set local_array($attribute) $value } + if {$employer_exist_p} { + foreach attribute $employer_attributes { + set value [ams::value \ + -object_id $employer_id \ + -attribute_name $attribute + ] + set $attribute $value + } - ad_proc -public person_object_id { - } { - returns the object_id of the organization contact_object_type - } { - db_1row get_object_id {} - return $object_id + # Check if employee email, phone, and fax exist. If not, set them to employer values. + if {![exists_and_not_null $local_array(email)]} { + set local_array(email) $email + } + if {![exists_and_not_null $local_array(home_phone)]} { + set local_array(home_phone) $company_phone + } + if {![exists_and_not_null $local_array(private_fax)]} { + set local_array(private_fax) $company_fax + } } - - # some of this codes was borrowed from the directory module - ad_proc -public letter_bar { - {-export_vars ""} - {-letter ""} - {-initial_list:required} - } { - Returns an A-Z bar with greyed out letters not - in initial_list and bolds "letter". - - Includes all existing url vars except those in - the "excluded_vars" list. - } { - set all_letters [list A B C D E F G H I J K L M N O P Q R S T U V W X Y Z] - - set html_list [list] - foreach l $all_letters { - if { [lsearch -exact $initial_list $l] == -1 } { - # This means no user has this initial - lappend html_list "$l" - } elseif { [string compare $l $letter] == 0 } { - lappend html_list "$l" - } else { - lappend html_list "$l" - } - } - if { [empty_string_p $letter] || [string compare $letter "all"] == 0 } { - lappend html_list "\#contacts.All\#" - } else { - lappend html_list "\#contacts.All\#" - } - return "[join $html_list " | "]" - } - - ad_proc -public sqlify_list { - variable_list + set local_array(company_name) $name + set address_id [attribute::id -object_type "organization" -attribute_name "company_address"] + contacts::postal_address::get -address_id $address_id -array address_array + set local_array(company_address) $address_array(delivery_address) + set local_array(company_municipality) $address_array(municipality) + set local_array(company_region) $address_array(region) + set local_array(company_postal_code) $address_array(postal_code) + set local_array(company_country_code) $address_array(country_code) + + return 1 +} + +ad_proc -public contact::util::get_employee_organization { + {-employee_id:required} +} { + get organization of an employee +} { + set contact_list {} + db_foreach select_employee_ids { + select CASE WHEN object_id_one = :employee_id + THEN object_id_two + ELSE object_id_one END as other_party_id + from acs_rels, acs_rel_types + where acs_rels.rel_type = acs_rel_types.rel_type + and ( object_id_one = :employee_id or object_id_two = :employee_id ) + and acs_rels.rel_type = 'contact_rels_employment' } { - set output_list {} - foreach item $variable_list { - if { [exists_and_not_null output_list] } { - append output_list ", " - } - append output_list "'$item'" - } - return $output_list + lappend contact_list $other_party_id } - + return $contact_list } +ad_proc -private contact::flush { + {-party_id:required} +} { + Flush memorized information related to this contact +} { + util_memoize_flush "::contact::email_address_exists_p_not_cached -party_id $party_id" + util_memoize_flush "::contact::mailing_address_exists_p_not_cached -party_id $party_id" + util_memoize_flush "::contact::name_not_cached -party_id $party_id" + util_memoize_flush "::contact::email_not_cached -party_id $party_id" +} +ad_proc -public contact::name { + {-party_id:required} +} { + this returns the contact's name. Cached +} { + return [util_memoize [list ::contact::name_not_cached -party_id $party_id]] +} -namespace eval contacts::get { +ad_proc -public contact::name_not_cached { + {-party_id:required} +} { + this returns the contact's name +} { + if {[person::person_p -party_id $party_id]} { + set person_info [person::name -person_id $party_id] + return $person_info + } else { + # if there is an org the name is returned otherwise we search for a grou, + # if there is no group null is returned + set name [db_string get_org_name {select name from organizations where organization_id = :party_id} -default ""] + if { [empty_string_p $name] } { + set name [db_string get_group_name {select group_name from groups where group_id = :party_id} -default {}] + } else { + return $name + } - ad_proc -public ad_form_elements { - object_id - party_id - } { - this code lists the form elements for a contact (after checking whether or not the user has permission to edit/add this info) - } { + } +} +ad_proc -public contact::email { + {-party_id:required} +} { + this returns the contact's name. Cached +} { + return [util_memoize [list ::contact::email_not_cached -party_id $party_id]] +} - set locale [lang::conn::locale -site_wide] - set user_id [ad_conn user_id] +ad_proc -public contact::email_not_cached { + {-party_id:required} +} { + this returns the contact's name +} { + set email [db_string get_party_email { select email from parties where party_id = :party_id } -default {}] + if { ![exists_and_not_null email] } { + # we check if these is an ams_attribute_valued email address for this party + set attribute_id [contact::email_attribute_id] + set revision_id [contact::live_revision -party_id $party_id] + if { [exists_and_not_null revision_id] } { + set email [db_string get_email { select ams_attribute_value__value(:attribute_id,value_id) from ams_attribute_values where object_id = :revision_id and attribute_id = :attribute_id } -default {}] + set email [ams::widget -widget email -request value_text -value $email] + } + } + return $email +} - set active_group_id "" +ad_proc -private contact::email_attribute_id { +} { + this returns the email attributes attribute_id. cached +} { + return [util_memoize [list ::contact::email_attribute_id]] +} - set element_list "" - if { [string is true [contact::exists_p $party_id]] } { - set object_type [contact::get::object_type $party_id] - } else { - # since the party doesn't exist yet, we assume that - # contacts is calling this proc to create a person - # or an organization - if { $object_id == [contacts::util::organization_object_id] } { - set object_type "organization" - } else { - set object_type "person" - } - } - db_foreach select_attributes {} { +ad_proc -private contact::email_attribute_id { +} { + this returns the email attributes attribute_id +} { + return [db_string get_email_attribute_id { select attribute_id from acs_attributes where object_type = 'party' and attribute_name = 'email'}] +} - if { [lsearch [list first_names last_name email url] $attribute] >= 0 } { - if { [contacts::util::party_is_user_p $party_id] } { - if { ![string compare $party_id [ad_conn user_id]] } { - set help_text "This will change your account info." - } elseif { [acs_user::site_wide_admin_p] } { - set help_text "This will change [person::name -person_id $party_id]'s account info." - } else { -# set help_text "You may not edit this information since [person::name -person_id $party_id] is a user of this system." - set widget "inform" - } - } - } +ad_proc -public contact::link { + {-party_id:required} +} { + this returns the contact's name. Cached +} { + set contact_name [contact::name -party_id $party_id] + if { ![empty_string_p $contact_name] } { + set contact_url [contact::url -party_id $party_id] + return "${contact_name}" + } else { + return {} + } +} - if { [contacts::util::party_is_user_p $party_id] && ![string compare $attribute "email"] } { - set required_p 1 - } - if { $object_type == "person" } { - if { [lsearch [list first_names last_name] $attribute] >= 0 } { - set required_p 1 - } - } - if { $object_type == "organization" } { - if { [lsearch [list organization_name organization_type] $attribute] >= 0 } { - set required_p 1 - } - } +ad_proc -public contact::type { + {-party_id:required} +} { + returns the contact type +} { + if {[contact::user_p -party_id $party_id]} { + return "user" + } elseif {[person::person_p -party_id $party_id]} { + return "person" + } elseif {[organization::organization_p -party_id $party_id]} { + return "organization" + } else { + return "" + } +} +ad_proc -public contact::exists_p { + {-party_id:required} +} { + does this contact exist? +} { + # persons can be organizations so we need to do the check this way + if {[person::person_p -party_id $party_id]} { + return 1 + } elseif {[organization::organization_p -party_id $party_id]} { + return 1 + } else { + return 0 + } +} +ad_proc -public contact::user_p { + {-party_id:required} +} { + is this party a user? Cached +} { + return [util_memoize [list ::contact::user_p_not_cached -party_id $party_id]] +} +ad_proc -public contact::user_p_not_cached { + {-party_id:required} +} { + is this party a person? Cached +} { + if {[db_0or1row contact_user_exists_p {select '1' from users where user_id = :party_id}]} { + return 1 + } else { + return 0 + } +} +ad_proc -public contact::url { + {-party_id:required} +} { + create a contact revision +} { + return "[apm_package_url_from_id [apm_package_id_from_key "contacts"]]$party_id/" +} +ad_proc -public contact::revision::new { + {-party_id:required} + {-party_revision_id ""} +} { + create a contact revision +} { + set extra_vars [ns_set create] + oacs_util::vars_to_ns_set -ns_set $extra_vars -var_list {party_id party_revision_id} + return [package_instantiate_object \ + -extra_vars $extra_vars contact_party_revision] +} - set widget_string "contact_attribute__$attribute\:$datatype\($widget\)" +ad_proc -public contact::live_revision { + {-party_id:required} +} { + create a contact revision +} { + if {[db_0or1row revision_exists_p {select 1 from cr_items where item_id = :party_id}]} { + return [item::get_live_revision $party_id] + } else { + return "" + } +} +ad_proc -public contact::subsite_user_group { + {-party_id:required} +} { + create a contact revision +} { + if {[db_0or1row revision_exists_p {select 1 from cr_items where item_id = :party_id}]} { + return [item::get_live_revision $party_id]} else { + return "" + } +} - if { ![exists_and_not_null required_p] } { - append widget_string ",optional" - } else { - if { [string is false $required_p] } { - append widget_string ",optional" - } - } - if { [exists_and_not_null multiple_p] } { - if { [string is true $multiple_p] } { - append widget_string ",multiple" - } - } +ad_proc -private contact::person_upgrade_to_user { + {-person_id ""} +} { + Upgrade a person to a user. This proc does not send an email to the newly created user. +} { + contact::flush -party_id $person_id + set user_id $person_id + set username [contact::email -party_id $person_id] + set authority_id [auth::authority::local] - if { [exists_and_not_null nospell_p] } { - if { [string is true $nospell_p] } { - append widget_string ",nospell" - } - } + # Make sure that we do not upgrade an already existing user + if {![contact::user_p -party_id $person_id]} { + db_transaction { + db_dml upgrade_user {update acs_objects set object_type = 'user' where object_id = :user_id; + + insert into users + (user_id, authority_id, username, email_verified_p) + values + (:user_id, :authority_id, :username, 't'); + + } + # Make sure that we we did not store user preferences before + if {![db_string user_prefs_p "select 1 from user_preferences where user_id = :user_id" -default "0"]} { + db_dml update_user_prefs {insert into user_preferences + (user_id) + values + (:user_id); + } + } + + # we reset the password in admin mode. this means that an email + # will not automatically be sent. + auth::password::reset -authority_id [auth::authority::local] -username $username -admin + group::add_member \ + -group_id "-2" \ + -user_id $person_id \ + -rel_type "membership_rel" + + # Grant the user to update the password on himself + permission::grant -party_id $user_id -object_id $user_id -privilege write - set temp_element [list $widget_string [list "label" "$name"]] + return 1 + } on_error { + error "There was an error in contact::person_upgrade_to_user: $errmsg" + return 0 + } + } +} - if { $storage_column == "option_map_id" } { - lappend temp_element [list "options" [db_list_of_lists select_element_options { - select option, option_id - from contact_attribute_options - where attribute_id = :attribute_id - order by sort_order - } ]] - } +ad_proc -private contact::group::new { + {-group_id ""} + {-email ""} + {-url ""} + -group_name:required + {-join_policy "open"} + {-context_id:required} +} { + this creates a new group for use with contacts (and the permissions system) +} { + set creation_user [ad_conn user_id] + set creation_ip [ad_conn peeraddr] + set group_name [lang::util::convert_to_i18n -prefix "group" -text "$group_name"] - if { [exists_and_not_null help_p] } { - if { [string is true $help_p] } { - lappend temp_element "help" - } - } + return [db_string create_group {}] +} - if { [exists_and_not_null help_text] } { - lappend temp_element [list "help_text" $help_text] - } +ad_proc -public contact::group::map { + -group_id:required + {-package_id ""} + {-default_p "f"} +} { + this creates a new group for use with contacts (and the permissions system) +} { + if {[empty_string_p $package_id]} { + set package_id [ad_conn package_id] + } + db_dml map_group {} +} - if { $datatype == "date" && [exists_and_not_null format] } { - lappend temp_element [list "format" "$format"] - } +ad_proc -public contact::group::parent { + -group_id:required +} { + returns the group_id for which this group is a component, if none then it return null +} { + return [db_string get_parent {} -default {}] +} - if { [exists_and_not_null html] } { - set temp_html "" - foreach element [lrange $html 0 [llength $html]] { - lappend temp_html "[lindex $element 0]" - } - if { [exists_and_not_null temp_html] } { - lappend temp_element [list "html" $temp_html] - } - } +ad_proc -public contact::groups { + {-expand "all"} + {-indent_with "..."} + {-privilege_required "read"} + {-output "list"} + {-all:boolean} + {-no_member_count:boolean} +} { +} { + set user_id [ad_conn user_id] + set group_list [list] + # Filter clause + # set filter_clause "" + set filter_clause "and groups.group_id not in (select community_id from dotlrn_communities_all)" + db_foreach get_groups {} { + # We check if the group has the required privilege + # specified on privilege_required switch, if not then + # we just simple continue with the next one + if { ![permission::permission_p -object_id $group_id -party_id $user_id -privilege $privilege_required] } { + continue + } - if { [exists_and_not_null heading] } { - lappend temp_element [list "section" "$heading"] + if { $mapped_p || $all_p} { + lappend group_list [list [lang::util::localize $group_name] $group_id $member_count "1" $mapped_p $default_p] + if { $component_count > 0 && ( $expand == "all" || $expand == $group_id ) } { + db_foreach get_components {} { + if { $mapped_p || $all_p} { + lappend group_list [list "$indent_with$group_name" $group_id $member_count "2" $mapped_p $default_p] + } + } } - - lappend element_list "$temp_element" } - - return $element_list } + set group_list [ams::util::localize_list_of_lists -list $group_list] - - - - - ad_proc -public ad_form_values { - object_id - party_id - } { - get the attribute_values for a contact - } { - - if { [string is true [contact::exists_p $party_id]] } { - set user_id [ad_conn user_id] - - - contacts::get::values::multirow -multirow_name "ad_form_values" -party_id $party_id -object_id $object_id -permission "write" - - - set courses_info_set [ns_set create] - - template::multirow -unclobber foreach ad_form_values { - ns_set put $courses_info_set contact_attribute__$attribute_name $ad_form_value + switch $output { + list { + set list_output [list] + foreach group $group_list { + if {$no_member_count_p} { + lappend list_output [list [lindex $group 0] [lindex $group 1]] + } else { + lappend list_output [list [lindex $group 0] [lindex $group 1] [lindex $group 2]] + } } - - # Now, set the variables in the caller's environment - ad_ns_set_to_tcl_vars -level 2 $courses_info_set - ns_set free $courses_info_set - + return $list_output } + ad_form { + set ad_form_output [list] + foreach group $group_list { + lappend ad_form_output [list [lindex $group 0] [lindex $group 1]] + } + return $ad_form_output + } + default { + return $group_list + } } - - - } +ad_proc -public contact::special_attributes::ad_form_values { + -party_id:required + -form:required +} { +} { + set object_type [contact::type -party_id $party_id] -namespace eval contacts::get::values:: { + db_1row get_extra_info { + select email, url + from parties + where party_id = :party_id} + set element_list [list email url] - ad_proc multirow { - {-multirow_name} - {-permission "read"} - {-object_id} - {-party_id} - {-orderby "sort_order,asc"} - } { - Returns a multirow - } { - - set user_id [ad_conn user_id] - - template::multirow create $multirow_name attribute_name attribute_id pretty_attribute_name ad_form_value pretty_value pretty_value_html sort_order sort_key - - set custom_field_list [contact::get::custom_field_list $party_id] - set custom_field_sql_list [contacts::util::sqlify_list $custom_field_list] + if { [lsearch [list person user] $object_type] >= 0 } { - set sort_order "0" + array set person [person::get -person_id $party_id] + set first_names $person(first_names) + set last_name $person(last_name) - db_foreach select_attribute_values "" { - - set attribute_name $attribute - set attribute_id $attribute_id - set pretty_attribute_name [contacts::attribute::name $attribute_id] - - if { [lsearch $custom_field_list $attribute] >= 0 } { - - if { $attribute == "organization_name" } { - set ad_form_value [db_string organization_name_from_party_id {} -default {}] - set pretty_value $ad_form_value - } - if { $attribute == "organization_type" } { - set ad_form_value [list] - set pretty_value {} - db_foreach organization_types_from_party_and_attribute_id {} { - if { [llength $ad_form_value] > 0 } { - append pretty_value "\n" - } - lappend ad_form_value $option_id - append pretty_value $option - } - } - if { $attribute == "legal_name" } { - set ad_form_value [db_string legal_name_from_party_id {} -default {}] - set pretty_value $ad_form_value - } - if { $attribute == "reg_number" } { - set ad_form_value [db_string reg_number_from_party_id {} -default {}] - set pretty_value $ad_form_value - } - if { $attribute == "first_names" } { - set ad_form_value [db_string first_names_from_party_id {} -default {}] - set pretty_value $ad_form_value - } - if { $attribute == "last_name" } { - set ad_form_value [db_string last_name_from_party_id {} -default {}] - set pretty_value $ad_form_value - } - if { $attribute == "email" } { - set ad_form_value [db_string email_from_party_id {} -default {}] - set pretty_value $ad_form_value - } - if { $attribute == "url" } { - set ad_form_value [db_string url_from_party_id {} -default {}] - set pretty_value $ad_form_value - } - - } else { - - set pretty_value $value - set ad_form_value $value - - if { $storage_column == "address_id" } { - contacts::postal_address::get -address_id "$address_id" -array "address_info" - set ad_form_value [list $address_info(delivery_address) $address_info(municipality) $address_info(region) $address_info(postal_code) $address_info(country_code)] - set pretty_value "$address_info(delivery_address)\n$address_info(municipality), $address_info(region) $address_info(postal_code)\n$address_info(country_code)" - } - if { $storage_column == "number_id" && [exists_and_not_null number_id] } { - contacts::telecom_number::get -number_id $number_id -array "telecom_info" - set ad_form_value $telecom_info(subscriber_number) - set pretty_value $telecom_info(subscriber_number) - } - if { $storage_column == "time" && [exists_and_not_null time] } { - set ad_form_value $time - set pretty_value $time - } - if { $storage_column == "option_map_id" && [exists_and_not_null option_map_id] } { - set pretty_value {} - set ad_form_value [list] - db_foreach select_options_from_map {} { - if { [llength $ad_form_value] > 0 } { - # we know there has been a previous entry so we can put in a comma - append pretty_value "\n" - } - append pretty_value $option - lappend ad_form_value $option_id - } - } - - } - if { [exists_and_not_null ad_form_value] || [exists_and_not_null pretty_value] } { - incr sort_order - set pretty_value_html [ad_convert_to_html $pretty_value] - template::multirow append $multirow_name $attribute_name $attribute_id $pretty_attribute_name $ad_form_value $pretty_value $pretty_value_html $sort_order - } - - } + lappend element_list first_names last_name + } elseif {$object_type == "organization" } { - set orderby [split $orderby ","] - set orderby_field [lindex $orderby 0] - if { [lindex $orderby 1] == "asc" } { - set orderby_direction {-increasing} - } else { - set orderby_direction {-decreasing} - } - template::multirow sort $multirow_name -dictionary $orderby_direction $orderby_field - + db_0or1row get_org_info { + select name, legal_name, reg_number, notes + from organizations + where organization_id = :party_id} + lappend element_list name legal_name reg_number notes } - - + + foreach element $element_list { + if {[exists_and_not_null $element]} { + if {[template::element::exists $form $element]} { + template::element::set_value $form $element [set $element] + } + } + } } - -namespace eval contacts::save::ad_form { - - ad_proc -public values { - object_id - party_id - - } { - this code saves attributes input in a form - } { - - set user_id [ad_conn user_id] - - if { [exists_and_not_null party_id] } { - if { ![contact::exists_p $party_id] } { - set party_id [contacts::contact::create -party_id $party_id] - } - } else { - set party_id [contacts::contact::create] +ad_proc -public contact::special_attributes::ad_form_save { + -party_id:required + -form:required +} { +} { + set object_type [contact::type -party_id $party_id] + set element_list [list email url] + if { [lsearch [list person user] $object_type] >= 0 } { + lappend element_list first_names last_name + } elseif {$object_type == "organization" } { + lappend element_list name legal_name reg_number notes + } + foreach element $element_list { + if {[template::element::exists $form $element]} { + set value [template::element::get_value $form $element] + switch $element { + email { + if {[db_0or1row party_is_user_p {select '1' from users where user_id = :party_id}]} { + if {[exists_and_not_null value]} { + set username $value + } else { + set username $party_id + } + acs_user::update -user_id $party_id -username $username + } + party::update -party_id $party_id -email $value -url [db_string get_url {select url from parties where party_id = :party_id} -default {}] + } + url { + party::update -party_id $party_id -email [db_string get_email {select email from parties where party_id = :party_id} -default {}] -url $value + } + default { + set $element $value + } + } } - + } + if { [lsearch [list person user] $object_type] >= 0 } { - set locale [lang::conn::locale -site_wide] + # first_names and last_name are required - set object_type [contact::get::object_type $party_id] + if {[exists_and_not_null first_names] + && [exists_and_not_null last_name]} { + person::update -person_id $party_id -first_names $first_names -last_name $last_name + } else { + if {![exists_and_not_null first_names]} { + error "The object type was person but first_names (a required element) did not exist" + } + if {![exists_and_not_null last_name]} { + error "The object type was person but first_names (a required element) did not exist" + } + } + } elseif {$object_type == "organization" } { - set attr_value_temp "" + # name is required - db_foreach select_attributes {} { - - set attribute_value_temp [string trim [template::element::get_value entry "contact_attribute__$attribute"]] - - if { $storage_column == "address_id" } { - - # I need to verify that something has changed here - - set delivery_address [string trim [template::util::address::get_property delivery_address $attribute_value_temp]] - set municipality [string trim [template::util::address::get_property municipality $attribute_value_temp]] - set region [string trim [template::util::address::get_property region $attribute_value_temp]] - set postal_code [string trim [template::util::address::get_property postal_code $attribute_value_temp]] - set country_code [string trim [template::util::address::get_property country_code $attribute_value_temp]] - - - set old_address_id "" - db_0or1row select_old_address_id {} - if { [exists_and_not_null old_address_id] } { - # the address in the database is the same - set address_id $old_address_id - } else { - # the address in the database is different so we need to add one - if { [exists_and_not_null delivery_address] && [exists_and_not_null country_code] } { - set address_id [contacts::postal_address::new \ - -delivery_address $delivery_address \ - -municipality $municipality \ - -region $region \ - -postal_code $postal_code \ - -country_code $country_code ] - } else { - set address_id "" - } - } - - contacts::attribute::value::save \ - -attribute_id $attribute_id \ - -party_id $party_id \ - -address_id $address_id - - } - if { $storage_column == "number_id" } { - - set old_number_id "" - db_0or1row select_old_number_id {} - if { [exists_and_not_null old_number_id] } { - # the number in the database is the same - set number_id $old_number_id - } else { - # the telecom_number in the database is different so we need to add one - if { [exists_and_not_null attribute_value_temp] } { - set number_id [contacts::telecom_number::new -subscriber_number $attribute_value_temp ] - } else { - set number_id "" - } - } - - contacts::attribute::value::save \ - -attribute_id $attribute_id \ - -party_id $party_id \ - -number_id $number_id - } - if { $storage_column == "option_map_id" } { - - set attribute_value_temp [string trim [template::element::get_values entry "contact_attribute__$attribute"]] - - if { [exists_and_not_null attribute_value_temp] } { - - # first we verify that the address has changed. otherwise we pass on the old option_map_id - db_0or1row get_option_map_id {} + if {[exists_and_not_null name]} { + if {![exists_and_not_null legal_name]} {set legal_name "" } + if {![exists_and_not_null reg_number]} {set reg_number "" } + if {![exists_and_not_null notes]} {set notes "" } + db_dml update_org { + update organizations + set name = :name, + legal_name = :legal_name, + reg_number = :reg_number, + notes = :notes + where organization_id = :party_id} + } else { + error "The object type was organization but name (a required element) did not exist" + } + } +} - if { [exists_and_not_null option_map_id] } { - # we know that a previous entry exists +ad_proc -public contacts::get_values { + {-attribute_name ""} + {-group_name ""} + {-group_id ""} + {-contacts_package_id ""} + {-party_id:required} + {-object_type:required} +} { + If attribute_name is provided return the value of the attribute for the party, otherwise return an array with all elements for this party - set old_option_ids "" - db_foreach get_old_options {} { - lappend old_option_ids $option_id - } - set new_option_ids $attribute_value_temp + @author Malte Sussdorff (sussdorff@sussdorff.de) + @creation-date 2005-06-09 - set same_count 0 - foreach option_id $old_option_ids { - if {![empty_string_p $option_id]} { - if { [regsub -all $option_id $new_option_ids $option_id new_option_ids] } { - incr same_count - } - } - } - if { [llength $new_option_ids] == $same_count && [llength $old_option_ids] == $same_count } { - # the lists have the same values - do nothing - } else { - # the lists are different - db_1row get_new_option_map_id {} + @param attribute_name If attribute name is provided, return the value of the attribute for the user. Otherwise return an array with all attributes. - foreach option_id $attribute_value_temp { - if {![empty_string_p $option_id]} { - db_dml insert_options_map {} - } - } - } - } else { - # there is no previous entry in the database - db_1row get_new_option_map_id {} + @param group_name Name of the group that contains the value of the attribute (e.g. #acs-kernel.Registered_Users) - foreach option_id $attribute_value_temp { - if {![empty_string_p $option_id]} { - db_dml insert_options_map { - insert into contact_attribute_option_map - (option_map_id,party_id,option_id) - values - (:option_map_id,:party_id,:option_id) - } - } - } - } - - set attribute_value_temp $option_map_id - } - - contacts::attribute::value::save \ - -attribute_id $attribute_id \ - -party_id $party_id \ - -option_map_id $attribute_value_temp - } - if { $storage_column == "time" } { - contacts::attribute::value::save \ - -attribute_id $attribute_id \ - -party_id $party_id \ - -time [contacts::date::sqlify -date $attribute_value_temp] - } - if { $storage_column == "value" } { - contacts::attribute::value::save \ - -attribute_id $attribute_id \ - -party_id $party_id \ - -value $attribute_value_temp - } - + @param group_id Instead of group_name you can specify the group_id directly + @param contacts_package_id The package_id of the contacts package that contains the element. - - - set custom_fields [list organization_name legal_name reg_number organization_type first_names last_name email url] - - if { [lsearch $custom_fields $attribute] >= 0 } { - if { $attribute == "email" } { - db_dml update_parties_email {} - } - if { $attribute == "url" } { - db_dml update_parties_url {} - } - if { $object_type == "organization" } { - # [list organization_name legal_name reg_number organization_type] - if { $attribute == "organization_name" } { - db_dml update_organizations_name {} - } - if { $attribute == "legal_name" } { - db_dml update_organizations_legal_name {} - } - if { $attribute == "reg_number" } { - db_dml update_organizations_reg_number {} - } - if { $attribute == "organization_type" } { - db_dml delete_org_type_maps {} - set attribute_value_temp [string trim [template::element::get_values entry "contact_attribute__$attribute"]] - foreach option_id $attribute_value_temp { - if {![empty_string_p $option_id]} { - db_1row get_organization_type_id {} - - - db_dml insert_mapping {} - } - } - } - } - if { $object_type == "person" } { - # [list first_names last_name] - if { $attribute == "first_names" } { - db_dml update_persons_first_names {} - } - if { $attribute == "last_name" } { - db_dml update_persons_last_name {} - } - - - } - - - } - - - - - - - - - } + @return - return $party_id + @error +} { + if {[empty_string_p $contacts_package_id]} { + set contacts_package_id [ad_conn package_id] } + if {[empty_string_p $group_id]} { + if {![db_0or1row get_group_id "select group_id from groups where group_name = :group_name"]} { + ad_return_error "ERROR" "[_ contacts.lt_Unable_to_retrieve_gr]" + } + } + + set list_name "${contacts_package_id}__${group_id}" + set revision_id [contact::live_revision -party_id $party_id] + set values [ams::values -package_key "contacts" -object_type $object_type -list_name $list_name -object_id $revision_id] + array set return_array [list] + # Never forget to localize the values retrieved from ams. + foreach {section attribute pretty_name value} $values { + set return_array($attribute) [lang::util::localize $value] + } + + if {![empty_string_p $attribute_name]} { + return $return_array($attribute_name) + } else { + return [array get return_array] + } } Index: openacs-4/packages/contacts/tcl/view-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/tcl/Attic/view-procs-postgresql.xql,v diff -u -N -r1.3 -r1.3.2.1 --- openacs-4/packages/contacts/tcl/view-procs-postgresql.xql 27 Feb 2005 17:07:18 -0000 1.3 +++ openacs-4/packages/contacts/tcl/view-procs-postgresql.xql 30 Nov 2005 15:31:01 -0000 1.3.2.1 @@ -1,87 +1,85 @@ - - - -postgresql7.2 - - - - select sort_order - from contact_views - where contact_object_type = :contact_object_type - order by sort_order desc limit 1 - - - - - - - select contact__view_create( - null, - :src, - :privilege_required, - :privilege_object_id, - :contact_object_type, - :package_id, - :sort_order, - now(), - :creation_user, - :creation_ip, - :context_id) as view_id - - - - - - - select contact__view_name_save( - :view_id, - :locale, - :name - ) - - - - - - - select '1' from contact_views limit 1 - - - - - - - select package_id from apm_packages where package_key = 'contacts' - - - - - - - select 1 from contact_views where view_id = :view_id and contact_object_type = :object_type - - - - - - - select * - from contact_views - where view_id = :view_id - - - - - - - select name from contact_view_names where view_id = :view_id and locale = :locale - - - - - - select view_id from contact_views where contact_object_type = :object_type order by sort_order limit 1 - - - - + + + + + + select sort_order + from contact_views + where contact_object_type = :contact_object_type + order by sort_order desc limit 1 + + + + + + + select contact__view_create( + null, + :src, + :privilege_required, + :privilege_object_id, + :contact_object_type, + :package_id, + :sort_order, + now(), + :creation_user, + :creation_ip, + :context_id) as view_id + + + + + + + select contact__view_name_save( + :view_id, + :locale, + :name + ) + + + + + + + select '1' from contact_views limit 1 + + + + + + + select package_id from apm_packages where package_key = 'contacts' + + + + + + + select 1 from contact_views where view_id = :view_id and contact_object_type = :object_type + + + + + + + select * + from contact_views + where view_id = :view_id + + + + + + + select name from contact_view_names where view_id = :view_id and locale = :locale + + + + + + select view_id from contact_views where contact_object_type = :object_type order by sort_order limit 1 + + + + Index: openacs-4/packages/contacts/www/add-edit-complaint.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/add-edit-complaint.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/add-edit-complaint.adp 30 Nov 2005 15:31:02 -0000 1.4.2.2 @@ -0,0 +1,6 @@ + +@page_title;noquote@ +@context;noquote@ + + + \ No newline at end of file Index: openacs-4/packages/contacts/www/add-edit-complaint.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/add-edit-complaint.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/add-edit-complaint.tcl 30 Nov 2005 15:31:02 -0000 1.3.2.2 @@ -0,0 +1,21 @@ +ad_page_contract { + Page to add or edit one complaint. + + @author Miguel Marin (miguelmarin@viaro.net) + @author Viaro Networks www.viaro.net + +} { + {complaint_id ""} + customer_id:notnull + {supplier_id ""} + {return_url ""} + {object_id ""} + {mode "edit"} +} + +set page_title "[_ contacts.Edit_complaint]" +set context [list $page_title] + +if { [empty_string_p $return_url] } { + set return_url [get_referrer] +} \ No newline at end of file Index: openacs-4/packages/contacts/www/bulk-update.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/bulk-update.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/bulk-update.adp 30 Nov 2005 15:31:02 -0000 1.1.2.2 @@ -0,0 +1,4 @@ + + + + Index: openacs-4/packages/contacts/www/bulk-update.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/bulk-update.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/bulk-update.tcl 30 Nov 2005 15:31:02 -0000 1.6.2.2 @@ -0,0 +1,148 @@ +ad_page_contract { + Bulk update contacts + + @author Matthew Geddert openacs@geddert.com + @creation-date 2005-06-14 + @cvs-id $Id: bulk-update.tcl,v 1.6.2.2 2005/11/30 15:31:02 miguelm Exp $ +} { + {party_id:integer,multiple ""} + {person_ids ""} + {organization_ids ""} + {attribute_id ""} + {return_url "./"} +} -validate { + parties_submitted_p { + if { [llength $party_id] == 0 && [llength $person_ids] == 0 && [llength $organization_ids] == 0 } { + ad_complain [_ contacts.lt_You_need_parties_to_bulk_update] + } + } +} + +set title "[_ contacts.Bulk_Update]" +set user_id [ad_conn user_id] +set context [list $title] +set package_id [ad_conn package_id] +set recipients [list] +if { [exists_and_not_null party_id] } { + foreach party_id $party_id { + if { [person::person_p -party_id $party_id] } { + lappend person_ids $party_id + } else { + lappend organization_ids $party_id + } + } +} +set organization_count [llength $organization_ids] +set person_count [llength $person_ids] + + +set people [list] +foreach party_id $person_ids { + lappend people "[person::name -person_id $party_id]" +} +set people [join $people ", "] + +set organizations [list] +foreach party_id $organization_ids { + lappend organizations "[organizations::name -organization_id $party_id]" +} +set organizations [join $organizations ", "] + +set form_elements { + person_ids:text(hidden),optional + organization_ids:text(hidden),optional + return_url:text(hidden) +} + + +if { $person_count == 0 } { + lappend form_elements "people:text(hidden),optional" +} elseif { $person_count == 1 } { + lappend form_elements [list people:text(inform),optional [list label [_ contacts.Person]]] +} else { + lappend form_elements [list people:text(inform),optional [list label [_ contacts.People]]] +} + +if { $organization_count == 0 } { + lappend form_elements "organizations:text(hidden),optional" +} elseif { $organization_count == 1 } { + lappend form_elements [list organizations:text(inform),optional [list label [_ contacts.Organization]]] +} else { + lappend form_elements [list organizations:text(inform),optional [list label [_ contacts.Organizations]]] +} + +if { $person_count > 0 && $organization_count > 0 } { + set object_type "party" +} elseif { $person_count > 0 } { + set object_type "person" +} elseif { $organization_count > 0 } { + set object_type "organization" +} + + +if { [exists_and_not_null attribute_id] } { + ams::attribute::get -attribute_id $attribute_id -array attr + lappend form_elements [list attribute_id:integer(hidden)] + lappend form_elements [ams::widget \ + -widget $attr(widget) \ + -request "ad_form_widget" \ + -attribute_id $attr(attribute_id) \ + -attribute_name $attr(attribute_name) \ + -pretty_name $attr(pretty_name) \ + -form_name "bulk_update" \ + -optional_p "1"] + set edit_buttons [list [list "[_ contacts.Bulk_Update_these_Contacts]" update]] + lappend form_elements +} else { + + set attribute_options [db_list_of_lists get_attributes {}] + set attribute_options [ams::util::localize_and_sort_list_of_lists -list $attribute_options] + + set attribute_label [_ contacts.Attribute] + set attribute_options [concat [list [list "" ""]] $attribute_options] + lappend form_elements {attribute_id:integer(select) {label $attribute_label} {options $attribute_options}} + set edit_buttons [list [list "[_ contacts.Next]" next]] + +} + + +ad_form -action bulk-update \ + -name bulk_update \ + -cancel_label "[_ contacts.Cancel]" \ + -cancel_url $return_url \ + -edit_buttons $edit_buttons \ + -form $form_elements \ + -on_request { + } -on_submit { + if { [template::form get_button bulk_update] == "update" } { + db_transaction { + ams::attribute::get -attribute_id $attribute_id -array attr + set value_id [ams::widget \ + -widget $attr(widget) \ + -request "form_save_value" \ + -attribute_id $attr(attribute_id) \ + -attribute_name $attr(attribute_name) \ + -pretty_name $attr(pretty_name) \ + -form_name "bulk_update" \ + -optional_p "1"] + set party_ids [concat $organization_ids $person_ids] + + foreach party_id $party_ids { + set old_revision_id [contact::live_revision -party_id $party_id] + set new_revision_id [contact::revision::new -party_id $party_id] + if { [exists_and_not_null old_revision_id] } { + ams::object_copy -from $old_revision_id -to $new_revision_id + } + ams::attribute::value_save -object_id $new_revision_id -attribute_id $attribute_id -value_id $value_id + } + } + } + } -after_submit { + contact::search::flush_results_counts + if { [template::form get_button bulk_update] == "update" } { + ad_returnredirect -message [_ contacts.lt_your_bulk_update_was_successful] $return_url + ad_script_abort + } + } + + Index: openacs-4/packages/contacts/www/bulk-update.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/bulk-update.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/bulk-update.xql 30 Nov 2005 15:31:02 -0000 1.1.2.2 @@ -0,0 +1,14 @@ + + + + + + select pretty_name, + attribute_id + from ams_attributes + where object_type in ([ams::object_parents -sql -object_type $object_type]) + and widget in (select widget from ams_widgets where value_method in ( 'ams_value__time', 'ams_value__options')) + + + + Index: openacs-4/packages/contacts/www/changes.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/changes.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/changes.adp 30 Nov 2005 15:31:02 -0000 1.1.2.2 @@ -0,0 +1,19 @@ + +@party_id@ + + + + + + + + + + + +
+

#contacts.Preview#

+
+ +
+
\ No newline at end of file Index: openacs-4/packages/contacts/www/changes.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/changes.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/changes.tcl 30 Nov 2005 15:31:02 -0000 1.1.2.2 @@ -0,0 +1,17 @@ +ad_page_contract { + + @author Miguel Marin (miguelmarin@viaro.net) + @author Viaro Networks www.viaro.net + @creation-date 2005-09-12 +} { + {party_id:integer} + {revision_id:integer "" } +} -validate { + contact_exists -requires {party_id} { + if { ![contact::exists_p -party_id $party_id] } { + ad_complain "[_ contacts.lt_The_contact_specified]" + } + } +} + +ad_return_template Index: openacs-4/packages/contacts/www/comment-add.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/comment-add.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/comment-add.tcl 30 Nov 2005 15:31:02 -0000 1.3.2.2 @@ -0,0 +1,95 @@ +ad_page_contract { + + @author Matthew Geddert openacs@geddert.com + @creation-date 2004-07-28 + @cvs-id $Id: comment-add.tcl,v 1.3.2.2 2005/11/30 15:31:02 miguelm Exp $ + + +} { + {comment ""} + {comment_id:integer ""} + {party_id:integer} + {return_url ""} +} -validate { + contact_exists -requires {party_id} { + if { ![contact::exists_p -party_id $party_id] && ![ad_form_new_p -key party_id] } { + ad_complain "[_ contacts.lt_The_contact_specified]" + } + } +} + +if { ![exists_and_not_null comment_id] } { + set comment_id [db_nextval acs_object_id_seq] +} +# check to see if the user can create comments on this object +#ad_require_permission $object_id general_comments_create + +# insert the comment into the database +set creation_user [ad_conn user_id] +set creation_ip [ad_conn peeraddr] +set context_id $party_id +set comment_mime_type "text/plain" +set title "" +if { [string trim $comment] != "" } { + db_transaction { + set message_id [db_exec_plsql insert_comment { + select acs_message__new ( + :comment_id, -- 1 p_message_id + NULL, -- 2 p_reply_to + current_timestamp, -- 3 p_sent_date + NULL, -- 4 p_sender + NULL, -- 5 p_rfc822_id + :title, -- 6 p_title + NULL, -- 7 p_description + :comment_mime_type, -- 8 p_mime_type + :comment, -- 9 p_text + NULL, -- empty_blob(), -- 10 p_data + 0, -- 11 p_parent_id + :context_id, -- 12 p_context_id + :creation_user, -- 13 p_creation_user + :creation_ip, -- 14 p_creation_ip + 'acs_message', -- 15 p_object_type + 't' -- 16 p_is_live + ) + }] + + db_dml add_entry { + insert into general_comments + (comment_id, + object_id, + category) + values + (:comment_id, + :party_id, + null) + } + + } on_error { + ad_return_error "[_ contacts.Error]" $errmsg + } +} +if { [string is false [exists_and_not_null return_url]] } { + set return_url [contact::url -party_id $party_id] +} + +ad_returnredirect -message "[_ contacts.Comment_Added]" $return_url +ad_script_abort + + + + + + + + + + + + + + + + + + +ad_return_template Index: openacs-4/packages/contacts/www/comments.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/comments.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/comments.adp 30 Nov 2005 15:31:02 -0000 1.1.2.2 @@ -0,0 +1,4 @@ + +@party_id@ + + Index: openacs-4/packages/contacts/www/comments.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/comments.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/comments.tcl 30 Nov 2005 15:31:02 -0000 1.2.2.2 @@ -0,0 +1,19 @@ +ad_page_contract { + + @author Matthew Geddert openacs@geddert.com + @creation-date 2004-07-28 + @cvs-id $Id: comments.tcl,v 1.2.2.2 2005/11/30 15:31:02 miguelm Exp $ + + +} { + {party_id:integer} + {page "comments"} +} -validate { + contact_exists -requires {party_id} { + if { ![contact::exists_p -party_id $party_id] } { + ad_complain "[_ contacts.lt_The_contact_specified]" + } + } +} + +ad_return_template Index: openacs-4/packages/contacts/www/complaint-ae.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/complaint-ae.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/complaint-ae.adp 30 Nov 2005 15:31:02 -0000 1.3.2.2 @@ -0,0 +1,6 @@ + +@supplier_id@ + + + Index: openacs-4/packages/contacts/www/complaint-ae.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/complaint-ae.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/complaint-ae.tcl 30 Nov 2005 15:31:02 -0000 1.4.2.2 @@ -0,0 +1,28 @@ +ad_page_contract { + + @author Matthew Geddert openacs@geddert.com + @creation-date 2005-07-09 + @cvs-id $Id: complaint-ae.tcl,v 1.4.2.2 2005/11/30 15:31:02 miguelm Exp $ + + +} { + {supplier_id:integer} + {customer_id ""} + {project_id ""} + {object_id ""} +} -validate { + contact_exists -requires {party_id} { + if { ![contact::exists_p -party_id $party_id] } { + ad_complain "[_ contacts.lt_The_contact_specified]" + } + } +} + +if {![empty_string_p $project_id]} { + if {[empty_string_p $customer_id]} { + set customer_id [db_string get_customer_id "select p.customer_id from pm_projectsx p, cr_items i where p.item_id = :project_id and i.live_revision = p.revision_id"] + } + set object_id $project_id +} + +ad_return_template Index: openacs-4/packages/contacts/www/complaint.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/complaint.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/complaint.adp 30 Nov 2005 15:31:02 -0000 1.1.2.2 @@ -0,0 +1,4 @@ + +@party_id@ + + Index: openacs-4/packages/contacts/www/complaint.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/complaint.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/complaint.tcl 30 Nov 2005 15:31:02 -0000 1.1.2.2 @@ -0,0 +1,22 @@ +ad_page_contract { + + @author Matthew Geddert openacs@geddert.com + @creation-date 2005-07-09 + @cvs-id $Id: complaint.tcl,v 1.1.2.2 2005/11/30 15:31:02 miguelm Exp $ + + +} { + {party_id:integer} + {page "Complaints"} + {customer_id ""} +} -validate { + contact_exists -requires {party_id} { + if { ![contact::exists_p -party_id $party_id] } { + ad_complain "[_ contacts.lt_The_contact_specified]" + } + } +} + +set supplier_id $party_id + +ad_return_template Index: openacs-4/packages/contacts/www/contact-add.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/contact-add.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/contact-add.adp 30 Nov 2005 15:31:02 -0000 1.4.2.2 @@ -0,0 +1,6 @@ + +party_ae.first_names + + + + Index: openacs-4/packages/contacts/www/contact-add.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/contact-add.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/contact-add.tcl 30 Nov 2005 15:31:02 -0000 1.37.2.2 @@ -0,0 +1,338 @@ +ad_page_contract { + + @author Matthew Geddert openacs@geddert.com + @creation-date 2004-07-28 + @cvs-id $Id: contact-add.tcl,v 1.37.2.2 2005/11/30 15:31:02 miguelm Exp $ + + +} { + {object_type "person"} + {group_ids ""} + {rel_type ""} + {role_two ""} + {object_id_two ""} +} -validate { + valid_type -requires {object_type} { + if { [lsearch [list organization person] $object_type] < 0 } { + ad_complain "[_ contacts.lt_You_have_not_specifie]" + } + } +} +set master_src [parameter::get -parameter "ContactsMaster"] +set default_group [contacts::default_group] + + +set group_list [concat [list [list [_ contacts.All_Contacts] $default_group "0"]] [contact::groups]] + +if {[empty_string_p $group_ids] && [llength $group_list] > 1} { + ad_returnredirect "[export_vars -base "../select-groups" -url {object_type}]" +} elseif { [lsearch $group_ids $default_group] < 0 } { + # an invalid group_ids list has been specified or they do not have permission to add person + ad_return_error "[_ contacts.lt_Insufficient_Permissi]" "[_ contacts.lt_You_do_not_have_permi]" +} + + +set path_info [ad_conn path_info] +if { $path_info == "add/person" } { + set object_type "person" +} elseif { $path_info == "add/organization" } { + set object_type "organization" +} + +set package_id [ad_conn package_id] +set user_id [ad_conn user_id] +set peeraddr [ad_conn peeraddr] + +set form_elements {party_id:key} +lappend form_elements {object_type:text(hidden)} +lappend form_elements {rel_type:text(hidden),optional} +lappend form_elements {object_id_two:text(hidden),optional} + +set application_group_id [application_group::group_id_from_package_id -package_id [ad_conn subsite_id]] + +if {[lsearch $group_ids $default_group] == -1} { + lappend group_ids $default_group +} + +lappend form_elements {group_ids:text(hidden)} + +# Save Group Information +if {[lsearch $group_ids $application_group_id] == -1} { + lappend group_ids $application_group_id +} + +set group_list [contact::groups -expand "all" -privilege_required "read"] +set group_list "{{All Contacts} $default_group 0} $group_list" + + +ad_form -name party_ae \ + -mode "edit" \ + -cancel_label "[_ contacts.Cancel]" \ + -cancel_url [export_vars -base contact -url {party_id}] \ + -edit_buttons [list [list "[_ acs-kernel.common_Save]" save] ]\ + -form $form_elements + +# List to get the elements to the form +set list_names [list] + +foreach group $group_list { + set group_id [lindex $group 1] + if { [lsearch $group_ids $group_id] >= 0 } { + + # Adding the list_name to get the elements in the form + lappend list_names [list ${package_id}__${group_id}] + + # Add the category widget(s) + set element_name "category_ids$group_id" + if {$group_id < 0} { + set element_name "category_ids[expr 0 - $group_id]" + } + + category::ad_form::add_widgets \ + -container_object_id $group_id \ + -categorized_object_id $user_id \ + -form_name party_ae \ + -element_name $element_name + + } +} + +# Creating the form +ad_form -extend -name party_ae -form [ams::ad_form::elements \ + -package_key "contacts" \ + -object_type $object_type \ + -list_names $list_names] + + +# Append relationship attributes + +if {[exists_and_not_null role_two]} { + set rel_type [db_string select_rel_type "select rel_type from contact_rel_types where secondary_object_type = :object_type and secondary_role = :role_two" -default ""] +} + +if {[exists_and_not_null rel_type]} { + ad_form -extend -name party_ae -form [ams::ad_form::elements -package_key "contacts" -object_type $rel_type -list_name [ad_conn package_id]] +} + +# Append the option to create a user who get's a welcome message send +# Furthermore set the title. + +if { $object_type == "person" } { + set title "[_ contacts.Add_a_Person]" +} else { + set title "[_ contacts.Add_an_Organization]" +} + +set context [list $title] + +callback contact::contact_form -package_id $package_id -form party_ae -object_type $object_type -group_ids $group_ids + +ad_form -extend -name party_ae \ + -on_request { + + if { $object_type == "person" } { + set required_attributes [list first_names last_name email] + } else { + set required_attributes [list name] + } + + set missing_elements [list] + foreach attribute $required_attributes { + if { [string is false [template::element::exists party_ae $attribute]] } { + lappend missing_elements $attribute + } + } + # make the error message multiple item aware + if { [llength $missing_elements] > 0 } { + ad_return_error "[_ contacts.Configuration_Error]" "[_ contacts.lt_Some_of_the_required_]
  • [join $missing_elements "
  • "]
" + } + } -new_request { + foreach group $group_ids { + if { ![permission::permission_p -object_id $group -party_id $user_id -privilege "create"] } { + ad_return_error "[_ contacts.lt_Insufficient_Permissi]" "[_ contacts.lt_You_do_not_have_permi]" + ad_script_abort + } + } + } -edit_request { + foreach group $group_ids { + if { ![permission::permission_p -object_id $group -party_id $user_id -privilege "write"] } { + ad_return_error "[_ contacts.lt_Insufficient_Permissi]" "[_ contacts.lt_You_do_not_have_permi]" + ad_script_abort + } + } + } -on_submit { + + # for orgs name needs to be unique + # for users username needs to be unique + # for all of them email needs to be unique + + if { $object_type == "person" } { + if { ![exists_and_not_null first_names] } { + template::element::set_error party_ae first_names "[_ contacts.lt_First_Names_is_requir]" + } + if { ![exists_and_not_null last_name] } { + template::element::set_error party_ae last_name "[_ contacts.lt_Last_Name_is_required]" + } + } else { + if { ![exists_and_not_null name] } { + template::element::set_error party_ae name "[_ contacts.Name_is_required]" + } else { + set other_organization_id [organization::get_by_name -name $name] + if { ![empty_string_p $other_organization_id] } { + set another_organization [contact::link -party_id $other_organization_id] + template::element::set_error party_ae name "[_ contacts.lt_-another_organization-_already_uses_this_name]" + } + } + } + + if { [exists_and_not_null email] } { + set other_party_id [party::get_by_email -email $email] + if { ![empty_string_p $other_party_id] } { + set another_contact [contact::link -party_id $other_party_id] + template::element::set_error party_ae email "[_ contacts.lt_-another_contact-_already_uses_this_email]" + } + } + + if { ![template::form::is_valid party_ae] } { + break + } + + } -new_data { + + if { $object_type == "person" } { + + if { ![exists_and_not_null url] } { + set url "" + } + + # Initialize Person + template::form create add_party + template::element create add_party email -value "$email" + template::element create add_party first_names -value "$first_names" + template::element create add_party last_name -value "$last_name" + template::element create add_party url -value "$url" + set party_id [party::new -party_id $party_id -form_id add_party person] + # party::new does not correctly save email address + party::update -party_id $party_id -email $email -url $url + + # in order to create a user we need a valid unique username (i.e. their email address). + # the on_submit block has already validated that this is in fact a valid and unique + # email address which will serve as their username + callback contact::person_add -package_id $package_id -person_id $party_id + + # Add the new categories and enter the Party into the groups + set cat_ids [list] + + foreach group_id $group_ids { + group::add_member \ + -group_id $group_id \ + -user_id $party_id \ + -rel_type "membership_rel" + + callback contact::person_new_group -person_id $party_id -group_id $group_id + set element_name "category_ids$group_id" + if {$group_id < 0} { + set element_name "category_ids[expr - $group_id]" + } + + set cat_ids [concat $cat_ids \ + [category::ad_form::get_categories \ + -container_object_id $group_id \ + -element_name $element_name]] + } + + category::map_object -remove_old -object_id $party_id $cat_ids + + + + } else { + + # Initialize Party Entry for organization + set party_id [organization::new -organization_id $party_id -name $name] + + foreach group_id $group_ids { + if {![empty_string_p $group_id]} { + + # relation-add does not work as there is no + # special procedure for organizations at the moment. + set rel_id [db_string insert_rels { select acs_rel__new (NULL::integer,'organization_rel',:group_id,:party_id,NULL,:user_id,:peeraddr) as org_rel_id }] + db_dml insert_state { insert into membership_rels (rel_id,member_state) values (:rel_id,'approved') } + callback contact::organization_new_group -organization_id $party_id -group_id $group_id + } + } + + callback contact::organization_new -package_id $package_id -contact_id $party_id -name $name + } + + # Save the contact information + # No clue why this is not part of the db_transaction though .... + contact::special_attributes::ad_form_save -party_id $party_id -form "party_ae" + set revision_id [contact::revision::new -party_id $party_id] + foreach group_id $group_ids { + ams::ad_form::save -package_key "contacts" \ + -object_type $object_type \ + -list_name "${package_id}__${group_id}" \ + -form_name "party_ae" \ + -object_id $revision_id + # execute group specific callbacks + group::get -group_id $group_id -array group_array + set group_name ${group_array(group_name)} + regsub -all " " $group_name "_" group_name + regsub -all {[^-a-zA-Z0-9_]} $group_name "" group_name + + if {[info exists contact::${object_type}_${group_array(group_name)}_new]} { + callback contact::${object_type}_${group_array(group_name)}_new -package_id $package_id -contact_id $party_id + } + } + + # Insert the relationship + if {[exists_and_not_null rel_type] && [exists_and_not_null object_id_two]} { + set rel_id {} + set context_id {} + set creation_user [ad_conn user_id] + set creation_ip [ad_conn peeraddr] + set rel_id [db_exec_plsql create_rel "select acs_rel__new ( + :rel_id, + :rel_type, + :party_id, + :object_id_two, + :context_id, + :creation_user, + :creation_ip + )"] + + if {[exists_and_not_null rel_type]} { + ams::ad_form::save -package_key "contacts" \ + -object_type $rel_type \ + -list_name [ad_conn package_id] \ + -form_name "party_ae" \ + -object_id $rel_id + } + + callback contact::${object_type}_new_rel -object_id_two $object_id_two -rel_type $rel_type -party_id $party_id + } + + # Add the user to the + set contact_link [contact::link -party_id $party_id] + set object_type [_ contacts.$object_type] + util_user_message -html -message "[_ contacts.lt_The_-object_type-_-contact_link-_was_added]" + + + } -after_submit { + contact::flush -party_id $party_id + contact::search::flush_results_counts + #the formbutton does not work. No clue how to fix it. +# if { [exists_and_not_null formbutton\:save_add_another] } { +# ad_returnredirect [export_vars -base "/contacts/$object_type/add" -url] +# } else { + if {[empty_string_p $object_id_two]} { + ad_returnredirect [contact::url -party_id $party_id] +# ad_returnredirect [export_vars -base "/contacts" -url {{query_id $group_id}}] + } else { + ad_returnredirect "/contacts/$object_id_two" + } + # } + ad_script_abort + } + +ad_return_template Index: openacs-4/packages/contacts/www/contact-ae-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/Attic/contact-ae-postgresql.xql,v diff -u -N --- openacs-4/packages/contacts/www/contact-ae-postgresql.xql 13 Jan 2005 13:57:06 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,60 +0,0 @@ - - - - postgresql7.1 - - - - - select organization_type_id - from contact_attribute_options cao, - organization_types ot - where cao.option = ot.type - and cao.option_id = :option_id_temp - - - - - - - - - select organization__new ( - null, - :contact_attribute__organization_name, - null, - :party_id, - :organization_type_id, - null, - null, - null, - :creation_user, - :creation_ip, - null - ) as party_id - - - - - - - - - select person__new ( - :party_id, - 'person', - now(), - :creation_user, - :creation_ip, - null, - null, - :contact_attribute__first_names, - :contact_attribute__last_name, - null - ) as party_id - - - - - - Index: openacs-4/packages/contacts/www/contact-ae.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/Attic/contact-ae.adp,v diff -u -N --- openacs-4/packages/contacts/www/contact-ae.adp 13 Jan 2005 13:57:06 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,6 +0,0 @@ - - -@title@ -@context@ - - Index: openacs-4/packages/contacts/www/contact-ae.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/Attic/contact-ae.tcl,v diff -u -N --- openacs-4/packages/contacts/www/contact-ae.tcl 13 Jan 2005 13:57:06 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,97 +0,0 @@ -ad_page_contract { - - - @author Matthew Geddert openacs@geddert.com - @creation-date 2004-07-28 - @cvs-id $Id: contact-ae.tcl,v 1.2 2005/01/13 13:57:06 jeffd Exp $ - -} { - {party_id:integer ""} - {object_type ""} - {return_url ""} -} -set user_id [auth::require_login] -permission::require_write_permission -object_id [ad_conn package_id] -action "write" - -if { [string is true [contact::exists_p $party_id]] } { - set context [list "\#acs-kernel.common_Edit\#"] - set title "\#acs-kernel.common_Edit\# [contact::get::name $party_id]" - set object_type [contact::get::object_type $party_id] -} else { - set context [list "\#acs-kernel.common_Add\#"] - if { $object_type == "organization" } { - set title "\#contacts.Add_an_Organization\#" - } else { - set title "\#contacts.Add_a_Person\#" - set object_type "person" - } - set party_id [contacts::util::next_object_id] -} - - -if { $object_type == "organization" } { - set object_id [contacts::util::organization_object_id] -} - -if { $object_type == "person" } { - set object_id [contacts::util::person_object_id] -} - -ad_form -name entry -action contact-ae -form { - party_id:key - object_type:text(hidden) - return_url:text(hidden),optional -} - -ad_form -extend -name entry -form [contacts::get::ad_form_elements $object_id $party_id] - -if { [string is true [contacts::categories::enabled_p]]} { - ad_form -extend -name entry -form { - {category_ids:integer(category),multiple,optional {label "Categories"} - {html {size 7}} {value {$party_id [ad_conn package_id]}}} - } -} - -ad_form -extend -name entry \ - -new_request { - } -edit_request { - if { [contact::exists_p $party_id] } { - contacts::get::ad_form_values $object_id $party_id - } - } -validate { - } -on_submit { - - - # this should probably be moved into a proc... - - if { ![contact::exists_p $party_id] } { - set creation_user [ad_conn user_id] - set creation_ip [ad_conn peeraddr] - - if { $object_type == "organization" } { - set option_id_temp [lindex $contact_attribute__organization_type 0] - db_1row get_organization_type_id {} - - db_1row create_org {} - } else { - db_1row create_person {} - } - } - - contacts::save::ad_form::values $object_id $party_id - if { [contacts::categories::enabled_p]} { - category::map_object -remove_old -object_id $party_id $category_ids - } - } -after_submit { - if { ![exists_and_not_null return_url] } { - set return_url "./" - } - ad_returnredirect -message "Contact '[contact::get::name $party_id]' Updated" $return_url - ad_script_abort - } - - - - - -ad_return_template Index: openacs-4/packages/contacts/www/contact-archive-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/Attic/contact-archive-postgresql.xql,v diff -u -N --- openacs-4/packages/contacts/www/contact-archive-postgresql.xql 13 Jan 2005 13:57:06 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,15 +0,0 @@ - - - - postgresql7.1 - - - - - insert into contact_archives (party_id) values (:party_id) - - - - - - Index: openacs-4/packages/contacts/www/contact-archive.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/Attic/contact-archive.adp,v diff -u -N --- openacs-4/packages/contacts/www/contact-archive.adp 13 Jan 2005 13:57:06 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,11 +0,0 @@ - -@title@ -@context@ - -

- Are you sure you want to archive this contactthese @num_entries@ contacts? -

- -

- Archive - Cancel, do not archive -

Index: openacs-4/packages/contacts/www/contact-archive.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/Attic/contact-archive.tcl,v diff -u -N --- openacs-4/packages/contacts/www/contact-archive.tcl 13 Jan 2005 13:57:06 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,38 +0,0 @@ -ad_page_contract { - - - @author Matthew Geddert openacs@geddert.com - @creation-date 2004-07-28 - @cvs-id $Id: contact-archive.tcl,v 1.2 2005/01/13 13:57:06 jeffd Exp $ - -} { - {party_id:integer,multiple} - {confirm_p:boolean 0} -} - - -if { [string is false $confirm_p] } { - set num_entries [llength $party_id] - - if { $num_entries == 0 } { - ad_returnredirect "contacts" - return - } - - set title "Archive Contact [ad_decode $num_entries 1 "Entry" "Entries"]" - set context [list $title] - set yes_url "contact-archive?[export_vars { party_id:multiple { confirm_p 1 } }]" - set no_url "./" - - return -} - -set archived_user [ad_conn user_id] -set archived_reason "This contact is no longer needed" - -foreach party_id $party_id { - db_dml archive_contact {} -} - -ad_returnredirect "./" -ad_script_abort Index: openacs-4/packages/contacts/www/contact-complaint.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/contact-complaint.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/contact-complaint.adp 30 Nov 2005 15:31:02 -0000 1.1.2.2 @@ -0,0 +1 @@ \ No newline at end of file Index: openacs-4/packages/contacts/www/contact-current-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/Attic/contact-current-postgresql.xql,v diff -u -N --- openacs-4/packages/contacts/www/contact-current-postgresql.xql 13 Jan 2005 13:57:06 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,15 +0,0 @@ - - - - postgresql7.1 - - - - - delete from contact_archives where party_id = :party_id - - - - - - Index: openacs-4/packages/contacts/www/contact-current.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/Attic/contact-current.adp,v diff -u -N --- openacs-4/packages/contacts/www/contact-current.adp 13 Jan 2005 13:57:07 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,11 +0,0 @@ - -@title@ -@context@ - -

- Are you sure you want to make this contactthese @num_entries@ contacts current? -

- -

- Make Current - Cancel, do not make current -

Index: openacs-4/packages/contacts/www/contact-current.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/Attic/contact-current.tcl,v diff -u -N --- openacs-4/packages/contacts/www/contact-current.tcl 13 Jan 2005 13:57:07 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,36 +0,0 @@ -ad_page_contract { - - - @author Matthew Geddert openacs@geddert.com - @creation-date 2004-07-28 - @cvs-id $Id: contact-current.tcl,v 1.2 2005/01/13 13:57:07 jeffd Exp $ - -} { - {party_id:integer,multiple} - {confirm_p:boolean 0} -} - - -if { [string is false $confirm_p] } { - set num_entries [llength $party_id] - - if { $num_entries == 0 } { - ad_returnredirect "./" - return - } - - set title "Make [ad_decode $num_entries 1 "Entry" "Entries"] Current" - set context [list $title] - set yes_url "contact-current?[export_vars { party_id:multiple { confirm_p 1 } }]" - set no_url "./" - - return -} else { - -foreach party_id $party_id { - db_dml unarchive_contact {} -} - -ad_returnredirect "./" -ad_script_abort -} Index: openacs-4/packages/contacts/www/contact-edit.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/contact-edit.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/contact-edit.adp 30 Nov 2005 15:31:02 -0000 1.2.2.2 @@ -0,0 +1,5 @@ + +@party_id@ + + + Index: openacs-4/packages/contacts/www/contact-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/contact-edit.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/contact-edit.tcl 30 Nov 2005 15:31:02 -0000 1.14.2.2 @@ -0,0 +1,196 @@ +ad_page_contract { + + @author Matthew Geddert openacs@geddert.com + @creation-date 2004-07-28 + @cvs-id $Id: contact-edit.tcl,v 1.14.2.2 2005/11/30 15:31:02 miguelm Exp $ + + +} { + {party_id:integer,notnull} +} -validate { + contact_exists -requires {party_id} { + if { ![contact::exists_p -party_id $party_id] && ![ad_form_new_p -key party_id] } { + ad_complain "[_ contacts.lt_The_contact_specified]" + } + } +} + + +set object_type [contact::type -party_id $party_id] +if { $object_type == "user" } { + set object_type "person" +} + +set user_id [ad_conn user_id] +set package_id [ad_conn package_id] + +set groups_belonging_to [db_list get_party_groups { select group_id from group_distinct_member_map where member_id = :party_id }] + +set form_elements {party_id:key} +lappend form_elements {object_type:text(hidden)} + +set ams_forms [list "${package_id}__[contacts::default_group]"] +foreach group [contact::groups -expand "all" -privilege_required "read"] { + set group_id [lindex $group 1] + if { [lsearch $groups_belonging_to $group_id] >= 0 } { + lappend ams_forms "${package_id}__${group_id}" + } +} + + +append form_elements " [ams::ad_form::elements -package_key "contacts" -object_type $object_type -list_names $ams_forms]" + +ad_form -name party_ae \ + -mode "edit" \ + -form $form_elements \ + -has_edit "1" + +foreach group_id $groups_belonging_to { + set element_name "category_ids$group_id" + if {$group_id < 0} { + set element_name "category_ids[expr - $group_id]" + } + + category::ad_form::add_widgets \ + -container_object_id $group_id \ + -categorized_object_id $party_id \ + -form_name party_ae \ + -element_name $element_name +} + +callback contact::contact_form -package_id $package_id -form party_ae -object_type $object_type -party_id $party_id + +ad_form -extend -name party_ae \ + -on_request { + + if { $object_type == "person" } { + set required_attributes [list first_names last_name email] + } else { + set required_attributes [list name] + } + + set missing_elements [list] + foreach attribute $required_attributes { + if { [string is false [template::element::exists party_ae $attribute]] } { + lappend missing_elements $attribute + } + } + # make the error message multiple item aware + if { [llength $missing_elements] > 0 } { + ad_return_error "[_ contacts.Configuration_Error]" "[_ contacts.lt_Some_of_the_required__1]
  • [join $missing_elements "
  • "]
" + } + + } -edit_request { + set revision_id [contact::live_revision -party_id $party_id] + foreach form $ams_forms { + ams::ad_form::values -package_key "contacts" \ + -object_type $object_type \ + -list_name $form \ + -form_name "party_ae" \ + -object_id $revision_id + } + contact::special_attributes::ad_form_values -party_id $party_id -form "party_ae" + + } -on_submit { + + # WE NEED TO MAKE SURE THAT VALUES THAT NEED TO BE UNIQUE ARE UNIQUE + + # for orgs name needs to be unique + # for all of them email needs to be unique + + if { $object_type == "person" } { + if { ![exists_and_not_null first_names] } { + template::element::set_error party_ae first_names "[_ contacts.lt_First_Names_is_requir]" + } + if { ![exists_and_not_null last_name] } { + template::element::set_error party_ae last_name "[_ contacts.lt_Last_Name_is_required]" + } + } else { + if { ![exists_and_not_null name] } { + template::element::set_error party_ae name "[_ contacts.Name_is_required]" + } + } + if { ![template::form::is_valid party_ae] } { + break + } + + } -new_data { + } -edit_data { + + contact::special_attributes::ad_form_save -party_id $party_id -form "party_ae" + set revision_id [contact::revision::new -party_id $party_id] + + + + foreach form $ams_forms { + ams::ad_form::save -package_key "contacts" \ + -object_type $object_type \ + -list_name $form \ + -form_name "party_ae" \ + -object_id $revision_id + } + + # We need to flush the cache for every attribute_id that this party has + set flush_attribute_list [db_list_of_lists get_attribute_ids { + select + distinct + ams_a.attribute_id + from + ams_attribute_values ams_a, + ams_attribute_values ams_b, + acs_objects o + where + ams_a.object_id = ams_b.object_id + and ams_b.object_id = o.object_id + and o.context_id = :party_id + }] + + foreach attr_id $flush_attribute_list { + util_memoize_flush [list ams::values_not_cached \ + -package_key "contacts" \ + -object_type $object_type \ + -object_id $attr_id] + } + + + + util_user_message -html -message "The $object_type [contact::name -party_id $party_id] was updated" + + set cat_ids [list] + foreach group_id $groups_belonging_to { + set element_name "category_ids$group_id" + if {$group_id < 0} { + set element_name "category_ids[expr - $group_id]" + } + + set cat_ids [concat $cat_ids \ + [category::ad_form::get_categories \ + -container_object_id $group_id \ + -element_name $element_name]] + } + + category::map_object -remove_old -object_id $party_id $cat_ids + if {$object_type == "organization"} { + callback contact::organization_new -package_id $package_id -contact_id $party_id -name $name + } else { + callback contact::person_add -package_id $package_id -person_id $party_id + } + } -after_submit { + contact::flush -party_id $party_id + contact::search::flush_results_counts + ad_returnredirect [contact::url -party_id $party_id] + ad_script_abort + } + + + + + + + + + + + + +ad_return_template Index: openacs-4/packages/contacts/www/contact-groups.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/contact-groups.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/contact-groups.adp 30 Nov 2005 15:31:02 -0000 1.2.2.2 @@ -0,0 +1,4 @@ + +@party_id@ + + Index: openacs-4/packages/contacts/www/contact-groups.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/contact-groups.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/contact-groups.tcl 30 Nov 2005 15:31:02 -0000 1.3.2.2 @@ -0,0 +1,38 @@ +ad_page_contract { + List and manage contacts. + + @author Matthew Geddert openacs@geddert.com + @creation-date 2004-07-28 + @cvs-id $Id: contact-groups.tcl,v 1.3.2.2 2005/11/30 15:31:02 miguelm Exp $ +} { + {party_id:integer,notnull} + {return_url "./"} +} + +set user_id [ad_conn user_id] +set package_id [ad_conn package_id] +set recipients [list] + +lappend recipients "[contact::name -party_id $party_id]" + +set recipients [join $recipients ", "] + + +set group_options [contact::groups -expand "all" -privilege_required "create"] + +set groups_belonging_to [db_list get_party_groups { select group_id from group_distinct_member_map where member_id = :party_id }] + +set groups_to_add [list [list "[_ contacts.--_select_a_group_--]" ""]] +foreach group $group_options { + if { [lsearch "$groups_belonging_to" [lindex $group 1]] >= 0 } { + # the party is part of this group + lappend groups_in [list [lindex $group 0] [lindex $group 1] [lindex $group 2]] + } else { + lappend groups_to_add [list [lindex $group 0] [lindex $group 1]] + } +} + +if { [llength $group_options] == "0" } { + ad_return_error "[_ contacts.lt_Insufficient_Permissi]" "[_ contacts.lt_You_do_not_have_permi]" +} + Index: openacs-4/packages/contacts/www/contact-rels-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/contact-rels-postgresql.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/contact-rels-postgresql.xql 30 Nov 2005 15:31:02 -0000 1.5.2.2 @@ -0,0 +1,66 @@ +` + + + + +select primary_object_type + from contact_rel_types + where primary_role = :role_two + + + + + +select acs_rel_type__role_pretty_name(primary_role) as pretty_name, + primary_role as role + from contact_rel_types + where secondary_object_type in ( :contact_type, 'party' ) + group by primary_role + order by upper(acs_rel_type__role_pretty_name(primary_role)) + + + + + +select rel_id, other_name, other_party_id, role_singular, rel_type, object_id_one, object_id_two +from +( + select CASE WHEN object_id_one = :party_id THEN contact__name(object_id_two) ELSE contact__name(object_id_one) END as other_name, + CASE WHEN object_id_one = :party_id THEN object_id_two ELSE object_id_one END as other_party_id, + CASE WHEN object_id_one = :party_id THEN role_two ELSE role_one END as role, + CASE WHEN object_id_one = :party_id THEN acs_rel_type__role_pretty_name(role_two) ELSE acs_rel_type__role_pretty_name(role_one) END as role_singular, + CASE WHEN object_id_one = :party_id THEN acs_rel_type__role_pretty_plural(role_two) ELSE acs_rel_type__role_pretty_name(role_two) END as role_plural, + role_one, role_two, + acs_rels.rel_id, acs_rels.rel_type, object_id_one, object_id_two + from acs_rels, + acs_rel_types + where acs_rels.rel_type = acs_rel_types.rel_type + and ( object_id_one = :party_id or object_id_two = :party_id ) + and acs_rels.rel_type in ( select object_type from acs_object_types where supertype = 'contact_rel') +) rels_temp +[template::list::orderby_clause -orderby -name "relationships"] + + + + + +select contact__name(parties.party_id), + parties.party_id, + cr_revisions.revision_id, + contact__name(parties.party_id,:name_order) as name, + parties.email, + ( select first_names from persons where person_id = party_id ) as first_names, + ( select last_name from persons where person_id = party_id ) as last_name, + ( select name from organizations where organization_id = party_id ) as organization + from parties left join cr_items on (parties.party_id = cr_items.item_id) left join cr_revisions on (cr_items.latest_revision = cr_revisions.revision_id ) , group_distinct_member_map + where parties.party_id = group_distinct_member_map.member_id + and group_distinct_member_map.group_id = '[contacts::default_group]' + $type_clause + [contact::search_clause -and -search_id $search_id -query $query -party_id "parties.party_id" -revision_id "revision_id"] + order by upper(contact__name(parties.party_id)) + limit 100 + + + + + Index: openacs-4/packages/contacts/www/contact-rels.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/contact-rels.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/contact-rels.adp 30 Nov 2005 15:31:02 -0000 1.5.2.2 @@ -0,0 +1,17 @@ + +@party_id@ +search.searchterm + + +

+ +

+ + + + +

#contacts.lt_Existing_Relationship#

+
+ + + Index: openacs-4/packages/contacts/www/contact-rels.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/contact-rels.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/contact-rels.tcl 30 Nov 2005 15:31:02 -0000 1.19.2.2 @@ -0,0 +1,266 @@ +ad_page_contract { + List and manage contacts. + + @author Matthew Geddert openacs@geddert.com + @creation-date 2004-07-28 + @cvs-id $Id: contact-rels.tcl,v 1.19.2.2 2005/11/30 15:31:02 miguelm Exp $ +} { + {party_id:integer,notnull} + {party_two:optional} + {role_two ""} + {buttonsearch:optional} + {buttonme:optional} + {query ""} + {orderby "role,asc"} +} -validate { + contact_one_exists -requires {party_id} { + if { ![contact::exists_p -party_id $party_id] } { + ad_complain "[_ contacts.lt_The_first_contact_spe]" + } + } + contact_two_exists -requires {party_two} { + if { ![contact::exists_p -party_id $party_two] } { + ad_complain "[_ contacts.lt_The_second_contact_sp]" + } + } + +} + +set contact_type [contact::type -party_id $party_id] +if { $contact_type == "user" } { + set contact_type "person" +} +set contact_name [contact::name -party_id $party_id] +set contact_url [contact::url -party_id $party_id] + + + + + + +set pretty_plural_list_name "contacts" +if { [exists_and_not_null role_two] } { + set valid_object_types [db_list get_valid_object_types {}] + set person_valid_p 0 + set org_valid_p 0 + foreach type $valid_object_types { + switch $type { + party { + set person_valid_p 1 + set org_valid_p 1 + } + person { + set person_valid_p 1 + } + organization { + set org_valid_p 1 + } + } + } + if { $org_valid_p && $person_valid_p } { + # we do nothing + set type_clause "" + } else { + if { $org_valid_p } { + set type_clause "and parties.party_id in ( select organization_id from organizations )" + set pretty_plural_list_name "[_ contacts.organizations]" + } elseif { $person_valid_p } { + set type_clause "and parties.party_id in ( select person_id from persons )" + set pretty_plural_list_name "[_ contacts.people]" + } else { + error "[_ contacts.lt_neither_person_nor_or]" + } + } +} + + +set name_order 0 +set member_state "approved" +set format "normal" + +set admin_p [ad_permission_p [ad_conn package_id] admin] +#set default_group_id [contacts::default_group_id] +set title "Contacts" +set context {} +set package_url [ad_conn package_url] + +if { [exists_and_not_null query] && [exists_and_not_null role_two] } { + set primary_party $party_id + + template::list::create \ + -html {width 100%} \ + -name "contacts" \ + -multirow "contacts" \ + -row_pretty_plural "$pretty_plural_list_name found in search, please try again or add a new contact" \ + -checkbox_name checkbox \ + -selected_format ${format} \ + -orderby_name "order_search" \ + -key party_id \ + -elements { + type { + label {} + display_template { + + } + } + contact { + label {} + display_template { + @contacts.party_id@">@contacts.name@ \[Select\] + @contacts.email@ + } + } + contact_id { + display_col party_id + } + first_names { + display_col first_names + } + last_name { + display_col last_name + } + organization { + display_col organization + } + email { + display_col email + } + } -filters { + } -orderby { + first_names { + label "[_ contacts.First_Name]" + orderby_asc "lower(contact__name(party_id,'f')) asc" + orderby_desc "lower(contact__name(party_id,'f')) asc" + } + last_name { + label "[_ contacts.Last_Name]" + orderby_asc "lower(contact__name(party_id,'t')) asc" + orderby_desc "lower(contact__name(party_id,'t')) asc" + } + default_value first_names,asc + } -formats { + normal { + label "[_ contacts.Table]" + layout table + row { + contact {} + } + } + } + + set search_id "" + set original_party_id $party_id + db_multirow -extend {map_url} -unclobber contacts contacts_select {} { + set map_url [export_vars -base "${package_url}relationship-add" -url {{party_one $original_party_id} {party_two $party_id} {role_two $role_two}}] + } + + +} + + +set rel_options [db_list_of_lists get_rels {}] +set rel_options [ams::util::localize_and_sort_list_of_lists -list $rel_options] + +set rel_options [concat [list [list "[_ contacts.--select_one--]" ""]] $rel_options] + +ad_form -name "search" -method "GET" -export {party_id} -form { + {role_two:text(select),optional {label "[_ contacts.Add]"} {options $rel_options}} + {query:text(text),optional {label ""} {html {size 24}}} + {search:text(submit) {label "[_ contacts.Search_Existing]"}} + {add:text(submit) {label "[_ contacts.Add_New]"}} +} -on_request { +} -edit_request { +} -on_refresh { +} -on_submit { + if {[exists_and_not_null add]} { + set default_group [contacts::default_group] + if {$person_valid_p} { + ad_returnredirect [export_vars -base "/contacts/add/person" -url {{group_ids $default_group} {object_id_two "$party_id"} role_two}] + } + if {$org_valid_p} { + ad_returnredirect [export_vars -base "/contacts/add/organization" -url {{group_ids $default_group} {object_id_two "$party_id"} role_two}] + } + } + if { ![exists_and_not_null role_two] } { + template::element::set_error search role_two "[_ contacts.A_role_is_required]" + } + if { ![template::form::is_valid search] } { + break + } +} -after_submit { +} + +template::list::create \ + -html {width 100%} \ + -name "relationships" \ + -multirow "relationships" \ + -row_pretty_plural "[_ contacts.relationships]" \ + -selected_format "normal" \ + -elements { + role { + label "[_ contacts.Art_of_Relationship]" + display_col role_singular + } + other_name { + label "[_ contacts.Contact]" + display_col other_name + link_url_eval $contact_url + } + details { + label "[_ contacts.Details]" + display_col details;noquote + } + actions { + label "[_ contacts.Actions]" + display_template { + [_ contacts.Delete] + [_ contacts.Edit_Details] + } + } + } -filters { + party_id {} + } -orderby { + other_name { + label "[_ contacts.Contact]" + orderby_asc "CASE WHEN object_id_one = :party_id THEN upper(contact__name(object_id_two)) ELSE upper(contact__name(object_id_one)) END asc, upper(role_singular) asc" + orderby_desc "CASE WHEN object_id_one = :party_id THEN upper(contact__name(object_id_two)) ELSE upper(contact__name(object_id_one)) END desc, upper(role_singular) asc" + } + role { + label "[_ contacts.Role]" + orderby_asc "upper(role_singular) asc, CASE WHEN object_id_one = :party_id THEN upper(contact__name(object_id_two)) ELSE upper(contact__name(object_id_one)) END asc" + orderby_desc "upper(role_singular) desc, CASE WHEN object_id_one = :party_id THEN upper(contact__name(object_id_two)) ELSE upper(contact__name(object_id_one)) END asc" + } + default_value role,asc + } -formats { + normal { + label "[_ contacts.Table]" + layout table + row { + role {} + other_name {} + details {} + actions {} + } + } + } + + +set package_id [ad_conn package_id] +set return_url "[ad_conn package_url]${party_id}/relationships" +db_multirow -unclobber -extend {contact_url rel_add_edit_url rel_delete_url details} relationships get_relationships "" { + set contact_url [contact::url -party_id $other_party_id] + set details "" + if { [ams::list::exists_p -package_key "contacts" -object_type ${rel_type} -list_name ${package_id}] } { + set rel_add_edit_url [export_vars -base "${package_url}relationship-ae" -url {rel_type object_id_one object_id_two party_id}] + set details_list [ams::values -package_key "contacts" -object_type $rel_type -list_name $package_id -object_id $rel_id -format "text"] + if { [llength $details_list] > 0 } { + append details "
\n" + foreach {section attribute_name pretty_name value} $details_list { + append details "
${pretty_name}:
\n" + append details "
${value}
\n" + } + append details "
\n" + } + } + set rel_delete_url [export_vars -base "${package_url}relationship-delete" -url {rel_id party_id return_url}] +} Index: openacs-4/packages/contacts/www/contact.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/contact.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/contact.adp 30 Nov 2005 15:31:02 -0000 1.38.2.2 @@ -0,0 +1,127 @@ + +@party_id@ +
+
+
+ +
+
+ +

#contacts.Visit_Club#

+
+ +
+ + +
+
+ +
+ + +
+
+ + + + + + + + +
+
+
+ + + +
+ + +
+ + +
+
+ + +
+ + +
+ + +
+
+ +

#contacts.Last_updated# @update_date@

+
+
+
Index: openacs-4/packages/contacts/www/contact.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/contact.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/contact.tcl 30 Nov 2005 15:31:02 -0000 1.31.2.2 @@ -0,0 +1,124 @@ +ad_page_contract { + + @author Matthew Geddert openacs@geddert.com + @creation-date 2004-07-28 + @cvs-id $Id: contact.tcl,v 1.31.2.2 2005/11/30 15:31:02 miguelm Exp $ + + +} { + {party_id:integer,notnull} + {orderby ""} + {cgl_orderby ""} + {tasks_orderby ""} + {page "1"} + {emp_f ""} + {pt_orderby ""} + +} -validate { + contact_exists -requires {party_id} { + if { ![contact::exists_p -party_id $party_id] } { + ad_complain "[_ contacts.lt_The_contact_specified]" + } + } +} + +set object_type [contact::type -party_id $party_id] +set user_id [ad_conn user_id] +set package_url [ad_conn package_url] + +set master_src [parameter::get -parameter "ContactMaster"] + +# Code for quickly adding an employee + +if {$object_type == "organization"} { +} else { + set employee_url "" +} + +set live_revision [contact::live_revision -party_id $party_id] +if { [exists_and_not_null live_revision] } { + set update_date [db_string get_update_date { select to_char(publish_date,'Mon FMDD, YYYY at FMHH12:MIam') from cr_revisions where revision_id = :live_revision } -default {}] +} + + +if { [site_node::get_package_url -package_key "tasks"] != "" } { + set tasks_enabled_p 1 +} else { + set tasks_enabled_p 0 +} + +# Get the linked projekt_id to display the subprojects if projects is installed +set pm_package_id "" + +if { [string is false [empty_string_p [info procs "::application_data_link::get_linked"]]] } { + + set project_id [lindex [application_data_link::get_linked -from_object_id $party_id -to_object_type "pm_project"] 0] + set dotlrn_club_id [lindex [application_data_link::get_linked -from_object_id $party_id -to_object_type "dotlrn_club"] 0] + + if {$project_id > 0 && $dotlrn_club_id <1} { + set pm_package_id [acs_object::get_element -object_id $project_id -element package_id] + set pm_base_url [apm_package_url_from_id $pm_package_id] + set project_url [export_vars -base $base_url {{project_item_id $project_id}}] + set projects_enabled_p 1 + } else { + set projects_enabled_p 0 + set project_url "" + } + + if {$dotlrn_club_id > 0} { + set club_url [dotlrn_community::get_community_url $dotlrn_club_id] + set dotlrn_club_enabled_p 1 + set pm_package_id [dotlrn_community::get_package_id_from_package_key -package_key "project-manager" -community_id $dotlrn_club_id] + set pm_base_url [apm_package_url_from_id $pm_package_id] + } else { + set dotlrn_club_enabled_p 0 + } + + set iv_package_id [application_link::get_linked -from_package_id [ad_conn package_id] -to_package_key "invoices"] + if {$iv_package_id > 0 } { + set iv_base_url [apm_package_url_from_id $iv_package_id] + set invoices_enabled_p 1 + } else { + set invoices_enabled_p 0 + } +} else { + set dotlrn_club_enabled_p 0 + set projects_enabled_p 0 + set invoices_enabled_p 0 +} + +# We check if the project-manager package is installed, otherwise the queries break +set pm_installed_p [apm_package_enabled_p "project-manager"] + +if { $object_type == "organization" && $pm_installed_p} { + # We are going to get a list of all members of the group Freelancer + # that have worked in a project for customer_id (party_id in this case). + # So first we get all projects were the party_id is customer + + set project_list [db_list get_projects { }] + # Default value for select menu + set select_menu "" + + if {![empty_string_p $project_list]} { + # Now we search for all the members of the Freelancer + # group that are assigned to one of this projects. + + # Get the group members list + set group_id [group::get_id -group_name "Freelancer"] + set group_members_list [group::get_members -group_id $group_id] + if { ![string equal [llength $group_members_list] "0"] } { + # Now we create the select menu to use + # since there is at least one member to the group + set select_menu "" + } + } +} + +set freelancer_p [group::member_p -user_id $party_id -group_name "Freelancer"] + +ad_return_template Index: openacs-4/packages/contacts/www/contact.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/contact.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/contact.xql 30 Nov 2005 15:31:02 -0000 1.4.2.2 @@ -0,0 +1,28 @@ + + + + + + select + item_id + from + pm_projectsx + where + customer_id = :party_id + + + + + + select + distinct + pa.party_id as supplier_id + from + pm_project_assignment pa + where + pa.project_id in ([template::util::tcl_to_sql_list $project_list]) + and pa.party_id in ([template::util::tcl_to_sql_list $group_members_list]) + + + + \ No newline at end of file Index: openacs-4/packages/contacts/www/files-delete.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/files-delete.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/files-delete.tcl 30 Nov 2005 15:31:02 -0000 1.2.2.2 @@ -0,0 +1,19 @@ +ad_page_contract { + + Update sort order + + @author Matthew Geddert openacs@geddert.com + @creation-date 2005-05-24 + @cvs-id $Id: files-delete.tcl,v 1.2.2.2 2005/11/30 15:31:02 miguelm Exp $ + +} { + item_id:multiple,notnull + party_id +} + +db_transaction { + foreach item_id $item_id { + db_dml expire_item { update cr_items set publish_status = 'expired', live_revision = NULL where item_id = :item_id } + } +} +ad_returnredirect "${party_id}/files" Index: openacs-4/packages/contacts/www/files-update.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/files-update.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/files-update.tcl 30 Nov 2005 15:31:02 -0000 1.2.2.2 @@ -0,0 +1,41 @@ +ad_page_contract { + + Update sort order + + @author Matthew Geddert openacs@geddert.com + @creation-date 2005-05-24 + @cvs-id $Id: files-update.tcl,v 1.2.2.2 2005/11/30 15:31:02 miguelm Exp $ + +} { + rename:array + party_id:integer,notnull +} + +set item_ids [db_list get_item_ids { select item_id from cr_items where parent_id = :party_id and publish_status = 'ready' } ] +db_transaction { + foreach item_id $item_ids { + set new_title [string trim $rename(${item_id})] + if { [exists_and_not_null new_title] } { + db_0or1row get_item_date { +select ci.name, + cr.title, + cr.mime_type, + cr.content, + cr.content_length + from cr_items ci, cr_revisions cr, acs_objects ao + where ci.parent_id = :party_id + and ci.live_revision = cr.revision_id + and cr.revision_id = ao.object_id + and ci.item_id = :item_id } + + if { $new_title != $title } { + set filename [contact::util::generate_filename -title $new_title -extension [contact::util::get_file_extension -filename $name] -party_id $party_id] + set revision_id [content::revision::new -item_id $item_id -is_live "t" -title $new_title -mime_type $mime_type] + db_dml update_revision { update cr_revisions set content = :content, content_length = :content_length where revision_id = :revision_id } + db_dml update_item { update cr_items set name = :filename where item_id = :item_id } + } + } + + } +} +ad_returnredirect "${party_id}/files" Index: openacs-4/packages/contacts/www/files.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/files.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/files.adp 30 Nov 2005 15:31:02 -0000 1.3.2.2 @@ -0,0 +1,11 @@ + +@party_id@ + + + + + + + + + Index: openacs-4/packages/contacts/www/files.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/files.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/files.tcl 30 Nov 2005 15:31:02 -0000 1.5.2.2 @@ -0,0 +1,206 @@ +ad_page_contract { + List and manage files for a contact. + + @author Matthew Geddert openacs@geddert.com + @creation-date 2005-05-24 + @cvs-id $Id: files.tcl,v 1.5.2.2 2005/11/30 15:31:02 miguelm Exp $ +} { + {party_id:integer,notnull} + {upload_count:integer "1"} + {orderby "file,asc"} +} -validate { + contact_exists -requires {party_id} { + if {![contact::exists_p \ + -party_id $party_id]} { + ad_complain "[_ contacts.lt_The_contact_specified]" + } + } +} + +if {$upload_count != 10} { + set upload_count 1 +} + +set folder_id [application_data_link::get_linked \ + -from_object_id $party_id \ + -to_object_type "content_folder"] + +if {[empty_string_p $folder_id]} { + + # We assume that the folder_id will definitely be empty for users This + # is why we try if there is an organization that has the user as an + # employee + + set organization_list [list] + db_foreach select_employee_ids "select CASE WHEN object_id_one = :party_id THEN object_id_two ELSE object_id_one END as other_party_id + from acs_rels, + acs_rel_types + where acs_rels.rel_type = acs_rel_types.rel_type + and ( object_id_one = :party_id or object_id_two = :party_id ) + and acs_rels.rel_type = 'contact_rels_employment'" { + lappend organization_list $other_party_id + } + + set folder_id [application_data_link::get_linked \ + -from_object_id [lindex $organization_list 0] \ + -to_object_type "content_folder"] +} + +set contact_name [contact::name \ + -party_id $party_id] +set form_elements [list {party_id:integer(hidden)}] +lappend form_elements [list {upload_count:integer(hidden)}] +lappend form_elements [list {orderby:text(hidden),optional}] +set upload_number 1 + +while {$upload_number <= $upload_count} { + lappend form_elements [list "upload_file${upload_number}:file(file),optional" [list label ""] [list section "section$upload_number"]] + lappend form_elements [list "upload_title${upload_number}:text(text),optional" [list html "size 45 maxlength 100"] [list label ""]] + incr upload_number +} + +if {$upload_count == 1} {set upload_label "Upload" } else {set upload_label "[_ contacts.Done]" } + +lappend form_elements [list "upload:text(submit),optional" [list "label" $upload_label]] +lappend form_elements [list "upload_more:text(submit),optional" [list "label" "[_ contacts.Upload_More]"]] + +ad_form -name upload_files -html {enctype multipart/form-data} -form $form_elements -on_request { +} -on_submit { + set upload_number 1 + set message [list] + while {$upload_number <= $upload_count} { + set file [set "upload_file${upload_number}"] + set title [set "upload_title${upload_number}"] + set filename [template::util::file::get_property filename $file] + if {$filename != "" } { + set tmp_filename [template::util::file::get_property tmp_filename $file] + set mime_type [template::util::file::get_property mime_type $file] + set tmp_size [file size $tmp_filename] + set extension [contact::util::get_file_extension \ + -filename $filename] + if {![exists_and_not_null title]} { + regsub -all ".${extension}\$" $filename "" title + } + set filename [contact::util::generate_filename \ + -title $title \ + -extension $extension \ + -party_id $party_id] + set revision_id [cr_import_content \ + -storage_type "file" -title $title $party_id $tmp_filename $tmp_size $mime_type $filename] + + content::item::set_live_revision -revision_id $revision_id + + # if the file is an image we need to create thumbnails + # #/sw/bin/convert -gravity Center -crop 75x75+0+0 fred.jpg fred.jpg + # #/sw/bin/convert -gravity Center -geometry 100x100+0+0 04055_7.jpg + # fred.jpg + + lappend message "$title" + } + incr upload_number + } + if {[llength $message] == 1} { + set message [lindex $message 1] + util_user_message -html -message "[_ contacts.lt_The_file_lindex_messa]" + } elseif {[llength $message] > 1} { + set message [join $message ", "] + util_user_message -html -message "[_ contacts.lt_The_files_join_messag]" + } +} -after_submit { + if {[exists_and_not_null upload_more]} { + ad_returnredirect [export_vars \ + -base "files" -url {{upload_count 10}}] + } else { + ad_returnredirect "files" + } + ad_script_abort +} + +template::list::create \ + -html {width 100%} \ + -name "files" \ + -multirow "files" \ + -row_pretty_plural "[_ contacts.files]" \ + -checkbox_name checkbox \ + -bulk_action_export_vars [list party_id orderby] \ + -bulk_actions [list \ + "[_ contacts.Delete]" "../files-delete" "[_ contacts.lt_Delete_the_selectted_]" \ + "[_ contacts.Update]" "../files-update" "[_ contacts.Update_filenames]" \ + ] \ + -selected_format "normal" \ + -key item_id \ + -elements { + file { + label {File} + display_col title + link_url_eval $file_url + } + rename { + label {Rename} + display_template { + } + } + type { + label "[_ contacts.Type]" + display_col extension + } + creation_date { + label "[_ contacts.Updated_On]" + display_col creation_date_pretty + } + creation_user { + label "[_ contacts.Updated_By]" + display_col creation_user_pretty + } + } -filters { + } -orderby { + file { + label "[_ contacts.File]" + orderby_asc "upper(cr.title) asc, ao.creation_date desc" + orderby_desc "upper(cr.title) desc, ao.creation_date desc" + default_direction asc + } + creation_date { + label "[_ contacts.Updated_On]" + orderby_asc "ao.creation_date asc" + orderby_desc "ao.creation_date desc" + default_direction desc + } + creation_user { + label "[_ contacts.Updated_By]" + orderby_asc "upper(contact__name(ao.creation_user)) asc, upper(cr.title) asc" + orderby_desc "upper(contact__name(ao.creation_user)) desc, upper(cr.title) asc" + default_direction desc + } + default_value file,asc + } -formats { + normal { + label "[_ contacts.Table]" + layout table + row { + } + } + } + +set package_url [ad_conn package_url] +db_multirow -extend {file_url extension} -unclobber files select_files "select ci.item_id, + ci.name, + cr.title, + to_char(ao.creation_date,'FMMon DD FMHH12:MIam') as creation_date_pretty, + contact__name(ao.creation_user) as creation_user_pretty + from cr_items ci, cr_revisions cr, acs_objects ao + where ci.parent_id = :party_id + and ci.live_revision = cr.revision_id + and cr.revision_id = ao.object_id +[template::list::orderby_clause \ + -orderby \ + -name "files"]" { + set file_url "${package_url}${party_id}/files/${name}" + set extension [lindex [split $name "."] end] + } +if {![empty_string_p $folder_id]} { + set package_id [lindex [fs::get_folder_package_and_root $folder_id] 0] + set base_url [apm_package_url_from_id $package_id] +} + +ad_return_template Index: openacs-4/packages/contacts/www/group-delete-confirm.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/group-delete-confirm.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/group-delete-confirm.adp 30 Nov 2005 15:31:02 -0000 1.1.2.2 @@ -0,0 +1,9 @@ + +@title@ +@context@ + + + + +

#contacts.Are_you_sure_you_want_to_delete#

+

#acs-kernel.common_Yes# - #acs-kernel.common_no#

Index: openacs-4/packages/contacts/www/group-parties-add.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/group-parties-add.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/group-parties-add.adp 30 Nov 2005 15:31:02 -0000 1.2.2.2 @@ -0,0 +1,10 @@ + + +@title@ +@context@ + + + + + + Index: openacs-4/packages/contacts/www/group-parties-add.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/group-parties-add.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/group-parties-add.tcl 30 Nov 2005 15:31:02 -0000 1.6.2.2 @@ -0,0 +1,108 @@ +ad_page_contract { + List and manage contacts. + + @author Matthew Geddert openacs@geddert.com + @creation-date 2004-07-28 + @cvs-id $Id: group-parties-add.tcl,v 1.6.2.2 2005/11/30 15:31:02 miguelm Exp $ +} { + {party_id:integer,multiple,optional} + {party_ids:optional} + {return_url "./"} +} -validate { + valid_party_submission { + if { ![exists_and_not_null party_id] && ![exists_and_not_null party_ids] } { + ad_complain "[_ contacts.lt_Your_need_to_provide_]" + } + } +} +if { [exists_and_not_null party_id] } { + set party_ids [list] + foreach party_id $party_id { + lappend party_ids $party_id + } +} + + + +set title "[_ contacts.Add_to_Group]" +set user_id [ad_conn user_id] +set peeraddr [ad_conn peeraddr] +set context [list $title] +set package_id [ad_conn package_id] +set recipients [list] +foreach party_id $party_ids { + lappend recipients "[contact::name -party_id $party_id]" +} +set recipients [join $recipients ", "] + +set form_elements { + party_ids:text(hidden) + return_url:text(hidden) + {recipients:text(inform),optional {label "[_ contacts.Contacts]"}} +} + +set group_options [contact::groups -expand "all" -privilege_required "create"] +if { [llength $group_options] == "0" } { + ad_return_error "[_ contacts.lt_Insufficient_Permissi]" "[_ contacts.lt_You_do_not_have_permi]" +} + +append form_elements { + {group_ids:text(checkbox),multiple {label "[_ contacts.Add_to_Groups]"} {options $group_options}} +} +set edit_buttons [list [list "[_ contacts.lt_Add_to_Selected_Group]" create]] + + + + +ad_form -action group-parties-add \ + -name add_to_group \ + -cancel_label "[_ contacts.Cancel]" \ + -cancel_url $return_url \ + -edit_buttons $edit_buttons \ + -form $form_elements \ + -on_request { + } -on_submit { + db_transaction { + foreach group_id $group_ids { + foreach party_id $party_ids { + + switch [contact::type -party_id $party_id] { + person - user { + set rel_type "membership_rel" + } + organization { + # Execute the callback for the organization depending on the group they are added to. + # We use this callback to add the organization to .LRN if it is a Customer + callback contact::organization_new_group -organization_id $party_id -group_id $group_id + set rel_type "organization_rel" + } + } + + # relation-add does not work as there is no + # special procedure for organizations at + # the moment. + set existing_rel_id [db_string rel_exists { + select rel_id + from acs_rels + where rel_type = :rel_type + and object_id_one = :group_id + and object_id_two = :party_id + } -default {}] + + if { [empty_string_p $existing_rel_id] } { + + set rel_id [db_string insert_rels { select acs_rel__new (NULL::integer,:rel_type,:group_id,:party_id,NULL,:user_id,:peeraddr) as org_rel_id }] + db_dml insert_state { insert into membership_rels (rel_id,member_state) values (:rel_id,'approved') } + } + + + } + } + } + } -after_submit { + contact::search::flush_results_counts + ad_returnredirect $return_url + ad_script_abort + } + + Index: openacs-4/packages/contacts/www/group-parties-remove.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/group-parties-remove.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/group-parties-remove.adp 30 Nov 2005 15:31:02 -0000 1.2.2.2 @@ -0,0 +1,10 @@ + + +@title@ +@context@ + + + + + + Index: openacs-4/packages/contacts/www/group-parties-remove.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/group-parties-remove.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/group-parties-remove.tcl 30 Nov 2005 15:31:02 -0000 1.8.2.2 @@ -0,0 +1,123 @@ +ad_page_contract { + List and manage contacts. + + @author Matthew Geddert openacs@geddert.com + @creation-date 2004-07-28 + @cvs-id $Id: group-parties-remove.tcl,v 1.8.2.2 2005/11/30 15:31:02 miguelm Exp $ +} { + {party_id:integer,multiple,optional} + {party_ids:optional} + {return_url "./"} + {group_id:integer,multiple,optional} + {confirmed_p "0"} +} -validate { + valid_party_submission { + if { ![exists_and_not_null party_id] && ![exists_and_not_null party_ids] } { + ad_complain "[_ contacts.lt_Your_need_to_provide_]" + } + } +} +if { [exists_and_not_null party_id] } { + set party_ids [list] + foreach party_id $party_id { + lappend party_ids $party_id + } +} + +if { [exists_and_not_null group_id] } { + if { $group_id != [contacts::default_group] || $confirmed_p } { + + set group_ids $group_id + db_transaction { + set message [list] + foreach group_id $group_ids { + set contacts [list] + foreach party_id $party_ids { + # relation_add verifies that they aren't already in the group + set contact_name [contact::name -party_id $party_id] + if { $group_id != [contacts::default_group] } { + lappend contacts "$contact_name" + } else { + lappend contacts $contact_name + } + group::remove_member -group_id $group_id -user_id $party_id + } + set contact_count [llength $contacts] + set contacts [join $contacts ", "] + set contact $contacts + set group [lang::util::localize [group::get_element -group_id $group_id -element group_name]] + if { $group_id != [contacts::default_group] } { + if { $contact_count > 1 } { + util_user_message -html -message [_ contacts.lt_contacts_were_removed_from_group] + } else { + util_user_message -html -message [_ contacts.lt_contacts_was_removed_from_group] + } + } else { + if { $contact_count > 1 } { + util_user_message -html -message [_ contacts.lt_contacts_were_deleted] + } else { + util_user_message -html -message [_ contacts.lt_contacts_was_deleted] + } + } + } + } + ad_returnredirect $return_url + ad_script_abort + } else { + set delete_url [export_vars -base group-parties-remove -url {party_id group_id party_ids {confirmed_p 1} return_url}] + set cancel_url $return_url + ad_return_template group-delete-confirm + } +} + +set title "[_ contacts.Remove_From_to_Group]" +set user_id [ad_conn user_id] +set context [list $title] +set package_id [ad_conn package_id] +set recipients [list] +foreach party_id $party_ids { + lappend recipients "[contact::name -party_id $party_id]" +} +set recipients [join $recipients ", "] + +set form_elements { + party_ids:text(hidden) + return_url:text(hidden) + {recipients:text(inform),optional {label "[_ contacts.Contacts]"}} +} + +set group_options [contact::groups -expand "all" -privilege_required "create"] +if { [llength $group_options] == "0" } { + ad_return_error "[_ contacts.lt_Insufficient_Permissi]" "[_ contacts.lt_You_do_not_have_permi]" +} + +append form_elements { + {group_ids:text(checkbox),multiple {label "[_ contacts.Remove_from_Groups]"} {options $group_options}} +} +set edit_buttons [list [list "[_ contacts.lt_Remove_from_Selected_]" create]] + + + + +ad_form -action group-parties-remove \ + -name remove_from_group \ + -cancel_label "[_ contacts.Cancel]" \ + -cancel_url $return_url \ + -edit_buttons $edit_buttons \ + -form $form_elements \ + -on_request { + } -on_submit { + db_transaction { + foreach group_id $group_ids { + foreach party_id $party_ids { + # relation_add verifies that they aren't already in the group + group::remove_member -group_id $group_id -user_id $party_id + } + } + } + } -after_submit { + contact::search::flush_results_counts + ad_returnredirect $return_url + } + + Index: openacs-4/packages/contacts/www/group-party-add-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/group-party-add-postgresql.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/group-party-add-postgresql.xql 30 Nov 2005 15:31:02 -0000 1.1.2.2 @@ -0,0 +1,19 @@ + + +postgresql7.2 + + + + select acs_rel__new ( + null, + 'organization_rel', + :group_id, + :party_id, + :group_id, + :user_id, + :ip_addr + ) + + + + Index: openacs-4/packages/contacts/www/group-party-add.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/group-party-add.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/group-party-add.tcl 30 Nov 2005 15:31:02 -0000 1.5.2.2 @@ -0,0 +1,50 @@ +ad_page_contract { + List and manage contacts. + + @author Matthew Geddert openacs@geddert.com + @creation-date 2004-07-28 + @cvs-id $Id: group-party-add.tcl,v 1.5.2.2 2005/11/30 15:31:02 miguelm Exp $ +} { + {party_id:multiple,integer,notnull} + {group_id:integer,notnull} + {return_url ""} +} + + +set party_id [lindex $party_id 0] +set object_type [contact::type -party_id $party_id] +switch $object_type { + person { + set rel_type "membership_rel" + } + organization { + set rel_type "organization_rel" + } + default { + set rel_type "membership_rel" + } +} + +ns_log notice "\#\#\# rel_type $rel_type" +if {$rel_type == "organization_rel"} { + set user_id [ad_conn user_id] + set ip_addr [ad_conn peeraddr] + set rel_id [db_exec_plsql add_organization_rel {}] + db_dml insert_state {} + + # Execute the callback for the organization depending on the group they are added to. + # We use this callback to add the organization to .LRN if it is a Customer + callback contact::organization_new_group -organization_id $party_id -group_id $group_id + +} else { + group::add_member \ + -group_id $group_id \ + -user_id $party_id \ + -rel_type membership_rel +} + +if { ![exists_and_not_null return_url] } { + set return_url[contact::url -party_id $party_id] +} +contact::search::flush_results_counts +ad_returnredirect $return_url Index: openacs-4/packages/contacts/www/group-party-add.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/group-party-add.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/group-party-add.xql 30 Nov 2005 15:31:02 -0000 1.1.2.2 @@ -0,0 +1,10 @@ + + + + + + insert into membership_rels (rel_id,member_state) values (:rel_id,'approved') + + + + Index: openacs-4/packages/contacts/www/group-party.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/group-party.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/group-party.tcl 30 Nov 2005 15:31:02 -0000 1.2.2.2 @@ -0,0 +1,80 @@ +ad_page_contract { + List and manage contacts. + + @author Matthew Geddert openacs@geddert.com + @creation-date 2004-07-28 + @cvs-id $Id: group-party.tcl,v 1.2.2.2 2005/11/30 15:31:02 miguelm Exp $ +} { + {party_id:integer,multiple} + {group_id:integer,multiple} + {return_url "./"} +} -validate { +} +if { [exists_and_not_null party_id] } { + set party_ids [list] + foreach party_id $party_id { + lappend party_ids $party_id + } +} + + + +set title "Add to Group" +set user_id [ad_conn user_id] +set context [list $title] +set package_id [ad_conn package_id] +set recipients [list] +foreach party_id $party_ids { + lappend recipients "[contact::name -party_id $party_id]" +} +set recipients [join $recipients ", "] + +set form_elements { + party_ids:text(hidden) + return_url:text(hidden) + {recipients:text(inform),optional {label "Contacts"}} +} + +set group_options [contact::groups -expand "all" -privilege_required "create"] +if { [llength $group_options] == "0" } { + ad_return_error "Insufficient Permissions" "You do not have permission to add users to groups" +} + +append form_elements { + {group_ids:text(checkbox),multiple {label "Add to Group(s)"} {options $group_options}} +} +set edit_buttons [list [list "Add to Selected Groups" create]] + + + + +ad_form -action group-parties-add \ + -name add_to_group \ + -cancel_label "Cancel" \ + -cancel_url $return_url \ + -edit_buttons $edit_buttons \ + -form $form_elements \ + -on_request { + } -on_submit { + db_transaction { + foreach group_id $group_ids { + foreach party_id $party_ids { + # relation_add verifies that they aren't already in the group + switch [contact::type -party_id $party_id] { + person - user { + set rel_type "membership_rel" + } + organization { + set rel_type "organization_rel" + } + } + relation_add -member_state "approved" $rel_type $group_id $party_id + } + } + } + } -after_submit { + ad_returnredirect $return_url + ad_script_abort + } + + Index: openacs-4/packages/contacts/www/history.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/history.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/history.adp 30 Nov 2005 15:31:02 -0000 1.1.2.2 @@ -0,0 +1,4 @@ + +@party_id@ + + Index: openacs-4/packages/contacts/www/history.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/history.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/history.tcl 30 Nov 2005 15:31:02 -0000 1.1.2.2 @@ -0,0 +1,19 @@ +ad_page_contract { + + @author Matthew Geddert openacs@geddert.com + @creation-date 2005-07-09 + @cvs-id $Id: history.tcl,v 1.1.2.2 2005/11/30 15:31:02 miguelm Exp $ + + +} { + {party_id:integer} + {page "comments"} +} -validate { + contact_exists -requires {party_id} { + if { ![contact::exists_p -party_id $party_id] } { + ad_complain "[_ contacts.lt_The_contact_specified]" + } + } +} + +ad_return_template Index: openacs-4/packages/contacts/www/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/index.adp,v diff -u -N -r1.2 -r1.2.2.1 --- openacs-4/packages/contacts/www/index.adp 13 Jan 2005 13:57:07 -0000 1.2 +++ openacs-4/packages/contacts/www/index.adp 30 Nov 2005 15:31:02 -0000 1.2.2.1 @@ -1,87 +1,19 @@ - + -@title@ -@context@ - - - - - - -
-[ Admin ] -
+

+ + - - - - - - - - - - - - -
- - - -

- - - - - - - -
- #contacts.Search# (clear) - -
-
- - @export_vars_search_form;noquote@ - -
-
-

- - - -

- - - - - - - -
- #contacts.Limit_Contacts_to# (clear) -
- @category_select;noquote@ -
-

-
- - - -
-
-

@letter_bar;noquote@

- - -

#contacts.Showing# @first_row@ - @last_row@ #contacts.of# @total_rows@ -| Prev -| Next -

-
-
- - -
- - - + + + \ No newline at end of file Index: openacs-4/packages/contacts/www/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/index.tcl,v diff -u -N -r1.2 -r1.2.2.1 --- openacs-4/packages/contacts/www/index.tcl 13 Jan 2005 13:57:08 -0000 1.2 +++ openacs-4/packages/contacts/www/index.tcl 30 Nov 2005 15:31:02 -0000 1.2.2.1 @@ -1,357 +1,93 @@ ad_page_contract { + List and manage contacts. - @author Matthew Geddert openacs@geddert.com @creation-date 2004-07-28 @cvs-id $Id$ - } { - {searchterm ""} - {letter ""} - {num_rows "20"} - {start_row:naturalnum "0"} - {category_id:multiple,optional} - {groupby:optional} - {orderby:optional} - {sortby "first_names"} + {orderby "first_names,asc"} {format "normal"} - {status "current"} - {object_type ""} + {search_id:integer ""} + {query ""} + {page:optional} + {page_size:integer ""} + {add_person:optional} + {add_organization:optional} + {aggregate_attribute_id ""} + {aggregate_extend_id:multiple ""} + {extend_values:optional ""} + {attr_val_name:optional ""} } -set admin_p [ad_permission_p [ad_conn package_id] admin] - -set title "Contacts" -set context {} - -set valid_numrows [list 10 20 50 100 ALL] -if { [lsearch $valid_numrows $num_rows] < 0 } { - set num_rows 50 +if { [exists_and_not_null add_person] } { + ad_returnredirect "add/person" + ad_script_abort +} elseif { [exists_and_not_null add_organization] } { + ad_returnredirect "add/organization" + ad_script_abort } +set aggregated_p 0 +if {[exists_and_not_null aggregate_attribute_id] } { + set aggregated_p 1 +} - -if { $num_rows == "ALL" } { - set start_row 0 +set extend_p 0 +if { [exists_and_not_null search_id] } { + set extend_p 1 } +set user_id [ad_conn user_id] +set package_id [ad_conn package_id] - - - -set export_vars_page_nav [export_vars -url { category_id format letter num_rows object_type orderby searchterm sortby status }] -set export_vars_search_form [export_vars -form { category_id format num_rows object_type orderby sortby status }] -set export_vars_search_url [export_vars -url { category_id format num_rows object_type orderby sortby status }] -set export_vars_letter_url [export_vars -url { category_id format num_rows object_type orderby sortby status }] -set export_vars_sortby_url [export_vars -url { category_id format letter num_rows object_type orderby searchterm status }] -set export_vars_num_rows_url [export_vars -url { category_id format letter object_type orderby searchterm sortby status }] -set export_vars_category_form [export_vars -form { format letter num_rows object_type orderby searchterm sortby status }] -set export_vars_category_url [export_vars -url { format letter num_rows object_type orderby searchterm sortby status }] - - - - -if {[exists_and_not_null category_id]} { - set category_id_filter "party_id in ( select object_id from category_object_map where category_id = $category_id )" - set temp_category_id $category_id -} else { - set category_id_filter "" - set temp_category_id "" +set valid_page_sizes [list 25 50 100 500] +if { ![exists_and_not_null page_size] || [lsearch $valid_page_sizes $page_size] < 0 } { + set page_size [parameter::get -boolean -parameter "DefaultPageSize" -default "50"] } -set categories_p [contacts::categories::enabled_p] +set contacts_total_count [contact::search::results_count -search_id $search_id -query $query] -if { [string is true $categories_p] } { -set category_select [contacts::categories::get_selects -export_vars $export_vars_category_form -category_id $temp_category_id] +if { $aggregated_p } { + set contacts_total_count "$contacts_total_count" } - -set searchterm_filter "upper(sort_$sortby) like upper('%$searchterm%')" -set letter_filter "upper(sort_$sortby) like upper('$letter%')" - -if { [lsearch [list organization person] $object_type] < 0 } { - set object_type_filter "" -} else { - set object_type_filter "object_type = '$object_type'" +if { [exists_and_not_null search_id] } { + contact::search::log -search_id $search_id } -if { [lsearch [list current archived] $status] < 0 } { - set status_filter "" -} else { - set status_filter "status = '$status'" +set public_searches [lang::util::localize_list_of_lists -list [db_list_of_lists public_searches {}]] +set search_options [concat [list [list [_ contacts.All_Contacts] ""]] $public_searches] +set searchcount 1 +db_foreach my_recent_searches {} { + lappend search_options [list "${searchcount}) ${recent_title}" ${recent_search_id}] + incr searchcount } +lang::util::localize_list_of_lists -list $search_options -if { $status == "archived" } { -set bulk_actions [list \ - "\#contacts.Make_Current\#" "contact-current" "\#contacts.Make_the_checked_contacts_current\#"] -} else { -set bulk_actions [list \ - "\#contacts.Archive\#" "contact-archive" "\#contacts.Archive_the_checked_contacts\#"] -} -# "\#contacts.Add_to_Category\#" "contacts-category-add" "\#contacts.Add_the_selected_contacts_to_a_category\#" -# "\#contacts.Send_Email\#" "bulk-email" "\#contacts.Send_an_email_message_to_the_selected_contacts\#" \ -list::create \ - -html { width 100% } \ - -name entries \ - -multirow entries \ - -key party_id \ - -row_pretty_plural "Contacts" \ - -checkbox_name checkbox \ - -selected_format $format \ - -class "list" \ - -main_class "list" \ - -sub_class "narrow" \ - -pass_properties { - variable - } -actions { - "\#contacts.Add_a_Person\#" "contact-ae?object_type=person" "\#contacts.Add_a_Person\#" - "\#contacts.Add_an_Organization\#" "contact-ae?object_type=organization" "\#contacts.Add_an_Organization\#" - } -bulk_actions $bulk_actions \ - -elements { - edit { - label {} - display_template { - Edit - } +set form_elements { + {search_id:integer(select),optional {label ""} {options $search_options} {html {onChange "javascript:acs_FormRefresh('search')"}}} + {query:text(text),optional {label ""} {html {size 20 maxlength 255}}} + {save:text(submit) {label {[_ contacts.Search]}} {value "go"}} + {results_count:integer(inform),optional {label "  [_ contacts.Results] $contacts_total_count "}} +} - } - contact_name { - display_col contact_name - link_url_eval $contact_url - label "\#contacts.Contact\#" - } - first_names { - display_col first_names - label "First Names" - } - last_name { - display_col last_name - label "Last Name" - } - organization_name { - display_col name - label "Organization" - } - email { - display_template { - @entries.email_url;noquote@ - } - label "\#contacts.Email_Address\#" - } - contact_type { - display_template { - \#contacts.Organization\# - \#contacts.Person\# - } - label "\#contacts.Contact_Type\#" - } - } -filters { - sortby { - label "\#contacts.Sort_By\#" - values { - {{\#contacts.First_Names\#} first_names} - {{\#contacts.Last_Name\#} last_name} - } - where_clause {} - } - start_row {} - category_id { - label Categories - where_clause {$category_id_filter} - } - letter { - label "Letter" - where_clause {$letter_filter} - } - object_type { - label "\#contacts.Contact_Type\#" - values { - {{\#contacts.Organization\#} organization} - {{\#contacts.Person\#} person} - } - where_clause {$object_type_filter} - } - searchterm { - label "Search" - where_clause {$searchterm_filter} - } - status { - label "\#contacts.Status\#" - values { - {{\#contacts.Current\#} current} - {{\#contacts.Archived\#} archived} - } - where_clause {$status_filter} - } - num_rows { - label "\#contacts.Number_of_Rows\#" - values { - {10 10} - {20 20} - {50 50} - {100 100} - {500 500} - {All ALL} - } - } - } -groupby { - } -orderby { - default_value contact_name,asc - contact_name { - label "\#contacts.Contact\#" - orderby_desc "contacts.sort_$sortby desc, contacts.object_type desc, contacts.email desc" - orderby_asc "contacts.sort_$sortby asc, contacts.object_type desc, contacts.email desc" - default_direction asc - } - email { - label "\#contacts.Email_Address\#" - orderby_desc "contacts.email desc, contacts.sort_$sortby desc, contacts.object_type desc" - orderby_asc "contacts.email asc, contacts.sort_$sortby desc, contacts.object_type desc" - default_direction asc - } - contact_type { - label "\#contacts.Contact_Type\#" - orderby_desc "contacts.object_type desc, contacts.sort_$sortby desc, contacts.email desc" - orderby_asc "contacts.object_type asc, contacts.sort_$sortby desc, contacts.email desc" - default_direction asc - } - } -formats { - normal { - label "Table" - layout table - row { - checkbox {} - edit {} - contact_name {} - email {} - contact_type {} - } - } - csv { - label "CSV" - output csv - row { - contact_name {} - first_names {} - last_name {} - organization_name {} - email {} - contact_type {} - } - } +if { [parameter::get -boolean -parameter "ForceSearchBeforeAdd" -default "0"] } { + if { [exists_and_not_null query] && $search_id == "" } { + append form_elements { + {add_person:text(submit) {label {[_ contacts.Add_Person]}} {value "1"}} + {add_organization:text(submit) {label {[_ contacts.Add_Organization]}} {value "1"}} + } } - -# This query will override the ad_page_contract value entry_id - -# left join category_object_map c on (contact_attrs.party_id = c.object_id) -set multirow_query " -" -# [template::list::sortby_clause -sortby -name entries] - -db_multirow -extend { contact_url email_url object_type_pretty } -unclobber entries get_contact_info {} { - set contact_url "view/$party_id" - if { [exists_and_not_null email] } { - set email_url "$email" - } - if { $object_type == "organization" } { - set object_type_pretty "\#contacts.Organization\#" - } else { - set object_type_pretty "\#contacts.Person\#" - } } - -set initial_list_query " -select distinct upper(substr(sort_$sortby,1,1)) - from contacts - where party_id is not null -" - -if { [exists_and_not_null category_id_filter ] } { - append initial_list_query "and $category_id_filter\n" -} -# we cannot use the letter filter because it defeats the purpose -#if { [exists_and_not_null letter_filter ] } { -# append initial_list_query "and $category_id_filter" -# -#} -if { [exists_and_not_null object_type_filter ] } { - append initial_list_query "and $object_type_filter\n" -} -if { [exists_and_not_null searchterm_filter ] } { - append initial_list_query "and $searchterm_filter\n" -} -if { [exists_and_not_null status_filter ] } { - append initial_list_query "and $status_filter\n" -} - -set initial_list [db_list_of_lists get_list_of_starting_letters $initial_list_query] - - - -set letter_bar [contacts::util::letter_bar -letter $letter -export_vars $export_vars_letter_url -initial_list $initial_list] - - -# pagination - hopefully once list builder has pagination documenation -# this can be built into list builder - - -db_1row get_total_rows " -select count(*) as total_rows - from contacts - where party_id is not null - [template::list::filter_where_clauses -and -name entries] -" - -if { $num_rows != "ALL" } { - - set first_row [expr $start_row + 1] - set last_row [expr $start_row + $num_rows] - - if { $num_rows >= $total_rows } { - set first_row 1 - set last_row $total_rows - set start_row 0 +ad_form -name "search" -method "GET" -export {orderby page_size format} -form $form_elements \ + -on_request { + } -edit_request { + } -on_refresh { + } -on_submit { + } -after_submit { } - - if { $last_row >= $total_rows } { - set next_link_p 0 - set last_row $total_rows - } else { - set next_link_p 1 - set next_link_url "?start_row=$last_row&$export_vars_page_nav" - } - if { $start_row == "0" } { - set prev_link_p 0 - } else { - set prev_link_p 1 - set prev_link_start_row [expr $start_row - $num_rows] - if { $prev_link_start_row < "0" } { - set prev_link_start_row "0" - } - set prev_link_url "?start_row=$prev_link_start_row&$export_vars_page_nav" - } - -} else { - set next_link_p 0 - set prev_link_p 0 - set first_row 1 - set last_row $total_rows -} -template::list::write_output -name entries - - - - - - - - - -ad_return_template - - Index: openacs-4/packages/contacts/www/index.vuh =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/index.vuh,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/index.vuh 30 Nov 2005 15:31:02 -0000 1.10.2.2 @@ -0,0 +1,92 @@ +# +# Provide pretty urls for the contacts package +# +# @author Matthew Geddert (openacs@geddert.com) +# @creation-date 2005-05-24 +# @cvs-id $Id: index.vuh,v 1.10.2.2 2005/11/30 15:31:02 miguelm Exp $ + +set package_url [ad_conn package_url] +set file_url [ad_conn path_info] +set file_list [split $file_url "/"] + +set party_id [lindex $file_list 0] +if { [string is integer $party_id] } { + set party_is_contact_p [contact::exists_p -party_id $party_id] +} else { + set party_is_contact_p 0 +} +set action [lindex $file_list 1] + + +if { $party_is_contact_p } { + if { [llength $file_list] == "1" } { + # we need to redirect the user to their "correct" summary page otherwise + # sub links will not work correctly + ad_returnredirect "[ad_conn package_url]${party_id}/" + ad_script_abort + } + set valid_pages [list "" edit files groups relationships comments message history changes mail-tracking] + + if { [lsearch $valid_pages $action] >= 0 && [llength $file_list] == "2" } { + switch $action { + edit { set file "contact-edit" } + files { set file "files" } + groups { set file "contact-groups" } + relationships { set file "contact-rels" } + comments { set file "comments" } + message { set file "message" } + letter { set file "letter" } + email { set file "email" } + complaint { set file "complaint" } + history { set file "history" } + changes { set file "changes" } + mail-tracking { set file "mail-tracking" } + default { set file [parameter::get -parameter "ContactSummaryViewTemplate" -default "/packages/contacts/www/contact"] } + } + + set form_supplied_party_id [ns_queryget party_id] + if { [exists_and_not_null form_supplied_party_id] } { + if { $form_supplied_party_id != $party_id } { + ns_returnnotfound + ad_script_abort + } + } else { + rp_form_put party_id $party_id + } + rp_internal_redirect $file + } elseif { $action == "files" && [llength $file_list] == "3" } { + # we may have a valid file request + set item_id [content::item::get_id -root_folder_id $party_id -item_path [lindex $file_list 2]] + set revision_id [content::item::get_live_revision -item_id $item_id] + if { [exists_and_not_null revision_id] } { + cr_write_content -revision_id $revision_id + } else { + ns_returnnotfound + ad_script_abort + } + } else { + ns_returnnotfound + ad_script_abort + } +} else { + switch $file_url { + "add/person" { + if { ![ns_queryexists object_type] } { + rp_form_put object_type "person" + } + rp_internal_redirect contact-add + } + "add/organization" { + if { ![ns_queryexists object_type]} { + rp_form_put object_type "organization" + } + rp_internal_redirect contact-add + } + default { + ns_returnnotfound + ad_script_abort + } + } + +} + Index: openacs-4/packages/contacts/www/index.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/index.xql,v diff -u -N -r1.2 -r1.2.2.1 --- openacs-4/packages/contacts/www/index.xql 13 Jan 2005 13:57:09 -0000 1.2 +++ openacs-4/packages/contacts/www/index.xql 30 Nov 2005 15:31:02 -0000 1.2.2.1 @@ -1,18 +1,31 @@ - - -select contacts.*, sort_$sortby as contact_name - from contacts - where party_id is not null - [template::list::filter_where_clauses -and -name entries] - [template::list::orderby_clause -orderby -name entries] - limit $num_rows offset $start_row - - + + + select title, + search_id + from contact_searches + where owner_id = :package_id + and title is not null + and not deleted_p + order by lower(title) + + + + + select cs.title as recent_title, + cs.search_id as recent_search_id + from contact_searches cs, contact_search_log csl + where csl.user_id = :user_id + and cs.search_id = csl.search_id + and cs.title is not null + and cs.owner_id != :package_id + and not cs.deleted_p + order by last_search desc + limit 10 + + - - Index: openacs-4/packages/contacts/www/mail-tracking.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/mail-tracking.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/mail-tracking.adp 30 Nov 2005 15:31:02 -0000 1.3.2.2 @@ -0,0 +1,8 @@ + +@party_id@ + + \ No newline at end of file Index: openacs-4/packages/contacts/www/mail-tracking.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/mail-tracking.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/mail-tracking.tcl 30 Nov 2005 15:31:02 -0000 1.5.2.2 @@ -0,0 +1,21 @@ +ad_page_contract { + + @author Al-Faisal El-Dajani (faisal.dajani@gmail.com) + @creation-date 2005-10-18 +} { + {party_id ""} + {orderby ""} + {page "1"} +} + +foreach optional_param {sender_id recipient_id page page_size page_flush_p orderby object_id emp_mail_f} { + if {![info exists $optional_param]} { + set $optional_param {} + } +} + +if {![exists_and_not_null party_id]} { + set party_id $sender_id +} + +ad_return_template \ No newline at end of file Index: openacs-4/packages/contacts/www/message-action.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/message-action.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/message-action.tcl 30 Nov 2005 15:31:02 -0000 1.2.2.2 @@ -0,0 +1,90 @@ +ad_page_contract { + List and manage contacts. + + @author Matthew Geddert openacs@geddert.com + @creation-date 2004-07-28 + @cvs-id $Id: message-action.tcl,v 1.2.2.2 2005/11/30 15:31:02 miguelm Exp $ +} { + {item_id:integer} + {owner_id:integer ""} + {action} + {return_url ""} +} -validate { + item_exists -requires {item_id} { + if { ![db_0or1row message_exists_p { select 1 from contact_messages where item_id = :item_id}] && ![exists_and_not_null message_type]} { + ad_complain [_ contacts.lt_The_message_id_specified_does_not_exist] + } + } + action_valid -requires {action} { + if { [lsearch [list move copy delete] $action] < 0 } { + ad_complain [_ contacts.The_action_specified_is_invalid] + } elseif { ![permission::permission_p -object_id [ad_conn package_id] -privilege "admin"] } { + set message_owner_id [db_string get_owner_id { select owner_id from contact_messages where item_id = :item_id}] + switch $action { + "move" { + ad_complain [_ contacts.You_do_not_have_permission_to_move_searches] + } + "copy" { + if { $owner_id != [ad_conn user_id] } { + ad_complain [_ contacts.You_cannot_copy_searches_to_somebody_other_than_yourself] + } + } + "delete" { + if { $message_owner_id != [ad_conn user_id] } { + ad_complain [_ contacts.You_cannot_delete_searches_that_do_not_belong_to_you] + } + } + } + } + } + owner_valid -requires {owner_id} { + if { [exists_and_not_null owner_id] } { + if { $owner_id == [ad_conn package_id] || ( [contact::exists_p -party_id $owner_id] && [lsearch [list person user] [contact::type -party_id $owner_id]] >= 0 ) } { + } else { + ad_complain [_ contacts.The_owner_id_specified_is_not_valid] + } + } + } +} + +db_1row select_message_info {} +set package_id [ad_conn package_id] + + +switch $action { + "move" { + db_dml update_owner {} + util_user_message -html -message [_ contacts.The_message_-title-_was_made_public] + } + "copy" { + regsub -all "'" $title "''" sql_title + set similar_titles [db_list select_similar_titles {}] + set number 1 + set orig_title $title + while { [lsearch $similar_titles $title] >= 0 } { + set title "$orig_title ($number)" + incr number + } + contact::message::save \ + -item_id $new_item_id \ + -owner_id $owner_id \ + -message_type $message_type \ + -title $title \ + -description $description \ + -content $content \ + -content_format $content_format + util_user_message -html -message [_ contacts.The_message_-title-_was_copied_to_your_messages] + } + "delete" { + db_dml expire_message {} + util_user_message -html -message [_ contacts.The_message_-title-_was_deleted] + + } +} + +if { ![exists_and_not_null return_url] } { + set return_url [export_vars -base "messages" -url {owner_id}] +} + +ad_returnredirect $return_url +ad_script_abort Index: openacs-4/packages/contacts/www/message-action.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/message-action.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/message-action.xql 30 Nov 2005 15:31:02 -0000 1.1.2.2 @@ -0,0 +1,45 @@ + + + + + + select title, + acs_object_id_seq.nextval as new_item_id, + owner_id as old_owner_id, + message_type, + title, + description, + content, + content_format + from contact_messages + where item_id = :item_id + + + + + + update contact_message_items + set owner_id = :owner_id + where item_id = :item_id + + + + + + select title + from contact_messages + where owner_id = :owner_id + and upper(title) like upper('${sql_title}%') + + + + + + update cr_items + set publish_status = 'expired' + where item_id = :item_id + + + + + Index: openacs-4/packages/contacts/www/message-ae.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/message-ae.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/message-ae.adp 30 Nov 2005 15:31:02 -0000 1.2.2.2 @@ -0,0 +1,5 @@ + +@context;noquote@ +@page_title@ + + \ No newline at end of file Index: openacs-4/packages/contacts/www/message-ae.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/message-ae.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/message-ae.tcl 30 Nov 2005 15:31:02 -0000 1.3.2.2 @@ -0,0 +1,125 @@ +# /packages/mbryzek-subsite/www/admin/rel-type/new.tcl + +ad_page_contract { + + Form to create a new relationship type + + @author mbryzek@arsdigita.com + @creation-date Sun Nov 12 18:27:08 2000 + @cvs-id $Id: message-ae.tcl,v 1.3.2.2 2005/11/30 15:31:02 miguelm Exp $ + +} { + {item_id:integer,optional} + {message_type ""} + {return_url "messages"} +} -properties { +} -validate { + type_exists -requires {message_type} { + if { ![exists_and_not_null message_type] && ![exists_and_not_null item_id] } { + ad_complain [_ contacts.lt_You_must_specify_a_message_type] + } + } + item_exists -requires {item_id} { + if { ![db_0or1row message_exists_p { select 1 from contact_messages where item_id = :item_id}] && ![exists_and_not_null message_type]} { + ad_complain [_ contacts.lt_The_message_id_specified_does_not_exist] + } + } + item_not_yours -requires {item_id} { + if { ![permission::permission_p -object_id [ad_conn package_id] -privilege "admin"] } { + set user_id [ad_conn user_id] + if { ![db_0or1row message_exists_p { select 1 from contact_messages where item_id = :item_id and owner_id = :user_id}] } { + ad_complain [_ contacts.lt_The_message_id_specified_does_not_belong_to_you] + } + } + } +} + +set message_exists_p 0 +if { [exists_and_not_null item_id] } { + if { [db_0or1row message_exists_p { select 1 from contact_messages where item_id = :item_id}] } { + set message_exists_p 1 + } +} + +if { $message_exists_p } { + db_1row get_message_type_and_title { select message_type, title as page_title from contact_messages where item_id = :item_id } +} else { + set page_title "[_ contacts.Add] [lang::util::localize [db_string select_type_pretty { select pretty_name from contact_message_types where message_type = :message_type}]]" +} +set context [list [list "messages" "[_ contacts.Messages]"] $page_title] + +set form_elements { + {item_id:key} + {owner_id:integer(hidden)} + {message_type:text(hidden)} + {return_url:text(hidden)} + {title:text(text) {label "[_ contacts.Title]"} {html {size 45 maxlength 1000}} {help_text "[_ contacts.lt_Title_is_not_shown_in_the_message]"}} + {locale:text(select) {label "[_ acs-lang.Locale]"} {options [lang::util::get_locale_options]}} +} + +switch $message_type { + email { + append form_elements { + {description:text(text) {label "[_ contacts.Subject]"} {html {size 55 maxlength 1000}}} + {content:text(textarea) {label "[_ contacts.Body]"} {html {cols 70 rows 24}}} + } + } + letter { + append form_elements { + {content:richtext(richtext) {label "[_ contacts.Message]"} {html {cols 70 rows 24}}} + } + } + header { + append form_elements { + {content:richtext(richtext) {label "[_ contacts.Header]"} {html {cols 70 rows 24}}} + } + } + footer { + append form_elements { + {content:richtext(richtext) {label "[_ contacts.Header]"} {html {cols 70 rows 24}}} + } + } + +} + +ad_form -name "rel_type" \ + -cancel_label [_ contacts.Cancel] \ + -cancel_url $return_url \ + -form $form_elements \ + -on_request { + } -new_request { + set owner_id [ad_conn user_id] + set locale [lang::system::locale] + } -edit_request { + + db_1row get_data { select * from contact_messages where item_id = :item_id } + if { $message_type != "email" } { + set content [list $content $content_format] + } + + } -on_submit { + + if { $message_type != "email" } { + set content_format [template::util::richtext::get_property format $content] + set content [template::util::richtext::get_property content $content] + set description "" + } else { + set content_format "text/plain" + } + + contact::message::save \ + -item_id $item_id \ + -owner_id $owner_id \ + -message_type $message_type \ + -title $title \ + -description $description \ + -content $content \ + -content_format $content_format \ + -locale $locale + + } -after_submit { + ad_returnredirect $return_url + ad_script_abort + } + +ad_return_template Index: openacs-4/packages/contacts/www/message-log.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/message-log.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/message-log.adp 30 Nov 2005 15:31:02 -0000 1.1.2.2 @@ -0,0 +1,28 @@ + + +@party_id@ + + + + +@content;noquote@ + + + + + + +#contacts.Print_Letter# + + + +

#contacts.Return_to_history#

+ +@content;noquote@ + + + + +
+ + Index: openacs-4/packages/contacts/www/message-log.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/message-log.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/message-log.tcl 30 Nov 2005 15:31:02 -0000 1.1.2.2 @@ -0,0 +1,48 @@ +ad_page_contract { + + @author Matthew Geddert openacs@geddert.com + @creation-date 2004-07-28 + @cvs-id $Id: message-log.tcl,v 1.1.2.2 2005/11/30 15:31:02 miguelm Exp $ + + +} { + {message_id:integer,notnull} +} -validate { + message_exists -requires {message_id} { + if { ![db_0or1row message_exists_p { select 1 from contact_message_log where message_id = :message_id}] } { + ad_complain "[_ contacts.lt_The_message_specified_does_not_exist]" + } + } +} + +db_1row get_message_data { + select message_type, + sender_id, + recipient_id, + sent_date, + title, + description, + content, + content_format + from contact_message_log + where message_id = :message_id + +} + +set timestamp [lindex [split $sent_date "."] 0] +set date [lc_time_fmt $timestamp "%q"] +set time [string trimleft [lc_time_fmt $timestamp "%r"] "0"] + +if { $message_type == "email" } { + set content "
[_ contacts.Date]:    $date $time
+[_ contacts.From]:    [contact::link -party_id $sender_id]
+[_ contacts.To]:      [contact::link -party_id $recipient_id]
+[_ contacts.Subject]: $description
+
+[ad_convert_to_html $content] +" +} else { + set return_url "[contact::url -party_id $recipient_id]history" +} +set party_id $recipient_id +ad_return_template Index: openacs-4/packages/contacts/www/message-messages.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/message-messages.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/message-messages.adp 30 Nov 2005 15:31:02 -0000 1.2.2.2 @@ -0,0 +1,26 @@ + + +#contacts.Mail_Merge_Results# + + + + + + +
+@messages.content;noquote@ +
+
+ +
+From:    @from@
+To:      @messages.to@
+Subject: @messages.subject@
+
+@messages.content@
+
+



+
+
+ + Index: openacs-4/packages/contacts/www/message.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/message.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/message.adp 30 Nov 2005 15:31:02 -0000 1.20.2.2 @@ -0,0 +1,39 @@ + + +@title@ +@context@ + + + + + + +@party_id@ + +

@error_message;noquote@

+
+
+comment_add.comment + + + #contacts.This_contact_doesnt# + + + + + + + + + Index: openacs-4/packages/contacts/www/message.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/message.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/message.tcl 30 Nov 2005 15:31:02 -0000 1.21.2.2 @@ -0,0 +1,323 @@ +ad_page_contract { + List and manage contacts. + + @author Matthew Geddert openacs@geddert.com + @creation-date 2004-07-28 + @cvs-id $Id: message.tcl,v 1.21.2.2 2005/11/30 15:31:02 miguelm Exp $ +} { + {object_id:integer,multiple,optional} + {party_id:integer,multiple,optional} + {party_ids:optional} + {message_type ""} + {message:optional} + {header_id:integer ""} + {footer_id:integer ""} + {return_url "./"} + {file_ids ""} + {item_id:integer ""} + {folder_id:integer ""} + {signature_id:integer ""} + {subject ""} + {content_body:html ""} + {to:integer,multiple,optional ""} + {page:optional 1} + {context_id:integer ""} +} -validate { + valid_message_type -requires {message_type} { + if { [lsearch [list email letter] $message_type] < 0 } { + ad_complain "[_ contacts.lt_Your_provided_an_inva]" + } + } +} + +if { [exists_and_not_null message] && ![exists_and_not_null message_type] } { + set message_type [lindex [split $message "."] 0] + set item_id [lindex [split $message "."] 1] +} + +if { [exists_and_not_null party_id] } { + set party_ids [list] + foreach party_id $party_id { + lappend party_ids $party_id + } +} + +if { [exists_and_not_null to] } { + set party_ids [list] + foreach party_id $to { + lappend party_ids $party_id + } +} + +set party_count [llength $party_ids] +set title "[_ contacts.Messages]" +set user_id [ad_conn user_id] +set context [list $title] + +set using_emp_email_p 0 + +set recipients [list] +foreach party_id $party_ids { + set contact_name [contact::name -party_id $party_id] + set contact_url [contact::url -party_id $party_id] + set contact_link "${contact_name}" + set sort_key [string toupper $contact_name] + # Check if the party has a valid e-mail address we can send to + set email_p [contact::message::email_address_exists_p -party_id $party_id] + set letter_p [contact::message::mailing_address_exists_p -party_id $party_id] + lappend recipients [list $contact_name $party_id $contact_link $email_p $letter_p] +} +set sorted_recipients [ams::util::sort_list_of_lists -list $recipients] +set recipients [list] +set invalid_recipients [list] +set party_ids [list] +set invalid_party_ids [list] + +foreach recipient $sorted_recipients { + set party_id [lindex $recipient 1] + set contact_link [lindex $recipient 2] + set email_p [lindex $recipient 3] + set letter_p [lindex $recipient 4] + if { $message_type == "letter" } { + if { $letter_p } { + lappend party_ids $party_id + lappend recipients $contact_link + } else { + lappend invalid_party_ids $party_id + lappend invalid_recipients $contact_link + } + } elseif { $message_type == "email" } { + if { $email_p } { + lappend party_ids $party_id + lappend recipients $contact_link + } else { + # We are going to check if there is an employee relationship + # if there is we are going to check if the employer has an + # email adrres, if it does we are going to use that address + set employer_id [relation::get_object_two -object_id_one $party_id \ + -rel_type "contact_rels_employment"] + + if { ![empty_string_p $employer_id] } { + set emp_addr [contact::email -party_id $employer_id] + if { ![empty_string_p $emp_addr] } { + lappend party_ids $party_id + lappend recipients $contact_link + set using_emp_email_p 1 + } else { + lappend invalid_party_ids $party_id + lappend invalid_recipients $contact_link + } + } else { + lappend invalid_party_ids $party_id + lappend invalid_recipients $contact_link + } + } + } else { + if { $email_p || $letter_p } { + lappend party_ids $party_id + lappend recipients $contact_link + } else { + # We are going to check if there is an employee relationship + # if there is we are going to check if the employer has an + # email adrres, if it does we are going to use that address + set employer_id [relation::get_object_two -object_id_one $party_id \ + -rel_type "contact_rels_employment"] + + if { ![empty_string_p $employer_id] } { + set emp_addr [contact::email -party_id $employer_id] + if { ![empty_string_p $emp_addr] } { + lappend party_ids $party_id + lappend recipients $contact_link + set using_emp_email_p 1 + } else { + lappend invalid_party_ids $party_id + lappend invalid_recipients $contact_link + } + } else { + lappend invalid_party_ids $party_id + lappend invalid_recipients $contact_link + } + } + } +} + +set recipients [join $recipients ", "] +set invalid_recipients [join $invalid_recipients ", "] +if { [llength $invalid_recipients] > 0 } { + switch $message_type { + letter { + set error_message [_ contacts.lt_You_cannot_send_a_letter_to_invalid_recipients] + } + email { + set error_message [_ contacts.lt_You_cannot_send_an_email_to_invalid_recipients] + } + default { + set error_message [_ contacts.lt_You_cannot_send_a_message_to_invalid_recipients] + } + } + if { $party_ids != "" } { + util_user_message -html -message $error_message + } +} + +if {[exists_and_not_null object_id]} { + foreach object $object_id { + if {[fs::folder_p -object_id $object]} { + db_foreach files "select r.revision_id + from cr_revisions r, cr_items i + where r.item_id = i.item_id and i.parent_id = :object" { + lappend file_list $revision_id + } + } else { + set revision_id [content::item::get_best_revision -item_id $object] + if {[empty_string_p $revision_id]} { + # so already is a revision + lappend file_list $object + } else { + # append revision of content item + lappend file_list $revision_id + } + } + } +} + +if {[exists_and_not_null file_list]} { + set file_ids [join $file_list " "] +} + +set form_elements { + file_ids:text(hidden) + party_ids:text(hidden) + return_url:text(hidden) + folder_id:text(hidden) + {to_name:text(inform),optional {label "[_ contacts.Recipients]"} {value $recipients}} +} + + +if { ![exists_and_not_null message_type] } { + + set message_type_options [ams::util::localize_and_sort_list_of_lists \ + -list [db_list_of_lists get_message_types { select pretty_name, message_type from contact_message_types }] \ + ] + + set message_options [list] + foreach op $message_type_options { + set message_type [lindex $op 1] + if {$message_type == "letter" || $message_type == "email"} { + lappend message_options [list "-- [_ contacts.New] [lindex $op 0] --" $message_type] + } else { + set ${message_type}_options [list [list [_ contacts.--none--] ""]] + } + + # set email_text and letter_text and others in the future + set "${message_type}_text" [lindex $op 0] + } + + set public_text [_ contacts.Public] + set package_id [ad_conn package_id] + set letter_options "" + set email_options "" + db_foreach get_messages { + select CASE WHEN owner_id = :package_id THEN :public_text ELSE contact__name(owner_id) END as public_display, + title, + to_char(item_id,'FM9999999999999999999999') as item_id, + message_type + from contact_messages + where owner_id in ( select party_id from parties ) + or owner_id = :package_id + order by CASE WHEN owner_id = :package_id THEN '000000000' ELSE upper(contact__name(owner_id)) END, message_type, upper(title) + } { + if {$message_type == "letter" || $message_type == "email"} { + lappend ${message_type}_options [list "$public_display [set ${message_type}_text]:$title" "${message_type}.$item_id"] + } else { + lappend ${message_type}_options [list "$public_display:$title" "$item_id"] + } + } + + set message_options [concat \ + $message_options \ + $letter_options \ + $email_options] + + if {[exists_and_not_null header_options]} { + lappend form_elements [list \ + header_id:text(select) \ + [list label "[_ contacts.Header]"] \ + [list options $header_options] \ + ] + } + + lappend form_elements [list \ + message:text(select) \ + [list label "[_ contacts.Message]"] \ + [list options $message_options] \ + ] + + set message_type "" + set title [_ contacts.create_a_message] + +} else { + set title [_ contacts.create_$message_type] +} + +set context [list $title] + +if { [string is false [exists_and_not_null message]] } { + set signature_list [list [list [_ contacts.--none--] ""]] + set reset_title $title + set reset_signature_id $signature_id + db_foreach signatures "select title, signature_id, default_p + from contact_signatures + where party_id = :user_id + order by default_p, upper(title), upper(signature)" { + lappend signature_list [list $title $signature_id] + if { $default_p == "t" } { + set default_signature_id $signature_id + } + } + set title $reset_title + set signature_id $reset_signature_id + append form_elements { + {signature_id:text(select) + {label "[_ contacts.Signature]"} + {options {$signature_list}} + } + } +} + +if {[exists_and_not_null footer_options]} { + lappend form_elements [list \ + footer_id:text(select) \ + [list label "[_ contacts.Footer]"] \ + [list options $footer_options] \ + ] +} + +set edit_buttons [list [list "[_ contacts.Next]" create]] + +# the message form will rest party_ids so we need to carry it over +set new_party_ids $party_ids +ad_form -action message \ + -name message \ + -cancel_label "[_ contacts.Cancel]" \ + -cancel_url $return_url \ + -edit_buttons $edit_buttons \ + -form $form_elements \ + -on_request { + if { [exists_and_not_null default_signature_id] } { + set signature_id $default_signature_id + } else { + set signature_id "" + } + } -new_request { + } -edit_request { + } -on_submit { + } +set party_ids $new_party_ids + +if {[exists_and_not_null signature_id]} { + set signature [contact::signature::get -signature_id $signature_id] +} else { + set signature "" +} + Index: openacs-4/packages/contacts/www/messages.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/messages.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/messages.adp 30 Nov 2005 15:31:02 -0000 1.1.2.2 @@ -0,0 +1,13 @@ + + + + + + + +
+ + + +
+ Index: openacs-4/packages/contacts/www/messages.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/messages.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/messages.tcl 30 Nov 2005 15:31:02 -0000 1.2.2.2 @@ -0,0 +1,91 @@ +ad_page_contract { + List and manage contacts. + + @author Matthew Geddert openacs@geddert.com + @creation-date 2004-07-28 + @cvs-id $Id: messages.tcl,v 1.2.2.2 2005/11/30 15:31:02 miguelm Exp $ +} { + orderby:optional + {owner_id:optional} + {message_type ""} +} -validate { +} + +set user_id [ad_conn user_id] +set package_id [ad_conn package_id] +if { ![exists_and_not_null owner_id] } { + set owner_id $user_id +} +set owner_options [db_list_of_lists select_owner_options {}] +set owner_options [concat [list [list [_ contacts.Public_Messages] "${package_id}"]] $owner_options] + +set message_types [ams::util::localize_and_sort_list_of_lists \ + -list [db_list_of_lists get_message_types { select pretty_name, message_type from contact_message_types}] \ + ] + +set actions [list] +foreach type $message_types { + lappend actions "[_ contacts.Add] [lindex $type 0]" [export_vars -base message-ae -url [list [list message_type [lindex $type 1]]]] "[_ contacts.Add] [lindex $type 0]" + set type_pretty_name([lindex $type 1]) [lindex $type 0] +} + +template::list::create \ + -name "messages" \ + -multirow "messages" \ + -row_pretty_plural "[_ contacts.messages]" \ + -actions $actions \ + -key item_id \ + -elements { + type_pretty { + label {#acs-kernel.common_Type#} + display_col type_pretty + } + title { + label {#acs-kernel.common_Title#} + display_col title + link_url_eval $message_url + } + locale { + label {#acs-lang.Locale#} + } + action { + label "" + display_template { + #acs-kernel.common_Copy# + + #acs-kernel.common_Delete# + + + #contacts.Make_Public# + + } + } + } -filters { + owner_id { + label "\#contacts.Owner\#" + values $owner_options + where_clause "" + default_value $user_id + } + } -orderby { + } -formats { + } + + +set return_url [export_vars -base messages -url {owner_id}] +set admin_p [permission::permission_p -object_id $package_id -privilege "admin"] + +db_multirow -extend {message_url make_public_url delete_url copy_url type_pretty} -unclobber messages select_messages {} { + set type_pretty $type_pretty_name($message_type) + if { $owner_id != $package_id && $admin_p } { + set make_public_url [export_vars -base message-action -url {item_id {owner_id $package_id} {action move} return_url}] + } + if { $owner_id == $user_id || $admin_p } { + set delete_url [export_vars -base message-action -url {item_id {action delete}}] + } + set message_url [export_vars -base "message-ae" -url {item_id}] + set copy_url [export_vars -base message-action -url {item_id {owner_id $user_id} {action copy} return_url}] + +} + + Index: openacs-4/packages/contacts/www/messages.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/messages.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/messages.xql 30 Nov 2005 15:31:02 -0000 1.2.2.2 @@ -0,0 +1,34 @@ + + + + + + select CASE WHEN owner_id = :user_id + THEN '\#contacts.My_Messages\#' + ELSE contact__name(owner_id) END, + owner_id + from ( select distinct owner_id + from contact_messages + where ( title is not null or owner_id = :user_id ) + and owner_id in ( select party_id from parties )) distinct_owners + order by CASE WHEN owner_id = :user_id THEN '0000000000000000000' ELSE upper(contact__name(owner_id)) END + + + + + + select item_id, + owner_id, + message_type, + title, + description, + content, + content_format, + locale + from contact_messages + where owner_id = :owner_id + order by message_type, upper(title) + + + + Index: openacs-4/packages/contacts/www/person-groups-ae.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/person-groups-ae.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/person-groups-ae.adp 30 Nov 2005 15:31:02 -0000 1.2.2.2 @@ -0,0 +1,7 @@ + +@title@ +@context@ + + + + Index: openacs-4/packages/contacts/www/person-groups-ae.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/person-groups-ae.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/person-groups-ae.tcl 30 Nov 2005 15:31:02 -0000 1.3.2.2 @@ -0,0 +1,83 @@ +ad_page_contract { + + @author Matthew Geddert openacs@geddert.com + @creation-date 2004-07-28 + @cvs-id $Id: person-groups-ae.tcl,v 1.3.2.2 2005/11/30 15:31:02 miguelm Exp $ + + +} { + {person_id:integer,optional} +} + + +if { [exists_and_not_null person_id] } { + set admin_user_url [acs_community_member_admin_url -user_id $person_id] + set user_url [acs_community_member_url -user_id $person_id] +} else { + set admin_user_url "" + set user_url "" +} + +set list_name "person_[ad_conn package_id]" +set object_type "person" +set package_key "contacts" + +if { [ad_form_new_p -key person_id] } { + set title "[_ contacts.Add_a_Person]" + set mode "edit" +} else { + set title [person::name -person_id $person_id] + set mode "display" +} +set context [list $title] + + + + + + + + +# groups +ad_form -name groups_ae \ + -mode "display" \ + -has_edit "t" \ + -actions { + {"[_ contacts.Add_to_Group]" "formbutton:edit"} + } -form { + {person_id:key} + } + +set package_id [ad_conn package_id] +set group_options [db_list_of_lists get_groups { + select groups.group_name, + groups.group_id, + ( select count(distinct member_id) from group_member_map where group_member_map.group_id = groups.group_id ) as member_count + from groups left join ( select group_id, owner_id, group_type, deprecated_p + from contact_groups + where package_id = :package_id ) contact_groups on (groups.group_id = contact_groups.group_id) + where groups.group_id != '-1' +}] + +set groups_available [db_list_of_lists get_groups { + select groups.group_name, + groups.group_id, + ( select count(distinct member_id) from group_member_map where group_member_map.group_id = groups.group_id ) as member_count + from groups left join ( select group_id, owner_id, group_type, deprecated_p + from contact_groups + where package_id = :package_id ) contact_groups on (groups.group_id = contact_groups.group_id) + where groups.group_id != '-1' +}] +ad_form -extend -name groups_ae -form { + {group_id:integer(checkbox),multiple {label "[_ contacts.Groups]"} {options $group_options}} + } -edit_request { + set group_id [db_list get_them { select distinct group_id from group_member_map where member_id = :person_id }] + #ad_return_error $group_id $group_id + } -on_submit { + } -after_submit { + ad_returnredirect -message "[_ contacts.lt_Group_Information_Sav]" [export_vars -base "person-ae" -url {person_id}] + } + + + +ad_return_template Index: openacs-4/packages/contacts/www/person-upgrade-to-user.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/person-upgrade-to-user.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/person-upgrade-to-user.tcl 30 Nov 2005 15:31:02 -0000 1.1.2.2 @@ -0,0 +1,18 @@ +ad_page_contract { + + @author Matthew Geddert openacs@geddert.com + @creation-date 2005-07-06 + @cvs-id $Id: person-upgrade-to-user.tcl,v 1.1.2.2 2005/11/30 15:31:02 miguelm Exp $ + + +} { + {person_id:integer} +} + +permission::require_permission -object_id [ad_conn package_id] -privilege "admin" + +contact::person_upgrade_to_user -person_id $person_id +set contact_link [contact::link -party_id $person_id] +util_user_message -message "[_ contacts.lt_-contact_link-_was_upgraded_to_a_user]" +ad_returnredirect [contact::url -party_id $person_id] +ad_script_abort Index: openacs-4/packages/contacts/www/relationship-add-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/relationship-add-postgresql.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/relationship-add-postgresql.xql 30 Nov 2005 15:31:02 -0000 1.1.2.2 @@ -0,0 +1,40 @@ + + + + + +select 1 + from contact_rel_types + where primary_role = :role + limit 1 + + + + + +select acs_rel_type__role_pretty_name(:role_two) as secondary_role_pretty + + + + + +select rel_type, + primary_role, + acs_rel_type__role_pretty_name(primary_role) as primary_role_pretty + from contact_rel_types + where secondary_role = :role_two + and secondary_object_type in (:contact_type_two,'party') + and primary_object_type in (:contact_type_one,'party') + + + + + +select role_one as db_role_one, + role_two as db_role_two + from acs_rel_types + where rel_type = :rel_type + + + + Index: openacs-4/packages/contacts/www/relationship-add.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/relationship-add.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/relationship-add.adp 30 Nov 2005 15:31:02 -0000 1.2.2.2 @@ -0,0 +1,10 @@ + +@party_id@ + +

#contacts.lt_What_role_does_contac#

+ + Index: openacs-4/packages/contacts/www/relationship-add.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/relationship-add.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/relationship-add.tcl 30 Nov 2005 15:31:02 -0000 1.5.2.2 @@ -0,0 +1,90 @@ +ad_page_contract { + Add a contact relationship + + @author Matthew Geddert openacs@geddert.com + @creation-date 2004-05-15 + @cvs-id $Id: relationship-add.tcl,v 1.5.2.2 2005/11/30 15:31:02 miguelm Exp $ +} { + {party_one:integer,notnull} + {role_one:optional} + {party_two:integer,notnull} + {role_two:notnull} + {rel_type:optional} + {return_url ""} +} -validate { + contact_one_exists -requires {party_one} { + if { ![contact::exists_p -party_id $party_one] } { + ad_complain "[_ contacts.lt_The_first_contact_spe]" + } + } + contact_two_exists -requires {party_two} { + if { ![contact::exists_p -party_id $party_two] } { + ad_complain "[_ contacts.lt_The_second_contact_sp]" + } + } + role_one_exists -requires {role_one} { + set role $role_one + if { ![db_0or1row role_exists_p {}] } { + ad_complain "[_ contacts.lt_The_first_role_specif]" + } + } + role_two_exists -requires {role_two} { + set role $role_two + if { ![db_0or1row role_exists_p {}] } { + ad_complain "[_ contacts.lt_The_second_role_speci]" + } + } +} + +set party_id $party_one +set contact_name_one [contact::name -party_id $party_id] +set contact_name_two [contact::name -party_id $party_two] +set contact_type_one [contact::type -party_id $party_id] +if { $contact_type_one == "user" } { + set contact_type_one "person" +} +set contact_type_two [contact::type -party_id $party_two] +if { $contact_type_two == "user" } { + set contact_type_two "person" +} +set secondary_role_pretty [db_string get_secondary_role_pretty {}] +if { ![exists_and_not_null rel_type] } { + set options_list [db_list_of_lists get_rel_types {}] + set options_length [llength $options_list] + if { $options_length == "0" } { + ad_return_error "[_ contacts.Error]" "[_ contacts.lt_There_was_a_problem_w]" + } elseif { $options_length == "1" } { + set rel_type [lindex [lindex $options_list 0] 0] + set role_one [lindex [lindex $options_list 0] 1] + } else { + multirow create rel_types rel_type primary_role_pretty url + foreach rel $options_list { + set temp_rel_type [lindex $rel 0] + set temp_role_one [lindex $rel 1] + set temp_role_pretty [lindex $rel 2] + multirow append rel_types $temp_rel_type $temp_role_pretty [export_vars -base "relationship-add" -url {party_one party_two role_two {role_one $temp_role_one} {rel_type $temp_rel_type}}] + } + } +} + + + + +if { [exists_and_not_null rel_type] } { + + db_1row get_roles {} + + if { $db_role_one == $role_one } { + set object_id_one $party_one + set object_id_two $party_two + } else { + set object_id_one $party_two + set object_id_two $party_one + } + if { ![exists_and_not_null return_url] } { + set return_url "${party_id}/relationships" + } + ad_returnredirect [export_vars -base "relationship-ae" -url {object_id_one object_id_two rel_type return_url {party_id $party_one}}] + ad_script_abort +} + Index: openacs-4/packages/contacts/www/relationship-ae-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/relationship-ae-postgresql.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/relationship-ae-postgresql.xql 30 Nov 2005 15:31:02 -0000 1.1.2.2 @@ -0,0 +1,46 @@ + + + + + +select rel_id + from acs_rels + where rel_type = :rel_type + and ( object_id_one = :object_id_one and object_id_two = :object_id_two ) + + + + + +select rel_id + from acs_rels + where rel_type = :rel_type + and object_id_one = :object_id_one + and object_id_two = :object_id_two + + + + + +select acs_rel__new ( + :rel_id, + :rel_type, + :object_id_one, + :object_id_two, + :context_id, + :creation_user, + :creation_ip + ) + + + + + +insert into contact_rels + (rel_id) +values + (:rel_id) + + + + Index: openacs-4/packages/contacts/www/relationship-ae.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/relationship-ae.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/relationship-ae.adp 30 Nov 2005 15:31:02 -0000 1.2.2.2 @@ -0,0 +1,5 @@ + +@party_id@ + + + Index: openacs-4/packages/contacts/www/relationship-ae.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/relationship-ae.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/relationship-ae.tcl 30 Nov 2005 15:31:02 -0000 1.5.2.2 @@ -0,0 +1,96 @@ +ad_page_contract { + Add a Relationship and Manage Relationship Details + + @author Matthew Geddert openacs@geddert.com + @creation-date 2004-05-21 + @cvs-id $Id: relationship-ae.tcl,v 1.5.2.2 2005/11/30 15:31:02 miguelm Exp $ +} { + {object_id_one:integer,notnull} + {object_id_two:integer,notnull} + {party_id:integer,notnull} + {rel_type:notnull} + {return_url ""} +} -validate { + contact_one_exists -requires {object_id_one} { + if { ![contact::exists_p -party_id $object_id_one] } { + ad_complain "[_ contacts.lt_The_first_contact_spe]" + } + } + contact_two_exists -requires {object_id_two} { + if { ![contact::exists_p -party_id $object_id_two] } { + ad_complain "[_ contacts.lt_The_second_contact_sp]" + } + } + party_id_valid -requires {object_id_one object_id_two party_id} { + if { $party_id != $object_id_one && $party_id != $object_id_two } { + ad_complain "[_ contacts.lt_The_contact_specified_1]" + } + } +} + +set rel_id_from_db [db_string get_rel_id {} -default {}] +if { [exists_and_not_null rel_id_from_db] } { + set rel_id $rel_id_from_db +} +set package_id [ad_conn package_id] +set list_exists_p [ams::list::exists_p -package_key "contacts" -object_type ${rel_type} -list_name ${package_id}] + +if { $list_exists_p } { + + set form_elements { + rel_id:key + {object_id_one:integer(hidden)} + {object_id_two:integer(hidden)} + {party_id:integer(hidden)} + {rel_type:text(hidden)} + {return_url:text(hidden),optional} + } + append form_elements [ams::ad_form::elements -package_key "contacts" -object_type $rel_type -list_name [ad_conn package_id]] + + ad_form -name rel_form \ + -mode "edit" \ + -form $form_elements \ + -on_request { + } -new_request { + } -edit_request { + ams::ad_form::values -form_name "rel_form" -package_key "contacts" -object_type $rel_type -list_name [ad_conn package_id] -object_id $rel_id + } -on_submit { + } -new_data { + } -edit_data { + } -after_submit { + } + + +} + +if { !$list_exists_p || [template::form::is_valid "rel_form"] } { + + set existing_rel_id [db_string rel_exists_p {} -default {}] + + if { [empty_string_p $existing_rel_id] } { + set rel_id {} + set context_id {} + set creation_user [ad_conn user_id] + set creation_ip [ad_conn peeraddr] + set rel_id [db_exec_plsql create_rel {}] + db_dml insert_contact_rel {} + # callback contact::insert_contact_rel -package_id $package_id -form party_ae -object_type $object_type + util_user_message -message "[_ contacts.Relationship_Added]" + } else { + util_user_message -message "[_ contacts.Relationship_Updated]" + } + if { $list_exists_p } { + ams::ad_form::save -package_key "contacts" \ + -object_type $rel_type \ + -list_name [ad_conn package_id] \ + -form_name "rel_form" \ + -object_id $rel_id + } + if { ![exists_and_not_null return_url] } { + set return_url "$party_id/relationships" + } + ad_returnredirect $return_url + ad_script_abort +} + +ad_return_template Index: openacs-4/packages/contacts/www/relationship-delete-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/relationship-delete-postgresql.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/relationship-delete-postgresql.xql 30 Nov 2005 15:31:02 -0000 1.1.2.2 @@ -0,0 +1,13 @@ + + + + + +select acs_object__delete(rel_id) + from acs_rels + where ( object_id_one = :party_id or object_id_two = :party_id ) + and rel_id = :rel_id + + + + Index: openacs-4/packages/contacts/www/relationship-delete.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/relationship-delete.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/relationship-delete.tcl 30 Nov 2005 15:31:02 -0000 1.4.2.2 @@ -0,0 +1,26 @@ +ad_page_contract { + List and manage contacts. + + @author Matthew Geddert openacs@geddert.com + @creation-date 2004-07-28 + @cvs-id $Id: relationship-delete.tcl,v 1.4.2.2 2005/11/30 15:31:02 miguelm Exp $ +} { + {party_id:integer,notnull} + {rel_id:integer,notnull} + {return_url ""} +} -validate { + valid_party -requires {party_id} { + if { ![contact::exists_p -party_id $party_id] } { + ad_complain "[_ contacts.lt_The_contact_specified]" + } + } +} + +# ams::object_delete -object_id $rel_id +db_1row delete_rel {} + +if { ![exists_and_not_null return_url] } { + set return_url "$party_id/relationships" +} +ad_returnredirect -message "[_ contacts.Relationship_Deleted]" $return_url +ad_script_abort Index: openacs-4/packages/contacts/www/search-action.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/search-action.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/search-action.tcl 30 Nov 2005 15:31:02 -0000 1.3.2.2 @@ -0,0 +1,85 @@ +ad_page_contract { + List and manage contacts. + + @author Matthew Geddert openacs@geddert.com + @creation-date 2004-07-28 + @cvs-id $Id: search-action.tcl,v 1.3.2.2 2005/11/30 15:31:02 miguelm Exp $ +} { + {search_id:integer} + {owner_id:integer ""} + {action} + {return_url ""} +} -validate { + valid_search_id -requires {search_id} { + if { ![contact::search::exists_p -search_id $search_id] } { + ad_complain [_ contacts.The_search_id_sepecified_does_not_exist] + } + } + action_valid -requires {action} { + if { [lsearch [list move copy delete] $action] < 0 } { + ad_complain [_ contacts.The_action_specified_is_invalid] + } elseif { ![permission::permission_p -object_id [ad_conn package_id] -privilege "admin"] } { + set search_owner_id [contact::search::owner_id -search_id $search_id] + switch $action { + "move" { + ad_complain [_ contacts.You_do_not_have_permission_to_move_searches] + } + "copy" { + if { $owner_id != [ad_conn user_id] } { + ad_complain [_ contacts.You_cannot_copy_searches_to_somebody_other_than_yourself] + } + } + "delete" { + if { $search_owner_id != [ad_conn user_id] } { + ad_complain [_ contacts.You_cannot_delete_searches_that_do_not_belong_to_you] + } + } + } + } + } + owner_valid -requires {owner_id} { + if { [exists_and_not_null owner_id] } { + if { $owner_id == [ad_conn package_id] || ( [contact::exists_p -party_id $owner_id] && [lsearch [list person user] [contact::type -party_id $owner_id]] >= 0 ) } { + } else { + ad_complain [_ contacts.The_owner_id_specified_is_not_valid] + } + } + } +} + +db_1row select_search_info {} +set package_id [ad_conn package_id] + + +switch $action { + "move" { + db_dml update_owner {} + util_user_message -html -message [_ contacts.The_search_-title-_was_made_public] + } + "copy" { + regsub -all "'" $title "''" sql_title + set similar_titles [db_list select_similar_titles {}] + set number 1 + set orig_title $title + while { [lsearch $similar_titles $title] >= 0 } { + set title "$orig_title ($number)" + incr number + } + set new_search_id [contact::search::new -title $title -owner_id $owner_id -all_or_any $all_or_any -object_type $object_type] + db_foreach select_search_conditions {} { + contact::search::condition::new -search_id $new_search_id -type $type -var_list $var_list + } + util_user_message -html -message [_ contacts.The_search_-title-_was_copied_to_your_searches] + } + "delete" { + contact::search::delete -search_id $search_id + util_user_message -html -message [_ contacts.The_search_-title-_was_deleted] + } +} + +if { ![exists_and_not_null return_url] } { + set return_url [export_vars -base "searches" -url {owner_id}] +} + +ad_returnredirect $return_url +ad_script_abort Index: openacs-4/packages/contacts/www/search-action.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/search-action.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/search-action.xql 30 Nov 2005 15:31:02 -0000 1.2.2.2 @@ -0,0 +1,41 @@ + + + + + + select title, + owner_id as old_owner_id, + all_or_any, + object_type + from contact_searches + where search_id = :search_id + + + + + + update contact_searches + set owner_id = :owner_id + where search_id = :search_id + + + + + + select title + from contact_searches + where owner_id = :owner_id + and upper(title) like upper('${sql_title}%') + + + + + + select type, + var_list + from contact_search_conditions + where search_id = :search_id + + + + Index: openacs-4/packages/contacts/www/search-condition-delete.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/search-condition-delete.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/search-condition-delete.tcl 30 Nov 2005 15:31:02 -0000 1.1.2.2 @@ -0,0 +1,43 @@ +ad_page_contract { + Delete a search condition. + + @author Matthew Geddert openacs@geddert.com + @creation-date 2004-07-28 + @cvs-id $Id: search-condition-delete.tcl,v 1.1.2.2 2005/11/30 15:31:02 miguelm Exp $ +} { + {condition_id:integer} +} -validate { + valid_condition -requires {condition_id} { + db_0or1row condition_exists_p { + select cs.owner_id + from contact_search_conditions csc, + contact_searches cs + where csc.condition_id = :condition_id + and csc.search_id = cs.search_id + } + if { ![exists_and_not_null owner_id] } { + ad_complain "[_ contacts.You_have_specified_an_invalid_search_condition]" + } else { + set valid_owner_ids [list] + lappend valid_owner_ids [ad_conn user_id] + if { [permission::permission_p -object_id [ad_conn package_id] -privilege "admin"] } { + lappend valid_owner_ids [ad_conn package_id] + } + if { [lsearch $valid_owner_ids $owner_id] < 0 } { + if { [contact::exists_p -party_id $owner_id] } { + ad_complain "[_ contacts.You_do_not_have_permission_to_delete_other_peoples_search_conditions]" + } else { + ad_complain "[_ contacts.You_do_not_have_permission_to_delete_this_condition]" + } + } + } + } +} + +db_1row get_search_id { select search_id, var_list, type from contact_search_conditions where condition_id = :condition_id } +contact::search::condition::delete -condition_id $condition_id +contact::search::flush -search_id $search_id +set condition [contacts::search::condition_type -type $type -request pretty -var_list $var_list] + +util_user_message -html -message [_ contacts.The_condition_-condition-_was_deleted] +ad_returnredirect [export_vars -base "search" -url { search_id }] Index: openacs-4/packages/contacts/www/search-help.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/search-help.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/search-help.adp 30 Nov 2005 15:31:02 -0000 1.2.2.2 @@ -0,0 +1,30 @@ + + +@title@ +@context@ + + + +

#contacts.lt_All_searches_are_case#

+

#contacts.Normal_Searches#

+

#contacts.lt_Entering_a_string_in_#

+
    +
  1. #contacts.lt_First_Names_contains_# +
  2. #contacts.lt_Last_Name_contains_Se# +
  3. #contacts.lt_Organization_Name_con# +
  4. #contacts.lt_Party_ID_equals_Searc# +
+

#contacts.lt_If_multiple_words_are# +

+Contact ID    | First Names    | Last Name     | Organization Name
+--------------+----------------+---------------+---------------------------------
+123           | Jane           | Doe           |
+234           | John           | Doe           |
+345           | Alfred         | Hitchcock     |
+456           |                |               | United States Treasury
+
+

#contacts.lt_If_in_a_normal_search#

+ +

#contacts.Advanced_Searches#

+

#contacts.lt_Advanced_searches_are# + Index: openacs-4/packages/contacts/www/search-help.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/search-help.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/search-help.tcl 30 Nov 2005 15:31:02 -0000 1.3.2.2 @@ -0,0 +1,14 @@ +ad_page_contract { + List and manage contacts. + + @author Matthew Geddert openacs@geddert.com + @creation-date 2004-07-28 + @cvs-id $Id: search-help.tcl,v 1.3.2.2 2005/11/30 15:31:02 miguelm Exp $ +} { +} -validate { +} +set admin_p [ad_permission_p [ad_conn package_id] admin] +#set default_group_id [contacts::default_group_id] +set title "[_ contacts.Search_Help]" +set context [list $title] + Index: openacs-4/packages/contacts/www/search.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/search.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/search.adp 30 Nov 2005 15:31:02 -0000 1.9.2.2 @@ -0,0 +1,30 @@ + + + + +
+
+ + + + + + + + +
+ + + +
+ @show_default_names;noquote@ @show_names;noquote@ + ( #contacts.Clear# ) + + + +
+
+
+
+ + Index: openacs-4/packages/contacts/www/search.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/search.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/search.tcl 30 Nov 2005 15:31:02 -0000 1.23.2.2 @@ -0,0 +1,400 @@ +ad_page_contract { + List and manage contacts. + + @author Matthew Geddert openacs@geddert.com + @creation-date 2004-07-28 + @cvs-id $Id: search.tcl,v 1.23.2.2 2005/11/30 15:31:02 miguelm Exp $ +} { + {search_id:integer,optional} + {type ""} + {save ""} + {add ""} + {next ""} + {clear ""} + {delete ""} + {search ""} + {object_type ""} + {all_or_any ""} + {title ""} + {owner_id ""} + {aggregate_attribute_id ""} + {aggregate ""} + {attribute_values ""} + {attribute_option ""} + {attribute_names ""} + {attr_val_name ""} +} -validate { + valid_object_type -requires {object_type} { + if { [lsearch [list party person organization] $object_type] < 0 } { + ad_complain "[_ contacts.You_have_specified_an_invalid_object_type]" + } + } + valid_search_id -requires {search_id} { + db_0or1row condition_exists_p { + select owner_id + from contact_searches + where search_id = :search_id + } + if { [exists_and_not_null owner_id] } { + set valid_owner_ids [list] + lappend valid_owner_ids [ad_conn user_id] + if { [permission::permission_p -object_id [ad_conn package_id] -privilege "admin"] } { + lappend valid_owner_ids [ad_conn package_id] + } + if { [lsearch $valid_owner_ids $owner_id] < 0 } { + if { [contact::exists_p -party_id $owner_id] } { + ad_complain "[_ contacts.lt_You_do_not_have_permission_to_edit_other_peo]" + } else { + ad_complain "[_ contacts.lt_You_do_not_have_permission_to_edit_this_search]" + } + } + } + } +} + + + +if { [exists_and_not_null aggregate] } { + ad_returnredirect "[export_vars -base ./ -url {search_id aggregate_attribute_id}]" +} + +set page_title "[_ contacts.Advanced_Search]" +set context [list $page_title] + +if { [exists_and_not_null clear] } { + ad_returnredirect "search" +} + +if { [exists_and_not_null delete] } { + ad_returnredirect [export_vars -base search-action -url {search_id {action delete}}] +} + +if { [exists_and_not_null search] } { + ad_returnredirect ".?search_id=$search_id" +} + + +set search_exists_p 0 +# set query_pretty [list] +if { [exists_and_not_null search_id] } { + if { [contact::search::exists_p -search_id $search_id] } { + db_1row get_em { } + set search_exists_p 1 + } +} + + +if { $search_exists_p } { + # Figure out if the search was over a person, organization or both + set search_for [db_string get_search_for { } -default ""] + + set search_for_clause "" + + # Get the var list of the search if type equals group + # so we can retrieve the default attributes of the group + # also. + set var_list [db_string get_var_list { } -default ""] + + # We get the default attributes of persons, organizations or both and of the group + # if there is a condition for the gorup in the search (when var_list not null) + switch $search_for { + person { + + if { ![empty_string_p $var_list] } { + # Default attributes for the group and persons + set group_id [lindex [split $var_list " "] 1] + set search_for_clause "and (l.list_name like '%__-2' or l.list_name like '%__$group_id') " + } else { + # Default attributes for person only + set search_for_clause "and l.list_name like '%__-2' " + } + append search_for_clause "and object_type = 'person'" + + # We are going to take the default attributes from the parameter + set default_extend_attributes [parameter::get -parameter "DefaultPersonAttributeExtension"] + + } + organization { + + if { ![empty_string_p $var_list] } { + # Default attributes for the group and organizations + set group_id [lindex [split $var_list " "] 1] + set search_for_clause "and (l.list_name like '%__-2' or l.list_name like '%__$group_id') " + } else { + # Default attributes for organization + set search_for_clause "and l.list_name like '%__-2' " + } + append search_for_clause "and object_type = 'organization'" + + # We are going to take the default attributes from the parameter + set default_extend_attributes [parameter::get -parameter "DefaultOrganizationAttributeExtension"] + } + party { + if { ![empty_string_p $var_list] } { + # Default attributes for the group, persons and organizations + set group_id [lindex [split $var_list " "] 1] + set search_for_clause "and (l.list_name like '%__-2' or l.list_name like '%__$group_id') " + } + + # We are going to take the default attributes from the parameter + set default_extend_attributes [parameter::get -parameter "DefaultPersonOrganAttributeExtension"] + } + } + + set show_default_names "" + set show_names "" + # We add the default attributes, first we take out all spaces + # and then split by ";" + regsub -all " " $default_extend_attributes "" default_extend_attributes + set default_extend_attributes [split $default_extend_attributes ";"] + + # Now we are going to add the mapped attributes in the contact_search_extend_map + set ema_list [db_list get_extend_mapped_attributes { }] + + foreach extend_attribute_id $ema_list { + # We check that the attribute is nor already in the default list + # to avoid duplicates + ams::attribute::get -attribute_id $extend_attribute_id -array ea_info + set attribute_name $ea_info(attribute_name) + + if { [string equal [lsearch $default_extend_attributes $attribute_name] "-1"] } { + lappend default_extend_attributes $attribute_name + } + } + + foreach attr $default_extend_attributes { + # Now we get the attribute_id + set attr_id [attribute::id -object_type "person" -attribute_name "$attr"] + if { [empty_string_p $attr_id] } { + set attr_id [attribute::id -object_type "organization" -attribute_name "$attr"] + } + + # We need to check if the attribute is not already present + # in the list, otherwise we could have duplicated. + if { ![empty_string_p $attr_id] } { + lappend attribute_values $attr_id + lappend default_names "[_ acs-translations.ams_attribute_${attr_id}_pretty_name]" + } + + if { [string equal [lsearch -exact $attr_val_name "[list $attr_id $attr]"] "-1"] } { + lappend attr_val_name [list $attr_id $attr] + } + } + + # To extend the result list using default attributes + if { [exists_and_not_null default_names] } { + set show_default_names "[join $default_names ", "], " + } + + # To extend the reult list using the selected attributes + if { [exists_and_not_null attribute_names] } { + set show_names [join $attribute_names ", "] + } + + # Now we are going to create the select options + set attribute_values_query "" + if { [exists_and_not_null attribute_values] } { + set attribute_values_query "and lam.attribute_id not in ([template::util::tcl_to_sql_list $attribute_values])" + } + set attribute_options [db_list_of_lists get_ams_options " "] + set ams_options [list [list "- - - - - - - - - -" ""]] + foreach attribute $attribute_options { + set attribute_name [lang::util::localize [db_string get_ams_pretty_name { }]] + lappend ams_options [list $attribute_name $attribute] + } + + ad_form -name extend_attributes -has_submit 1 -form { + {attribute_option:text(select),optional + {label "[_ contacts.Extend_result_list_by]:"} + {options { $ams_options }} + {html { onChange "document.extend_attributes.submit();" }} + } + {search_id:text(hidden) + {value "$search_id"} + } + {attribute_values:text(hidden) + {value "$attribute_values"} + } + {attribute_names:text(hidden) + {value "$attribute_names"} + } + {attr_val_name:text(hidden) + {value "$attr_val_name"} + } + } -on_submit { + # We clear the list when no value is submited, otherwise + # we acumulate the extend values. + if { [empty_string_p $attribute_option] } { + set attribute_values [list] + set attribute_names [list] + set attr_val_name [list] + } else { + set attribute $attribute_option + ams::attribute::get -attribute_id $attribute -array attr_info + set name $attr_info(attribute_name) + lappend attribute_names "[_ acs-translations.ams_attribute_${attribute}_pretty_name]" + lappend attribute_values $attribute + lappend attr_val_name [list $attribute $name] + } + ad_returnredirect [export_vars -base "search" {search_id attribute_values attribute_names attr_val_name}] + } +} + + +set object_type_pretty_name(party) [_ contacts.People_or_Organizations] +set object_type_pretty_name(person) [_ contacts.People] +set object_type_pretty_name(organization) [_ contacts.Organizations] + +if { ![exists_and_not_null owner_id] } { + set owner_id [ad_conn user_id] +} + + +# FORM HEADER +set form_elements { + {search_id:key} + {owner_id:integer(hidden)} +} + +if { [exists_and_not_null object_type] } { + set object_type_pretty $object_type_pretty_name($object_type) + append form_elements { + {object_type:text(hidden) {value $object_type}} + {object_type_pretty:text(inform) {label {[_ contacts.Search_for]}} {value "$object_type_pretty"} {after_html "[_ contacts.which_match]"}} + {all_or_any:text(select),optional {label ""} {options {{[_ contacts.All] all} {[_ contacts.Any] any}}} {after_html "[_ contacts.lt_of_the_following_cond]"}} + } +} else { + set object_type_options [list] + foreach object_type_temp [list party person organization] { + lappend object_type_options [list $object_type_pretty_name($object_type_temp) $object_type_temp] + } + append form_elements { + {object_type:text(select) {label {\#contacts.Search_for\#}} {options $object_type_options} {html {onChange "javascript:acs_FormRefresh('advanced_search')"}}} + } +} + + +if { $search_exists_p } { + set conditions [list] + db_foreach selectqueries { + select condition_id, type as query_type, var_list as query_var_list from contact_search_conditions where search_id = :search_id + } { + set condition_name [contacts::search::condition_type -type $query_type -request pretty -var_list $query_var_list] + if { [empty_string_p $condition_name] } { + set condition_name "[_ contacts.Employees]" + } + lappend conditions "$condition_name " + } + if { [llength $conditions] > 0 } { + set query_pretty "

  • [join $conditions {
  • }]
" + } else { + set query_pretty "" + } + lappend form_elements [list query:text(hidden),optional] + lappend form_elements [list query_pretty:text(inform),optional [list label {}] [list value $query_pretty]] +} + +# The employee search only works without other attribute so +# we are going to remove the option "Employee" where is already +# a condition_name and we are going to remove the attributes +# where the condition_name equals employee +set employee_p 0 +if { [exists_and_not_null object_type] } { + # QUERY TYPE + set type_options [contacts::search::condition_types] + + # We are going to add one extra element to show all employees + # and its organization + if { [string equal $object_type "party"] && ![exists_and_not_null condition_name] } { + lappend type_options [list "[_ contacts.Employees]" employees] + } + + if { [exists_and_not_null condition_name] && [string equal $condition_name [_ contacts.Employees]] } { + set employee_p 1 + } + if { !$employee_p } { + # Show the attribute options of the search + append form_elements { + {type:text(select),optional {label {}} {options $type_options} {html {onChange "javascript:acs_FormRefresh('advanced_search')"}}} + } + } +} + + +#get condition types widgets +set form_elements [concat \ + $form_elements \ + [contacts::search::condition_type -type $type -request ad_form_widgets -form_name advanced_search -object_type $object_type] \ + ] +if { !$employee_p } { + # Show the Ok button + lappend form_elements [list next:text(submit) [list label [_ acs-kernel.common_OK]] [list value "ok"]] +} + + +if { $search_exists_p } { + + set results_count [contact::search::results_count -search_id $search_id] + + append form_elements { + {title:text(text),optional {label "

[_ contacts.save_this_search_]"} {html {size 40 maxlength 255}}} + {save:text(submit) {label "[_ contacts.Save]"} {value "save"}} + {search:text(submit) {label "[_ contacts.Search]"} {value "search"}} + {clear:text(submit) {label "[_ contacts.Clear]"} {value "clear"}} + {delete:text(submit) {label "[_ contacts.Delete]"} {value "delete"} \ + {after_html "
[_ contacts.Aggregate_by]:
"} + } + } + + append form_elements [contacts::search::condition_type::attribute \ + -request ad_form_widgets \ + -prefix "aggregate_" \ + -without_arrow_p "t" \ + -only_multiple_p "t"] + + append form_elements { + {aggregate:text(submit) {label "[_ contacts.Aggregate]"} {value "aggregate"}} + {results_count_widget:text(inform) {label "  [_ contacts.Results]"} {value {$results_count}}} + } +} + +ad_form -name "advanced_search" -method "GET" -form $form_elements \ + -on_request { + } -edit_request { + } -on_refresh { + } -on_submit { + if { [contact::search::exists_p -search_id $search_id] } { + contact::search::update -search_id $search_id -title $title -owner_id $owner_id -all_or_any $all_or_any + } + + if { ![string equal $type "employees"] } { + set form_var_list [contacts::search::condition_type \ + -type $type \ + -request form_var_list \ + -form_name advanced_search] + } else { + set form_var_list "employees" + } + + if { $form_var_list != "" } { + if { [string is false [contact::search::exists_p -search_id $search_id]] } { + set search_id [contact::search::new -search_id $search_id -title $title -owner_id $owner_id -all_or_any $all_or_any -object_type $object_type] + } + + contact::search::condition::new -search_id $search_id -type $type -var_list $form_var_list + + } + } -after_submit { + if { $form_var_list != "" || [exists_and_not_null save] } { + set export_list [list search_id] + if { ![contact::search::exists_p -search_id $search_id] } { + lappend export_list object_type all_or_any + } else { + contact::search::flush -search_id $search_id + } + ad_returnredirect [export_vars -base "search" -url [list $export_list]] + ad_script_abort + } + } + + Index: openacs-4/packages/contacts/www/search.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/search.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/search.xql 30 Nov 2005 15:31:02 -0000 1.5.2.2 @@ -0,0 +1,165 @@ + + + + + + select gmm.member_id as party_id + from group_member_map gmm, + membership_rels mr + where gmm.rel_id = mr.rel_id + [template::list::filter_where_clauses -and -name "contacts"] + [template::list::orderby_clause -orderby -name "contacts"] + + + + + + + select admin_role.pretty_name as admin_role_pretty, + member_role.pretty_name as member_role_pretty + from acs_rel_roles admin_role, acs_rel_roles member_role + where admin_role.role = 'admin' + and member_role.role = 'member' + + + + + + + + select groups.group_name, + groups.group_id, + ( select count(distinct member_id) from group_approved_member_map where group_approved_member_map.group_id = groups.group_id ) as member_count + from groups left join ( select group_id, default_p + from contact_groups + where package_id = :package_id ) contact_groups on (groups.group_id = contact_groups.group_id) + where groups.group_id != '-1' + order by CASE WHEN groups.group_id = '[contacts::default_group]' THEN '000000000' ELSE upper(groups.group_name) END + + + + + + + + select arr.pretty_plural, + art.rel_type as relation_type, + ( select count(distinct gmm.member_id) from group_approved_member_map gmm where gmm.group_id = :group_id and gmm.rel_type = art.rel_type ) as member_count + from acs_rel_types art, + acs_rel_roles arr + where art.rel_type in ( select distinct gmm.rel_type from group_approved_member_map gmm where gmm.group_id = :group_id ) + and art.role_two = arr.role + + + + + + + select gmm.member_id as party_id, + gmm.group_id, + gmm.rel_id, + gmm.rel_type, + contact__name(gmm.member_id,:name_order) as name, + mr.member_state, + party__email(gmm.member_id) as email, + ( select first_names from persons where person_id = gmm.member_id ) as first_names, + ( select last_name from persons where person_id = gmm.member_id ) as last_name, + ( select name from organizations where organization_id = gmm.member_id ) as organization + from group_member_map gmm, + membership_rels mr + where gmm.rel_id = mr.rel_id + [template::list::filter_where_clauses -and -name "contacts"] + [template::list::page_where_clause -and -name "contacts" -key "gmm.member_id"] + + + + + + + select mr.member_state as state, + count(mr.rel_id) as num_contacts + from membership_rels mr, acs_rels r + where r.rel_id = mr.rel_id + and r.object_id_one = :group_id + and r.rel_type = 'membership_rel' + group by mr.member_state + + + + + + + select + object_type + from + contact_searches + where + search_id = :search_id + + + + + + select + var_list + from + contact_search_conditions + where + type = 'group' + and search_id = :search_id + + + + + + select + lam.attribute_id + from + ams_list_attribute_map lam, + ams_lists l + where + lam.list_id = l.list_id + $search_for_clause + $attribute_values_query + + + + + + select + a.pretty_name + from + ams_attributes a + where + a.attribute_id = :attribute + + + + + + select + attribute_id + from + contact_search_extend_map + where + search_id = :search_id + and attribute_id is not null + + + + + + select + title, + owner_id, + all_or_any, + object_type + from + contact_searches + where + search_id = :search_id + + + + + Index: openacs-4/packages/contacts/www/searches.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/searches.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/searches.adp 30 Nov 2005 15:31:02 -0000 1.2.2.2 @@ -0,0 +1,13 @@ + +
+ + + + + +
+ + + +
+ Index: openacs-4/packages/contacts/www/searches.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/searches.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/searches.tcl 30 Nov 2005 15:31:02 -0000 1.3.2.2 @@ -0,0 +1,114 @@ +ad_page_contract { + List and manage contacts. + + @author Matthew Geddert openacs@geddert.com + @creation-date 2004-07-28 + @cvs-id $Id: searches.tcl,v 1.3.2.2 2005/11/30 15:31:02 miguelm Exp $ +} { + orderby:optional + {owner_id:optional} + {format "noraml"} +} -validate { +} + +set user_id [ad_conn user_id] +set package_id [ad_conn package_id] +if { ![exists_and_not_null owner_id] } { + set owner_id $user_id +} +set owner_options [db_list_of_lists select_owner_options {}] +set owner_options [concat [list [list [_ contacts.Public_Searches] "${package_id}"]] $owner_options] + +template::list::create \ + -name "searches" \ + -multirow "searches" \ + -row_pretty_plural "[_ contacts.searches]" \ + -selected_format $format \ + -key search_id \ + -elements { + title { + label {[_ contacts.Title]} + display_template { + @searches.title@ + } + } + query { + label {#contacts.Query#} + display_col query;noquote + } + results { + label {#contacts.Results#} + display_col results + link_url_eval $search_url + } + action { + label "" + display_template { + #contacts.Search# + #contacts.Copy# + + #contacts.Delete# + + + #contacts.Make_Public# + + } + } + } -filters { + owner_id { + label "\#contacts.Owner\#" + values $owner_options + where_clause "" + default_value $user_id + } + } -orderby { + } -formats { + normal { + label "[_ contacts.Table]" + layout table + row { + } + } + csv { + label "CSV" + output csv + row { + title {} + results {} + } + } + } + + +set return_url [export_vars -base searches -url {owner_id}] +set search_ids [list] +set admin_p [permission::permission_p -object_id $package_id -privilege "admin"] + +db_multirow -extend {query search_url make_public_url delete_url copy_url results search_link} -unclobber searches select_searches {} { + set aggregated_attribute [db_string get_saved_p { } -default ""] + if { [exists_and_not_null aggregated_attribute] } { + set search_link ".?search_id=$search_id&aggregate_attribute_id=$aggregated_attribute" + } else { + set search_link "search?search_id=$search_id" + } + if { $owner_id != $package_id && $admin_p } { + set make_public_url [export_vars -base search-action -url {search_id {owner_id $package_id} {action move} return_url}] + } + if { $owner_id == $user_id || $admin_p } { + set delete_url [export_vars -base search-action -url {search_id {action delete}}] + } + set search_url [export_vars -base ./ -url {search_id}] + set copy_url [export_vars -base search-action -url {search_id {owner_id $user_id} {action copy} return_url}] + + lappend search_ids $search_id +} + +# Since contact::search::results_count can if not cached required two db queries +# when this is included in the multirow code block above it can hang due to a lack +# of db pools. So it has to be done here. +template::multirow foreach searches { + set results [contact::search::results_count -search_id $search_id] + set query [contact::search_pretty -search_id $search_id] +} + +list::write_output -name searches Index: openacs-4/packages/contacts/www/searches.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/searches.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/searches.xql 30 Nov 2005 15:31:02 -0000 1.3.2.2 @@ -0,0 +1,50 @@ + + + + + + select CASE WHEN owner_id = :user_id + THEN '\#contacts.My_Searches\#' + ELSE contact__name(owner_id) END, + owner_id + from ( select distinct owner_id + from contact_searches + where ( title is not null or owner_id = :user_id ) + and owner_id in ( select party_id from parties )) distinct_owners + order by CASE WHEN owner_id = :user_id THEN '0000000000000000000' ELSE upper(contact__name(owner_id)) END + + + + + +( select search_id, title, upper(title) as order_title, all_or_any, object_type + from contact_searches + where owner_id = :owner_id + and title is not null + and not deleted_p +) union ( + select search_id, 'Search \#' || to_char(search_id,'FM9999999999999999999') || ' on ' || to_char(creation_date,'Mon FMDD') as title, 'zzzzzzzzzzz' as order_title, all_or_any, contact_searches.object_type + from contact_searches, acs_objects + where owner_id = :owner_id + and search_id = object_id + and contact_searches.title is null + and not deleted_p + limit 10 +) + order by order_title + + + + + + select + aggregated_attribute + from + contact_searches + where + search_id = :search_id + and aggregated_attribute is not null + + + + Index: openacs-4/packages/contacts/www/select-groups.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/select-groups.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/select-groups.adp 30 Nov 2005 15:31:02 -0000 1.1.2.2 @@ -0,0 +1,10 @@ + + +@title@ +@context@ + + + + + + Index: openacs-4/packages/contacts/www/select-groups.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/select-groups.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/select-groups.tcl 30 Nov 2005 15:31:02 -0000 1.4.2.2 @@ -0,0 +1,49 @@ +ad_page_contract { + List and manage contacts. + + @author Matthew Geddert openacs@geddert.com + @creation-date 2004-07-28 + @cvs-id $Id: select-groups.tcl,v 1.4.2.2 2005/11/30 15:31:02 miguelm Exp $ +} { + {object_type} +} + + +set title "[_ contacts.Add_new_in_Group]" +set user_id [ad_conn user_id] +set context [list $title] +set package_id [ad_conn package_id] + +set form_elements { + object_type:text(hidden) +} +set default_group [contacts::default_group] +set group_options [contact::groups -privilege_required "create"] +if { [llength $group_options] == "0" } { + # only the default group is available to this user + set group_ids $default_group + ad_returnredirect [export_vars -base "add/${object_type}" -url {object_type group_ids}] +# ad_return_error "[_ contacts.lt_Insufficient_Permissi]" "[_ contacts.lt_You_do_not_have_permi]" +} + +append form_elements { + {group_ids:text(checkbox),multiple,optional {label "[_ contacts.Add_to_Groups]"} {options $group_options}} +} +set edit_buttons [list [list "[_ contacts.lt_Add_new_in_Selected_Groups]" create]] + +ad_form \ + -name group-parties-add \ + -cancel_label "[_ contacts.Cancel]" \ + -cancel_url "." \ + -edit_buttons $edit_buttons \ + -form $form_elements \ + -on_request { + } -on_submit { + } -after_submit { + # the contact needs to be added to the default group + lappend group_ids $default_group + ad_returnredirect [export_vars -base "add/${object_type}" -url {object_type group_ids}] + ad_script_abort + } + + Index: openacs-4/packages/contacts/www/settings.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/settings.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/settings.adp 30 Nov 2005 15:31:02 -0000 1.4.2.2 @@ -0,0 +1,7 @@ + + +

#contacts.My_Signatures#

+ + + + Index: openacs-4/packages/contacts/www/settings.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/settings.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/settings.tcl 30 Nov 2005 15:31:02 -0000 1.5.2.2 @@ -0,0 +1,61 @@ +ad_page_contract { + + @author Matthew Geddert openacs@geddert.com + @creation-date 2004-07-28 + @cvs-id $Id: settings.tcl,v 1.5.2.2 2005/11/30 15:31:02 miguelm Exp $ + + +} { +} + +set title "[_ contacts.Settings]" +set context [list $title] +set package_id [ad_conn package_id] +set party_id [ad_conn user_id] +set admin_p [ad_permission_p [ad_conn package_id] admin] + +template::list::create \ + -name "signatures" \ + -multirow "signatures" \ + -row_pretty_plural "[_ contacts.signatures]" \ + -actions [list [_ contacts.Add_Signature] "signature" [_ contacts.Add_Signature]] \ + -elements { + default_p { + label "" + display_template { + + Default Signature + + } + } + title { + label "" + display_col title + link_url_eval $signature_url + } + signature { + label "" + display_col signature;noquote + } + } -filters { + } -orderby { + } + + +db_multirow -extend { signature_url } signatures select_signatures { + select signature_id, + title, + signature, + default_p + from contact_signatures + where party_id = :party_id + order by default_p, upper(title), upper(signature) +} { + + set signature [ad_convert_to_html -- "$signature"] + set signature_url [export_vars -base signature -url {signature_id }] +} + + + +ad_return_template Index: openacs-4/packages/contacts/www/signature.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/signature.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/signature.adp 30 Nov 2005 15:31:02 -0000 1.1.2.2 @@ -0,0 +1,10 @@ + + +@page_title@ +@context@ + + + +signature.title + + Index: openacs-4/packages/contacts/www/signature.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/signature.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/signature.tcl 30 Nov 2005 15:31:02 -0000 1.3.2.2 @@ -0,0 +1,68 @@ +ad_page_contract { + List and manage contacts. + + @author Matthew Geddert openacs@geddert.com + @creation-date 2004-07-28 + @cvs-id $Id: signature.tcl,v 1.3.2.2 2005/11/30 15:31:02 miguelm Exp $ +} { + {signature_id:integer,optional} +} -validate { + valid_signature_id -requires {signature_id} { + set party_id [ad_conn user_id] + if { ![ad_form_new_p -key signature_id] } { + if { [string is false [db_0or1row sig_is_mine_p {select '1' from contact_signatures where signature_id = :signature_id and party_id = :party_id}]] } { + ad_complain "[_ contacts.lt_This_signature_specif]" + } + } + } +} + + +if { [ad_form_new_p -key signature_id] } { + set page_title "[_ contacts.Create_a_Signature]" + set edit_buttons [list [list "[_ contacts.Create]" save]] +} else { + set page_title "[_ contacts.Edit_a_Signature]" + set edit_buttons [list [list "[_ contacts.Save]" save] [list "[_ contacts.Delete]" delete]] +} + +set context [list $page_title] +set party_id [ad_conn user_id] +set form_elements { + signature_id:key + {title:text(text) {label "[_ contacts.Save_As]"} {html {size 35 maxlength 35}}} + {signature:text(textarea) {label "[_ contacts.Signature]"} {html {cols 45 rows 5}}} + {default_p:boolean(checkbox),optional {label ""} {options {{{[_ contacts.lt_this_is_my_default_si]} 1}}}} +} + + +ad_form -action signature \ + -name signature \ + -cancel_label "[_ contacts.Cancel]" \ + -cancel_url "settings" \ + -edit_buttons $edit_buttons \ + -form $form_elements \ + -on_request { + } -new_request { + } -edit_request { + db_1row get_sig_info { select * from contact_signatures where signature_id = :signature_id } + } -on_submit { + if { [ns_queryget "formbutton:delete"] != "" } { + db_dml delete_it { delete from contact_signatures where signature_id = :signature_id and party_id = :party_id } + ad_returnredirect "settings" + ad_script_abort + } + if { [string is false [exists_and_not_null default_p]] } { + set default_p 0 + } else { + # its true and we reset the default + db_dml update_defaults { update contact_signatures set default_p = 'f' where party_id = :party_id } + } + } -new_data { + db_dml insert_sig { insert into contact_signatures values ( :signature_id, :title, :signature, :default_p, :party_id ) } + } -edit_data { + db_dml update_sig { update contact_signatures set title = :title, signature = :signature, default_p = :default_p where signature_id = :signature_id } + } -after_submit { + ad_returnredirect "settings" + } + Index: openacs-4/packages/contacts/www/admin/attribute-add-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/admin/Attic/attribute-add-postgresql.xql,v diff -u -N --- openacs-4/packages/contacts/www/admin/attribute-add-postgresql.xql 13 Jan 2005 13:57:10 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,15 +0,0 @@ - - - - postgresql7.1 - - - - - - select description, widget_id from contact_widgets order by description - - - - - Index: openacs-4/packages/contacts/www/admin/attribute-add.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/admin/Attic/attribute-add.adp,v diff -u -N --- openacs-4/packages/contacts/www/admin/attribute-add.adp 13 Jan 2005 13:57:10 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,9 +0,0 @@ - -@title@ -@context@ - - - - - - Index: openacs-4/packages/contacts/www/admin/attribute-add.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/admin/Attic/attribute-add.tcl,v diff -u -N --- openacs-4/packages/contacts/www/admin/attribute-add.tcl 13 Jan 2005 13:57:10 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,66 +0,0 @@ -ad_page_contract { - - list all attributes avaiable, and let the user edit edit permissions, regroup, etc. - - @author Matthew Geddert openacs@geddert.com - @creation-date 2004-07-28 - @cvs-id $Id: attribute-add.tcl,v 1.2 2005/01/13 13:57:10 jeffd Exp $ - -} { - group_id:optional - groupby:optional - orderby:optional - {format "normal"} - {status "normal"} -} - - -set title "Add an Attribute" -set context [list [list "attributes" "Attributes"] $title] - - - - -list::create \ - -name entries \ - -multirow entries \ - -key course_id \ - -row_pretty_plural "Widgets" \ - -checkbox_name checkbox \ - -selected_format $format \ - -class "list" \ - -main_class "list" \ - -sub_class "narrow" \ - -pass_properties { - variable - } -actions { - } -bulk_actions { - } -elements { - widget_id { - display_col description - label "Select a Widget" - link_url_eval $attribute_add_url - } - } -filters { - } -groupby { - } -orderby { - } -formats { - normal { - label "Table" - layout table - row { - widget_id {} - } - } - } - - - -# This query will override the ad_page_contract value entry_id - -db_multirow -extend { attribute_add_url } -unclobber entries select_widgets {} { - set attribute_add_url "attribute-ae?widget_id=$widget_id" -} - -ad_return_template - Index: openacs-4/packages/contacts/www/admin/attribute-ae-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/admin/Attic/attribute-ae-postgresql.xql,v diff -u -N --- openacs-4/packages/contacts/www/admin/attribute-ae-postgresql.xql 13 Jan 2005 13:57:11 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,87 +0,0 @@ - - - - postgresql7.1 - - - - - - select 1 from contact_attributes where attribute_id = :attribute_id - - - - - - - select widget_id from contact_attributes where attribute_id = :attribute_id - - - - - - - select description as widget_description from contact_widgets where widget_id = :widget_id - - - - - - select CASE WHEN storage_column = 'option_map_id' THEN '1' ELSE '0' END as options_p - from contact_widgets - where widget_id = :widget_id - - - - - - select * from contact_attributes where attribute_id = :attribute_id - - - - - - select * from contact_attribute_names where attribute_id = :attribute_id and locale = :locale - - - - - - select option from contact_attribute_options where attribute_id = :attribute_id - - - - - - select contact__attribute_create ( - :attribute_id, - :attribute, - :widget_id, - 'f', - now(), - :user_id, - :peeraddr, - :context_id - ) - - - - - - select contact__attribute_name_save ( - :attribute_id, - :language, - :name, - :help_text - ) - - - - - - select contact__attribute_option_create (:attribute_id,:option,:sort_order) - - - - - Index: openacs-4/packages/contacts/www/admin/attribute-ae.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/admin/Attic/attribute-ae.adp,v diff -u -N --- openacs-4/packages/contacts/www/admin/attribute-ae.adp 13 Jan 2005 13:57:11 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,6 +0,0 @@ - -@title@ -@context@ - - - Index: openacs-4/packages/contacts/www/admin/attribute-ae.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/admin/Attic/attribute-ae.tcl,v diff -u -N --- openacs-4/packages/contacts/www/admin/attribute-ae.tcl 13 Jan 2005 13:57:11 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,101 +0,0 @@ -ad_page_contract { - - Create an Attribute - - @author Matthew Geddert openacs@geddert.com - @creation-date 2004-07-28 - @cvs-id $Id: attribute-ae.tcl,v 1.2 2005/01/13 13:57:11 jeffd Exp $ - -} { - attribute_id:integer,optional - widget_id:integer,optional - {locale "en_US"} -} - - -set attr_exists_p 0 -if { [exists_and_not_null attribute_id] } { - set attr_exists_p [db_0or1row attr_exists_p {} ] - if { ![exists_and_not_null widget_id] } { - db_1row get_widget_id {} - } -} - -if { ![exists_and_not_null widget_id] } { - ad_returnredirect "attribute-add" - ad_abort_script -} - -db_1row get_widget_description {} - -db_1row get_options_p {} - -set languages [lang::system::get_locale_options] - -set package_id [ad_conn package_id] -set user_id [ad_conn user_id] - -ad_form -name attribute_form -action attribute-ae -form { - {attribute_id:key} - {widget_id:integer(hidden)} - {widget_description:text(inform) {label "Widget"}} - {language:text(select) {label "Language"} {value $locale} {options $languages}} - {name:text {label "Name"} {html {size 50 maxlength 100}}} - {help_text:text(textarea),optional {label "Help Text"} {html {rows 3 cols 50}} {help_text {Text entered here will assist people in filling out forms by adding extra information, useful facts, etc. Just like this scentence assists in describing what the \"Help Text\" field is}}} -} - -if { [string is true $options_p] && [string is false $attr_exists_p] } { - ad_form -extend -name attribute_form -form { - {options:text(textarea),nospell {label "Options"} {help_text "One option per line"} {html {cols 35 rows 6 wrap virtual}}} - } -} - - -ad_form -extend -name attribute_form -new_request { - set title "Add an Attribute" -} -edit_request { - db_1row select_attribute_info {} - db_1row select_attribute_name {} - if { [string is true $options_p] } { - set options "" - db_foreach get_attribute_options {} { - append options "$option\r" - } - - } - set title "Edit: $attribute" -} -validate { - # i need to add validation that the attribute isn't already in the database -} -on_submit { -} -new_data { - set user_id [ad_conn user_id] - set peeraddr [ad_conn peeraddr] - set context_id [ad_conn package_id] - set attribute [util_text_to_url -text $name] - set attribute_id [db_string attribute_create {}] - db_1row attribute_name_save {} - if { [string is true $options_p] } { - set sort_order "1" - set options [string trim $options] - foreach option [split $options "\n"] { - set option [string trim $option] - if { ![empty_string_p $option] } { - db_1row attribute_option_create {} - incr sort_order - } - } - } - ad_returnredirect -message "Added attribute '$name'" attributes - ad_script_abort -} -edit_data { - db_1row attribute_name_save {} - ad_returnredirect -message "Updated attribute '$name'" attributes -} -after_submit { - ad_returnredirect "attributes" - ad_script_abort -} - -set context [list [list "attributes" "Attributes"] $title] - -ad_return_template - Index: openacs-4/packages/contacts/www/admin/attribute-depreciate-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/admin/Attic/attribute-depreciate-postgresql.xql,v diff -u -N --- openacs-4/packages/contacts/www/admin/attribute-depreciate-postgresql.xql 13 Jan 2005 13:57:11 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,16 +0,0 @@ - - - - postgresql7.1 - - - - - - update contact_attributes set depreciated_p = 't' where attribute_id = :attribute_id - - - - - - Index: openacs-4/packages/contacts/www/admin/attribute-depreciate.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/admin/Attic/attribute-depreciate.tcl,v diff -u -N --- openacs-4/packages/contacts/www/admin/attribute-depreciate.tcl 13 Jan 2005 13:57:11 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,17 +0,0 @@ -ad_page_contract { - - @author Matthew Geddert openacs@geddert.com - @creation-date 2004-07-28 - @cvs-id $Id: attribute-depreciate.tcl,v 1.2 2005/01/13 13:57:11 jeffd Exp $ - -} { - {attribute_id:integer,multiple} -} - - -foreach attribute_id $attribute_id { - db_dml depreciate_attribute {} -} - -ad_returnredirect "attributes" -ad_script_abort Index: openacs-4/packages/contacts/www/admin/attribute-list.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/admin/attribute-list.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/admin/attribute-list.adp 30 Nov 2005 15:31:03 -0000 1.2.2.2 @@ -0,0 +1,18 @@ + +
+ + + + + + +
#contacts.Default_attributes#: @default_names@
+
+
+ + + +
+
#contacts.Search_List#
+
+  Index: openacs-4/packages/contacts/www/admin/attribute-list.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/admin/attribute-list.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/admin/attribute-list.tcl 30 Nov 2005 15:31:03 -0000 1.2.2.2 @@ -0,0 +1,132 @@ +# packages/contacts/www/admin/attribute-list.tcl +ad_page_contract { + + Display a list of the available attributes to map to an specific + search_id and also the default attributes set in the paramaters + for each specific search_type. + + @author Miguel Marin (miguelmarin@viaro.net) + @author Viaro Networks www.viaro.net + @creation-date 2005-11-11 +} { + orderby:optional + search_id:notnull + page:optional +} + +set search_for [db_string get_search_for { } -default ""] +set search_for_clause "" + +# Get the var list of the search if type equals group +# so we can retrieve the default attributes of the group +# also. +set var_list [db_string get_var_list { } -default ""] + +# We get the default attributes of persons, organizations or both and of the group +# if there is a condition for the gorup in the search (when var_list not null) +switch $search_for { + person { + if { ![empty_string_p $var_list] } { + # Default attributes for the group and persons + set group_id [lindex [split $var_list " "] 1] + set search_for_clause "and (l.list_name like '%__-2' or l.list_name like '%__$group_id') " + } else { + # Default attributes for person only + set search_for_clause "and l.list_name like '%__-2' " + } + append search_for_clause "and l.object_type = 'person'" + set default_extend_attributes [parameter::get -parameter "DefaultPersonAttributeExtension"] + + } + organization { + if { ![empty_string_p $var_list] } { + # Default attributes for the group and organizations + set group_id [lindex [split $var_list " "] 1] + set search_for_clause "and (l.list_name like '%__-2' or l.list_name like '%__$group_id') " + } else { + # Default attributes for organization + set search_for_clause "and l.list_name like '%__-2' " + } + append search_for_clause "and l.object_type = 'organization'" + set default_extend_attributes [parameter::get -parameter "DefaultOrganizationAttributeExtension"] + + } + party { + if { ![empty_string_p $var_list] } { + # Default attributes for the group, persons and organizations + set group_id [lindex [split $var_list " "] 1] + set search_for_clause "and (l.list_name like '%__-2' or l.list_name like '%__$group_id') " + } + set default_extend_attributes [parameter::get -parameter "DefaultPersonOrganAttributeExtension"] + } +} + + +set default_names [list] +set attribute_values [list] + +# We add the default attributes, first we take out all spaces +# and then split by ";" +regsub -all " " $default_extend_attributes "" default_extend_attributes +set default_extend_attributes [split $default_extend_attributes ";"] + +foreach attr $default_extend_attributes { + # Now we get the attribute_id + set attr_id [attribute::id -object_type "person" -attribute_name "$attr"] + if { [empty_string_p $attr_id] } { + set attr_id [attribute::id -object_type "organization" -attribute_name "$attr"] + } + + # We need to check if the attribute is not already present + # in the list, otherwise we could have duplicated. + if { ![empty_string_p $attr_id] } { + lappend attribute_values $attr_id + lappend default_names "[_ acs-translations.ams_attribute_${attr_id}_pretty_name]" + } +} + +set default_names [join $default_names ", "] +set extend_query "" +if { ![string equal [llength $attribute_values] 0] } { + set extend_query "and a.attribute_id not in ([join $attribute_values ","])" +} + +set bulk_actions [list "[_ contacts.Set_default]" set-default "[_ contacts.Set_default]" \ + "[_ contacts.Remove_default]" remove-default "[_ contacts.Remove_default]"] + +template::list::create \ + -name ams_options \ + -multirow ams_options \ + -key attribute_id \ + -page_size 15 \ + -page_flush_p 0 \ + -page_query_name get_ams_options_pagination \ + -bulk_action_method post \ + -bulk_actions $bulk_actions \ + -bulk_action_export_vars { search_id } \ + -elements { + pretty_name { + label "[_ contacts.Attribute_Name]:" + } + default { + label "" + } + } -filters { + search_id {} + } -orderby { + default_value pretty_name + pretty_name { + label "[_ contacts.Attribute_Name]:" + orderby_asc "a.attribute_name asc" + orderby_desc "a.attribute_name desc" + } + } + +db_multirow -extend { default } ams_options get_ams_options " " { + set default "" + set default_p [db_string get_default_p { } -default "0"] + if { $default_p } { + set default "[_ contacts.Default]" + } +} + Index: openacs-4/packages/contacts/www/admin/attribute-list.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/admin/attribute-list.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/admin/attribute-list.xql 30 Nov 2005 15:31:03 -0000 1.3.2.2 @@ -0,0 +1,82 @@ + + + + + + select + object_type + from + contact_searches + where + search_id = :search_id + + + + + + select + var_list + from + contact_search_conditions + where + type = 'group' + and search_id = :search_id + + + + + + + select + distinct + lam.attribute_id, + a.pretty_name, + a.attribute_name + from + ams_list_attribute_map lam, + ams_lists l, + ams_attributes a + where + lam.list_id = l.list_id + and lam.attribute_id = a.attribute_id + [template::list::page_where_clause -and -name "ams_options" -key "lam.attribute_id"] + $extend_query + $search_for_clause + [template::list::orderby_clause -name "ams_options" -orderby] + + + + + + select + distinct + lam.attribute_id, + a.pretty_name, + a.attribute_name + from + ams_list_attribute_map lam, + ams_lists l, + ams_attributes a + where + lam.list_id = l.list_id + and lam.attribute_id = a.attribute_id + $extend_query + $search_for_clause + [template::list::orderby_clause -name "ams_options" -orderby] + + + + + + select + 1 + from + contact_search_extend_map + where + search_id = :search_id + and attribute_id = :attribute_id + + + + + \ No newline at end of file Index: openacs-4/packages/contacts/www/admin/attribute-restore-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/admin/Attic/attribute-restore-postgresql.xql,v diff -u -N --- openacs-4/packages/contacts/www/admin/attribute-restore-postgresql.xql 13 Jan 2005 13:57:11 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,15 +0,0 @@ - - - - postgresql7.1 - - - - - - update contact_attributes set depreciated_p = 'f' where attribute_id = :attribute_id - - - - - Index: openacs-4/packages/contacts/www/admin/attribute-restore.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/admin/Attic/attribute-restore.tcl,v diff -u -N --- openacs-4/packages/contacts/www/admin/attribute-restore.tcl 13 Jan 2005 13:57:11 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,17 +0,0 @@ -ad_page_contract { - - @author Matthew Geddert openacs@geddert.com - @creation-date 2004-07-28 - @cvs-id $Id: attribute-restore.tcl,v 1.2 2005/01/13 13:57:11 jeffd Exp $ - -} { - {attribute_id:integer,multiple} -} - - -foreach attribute_id $attribute_id { - db_dml restore_attribute {} -} - -ad_returnredirect "attributes" -ad_script_abort Index: openacs-4/packages/contacts/www/admin/attributes-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/admin/Attic/attributes-postgresql.xql,v diff -u -N --- openacs-4/packages/contacts/www/admin/attributes-postgresql.xql 13 Jan 2005 13:57:11 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,26 +0,0 @@ - - - - postgresql7.1 - - - - - - select ca.widget_id, - ca.attribute_id, - ca.attribute, - can.name, - can.help_text, - ca.depreciated_p, - cw.description as widget_description - from contact_attributes ca left join contact_attribute_names can on (can.attribute_id = ca.attribute_id), - contact_widgets cw - where cw.widget_id = ca.widget_id - and can.locale = :locale - [list::filter_where_clauses -and -name "entries"] - [template::list::orderby_clause -orderby -name "entries"] - - - - Index: openacs-4/packages/contacts/www/admin/attributes.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/admin/Attic/attributes.adp,v diff -u -N --- openacs-4/packages/contacts/www/admin/attributes.adp 13 Jan 2005 13:57:11 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,9 +0,0 @@ - -@title@ -@context@ - - - - - - Index: openacs-4/packages/contacts/www/admin/attributes.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/admin/Attic/attributes.tcl,v diff -u -N --- openacs-4/packages/contacts/www/admin/attributes.tcl 13 Jan 2005 13:57:12 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,121 +0,0 @@ -ad_page_contract { - - list all attributes avaiable, and let the user edit edit permissions, regroup, etc. - - @author Matthew Geddert openacs@geddert.com - @creation-date 2004-07-28 - @cvs-id $Id: attributes.tcl,v 1.2 2005/01/13 13:57:12 jeffd Exp $ - -} { - groupby:optional - orderby:optional - {format "normal"} - {status "normal"} - {locale "en_US"} -} - -set title "\#contacts.Attributes\#" -set context [list $title] - -list::create \ - -name entries \ - -multirow entries \ - -key attribute_id \ - -row_pretty_plural $title \ - -checkbox_name checkbox \ - -selected_format $format \ - -class "list" \ - -main_class "list" \ - -sub_class "narrow" \ - -pass_properties { - variable - } -actions { - "Add" "attribute-ae" "Add an Attribute" - "Widgets" "widgets" "Widgets" - } -bulk_actions { - "Depreciate" "attribute-depreciate" "Depreciated checked attribute" - "Restore" "attribute-restore" "Restore checked attribute" - } -elements { - edit { - label {} - display_template { - Edit - } - } - attribute { - label "\#contacts.Attribute\#" - display_col attribute - } - name { - label "\#contacts.Name\#" - display_template { - @entries.name@ - (Depreciated - Restore) - } - } - widget { - display_col widget_description - label "\#contacts.Widget\#" - } - help_text { - display_col help_text - label "\#contacts.Help_Text\#" - } - permissions { - display_template { - Permissions - } - label "Permissions" - } - } -filters { - } -groupby { - } -orderby { - default_value name,asc - name { - label "\#contacts.Name\#" - orderby_desc "upper(can.name) desc" - orderby_asc "upper(can.name) asc" - default_direction asc - } - attribute { - label "\#contacts.Attribute\#" - orderby_desc "upper(ca.attribute) desc" - orderby_asc "upper(ca.attribute) asc" - default_direction asc - } - widget { - label "\#contacts.Widget\#" - orderby_desc "upper(cw.description) desc" - orderby_asc "upper(cw.description) asc" - default_direction asc - } - help_text { - label "\#contacts.Help_Text\#" - orderby_desc "upper(help_text) desc" - orderby_asc "upper(help_text) asc" - default_direction asc - } - } -formats { - normal { - label "Table" - layout table - row { - checkbox {} - edit {} - name {} - attribute {} - widget {} - help_text {} - permissions {} - } - } - } - - - - -db_multirow -unclobber entries get_attributes {} - - - -ad_return_template Index: openacs-4/packages/contacts/www/admin/ext-search-options.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/admin/ext-search-options.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/admin/ext-search-options.adp 30 Nov 2005 15:31:03 -0000 1.5.2.2 @@ -0,0 +1,34 @@ + +@page_title;noquote@ +@context;noquote@ + + + +
+

Create New Extended Search Option:

+ +
+ +
+ + +

#contacts.Stored_extended#:

+ +
+ + +

#contacts.Stored_extended_default#:

+ +
+
+ +

#contacts.Remove_default_options#:

+ +
+ #contacts.Go_to_search_results# + #contacts.Search_List# +
+
+ Index: openacs-4/packages/contacts/www/admin/ext-search-options.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/admin/ext-search-options.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/admin/ext-search-options.tcl 30 Nov 2005 15:31:03 -0000 1.5.2.2 @@ -0,0 +1,228 @@ +#packages/contacts/www/admin/ext-search-options.tcl +ad_page_contract { + UI to add edit or delete options for extended search. + @author Miguel Marin (miguelmarin@viaro.net) + @author Viaro Network www.viaro.net + @creation-date 2005-09-08 +} { + extend_id:optional + {edit_p "f"} + {delete_p "f"} + {orderby "var_name,asc"} + {search_id:multiple ""} + {aggregated_p "f"} +} + +set page_title [_ contacts.Extended_search_opt] +set context [list [_ contacts.Extended_search_opt]] + +if { $delete_p } { + contact::extend::delete -extend_id $extend_id + ad_returnredirect -message "[_ contacts.ext_del_message]" "ext-search-options" +} + +ad_form -name "add_option" -form { + extend_id:key(contact_extend_search_seq) +} +if { $edit_p } { + ad_form -extend -name "add_option" -form { + {var_name:text(text) + {label "[_ contacts.Var_name]:"} + {help_text "[_ contacts.var_name_help]"} + {mode display } + } + } +} else { + ad_form -extend -name "add_option" -form { + {var_name:text(text) + {label "[_ contacts.Var_name]:"} + {help_text "[_ contacts.var_name_help]"} + } + } +} + +ad_form -extend -name "add_option" -form { + {pretty_name:text(text) + {label "[_ contacts.Pretty_name]:"} + {help_text "[_ contacts.pretty_name_help]"} + } + {subquery:text(textarea),nospell + {label "[_ contacts.Subquery]:"} + {html {cols 40 rows 4}} + {help_text "[_ contacts.subquery_help]"} + } + {aggregated_p:text(radio) + {label "Aggregated:"} + {options { {[_ contacts.True] t} {[_ contacts.False] f}}} + {value $aggregated_p} + {help_text "[_ contacts.aggregated_help]"} + } + {description:text(textarea),optional,nospell + {label "[_ contacts.Description]"} + {html {cols 40 rows 2}} + {help_text "[_ contacts.description_help]"} + } +} + +if { !$edit_p } { + ad_form -extend -name "add_option" -validate { + {var_name + {![contact::extend::var_name_check -var_name $var_name]} + "[_ contacts.this_var_name]" + } + } +} + +ad_form -extend -name "add_option" -new_data { + contact::extend::new \ + -extend_id $extend_id \ + -var_name $var_name \ + -pretty_name $pretty_name \ + -subquery $subquery \ + -description $description \ + -aggregated_p $aggregated_p + +} -select_query { + select * from contact_extend_options where extend_id = :extend_id +} -edit_data { + contact::extend::update \ + -extend_id $extend_id \ + -var_name $var_name \ + -pretty_name $pretty_name \ + -subquery $subquery \ + -description $description \ + -aggregated_p $aggregated_p +} -after_submit { + ad_returnredirect "ext-search-options" +} + +set edit_url "ext-search-options?extend_id=@ext_options.extend_id@&edit_p=t" +set delete_url "ext-search-options?extend_id=@ext_options.extend_id@&delete_p=t" + +set row_list [list] +set bulk_actions [list] +set extra_query "" +if { ![exists_and_not_null search_id] } { + lappend row_list \ + action_buttons [list] +} else { + set extra_query "where extend_id not in (select extend_id from contact_search_extend_map where search_id in ([template::util::tcl_to_sql_list $search_id])) and aggregated_p ='f'" + lappend bulk_actions "[_ contacts.Set_default]" set-default "[_ contacts.Stored_extended_default]" + lappend row_list \ + checkbox [list] +} + +lappend row_list \ + var_name [list] \ + pretty_name [list] \ + subquery [list] \ + aggregated_p [list] \ + description [list] + +template::list::create \ + -name ext_options \ + -key extend_id \ + -actions "" \ + -html {width 100%} \ + -multirow ext_options \ + -bulk_actions $bulk_actions \ + -bulk_action_method post \ + -bulk_action_export_vars { search_id } \ + -selected_format "normal" \ + -elements { + action_buttons { + display_template { + + + } + html { width 5% } + } + var_name { + label "[_ contacts.Var_name]" + html { width 10% } + } + pretty_name { + label "[_ contacts.Pretty_name]" + html { width 10% } + } + subquery { + label "[_ contacts.Subquery]" + html { width 35% } + } + aggregated_p { + label "[_ contacts.Aggregated]" + } + description { + label "[_ contacts.Description]" + html { width 25% } + } + } -filters { + search_id {} + } -orderby { + var_name { + label "[_ contacts.Var_name]" + orderby_asc "var_name asc" + orderby_desc "var_name desc" + } + pretty_name { + label "[_ contacts.Pretty_name]" + orderby_asc "pretty_name asc" + orderby_desc "pretty_name desc" + } + } -formats { + normal { + label "[_ contacts.Table]" + layout table + row { + $row_list + } + } + } + +db_multirow ext_options ext_options " " + + +########################### Remove Default List #################################### + +set def_extra_query "" +if { [exists_and_not_null search_id] } { + set def_extra_query "where extend_id in (select extend_id from contact_search_extend_map where search_id in ([template::util::tcl_to_sql_list $search_id]))" +} +set def_bulk_actions [list "[_ contacts.Remove_default]" remove-default "[_ contacts.Remove_default_options]"] + +template::list::create \ + -name def_ext_options \ + -key extend_id \ + -actions "" \ + -html {width 100%} \ + -multirow def_ext_options \ + -bulk_actions $def_bulk_actions \ + -bulk_action_method post \ + -bulk_action_export_vars { search_id } \ + -selected_format "normal" \ + -elements { + var_name { + label "[_ contacts.Var_name]" + html { width 10% } + } + pretty_name { + label "[_ contacts.Pretty_name]" + html { width 10% } + } + subquery { + label "[_ contacts.Subquery]" + html { width 35% } + } + aggregated_p { + label "[_ contacts.Aggregated]" + } + description { + label "[_ contacts.Description]" + html { width 25% } + } + } -filters { + search_id {} + } + +db_multirow def_ext_options def_ext_options " " + Index: openacs-4/packages/contacts/www/admin/ext-search-options.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/admin/ext-search-options.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/admin/ext-search-options.xql 30 Nov 2005 15:31:03 -0000 1.2.2.2 @@ -0,0 +1,25 @@ + + + + + + select + * + from + contact_extend_options + $extra_query + [template::list::orderby_clause -orderby -name "ext_options"] + + + + + + select + * + from + contact_extend_options + $def_extra_query + + + + \ No newline at end of file Index: openacs-4/packages/contacts/www/admin/group-ae.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/admin/group-ae.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/admin/group-ae.adp 30 Nov 2005 15:31:03 -0000 1.2.2.2 @@ -0,0 +1,7 @@ + + +@title@ +@context@ + + + Index: openacs-4/packages/contacts/www/admin/group-ae.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/admin/group-ae.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/admin/group-ae.tcl 30 Nov 2005 15:31:03 -0000 1.2.2.2 @@ -0,0 +1,113 @@ +ad_page_contract { + + + @author Matthew Geddert openacs@geddert.com + @creation-date 2004-07-28 + @cvs-id $Id: group-ae.tcl,v 1.2.2.2 2005/11/30 15:31:03 miguelm Exp $ + +} { + {group_id:integer,optional} + {object_type ""} + {return_url "./"} +} +set user_id [auth::require_login] + +set form_elements { + group_id:key + title:text(hidden),optional + context:text(hidden),optional + return_url:text(hidden),optional +} + +if { [ad_form_new_p -key group_id] } { + set parents "{{[_ contacts.lt_--_top_level_group_--]} {}} [contact::groups -expand "none" -output "ad_form" -privilege_required "admin"]" + append form_elements { + {parent:integer(select),optional {label "[_ contacts.Parent_Group]"} {options $parents}} + } +} else { + set parent_id [contact::group::parent -group_id $group_id] + if { [exists_and_not_null parent_id] } { + set parent [acs_object_name $parent_id] + append form_elements { + {parent:text(inform),optional {label "[_ contacts.Parent_Group]"}} + } + } +} + +#append form_elements { +# permitted_rels,text(checkbox) +#} + +append form_elements { + {group_name:text(text) {label "[_ contacts.Group_Name]"}} + join_policy:text(hidden) + url:text(hidden),optional + email:text(hidden),optional +} +ad_form -name group_ae -action group-ae -form $form_elements \ +-new_request { + set title "[_ contacts.Add_a_Group]" + set context [list $title] + set join_policy "open" +} -edit_request { + + db_1row select_group_info { + select group_name, join_policy, + url, email + from groups, + parties + where groups.group_id = parties.party_id + and groups.group_id = :group_id + } + + set title "[_ contacts.Edit_group_name]" + set context [list [list groups "[_ contacts.Groups]"] $title] + +} -validate { +} -new_data { + + db_transaction { + contact::group::new \ + -group_id $group_id \ + -email $email \ + -url $url \ + -group_name $group_name \ + -join_policy $join_policy \ + -context_id "" + + if { [exists_and_not_null parent] } { + relation_add -member_state "approved" "composition_rel" $parent $group_id + } + } + set message "[_ contacts.lt_Group_group_name_Crea]" + +} -edit_data { + + db_dml update_group { + update groups + set group_name = :group_name, + join_policy = :join_policy + where group_id = :group_id + } + + db_dml update_group_extras { + update parties + set email = :email, + url = :url + where party_id = :group_id + } + + set message "[_ contacts.lt_Group_group_name_Upda]" + +} -after_submit { + + ad_returnredirect -message ${message} ${return_url} + ad_script_abort + +} + + + + + +ad_return_template Index: openacs-4/packages/contacts/www/admin/group-map.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/admin/group-map.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/admin/group-map.adp 30 Nov 2005 15:31:03 -0000 1.2.2.2 @@ -0,0 +1,7 @@ + + +@title@ +@context@ + + + Index: openacs-4/packages/contacts/www/admin/group-map.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/admin/group-map.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/admin/group-map.tcl 30 Nov 2005 15:31:03 -0000 1.2.2.2 @@ -0,0 +1,87 @@ +ad_page_contract { + + + @author Matthew Geddert openacs@geddert.com + @creation-date 2004-07-28 + @cvs-id $Id: group-map.tcl,v 1.2.2.2 2005/11/30 15:31:03 miguelm Exp $ + +} { + {group_id:integer,notnull} + {action:notnull} + {return_url "./"} +} -validate { + action_valid -requires {action} { + if { [lsearch [list map unmap makedefault] $action] < 0 } { + ad_complain "[_ contacts.lt_the_action_supplied_i]" + } + } + action_appropriate -requires {action} { + set package_id [ad_conn package_id] + set default_p [db_string group_mapped { select default_p from contact_groups where group_id = :group_id and package_id = :package_id } -default {}] + set parent_id [contact::group::parent -group_id $group_id] + + if { [exists_and_not_null default_p] } { + # the group is mapped + if { $default_p && $action == "makedefault" } { + ad_complain "[_ contacts.lt_This_group_is_already]" + } + if { [exists_and_not_null parent_id] && $action == "makedefault" } { + ad_complain "[_ contacts.lt_You_cannot_make_sub_g]" + } + if { $default_p && $action == "unmap" } { + ad_complain "[_ contacts.lt_You_cannot_unmap_the_]" + } + if { $action == "map" } { + ad_complain "[_ contacts.lt_This_group_is_already_1]" + } + } else { + if { $action != "map" } { + ad_complain "[_ contacts.lt_This_action_cannot_be]" + } + if { [exists_and_not_null parent_id] } { + if { ![db_0or1row parent_mapped { select 1 from contact_groups where group_id = :parent_id and package_id = :package_id }] } { + ad_complain "[_ contacts.lt_You_cannot_map_groups]" + } + } + } + } +} + + + +set package_id [ad_conn package_id] + +switch $action { + map { + # if the group is the only one for this package it needs to be made the default + set count [db_string get_count { select count(*) from contact_groups where package_id = :package_id } -default "0"] + if { $count == 0 } { + set default_p "1" + } else { + set default_p "0" + } + db_dml insert_map { + insert into contact_groups + (group_id,default_p,package_id) + values + (:group_id,:default_p,:package_id) + } + } + unmap { + db_dml delete_map { + delete from contact_groups where group_id = :group_id and package_id = :package_id + + } + } + makedefault { + db_dml remove_other_defaults { + update contact_groups set default_p = 'f' where package_id = :package_id + } + db_dml make_default { + update contact_groups set default_p = 't' where package_id = :package_id and group_id = :group_id + } + } +} + + +ad_returnredirect $return_url Index: openacs-4/packages/contacts/www/admin/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/admin/index.adp,v diff -u -N -r1.2 -r1.2.2.1 --- openacs-4/packages/contacts/www/admin/index.adp 13 Jan 2005 13:57:12 -0000 1.2 +++ openacs-4/packages/contacts/www/admin/index.adp 30 Nov 2005 15:31:03 -0000 1.2.2.1 @@ -1,15 +1,26 @@ - - + @title@ @context@ +

+#contacts.Relationships# +#contacts.Add_Group# +#contacts.lt_Instance_Permissions_# +#acs-subsite.Parameters# +#contacts.Extended_search_opt# +

+

#contacts.READ_THESE#

+
    +
  • #contacts.lt_Make_sure_you_do_not_#
  • +
  • #contacts.lt_The_default_group_mus#
  • +
+

#contacts.lt_Once_ready_for_releas#

+ - Index: openacs-4/packages/contacts/www/admin/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/admin/index.tcl,v diff -u -N -r1.2 -r1.2.2.1 --- openacs-4/packages/contacts/www/admin/index.tcl 13 Jan 2005 13:57:13 -0000 1.2 +++ openacs-4/packages/contacts/www/admin/index.tcl 30 Nov 2005 15:31:03 -0000 1.2.2.1 @@ -6,19 +6,132 @@ } { - {orderby "name"} } -set title "Contact Administration" + +set orderby "name" +set title "[_ contacts.lt_Contact_Administratio]" set context {} set package_id [ad_conn package_id] +set parameter_url [export_vars -base "/shared/parameters" {package_id {return_url "[ad_conn url]"}}] +template::list::create \ + -name "groups" \ + -multirow "groups" \ + -row_pretty_plural "[_ contacts.groups]" \ + -elements { + edit { + label {} + display_template { + [_ acs-kernel.common_Edit] + } + } + group_name { + label {Group} + display_col group_name + } + member_count { + label {[_ contacts.Contacts]} + display_col member_count + link_url_eval $group_url + } + mapped { + label {Mapped} + display_template { + + [_ contacts.True] + + + [_ contacts.False] + + } + } + default { + label {Default} + display_template { + + [_ contacts.True] + + + + [_ contacts.False] + + + + + } + } + person_form { + display_template { + [_ contacts.Person_Form] + } + } + org_form { + display_template { + [_ contacts.Organization_Form] + } + } + categories { + display_template { + [_ contacts.Manage_group_categories] + } + } + actions { + display_template { + [_ contacts.Permissions] + } + } + } -filters { + } -orderby { + } +multirow create groups group_id group_name group_url ams_person_url ams_org_url member_count level mapped_p default_p categories_url +set return_url [ad_conn url] +foreach group [contact::groups -indent_with "..." -expand "all" -output "all" -privilege_required "admin" -all] { + set group_id [lindex $group 1] + set group_name [lindex $group 0] + set member_count [lindex $group 2] + set level [lindex $group 3] + set mapped_p [lindex $group 4] + set default_p [lindex $group 5] + set ams_person_url [ams::list::url \ + -package_key "contacts" \ + -object_type "person" \ + -list_name "${package_id}__${group_id}" \ + -pretty_name "${package_id}__${group_id}" \ + -return_url $return_url \ + -return_url_label "[_ contacts.Return_to_title]"] + set ams_org_url [ams::list::url \ + -package_key "contacts" \ + -object_type "organization" \ + -list_name "${package_id}__${group_id}" \ + -pretty_name "${package_id}__${group_id}" \ + -return_url $return_url \ + -return_url_label "[_ contacts.Return_to_title]"] + set categories_url [export_vars -base "/categories/cadmin/object-map" -url {{object_id $group_id}}] + multirow append groups [lindex $group 1] [lindex $group 0] "../?group_id=${group_id}" $ams_person_url $ams_org_url $member_count $level $mapped_p $default_p $categories_url -set organization_object_id [contacts::util::organization_object_id] -set person_object_id [contacts::util::person_object_id] +} +set default_group [contacts::default_group] + set ams_person_url [ams::list::url \ + -package_key "contacts" \ + -object_type "person" \ + -list_name "${package_id}__${default_group}" \ + -pretty_name "${package_id}__${default_group}" \ + -return_url $return_url \ + -return_url_label "[_ contacts.Return_to_title]"] + set ams_org_url [ams::list::url \ + -package_key "contacts" \ + -object_type "organization" \ + -list_name "${package_id}__${default_group}" \ + -pretty_name "${package_id}__${default_group}" \ + -return_url $return_url \ + -return_url_label "[_ contacts.Return_to_title]"] + + + ad_return_template Index: openacs-4/packages/contacts/www/admin/permissions-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/admin/permissions-postgresql.xql,v diff -u -N -r1.2 -r1.2.2.1 --- openacs-4/packages/contacts/www/admin/permissions-postgresql.xql 13 Jan 2005 13:57:13 -0000 1.2 +++ openacs-4/packages/contacts/www/admin/permissions-postgresql.xql 30 Nov 2005 15:31:03 -0000 1.2.2.1 @@ -1,14 +1,14 @@ - - - - postgresql7.1 - - - - - - select acs_object__name(:object_id) as object_name - - - - + + + + postgresql7.1 + + + + + + select acs_object__name(:object_id) as object_name + + + + Index: openacs-4/packages/contacts/www/admin/permissions-user-add.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/admin/permissions-user-add.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/admin/permissions-user-add.adp 30 Nov 2005 15:31:03 -0000 1.1.2.2 @@ -0,0 +1,5 @@ + + @page_title@ + @context@ + + Index: openacs-4/packages/contacts/www/admin/permissions-user-add.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/admin/permissions-user-add.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/admin/permissions-user-add.tcl 30 Nov 2005 15:31:03 -0000 1.2.2.2 @@ -0,0 +1,14 @@ +ad_page_contract { + Redirect page for adding users to the permissions list. + + @author Lars Pind (lars@collaboraid.biz) + @creation-date 2003-06-13 + @cvs-id $Id: permissions-user-add.tcl,v 1.2.2.2 2005/11/30 15:31:03 miguelm Exp $ +} { + object_id:integer +} + +set page_title "[_ contacts.Add_User]" + +set context [list [list [export_vars -base permissions { object_id }] "[_ contacts.Permissions]"] $page_title] + Index: openacs-4/packages/contacts/www/admin/permissions.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/admin/permissions.adp,v diff -u -N -r1.2 -r1.2.2.1 --- openacs-4/packages/contacts/www/admin/permissions.adp 13 Jan 2005 13:57:14 -0000 1.2 +++ openacs-4/packages/contacts/www/admin/permissions.adp 30 Nov 2005 15:31:03 -0000 1.2.2.1 @@ -1,7 +1,5 @@ - @title@ + @page_title@ @context@ -

Note: Write permission is needed to create or edit a contact and/or any sepecific attribute associated with that contact type. By default all attributes inherit permissions from the package.

- - + Index: openacs-4/packages/contacts/www/admin/permissions.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/admin/permissions.tcl,v diff -u -N -r1.2 -r1.2.2.1 --- openacs-4/packages/contacts/www/admin/permissions.tcl 13 Jan 2005 13:57:14 -0000 1.2 +++ openacs-4/packages/contacts/www/admin/permissions.tcl 30 Nov 2005 15:31:03 -0000 1.2.2.1 @@ -1,14 +1,16 @@ ad_page_contract { - Permissions for contacts and contact-attributes - - @author Matthew Geddert openacs@geddert.com - @creation-date 2004-07-28 + Permissions for the subsite itself. + + @author Lars Pind (lars@collaboraid.biz) + @creation-date 2003-06-13 @cvs-id $Id$ - } { - object_id:integer + group_id:integer } -set object_name [db_string get_object_name {}] -set title "Permissions for $object_name" -set context [list $title] +set object_id $group_id + +set page_title "[_ contacts.Permissions]" + +set context [list $page_title] + Index: openacs-4/packages/contacts/www/admin/relationship-ae-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/admin/relationship-ae-postgresql.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/admin/relationship-ae-postgresql.xql 30 Nov 2005 15:31:03 -0000 1.1.2.2 @@ -0,0 +1,56 @@ + + + + postgresql7.1 + + + + + select repeat(' ', ((tree_level(t2.tree_sortkey) - tree_level(t1.tree_sortkey)) * 4)) || t2.pretty_name, + t2.object_type as rel_type + from acs_object_types t1, + acs_object_types t2 + where t2.tree_sortkey between t1.tree_sortkey and tree_right(t1.tree_sortkey) + and t1.object_type = :max_object_type_one + + + + + + + + + select repeat(' ', ((tree_level(t2.tree_sortkey) - tree_level(t1.tree_sortkey)) * 4)) || t2.pretty_name, + t2.object_type as rel_type + from acs_object_types t1, + acs_object_types t2 + where t2.tree_sortkey between t1.tree_sortkey and tree_right(t1.tree_sortkey) + and t1.object_type = :max_object_type_two + + + + + + + + + select case when exists (select 1 from acs_object_types t where t.pretty_name = :pretty_name) + then 1 else 0 end + + + + + + + + + + select case when exists (select 1 from acs_object_types t where t.pretty_plural = :pretty_plural) + then 1 else 0 end + + + + + + + Index: openacs-4/packages/contacts/www/admin/relationship-ae.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/admin/relationship-ae.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/admin/relationship-ae.adp 30 Nov 2005 15:31:03 -0000 1.1.2.2 @@ -0,0 +1,6 @@ + +@context;noquote@ +@title@ +rel_type.rel_type + + Index: openacs-4/packages/contacts/www/admin/relationship-ae.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/admin/relationship-ae.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/admin/relationship-ae.tcl 30 Nov 2005 15:31:03 -0000 1.4.2.2 @@ -0,0 +1,87 @@ +# /packages/mbryzek-subsite/www/admin/rel-type/new.tcl + +ad_page_contract { + + Form to create a new relationship type + + @author mbryzek@arsdigita.com + @creation-date Sun Nov 12 18:27:08 2000 + @cvs-id $Id: relationship-ae.tcl,v 1.4.2.2 2005/11/30 15:31:03 miguelm Exp $ + +} { + rel_type:optional + {return_url "relationships"} +} -properties { +} -validate { + type_exists -requires {rel_type} { + if { ![db_0or1row get_it { select 1 from contact_rel_types where rel_type = :rel_type}] } { + ad_complain "[_ contacts.lt_The_contact_specified]" + } + } +} +set title "[_ contacts.lt_Add_relationship_type]" +set context [list [list "[ad_conn package_url]admin/relationships" "[_ contacts.Relationship_types]"] $title] + +set object_types_list [list [list [_ contacts.lt_Person_or_Organizatio] party] \ + [list [_ contacts.Person] person] \ + [list [_ contacts.Organization] organization] + ] + +set locale [ad_conn locale] + +set roles_list [list [list "[_ contacts.--select_one--]" ""]] + +db_foreach select_roles { + select r.pretty_name, r.role + from acs_rel_roles r + order by lower(r.role)} { + set pretty_name [lang::util::localize $pretty_name] + lappend roles_list [list $pretty_name $role] + } + +ad_form -name "rel_type" \ + -form { + {return_url:text(hidden),optional} + {object_type_one:text(select) {label "[_ contacts.Contact_Type_One]"} {options $object_types_list}} + {role_one:text(select) {label "[_ contacts.Role_One]"} {options $roles_list}} + {object_type_two:text(select) {label "[_ contacts.Contact_Type_Two]"} {options $object_types_list}} + {role_two:text(select) {label "[_ contacts.Role_Two]"} {options $roles_list}} + } -on_request { +# if { [exists_and_not_null rel_type] } { +# db_1row get_them { select * from acs_rel_types where rel_type=:rel_type } +# } + } -on_submit { + + foreach role $roles_list { + if { [lindex $role 1] == $role_one } { set role_one_pretty [lindex $role 0] } + if { [lindex $role 1] == $role_two } { set role_two_pretty [lindex $role 0] } + } + set pretty_name "Contact Rel $role_one_pretty (${object_type_one}) -> $role_two_pretty (${object_type_two})" + set pretty_plural "Contact Rels $role_one_pretty (${object_type_one}) -> $role_two_pretty (${object_type_two})" + set rel_type [util_text_to_url -text "Contact Rels $role_one $role_two" \ + -replacement "_" \ + -existing_urls [db_list get_roles { select object_type from acs_object_types }]] + + + set next_object_id [db_string getid { select acs_object_id_seq.nextval }] + set table_name "contact_rel_${next_object_id}" + set package_name "contact_rel__${next_object_id}" + + rel_types::new -table_name "$table_name" -create_table_p "t" -supertype "contact_rel" -role_one $role_one -role_two $role_two \ + "$rel_type" \ + "$pretty_name" \ + "$pretty_plural" \ + "$object_type_one" \ + "0" \ + "" \ + "$object_type_two" \ + "0" \ + "" + + } -after_submit { + ad_returnredirect $return_url + ad_script_abort + +} + +ad_return_template Index: openacs-4/packages/contacts/www/admin/relationship-ae.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/admin/relationship-ae.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/admin/relationship-ae.xql 30 Nov 2005 15:31:03 -0000 1.1.2.2 @@ -0,0 +1,34 @@ + + + + + + + select r.object_type_one as max_object_type_one, + r.object_type_two as max_object_type_two, + t.pretty_name as supertype_pretty_name, + r.role_one as supertype_role_one, r.role_two as supertype_role_two, + r.min_n_rels_one as supertype_min_n_rels_one, + r.max_n_rels_one as supertype_max_n_rels_one, + r.min_n_rels_two as supertype_min_n_rels_two, + r.max_n_rels_two as supertype_max_n_rels_two + from acs_object_types t, acs_rel_types r + where r.rel_type = :supertype + and r.rel_type = t.object_type + + + + + + + + + select r.pretty_name, r.role + from acs_rel_roles r + order by lower(r.role) + + + + + + Index: openacs-4/packages/contacts/www/admin/relationships-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/admin/relationships-postgresql.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/admin/relationships-postgresql.xql 30 Nov 2005 15:31:03 -0000 1.1.2.2 @@ -0,0 +1,30 @@ + + + + postgresql7.1 + + + + select t.object_type as rel_type, t.pretty_name, t.indent, + coalesce(num.number_relationships,0) as number_relationships + from (select t2.pretty_name, t2.object_type, t2.tree_sortkey as inner_sortkey, + repeat(' ', (tree_level(t2.tree_sortkey) - tree_level(t1.tree_sortkey)) * 4) as indent + from acs_object_types t1, + acs_object_types t2 + where t2.tree_sortkey between t1.tree_sortkey and tree_right(t1.tree_sortkey) + and t1.object_type in ('contact_rel')) t left join + (select r.rel_type, count(*) as number_relationships + from acs_objects o, acs_rel_types r, + app_group_distinct_rel_map m + where r.rel_type = o.object_type + and o.object_id = m.rel_id + and m.package_id = :package_id + group by r.rel_type) num + on (t.object_type = num.rel_type) + order by t.inner_sortkey + + + + + + Index: openacs-4/packages/contacts/www/admin/relationships.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/admin/relationships.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/admin/relationships.adp 30 Nov 2005 15:31:03 -0000 1.3.2.2 @@ -0,0 +1,38 @@ + +@context;noquote@ +@title@ + + +

+#contacts.lt_Define_a_new_relation# +#contacts.View_all_roles# +

+

#contacts.lt_Currently_the_system_#

+ + + +
+ + +
#contacts.none#
+ +
+ + + +
@rel_types.primary_type_pretty@ -> @rel_types.secondary_type_pretty@
+
+ +
+
+ +
+ +
+ + + Index: openacs-4/packages/contacts/www/admin/relationships.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/admin/relationships.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/admin/relationships.tcl 30 Nov 2005 15:31:03 -0000 1.3.2.2 @@ -0,0 +1,57 @@ +# /packages/mbryzek-subsite/www/admin/rel-types/index.tcl + +ad_page_contract { + + Shows list of all defined relationship types, excluding the parent + type "relationship" + + @author mbryzek@arsdigita.com + @creation-date Sun Dec 10 17:10:56 2000 + @cvs-id $Id: relationships.tcl,v 1.3.2.2 2005/11/30 15:31:03 miguelm Exp $ + +} { +} -properties { + context:onevalue + rel_types:multirow +} + +set title "[_ contacts.Relationship_types]" +set context [list $title] + +set package_id [ad_conn package_id] +set url [ad_conn url] +# Select out all relationship types, excluding the parent type names 'relationship' +# Count up the number of relations that exists for each type. +db_multirow -extend { primary_type_pretty secondary_type_pretty rel_form_url } rel_types get_rels { + +select CASE WHEN primary_object_type = 'party' THEN '1' WHEN primary_object_type = 'person' THEN '2' ELSE '3' END as sort_one, + CASE WHEN secondary_object_type = 'party' THEN '2' WHEN secondary_object_type = 'person' THEN '3' ELSE '4' END as sort_two, + acs_rel_type__role_pretty_name(primary_role) as primary_role_pretty, + acs_rel_type__role_pretty_name(secondary_role) as secondary_role_pretty, + contact_rel_types.*, + acs_object_types.pretty_name + from contact_rel_types, acs_object_types + where contact_rel_types.rel_type = acs_object_types.object_type +order by sort_one, sort_two, primary_role_pretty + +} { + switch $primary_object_type { + party { set primary_type_pretty "[_ contacts.lt_Person_or_Organizatio]" } + organization { set primary_type_pretty "[_ contacts.Organization]" } + person { set primary_type_pretty "[_ contacts.Person]" } + } + switch $secondary_object_type { + party { set secondary_type_pretty "[_ contacts.lt_Person_or_Organizatio]" } + organization { set secondary_type_pretty "[_ contacts.Organization]" } + person { set secondary_type_pretty "[_ contacts.Person]" } + } + set rel_form_url [ams::list::url \ + -package_key "contacts" \ + -object_type ${rel_type} \ + -list_name ${package_id} \ + -pretty_name ${pretty_name} \ + -return_url ${url} \ + -return_url_label "[_ contacts.Return_to_title]"] + +} +ad_return_template Index: openacs-4/packages/contacts/www/admin/remove-default.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/admin/remove-default.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/admin/remove-default.tcl 30 Nov 2005 15:31:03 -0000 1.3.2.2 @@ -0,0 +1,31 @@ +#packages/contacts/www/admin/remove-default.tcl +ad_page_contract { + Remove the default extended options map to one search_id + @author Miguel Marin (miguelmarin@viaro.net) + @author Viaro Network www.viaro.net + @creation-date 2005-09-08 +} { + extend_id:multiple,optional + attribute_id:multiple,optional + search_id:integer,notnull +} + +if { [exists_and_not_null extend_id] } { + foreach value $extend_id { + db_dml unmap_extend_id { + delete from contact_search_extend_map where search_id = :search_id and extend_id = :value + } + } + ad_returnredirect ext-search-options?search_id=$search_id +} + +if { [exists_and_not_null attribute_id] } { + foreach value $attribute_id { + db_dml unmap_extend_id { + delete from contact_search_extend_map where search_id = :search_id and attribute_id = :value + } + } + ad_returnredirect attribute-list?search_id=$search_id +} + +ad_returnredirect search-list \ No newline at end of file Index: openacs-4/packages/contacts/www/admin/role-ae.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/admin/role-ae.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/admin/role-ae.adp 30 Nov 2005 15:31:03 -0000 1.2.2.2 @@ -0,0 +1,7 @@ + +@context;noquote@ +#contacts.Create_role# +role_form.role + + + Index: openacs-4/packages/contacts/www/admin/role-ae.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/admin/role-ae.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/admin/role-ae.tcl 30 Nov 2005 15:31:03 -0000 1.4.2.2 @@ -0,0 +1,45 @@ +# /packages/mbryzek-subsite/www/admin/rel-types/role-new.tcl + +ad_page_contract { + Form to create a new role + + @author mbryzek@arsdigita.com + @creation-date Mon Dec 11 10:52:35 2000 + @cvs-id $Id: role-ae.tcl,v 1.4.2.2 2005/11/30 15:31:03 miguelm Exp $ +} { + {role:trim "" } + {pretty_name "" } + {pretty_plural "" } + {return_url "roles" } +} -properties { + context:onevalue +} + +set context [list [list "relationships" "[_ contacts.Relationship_types]"] [list "roles" "[_ contacts.Roles]"] "[_ contacts.Create_role]"] + +ad_form -name "role_form" \ + -form { + {return_url:text(hidden),optional} + {role:text {label "[_ contacts.Role_Name]"}} + {pretty_name:text {label "[_ contacts.Role_Singular]"}} + {pretty_plural:text {label "[_ contacts.Role_Plural]"}} + } -on_request { + # if a return_url was provided it is set here + } -on_submit { + + if {[db_string role_exists_with_same_names_p { + select count(r.role) from acs_rel_roles r where r.role = :role}]} { + ad_return_complaint 1 "[_ contacts.lt_li_The_role_you_enter]" + return + } + if { [empty_string_p $role] } { + rel_types::create_role -pretty_name $pretty_name -pretty_plural $pretty_plural + } else { + rel_types::create_role -pretty_name $pretty_name -pretty_plural $pretty_plural -role $role + } + + } -after_submit { + ad_returnredirect $return_url + ad_script_abort + } + Index: openacs-4/packages/contacts/www/admin/roles.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/admin/roles.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/admin/roles.adp 30 Nov 2005 15:31:03 -0000 1.2.2.2 @@ -0,0 +1,17 @@ + +@context;noquote@ +#contacts.Roles# + + +

#contacts.Create_a_role#

+ + + Index: openacs-4/packages/contacts/www/admin/roles.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/admin/roles.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/admin/roles.tcl 30 Nov 2005 15:31:03 -0000 1.2.2.2 @@ -0,0 +1,37 @@ +# /packages/mbryzek-subsite/www/admin/rel-types/roles.tcl + +ad_page_contract { + + Shows all roles with links to add/delete + + @author mbryzek@arsdigita.com + @creation-date Mon Dec 11 11:08:34 2000 + @cvs-id $Id: roles.tcl,v 1.2.2.2 2005/11/30 15:31:03 miguelm Exp $ + +} { +} -properties { + context:onevalue + +} + +set context [list [list "relationships" "[_ contacts.Relationship_types]"] "[_ contacts.Roles]"] + +db_multirow roles select_roles { + select r.role, r.pretty_name, coalesce(num1.number_rels,0) + coalesce(num2.number_rels,0) as number_rel_types + from acs_rel_roles r left join + (select t.role_one as role, count(*) as number_rels + from acs_rel_types t + group by t.role_one) num1 on r.role=num1.role left join + (select t.role_two as role, count(*) as number_rels + from acs_rel_types t + group by t.role_two) num2 on r.role=num2.role + order by lower(r.role) +} { + # The role pretty names can be message catalog keys that need + # to be localized before they are displayed + set pretty_name [lang::util::localize $pretty_name] +} + +ad_return_template + + Index: openacs-4/packages/contacts/www/admin/search-list.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/admin/search-list.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/admin/search-list.adp 30 Nov 2005 15:31:03 -0000 1.2.2.2 @@ -0,0 +1,6 @@ + +@page_title;noquote@ + +
+ + Index: openacs-4/packages/contacts/www/admin/search-list.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/admin/search-list.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/admin/search-list.tcl 30 Nov 2005 15:31:03 -0000 1.5.2.2 @@ -0,0 +1,124 @@ +ad_page_contract { + List and manage contacts. + + @author Matthew Geddert openacs@geddert.com + @creation-date 2004-07-28 + @cvs-id $Id: search-list.tcl,v 1.5.2.2 2005/11/30 15:31:03 miguelm Exp $ +} { + orderby:optional + {owner_id:optional} + {format "normal"} + page:optional +} -validate { +} + +set page_title [_ contacts.Search_List] + + + +set user_id [ad_conn user_id] +set package_id [ad_conn package_id] +if { ![exists_and_not_null owner_id] } { + set owner_id $user_id +} + +template::list::create \ + -name "searches" \ + -key search_id \ + -page_size 10 \ + -page_flush_p 0 \ + -page_query_name select_searches_pagination \ + -multirow "searches" \ + -row_pretty_plural "[_ contacts.searches]" \ + -selected_format $format \ + -key search_id \ + -elements { + title { + label {[_ contacts.Title]} + display_template { + @searches.title@ + } + } + owner { + label {[_ contacts.Owner]} + display_template { + by @searches.owner@ + } + } + query { + label { [_ contacts.Query]} + display_col query;noquote + } + results { + label {[_ contacts.Results]} + display_col results + link_url_eval $search_url + } + action { + label "" + display_template { + Default Extend Options + Default Attributes + } + } + } -orderby { + default_value title + title { + label {[_ contacts.Title]} + orderby_desc "order_title desc" + orderby_asc "order_title asc" + } + owner { + label {[_ contacts.Owner]} + orderby_desc "owner_id desc, order_title asc" + orderby_asc "owner_id asc, order_title asc" + } + } -formats { + normal { + label "[_ contacts.Table]" + layout table + row { + } + } + csv { + label "CSV" + output csv + row { + title {} + results {} + } + } + } + + +set return_url [export_vars -base searches -url {owner_id}] +set search_ids [list] +set admin_p [permission::permission_p -object_id $package_id -privilege "admin"] + +db_multirow -extend {query search_url make_public_url delete_url copy_url results owner search_link} -unclobber searches select_searches {} { + + set aggregated_attribute [db_string get_saved_p { } -default ""] + if { [exists_and_not_null aggregated_attribute] } { + set search_link ".?search_id=$search_id&aggregate_attribute_id=$aggregated_attribute" + } else { + set search_link "search?search_id=$search_id" + } + + set search_url [export_vars -base ../ -url {search_id}] + set owner [contact::name -party_id $search_owner_id] + if { [empty_string_p $owner] } { + set owner "Public" + } + + lappend search_ids $search_id +} + +# Since contact::search::results_count can if not cached required two db queries +# when this is included in the multirow code block above it can hang due to a lack +# of db pools. So it has to be done here. +template::multirow foreach searches { + set results [contact::search::results_count -search_id $search_id] + set query [contact::search_pretty -search_id $search_id] +} + +list::write_output -name searches Index: openacs-4/packages/contacts/www/admin/search-list.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/admin/search-list.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/admin/search-list.xql 30 Nov 2005 15:31:03 -0000 1.4.2.2 @@ -0,0 +1,65 @@ + + + + + + select + cs.search_id, + CASE + WHEN cs.title is not null + THEN cs.title + ELSE 'Search \#'||to_char(search_id,'FM9999999999999999999')||' on '||to_char(creation_date,'Mon FMDD') + END as title, + CASE + WHEN cs.title is not null + THEN upper(cs.title) + ELSE + upper('Search \#'||to_char(search_id,'FM9999999999999999999')||' on '||to_char(creation_date,'Mon FMDD')) + END as order_title, + cs.all_or_any, + cs.object_type, + cs.owner_id as search_owner_id + from + contact_searches cs, + acs_objects o + where + not cs.deleted_p + and o.object_id = cs.search_id + [template::list::page_where_clause -and -name "searches" -key "cs.search_id"] + [template::list::orderby_clause -name "searches" -orderby] + + + + + + select + cs.search_id, + CASE + WHEN cs.title is not null + THEN upper(cs.title) + ELSE + upper('Search \#'||to_char(search_id,'FM9999999999999999999')||' on '||to_char(creation_date,'Mon FMDD')) + END as order_title + from + contact_searches cs, + acs_objects o + where + not cs.deleted_p + and o.object_id = cs.search_id + [template::list::orderby_clause -name "searches" -orderby] + + + + + + select + aggregated_attribute + from + contact_searches + where + search_id = :search_id + and aggreagated_attribute is not null + + + + Index: openacs-4/packages/contacts/www/admin/set-default.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/admin/set-default.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/admin/set-default.tcl 30 Nov 2005 15:31:03 -0000 1.3.2.2 @@ -0,0 +1,55 @@ +#packages/contacts/www/admin/remove-default.tcl +ad_page_contract { + Set the default extended options to one search_id + @author Miguel Marin (miguelmarin@viaro.net) + @author Viaro Network www.viaro.net + @creation-date 2005-09-08 +} { + extend_id:multiple,optional + attribute_id:multiple,optional + search_id:integer,notnull +} + + +if { [exists_and_not_null extend_id] } { + foreach value $extend_id { + set already_p [db_string get_already_p { + select + 1 + from + contact_search_extend_map + where + extend_id = :value + and search_id = :search_id + } -default 0] + if { !$already_p } { + db_dml map_extend_id { + insert into contact_search_extend_map (search_id,extend_id) + values (:search_id, :value) + } + } + } + ad_returnredirect ext-search-options?search_id=$search_id +} + +if { [exists_and_not_null attribute_id] } { + foreach value $attribute_id { + set already_p [db_string get_already_p { + select + 1 + from + contact_search_extend_map + where + attribute_id = :value + and search_id = :search_id + } -default 0] + if { !$already_p } { + db_dml map_extend_id { + insert into contact_search_extend_map (search_id,attribute_id) + values (:search_id, :value) + } + } + } + ad_returnredirect attribute-list?search_id=$search_id +} + Index: openacs-4/packages/contacts/www/admin/widgets-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/admin/widgets-postgresql.xql,v diff -u -N -r1.2 -r1.2.2.1 --- openacs-4/packages/contacts/www/admin/widgets-postgresql.xql 13 Jan 2005 13:57:14 -0000 1.2 +++ openacs-4/packages/contacts/www/admin/widgets-postgresql.xql 30 Nov 2005 15:31:03 -0000 1.2.2.1 @@ -1,15 +1,15 @@ - - - - postgresql7.1 - - - - - - select * from contact_widgets order by storage_column, description - - - - - + + + + postgresql7.1 + + + + + + select * from contact_widgets order by storage_column, description + + + + + Index: openacs-4/packages/contacts/www/cadmin/attributes-answer-optional-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/cadmin/Attic/attributes-answer-optional-postgresql.xql,v diff -u -N --- openacs-4/packages/contacts/www/cadmin/attributes-answer-optional-postgresql.xql 13 Jan 2005 13:57:15 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,14 +0,0 @@ - - - - postgresql7.1 - - - - - - update contact_attribute_object_map set required_p = 'f' where object_id = :object_id and attribute_id = :attribute_id - - - - Index: openacs-4/packages/contacts/www/cadmin/attributes-answer-optional.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/cadmin/Attic/attributes-answer-optional.tcl,v diff -u -N --- openacs-4/packages/contacts/www/cadmin/attributes-answer-optional.tcl 13 Jan 2005 13:57:15 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,19 +0,0 @@ -ad_page_contract { - - - @author Matthew Geddert openacs@geddert.com - @creation-date 2004-07-28 - @cvs-id $Id: attributes-answer-optional.tcl,v 1.2 2005/01/13 13:57:15 jeffd Exp $ - -} { - {attribute_id:integer,multiple} - {object_id:integer,notnull} -} - - -foreach attribute_id $attribute_id { - db_dml answer_optional {} -} - -ad_returnredirect "object-map?object_id=$object_id" -ad_script_abort Index: openacs-4/packages/contacts/www/cadmin/attributes-answer-required-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/cadmin/Attic/attributes-answer-required-postgresql.xql,v diff -u -N --- openacs-4/packages/contacts/www/cadmin/attributes-answer-required-postgresql.xql 13 Jan 2005 13:57:15 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,14 +0,0 @@ - - - - postgresql7.1 - - - - - - update contact_attribute_object_map set required_p = 't' where object_id = :object_id and attribute_id = :attribute_id - - - - Index: openacs-4/packages/contacts/www/cadmin/attributes-answer-required.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/cadmin/Attic/attributes-answer-required.tcl,v diff -u -N --- openacs-4/packages/contacts/www/cadmin/attributes-answer-required.tcl 13 Jan 2005 13:57:15 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,19 +0,0 @@ -ad_page_contract { - - - @author Matthew Geddert openacs@geddert.com - @creation-date 2004-07-28 - @cvs-id $Id: attributes-answer-required.tcl,v 1.2 2005/01/13 13:57:15 jeffd Exp $ - -} { - {attribute_id:integer,multiple} - {object_id:integer,notnull} -} - - -foreach attribute_id $attribute_id { - db_dml answer_required {} -} - -ad_returnredirect "object-map?object_id=$object_id" -ad_script_abort Index: openacs-4/packages/contacts/www/cadmin/attributes-map-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/cadmin/Attic/attributes-map-postgresql.xql,v diff -u -N --- openacs-4/packages/contacts/www/cadmin/attributes-map-postgresql.xql 13 Jan 2005 13:57:15 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,21 +0,0 @@ - - - - postgresql7.1 - - - - - select sort_order from contact_attribute_object_map order by sort_order desc limit 1 - - - - - - - select contact__attribute_object_map_save(:object_id,:attribute_id,:sort_order,'f',null) - - - - - Index: openacs-4/packages/contacts/www/cadmin/attributes-map.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/cadmin/Attic/attributes-map.tcl,v diff -u -N --- openacs-4/packages/contacts/www/cadmin/attributes-map.tcl 13 Jan 2005 13:57:15 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,25 +0,0 @@ -ad_page_contract { - - - @author Matthew Geddert openacs@geddert.com - @creation-date 2004-07-28 - @cvs-id $Id: attributes-map.tcl,v 1.2 2005/01/13 13:57:15 jeffd Exp $ - -} { - {attribute_id:integer,multiple} - {object_id:integer,notnull} -} - - -db_0or1row get_latest_sort_order {} - -if { ![exists_and_not_null sort_order] } { - set sort_order 0 -} -foreach attribute_id $attribute_id { - incr sort_order - db_1row map_attribute {} -} - -ad_returnredirect "object-map?object_id=$object_id" -ad_script_abort Index: openacs-4/packages/contacts/www/cadmin/attributes-order-update-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/cadmin/Attic/attributes-order-update-postgresql.xql,v diff -u -N --- openacs-4/packages/contacts/www/cadmin/attributes-order-update-postgresql.xql 13 Jan 2005 13:57:15 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,25 +0,0 @@ - - - - postgresql7.1 - - - - update contact_attribute_object_map set sort_order = '-1' where object_id = :object_id - - - - - - select attribute_id from contact_attribute_object_map where object_id = :object_id - - - - - - update contact_attribute_object_map set sort_order = :sort_order_temp where object_id = :object_id and attribute_id = :attribute_id - - - - - Index: openacs-4/packages/contacts/www/cadmin/attributes-order-update.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/cadmin/Attic/attributes-order-update.tcl,v diff -u -N --- openacs-4/packages/contacts/www/cadmin/attributes-order-update.tcl 13 Jan 2005 13:57:15 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,27 +0,0 @@ -ad_page_contract { - - Update sort order - - @author Matthew Geddert openacs@geddert.com - @creation-date 2004-07-28 - @cvs-id $Id: attributes-order-update.tcl,v 1.2 2005/01/13 13:57:15 jeffd Exp $ - - -} { - sort_key:array - object_id:integer,notnull -} - - -set count 0 - -# first we get rid of the old sort order -db_dml delete_previous_sort_orders {} -db_foreach get_attributes {} { - if {[info exists sort_key($attribute_id)]} { - set sort_order_temp $sort_key($attribute_id) - db_dml update_sort_order {} - } -} - -ad_returnredirect "object-map?object_id=$object_id" Index: openacs-4/packages/contacts/www/cadmin/attributes-unmap-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/cadmin/Attic/attributes-unmap-postgresql.xql,v diff -u -N --- openacs-4/packages/contacts/www/cadmin/attributes-unmap-postgresql.xql 13 Jan 2005 13:57:15 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,21 +0,0 @@ - - - - postgresql7.1 - - - - - select sort_order from contact_attribute_object_map order by sort_order desc limit 1 - - - - - - - delete from contact_attribute_object_map where object_id = :object_id and attribute_id = :attribute_id - - - - - Index: openacs-4/packages/contacts/www/cadmin/attributes-unmap.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/cadmin/Attic/attributes-unmap.tcl,v diff -u -N --- openacs-4/packages/contacts/www/cadmin/attributes-unmap.tcl 13 Jan 2005 13:57:15 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,21 +0,0 @@ -ad_page_contract { - - @author Matthew Geddert openacs@geddert.com - @creation-date 2004-07-28 - @cvs-id $Id: attributes-unmap.tcl,v 1.2 2005/01/13 13:57:15 jeffd Exp $ - - -} { - {attribute_id:integer,multiple} - {object_id:integer,notnull} -} - - -db_0or1row get_latest_sort_order {} - -foreach attribute_id $attribute_id { - db_dml unmap_attribute {} -} - -ad_returnredirect "object-map?object_id=$object_id" -ad_script_abort Index: openacs-4/packages/contacts/www/cadmin/object-map-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/cadmin/Attic/object-map-postgresql.xql,v diff -u -N --- openacs-4/packages/contacts/www/cadmin/object-map-postgresql.xql 13 Jan 2005 13:57:15 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,57 +0,0 @@ - - - - postgresql7.1 - - - - - - select acs_object__name(:object_id) as object_name - - - - - - - select ca.attribute_id, - ca.attribute, - can.name, - can.help_text, - caom.required_p, - caom.sort_order, - cw.description as widget_description - from contact_attribute_object_map caom, - contact_attributes ca left join contact_attribute_names can on (can.attribute_id = ca.attribute_id), - contact_widgets cw - where caom.attribute_id = ca.attribute_id - and cw.widget_id = ca.widget_id - and can.locale = :locale - and not ca.depreciated_p - and caom.object_id = :object_id - order by caom.sort_order asc - - - - - - - - select ca.attribute_id, - ca.attribute, - can.name, - can.help_text, - cw.description as widget_description - from contact_attributes ca left join contact_attribute_names can on (can.attribute_id = ca.attribute_id), - contact_widgets cw - where cw.widget_id = ca.widget_id - and can.locale = :locale - and not ca.depreciated_p - and ca.attribute_id not in ( select attribute_id from contact_attribute_object_map where object_id = :object_id) - order by upper(can.name) asc - - - - - - Index: openacs-4/packages/contacts/www/cadmin/object-map.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/cadmin/Attic/object-map.adp,v diff -u -N --- openacs-4/packages/contacts/www/cadmin/object-map.adp 13 Jan 2005 13:57:16 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,18 +0,0 @@ - -@title@ -@context@ - - -

Contact attributes mapped to "@object_name@"

- - - - -

Contact attributes available for mapping

- - - - Index: openacs-4/packages/contacts/www/cadmin/object-map.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/cadmin/Attic/object-map.tcl,v diff -u -N --- openacs-4/packages/contacts/www/cadmin/object-map.tcl 1 Mar 2005 00:01:27 -0000 1.3 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,190 +0,0 @@ -ad_page_contract { - - This page lets users map contact attributes to any - acs_object. It also lets one customize the way the - form elements are presented to that object. - - @author Matthew Geddert openacs@geddert.com - @creation-date 2004-07-28 - @cvs-id $Id: object-map.tcl,v 1.3 2005/03/01 00:01:27 jeffd Exp $ - -} { - object_id:integer,notnull - groupby:optional - orderby:optional - {format "normal"} - {status "normal"} - {locale "en_US"} -} - -set user_id [auth::require_login] -permission::require_permission -object_id $object_id -privilege admin - -set object_name [db_string get_object_name {}] - -set title "Attribute Management" -set context [list $title] - -set contacts_admin_p [permission::permission_p -object_id [ad_conn package_id] -privilege admin] - - - -list::create \ - -name mapped_attributes \ - -multirow mapped_attributes \ - -key attribute_id \ - -row_pretty_plural "Mapped Attributes" \ - -checkbox_name checkbox \ - -selected_format $format \ - -class "list" \ - -main_class "list" \ - -sub_class "narrow" \ - -pass_properties { - } -actions { - } -bulk_actions { - "Answer Required" "attributes-answer-required" "Require an answer from the checked attributes" - "Answer Optional" "attributes-answer-optional" "An answer from the checked attributes is optional" - "Unmap" "attributes-unmap" "Unmap check attributes" - "Update ordering" "attributes-order-update" "Update ordering from values in list" - } -bulk_action_export_vars { - object_id - } -elements { - attribute { - label "\#contacts.Attribute\#" - display_col attribute - } - name { - label "\#contacts.Name\#" - display_col name - } - widget { - display_col widget_description - label "\#contacts.Widget\#" - } - action { - label "\#contacts.Action\#" - display_template { - Unmap - } - } - answer { - label "\#contacts.Required\#" - display_template { - - - - - - - } - } - sort_order { - label "\#contacts.Ordering\#" - display_template { - - } - } - } -filters { - } -groupby { - } -orderby { - } -formats { - normal { - label "Table" - layout table - row { - checkbox {} - name {} - sort_order {} - answer {} - action {} - } - } - } - - - -# This query will override the ad_page_contract value entry_id -template::multirow create mapped_attributes attribute_id attribute name help_text required_p sort_order widget_description sort_order_key - -set sort_order_key 0 - -db_foreach get_mapped_courses {} { - incr sort_order_key 10 - template::multirow append mapped_attributes $attribute_id $attribute $name $help_text $required_p $sort_order $widget_description $sort_order_key - -} - - -#---------------------------------------------------------------------- -# List builder -#---------------------------------------------------------------------- - - - - - -list::create \ - -name unmapped_attributes \ - -multirow unmapped_attributes \ - -key attribute_id \ - -row_pretty_plural "Unmapped Attributes" \ - -checkbox_name checkbox \ - -selected_format $format \ - -class "list" \ - -main_class "list" \ - -sub_class "narrow" \ - -pass_properties { - } -actions { - } -bulk_actions { - "Map" "attributes-map" "Map the selected attributes" - } -bulk_action_export_vars { - object_id - } -elements { - attribute { - label "\#contacts.Attribute\#" - display_col attribute - } - name { - label "\#contacts.Name\#" - display_col name - } - widget { - display_col widget_description - label "\#contacts.Widget\#" - } - action { - label "\#contacts.Action\#" - display_template { - Map - } - } - } -filters { - } -groupby { - } -orderby { - } -formats { - normal { - label "Table" - layout table - row { - checkbox {} - name {} - action {} - } - } - } - - - -# This query will override the ad_page_contract value entry_id - -db_multirow -extend { sort_order_key } -unclobber unmapped_attributes get_unmapped_courses {} { -} - - - -ad_return_template - - - - - Index: openacs-4/packages/contacts/www/resources/contacts-print.css =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/resources/contacts-print.css,v diff -u -N -r1.4.2.1 -r1.4.2.2 Binary files differ Index: openacs-4/packages/contacts/www/resources/contacts.css =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/resources/contacts.css,v diff -u -N -r1.2 -r1.2.2.1 --- openacs-4/packages/contacts/www/resources/contacts.css 13 Jan 2005 13:57:16 -0000 1.2 +++ openacs-4/packages/contacts/www/resources/contacts.css 30 Nov 2005 15:31:04 -0000 1.2.2.1 @@ -1,3 +1,180 @@ +/* Comments Style Sheet + + @author Matthew Geddert openacs@geddert.com + @creation-date 2005-05-15 + @cvs-id $Id$ + +----------------------------------------------- */ + +/* For Portlets */ + +td.highlighted { + background-color:#ddddff; +} + +td.highlight { + background-color:#ffffdd; + border-bottom: 1px dotted #A0BDEB; +} + +td.subheader { + background-color:#ffffdd; + border-top: 1px dotted #e6e6fa; + border-bottom: 1px dotted #e6e6fa; + border-left: 1px solid #e6e6fa; +} + +td.list-bg { + border-left: 1px solid #e6e6fa; +} + +td.list-bottom-bg { + border-bottom: 1px solid #e6e6fa; + border-left: 1px solid #e6e6fa; +} + +td.list-right-bg { + border-bottom: 1px solid #e6e6fa; + border-right: 1px solid #e6e6fa; +} + +th.project { + background-color:#9999cc; +} + +td.project-filter-pane { + background-color: #bbbbee; + vertical-align: top; +} + +.shaded { + background-color: #dddddd; +} + +.selected { + background-color: #eeccdd; +} + +th { + font-size: 9pt; + text-align: left; + background-color:dfdfff; +} + + +/* From logger */ + +table.logger_navbar { + background-color: #41329c; + clear: both; +} +a.logger_navbar { + color: white; + text-decoration: none; +} +a.logger_navbar:visited { + color: white; +} +a.logger_navbar:hover { + color: white; + text-decoration: underline; +} +td.logger_navbar { + font-family: tahoma,verdana,arial,helvetica; + font-size: 70%; + font-weight: bold; + color: #ccccff; + text-decoration: none; +} + +td.fill-list-right { + border-bottom: 3px solid #A0BDEB; + border-right: 1px solid #A0BDEB; + background-color: #eaf2ff; +} + +td.fill-list-right2 { + border-right: 1px solid #A0BDEB; + background-color: #eaf2ff; +} + +td.fill-list-bottom { + border-bottom: 3px solid #A0BDEB; + border-left: 1px solid #A0BDEB; + background-color: #eaf2ff; +} + +td.fill-list-middle { + border-left: 1px solid #A0BDEB; + background-color: #eaf2ff; +} + +td.fill-list-bg { + background-color: #eaf2ff; +} + +#search-block { + border:1px solid #000; + background-color: #EAF2FF; + padding:5px; + width:70%; +} + +/* End of Portlets*/ + +div#contact-info { + clear: both; +} +#contact-info h3 { + clear: both; +} +#contact-info div.primary { + width: 48%; + float: left; +} +#contact-info div.secondary { + width: 48%; + float: right; +} +p.last-updated { + clear: both; + font-size: small; + text-align: right; +} +dl.comments { + font-size: 100%; + margin: 0px; + padding: 0px; + } +dl.comments dt { + margin: 5px 0px 0px 0px; + background: #EEE; + font-weight: normal; + font-size: 100%; + } +dl.comments dd { + padding: 5px; + margin: 0 0px 0px 0px; + background: #EEE; + } +dl.comments dt.odd, dl.comments dd.odd { + background: #DDD; + } +dl.comments dt.mine-odd, dl.comments dd.mine-odd { + background: #FFFFFF; + } +dl.comments dt.mine-even, dl.comments dd.mine-even { + background: #FFFFFF; + } +dl.comments .number { + padding: 0px 5px 0px 0px; + margin: 0px 2px 0px 0px; + border-style: solid; + border-width: 0px 1px 0px 0px; + border-color: #CCC; + font: 160% Georgia,Serif; + } + #contacts-sortbars { font:70% verdana,sans-serif; } @@ -8,3 +185,181 @@ #contacts-sortbars a:hover { text-decoration: underline; } + +div.letter { + margin-bottom: 10px; + padding-bottom: 10px; + border-bottom: 1px solid #AAA; +} +.address-widget { + width: 300px; +} +.address-widget-country-code { + width: 100%; +} + + +.hidden { + display: none; +} + +span.overdue { + color: red; +} + +#section { + margin: 0px 0px 0px 0px; +} + +#section ul { + border-left: 1px solid #333; + margin: 0px 0px 10px 0px; + padding: 0px; + text-transform: lowercase; + background: #CCC; +} + +#section ul li { + display:inline; + margin:0; + padding:0; + background-image:none; +} + +#section ul a { + float:left; + display:block; + padding: 0px 5px 2px 5px; + border-width:0; + border-style:none; + border-top: 4px solid #CCC; + border-right: 1px solid #000; + border-bottom: 1px solid #CCC; + text-decoration:none; + color:#000; +} +#section ul a:hover { + border-top: 4px solid #000; +} +#section ul strong { + border-top: 4px solid #000; + margin: 0px -5px 0px -5px; + padding: 0px 5px 2px 5px; + background-color: #FFF; + border-bottom: 1px solid #FFF; +} + +#section ul a:hover { + color: red; +} + + + +#section ul em { + float:none; + display:block; + padding: 4px 5px 2px 5px; + border-right-width:0; + border-bottom: 1px solid #CCC; + } + +h3.contact-title { + margin: 0; + padding: 0; + clear: both; + line-height: 2em; +} + +dt.attribute-name { + margin: 0; + padding: 0; + font: 90% Verdana,Georgia,Serif; + text-align: right; + line-height: 1.5em; + border-width: 0; + width: 33%; + float: left; + clear: both; +} + +dd.attribute-value { + margin: 0; + padding: 0 0 .5em 0; + text-align: left; + line-height: 1.2em; + border-width: 0; + width: 65%; + float: right; + font: 90% Verdana,Georgia,Serif; +} +dl.attribute-values { + margin: 0; + padding: 0; +} + + + + +/* Tasks */ +div.tasks * { + margin: 0; + padding: 0; +} +div.tasks h3 { + padding-bottom: 5px; +} +div.tasks ul { + padding-left: 1em; + list-style: square; +} +div.tasks li { + padding-bottom: .5em; +} +div.tasks dt { + clear: both; + float: left; + width: 25%; +} +div.tasks dd { + float: right; + width: 73%; + padding-bottom: .75em; +} + +#tasks dt { + display: block; + float: left; + margin: 0px; + width: 120px; + padding-top: 2px; +} +#tasks dl { + margin: 5px 0px 0px 0px; +} +#tasks ul { + margin: 0px 0px 0px -10px; + clear: both; +} +#tasks li { + margin: 0px; +} +.done { + color: #BBB; +} +.contact-editlink { + padding-left: 1em; + font: 100% Verdana,Georgia,Serif; +} +.contact-attributes { + clear:both; + display: block; + margin-left: 10px; + font: 90% Verdana,Georgia,Serif; +} +.contact-attributes a { + text-decoration: none; + color: #000; +} +.contact-attributes a:hover { + text-decoration: underline; +} Index: openacs-4/packages/contacts/www/view/comments-view-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/view/Attic/comments-view-postgresql.xql,v diff -u -N --- openacs-4/packages/contacts/www/view/comments-view-postgresql.xql 13 Jan 2005 13:57:16 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,29 +0,0 @@ - - - - postgresql7.1 - - - - - - select g.comment_id, - r.mime_type, - o.creation_user, - acs_object__name(o.creation_user) as author, - to_char(o.creation_date, 'MM-DD-YYYY') as pretty_date, - to_char(o.creation_date, 'YYYY-MM-DD HH24:MI') as pretty_timestamp, - r.content - from general_comments g, - cr_revisions r, - acs_objects o - where g.object_id = :party_id and - r.revision_id = content_item__get_live_revision(g.comment_id) and - o.object_id = g.comment_id - and o.context_id = :package_id - [template::list::orderby_clause -orderby -name comments] - - - - - Index: openacs-4/packages/contacts/www/view/comments-view.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/view/Attic/comments-view.adp,v diff -u -N --- openacs-4/packages/contacts/www/view/comments-view.adp 13 Jan 2005 13:57:16 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,4 +0,0 @@ - - - - Index: openacs-4/packages/contacts/www/view/comments-view.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/view/Attic/comments-view.tcl,v diff -u -N --- openacs-4/packages/contacts/www/view/comments-view.tcl 13 Jan 2005 13:57:16 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,122 +0,0 @@ -ad_page_contract { - - - @author Matthew Geddert openacs@geddert.com - @creation-date 2004-07-28 - @cvs-id $Id: comments-view.tcl,v 1.2 2005/01/13 13:57:16 jeffd Exp $ - -} { - {party_id:integer} - {return_url} - groupby:optional - orderby:optional - {format "normal"} - {status "normal"} -} - -set add_url "[apm_package_url_from_id [ad_conn package_id]]comment-add?[export_url_vars party_id return_url]" - - -list::create \ - -name comments \ - -multirow comments \ - -key comment_id \ - -row_pretty_plural "Comments" \ - -checkbox_name checkbox \ - -selected_format $format \ - -class "list" \ - -main_class "list" \ - -sub_class "narrow" \ - -pass_properties { - } -actions { - } -bulk_actions { - } -bulk_action_export_vars { - } -elements { - time { - label "Time" - display_col pretty_timestamp - } - author { - display_col author - label "Author" - link_url_eval $author_url - } - comment { - label "Comment" - display_col content_html;noquote - } - } -filters { - } -groupby { - } -orderby { - default_value time,desc - time { - label "Time" - orderby_desc "o.creation_date desc" - orderby_asc "o.creation_date asc" - default_direction desc - } - author { - label "Author" - orderby_desc "acs_object__name(o.creation_user) desc, o.creation_date desc" - orderby_asc "acs_object__name(o.creation_user) asc, o.creation_date desc" - default_direction asc - } - } -formats { - normal { - label "Table" - layout table - row { - time {} - author {} - comment {} - } - } - } - - - -# This query will override the ad_page_contract value entry_id -template::multirow create comments comment_id author author_url pretty_timestamp content content_html - -set package_id [ad_conn package_id] -db_foreach get_comments "" { - set author_url "[apm_package_url_from_id [ad_conn package_id]]view/$creation_user" - set content_html [ad_html_text_convert -from $mime_type -to "text/html" $content] - template::multirow append comments $comment_id $author $author_url $pretty_timestamp $content $content_html -} - - - -set login_button [list [list "Add this Comment" ok]] - -ad_form -name comment -action comments-view -edit_buttons $login_button -form { - new_comment_id:key - party_id:integer(hidden) - return_url:text(hidden) - {description:text(textarea),nospell {label "Comment"} {html { rows 6 cols 65 wrap soft}}} - } -new_request { - } -on_submit { - - # insert the comment into the database -# set description_body [template::util::richtext::get_property contents $description] -# set description_format [template::util::richtext::get_property format $description] - set description_body [string trim $description] - set description_format "text/plain" - - - general_comment_new -object_id $party_id \ - -comment_id $new_comment_id \ - -title [contact::name $party_id] \ - -user_id [ad_conn user_id] \ - -creation_ip [ad_conn peeraddr] \ - -context_id [ad_conn package_id] \ - -is_live t \ - -comment_mime_type $description_format \ - -content $description_body \ - -category "" - - ad_returnredirect -message "Comment added" $return_url - } - - -ad_return_template Index: openacs-4/packages/contacts/www/view/contact-view.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/view/Attic/contact-view.adp,v diff -u -N --- openacs-4/packages/contacts/www/view/contact-view.adp 13 Jan 2005 13:57:16 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,3 +0,0 @@ - - - Index: openacs-4/packages/contacts/www/view/contact-view.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/view/Attic/contact-view.tcl,v diff -u -N --- openacs-4/packages/contacts/www/view/contact-view.tcl 13 Jan 2005 13:57:16 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,71 +0,0 @@ -ad_page_contract { - - - @author Matthew Geddert openacs@geddert.com - @creation-date 2004-07-28 - @cvs-id $Id: contact-view.tcl,v 1.2 2005/01/13 13:57:16 jeffd Exp $ - -} { - {party_id:integer} - {return_url ""} - groupby:optional - orderby:optional - {format "normal"} - {status "normal"} -} - -set actions_list [list "Edit" "[apm_package_url_from_id [ad_conn package_id]]contact-ae?party_id=$party_id\&return_url=$return_url" "Edit [contact::name $party_id]"] - -list::create \ - -name attributes \ - -multirow attributes \ - -key comment_id \ - -row_pretty_plural "Attributes" \ - -checkbox_name checkbox \ - -selected_format $format \ - -class "list" \ - -main_class "list" \ - -sub_class "narrow" \ - -pass_properties { - } -actions $actions_list \ - -bulk_actions { - } -bulk_action_export_vars { - } -elements { - attribute { - label "Attribute" - display_col pretty_attribute_name - } - attribute_value { - label "Value" - display_col pretty_value_html;noquote - } - } -filters { - } -groupby { - } -orderby { - } -formats { - normal { - label "Table" - layout table - row { - attribute {} - attribute_value {} - } - } - } - -set user_id [ad_conn user_id] -set object_type [contact::get::object_type $party_id] -if { $object_type == "organization" } { - set object_id [contacts::util::organization_object_id] -} - -if { $object_type == "person" } { - set object_id [contacts::util::person_object_id] -} - -contacts::get::values::multirow -multirow_name "attributes" -party_id $party_id -object_id $object_id - - - - -ad_return_template Index: openacs-4/packages/contacts/www/view/index.vuh =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/view/Attic/index.vuh,v diff -u -N --- openacs-4/packages/contacts/www/view/index.vuh 13 Jan 2005 13:57:16 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,58 +0,0 @@ -ad_page_contract { - - - @author Matthew Geddert (geddert@yahoo.com) - @creation-date 2004-06-07 - @cvs-id $Id: index.vuh,v 1.2 2005/01/13 13:57:16 jeffd Exp $ -} { -} - -permission::require_permission -object_id [ad_conn package_id] -privilege "read" - -set path [split [ad_conn path_info] "-"] -set party_id [lindex $path 0] -set view_id [lindex $path 1] - -set error_p 0 - -if { ![exists_and_not_null party_id] } { - set error_p 1 -} else { - if { ![string is integer $party_id] } { - set error_p 1 - } else { - if { ![contact::exists_p $party_id] } { - set error_p 1 - } - } -} - -if { ![exists_and_not_null view_id] } { - if { [string is false $error_p] } { - # there is no view_id but the party_id was valid, so we get the default view_id - set object_type [contact::get::object_type $party_id] - set view_id [contacts::view::get::first_view_id $object_type] - if { ![exists_and_not_null view_id] } { - # there are no pages available for this contact object type - set error_p 1 - } - } -} else { - if { [string is integer $view_id] && [string is false $error_p] } { - if { ![contacts::view::exists_p -object_type [contact::get::object_type $party_id] $view_id] } { - set error_p 1 - } - } else { - # the view_id specified was invalid - set error_p 1 - } -} - - -if { [string is true $error_p] } { - ad_returnredirect -message "The URL you specified was invalid" [apm_package_url_from_id [ad_conn package_id]] -} else { - rp_form_put party_id $party_id - rp_form_put view_id $view_id - rp_internal_redirect "/packages/contacts/www/view/view" -} Index: openacs-4/packages/contacts/www/view/view-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/view/Attic/view-postgresql.xql,v diff -u -N --- openacs-4/packages/contacts/www/view/view-postgresql.xql 13 Jan 2005 13:57:16 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,20 +0,0 @@ - - - - postgresql7.1 - - - - - - - select view_id - from contact_views - where contact_object_type = :object_type - and acs_permission__permission_p(privilege_object_id,:user_id,privilege_required) - order by sort_order - - - - - Index: openacs-4/packages/contacts/www/view/view.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/view/Attic/view.adp,v diff -u -N --- openacs-4/packages/contacts/www/view/view.adp 13 Jan 2005 13:57:16 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,31 +0,0 @@ - -@title@ -@context@ - - - - Index: openacs-4/packages/contacts/www/view/view.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/view/Attic/view.tcl,v diff -u -N --- openacs-4/packages/contacts/www/view/view.tcl 13 Jan 2005 13:57:16 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,44 +0,0 @@ -ad_page_contract { - - - @author Matthew Geddert openacs@geddert.com - @creation-date 2004-07-28 - -} { - party_id:integer - view_id:integer -} - - -permission::require_permission -object_id [ad_conn package_id] -privilege "read" - -contacts::view::get $view_id - -if { [exists_and_not_null privilege_required] && [exists_and_not_null privilege_object_id] } { - permission::require_permission -object_id "$privilege_object_id" -privilege "$privilege_required" -} - -# NOTE, since this page is called on by the index.vuh file the party_id is already passed to the included page -rp_form_put return_url "[apm_package_url_from_id [ad_conn package_id]]view/$party_id\-$view_id" - -set title "[contact::name $party_id]" -set context [list $title] - -set object_type [contact::get::object_type $party_id] -set selected_view_id $view_id -set user_id [ad_conn user_id] - -db_multirow -extend { name url selected_p } views select_views {} { - if { $selected_view_id == $view_id } { - set selected_p 1 - } else { - set selected_p 0 - } - set name [contacts::view::get::name $view_id] - set url "$party_id\-$view_id" -} - - - - -ad_return_template