function getVar($key, $format = 's') { $value = parent::getVar($key, $format); if ($key == 'field_options' && !empty($value)) { foreach (array_keys($value) as $idx) { $value[$idx] = base64_decode($value[$idx]); } } return $value; }
/** * @param XoopsRank|XoopsObject $obj */ public function __construct(XoopsObject $obj) { if ($obj->isNew()) { $blank_img = 'blank.gif'; } else { $blank_img = str_replace('ranks/', '', $obj->getVar('rank_image', 'e')); } $title = $obj->isNew() ? sprintf(_AM_USERRANK_ADD) : sprintf(_AM_USERRANK_EDIT); parent::__construct($title, 'form', 'userrank.php', 'post', true); $this->setExtra('enctype="multipart/form-data"'); $this->addElement(new Xoops\Form\Text(_AM_USERRANK_TITLE, 'rank_title', 4, 50, $obj->getVar('rank_title')), true); $min = new Xoops\Form\Text(_AM_USERRANK_MINPOST, 'rank_min', 1, 10, $obj->getVar('rank_min')); $min->setPattern('^\\d+$', _AM_USERRANK_ERROR_POST); $this->addElement($min); $max = new Xoops\Form\Text(_AM_USERRANK_MAXPOST, 'rank_max', 1, 10, $obj->getVar('rank_max')); $max->setPattern('^\\d+$', _AM_USERRANK_ERROR_POST); $this->addElement($max); $imgtray_img = new Xoops\Form\ElementTray(_AM_USERRANK_IMAGE, '<br />'); $imgpath_img = sprintf(_AM_USERRANK_IMAGE_PATH, \XoopsBaseConfig::get('uploads-path') . '/ranks/'); $imageselect_img = new Xoops\Form\Select($imgpath_img, 'rank_image', $blank_img); $image_array_img = XoopsLists::getImgListAsArray(\XoopsBaseConfig::get('uploads-path') . '/ranks'); $imageselect_img->addOption("{$blank_img}", $blank_img); foreach ($image_array_img as $image_img) { $imageselect_img->addOption("{$image_img}", $image_img); } $imageselect_img->setExtra("onchange='showImgSelected(\"xo-ranks-img\", \"rank_image\", \"ranks\", \"\", \"" . \XoopsBaseConfig::get('uploads-url') . "\")'"); $imgtray_img->addElement($imageselect_img, false); $imgtray_img->addElement(new Xoops\Form\Label('', "<br /><img src='" . \XoopsBaseConfig::get('uploads-url') . "/ranks/" . $blank_img . "' name='image_img' id='xo-ranks-img' alt='' />")); $fileseltray_img = new Xoops\Form\ElementTray('<br />', '<br /><br />'); $fileseltray_img->addElement(new Xoops\Form\File(_AM_USERRANK_UPLOAD, 'rank_image'), false); $fileseltray_img->addElement(new Xoops\Form\Label(''), false); $imgtray_img->addElement($fileseltray_img); $this->addElement($imgtray_img); if (!$obj->isNew()) { $rank_special = $obj->getVar('rank_special'); } else { $rank_special = 0; } $special_tray = new Xoops\Form\ElementTray(_AM_USERRANK_SPECIAL, '<br />'); $special_tray->setDescription(_AM_USERRANK_SPECIAL_CAN); $special_tray->addElement(new Xoops\Form\RadioYesNo('', 'rank_special', $rank_special)); $this->addElement($special_tray); if (!$obj->isNew()) { $this->addElement(new Xoops\Form\Hidden('rank_id', $obj->getVar('rank_id'))); } $this->addElement(new Xoops\Form\Hidden('op', 'userrank_save')); $this->addElement(new Xoops\Form\Button('', 'submit', XoopsLocale::A_SUBMIT, 'submit')); }
/** * Delete a {@link XoopsGroupPerm} * * @param XoopsObject|XoopsGroupPerm $perm a XoopsGroupPerm object * * @return bool true on success, otherwise false */ public function delete(XoopsObject $perm) { $className = 'XoopsGroupPerm'; if (!$perm instanceof $className) { return false; } $sql = sprintf('DELETE FROM %s WHERE gperm_id = %u', $this->db->prefix('group_permission'), $perm->getVar('gperm_id')); if (!($result = $this->db->query($sql))) { return false; } return true; }
/** * Compare two objects and returns, in an array, the differences * * @param XoopsObject $old_object The first object to compare * @param XoopsObject $new_object The new object * @return array differences key = fieldname, value = array('old_value', 'new_value') */ function compareObjects($old_object, $new_object) { $ret = array(); $vars_name = array_keys($old_object->getVars()); foreach ($vars_name as $one_var) { if ($old_object->getVar($one_var, 'f') == $new_object->getVar($one_var, 'f')) { } else { $ret[$one_var] = array($old_object->getVar($one_var), $new_object->getVar($one_var)); } } return $ret; }
/** * Delete an image from the database * * @param XoopsObject|XoopsImageSetImg $imgsetimg a XoopsImageSet object * * @return bool true on success, otherwise false **/ public function delete(XoopsObject $imgsetimg) { $className = 'XoopsImageSetImg'; if (!$imgsetimg instanceof $className) { return false; } $sql = sprintf('DELETE FROM %s WHERE imgsetimg_id = %u', $this->db->prefix('imgsetimg'), $imgsetimg->getVar('imgsetimg_id')); if (!($result = $this->db->query($sql))) { return false; } return true; }
/** * delete a block from the database * * @param XoopsObject|XoopsTplfile $tplfile a XoopsTplfile object * * @return bool true on success, otherwise false */ public function delete(XoopsObject $tplfile) { $className = 'XoopsTplfile'; if (!$tplfile instanceof $className) { return false; } $id = $tplfile->getVar('tpl_id'); $sql = sprintf('DELETE FROM %s WHERE tpl_id = %u', $this->db->prefix('tplfile'), $id); if (!($result = $this->db->query($sql))) { return false; } $sql = sprintf('DELETE FROM %s WHERE tpl_id = %u', $this->db->prefix('tplsource'), $id); $this->db->query($sql); return true; }
/** * returns a specific variable for the object in a proper format * * @access public * @param string $key key of the object's variable to be returned * @param string $format format to use for the output * @return mixed formatted value of the variable */ function &getVar($key, $format = 's') { $ret =& parent::getVar($key, $format); if ($this->vars[$key]['data_type'] == XOBJ_DTYPE_TXTAREA && ($format == 'e' || $format == 'edit')) { $ret = preg_replace("/&(#[0-9]+;)/i", '&$1', $ret); } return $ret; }
/** * returns a specific variable for the object in a proper format * * @access public * @param string $key key of the object's variable to be returned * @param string $format format to use for the output * @return mixed formatted value of the variable */ function getVar($key, $format = "s") { $uservars = array_keys($this->getVars()); if (!in_array($key, $uservars)) { return $this->_profile->getVar($key, $format); } return parent::getVar($key, $format); }
/** * delete a profile field from the database * * @param XoopsObject|ProfileField $obj reference to the object to delete * @param bool $force * @return bool FALSE if failed. **/ public function delete(XoopsObject $obj, $force = false) { if (!$obj instanceof $this->className) { return false; } $profile_handler = xoops_getModuleHandler('profile', 'profile'); // remove column from table $sql = 'ALTER TABLE ' . $profile_handler->table . ' DROP `' . $obj->getVar('field_name', 'n') . '`'; if ($this->db->query($sql)) { //change this to update the cached field information storage if (!parent::delete($obj, $force)) { return false; } if ($obj->getVar('field_show') || $obj->getVar('field_edit')) { $module_handler = xoops_getHandler('module'); $profile_module = $module_handler->getByDirname('profile'); if (is_object($profile_module)) { // Remove group permissions $groupperm_handler = xoops_getHandler('groupperm'); $criteria = new CriteriaCompo(new Criteria('gperm_modid', $profile_module->getVar('mid'))); $criteria->add(new Criteria('gperm_itemid', $obj->getVar('field_id'))); return $groupperm_handler->deleteAll($criteria); } } } return false; }
/** * Delete a {@link XoopsComment} from the database * * @param XoopsObject|XoopsComment $comment a XoopsComment object * * @return bool true on success, otherwise false **/ public function delete(XoopsObject $comment) { $className = 'XoopsComment'; if (!$comment instanceof $className) { return false; } $sql = sprintf('DELETE FROM %s WHERE com_id = %u', $this->db->prefix('xoopscomments'), $comment->getVar('com_id')); if (!($result = $this->db->query($sql))) { return false; } return true; }
/** * delete a profile field from the database * * @param XoopsObject|ProfileField $obj reference to the object to delete * @param bool $force * @return bool FALSE if failed. **/ public function deleteFields(XoopsObject $obj, $force = false) { $xoops = Xoops::getInstance(); $profile_handler = $xoops->getModuleHandler('profile', 'profile'); // remove column from table $sql = "ALTER TABLE " . $profile_handler->table . " DROP `" . $obj->getVar('field_name', 'n') . "`"; if ($this->db->query($sql)) { //change this to update the cached field information storage if (!parent::delete($obj, $force)) { return false; } if ($obj->getVar('field_show') || $obj->getVar('field_edit')) { $profile_module = $xoops->getModuleByDirname('profile'); if (is_object($profile_module)) { // Remove group permissions $groupperm_handler = $xoops->getHandlerGroupperm(); $criteria = new CriteriaCompo(new Criteria('gperm_modid', $profile_module->getVar('mid'))); $criteria->add(new Criteria('gperm_itemid', $obj->getVar('field_id'))); return $groupperm_handler->deleteAll($criteria); } } } return false; }
/** * returns a specific variable for the object in a proper format * * @access public * @param string $key key of the object's variable to be returned * @param string $format format to use for the output * @return mixed formatted value of the variable */ function &getVar($key, $format = 's') { if ($this->vars[$key]['data_type'] == XOBJ_DTYPE_CUSTOM) { //個別の変数Getがあれば実行; $getMethod = 'getVar_' . $key; if (method_exists($this, $getMethod)) { $ret = $this->{$getMethod}($this->vars[$key]['value'], $format); } else { if (in_array($key, array_keys($this->mGroupPermAttrib))) { $groupPermHandler =& NBFrame::getHandler('NBFrame.xoops.GroupPerm', NBFrame::null()); $ret = $groupPermHandler->getGroupIdsByObjectKey($this->mGroupPermAttrib[$key], $this); } else { $this->vars[$key]['data_type'] = XOBJ_DTYPE_TXTBOX; $ret =& parent::getVar($key, $format); $this->vars[$key]['data_type'] = XOBJ_DTYPE_CUSTOM; } } } else { $ret =& parent::getVar($key, $format); } if ($this->vars[$key]['data_type'] == XOBJ_DTYPE_TXTAREA && ($format == 'e' || $format == 'edit')) { $ret = preg_replace("/&(#[0-9]+;)/i", '&$1', $ret); } return $ret; }
/** * Delete a module from the database * * @param XoopsObject|XoopsModule $module a XoopsModule object * * @return bool true on success, otherwise false */ public function delete(XoopsObject $module) { $className = 'XoopsModule'; if (!$module instanceof $className) { return false; } $sql = sprintf('DELETE FROM %s WHERE mid = %u', $this->db->prefix('modules'), $module->getVar('mid')); if (!($result = $this->db->query($sql))) { return false; } // delete admin permissions assigned for this module $sql = sprintf("DELETE FROM %s WHERE gperm_name = 'module_admin' AND gperm_itemid = %u", $this->db->prefix('group_permission'), $module->getVar('mid')); $this->db->query($sql); // delete read permissions assigned for this module $sql = sprintf("DELETE FROM %s WHERE gperm_name = 'module_read' AND gperm_itemid = %u", $this->db->prefix('group_permission'), $module->getVar('mid')); $this->db->query($sql); $sql = sprintf('SELECT block_id FROM %s WHERE module_id = %u', $this->db->prefix('block_module_link'), $module->getVar('mid')); if ($result = $this->db->query($sql)) { $block_id_arr = array(); while ($myrow = $this->db->fetchArray($result)) { $block_id_arr[] = $myrow['block_id']; } } // loop through block_id_arr if (isset($block_id_arr)) { foreach ($block_id_arr as $i) { $sql = sprintf('SELECT block_id FROM %s WHERE module_id != %u AND block_id = %u', $this->db->prefix('block_module_link'), $module->getVar('mid'), $i); if ($result2 = $this->db->query($sql)) { if (0 < $this->db->getRowsNum($result2)) { // this block has other entries, so delete the entry for this module $sql = sprintf('DELETE FROM %s WHERE (module_id = %u) AND (block_id = %u)', $this->db->prefix('block_module_link'), $module->getVar('mid'), $i); $this->db->query($sql); } else { // this block doesnt have other entries, so disable the block and let it show on top page only. otherwise, this block will not display anymore on block admin page! $sql = sprintf('UPDATE %s SET visible = 0 WHERE bid = %u', $this->db->prefix('newblocks'), $i); $this->db->query($sql); $sql = sprintf('UPDATE %s SET module_id = -1 WHERE module_id = %u', $this->db->prefix('block_module_link'), $module->getVar('mid')); $this->db->query($sql); } } } } if (!empty($this->_cachedModule_dirname[$module->getVar('dirname')])) { unset($this->_cachedModule_dirname[$module->getVar('dirname')]); } if (!empty($this->_cachedModule_mid[$module->getVar('mid')])) { unset($this->_cachedModule_mid[$module->getVar('mid')]); } return true; }
/** * Delete an object from the database * * @param XoopsObject|XoopsAvatar $avatar a XoopsAvatar object * * @return bool true on success, otherwise false */ public function delete(XoopsObject $avatar) { $className = 'XoopsAvatar'; if (!$avatar instanceof $className) { return false; } $id = $avatar->getVar('avatar_id'); $sql = sprintf('DELETE FROM %s WHERE avatar_id = %u', $this->db->prefix('avatar'), $id); if (!($result = $this->db->query($sql))) { return false; } $sql = sprintf('DELETE FROM %s WHERE avatar_id = %u', $this->db->prefix('avatar_user_link'), $id); $result = $this->db->query($sql); return true; }
/** * Delete an image from the database * * @param XoopsObject|XoopsImage $image a XoopsImage object * * @return bool true on success, otherwise false **/ public function delete(XoopsObject $image) { $className = 'XoopsImage'; if (!$image instanceof $className) { return false; } $id = $image->getVar('image_id'); $sql = sprintf('DELETE FROM %s WHERE image_id = %u', $this->db->prefix('image'), $id); if (!($result = $this->db->query($sql))) { return false; } $sql = sprintf('DELETE FROM %s WHERE image_id = %u', $this->db->prefix('imagebody'), $id); $this->db->query($sql); return true; }
/** * Delete a {@link XoopsNotification} from the database * * @param XoopsObject|XoopsNotification $notification a XoopsNotification object * * @return bool true on success, otherwise false **/ public function delete(XoopsObject $notification) { $className = 'XoopsNotification'; if (!$notification instanceof $className) { return false; } $sql = sprintf('DELETE FROM %s WHERE not_id = %u', $this->db->prefix('xoopsnotifications'), $notification->getVar('not_id')); if (!($result = $this->db->query($sql))) { return false; } return true; }
public function getVar($key, $format = 's') { $return_value = parent::getVar($key, $format); if (XOBJ_DTYPE_ARRAY == $this->vars[$key]['data_type'] && !is_array($return_value)) { // now it's an array $return_value = array(); } return $return_value; }
/** * delete a tplset from the database * * @param XoopsObject|XoopsTplset $tplset a XoopsTplset object * * @return bool true on success, otherwise false **/ public function delete(XoopsObject $tplset) { $className = 'XoopsTplset'; if (!$tplset instanceof $className) { return false; } $sql = sprintf('DELETE FROM %s WHERE tplset_id = %u', $this->db->prefix('tplset'), $tplset->getVar('tplset_id')); if (!($result = $this->db->query($sql))) { return false; } $sql = sprintf('DELETE FROM %s WHERE tplset_name = %s', $this->db->prefix('imgset_tplset_link'), $this->db->quoteString($tplset->getVar('tplset_name'))); $this->db->query($sql); return true; }
/** * returns a specific variable for the object in a proper format * * @access public * @param string $key key of the object's variable to be returned * @param string $format format to use for the output * @return mixed formatted value of the variable */ function &getVar($key, $format = 's') { if ($this->vars[$key]['data_type'] == XOBJ_DTYPE_CUSTOM) { //個別の変数Getがあれば実行; $getMethod = 'getVar_' . $key; if (method_exists($this, $getMethod)) { $this->{$getMethod}($this->vars[$key]['value'], $format); } else { $this->vars[$key]['data_type'] == XOBJ_DTYPE_TXTBOX; $ret =& parent::getVar($key, $format); $this->vars[$key]['data_type'] == XOBJ_DTYPE_CUSTOM; } } else { $ret =& parent::getVar($key, $format); } if ($this->vars[$key]['data_type'] == XOBJ_DTYPE_TXTAREA && ($format == 'e' || $format == 'edit')) { $ret = preg_replace("/&(#[0-9]+;)/i", '&$1', $ret); } return $ret; }
/** * Delete from the database * @param XoopsPrivmessage $pm {@link XoopsPrivmessage} object * @return bool **/ public function delete(XoopsObject $pm) { $className = 'XoopsPrivmessage'; if (!$pm instanceof $className) { return false; } if (!($result = $this->db->query(sprintf('DELETE FROM %s WHERE msg_id = %u', $this->db->prefix('priv_msgs'), $pm->getVar('msg_id'))))) { return false; } return true; }
/** * remove a group from the database * * @param XoopsObject|XoopsGroup $group a group object * * @return bool true on success, otherwise false */ public function delete(XoopsObject $group) { $className = 'XoopsGroup'; if (!$group instanceof $className) { return false; } $sql = sprintf('DELETE FROM %s WHERE groupid = %u', $this->db->prefix('groups'), $group->getVar('groupid')); if (!($result = $this->db->query($sql))) { return false; } return true; }
/** * Delete a {@link XoopsConfigOption} * * @param XoopsObject|XoopsConfigOption $confoption a XoopsConfigOption object * * @return bool true on success, otherwise false */ public function delete(XoopsObject $confoption) { $className = 'XoopsConfigOption'; if (!$confoption instanceof $className) { return false; } $sql = sprintf('DELETE FROM %s WHERE confop_id = %u', $this->db->prefix('configoption'), $confoption->getVar('confop_id')); if (!($result = $this->db->query($sql))) { return false; } return true; }
/** * delete a block from the database * * @param XoopsObject|XoopsBlock $block a XoopsBlock object * * @return bool true on success, otherwise false */ public function delete(XoopsObject $block) { $className = 'XoopsBlock'; if (!$block instanceof $className) { return false; } $id = $block->getVar('bid'); $sql = sprintf('DELETE FROM %s WHERE bid = %u', $this->db->prefix('newblocks'), $id); if (!($result = $this->db->query($sql))) { return false; } $sql = sprintf('DELETE FROM %s WHERE block_id = %u', $this->db->prefix('block_module_link'), $id); $this->db->query($sql); return true; }
function &getVar($key, $format = 's', $blog_id = 0, $contents_mode = false) { if (!($key == 'contents' && $contents_mode)) { return parent::getVar($key, $format); } $contents = parent::getVar($key, $format); return $this->parse_viewmode($contents, $blog_id, $contents_mode, $this->mydirname); }