Esempio n. 1
0
 /**
  * Comprueba si existe un elemento en una tabla expec?fica
  * @param string $table Nombre de la tabla
  * @param string $cond Condici?n de b?squeda
  * @return bool
  */
 public function get_count($table, $cond = '')
 {
     $db =& EXMDatabase::get();
     $sql = "SELECT COUNT(*) FROM {$table}";
     if ($cond != '') {
         $sql .= " WHERE {$cond}";
     }
     list($num) = $db->fetchRow($db->query($sql));
     return $num;
 }
Esempio n. 2
0
 function getByModule($moduleid, $asobject = true)
 {
     $db =& EXMDatabase::get();
     if (!is_numeric($moduleid)) {
         $col = 'dirname';
     } else {
         $col = 'mid';
     }
     if ($asobject == true) {
         $sql = $sql = "SELECT * FROM " . $db->prefix("rmc_blocks") . " WHERE {$col}='" . $moduleid . "'";
     } else {
         $sql = "SELECT bid FROM " . $db->prefix("rmc_blocks") . " WHERE {$col}=" . $moduleid . "";
     }
     $result = $db->query($sql);
     $ret = array();
     while ($myrow = $db->fetchArray($result)) {
         if ($asobject) {
             $ret[] = new EXMBlock($myrow['bid']);
         } else {
             $ret[] = $myrow['bid'];
         }
     }
     return $ret;
 }
Esempio n. 3
0
/**
* Change the current visibility status for a set of selected widgets
*/
function toggle_visibility($s)
{
    global $exmSecurity;
    if (!$exmSecurity->check() || !$exmSecurity->checkReferer()) {
        redirectMsg('widgets.php', __('You are not allowed to do this action!', 'system'), 1);
        die;
    }
    $ids = exm_server_var($_POST, 'widget', array());
    if (empty($ids) || !is_array($ids)) {
        redirectMsg('widgets.php', __('An error was found while trying to do this action', 'system'), 1);
        die;
    }
    $db = EXMDatabase::get();
    $db->queryF("UPDATE " . $db->prefix("widgets") . " SET visible={$s} WHERE wid IN (" . join(",", $ids) . ")");
    if ($db->error() == '') {
        redirectMsg('widgets.php', __('Database updated successfully', 'global'), 0);
    } else {
        redirectMsg('widgets.php', __('There was an error while trying this action: ', 'system') . $db->error(), 1);
    }
}
Esempio n. 4
0
 /**
  * Genera el código HTML para este elemento.
  * @return string
  */
 public function render()
 {
     $db = EXMDatabase::get();
     $sql = "SELECT * FROM " . $db->prefix("avatar");
     if ($this->_onlyuser) {
         global $exmUser;
         if ($exmUser) {
             $useravatar = $exmUser->getVar('user_avatar');
             $sql .= " WHERE avatar_display='1' AND (avatar_type='0' OR (avatar_type='1' AND avatar_file='{$useravatar}'))";
             unset($useravatar);
         }
     }
     $sql .= " ORDER BY avatar_name";
     $result = $db->query($sql);
     $rtn = '';
     $col = 1;
     $typeinput = $this->_multi ? 'checkbox' : 'radio';
     $name = $this->_multi ? $this->getName() . '[]' : $this->getName();
     if ($this->_showtype) {
         $rtn = "<div style='height: 200px; overflow: auto;'><table cellspacing='2' cellpadding='3' border='0'>";
         $rtn .= "<tr>";
         $rtn .= "<td align='left'><label><input type='{$typeinput}' name='{$name}' id='{$name}' value=''";
         if (empty($this->_select)) {
             $rtn .= " checked='checked'";
         }
         $rtn .= ">" . _RMS_CF_NOAVATAR . "</label></td>";
         $col++;
         while ($row = $db->fetchArray($result)) {
             if ($col > $this->_cols) {
                 $rtn .= "</tr><tr>";
                 $col = 1;
             }
             $rtn .= "<td align='left'><label><img src='" . ABSURL . "/uploads/avatars/{$row['avatar_file']}' align='absmiddle' /> <input type='{$typeinput}' name='{$name}' id='{$name}' value='{$row['avatar_file']}'";
             if (is_array($this->_select)) {
                 if (in_array($row['avatar_file'], $this->_select)) {
                     $rtn .= " checked='checked'";
                 }
             }
             $rtn .= ">{$row['avatar_name']}</label>";
             $rtn .= "</td>";
             $col++;
         }
         $rtn .= "</tr>";
         $rtn .= "</table></div>";
     } else {
         $rtn = "<script type='text/javascript'>\n\t\t\t\t\t\tfunction showImageAvatar(){\n\t\t\t\t\t\t\tsel = \$('{$name}');\n\t\t\t\t\t\t\tvar img = sel.options[sel.selectedIndex].value;\n\t\t\t\t\t\t\tdiv = \$('avatarimg');\n\t\t\t\t\t\t\tdiv.innerHTML = \"<img src='" . ABSURL . "/uploads/avatars/\"+img+\"' />\";\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t</script>";
         $rtn .= "<div id='avatarimg' style='float: right;'>";
         if (count($this->_select) > 0) {
             $rtn .= "<img src='" . ABSURL . "/uploads/avatars/" . $this->_select[0] . "' border='0' alt='' />";
         }
         $rtn .= "</div>\n\t\t\t\t\t<select name='{$name}' id='{$name}' onchange='showImageAvatar();'";
         $rtn .= $this->_multi ? " multiple='multiple' size='5'" : "";
         $rtn .= "><option value='0'";
         if (is_array($this->_select)) {
             if (in_array(0, $this->_select)) {
                 $rtn .= " selected='selected'";
             }
         } else {
             $rtn .= " selected='selected'";
         }
         $rtn .= ">" . _RMS_CF_ALL . "</option>";
         while ($row = $db->fetchArray($result)) {
             $rtn .= "<option value='{$row['avatar_file']}'";
             if (is_array($this->_select)) {
                 if (in_array($row['avatar_file'], $this->_select)) {
                     $rtn .= " selected='selected'";
                 }
             }
             $rtn .= ">" . $row['avatar_name'] . "</option>";
         }
         $rtn .= "</select>";
     }
     return $rtn;
 }