Beispiel #1
0
     $instance_id = (int) $param[$name];
 }
 switch ($request->get('action')) {
     case 'widget':
         if ($name && $layout_id) {
             if ($widget = Widget::getInstance($name)) {
                 if ($widget->isAvailable()) {
                     $action = array_pop(array_keys($param[$name]));
                     switch ($action) {
                         case 'remove':
                             $instance_id = (int) $param[$name][$action];
                             $lm->removeWidget($owner_id, $owner_type, $layout_id, $name, $instance_id, $widget);
                             break;
                         case 'add':
                         default:
                             $lm->addWidget($owner_id, $owner_type, $layout_id, $name, $widget, $request);
                             break;
                     }
                 }
             }
         }
         break;
     case 'minimize':
         if ($name) {
             $lm->mimizeWidget($owner_id, $owner_type, $layout_id, $name, $instance_id);
         }
         break;
     case 'maximize':
         if ($name) {
             $lm->maximizeWidget($owner_id, $owner_type, $layout_id, $name, $instance_id);
         }
 /**
  * Add a projectlink widget on project summary page if not already here
  * 
  * @param Integer $groupId Project id on which the widget is to add
  * 
  * @return void
  */
 function addWidgetOnSummaryPage($groupId)
 {
     include_once 'common/widget/WidgetLayoutManager.class.php';
     $widgetLayoutManager = new WidgetLayoutManager();
     $layoutId = 1;
     // 4.0 only
     // $layoutId = $widgetLayoutManager->getDefaultLayoutId($groupId, $widgetLayoutManager->OWNER_TYPE_GROUP);
     $sql = "SELECT NULL" . " FROM layouts_contents" . " WHERE owner_type = '" . WidgetLayoutManager::OWNER_TYPE_GROUP . "'" . " AND owner_id = " . $groupId . " AND layout_id = " . $layoutId . " AND name = 'projectlinkshomepage'";
     $res = db_query($sql);
     if ($res && db_numrows($res) == 0) {
         include_once 'ProjectLinks_Widget_HomePageLinks.class.php';
         $request = HTTPRequest::instance();
         $widget = new ProjectLinks_Widget_HomePageLinks($this);
         $widgetLayoutManager->addWidget($groupId, WidgetLayoutManager::OWNER_TYPE_GROUP, $layoutId, 'projectlinkshomepage', $widget, $request);
     }
 }