예제 #1
0
 public function process(Vtiger_Request $request, $widget = NULL)
 {
     $currentUser = Users_Record_Model::getCurrentUserModel();
     $viewer = $this->getViewer($request);
     $moduleName = $request->getModule();
     // Initialize Widget to the right-state of information
     if ($widget && !$request->has('widgetid')) {
         $widgetId = $widget->get('id');
     } else {
         $widgetId = $request->get('widgetid');
     }
     $widget = Vtiger_Widget_Model::getInstanceWithWidgetId($widgetId, $currentUser->getId());
     if (!$request->has('owner')) {
         $owner = Settings_WidgetsManagement_Module_Model::getDefaultUserId($widget);
     } else {
         $owner = $request->get('owner');
     }
     $minilistWidgetModel = new Vtiger_MiniList_Model();
     $minilistWidgetModel->setWidgetModel($widget);
     $viewer->assign('WIDGET', $widget);
     $viewer->assign('MODULE_NAME', $moduleName);
     $viewer->assign('USER', $owner);
     $viewer->assign('CURRENTUSER', $currentUser);
     $viewer->assign('MINILIST_WIDGET_MODEL', $minilistWidgetModel);
     $viewer->assign('BASE_MODULE', $minilistWidgetModel->getTargetModule());
     $viewer->assign('SCRIPTS', $this->getFooterScripts());
     $content = $request->get('content');
     if (!empty($content)) {
         $viewer->view('dashboards/MiniListContents.tpl', $moduleName);
     } else {
         $widget->set('title', $minilistWidgetModel->getTitle());
         $viewer->view('dashboards/MiniList.tpl', $moduleName);
     }
 }
예제 #2
0
 public function process(Vtiger_Request $request, $widget = NULL)
 {
     global $log;
     $log->debug("Entering ./dashboards/MiniList.php::process");
     $currentUser = Users_Record_Model::getCurrentUserModel();
     $viewer = $this->getViewer($request);
     $moduleName = $request->getModule();
     // Initialize Widget to the right-state of information
     if ($widget && !$request->has('widgetid')) {
         $widgetId = $widget->get('id');
     } else {
         $widgetId = $request->get('widgetid');
     }
     $widget = Vtiger_Widget_Model::getInstanceWithWidgetId($widgetId, $currentUser->getId());
     $minilistWidgetModel = new Vtiger_MiniList_Model();
     $minilistWidgetModel->setWidgetModel($widget);
     $viewer->assign('WIDGET', $widget);
     $viewer->assign('MODULE_NAME', $moduleName);
     $viewer->assign('MINILIST_WIDGET_MODEL', $minilistWidgetModel);
     $viewer->assign('BASE_MODULE', $minilistWidgetModel->getTargetModule());
     $viewer->assign('SCRIPTS', $this->getHeaderScripts());
     $content = $request->get('content');
     if (!empty($content)) {
         $viewer->view('dashboards/MiniListContents.tpl', $moduleName);
     } else {
         $widget->set('title', $minilistWidgetModel->getTitle());
         $viewer->view('dashboards/MiniList.tpl', $moduleName);
     }
 }
예제 #3
0
 /**
  * Function returns List of User's selected Dashboard Widgets
  * @return <Array of Vtiger_Widget_Model>
  */
 public function getDashboards($action = 1)
 {
     $db = PearDatabase::getInstance();
     $currentUser = Users_Record_Model::getCurrentUserModel();
     $moduleModel = $this->getModule();
     if ($action == 'Header') {
         $action = 0;
     }
     $sql = " SELECT vtiger_links.*, mdw.userid, mdw.data, mdw.active,  mdw.title, mdw.filterid, mdw.id as widgetid, mdw.position as position, vtiger_links.linkid as id \n\t\t\tFROM vtiger_links \n\t\t\tINNER JOIN vtiger_module_dashboard_widgets mdw ON vtiger_links.linkid = mdw.linkid\n\t\t\tWHERE mdw.userid = ? AND linktype = ? AND tabid = ? AND `active` = ?";
     $params = array($currentUser->getId(), 'DASHBOARDWIDGET', $moduleModel->getId(), $action);
     $result = $db->pquery($sql, $params);
     $widgets = array();
     for ($i = 0, $len = $db->num_rows($result); $i < $len; $i++) {
         $row = $db->query_result_rowdata($result, $i);
         $row['linkid'] = $row['id'];
         if ($row['linklabel'] == 'Mini List') {
             $minilistWidget = Vtiger_Widget_Model::getInstanceFromValues($row);
             $minilistWidgetModel = new Vtiger_MiniList_Model();
             $minilistWidgetModel->setWidgetModel($minilistWidget);
             $minilistWidget->set('title', $minilistWidgetModel->getTitle());
             $widgets[] = $minilistWidget;
         } else {
             $widgets[] = Vtiger_Widget_Model::getInstanceFromValues($row);
         }
     }
     foreach ($widgets as $index => $widget) {
         $label = $widget->get('linklabel');
         $url = $widget->get('linkurl');
         $redex = '/module=(.+?)&+/';
         preg_match($redex, $url, $match);
         if (isPermitted($match[1], 'Index') == 'no') {
             unset($widgets[$index]);
         }
         if ($label == 'Tag Cloud') {
             $isTagCloudExists = getTagCloudView($currentUser->getId());
             if ($isTagCloudExists === 'false') {
                 unset($widgets[$index]);
             }
         }
     }
     return $widgets;
 }
