|
From: Verdon V. <ve...@us...> - 2008-03-31 19:43:15
|
Update of /cvsroot/phpwebsite-comm/modules/rolodex/class In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27211/class Modified Files: RDX_Forms.php RDX_Member.php RDX_Mypage.php Rolodex.php Log Message: tweaks and fixes to prepare for beta release Index: RDX_Forms.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/rolodex/class/RDX_Forms.php,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** RDX_Forms.php 8 Feb 2008 19:38:48 -0000 1.4 --- RDX_Forms.php 31 Mar 2008 19:42:45 -0000 1.5 *************** *** 93,96 **** --- 93,101 ---- break; + case 'info': + $this->rolodex->panel->setCurrentTab('info'); + $this->showInfo(); + break; + } *************** *** 237,240 **** --- 242,253 ---- $form->setLabel('req_approval', dgettext('rolodex', 'Require approval for new profiles')); + $form->addCheckbox('send_notification', 1); + $form->setMatch('send_notification', PHPWS_Settings::get('rolodex', 'send_notification')); + $form->setLabel('send_notification', dgettext('rolodex', 'Send notification of pending applications')); + + $form->addText('admin_contact', PHPWS_Settings::get('rolodex', 'admin_contact')); + $form->setSize('admin_contact', 30); + $form->setLabel('admin_contact', dgettext('rolodex', 'The admin contact email address for this module')); + $form->addCheckbox('comments_enable', 1); $form->setMatch('comments_enable', PHPWS_Settings::get('rolodex', 'comments_enable')); *************** *** 277,280 **** --- 290,297 ---- $form->setMatch('privacy_export', PHPWS_Settings::get('rolodex', 'privacy_export')); + $form->addRadio('privacy_use_search', array(0, 1)); + $form->setLabel('privacy_use_search', array(dgettext('rolodex', 'No'), dgettext('rolodex', 'Yes'))); + $form->setMatch('privacy_use_search', PHPWS_Settings::get('rolodex', 'privacy_use_search')); + $form->addCheckbox('enable_expiry', 1); $form->setMatch('enable_expiry', PHPWS_Settings::get('rolodex', 'enable_expiry')); *************** *** 358,361 **** --- 375,379 ---- $tpl['PRIVACY_BUSINESS_TITLE'] = dgettext('rolodex', 'Business address'); $tpl['PRIVACY_EXPORT_TITLE'] = dgettext('rolodex', 'CSV Export'); + $tpl['PRIVACY_USE_SEARCH_TITLE'] = dgettext('rolodex', 'Register records in search module'); $tpl['COMMENTS_GROUP_LABEL'] = dgettext('rolodex', 'Comments Settings'); $tpl['PRIVACY_GROUP_LABEL'] = dgettext('rolodex', 'Privacy Settings'); *************** *** 648,672 **** $tpl = $form->getTemplate(); ! /* begin experiment with cats */ ! $key = new Key($member->key_id); ! PHPWS_Core::initModClass('categories', 'Categories.php'); ! if (javascriptEnabled()) { ! $js_vars['label'] = dgettext('categories', 'Categorize'); ! $js_vars['width'] = 640; ! $js_vars['height'] = 250; ! ! $vars['action'] = 'admin'; ! $vars['subaction'] = 'set_item_category'; ! $vars['key_id'] = $key->id; ! ! $js_vars['address'] = PHPWS_Text::linkAddress('categories', $vars, TRUE); ! $link = javascript('open_window', $js_vars); ! $tpl['CATS'] = $link; ! } else { ! $content = Categories::showForm($key); ! $tpl['CATS'] = $content; ! } ! /* end experiment with cats */ ! if (Current_User::allow('rolodex', 'edit_member')) { --- 666,670 ---- $tpl = $form->getTemplate(); ! $tpl['CATEGORIES'] = Categories::getForm($match=$member->get_categories(), $select_name='categories', $multiple=true); if (Current_User::allow('rolodex', 'edit_member')) { *************** *** 696,699 **** --- 694,698 ---- $tpl['MISC_GROUP_LABEL'] = dgettext('rolodex', 'Miscellaneous'); $tpl['EXPIRATION_GROUP_LABEL'] = dgettext('rolodex', 'Expiration utilities'); + $tpl['SEARCH_GROUP_LABEL'] = dgettext('rolodex', 'Search utilities'); $tpl['COMMENTS_GROUP_LABEL'] = dgettext('rolodex', 'Comments utilities'); *************** *** 707,710 **** --- 706,712 ---- $tpl['DELETE_EXPIRED'] = javascript('confirm', $js); + $tpl['SEARCH_INDEX_ALL'] = PHPWS_Text::secureLink(dgettext('rolodex', 'Register all current rolodex records to the search module'), 'rolodex', array('aop'=>'search_index_all')); + $tpl['SEARCH_REMOVE_ALL'] = PHPWS_Text::secureLink(dgettext('rolodex', 'Remove all current rolodex records from the search module'), 'rolodex', array('aop'=>'search_remove_all')); + $tpl['ALL_COMMENTS_YES'] = PHPWS_Text::secureLink(dgettext('rolodex', 'Reset "Allow comments" on all records to yes'), 'rolodex', array('aop'=>'all_comments_yes')); *************** *** 718,721 **** --- 720,743 ---- + function showInfo() + { + + $tpl['TITLE'] = dgettext('rolodex', 'Important Information'); + $tpl['INFO_1_LABEL'] = dgettext('rolodex', 'About this module:'); + $tpl['INFO_1'] = dgettext('rolodex', 'This is an early beta release of this module. There is not much documentation yet, but it will come.'); + $tpl['INFO_2_LABEL'] = dgettext('rolodex', 'Bugs:'); + $tpl['INFO_2'] = sprintf(dgettext('rolodex', 'Please report any bugs or observations of this beta release in %s this post at phpwsforums.com %s'), '<a href="">', '</a>'); + $tpl['INFO_3_LABEL'] = null; + $tpl['INFO_3'] = null; + $tpl['INFO_4_LABEL'] = null; + $tpl['INFO_4'] = null; + $tpl['INFO_5_LABEL'] = null; + $tpl['INFO_5'] = null; + $tpl['DONATE'] = sprintf(dgettext('rolodex', 'If you would like to help out with the ongoing development of Rolodex, or other modules by Verdon Vaillancourt, %s click here to donate %s (opens in new browser window).'), '<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=donations%40verdon%2eca&item_name=Rolodex%20Module%20Development&no_shipping=0&no_note=1&tax=0¤cy_code=USD&lc=CA&bn=PP%2dDonationsBF&charset=UTF%2d8" target="new">', '</a>'); + + $this->rolodex->title = dgettext('rolodex', 'Read me'); + $this->rolodex->content = PHPWS_Template::process($tpl, 'rolodex', 'info.tpl'); + } + } Index: Rolodex.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/rolodex/class/Rolodex.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Rolodex.php 8 Feb 2008 19:38:48 -0000 1.3 --- Rolodex.php 31 Mar 2008 19:42:45 -0000 1.4 *************** *** 61,66 **** Current_User::disallow(); } if ($this->postSettings()) { ! $this->forwardMessage(dgettext('rolodex', 'Rolodex settings saved.')); PHPWS_Core::reroute('index.php?module=rolodex&aop=menu'); } else { --- 61,77 ---- Current_User::disallow(); } + $oldsearch = PHPWS_Settings::get('rolodex', 'privacy_use_search'); if ($this->postSettings()) { ! $msg = dgettext('rolodex', 'Rolodex settings saved.') . '<br />'; ! if ($oldsearch != PHPWS_Settings::get('rolodex', 'privacy_use_search')) { ! if (PHPWS_Settings::get('rolodex', 'privacy_use_search')) { ! if ($this->search_index_all()) ! $msg .= dgettext('rolodex', 'All current member records have been indexed with the search module.'); ! } else { ! if ($this->search_remove_all()) ! $msg .= dgettext('rolodex', 'All current member records have been removed from the search module.'); ! } ! } ! $this->forwardMessage($msg); PHPWS_Core::reroute('index.php?module=rolodex&aop=menu'); } else { *************** *** 99,103 **** $this->loadMember(); $this->member->active = 1; ! $this->member->saveMember(); $this->message = dgettext('rolodex', 'Rolodex member activated.'); $this->loadForm('list'); --- 110,115 ---- $this->loadMember(); $this->member->active = 1; ! $this->member->save(); ! $this->member->saveKey(); $this->message = dgettext('rolodex', 'Rolodex member activated.'); $this->loadForm('list'); *************** *** 110,114 **** $this->loadMember(); $this->member->active = 0; ! $this->member->saveMember(); $this->message = dgettext('rolodex', 'Rolodex member deactivated.'); $this->loadForm('list'); --- 122,127 ---- $this->loadMember(); $this->member->active = 0; ! $this->member->save(); ! $this->member->saveKey(); $this->message = dgettext('rolodex', 'Rolodex member deactivated.'); $this->loadForm('list'); *************** *** 132,135 **** --- 145,168 ---- break; + case 'search_index_all': + if (PHPWS_Settings::get('rolodex', 'privacy_use_search')) { + $this->search_index_all(); + $this->message = dgettext('rolodex', 'All current member records have been indexed with the search module.'); + } else { + $this->message = dgettext('rolodex', 'Search indexing is disabled in Rolodex settings. You must enable it there before you may perform this action.'); + } + $this->loadForm('utilities'); + break; + + case 'search_remove_all': + if (PHPWS_Settings::get('rolodex', 'privacy_use_search')) { + $this->message = dgettext('rolodex', 'Search indexing is enabled in Rolodex settings. You must disable it there before you may perform this action.'); + } else { + $this->search_remove_all(); + $this->message = dgettext('rolodex', 'All current member records have been removed from the search module.'); + } + $this->loadForm('utilities'); + break; + case 'all_comments_yes': $this->setAllComments(1); *************** *** 412,415 **** --- 445,462 ---- PHPWS_Settings::set('rolodex', 'req_approval', 0); + isset($_POST['send_notification']) ? + PHPWS_Settings::set('rolodex', 'send_notification', 1) : + PHPWS_Settings::set('rolodex', 'send_notification', 0); + + if (isset($_POST['admin_contact']) && ($_POST['admin_contact']) !== '') { + if (PHPWS_Text::isValidInput($_POST['admin_contact'], 'email')) { + PHPWS_Settings::set('rolodex', 'admin_contact', $_POST['admin_contact']); + } else { + $errors[] = dgettext('rolodex', 'Check your admin contact e-mail address for formatting errors.'); + } + } else { + PHPWS_Settings::set('rolodex', 'admin_contact', null); + } + if (isset($_POST['comments_enable'])) { if (isset($_POST['comments_enforce'])) { *************** *** 445,448 **** --- 492,496 ---- PHPWS_Settings::set('rolodex', 'privacy_business', $_POST['privacy_business']); PHPWS_Settings::set('rolodex', 'privacy_export', $_POST['privacy_export']); + PHPWS_Settings::set('rolodex', 'privacy_use_search', $_POST['privacy_use_search']); isset($_POST['enable_expiry']) ? *************** *** 544,547 **** --- 592,596 ---- { $this->loadMember(); + // print_r($_POST); exit; if (isset($_POST['courtesy_title'])) { *************** *** 585,594 **** $errors[] = dgettext('rolodex', 'Check your contact e-mail address for formatting errors.'); } } ! if (isset($_POST['website']) && ($_POST['website']) !== '') { ! if (!$this->member->setWebsite($_POST['website'])) { $errors[] = dgettext('rolodex', 'Check your website address for formatting errors.'); } } --- 634,648 ---- $errors[] = dgettext('rolodex', 'Check your contact e-mail address for formatting errors.'); } + } else { + $this->member->contact_email = null; } ! if (!empty($_POST['website'])) { ! $link = PHPWS_Text::checkLink($_POST['website']); ! if (!$this->member->setWebsite($link)) { $errors[] = dgettext('rolodex', 'Check your website address for formatting errors.'); } + } else { + $this->member->website = null; } *************** *** 719,723 **** $image->setMaxWidth(COMMENT_MAX_AVATAR_WIDTH); $image->setMaxHeight(COMMENT_MAX_AVATAR_HEIGHT); ! if (!$image->importPost('avatar')) { if (isset($image->_errors)) { foreach ($image->_errors as $oError) { --- 773,777 ---- $image->setMaxWidth(COMMENT_MAX_AVATAR_WIDTH); $image->setMaxHeight(COMMENT_MAX_AVATAR_HEIGHT); ! if (!$image->importPost('avatar', false, true)) { if (isset($image->_errors)) { foreach ($image->_errors as $oError) { *************** *** 753,757 **** $image->setMaxWidth(PHPWS_Settings::get('rolodex', 'max_img_width')); $image->setMaxHeight(PHPWS_Settings::get('rolodex', 'max_img_height')); ! if (!$image->importPost('image')) { if (isset($image->_errors)) { foreach ($image->_errors as $oError) { --- 807,811 ---- $image->setMaxWidth(PHPWS_Settings::get('rolodex', 'max_img_width')); $image->setMaxHeight(PHPWS_Settings::get('rolodex', 'max_img_height')); ! if (!$image->importPost('image', false, true)) { if (isset($image->_errors)) { foreach ($image->_errors as $oError) { *************** *** 860,863 **** --- 914,965 ---- + function search_index_all() + { + + PHPWS_Core::initModClass('rolodex', 'RDX_Member.php'); + $db = new PHPWS_DB('rolodex_member'); + $db->addColumn('demographics.user_id'); + $db->addColumn('demographics.first_name'); + $db->addColumn('demographics.last_name'); + $db->addColumn('demographics.business_name'); + $db->addColumn('rolodex_member.description'); + $db->addColumn('rolodex_member.key_id'); + $db->addWhere('rolodex_member.user_id', 'demographics.user_id'); + $db->addOrder('demographics.user_id'); + $result = $db->select(); + if (!empty($result)) { + if (PHPWS_Error::logIfError($result)) { + return false; + } + foreach ($result as $member) { + $search = new Search($member['key_id']); + $search->resetKeywords(); + $name = $member['first_name'] . ' ' . $member['last_name']; + $search->addKeywords($name); + $search->addKeywords($member['business_name']); + $search->addKeywords($member['description']); + PHPWS_Error::logIfError($search->save()); + } + } + return true; + } + + + function search_remove_all() + { + + PHPWS_Core::initModClass('search', 'Search.php'); + $db = new PHPWS_DB('search'); + $db->addWhere('module', 'rolodex'); + $result = $db->delete(); + + if (!empty($result)) { + if (PHPWS_Error::logIfError($result)) { + return false; + } + } + return true; + } + function exportCSV($approved=null, $expired=false) *************** *** 927,931 **** ! function alpha_click() { $alphabet = $this->alphabet(); --- 1029,1034 ---- ! function alpha_click() ! { $alphabet = $this->alphabet(); Index: RDX_Mypage.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/rolodex/class/RDX_Mypage.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** RDX_Mypage.php 8 Feb 2008 19:38:48 -0000 1.2 --- RDX_Mypage.php 31 Mar 2008 19:42:45 -0000 1.3 *************** *** 41,45 **** $vars['uop'] = 'edit_member'; $links[] = PHPWS_Text::secureLink(dgettext('rolodex', 'Edit my profile'), 'rolodex', $vars); - $tpl['CONTENT'] = implode(' | ', $links); } else { $vars['user_id'] = Current_User::getId(); --- 41,44 ---- *************** *** 51,56 **** $links[] = PHPWS_Text::secureLink(dgettext('rolodex', 'Add my profile'), 'rolodex', $vars); } - $tpl['CONTENT'] = implode(' | ', $links); } } --- 50,58 ---- $links[] = PHPWS_Text::secureLink(dgettext('rolodex', 'Add my profile'), 'rolodex', $vars); } } + $vars2['uop'] = 'list'; + $links[] = PHPWS_Text::moduleLink(dgettext('rolodex', 'Browse members'), 'rolodex', $vars2); + $tpl['CONTENT'] = implode(' | ', $links); + $tpl['CONTENT'] .= Rolodex_Mypage::searchForm(); } *************** *** 77,80 **** --- 79,99 ---- + function searchForm() + { + $form = new PHPWS_Form('rolodex_search'); + $form->addHidden('module', 'rolodex'); + $form->addHidden('uop', 'list'); + $form->addHidden('search', ''); + $form->addHidden('limit', '10'); + $form->addHidden('orderby', 'demographics.last_name'); + $form->addHidden('orderby_dir', 'asc'); + $form->addText('pager_c_search'); + $form->setSize('pager_c_search', 25); + $form->setLabel('pager_c_search', sprintf(dgettext('rolodex', 'Search %s'), PHPWS_Settings::get('rolodex', 'module_title'))); + $form->addSubmit('go', dgettext('rolodex', 'Search')); + $tpl = $form->getTemplate(); + return PHPWS_Template::process($tpl, 'rolodex', 'search.tpl'); + } + function sendMessage(&$result, $success_msg, $error_msg) { Index: RDX_Member.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/rolodex/class/RDX_Member.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** RDX_Member.php 8 Feb 2008 19:38:48 -0000 1.3 --- RDX_Member.php 31 Mar 2008 19:42:45 -0000 1.4 *************** *** 85,88 **** --- 85,91 ---- /* I might need this for the advanced join in list but am unsure */ var $title = null; + + /* to hold the categories */ + // var $_categories = null; *************** *** 99,102 **** --- 102,118 ---- + function get_categories($print=false) + { + if ($print) { + $result = Categories::getSimpleLinks($this->key_id, true); + } else { + $db = new PHPWS_DB('category_items'); + $db->addWhere('key_id', (int)$this->key_id); + $db->addColumn('cat_id'); + $result = $db->select('col'); + } + return $result; + } + function setAvatar($avatar_url) { *************** *** 1036,1039 **** --- 1052,1060 ---- $tpl['DESCRIPTION'] = PHPWS_Text::parseTag($this->getDescription(true)); $tpl['IMAGE'] = $this->getImage(true); + + if ($this->get_categories(true)) { + $tpl['CATEGORY_LINKS'] = implode(', ', $this->get_categories(true)); + $tpl['CATEGORY_LINKS_LABEL'] = dgettext('rolodex', 'Category(s)'); + } $tpl['PROFILE_GROUP_LABEL'] = dgettext('rolodex', 'Profile'); *************** *** 1080,1083 **** --- 1101,1105 ---- $tpl['HOME_LABEL'] = dgettext('rolodex', 'Home address'); } + $tpl['MAILING_GOOGLE_MAP'] = $this->getGoogleMap('mailing'); } *************** *** 1092,1095 **** --- 1114,1118 ---- $tpl['BUSINESS_LABEL'] = dgettext('rolodex', 'Business address'); } + $tpl['BUSINESS_GOOGLE_MAP'] = $this->getGoogleMap('business'); } *************** *** 1224,1228 **** return PHPWS_Text::rewriteLink($this->getDisplay_name(), 'rolodex', $this->user_id); } ! function deleteMember() --- 1247,1292 ---- return PHPWS_Text::rewriteLink($this->getDisplay_name(), 'rolodex', $this->user_id); } ! ! ! function getGoogleMap($location='mailing') { ! ! if ($location == 'mailing') { ! if (!empty($this->mailing_address_1)) ! $address[] = $this->mailing_address_1; ! if (!empty($this->mailing_address_2)) ! $address[] = $this->mailing_address_2; ! if (!empty($this->mailing_city)) ! $address[] = $this->mailing_city; ! if (!empty($this->mailing_state)) ! $address[] = $this->mailing_state; ! if (!empty($this->mailing_country)) ! $address[] = $this->mailing_country; ! if (!empty($this->mailing_zip_code)) ! $address[] = $this->mailing_zip_code; ! } else { ! if (!empty($this->business_address_1)) ! $address[] = $this->business_address_1; ! if (!empty($this->business_address_2)) ! $address[] = $this->business_address_2; ! if (!empty($this->business_city)) ! $address[] = $this->business_city; ! if (!empty($this->business_state)) ! $address[] = $this->business_state; ! if (!empty($this->business_country)) ! $address[] = $this->business_country; ! if (!empty($this->business_zip_code)) ! $address[] = $this->business_zip_code; ! } ! ! if ($address) { ! $string = urlencode(htmlentities(implode(",", $address))); ! $googlemap = sprintf('<a class="url" href="http://maps.google.com/maps?f=q&q=%s">%s</a>', $string, dgettext('rolodex', 'Get Google Map')); ! } else { ! $googlemap = null; ! } ! ! return $googlemap; ! } ! function deleteMember() *************** *** 1282,1285 **** --- 1346,1352 ---- if (PHPWS_Settings::get('rolodex', 'req_approval') && !Current_User::allow('rolodex', 'edit_member')) { $this->active = 0; + if (PHPWS_Settings::get('rolodex', 'send_notification') && PHPWS_Settings::get('rolodex', 'admin_contact')) { + $this->sendNotification(); + } } } *************** *** 1320,1331 **** } ! ! $search = new Search($this->key_id); ! $search->resetKeywords(); ! $search->addKeywords($this->getDisplay_name()); ! $search->addKeywords($this->description); ! $result = $search->save(); ! if (PEAR::isError($result)) { ! return $result; } --- 1387,1413 ---- } ! if (PHPWS_Settings::get('rolodex', 'privacy_use_search')) { ! $search = new Search($this->key_id); ! $search->resetKeywords(); ! $search->addKeywords($this->getDisplay_name()); ! $search->addKeywords($this->description); ! $result = $search->save(); ! if (PEAR::isError($result)) { ! return $result; ! } ! } ! ! if (isset($_POST['categories'])) { ! $db = new PHPWS_DB('category_items'); ! $db->addWhere('key_id', (int)$this->key_id); ! PHPWS_Error::logIfError($db->delete()); ! PHPWS_Core::initModClass('categories', 'Action.php'); ! foreach ($_POST['categories'] as $var => $val) { ! Categories_Action::addCategoryItem($val, $this->key_id); ! } ! } else { ! $db = new PHPWS_DB('category_items'); ! $db->addWhere('key_id', (int)$this->key_id); ! PHPWS_Error::logIfError($db->delete()); } *************** *** 1567,1570 **** --- 1649,1672 ---- + function sendNotification() + { + + $page_title = $_SESSION['Layout_Settings']->getPageTitle(true); + $site_contact = PHPWS_User::getUserSetting('site_contact'); + $url = PHPWS_Core::getHomeHttp(); + $message = sprintf(dgettext('rolodex', 'You have a new %s application from %s waiting for your review at %s.'), PHPWS_Settings::get('rolodex', 'module_title'), $this->getDisplay_name(), $url); + + PHPWS_Core::initCoreClass('Mail.php'); + $mail = new PHPWS_Mail; + $mail->addSendTo(PHPWS_Settings::get('rolodex', 'admin_contact')); + $mail->setSubject(sprintf(dgettext('rolodex', 'Pending %s Application'), PHPWS_Settings::get('rolodex', 'module_title'))); + $mail->setFrom(sprintf('%s<%s>', $page_title, $site_contact)); + $mail->setMessageBody($message); + + return $mail->send(); + + } + + /** |