예제 #1
0
 /**
  *   Creates the edit form
  *
  *   @param  string  $type   Type of form, plugin or glFusion acct settings
  *   @return string HTML for edit form
  */
 function showForm($type = 'advt')
 {
     global $_TABLES, $_CONF, $_CONF_ADVT, $LANG_ADVT, $_USER, $_SYSTEM;
     $base_url = $_CONF['site_url'] . '/' . $_CONF_ADVT['pi_name'];
     $T = new Template(CLASSIFIEDS_PI_PATH . '/templates');
     $tpltype = $_SYSTEM['framework'] == 'uikit' ? '.uikit' : '';
     $T->set_file('accountinfo', "account_settings{$tpltype}.thtml");
     if ($type == 'advt') {
         // Called within the plugin
         //    $T->set_file('accountinfo', "accountinfo$tpltype.thtml");
     } else {
         // Called via glFusion account settings
         $T->set_var('profileedit', 'true');
         //    $T->set_file('accountinfo', "account_settings$tpltype.thtml");
     }
     $T->set_var(array('uid' => $this->uid, 'uinfo_address' => $this->address, 'uinfo_city' => $this->city, 'uinfo_state' => $this->state, 'uinfo_tel' => $this->tel, 'uinfo_fax' => $this->fax, 'uinfo_postcode' => $this->postcode, 'exp_notify_checked' => $this->notify_exp == 1 ? 'checked="checked"' : '', 'cmt_notify_checked' => $this->notify_comment == 1 ? 'checked="checked"' : ''));
     $sql = "SELECT cat_id, notice_id FROM {$_TABLES['ad_notice']} \n                WHERE uid='{$_USER['uid']}'";
     $notice = DB_query($sql);
     if (!$notice) {
         return CLASSIFIEDS_errorMsg($LANG_ADVT['database_error'], 'alert');
     }
     if (0 == DB_numRows($notice)) {
         $T->set_var('no_autonotify_list', 'true');
     } else {
         while ($row = DB_fetchArray($notice)) {
             $T->set_block('accountinfo', 'AutoNotifyListBlk', 'NotifyList');
             $T->set_var(array('cat_id' => $row['cat_id'], 'cat_name' => CLASSIFIEDS_BreadCrumbs($row['cat_id'], false), 'pi_url' => $base_url));
             $T->parse('NotifyList', 'AutoNotifyListBlk', true);
         }
     }
     $T->parse('output', 'accountinfo');
     return $T->finish($T->get_var('output'));
 }
예제 #2
0
 /**
  *  Creates the edit form
  *  @param integer $id Optional ID, current record used if zero
  *  @return string HTML for edit form
  */
 function showForm($type = 'advt')
 {
     global $_TABLES, $_CONF, $_CONF_ADVT, $LANG_ADVT, $_USER;
     $id = (int) $id;
     if ($id > 0) {
         $this->Read($id);
     }
     $base_url = $_CONF['site_url'] . '/' . $_CONF_ADVT['pi_name'];
     $T = new Template(CLASSIFIEDS_PI_PATH . '/templates');
     if ($type == 'advt') {
         // Called within the plugin
         $T->set_file('accountinfo', 'accountinfo.thtml');
     } else {
         // Called via glFusion account settings
         $T->set_file('accountinfo', 'account_settings.thtml');
     }
     $T->set_var(array('uinfo_address' => $this->getAddress(), 'uinfo_city' => $this->getCity(), 'uinfo_state' => $this->getState(), 'uinfo_tel' => $this->getTel(), 'uinfo_fax' => $this->getFax(), 'uinfo_postcode' => $this->getPostCode(), 'exp_notify_checked' => $this->getNotifyExp() == 1 ? 'checked="checked"' : '', 'cmt_notify_checked' => $this->getNotifyCmt() == 1 ? 'checked="checked"' : ''));
     $sql = "\n            SELECT \n                cat_id, notice_id\n            FROM \n                {$_TABLES['ad_notice']} \n            WHERE \n                uid='{$_USER['uid']}'";
     $notice = DB_query($sql);
     if (!$notice) {
         return CLASSIFIEDS_errorMsg($LANG_ADVT['database_error'], 'alert');
     }
     if (0 == DB_numRows($notice)) {
         $T->set_var('no_autonotify_list', 'true');
     } else {
         while ($row = DB_fetchArray($notice)) {
             $T->set_block('accountinfo', 'AutoNotifyListBlk', 'NotifyList');
             $T->set_var(array('cat_id' => $row['cat_id'], 'cat_name' => CLASSIFIEDS_BreadCrumbs($row['cat_id'], false), 'pi_url' => $base_url));
             $T->parse('NotifyList', 'AutoNotifyListBlk', true);
         }
     }
     $T->parse('output', 'accountinfo');
     return $T->finish($T->get_var('output'));
 }