예제 #4
0
 /**
  * Function returns List of User's selected Dashboard Widgets
  * @return <Array of Vtiger_Widget_Model>
  */
 public function getDashboards($action = 1)
 {
     $db = PearDatabase::getInstance();
     $currentUser = Users_Record_Model::getCurrentUserModel();
     $currentUserPrivilegeModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();
     $moduleModel = $this->getModule();
     if ($action == 'Header') {
         $action = 0;
     }
     $sql = " SELECT vtiger_links.*, mdw.userid, mdw.data, mdw.active, mdw.title, mdw.size, mdw.filterid, mdw.id as widgetid, mdw.position as position, vtiger_links.linkid as id, mdw.limit, mdw.owners \n\t\t\tFROM vtiger_links \n\t\t\tINNER JOIN vtiger_module_dashboard_widgets mdw ON vtiger_links.linkid = mdw.linkid\n\t\t\tWHERE mdw.userid = ? AND linktype = ? AND tabid = ? AND `active` = ?";
     $params = array($currentUser->getId(), 'DASHBOARDWIDGET', $moduleModel->getId(), $action);
     $result = $db->pquery($sql, $params);
     $widgets = array();
     for ($i = 0, $len = $db->num_rows($result); $i < $len; $i++) {
         $row = $db->query_result_rowdata($result, $i);
         $row['linkid'] = $row['id'];
         if ($row['linklabel'] == 'Mini List') {
             $minilistWidget = Vtiger_Widget_Model::getInstanceFromValues($row);
             $minilistWidgetModel = new Vtiger_MiniList_Model();
             $minilistWidgetModel->setWidgetModel($minilistWidget);
             $minilistWidget->set('title', $minilistWidgetModel->getTitle());
             $widgets[] = $minilistWidget;
         } else {
             $widgets[] = Vtiger_Widget_Model::getInstanceFromValues($row);
         }
     }
     foreach ($widgets as $index => $widget) {
         $label = $widget->get('linklabel');
         $url = $widget->get('linkurl');
         $data = $widget->get('data');
         $filterid = $widget->get('filterid');
         $module = $this->getModuleNameFromLink($url, $label);
         if ($module == 'Home' && !empty($filterid) && !empty($data)) {
             $filterData = Zend_Json::decode(htmlspecialchars_decode($data));
             $module = $filterData['module'];
         }
         if (!$currentUserPrivilegeModel->hasModulePermission(getTabid($module))) {
             unset($widgets[$index]);
         }
     }
     return $widgets;
 }
예제 #5
0
	/**
	 * Gets all id widgets for the module
	 * @param String $moduleName
	 * @return Array
	 * */
	public function getDashboardForModule($moduleName)
	{
		$log = vglobal('log');
		$log->debug("Entering Settings_WidgetsManagement_Module_Model::getDashboardForModule(" . $moduleName . ") method ...");
		$adb = PearDatabase::getInstance();
		$tabId = getTabid($moduleName);
		$data = array();

		//$data = self::getBlocksId();

		$query = 'SELECT 
				  mdw.blockid,
				  mdw.data,
				  mdw.title,
				  mdw.filterid,
				  mdw.id,
				  mdw.size,
				  mdw.limit,
				  mdw.isdefault,
				  mdw.owners,
				  `vtiger_links`.*,
				  `mdb`.`authorized`
				FROM
				  `vtiger_module_dashboard` AS mdw 
				  INNER JOIN `vtiger_links` 
					ON `mdw`.`linkid` = `vtiger_links`.`linkid` 
				  INNER JOIN `vtiger_module_dashboard_blocks` AS mdb 
					ON (`mdw`.`blockid` = `mdb`.`id` AND `vtiger_links`.`tabid` = `mdb`.`tabid`)
				WHERE `vtiger_links`.`tabid` = ?';
		$params = array($tabId);
		$result = $adb->pquery($query, $params);
		$num = $adb->num_rows($result);
		$userId = '';
		$blockId = '';
		for ($i = 0; $i < $num; $i++) {
			$row = $adb->query_result_rowdata($result, $i);
			if ($row['linklabel'] == 'Mini List') {
				$minilistWidget = Vtiger_Widget_Model::getInstanceFromValues($row);
				$minilistWidgetModel = new Vtiger_MiniList_Model();
				$minilistWidgetModel->setWidgetModel($minilistWidget);
				$minilistWidget->set('title', $minilistWidgetModel->getTitle());
				$data[$row['blockid']][$i] = $minilistWidget;
			} else
				$data[$row['blockid']][$i] = Vtiger_Widget_Model::getInstanceFromValues($row);
		}
		$log->debug("Exiting Settings_WidgetsManagement_Module_Model::getDashboardForModule() method ...");
		return $data;
	}
예제 #6
0
    public static function getInstanceWithWidgetId($widgetId, $userId)
    {
        $db = PearDatabase::getInstance();
        $result = $db->pquery('SELECT * FROM vtiger_module_dashboard_widgets
			INNER JOIN vtiger_links ON vtiger_links.linkid = vtiger_module_dashboard_widgets.linkid
			WHERE linktype = ? AND vtiger_module_dashboard_widgets.id = ? AND userid = ?', array('DASHBOARDWIDGET', $widgetId, $userId));
        $self = new self();
        if ($db->num_rows($result)) {
            $row = $db->query_result_rowdata($result, 0);
            if ($row['linklabel'] == 'Mini List') {
                $minilistWidget = Vtiger_Widget_Model::getInstanceFromValues($row);
                $minilistWidgetModel = new Vtiger_MiniList_Model();
                $minilistWidgetModel->setWidgetModel($minilistWidget);
                $row['title'] = $minilistWidgetModel->getTitle();
            }
            $self->setData($row);
        }
        return $self;
    }