function editrating($showmenu = FALSE, $ratingid = 0) { global $icms_rating_handler, $icmsAdminTpl; icms_cp_header(); $ratingObj = $icms_rating_handler->get($ratingid); if (!$ratingObj->isNew()) { $sform = $ratingObj->getForm(_CO_ICMS_RATINGS_EDIT, 'addrating'); $sform->assign($icmsAdminTpl); $icmsAdminTpl->assign('icms_rating_title', _CO_ICMS_RATINGS_EDIT_INFO); $icmsAdminTpl->display('db:admin/rating/system_adm_rating.html'); } else { $ratingObj->hideFieldFromForm(array('item', 'itemid', 'uid', 'date', 'rate')); if (isset($_POST['op'])) { $controller = new icms_ipf_Controller($icms_rating_handler); $controller->postDataToObject($ratingObj); if ($_POST['op'] == 'changedField') { switch ($_POST['changedField']) { case 'dirname': $ratingObj->showFieldOnForm(array('item', 'itemid', 'uid', 'date', 'rate')); break; } } } $sform = $ratingObj->getForm(_CO_ICMS_RATINGS_CREATE, 'addrating'); $sform->assign($icmsAdminTpl); $icmsAdminTpl->assign('icms_rating_title', _CO_ICMS_RATINGS_CREATE_INFO); $icmsAdminTpl->display('db:admin/rating/system_adm_rating.html'); } }
/** * Generate the form for editing a custom tag * * @param $customtagid unique identifier for the custom tag * @param $clone are you cloning an existing custom tag? */ function editcustomtag($customtagid = 0, $clone = FALSE) { global $icms_customtag_handler, $icmsAdminTpl; icms_cp_header(); $customtagObj = $icms_customtag_handler->get($customtagid); if (isset($_POST["op"]) && $_POST["op"] == "changedField" && in_array($_POST["changedField"], array("customtag_type"))) { $controller = new icms_ipf_Controller($icms_customtag_handler); $controller->postDataToObject($customtagObj); } switch ($customtagObj->getVar("customtag_type")) { case ICMS_CUSTOMTAG_TYPE_XCODES: break; case ICMS_CUSTOMTAG_TYPE_HTML: $customtagObj->setControl("customtag_content", array("name" => "source", "syntax" => "html")); break; case ICMS_CUSTOMTAG_TYPE_PHP: $customtagObj->setControl("customtag_content", array("name" => "source", "syntax" => "php")); break; default: break; } if (!$clone && !$customtagObj->isNew()) { $sform = $customtagObj->getForm(_CO_ICMS_CUSTOMTAG_EDIT, "addcustomtag"); $sform->assign($icmsAdminTpl); $icmsAdminTpl->assign("icms_custom_tag_title", _CO_ICMS_CUSTOMTAG_EDIT_INFO); $icmsAdminTpl->display("db:admin/customtag/system_adm_customtag.html"); } else { $customtagObj->setVar("customtagid", 0); $customtagObj->setVar("tag", ""); $sform = $customtagObj->getForm(_CO_ICMS_CUSTOMTAG_CREATE, "addcustomtag"); $sform->assign($icmsAdminTpl); $icmsAdminTpl->assign("icms_custom_tag_title", _CO_ICMS_CUSTOMTAG_CREATE_INFO); $icmsAdminTpl->display("db:admin/customtag/system_adm_customtag.html"); } }
/** * Edit a block * * @param int $bid ID of block to be edited * @param bool $clone Set to 'TRUE' if the block is being cloned */ function editblock($bid = 0, $clone = FALSE) { global $icms_block_handler, $icmsAdminTpl; $blockObj = $icms_block_handler->get($bid); if (isset($_POST['op']) && $_POST['op'] == 'changedField' && in_array($_POST['changedField'], array('c_type'))) { $controller = new icms_ipf_Controller($icms_block_handler); $controller->postDataToObject($blockObj); } if ($blockObj->getVar("c_type") == "H") { $blockObj->setControl("content", array("name" => "source", "syntax" => "html")); } elseif ($blockObj->getVar("c_type") == "P") { $blockObj->setControl("content", array("name" => "source", "syntax" => "php")); } else { $blockObj->setControl("content", "dhtmltextarea"); } if (!$blockObj->isNew() && $blockObj->getVar('edit_func') != '') $blockObj->showFieldOnForm('options'); if (!$clone && !$blockObj->isNew()) { $sform = $blockObj->getForm(_AM_SYSTEM_BLOCKSADMIN_EDIT, 'addblock'); $sform->assign($icmsAdminTpl); } else { if ($clone) { if ($blockObj->getVar('block_type') != 'C') { $blockObj->setVar('block_type', 'K'); $blockObj->hideFieldFromForm('content'); $blockObj->hideFieldFromForm('c_type'); } $blockObj->setVar('bid', '0'); $blockObj->setNew(); } else { $blockObj->setVar('block_type', 'C'); } $sform = $blockObj->getForm(_AM_SYSTEM_BLOCKSADMIN_CREATE, 'addblock'); $sform->assign($icmsAdminTpl); } $icmsAdminTpl->assign('bid', $bid); $icmsAdminTpl->display('db:admin/blocksadmin/system_adm_blocksadmin.html'); }
if (in_array($clean_op, $valid_op, true)) { switch ($clean_op) { case "clone": icms_cp_header(); editcontent($clean_content_id, true); break; case "mod": icms_cp_header(); editcontent($clean_content_id, false, $clean_content_pid); break; case "addcontent": $controller = new icms_ipf_Controller($content_content_handler); $controller->storeFromDefaultForm(_AM_CONTENT_CONTENT_CREATED, _AM_CONTENT_CONTENT_MODIFIED); break; case "del": $controller = new icms_ipf_Controller($content_content_handler); $controller->handleObjectDeletion(); break; case "view": $contentObj = $content_content_handler->get($clean_content_id); icms_cp_header(); icms::$module->displayAdminMenu(0, _AM_CONTENT_CONTENTS . " > " . _PREVIEW . ' > ' . $contentObj->getVar('content_title')); $icmsAdminTpl->assign('content_content_singleview', $contentObj->displaySingleObject(true, false, array('edit', 'delete'))); $icmsAdminTpl->display('db:content_admin_content.html'); break; case "changedField": foreach ($_POST['mod_content_Content_objects'] as $k => $v) { $changed = false; $obj = $content_content_handler->get($v); if ($obj->getVar('content_status', 'e') != $_POST['content_status'][$k]) { $obj->setVar('content_status', (int) $_POST['content_status'][$k]);
/** * generate delete button * * @staticvar icms_ipf_Controller $controller * @return str linked icon to delete the object */ public function getDeleteButtonForDisplay() { static $controller = null; if ($this->getVar('system') == 1) { return; } if ($controller === null) { $controller = new icms_ipf_Controller($this->handler); } return $controller->getDeleteItemLink($this, false, true, false); }
break; case "addvideos": if (!icms::$security->check()) { redirect_header(icms_getPreviousPage('index.php'), 3, _MD_PROFILE_SECURITY_CHECK_FAILED . implode('<br />', icms::$security->getErrors())); } $controller = new icms_ipf_Controller($profile_videos_handler); $controller->storeFromDefaultForm(_MD_PROFILE_VIDEOS_CREATED, _MD_PROFILE_VIDEOS_MODIFIED, PROFILE_URL . basename(__FILE__)); break; case "del": if (!$videosObj->userCanEditAndDelete()) { redirect_header($videosObj->getItemLink(true), 3, _NOPERM); } if (isset($_POST['confirm']) && !icms::$security->check()) { redirect_header(icms_getPreviousPage('index.php'), 3, _MD_PROFILE_SECURITY_CHECK_FAILED . implode('<br />', icms::$security->getErrors())); } $controller = new icms_ipf_Controller($profile_videos_handler); $controller->handleObjectDeletionFromUserSide(); break; default: $clean_start = isset($_GET['start']) ? (int) $_GET['start'] : 0; if ($real_uid && $real_uid == $uid) { editvideos($videosObj, true); } if ($clean_uid > 0 || $real_uid > 0) { $uid = $clean_uid > 0 ? $clean_uid : $real_uid; $videosArray = $profile_videos_handler->getVideos($clean_start, icms::$module->config['videosperpage'], $clean_uid); if (count($videosArray) == 0) { $icmsTpl->assign('lang_nocontent', _MD_PROFILE_VIDEOS_NOCONTENT); } else { $total_videos_count = $profile_videos_handler->getCount(new icms_db_criteria_Compo(new icms_db_criteria_Item('uid_owner', $uid))); $pagenav = new icms_view_PageNav($total_videos_count, icms::$module->config['videosperpage'], $clean_start, 'start', 'uid=' . $uid);
public function __construct($handler) { parent::__construct($handler); $this->_deprecated = icms_core_Debug::setDeprecated('icms_ipf_Controller', sprintf(_CORE_REMOVE_IN_VERSION, '1.4')); }
/** * Create a row based on the item and children * * @param object $object @link icms_ipf_Object * @param integer $level sub-level of the item */ public function createTableRow($object, $level = 0) { $aObject = array(); $i = 0; $aColumns = array(); $doWeHaveActions = false; foreach ($this->_columns as $column) { $aColumn = array(); if ($i == 0) { $class = "head"; } elseif ($i % 2 == 0) { $class = "even"; } else { $class = "odd"; } if ($column->_customMethodForValue && method_exists($object, $column->_customMethodForValue)) { $method = $column->_customMethodForValue; $value = $object->{$method}(); } else { /** * If the column is the identifier, then put a link on it */ if ($column->getKeyName() == $this->_objectHandler->identifierName) { $value = $object->getItemLink(); } else { $value = $object->getVar($column->getKeyName()); } } $space = ''; if ($column->getKeyName() == $this->_objectHandler->identifierName) { for ($i = 0; $i < $level; $i++) { $space = $space . '--'; } } if ($space != '') { $space .= ' '; } $aColumn['value'] = $space . $value; $aColumn['class'] = $class; $aColumn['width'] = $column->getWidth(); $aColumn['align'] = $column->getAlign(); $aColumn['key'] = $column->getKeyName(); $aColumns[] = $aColumn; $i++; } $aObject['columns'] = $aColumns; $class = $class == 'even' ? 'odd' : 'even'; $aObject['class'] = $class; $actions = array(); // Adding the custom actions if any foreach ($this->_custom_actions as $action) { if (method_exists($object, $action)) { $actions[] = $object->{$action}(); } } $controller = new icms_ipf_Controller($this->_objectHandler); if (in_array('edit', $this->_actions)) { $actions[] = $controller->getEditItemLink($object, false, true); } if (in_array('delete', $this->_actions)) { $actions[] = $controller->getDeleteItemLink($object, false, true); } $aObject['actions'] = $actions; $this->_tpl->assign('icms_actions_column_width', count($actions) * 30); $aObject['id'] = $object->id(); $this->_aObjects[] = $aObject; $childrenObjects = $this->getChildrenOf($object->id()); $this->_hasActions = $this->_hasActions ? true : count($actions) > 0; if ($childrenObjects) { $level++; foreach ($childrenObjects as $subObject) { $this->createTableRow($subObject, $level); } } }
switch ($clean_op) { case "suspend": if (empty($clean_uid) || !$profile_isAdmin) { redirect_header(icms_getPreviousPage('index.php'), 3, _NOPERM); } editconfigs($configsObj, $clean_uid); break; case "addconfigs": if (!icms::$security->check()) { redirect_header(icms_getPreviousPage('index.php'), 3, _MD_PROFILE_SECURITY_CHECK_FAILED . implode('<br />', icms::$security->getErrors())); } //check if current user is allowed to perform this action if ($real_uid == 0 || $real_uid != (int) $_POST['config_uid'] && !$profile_isAdmin) { redirect_header(icms_getPreviousPage('index.php'), 3, _NOPERM); } $controller = new icms_ipf_Controller($profile_configs_handler); $controller->storeFromDefaultForm(_MD_PROFILE_CONFIGS_CREATED, _MD_PROFILE_CONFIGS_MODIFIED, PROFILE_URL); break; default: if ($real_uid > 0 && icms::$user->getVar('uid') == $clean_uid) { editconfigs($configsObj); } elseif ($profile_isAdmin && $clean_uid > 0) { $configsObj = $profile_configs_handler->getConfigPerUser($clean_uid, true); editconfigs($configsObj, $clean_uid); } else { redirect_header(icms_getPreviousPage('index.php'), 3, _NOPERM); } break; } } $icmsTpl->assign('profile_category_path', _MD_PROFILE_CONFIGS);
/** * */ public function getPrintAndMailLink() { $controller = new icms_ipf_Controller($this->handler); return $controller->getPrintAndMailLink($this); }
} // Again, use a naming convention that indicates the source of the content of the variable $clean_friendship_id = isset($_GET['friendship_id']) ? (int) $_GET['friendship_id'] : 0; $profile_friendship_handler = icms_getModuleHandler('friendship', basename(dirname(__FILE__)), 'profile'); /* Create a whitelist of valid values, be sure to use appropriate types for each value * Be sure to include a value for no parameter, if you have a default condition */ $valid_op = array('addfriendship', 'editfriendship', ''); // Only proceed if the supplied operation is a valid operation if (in_array($clean_op, $valid_op, true) && is_object(icms::$user)) { switch ($clean_op) { case "addfriendship": $uid = (int) filter_input(INPUT_POST, 'friend2_uid'); if (!icms::$security->check()) { redirect_header(icms_getPreviousPage('index.php'), 3, _MD_PROFILE_SECURITY_CHECK_FAILED . implode('<br />', icms::$security->getErrors())); } $controller = new icms_ipf_Controller($profile_friendship_handler); $controller->storeFromDefaultForm(_MD_PROFILE_FRIENDSHIP_CREATED, _MD_PROFILE_FRIENDSHIP_MODIFIED, PROFILE_URL . "/index.php?uid=" . $uid); break; case "editfriendship": if (!icms::$security->check()) { redirect_header(icms_getPreviousPage('index.php'), 3, _MD_PROFILE_SECURITY_CHECK_FAILED . implode('<br />', icms::$security->getErrors())); } $clean_friendship_id = isset($_POST['friendship_id']) ? (int) $_POST['friendship_id'] : 0; $friendshipObj = $profile_friendship_handler->get($clean_friendship_id); if (!$friendshipObj->isNew() && $friendshipObj->getVar('friend2_uid') == $uid) { $clean_status = isset($_POST['status']) ? (int) $_POST['status'] : ''; $valid_status = array(PROFILE_FRIENDSHIP_STATUS_ACCEPTED, PROFILE_FRIENDSHIP_STATUS_REJECTED); if (in_array($clean_status, $valid_status, true)) { $friendshipObj->setVar('status', $clean_status); $friendshipObj->store(true); if (strpos(icms_getPreviousPage(), $friendshipObj->handler->_moduleUrl . $friendshipObj->handler->_page) !== false) {
/** * Determine if the user can delete the task and display a button * @return mixed */ public function getDeleteButtonForDisplay() { static $controller = NULL; if ($this->getType(0) == 'addon') return; if ($controller === NULL) $controller = new icms_ipf_Controller($this->handler); return $controller->getDeleteItemLink($this, FALSE, TRUE, FALSE); }
/** * Create the complete path of a category * * @todo this could be improved as it uses multiple queries * @param bool $withAllLink make all name clickable * @return string complete path (breadcrumb) */ public function getCategoryPath($withAllLink = true, $currentCategory = false) { $controller = new icms_ipf_Controller($this->handler); if (!$this->_categoryPath) { if ($withAllLink && !$currentCategory) { $ret = $controller->getItemLink($this); } else { $currentCategory = false; $ret = $this->getVar('name'); } $parentid = $this->getVar('parentid'); if ($parentid != 0) { $parentObj =& $this->handler->get($parentid); if ($parentObj->isNew()) { exit; } $parentid = $parentObj->getVar('parentid'); $ret = $parentObj->getCategoryPath($withAllLink, $currentCategory) . " > " . $ret; } $this->_categoryPath = $ret; } return $this->_categoryPath; }