예제 #3
0
/**
*   Notify the site adminstrator that an ad has been submitted.
*   @param  array   $A  All ad data, such as from $_POST
*/
function CLASSIFIEDS_notifyAdmin($A)
{
    global $_TABLES, $LANG_ADVT, $_CONF, $_CONF_ADVT;
    // require a valid ad ID
    if ($A['ad_id'] == '') {
        return;
    }
    USES_classifieds_class_adtype();
    COM_clearSpeedlimit(300, 'advtnotify');
    $last = COM_checkSpeedlimit('advtnotify');
    if ($last > 0) {
        return true;
    }
    $ad_type = AdType::GetDescription($A['ad_type']);
    // Select the template for the message
    $template_dir = CLASSIFIEDS_PI_PATH . '/templates/notify/' . $_CONF['language'];
    if (!file_exists($template_dir . '/admin.thtml')) {
        $template_dir = CLASSIFIEDS_PI_PATH . '/templates/notify/english';
    }
    $T = new Template($template_dir);
    $T->set_file('message', 'admin.thtml');
    $T->set_var('site_url', $_CONF['site_url']);
    $T->set_var('admin_url', "{$_CONF['site_admin_url']}/moderation.php");
    $T->set_var('site_name', $_CONF['site_name']);
    $T->set_var('cat', CLASSIFIEDS_BreadCrumbs($A['catid']), false);
    $T->set_var('subject', $A['subject']);
    $T->set_var('description', $A['descript']);
    $T->set_var('username', COM_getDisplayName(2));
    //$T->set_var('ad_url', "{$_CONF['site_url']}/{$_CONF_ADVT['pi_name']}/index.php?mode=detail&id={$A['ad_id']}");
    $T->set_var('price', $A['price']);
    $T->set_var('ad_type', $ad_type);
    $T->parse('output', 'message');
    $message = $T->finish($T->get_var('output'));
    $group_id = DB_getItem($_TABLES['groups'], 'grp_id', 'grp_name="classifieds Admin"');
    $groups = CLASSIFIEDS_getGroupList($group_id);
    if (empty($groups)) {
        return;
    }
    $groupList = implode(',', $groups);
    $sql = "SELECT DISTINCT \n                {$_TABLES['users']}.uid,username,fullname,email \n            FROM \n                {$_TABLES['group_assignments']},\n                {$_TABLES['users']} \n            WHERE \n                {$_TABLES['users']}.uid > 1 \n            AND \n                {$_TABLES['users']}.uid = {$_TABLES['group_assignments']}.ug_uid \n            AND \n                {$_TABLES['group_assignments']}.ug_main_grp_id IN ({$groupList})";
    $result = DB_query($sql);
    $nRows = DB_numRows($result);
    $toCount = 0;
    for ($i = 0; $i < $nRows; $i++) {
        $row = DB_fetchArray($result);
        if ($row['email'] != '') {
            COM_errorLog("Classifieds Submit: Sending notification email to: " . $row['email'] . " - " . $row['username']);
            COM_mail(array($row['email'], $row['username']), "{$LANG_ADVT['you_have_new_ad']} {$_CONF['site_name']}", $message, "{$LANG_ADVT['new_ad_notice']} <{$email}>", true);
        }
        // if valid email
    }
    // foreach administrator
    COM_updateSpeedlimit('advtnotify');
}