CoolFace
Apppublic

kenken999/php

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
memberspage_ad.php211 linesDownload Raw Back to classes
1<?php2/**3 * Class for display members_list with Active directory data4 */5class MembersPage_AD extends ListPage_Lookup6{7	var $resultData = array();8 9	var $strFilterClause = '';  //? 10 11	var $issetRecords = array();12 13	var $recNumber = 1;14 15 16	var $plugin = null;17 18	var $providerCode = "";19 20 21 22	function __construct($params)23	{24		ListPage_Embed::__construct($params);25 26		$this->issetRecords = $this->getDBMembers();27		28		$this->headerForms = array( "top" );29		$this->footerForms = array( "below-grid" );30		$this->pageData["provider"] = $params["providerCode"];31		$this->plugin = Security::getAuthPlugin( $params["providerCode"] );32		$this->pageSize = 10;33	}34 35	/**36	 *37	 */38	function getDBMembers()39	{40		$dc = new DsCommand();41		$dataSource = Security::getUgGroupsDatasource();42		43		if( !Security::ADonlyLogin() || storageGet( "groups_provider_field" ) ) {44			$dc->filter = DataCondition::FieldEquals( "Provider", $this->providerCode );45		}46		47		$qResult = $dataSource->getList( $dc );48		49		$members = array();50		while( $tdata = $qResult->fetchAssoc() )51		{52			$members[] = $tdata[ "Label" ];53		}54 55		return $members;56	}57 58	function isIssetRecord($name)59	{60		if (!in_array($name,$this->issetRecords))61			return true;62		return false;63	}64	/**65	 * Common assign for diferent mode on list page66	 * Branch classes add to this method its individualy code67	 */68	function commonAssign()69	{70		parent::commonAssign();71		$this->xt->assign("add_link", true);72		$this->xt->assign("addselectlink_attrs","id = \"addSelBtn\" ");73		$this->xt->assign("recordcontrolsad_block",true);74		$this->xt->assign("checkbox_header", true);75		76		$this->xt->assign("checkboxheader_attrs", "id=\"chooseAll_".$this->id."\" data-checked=\"0\"");77	}78 79	/**80	 * Checks if need to display grid81	 */82	function isDispGrid()83	{84		return true;85	}86 87	/**88	 * Calcs pagination info89	 */90	function buildPagination()91	{92		parent::buildPagination();93		$this->recNumber = $this->pageSize * ($this->myPage - 1);94	}95 96	/**97	 * Seeks recs, depending on page number etc.98	 * @param string $strSQL99	 */100	function seekPageInRecSet() {101		$this->resultData = $this->plugin->getGroupList( 102				$this->searchClauseObj->getAllFieldsSearchValue(), 103				$this->pSet->hideAdGroupsUntilSearch() 104			);105		106		$this->numRowsFromSQL = $this->resultData ? count( $this->resultData ) : 0;107		$this->recSet = $this->numRowsFromSQL;108	}109 110	function beforeProccessRow()111	{112		if( $this->recNumber <= $this->pageSize * $this->myPage - 1 113			&& $this->recNumber <= $this->numRowsFromSQL - 1 )114		{115			return $this->resultData[ $this->recNumber ];116		}117		118		return false;119	}120 121	function fillGridData()122	{123		$rowInfo = array();	124		$data = $this->beforeProccessRow();125		$this->controlsMap['gridRows'] = array();126 127		while( $data )128		{129			$row = array();130			$row["rowattrs"] = " id=\"gridRow".$this->recNumber."\"";131 132			$gridRowInd = count($this->controlsMap['gridRows']);133			$this->controlsMap['gridRows'][ $gridRowInd ]['id'] = $this->recNumber;134			$this->controlsMap['gridRows'][ $gridRowInd ]['rowInd'] = $gridRowInd;135			$this->controlsMap['gridRows'][ $gridRowInd ]['keys'] = array('name' => $data["name"]);136 137			$row["grid_record"] = array();138			$row["grid_record"]["data"] = array();139 140			$row["add_link"] = $this->isIssetRecord($data["name"]);141			$row["checkbox"] = $this->isIssetRecord($data["name"]);142 143			$row["addlink_attrs"] = "href='#' id='iAddLink".$this->recNumber."' ";144			$row["checkbox_attrs"] = "name=\"selection[]\" value=\"".$this->recNumber."\" 145				id=\"check".$this->id."_".$this->recNumber."\" data-checked=\"0\"";146			147			$row["username"] = runner_htmlspecialchars($data["name"]);148			$row["displayusername"] = runner_htmlspecialchars($data["displayname"]);149			$row["categoryuser"] = runner_htmlspecialchars($data["category"]);150			$row["emailuser"] = runner_htmlspecialchars($data["email"]);151			$row["recNo"] = $this->recNumber;152			$this->recNumber++;153 154			if($this->eventExists("BeforeMoveNextList"))155				$this->eventsObject->BeforeMoveNextList($data, $row, $record,$record["recId"], $this);156 157			$rowInfo[] = $row;158 159			$data = $this->beforeProccessRow();160		}161 162		// assign grid rows163		$this->xt->assign_loopsection("grid_row", $rowInfo);164	}165 166	function prepareForBuildPage()167	{168		//Sorting fields169		$this->buildOrderParams();170 171 172		$this->strFilterClause = $this->searchClauseObj->_where[ "_simpleSrch" ];173		$this->seekPageInRecSet();174 175		// build pagination block176		$this->buildPagination();177 178		$this->fillGridData();179		$this->assignSimpleSearch();180 181		$this->addCommonJs();182		$this->addCommonHtml();183		$this->commonAssign();184		185		$this->assignColumnHeaderClasses();		186	}187 188	function showPage()189	{190		$this->BeforeShowList();191 192		$this->xt->prepare_template( $this->templatefile );193		$this->showPageAjax();194		195		exit(); // .net compatibility issue196	}197	198	function inlineAddAvailable() 199	{200		return false;201	}202	203	function noRecordsMessage() {204		if( $this->pSet->hideAdGroupsUntilSearch() && !$this->isSearchFunctionalityActivated() ) {205			return "Nothing to see. Run some search.";206		}207 208		return parent::noRecordsMessage();209	}210}211?>