示例#1
0
 /**
 * Add or remove a default group to/from all existing accounts
 *
 * @param    int     $grp_id     ID of default group
 * @param    boolean $add        true: add, false: remove
 * @return   void
 *
 */
 function INSTALLER_applyGroupDefault($grp_id, $add = true)
 {
     global $_TABLES, $_GROUP_VERBOSE;
     /**
      * In the "add" case, we have to insert one record for each user. Pack this
      * many values into one INSERT statement to save some time and bandwidth.
      */
     $_values_per_insert = 25;
     if ($_GROUP_VERBOSE) {
         if ($add) {
             COM_errorLog("Adding group '{$grp_id}' to all user accounts");
         } else {
             COM_errorLog("Removing group '{$grp_id}' from all user accounts");
         }
     }
     if ($add) {
         $result = DB_query("SELECT uid FROM {$_TABLES['users']} WHERE uid > 1");
         $num_users = DB_numRows($result);
         for ($i = 0; $i < $num_users; $i += $_values_per_insert) {
             $u = array();
             for ($j = 0; $j < $_values_per_insert; $j++) {
                 list($uid) = DB_fetcharray($result);
                 $u[] = $uid;
                 if ($i + $j + 1 >= $num_users) {
                     break;
                 }
             }
             $v = "({$grp_id}," . implode("), ({$grp_id},", $u) . ')';
             DB_query("INSERT INTO {$_TABLES['group_assignments']} (ug_main_grp_id, ug_uid) VALUES " . $v);
         }
     } else {
         DB_query("DELETE FROM {$_TABLES['group_assignments']} WHERE (ug_main_grp_id = {$grp_id}) AND (ug_grp_id IS NULL)");
     }
 }
示例#2
0
 /**
  *  Delete a category, and all sub-categories, and all ads
  *
  *  @param  integer  $id     Category ID to delete
  *  @return boolean          True on success, False on failure
  */
 public static function Delete($id)
 {
     global $_TABLES, $_CONF_ADVT;
     $id = (int) $id;
     // find all sub-categories of this one and delete them.
     $sql = "SELECT cat_id FROM {$_TABLES['ad_category']} \n                WHERE papa_id={$id}";
     $result = DB_query($sql);
     if ($result) {
         while ($row = DB_fetcharray($result)) {
             if (!adCategory::Delete($row['cat_id'])) {
                 return false;
             }
         }
     }
     // now delete any ads associated with this category
     $sql = "SELECT ad_id FROM {$_TABLES['ad_ads']} \n             WHERE cat_id={$id}";
     $result = DB_query($sql);
     if ($result) {
         while ($row = DB_fetcharray($result)) {
             if (adDelete($row['ad_id'], true) != 0) {
                 return false;
             }
         }
     }
     // Delete this category
     // First, see if there's an image to delete
     $img_name = DB_getItem($_TABLES['ad_category'], 'image', "cat_id={$id}");
     if ($img_name != '' && file_exists($this->imgPath . $img_name)) {
         unlink($this->imgPath . $img_name);
     }
     DB_delete($_TABLES['ad_category'], 'cat_id', $id);
     // If we made it this far, must have worked ok
     return true;
 }
示例#3
0
function nexlistKey($listid, $match)
{
    global $_TABLES;
    $query = DB_query("SELECT id FROM {$_TABLES['nexlistitems']} WHERE lid='{$listid}' and value='{$match}'");
    if (DB_numRows($query) == 0) {
        // nexlist value may be part of a list with multiple fields
        $query = DB_query("SELECT id FROM {$_TABLES['nexlistitems']} WHERE lid='{$listid}' and value like '%{$match}%'");
    }
    list($id) = DB_fetcharray($query);
    return $id;
}
示例#4
0
        }
    }
} else {
    // no stories to display
    if ($page == 1) {
        if (!isset($_CONF['hide_no_news_msg']) || $_CONF['hide_no_news_msg'] == 0) {
            $display .= COM_startBlock($LANG05[1], '', COM_getBlockTemplate('_msg_block', 'header')) . $LANG05[2];
            $display .= COM_endBlock(COM_getBlockTemplate('_msg_block', 'footer'));
        }
        $display .= PLG_showCenterblock(3, $page, $topic);
        // bottom blocks
    } else {
        $topic_url = '';
        if (!empty($topic)) {
            $topic_url = COM_buildURL($_CONF['site_url'] . '/index.php?topic=' . $topic);
        }
        COM_handle404($topic_url);
    }
}
$header = '';
if ($topic) {
    // Meta Tags
    if ($_CONF['meta_tags'] > 0) {
        $result = DB_query("SELECT meta_description, meta_keywords FROM {$_TABLES['topics']} WHERE tid = '{$topic}'");
        $A = DB_fetcharray($result);
        $header .= LB . PLG_getMetaTags('homepage', '', array(array('name' => 'description', 'content' => stripslashes($A['meta_description'])), array('name' => 'keywords', 'content' => stripslashes($A['meta_keywords']))));
    }
}
$display = COM_createHTMLDocument($display, array('breadcrumbs' => $breadcrumbs, 'headercode' => $header, 'rightblock' => true));
// Output page
COM_output($display);
示例#5
0
 /**
  *  Creates a dropdown selection for the specified list, with the
  *  record corresponding to $sel selected.
  *  @param  integer $sel    Optional item ID to select
  *  @param  string  $sql    Optional SQL query
  *  @return string HTML for selection dropdown
  */
 function makeSelection($sel = 0, $sql = '')
 {
     global $_TABLES;
     if ($sql == '') {
         $sql = "SELECT id,descrip\n                FROM {$_TABLES['ad_types']}\n                WHERE enabled=1\n                ORDER BY descrip ASC";
     }
     $result = DB_query($sql);
     if (!$result) {
         $this->Error = 1;
         return '';
     }
     $selection = '';
     while ($row = DB_fetcharray($result)) {
         $selected = '';
         if (is_array($sel)) {
             // Multiple selections, check if the current one is among them
             if (in_array($row['id'], $sel)) {
                 $selected = "selected";
             }
         } else {
             if ($sel == 0) {
                 // No selection, take the first one found.
                 $sel = $row['id'];
             }
             if ($sel == $row['id']) {
                 $selected = "selected";
             }
         }
         if (is_object($this)) {
             // Set the current id, only if this is an instantiated object
             if ($selected == 'selected' && $this->getID() == 0) {
                 $this->setID($row['id']);
             }
         }
         $selection .= "<option value=\"{$row['id']}\" {$selected}>" . htmlspecialchars($row['descrip']) . "</option>\n";
     }
     return $selection;
 }