コード例 #1
0
ファイル: menu.php プロジェクト: kosmosby/medicine-prof
	/**
	 * @param cbautoactionsActionTable $trigger
	 * @param UserTable $user
	 */
	public function execute( $trigger, $user )
	{
		foreach ( $trigger->getParams()->subTree( 'menu' ) as $row ) {
			/** @var ParamsInterface $row */
			$menuTitle				=	$trigger->getSubstituteString( $row->get( 'title', null, GetterInterface::STRING ) );

			if ( ! $menuTitle ) {
				if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
					var_dump( CBTxt::T( 'AUTO_ACTION_MENU_NO_TITLE', ':: Action [action] :: CB Menu skipped due to missing title', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
				}

				continue;
			}

			$menuType				=	$trigger->getSubstituteString( $row->get( 'type', null, GetterInterface::STRING ), true, false );
			$menuClass				=	$trigger->getSubstituteString( $row->get( 'class', null, GetterInterface::STRING ), true, false );
			$menuTarget				=	$row->get( 'target', null, GetterInterface::STRING );
			$menuImg				=	$trigger->getSubstituteString( $row->get( 'image', null, GetterInterface::STRING ), false );

			$menuItem				=	array();
			$menuItem['arrayPos']	=	array( $menuType => array( $menuClass => null ) );
			$menuItem['position']	=	$row->get( 'position', 'menuBar', GetterInterface::STRING );
			$menuItem['caption']	=	htmlspecialchars( $menuTitle );
			$menuItem['url']		=	$trigger->getSubstituteString( $row->get( 'url', null, GetterInterface::STRING ), false );
			$menuItem['target']		=	( $menuTarget ? htmlspecialchars( $menuTarget ) : null );
			$menuItem['img']		=	( $menuImg ? ( $menuImg[0] == '<' ? $menuImg : '<img src="' . htmlspecialchars( $menuImg ) . '" />' ) : null );
			$menuItem['tooltip']	=	htmlspecialchars( $trigger->getSubstituteString( $row->get( 'tooltip', null, GetterInterface::STRING ), false ) );

			$this->addMenu( $menuItem );
		}
	}
コード例 #2
0
	/**
	 * @param cbautoactionsActionTable $trigger
	 * @param UserTable $user
	 */
	public function execute( $trigger, $user )
	{
		$params					=	$trigger->getParams()->subTree( 'loginlogout' );

		cbimport( 'cb.authentication' );

		$cbAuthenticate			=	new CBAuthentication();

		$isHttps				=	( isset( $_SERVER['HTTPS'] ) && ( ! empty( $_SERVER['HTTPS'] ) ) && ( $_SERVER['HTTPS'] != 'off' ) );
		$returnUrl				=	'http' . ( $isHttps ? 's' : '' ) . '://' . $_SERVER['HTTP_HOST'];

		if ( ( ! empty( $_SERVER['PHP_SELF'] ) ) && ( ! empty( $_SERVER['REQUEST_URI'] ) ) ) {
			$returnUrl			.=	$_SERVER['REQUEST_URI'];
		} else {
			$returnUrl			.=	$_SERVER['SCRIPT_NAME'];

			if ( isset( $_SERVER['QUERY_STRING'] ) && ( ! empty( $_SERVER['QUERY_STRING'] ) ) ) {
				$returnUrl		.=	'?' . $_SERVER['QUERY_STRING'];
			}
		}

		$returnUrl				=	cbUnHtmlspecialchars( preg_replace( '/[\\\"\\\'][\\s]*javascript:(.*)[\\\"\\\']/', '""', preg_replace( '/eval\((.*)\)/', '', htmlspecialchars( urldecode( $returnUrl ) ) ) ) );

		if ( preg_match( '/index.php\?option=com_comprofiler&task=confirm&confirmCode=|index.php\?option=com_comprofiler&view=confirm&confirmCode=|index.php\?option=com_comprofiler&task=login|index.php\?option=com_comprofiler&view=login/', $returnUrl ) ) {
			$returnUrl			=	'index.php';
		}

		$redirect				=	$trigger->getSubstituteString( $params->get( 'redirect', null, GetterInterface::STRING ), array( 'cbautoactionsClass', 'escapeURL' ) );

		if ( $redirect ) {
			$returnUrl			=	$redirect;
		}

		$message				=	$trigger->getSubstituteString( CBTxt::T( $params->get( 'message', null, GetterInterface::RAW ) ), false );

		if ( $params->get( 'mode', 1, GetterInterface::BOOLEAN ) ) {
			$messagesToUser		=	array();
			$alertMessages		=	array();

			if ( $params->get( 'method', 1, GetterInterface::BOOLEAN ) ) {
				$credentials	=	$trigger->getSubstituteString( $params->get( 'username', null, GetterInterface::STRING ) );
				$method			=	0;
			} else {
				$credentials	=	$trigger->getSubstituteString( $params->get( 'email', null, GetterInterface::STRING ) );
				$method			=	1;
			}

			$resultError		=	$cbAuthenticate->login( $credentials, false, 0, 1, $returnUrl, $messagesToUser, $alertMessages, $method );

			if ( $redirect ) {
				cbRedirect( $redirect, ( $resultError ? $resultError : ( $message ? $message : ( $alertMessages ? stripslashes( implode( '<br />', $alertMessages ) ) : null ) ) ), ( $resultError ? 'error' : 'message' ) );
			}
		} else {
			$resultError		=	$cbAuthenticate->logout( $returnUrl );

			if ( $redirect ) {
				cbRedirect( $redirect, ( $resultError ? $resultError : ( $message ? $message : CBTxt::T( 'LOGOUT_SUCCESS', 'You have successfully logged out' ) ) ), ( $resultError ? 'error' : 'message' ) );
			}
		}
	}
コード例 #3
0
ファイル: action.php プロジェクト: kosmosby/medicine-prof
	/**
	 * @param cbautoactionsActionTable $trigger
	 * @param UserTable $user
	 * @return mixed
	 */
	public function execute( $trigger, $user )
	{
		$params					=	$trigger->getParams()->subTree( 'action' );
		$actions				=	$params->get( 'actions' );
		$return					=	null;

		if ( $actions ) {
			$actions			=	explode( '|*|', $actions );

			cbArrayToInts( $actions );

			foreach ( $actions as $actionId ) {
				$action			=	new cbautoactionsActionTable();

				if ( $action->load( $actionId ) ) {
					$return		.=	cbautoactionsClass::triggerAction( $action, $user, $trigger->get( '_password' ), $trigger->get( '_extras' ), $trigger->get( '_vars' ) );
				}
			}
		}

		return $return;
	}
コード例 #4
0
ファイル: privacy.php プロジェクト: kosmosby/medicine-prof
	/**
	 * @param cbautoactionsActionTable $trigger
	 * @param UserTable $user
	 */
	public function execute( $trigger, $user )
	{
		if ( ! $this->installed() ) {
			if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
				var_dump( CBTxt::T( 'AUTO_ACTION_PRIVACY_NOT_INSTALLED', ':: Action [action] :: CB Privacy is not installed', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
			}

			return;
		}

		foreach ( $trigger->getParams()->subTree( 'privacy' ) as $row ) {
			/** @var ParamsInterface $row */
			$owner						=	$row->get( 'owner', null, GetterInterface::STRING );

			if ( ! $owner ) {
				$owner					=	(int) $user->get( 'id' );
			} else {
				$owner					=	(int) $trigger->getSubstituteString( $owner );
			}

			if ( ! $owner ) {
				if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
					var_dump( CBTxt::T( 'AUTO_ACTION_PRIVACY_NO_OWNER', ':: Action [action] :: CB Privacy skipped due to missing owner', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
				}

				continue;
			}

			$type						=	$trigger->getSubstituteString( $row->get( 'type', null, GetterInterface::STRING ) );

			if ( ! $type ) {
				if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
					var_dump( CBTxt::T( 'AUTO_ACTION_PRIVACY_NO_TYPE', ':: Action [action] :: CB Privacy skipped due to missing type', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
				}

				continue;
			}

			$rule						=	$row->get( 'rule', null, GetterInterface::STRING );

			if ( ! $rule ) {
				if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
					var_dump( CBTxt::T( 'AUTO_ACTION_PRIVACY_NO_RULE', ':: Action [action] :: CB Privacy skipped due to missing rule', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
				}

				continue;
			}

			$subtype					=	$trigger->getSubstituteString( $row->get( 'subtype', null, GetterInterface::STRING ) );
			$item						=	$trigger->getSubstituteString( $row->get( 'item', null, GetterInterface::STRING ) );

			$privacy					=	new cbprivacyPrivacyTable();

			if ( $item && $row->get( 'load', true, GetterInterface::BOOLEAN ) ) {
				$load					=	array( 'user_id' => $owner, 'type' => $type, 'item' => $item );

				if ( $subtype ) {
					$load['subtype']	=	$subtype;
				}

				$privacy->load( $load );
			}

			$privacy->set( 'user_id', $user );
			$privacy->set( 'type', $type );

			if ( $subtype ) {
				$privacy->set( 'subtype', $subtype );
			}

			if ( $item ) {
				$privacy->set( 'item', $item );
			}

			$privacy->set( 'rule', implode( '|*|', cbprivacyClass::validatePrivacy( $rule ) ) );

			if ( ! $privacy->store() ) {
				if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
					var_dump( CBTxt::T( 'AUTO_ACTION_PRIVACY_FAILED', ':: Action [action] :: CB Privacy failed to save. Error: [error]', array( '[action]' => (int) $trigger->get( 'id' ), '[error]' => $privacy->getError() ) ) );
				}
			}
		}
	}
コード例 #5
0
ファイル: invite.php プロジェクト: kosmosby/medicine-prof
	/**
	 * @param cbautoactionsActionTable $trigger
	 * @param UserTable $user
	 */
	public function execute( $trigger, $user )
	{
		global $_CB_database;

		if ( ! $this->installed() ) {
			if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
				var_dump( CBTxt::T( 'AUTO_ACTION_INVITE_NOT_INSTALLED', ':: Action [action] :: CB Invites is not installed', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
			}

			return;
		}

		foreach ( $trigger->getParams()->subTree( 'invite' ) as $row ) {
			/** @var ParamsInterface $row */
			$owner					=	$row->get( 'owner', null, GetterInterface::STRING );

			if ( ! $owner ) {
				$owner				=	(int) $user->get( 'id' );
			} else {
				$owner				=	(int) $trigger->getSubstituteString( $owner );
			}

			if ( ! $owner ) {
				if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
					var_dump( CBTxt::T( 'AUTO_ACTION_INVITE_NO_OWNER', ':: Action [action] :: CB Invites skipped due to missing owner', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
				}

				continue;
			}

			if ( $user->get( 'id' ) != $owner ) {
				$user				=	CBuser::getUserDataInstance( $owner );
			}

			switch ( (int) cbGetParam( $params, 'invite_mode', 1 ) ) {
				case 1:
					$invite			=	new cbinvitesInviteTable();

					$toArray		=	explode( ',', $trigger->getSubstituteString( $row->get( 'to', null, GetterInterface::STRING ) ) );

					foreach ( $toArray as $to ) {
						$invite->set( 'id', null );
						$invite->set( 'to', $to );
						$invite->set( 'subject', $trigger->getSubstituteString( $row->get( 'subject', null, GetterInterface::STRING ) ) );
						$invite->set( 'body', $trigger->getSubstituteString( $row->get( 'body', null, GetterInterface::RAW ) ) );
						$invite->set( 'user_id', $owner );
						$invite->set( 'code', md5( uniqid() ) );

						if ( ! $invite->store() ) {
							if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
								var_dump( CBTxt::T( 'AUTO_ACTION_INVITE_FAILED', ':: Action [action] :: CB Invites failed to save. Error: [error]', array( '[action]' => (int) $trigger->get( 'id' ), '[error]' => $invite->getError() ) ) );
							}

							continue;
						}

						if ( ! $invite->send() ) {
							if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
								var_dump( CBTxt::T( 'AUTO_ACTION_INVITE_SEND_FAILED', ':: Action [action] :: CB Invites failed to send. Error: [error]', array( '[action]' => (int) $trigger->get( 'id' ), '[error]' => $invite->getError() ) ) );
							}

							continue;
						}
					}
					break;
				case 2:
					$query			=	'SELECT *'
									.	"\n FROM " . $_CB_database->NameQuote( '#__comprofiler_plugin_invites' )
									.	"\n WHERE " . $_CB_database->NameQuote( 'to' ) . " = " . $_CB_database->Quote( $user->get( 'email' ) );
					$_CB_database->setQuery( $query );
					$invites		=	$_CB_database->loadObjectList( null, 'cbinvitesInviteTable', array( $_CB_database ) );

					/** @var cbinvitesInviteTable[] $invites */
					foreach ( $invites as $invite ) {
						$invite->accept( $user );
					}
					break;
				case 3:
					$query			=	'SELECT *'
									.	"\n FROM " . $_CB_database->NameQuote( '#__comprofiler_plugin_invites' )
									.	"\n WHERE ( " . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $user->get( 'id' )
									.	' OR ' . $_CB_database->NameQuote( 'user' ) . ' = ' . (int) $user->get( 'id' ) . ' )';
					$_CB_database->setQuery( $query );
					$invites		=	$_CB_database->loadObjectList( null, 'cbinvitesInviteTable', array( $_CB_database ) );

					/** @var cbinvitesInviteTable[] $invites */
					foreach ( $invites as $invite ) {
						$invite->delete();
					}
					break;
			}
		}
	}
コード例 #6
0
ファイル: groupjive.php プロジェクト: kosmosby/medicine-prof
	/**
	 * @param cbautoactionsActionTable $trigger
	 * @param UserTable $user
	 */
	public function execute( $trigger, $user )
	{
		global $_CB_database;

		if ( ! $this->installed() ) {
			if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
				var_dump( CBTxt::T( 'AUTO_ACTION_GROUPJIVE_NOT_INSTALLED', ':: Action [action] :: CB GroupJive is not installed', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
			}

			return;
		}

		foreach ( $trigger->getParams()->subTree( 'groupjive' ) as $row ) {
			/** @var ParamsInterface $row */
			switch( (int) $row->get( 'mode', 1, GetterInterface::INT ) ) {
				case 3:
					$owner							=	$row->get( 'owner', null, GetterInterface::STRING );

					if ( ! $owner ) {
						$owner						=	(int) $user->get( 'id' );
					} else {
						$owner						=	(int) $trigger->getSubstituteString( $owner );
					}

					if ( ! $owner ) {
						if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
							var_dump( CBTxt::T( 'AUTO_ACTION_GROUPJIVE_NO_OWNER', ':: Action [action] :: CB GroupJive skipped due to missing owner', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
						}

						continue;
					}

					$name							=	$trigger->getSubstituteString( $row->get( 'name', null, GetterInterface::STRING ) );

					if ( ! $name ) {
						if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
							var_dump( CBTxt::T( 'AUTO_ACTION_GROUPJIVE_NO_NAME', ':: Action [action] :: CB GroupJive skipped due to missing name', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
						}

						continue;
					}

					$category						=	new CategoryTable();

					$category->load( array( 'name' => $name ) );

					if ( ! $category->get( 'id' ) ) {
						if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
							var_dump( CBTxt::T( 'AUTO_ACTION_GROUPJIVE_NO_CATEGORY', ':: Action [action] :: CB GroupJive skipped due to missing category', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
						}

						continue;
					}

					$category->set( 'published', 1 );
					$category->set( 'user_id', $owner );
					$category->set( 'name', $name );
					$category->set( 'description', $trigger->getSubstituteString( $row->get( 'description', null, GetterInterface::STRING ) ) );
					$category->set( 'access', 1 );
					$category->set( 'create_access', 0 );
					$category->set( 'types', $row->get( 'types', '1|*|2|*|3', GetterInterface::STRING ) );
					$category->set( 'ordering', 1 );

					if ( ! $category->store() ) {
						if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
							var_dump( CBTxt::T( 'AUTO_ACTION_GROUPJIVE_FAILED', ':: Action [action] :: CB GroupJive failed to save. Error: [error]', array( '[action]' => (int) $trigger->get( 'id' ), '[error]' => $category->getError() ) ) );

							continue;
						}
					}
					break;
				case 2:
					$owner							=	$row->get( 'owner', null, GetterInterface::STRING );

					if ( ! $owner ) {
						$owner						=	(int) $user->get( 'id' );
					} else {
						$owner						=	(int) $trigger->getSubstituteString( $owner );
					}

					if ( ! $owner ) {
						if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
							var_dump( CBTxt::T( 'AUTO_ACTION_GROUPJIVE_NO_OWNER', ':: Action [action] :: CB GroupJive skipped due to missing owner', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
						}

						continue;
					}

					$categoryId						=	(int) $row->get( 'category', -1, GetterInterface::INT );

					$category						=	new CategoryTable();

					if ( $categoryId == -1 ) {
						$name						=	$trigger->getSubstituteString( $row->get( 'category_name', null, GetterInterface::STRING ) );

						if ( ! $name ) {
							if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
								var_dump( CBTxt::T( 'AUTO_ACTION_GROUPJIVE_NO_CAT_NAME', ':: Action [action] :: CB GroupJive skipped due to missing category name', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
							}

							continue;
						}

						$category->load( array( 'name' => $name ) );

						if ( ! $category->get( 'id' ) ) {
							$category->set( 'published', 1 );
							$category->set( 'user_id', $owner );
							$category->set( 'name', $name );
							$category->set( 'description', $trigger->getSubstituteString( $row->get( 'category_description', null, GetterInterface::STRING ) ) );
							$category->set( 'access', 1 );
							$category->set( 'create_access', 0 );
							$category->set( 'types', $row->get( 'category_types', '1|*|2|*|3', GetterInterface::STRING ) );
							$category->set( 'ordering', 1 );

							if ( ! $category->store() ) {
								if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
									var_dump( CBTxt::T( 'AUTO_ACTION_GROUPJIVE_FAILED', ':: Action [action] :: CB GroupJive failed to save. Error: [error]', array( '[action]' => (int) $trigger->get( 'id' ), '[error]' => $category->getError() ) ) );
								}

								continue;
							}
						}
					} else {
						$category->load( (int) $categoryId );
					}

					if ( ! $category->get( 'id' ) ) {
						if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
							var_dump( CBTxt::T( 'AUTO_ACTION_GROUPJIVE_NO_CATEGORY', ':: Action [action] :: CB GroupJive skipped due to missing category', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
						}

						continue;
					}

					$name							=	$trigger->getSubstituteString( $row->get( 'name', null, GetterInterface::STRING ) );

					if ( ! $name ) {
						if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
							var_dump( CBTxt::T( 'AUTO_ACTION_GROUPJIVE_NO_NAME', ':: Action [action] :: CB GroupJive skipped due to missing name', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
						}

						continue;
					}

					$group							=	new GroupTable();
					$join							=	false;

					if ( $row->get( 'unique', 1, GetterInterface::BOOLEAN ) ) {
						$group->load( array( 'category' => (int) $category->get( 'id' ), 'user_id' => (int) $owner, 'name' => $name ) );
					} else {
						$group->load( array( 'category' => (int) $category->get( 'id' ), 'name' => $name ) );

						if ( $row->get( 'autojoin', 1, GetterInterface::BOOLEAN ) ) {
							$join					=	true;
						}
					}

					if ( ! $group->get( 'id' ) ) {
						$group->set( 'published', 1 );
						$group->set( 'category', (int) $category->get( 'id' ) );
						$group->set( 'user_id', $owner );
						$group->set( 'name', $name );
						$group->set( 'description', $trigger->getSubstituteString( $row->get( 'description', null, GetterInterface::STRING ) ) );
						$group->set( 'types', (int) $row->get( 'type', 1, GetterInterface::INT ) );
						$group->set( 'ordering', 1 );

						if ( ! $group->store() ) {
							if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
								var_dump( CBTxt::T( 'AUTO_ACTION_GROUPJIVE_FAILED', ':: Action [action] :: CB GroupJive failed to save. Error: [error]', array( '[action]' => (int) $trigger->get( 'id' ), '[error]' => $group->getError() ) ) );
							}

							continue;
						}
					} elseif ( $join ) {
						$groupUser					=	new \CB\Plugin\GroupJive\Table\UserTable( $_CB_database );

						$groupUser->load( array( 'group' => (int) $group->get( 'id' ), 'user_id' => (int) $user->get( 'id' ) ) );

						if ( ! $groupUser->get( 'id' ) ) {
							$groupUser->set( 'user_id', (int) $user->get( 'id' ) );
							$groupUser->set( 'group', (int) $group->get( 'id' ) );
							$groupUser->set( 'status', (int) $row->get( 'group_status', 1, GetterInterface::INT ) );

							if ( ! $groupUser->store() ) {
								if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
									var_dump( CBTxt::T( 'AUTO_ACTION_GROUPJIVE_FAILED', ':: Action [action] :: CB GroupJive failed to save. Error: [error]', array( '[action]' => (int) $trigger->get( 'id' ), '[error]' => $groupUser->getError() ) ) );
								}

								continue;
							}
						}
					}
					break;
				case 4:
					$groups							=	$row->get( 'groups', null, GetterInterface::STRING );

					if ( $groups ) {
						$groups						=	explode( '|*|', $groups );

						cbArrayToInts( $groups );

						foreach ( $groups as $groupId ) {
							$group					=	new GroupTable();

							$group->load( (int) $groupId );

							if ( $group->get( 'id' ) ) {
								$groupUser			=	new \CB\Plugin\GroupJive\Table\UserTable( $_CB_database );

								$groupUser->load( array( 'group' => (int) $group->get( 'id' ), 'user_id' => (int) $user->get( 'id' ) ) );

								if ( $groupUser->get( 'id' ) && ( $groupUser->get( 'status' ) != 4 ) ) {
									$groupUser->delete();
								}
							}
						}
					}
					break;
				case 1:
				default:
					$groups							=	$row->get( 'groups', null, GetterInterface::STRING );

					if ( $groups ) {
						$groups						=	explode( '|*|', $groups );

						cbArrayToInts( $groups );

						foreach ( $groups as $groupId ) {
							$group					=	new GroupTable();

							$group->load( (int) $groupId );

							if ( $group->get( 'id' ) ) {
								$groupUser			=	new \CB\Plugin\GroupJive\Table\UserTable( $_CB_database );

								$groupUser->load( array( 'group' => (int) $group->get( 'id' ), 'user_id' => (int) $user->get( 'id' ) ) );

								if ( ! $groupUser->get( 'id' ) ) {
									$groupUser->set( 'user_id', (int) $user->get( 'id' ) );
									$groupUser->set( 'group', (int) $group->get( 'id' ) );
									$groupUser->set( 'status', (int) $row->get( 'status', 1, GetterInterface::INT ) );

									if ( ! $groupUser->store() ) {
										if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
											var_dump( CBTxt::T( 'AUTO_ACTION_GROUPJIVE_FAILED', ':: Action [action] :: CB GroupJive failed to save. Error: [error]', array( '[action]' => (int) $trigger->get( 'id' ), '[error]' => $groupUser->getError() ) ) );
										}

										continue;
									}
								}
							}
						}
					}
					break;
			}
		}
	}
コード例 #7
0
ファイル: kunena.php プロジェクト: kosmosby/medicine-prof
	/**
	 * @param cbautoactionsActionTable $trigger
	 * @param UserTable $user
	 */
	public function execute( $trigger, $user )
	{
		global $_CB_database;

		if ( ! $this->installed() ) {
			if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
				var_dump( CBTxt::T( 'AUTO_ACTION_KUNENA_NOT_INSTALLED', ':: Action [action] :: Kunena is not installed', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
			}

			return;
		}

		foreach ( $trigger->getParams()->subTree( 'kunena' ) as $row ) {
			/** @var ParamsInterface $row */
			$owner								=	$row->get( 'owner', null, GetterInterface::STRING );

			if ( ! $owner ) {
				$owner							=	(int) $user->get( 'id' );
			} else {
				$owner							=	(int) $trigger->getSubstituteString( $owner );
			}

			switch ( $row->get( 'mode', 'category', GetterInterface::STRING ) ) {
				case 'sync':
					if ( ! $user->get( 'id' ) ) {
						if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
							var_dump( CBTxt::T( 'AUTO_ACTION_KUNENA_NO_USER', ':: Action [action] :: Kunena skipped due to no user', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
						}

						continue;
					}

					$kunenaUser					=	KunenaUserHelper::get( (int) $user->get( 'id' ) );

					$kunenaUser->set( 'name', $user->get( 'name' ) );
					$kunenaUser->set( 'username', $user->get( 'username' ) );
					$kunenaUser->set( 'email', $user->get( 'email' ) );

					foreach ( $row->subTree( 'fields' ) as $r ) {
						/** @var ParamsInterface $r */
						$field					=	$r->get( 'field', null, GetterInterface::STRING );

						if ( $field ) {
							$kunenaUser->set( $field, $trigger->getSubstituteString( $r->get( 'value', null, GetterInterface::RAW ), false, $r->get( 'translate', false, GetterInterface::BOOLEAN ) ) );
						}
					}

					$kunenaUser->save();
					break;
				case 'reply':
					if ( ! $owner ) {
						if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
							var_dump( CBTxt::T( 'AUTO_ACTION_KUNENA_NO_OWNER', ':: Action [action] :: Kunena skipped due to missing owner', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
						}

						continue;
					}

					$message					=	$trigger->getSubstituteString( $row->get( 'message', null, GetterInterface::RAW ), false );

					if ( ! $message ) {
						if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
							var_dump( CBTxt::T( 'AUTO_ACTION_KUNENA_NO_MSG', ':: Action [action] :: Kunena skipped due to missing message', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
						}

						continue;
					}

					$topicId					=	(int) $row->get( 'topic', 0, GetterInterface::INT );

					if ( ! $topicId ) {
						if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
							var_dump( CBTxt::T( 'AUTO_ACTION_KUNENA_NO_TOPIC', ':: Action [action] :: Kunena skipped due to missing topic', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
						}

						continue;
					}

					$subject					=	$trigger->getSubstituteString( $row->get( 'subject', null, GetterInterface::STRING ) );

					$topic						=	KunenaForumMessageHelper::get( $topicId );

					$fields						=	array( 'message' => $message );

					if ( $subject ) {
						$fields['subject']		=	$subject;
					}

					$topic->newReply( $fields, $owner );
					break;
				case 'topic':
					if ( ! $owner ) {
						if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
							var_dump( CBTxt::T( 'AUTO_ACTION_KUNENA_NO_OWNER', ':: Action [action] :: Kunena skipped due to missing owner', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
						}

						continue;
					}

					$subject					=	$trigger->getSubstituteString( $row->get( 'subject', null, GetterInterface::STRING ) );

					if ( ! $subject ) {
						if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
							var_dump( CBTxt::T( 'AUTO_ACTION_KUNENA_NO_SUBJ', ':: Action [action] :: Kunena skipped due to missing subject', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
						}

						continue;
					}

					$message					=	$trigger->getSubstituteString( $row->get( 'message', null, GetterInterface::RAW ), false );

					if ( ! $message ) {
						if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
							var_dump( CBTxt::T( 'AUTO_ACTION_KUNENA_NO_MSG', ':: Action [action] :: Kunena skipped due to missing message', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
						}

						continue;
					}

					$categoryId					=	(int) $row->get( 'category', 0, GetterInterface::INT );

					if ( ! $categoryId ) {
						if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
							var_dump( CBTxt::T( 'AUTO_ACTION_KUNENA_NO_CAT', ':: Action [action] :: Kunena skipped due to missing category', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
						}

						continue;
					}

					$category					=	KunenaForumCategoryHelper::get( $categoryId );

					$fields						=	array(	'catid' => $categoryId,
															'subject' => $subject,
															'message' => $message
														);

					$category->newTopic( $fields, $owner );
					break;
				case 'category':
				default:
					$name						=	$trigger->getSubstituteString( $row->get( 'name', null, GetterInterface::STRING ) );

					if ( ! $name ) {
						if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
							var_dump( CBTxt::T( 'AUTO_ACTION_KUNENA_NO_NAME', ':: Action [action] :: Kunena skipped due to missing name', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
						}

						continue;
					}

					$query						=	'SELECT ' . $_CB_database->NameQuote( 'id' )
												.	"\n FROM " . $_CB_database->NameQuote( '#__kunena_categories' )
												.	"\n WHERE " . $_CB_database->NameQuote( 'name' ) . " = " . $_CB_database->Quote( $name );
					$_CB_database->setQuery( $query );
					if ( ! $_CB_database->loadResult() ) {
						$category				=	KunenaForumCategoryHelper::get();

						$category->set( 'parent_id', (int) $row->get( 'parent', 0, GetterInterface::INT ) );
						$category->set( 'name', $name );
						$category->set( 'alias', KunenaRoute::stringURLSafe( $name ) );
						$category->set( 'accesstype', 'joomla.group' );
						$category->set( 'access', (int) $row->get( 'access', 1, GetterInterface::INT ) );
						$category->set( 'published', (int) $row->get( 'published', 1, GetterInterface::INT ) );
						$category->set( 'description', $trigger->getSubstituteString( $row->get( 'description', null, GetterInterface::STRING ) ) );

						if ( $category->save() && $owner ) {
							$category->addModerator( (int) $owner );
						}
					}
					break;
			}
		}
	}
コード例 #8
0
ファイル: code.php プロジェクト: kosmosby/medicine-prof
	/**
	 * @param cbautoactionsActionTable $trigger
	 * @param UserTable $user
	 * @return mixed
	 */
	public function execute( $trigger, $user )
	{
		global $_CB_framework;

		$return							=	null;

		foreach ( $trigger->getParams()->subTree( 'code' ) as $row ) {
			/** @var ParamsInterface $row */
			$code						=	$trigger->getSubstituteString( $row->get( 'code', null, GetterInterface::RAW ), false );

			if ( ! $code ) {
				continue;
			}

			$method						=	$row->get( 'method', 'HTML', GetterInterface::STRING );
			$url						=	$trigger->getSubstituteString( $row->get( 'url', null, GetterInterface::STRING ) );
			$content					=	null;

			switch ( $method ) {
				case 'PHP1':
				case 'PHP2':
				case 'PHP':
					ob_start();
					$function			=	create_function( '$trigger,$user,$vars', $code );
					$content			=	$function( $trigger, $user, $trigger->get( '_vars' ) );
					ob_end_clean();
					break;
				case 'JS':
					$_CB_framework->document->addHeadScriptDeclaration( $code );
					break;
				case 'JS_URL':
					$_CB_framework->document->addHeadScriptUrl( $url );
					break;
				case 'JQUERY':
					$plugins			=	$row->get( 'plugins', null, GetterInterface::STRING );

					if ( $plugins ) {
						$plgs			=	explode( ',', $plugins );
					} else {
						$plgs			=	array();
					}

					$pluginUrls			=	$trigger->getSubstituteString( $row->get( 'pluginurls', null, GetterInterface::STRING ) );

					if ( $pluginUrls ) {
						$plgUrls		=	explode( "\n", $pluginUrls );

						if ( $plgUrls ) foreach ( $plgUrls as $plgUrl ) {
							$plgName	=	pathinfo( $plgUrl, PATHINFO_FILENAME );

							$_CB_framework->addJQueryPlugin( $plgName, $plgUrl );

							$plgs[]		=	$plgName;
						}
					}

					$_CB_framework->outputCbJQuery( $code, ( empty( $plgs ) ? null : $plgs ) );
					break;
				case 'CSS':
					$_CB_framework->document->addHeadStyleInline( $code );
					break;
				case 'CSS_URL':
					$_CB_framework->document->addHeadStyleSheet( $url );
					break;
				case 'HEADER':
					$_CB_framework->document->addHeadCustomHtml( $code );
					break;
				case 'TITLE':
					$_CB_framework->setPageTitle( $code );
					break;
				case 'PATHWAY':
					$_CB_framework->appendPathWay( $code, $url );
					break;
				case 'MESSAGE':
					$messageType		=	$row->get( 'message_type', 'message', GetterInterface::STRING );

					if ( $messageType == 'custom' ) {
						$messageType	=	$trigger->getSubstituteString( $row->get( 'message_type_custom', null, GetterInterface::STRING ) );
					}

					$_CB_framework->enqueueMessage( $code, ( $messageType ? $messageType : null ) );
					break;
				case 'HTML':
				default:
					ob_start();
					$content			=	$code;
					ob_end_clean();
					break;
			}

			if ( in_array( $method, array( 'HTML', 'PHP1', 'PHP2', 'PHP' ) ) ) {
				switch ( $row->get( 'return', 'ECHO', GetterInterface::STRING ) ) {
					case 'ECHO':
						echo $content;
						break;
					case 'DUMP':
						var_dump( $content );
						break;
					case 'PRINT':
						print $content;
						break;
					case 'RETURN':
					default:
						if ( is_object( $content ) || is_array( $content ) ) {
							$return		=	$content;
						} else {
							$return		.=	$content;
						}
						break;
				}
			}
		}

		return $return;
	}
コード例 #9
0
ファイル: activity.php プロジェクト: kosmosby/medicine-prof
	/**
	 * @param cbautoactionsActionTable $trigger
	 * @param UserTable $user
	 * @return null|string
	 */
	public function execute( $trigger, $user )
	{
		global $_CB_framework, $_CB_database;

		if ( ! $this->installed() ) {
			if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
				var_dump( CBTxt::T( 'AUTO_ACTION_ACTIVITY_NOT_INSTALLED', ':: Action [action] :: CB Activity is not installed', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
			}

			return null;
		}

		$return									=	null;

		foreach ( $trigger->getParams()->subTree( 'activity' ) as $row ) {
			/** @var ParamsInterface $row */
			$mode								=	$row->get( 'mode', 'activity', GetterInterface::STRING );
			$method								=	$row->get( 'method', 'create', GetterInterface::STRING );
			$owner								=	$row->get( 'owner', null, GetterInterface::STRING );

			if ( ! $owner ) {
				$owner							=	(int) $user->get( 'id' );
			} else {
				$owner							=	(int) $trigger->getSubstituteString( $owner );
			}

			$type								=	$trigger->getSubstituteString( $row->get( 'type', null, GetterInterface::STRING ) );
			$subtype							=	$trigger->getSubstituteString( $row->get( 'subtype', null, GetterInterface::STRING ) );
			$item								=	$trigger->getSubstituteString( $row->get( 'item', null, GetterInterface::STRING ) );
			$parent								=	$trigger->getSubstituteString( $row->get( 'parent', null, GetterInterface::STRING ) );

			if ( $mode == 'stream' ) {
				if ( $owner ) {
					$streamUser					=	CBuser::getUserDataInstance( (int) $owner );
				} else {
					$streamUser					=	CBuser::getMyUserDataInstance();
				}

				$source							=	$trigger->getSubstituteString( $row->get( 'source', null, GetterInterface::STRING ) );
				$direction						=	(int) $row->get( 'direction', 0, GetterInterface::INT );

				if ( $row->get( 'stream', 'activity', GetterInterface::STRING ) == 'comments' ) {
					$object						=	new Comments( $source, $streamUser, $direction );

					CBActivity::loadStreamDefaults( $object, $row->subTree( 'comments_stream' ), 'comments_' );
				} else {
					$object						=	new Activity( $source, $streamUser, $direction );

					CBActivity::loadStreamDefaults( $object, $row->subTree( 'activity_stream' ), 'activity_' );
				}

				if ( $type ) {
					$object->set( 'type', $type );
				}

				if ( $subtype ) {
					$object->set( 'subtype', $subtype );
				}

				if ( $item ) {
					$object->set( 'item', $item );
				}

				if ( $parent ) {
					$object->set( 'parent', $parent );
				}

				if ( $row->get( 'output', 'echo', GetterInterface::STRING ) == 'echo' ) {
					echo $object->stream( false );
				} else {
					$return						.=	$object->stream( false );
				}
			} elseif ( $method == 'delete' ) {
				$where							=	array();

				if ( $owner ) {
					$where[]					=	$_CB_database->NameQuote( 'user_id' ) . ' = ' . (int) $owner;
				}

				if ( $type ) {
					$where[]					=	$_CB_database->NameQuote( 'type' ) . ( strpos( $type, '%' ) !== false ? ' LIKE ' : ' = ' ) . $_CB_database->Quote( $type );
				}

				if ( $item ) {
					$where[]					=	$_CB_database->NameQuote( 'item' ) . ' = ' . $_CB_database->Quote( $item );
				}

				if ( $mode != 'hidden' ) {
					if ( $subtype ) {
						$where[]				=	$_CB_database->NameQuote( 'subtype' ) . ( strpos( $type, '%' ) !== false ? ' LIKE ' : ' = ' ) . $_CB_database->Quote( $subtype );
					}

					if ( $parent ) {
						$where[]				=	$_CB_database->NameQuote( 'parent' ) . ' = ' . $_CB_database->Quote( $parent );
					}
				}

				switch ( $mode ) {
					case 'hidden':
						$table					=	'#__comprofiler_plugin_activity_hidden';
						$class					=	'\CB\Plugin\Activity\Table\HiddenTable';
						break;
					case 'tag':
						$table					=	'#__comprofiler_plugin_activity_tags';
						$class					=	'\CB\Plugin\Activity\Table\TagTable';
						break;
					case 'comment':
						$table					=	'#__comprofiler_plugin_activity_comments';
						$class					=	'\CB\Plugin\Activity\Table\CommentTable';
						break;
					case 'activity':
					default:
						$table					=	'#__comprofiler_plugin_activity';
						$class					=	'\CB\Plugin\Activity\Table\ActivityTable';
						break;
				}

				$query							=	'SELECT *'
												.	"\n FROM " . $_CB_database->NameQuote( $table )
												.	( $where ? "\n WHERE " . implode( "\n AND ", $where ) : null );
				$_CB_database->setQuery( $query );
				$objects						=	$_CB_database->loadObjectList( null, $class, array( $_CB_database ) );

				/** @var TableInterface[] $objects */
				foreach ( $objects as $object ) {
					$object->delete();
				}
			} else {
				if ( ! $owner ) {
					if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
						var_dump( CBTxt::T( 'AUTO_ACTION_ACTIVITY_NO_OWNER', ':: Action [action] :: CB Activity skipped due to missing owner', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
					}

					continue;
				}

				if ( ! $type ) {
					if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
						var_dump( CBTxt::T( 'AUTO_ACTION_ACTIVITY_NO_TYPE', ':: Action [action] :: CB Activity skipped due to missing type', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
					}

					continue;
				}

				switch ( $mode ) {
					case 'hidden':
						$object					=	new HiddenTable( $_CB_database );
						break;
					case 'tag':
						$object					=	new TagTable( $_CB_database );
						break;
					case 'comment':
						$object					=	new CommentTable( $_CB_database );
						break;
					case 'activity':
					default:
						$object					=	new ActivityTable( $_CB_database );
						break;
				}

				if ( $item ) {
					$load						=	array( 'user_id' => $owner, 'type' => $type, 'item' => $item );

					if ( $mode != 'hidden' ) {
						if ( $subtype ) {
							$load['subtype']	=	$subtype;
						}

						if ( $parent ) {
							$load['parent']		=	$parent;
						}
					}

					$object->load( $load );
				}

				$object->set( 'user_id', $owner );

				if ( $type ) {
					$object->set( 'type', $type );
				}

				if ( $mode != 'hidden' ) {
					if ( $subtype ) {
						$object->set( 'subtype', $subtype );
					}

					if ( $parent ) {
						$object->set( 'parent', $parent );
					}
				}

				if ( $item ) {
					$object->set( 'item', $item );
				}

				if ( $mode == 'activity' ) {
					$title						=	$trigger->getSubstituteString( $row->get( 'title', null, GetterInterface::RAW ) );

					if ( $title ) {
						$object->set( 'title', $title );
					}

					$date						=	$trigger->getSubstituteString( $row->get( 'date', null, GetterInterface::STRING ) );

					if ( $date ) {
						$object->set( 'date', $_CB_framework->getUTCDate( 'Y-m-d H:i:s', $date ) );
					}

					$action						=	$row->subTree( 'action' );
					$actionId					=	$action->get( 'id', null, GetterInterface::INT );

					if ( $actionId ) {
						$actionMessage			=	$trigger->getSubstituteString( $action->get( 'message', null, GetterInterface::STRING ) );

						if ( $actionMessage ) {
							$newAction			=	array(	'id'		=>	$actionId,
															'message'	=>	$actionMessage,
															'emote'		=>	$action->get( 'emote', '', GetterInterface::STRING )
														);

							$object->params()->set( 'action', $newAction );
						}
					}

					$location					=	$row->subTree( 'location' );
					$locationId					=	$location->get( 'id', null, GetterInterface::INT );

					if ( $locationId ) {
						$locationPlace			=	$trigger->getSubstituteString( $location->get( 'place', null, GetterInterface::STRING ) );

						if ( $locationPlace ) {
							$newLocation		=	array(	'id'		=>	$locationId,
															'place'		=>	$locationPlace,
															'address'	=>	$trigger->getSubstituteString( $location->get( 'address', null, GetterInterface::STRING ) )
														);

							$object->params()->set( 'location', $newLocation );
						}
					}

					$newLinks					=	array();

					foreach ( $row->subTree( 'links' ) as $link ) {
						/** @var ParamsInterface $link */
						$linkType				=	$trigger->getSubstituteString( $link->get( 'type', null, GetterInterface::STRING ) );
						$linkUrl				=	$trigger->getSubstituteString( $link->get( 'url', null, GetterInterface::STRING ) );

						if ( ( ! $linkType ) || ( ! $linkUrl ) ) {
							continue;
						}

						$linkMedia				=	$link->subTree( 'media' );

						$newLinks[]				=	array(	'url'			=>	$linkUrl,
															'text'			=>	$trigger->getSubstituteString( $link->get( 'text', null, GetterInterface::STRING ) ),
															'title'			=>	$trigger->getSubstituteString( $link->get( 'title', null, GetterInterface::STRING ) ),
															'description'	=>	$trigger->getSubstituteString( $link->get( 'description', null, GetterInterface::RAW ) ),
															'media'			=>	array(	'url' => $trigger->getSubstituteString( $linkMedia->get( 'url', null, GetterInterface::STRING ) ),
																						'mimetype' => $trigger->getSubstituteString( $linkMedia->get( 'mimetype', null, GetterInterface::STRING ) ),
																						'extension' => $trigger->getSubstituteString( $linkMedia->get( 'extension', null, GetterInterface::STRING ) ),
																						'custom' => $trigger->getSubstituteString( $linkMedia->get( 'custom', null, GetterInterface::RAW ) )
																					),
															'type'			=>	$linkType,
															'thumbnail'		=>	$link->get( 'thumbnail', 1, GetterInterface::INT ),
															'internal'		=>	$link->get( 'internal', 0, GetterInterface::INT )
														);
					}

					if ( $newLinks ) {
						$object->params()->set( 'links', $newLinks );
					}

					$comments					=	$row->subTree( 'comments' );

					$object->params()->set( 'comments', array(	'display'	=>	(int) $comments->get( 'display', 1, GetterInterface::INT ),
																'source'	=>	(int) $comments->get( 'source', 1, GetterInterface::INT )
															));

					$tags						=	$row->subTree( 'tags' );

					$object->params()->set( 'tags', array(	'display'	=>	(int) $tags->get( 'display', 1, GetterInterface::INT ),
															'source'	=>	(int) $tags->get( 'source', 1, GetterInterface::INT )
														));

					$object->set( 'params', $object->params()->asJson() );
				} elseif ( $mode == 'comment' ) {
					$tags						=	$row->subTree( 'replies' );

					$object->params()->set( 'replies', array( 'display' => (int) $tags->get( 'display', 1, GetterInterface::INT ) ));

					$object->set( 'params', $object->params()->asJson() );
				}

				if ( in_array( $mode, array( 'activity', 'comment' ) ) ) {
					$message					=	$trigger->getSubstituteString( $row->get( 'message', null, GetterInterface::RAW ), false );

					if ( $message ) {
						$object->set( 'message', $message );
					}
				}

				if ( ! $object->store() ) {
					if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
						var_dump( CBTxt::T( 'AUTO_ACTION_ACTIVITY_CREATE_FAILED', ':: Action [action] :: CB Activity failed to save. Error: [error]', array( '[action]' => (int) $trigger->get( 'id' ), '[error]' => $object->getError() ) ) );
					}

					continue;
				}
			}
		}

		return $return;
	}
コード例 #10
0
ファイル: usergroup.php プロジェクト: kosmosby/medicine-prof
	/**
	 * @param cbautoactionsActionTable $trigger
	 * @param UserTable $user
	 */
	public function execute( $trigger, $user )
	{
		if ( ! $user->get( 'id' ) ) {
			if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
				var_dump( CBTxt::T( 'AUTO_ACTION_USERGROUP_NO_USER', ':: Action [action] :: Usergroup skipped due to no user', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
			}

			return;
		}

		$cache										=	$user->get( 'password' );

		$user->set( 'password', null );

		foreach ( $trigger->getParams()->subTree( 'usergroup' ) as $row ) {
			/** @var ParamsInterface $row */
			$groups									=	$row->get( 'groups', null, GetterInterface::STRING );

			if ( $groups ) {
				$groups								=	explode( '|*|', $groups );

				cbArrayToInts( $groups );
			}

			$session								=	JFactory::getSession();
			$jUser									=	$session->get( 'user' );
			$isMe									=	( $jUser ? ( $jUser->id == $user->get( 'id' ) ) : false );

			switch ( $row->get( 'mode', 'add', GetterInterface::STRING ) ) {
				case 'create':
					$title							=	$trigger->getSubstituteString( $row->get( 'title', null, GetterInterface::STRING ) );

					if ( ! $title ) {
						if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
							var_dump( CBTxt::T( 'AUTO_ACTION_USERGROUP_NO_TITLE', ':: Action [action] :: Usergroup skipped due to missing title', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
						}

						continue;
					}

					$usergroup						=	JTable::getInstance( 'usergroup' );

					$usergroup->load( array( 'title' => $title ) );

					if ( ! $usergroup->id ) {
						$usergroup->parent_id		=	(int) $row->get( 'parent', 0, GetterInterface::INT );
						$usergroup->title			=	$title;

						if ( ! $usergroup->store() ) {
							if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
								var_dump( CBTxt::T( 'AUTO_ACTION_USERGROUP_CREATE_FAILED', ':: Action [action] :: Usergroup failed to create', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
							}

							continue;
						}
					}

					if ( $row->get( 'add', 1, GetterInterface::BOOLEAN ) ) {
						if ( ! in_array( $usergroup->id, $user->get( 'gids' ) ) ) {
							$user->gids[]			=	$usergroup->id;

							if ( ! $user->store() ) {
								if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
									var_dump( CBTxt::T( 'AUTO_ACTION_USERGROUP_FAILED', ':: Action [action] :: Usergroup failed to save. Error: [error]', array( '[action]' => (int) $trigger->get( 'id' ), '[error]' => $user->getError() ) ) );
								}

								continue;
							}

							if ( $isMe ) {
								JAccess::clearStatics();

								$session->set( 'user', new JUser( $user->get( 'id'  ) ) );
							}
						}
					}
					break;
				case 'replace':
					if ( ! $groups ) {
						if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
							var_dump( CBTxt::T( 'AUTO_ACTION_USERGROUP_NO_GROUPS', ':: Action [action] :: Usergroup skipped due to missing groups', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
						}

						continue;
					}

					$user->set( 'gids', $groups );

					if ( ! $user->store() ) {
						if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
							var_dump( CBTxt::T( 'AUTO_ACTION_USERGROUP_FAILED', ':: Action [action] :: Usergroup failed to save. Error: [error]', array( '[action]' => (int) $trigger->get( 'id' ), '[error]' => $user->getError() ) ) );
						}

						continue;
					}

					if ( $isMe ) {
						JAccess::clearStatics();

						$session->set( 'user', new JUser( $user->get( 'id' ) ) );
					}
					break;
				case 'remove':
					if ( ! $groups ) {
						if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
							var_dump( CBTxt::T( 'AUTO_ACTION_USERGROUP_NO_GROUPS', ':: Action [action] :: Usergroup skipped due to missing groups', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
						}

						continue;
					}

					$removed						=	false;

					foreach( $user->get( 'gids' ) as $k => $gid ) {
						if ( in_array( $gid, $groups ) ) {
							unset( $user->gids[$k] );

							$removed				=	true;
						}
					}

					if ( $removed ) {
						if ( ! $user->store() ) {
							if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
								var_dump( CBTxt::T( 'AUTO_ACTION_USERGROUP_FAILED', ':: Action [action] :: Usergroup failed to save. Error: [error]', array( '[action]' => (int) $trigger->get( 'id' ), '[error]' => $user->getError() ) ) );
							}

							continue;
						}

						if ( $isMe ) {
							JAccess::clearStatics();

							$session->set( 'user', new JUser( $user->get( 'id'  ) ) );
						}
					}
					break;
				case 'add':
				default:
					if ( ! $groups ) {
						if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
							var_dump( CBTxt::T( 'AUTO_ACTION_USERGROUP_NO_GROUPS', ':: Action [action] :: Usergroup skipped due to missing groups', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
						}

						continue;
					}

					$usergroups						=	$groups;

					foreach( $usergroups as $k => $usergroup ) {
						if ( in_array( $usergroup, $user->get( 'gids' ) ) ) {
							unset( $usergroups[$k] );
						}
					}

					if ( $usergroups ) {
						$user->set( 'gids', array_unique( array_merge( $user->get( 'gids' ), $usergroups ) ) );

						if ( ! $user->store() ) {
							if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
								var_dump( CBTxt::T( 'AUTO_ACTION_USERGROUP_FAILED', ':: Action [action] :: Usergroup failed to save. Error: [error]', array( '[action]' => (int) $trigger->get( 'id' ), '[error]' => $user->getError() ) ) );
							}

							continue;
						}

						if ( $isMe ) {
							JAccess::clearStatics();

							$session->set( 'user', new JUser( $user->get( 'id'  ) ) );
						}
					}
					break;
			}
		}

		$user->set( 'password', $cache );
	}
コード例 #11
0
ファイル: acymailing.php プロジェクト: kosmosby/medicine-prof
	/**
	 * @param cbautoactionsActionTable $trigger
	 * @param UserTable $user
	 */
	public function execute( $trigger, $user )
	{
		global $_CB_framework;

		if ( ! $this->installed() ) {
			if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
				var_dump( CBTxt::T( 'AUTO_ACTION_ACYMAILING_NOT_INSTALLED', ':: Action [action] :: AcyMailing is not installed', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
			}

			return;
		}

		$params							=	$trigger->getParams()->subTree( 'acymailing' );

		require_once( $_CB_framework->getCfg( 'absolute_path' ) . '/administrator/components/com_acymailing/helpers/helper.php' );

		/** @var subscriberClass $acySubscriberAPI */
		$acySubscriberAPI				=	acymailing::get( 'class.subscriber' );
		$subscriberId					=	$acySubscriberAPI->subid( (int) $user->get( 'id' ) );

		if ( ! $subscriberId ) {
			$newSubscriber				=	new stdClass();
			$newSubscriber->email		=	$user->get( 'email' );
			$newSubscriber->userid		=	(int) $user->get( 'id' );
			$newSubscriber->name		=	$user->get( 'name' );
			$newSubscriber->created		=	$_CB_framework->getUTCTimestamp( $user->get( 'registerDate' ) );
			$newSubscriber->confirmed	=	1;
			$newSubscriber->enabled		=	1;
			$newSubscriber->accept		=	1;
			$newSubscriber->ip			=	$user->get( 'registeripaddr' );
			$newSubscriber->html		=	1;

			$subscriberId				=	$acySubscriberAPI->save( $newSubscriber );
		}

		if ( ! $subscriberId ) {
			if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
				var_dump( CBTxt::T( 'AUTO_ACTION_ACYMAILING_NO_SUB', ':: Action [action] :: AcyMailing skipped due to missing subscriber id', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
			}

			return;
		}

		$lists							=	array();

		$subscribe						=	$params->get( 'subscribe' );

		if ( $subscribe ) {
			$subscribe					=	explode( '|*|', $subscribe );

			cbArrayToInts( $subscribe );

			foreach ( $subscribe as $listId ) {
				$lists[$listId]			=	array( 'status' => 1 );
			}
		}

		$unsubscribe					=	$params->get( 'unsubscribe' );

		if ( $unsubscribe ) {
			$unsubscribe				=	explode( '|*|', $unsubscribe );

			cbArrayToInts( $unsubscribe );

			foreach ( $unsubscribe as $listId ) {
				$lists[$listId]			=	array( 'status' => -1 );
			}
		}

		$remove							=	$params->get( 'remove' );

		if ( $remove ) {
			$remove						=	explode( '|*|', $remove );

			cbArrayToInts( $remove );

			foreach ( $remove as $listId ) {
				$lists[$listId]			=	array( 'status' => 0 );
			}
		}

		$pending						=	$params->get( 'pending' );

		if ( $pending ) {
			$pending					=	explode( '|*|', $pending );

			cbArrayToInts( $pending );

			foreach ( $pending as $listId ) {
				$lists[$listId]			=	array( 'status' => 2 );
			}
		}

		if ( $lists ) {
			$acySubscriberAPI->saveSubscription( $subscriberId, $lists );
		}
	}
コード例 #12
0
ファイル: k2.php プロジェクト: kosmosby/medicine-prof
	/**
	 * @param cbautoactionsActionTable $trigger
	 * @param UserTable $user
	 */
	public function execute( $trigger, $user )
	{
		global $_CB_database;

		if ( ! $user->get( 'id' ) ) {
			if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
				var_dump( CBTxt::T( 'AUTO_ACTION_K2_NO_USER', ':: Action [action] :: K2 skipped due to no user', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
			}

			return;
		}

		if ( ! $this->installed() ) {
			if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
				var_dump( CBTxt::T( 'AUTO_ACTION_K2_NOT_INSTALLED', ':: Action [action] :: K2 is not installed', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
			}

			return;
		}

		$params				=	$trigger->getParams()->subTree( 'k2' );

		if ( $params->get( 'mode', 1, GetterInterface::INT ) ) {
			$group			=	(int) $params->get( 'group', null, GetterInterface::INT );
			$gender			=	$trigger->getSubstituteString( $params->get( 'gender', null, GetterInterface::STRING ) );
			$description	=	$trigger->getSubstituteString( $params->get( 'description', null, GetterInterface::RAW ), false );
			$url			=	$trigger->getSubstituteString( $params->get( 'url', null, GetterInterface::STRING ) );
			$notes			=	$trigger->getSubstituteString( $params->get( 'notes', null, GetterInterface::RAW ), false );

			$query			=	'SELECT *'
							.	"\n FROM " . $_CB_database->NameQuote( '#__k2_users' )
							.	"\n WHERE " . $_CB_database->NameQuote( 'userID' ) . " = " . (int) $user->get( 'id' );
			$_CB_database->setQuery( $query, 0, 1 );
			$k2User			=	null;
			$_CB_database->loadObject( $k2User );

			if ( $k2User ) {
				$set		=	array();

				if ( $group && ( $k2User->group != $group ) ) {
					$set[]	=	$_CB_database->NameQuote( 'group' ) . " = " . $_CB_database->Quote( $group );
				}

				if ( $gender && ( $k2User->gender != $gender ) ) {
					$set[]	=	$_CB_database->NameQuote( 'gender' ) . " = " . $_CB_database->Quote( $gender );
				}

				if ( $description && ( $k2User->description != $description ) ) {
					$set[]	=	$_CB_database->NameQuote( 'description' ) . " = " . $_CB_database->Quote( $description );
				}

				if ( $url && ( $k2User->url != $url ) ) {
					$set[]	=	$_CB_database->NameQuote( 'url' ) . " = " . $_CB_database->Quote( $url );
				}

				if ( $notes && ( $k2User->notes != $notes ) ) {
					$set[]	=	$_CB_database->NameQuote( 'notes' ) . " = " . $_CB_database->Quote( $notes );
				}

				if ( ! empty( $set ) ) {
					$query	=	'UPDATE ' . $_CB_database->NameQuote( '#__k2_users' )
							.	"\n SET " . implode( ', ', $set )
							.	"\n WHERE " . $_CB_database->NameQuote( 'userID' ) . " = " . (int) $user->get( 'id' );
					$_CB_database->setQuery( $query );
					$_CB_database->query();
				}
			} else {
				$ip			=	$this->input( 'server/REMOTE_ADDR', null, GetterInterface::STRING );
				$hostname	=	gethostbyaddr( $ip );

				$query		=	'INSERT INTO ' . $_CB_database->NameQuote( '#__k2_users' )
							.	"\n ("
							.		$_CB_database->NameQuote( 'userID' )
							.		', ' . $_CB_database->NameQuote( 'userName' )
							.		', ' . $_CB_database->NameQuote( 'gender' )
							.		', ' . $_CB_database->NameQuote( 'description' )
							.		', ' . $_CB_database->NameQuote( 'url' )
							.		', ' . $_CB_database->NameQuote( 'group' )
							.		', ' . $_CB_database->NameQuote( 'ip' )
							.		', ' . $_CB_database->NameQuote( 'hostname' )
							.		', ' . $_CB_database->NameQuote( 'notes' )
							.	')'
							.	"\n VALUES ("
							.		(int) $user->get( 'id' )
							.		', ' . $_CB_database->Quote( $user->get( 'username' ) )
							.		', ' . $_CB_database->Quote( ( $gender ? $gender : 'm' ) )
							.		', ' . $_CB_database->Quote( $description )
							.		', ' . $_CB_database->Quote( $url )
							.		', ' . ( $group ? $group : 1 )
							.		', ' . $_CB_database->Quote( $ip )
							.		', ' . $_CB_database->Quote( $hostname )
							.		', ' . $_CB_database->Quote( $notes )
							.	')';
				$_CB_database->setQuery( $query );
				$_CB_database->query();

				$query		=	'DELETE'
							.	"\n FROM " . $_CB_database->NameQuote( '#__k2_users' )
							.	"\n WHERE " . $_CB_database->NameQuote( 'userID' ) . " = 0"
							.	"\n AND " . $_CB_database->NameQuote( 'ip' ) . " = " . $_CB_database->Quote( $ip )
							.	"\n AND " . $_CB_database->NameQuote( 'hostname' ) . " = " . $_CB_database->Quote( $hostname );
				$_CB_database->setQuery( $query );
				$_CB_database->query();
			}
		} else {
			$query			=	'DELETE'
							.	"\n FROM " . $_CB_database->NameQuote( '#__k2_users' )
							.	"\n WHERE " . $_CB_database->NameQuote( 'userID' ) . " = " . (int) $user->get( 'id' );
			$_CB_database->setQuery( $query );
			$_CB_database->query();
		}
	}
コード例 #13
0
ファイル: email.php プロジェクト: kosmosby/medicine-prof
	/**
	 * @param cbautoactionsActionTable $trigger
	 * @param UserTable $user
	 */
	public function execute( $trigger, $user )
	{
		foreach ( $trigger->getParams()->subTree( 'email' ) as $row ) {
			/** @var ParamsInterface $row */
			$mailTo										=	$row->get( 'to', null, GetterInterface::STRING );

			if ( ! $mailTo ) {
				$mailTo									=	$user->get( 'email' );
			} else {
				$mailTo									=	$trigger->getSubstituteString( $mailTo );
			}

			if ( ! $mailTo ) {
				if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
					var_dump( CBTxt::T( 'AUTO_ACTION_EMAIL_NO_TO', ':: Action [action] :: Email skipped due to missing to', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
				}

				continue;
			}

			$mailSubject								=	$trigger->getSubstituteString( $row->get( 'subject', null, GetterInterface::STRING ) );

			if ( ! $mailSubject ) {
				if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
					var_dump( CBTxt::T( 'AUTO_ACTION_EMAIL_NO_SBJ', ':: Action [action] :: Email skipped due to missing subject', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
				}

				continue;
			}

			$mailBody									=	$trigger->getSubstituteString( $row->get( 'body', null, GetterInterface::RAW ), false );

			if ( ! $mailBody ) {
				if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
					var_dump( CBTxt::T( 'AUTO_ACTION_EMAIL_NO_BODY', ':: Action [action] :: Email skipped due to missing body', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
				}

				continue;
			}

			$mailHtml									=	(int) $row->get( 'mode', null, GetterInterface::INT );
			$mailCC										=	$trigger->getSubstituteString( $row->get( 'cc', null, GetterInterface::STRING ) );
			$mailBCC									=	$trigger->getSubstituteString( $row->get( 'bcc', null, GetterInterface::STRING ) );
			$mailAttachments							=	$trigger->getSubstituteString( $row->get( 'attachment', null, GetterInterface::STRING ) );
			$mailReplyToEmail							=	$trigger->getSubstituteString( $row->get( 'replyto_address', null, GetterInterface::STRING ) );
			$mailReplyToName							=	$trigger->getSubstituteString( $row->get( 'replyto_name', null, GetterInterface::STRING ) );
			$mailFromEmail								=	$trigger->getSubstituteString( $row->get( 'from_address', null, GetterInterface::STRING ) );
			$mailFromName								=	$trigger->getSubstituteString( $row->get( 'from_name', null, GetterInterface::STRING ) );
			$mailMailer									=	$row->get( 'mailer', null, GetterInterface::STRING );
			$mailProperties								=	array();

			if ( $mailTo ) {
				$mailTo									=	preg_split( ' *, *', $mailTo );
			} else {
				$mailTo									=	null;
			}

			if ( $mailCC ) {
				$mailCC									=	preg_split( ' *, *', $mailCC );
			} else {
				$mailCC									=	null;
			}

			if ( $mailBCC ) {
				$mailBCC								=	preg_split( ' *, *', $mailBCC );
			} else {
				$mailBCC								=	null;
			}

			if ( $mailAttachments ) {
				$mailAttachments						=	preg_split( ' *, *', $mailAttachments );
			} else {
				$mailAttachments						=	null;
			}

			if ( $mailReplyToEmail ) {
				$mailReplyToEmail						=	preg_split( ' *, *', $mailReplyToEmail );
			} else {
				$mailReplyToEmail						=	null;
			}

			if ( $mailReplyToName ) {
				$mailReplyToName						=	preg_split( ' *, *', $mailReplyToName );
			} else {
				$mailReplyToName						=	null;
			}

			if ( $mailMailer ) {
				$mailProperties['Mailer']				=	$mailMailer;

				if ( $mailMailer == 'smtp' ) {
					$mailProperties['SMTPAuth']			=	(int) $row->get( 'mailer_smtpauth', null, GetterInterface::INT );
					$mailProperties['Username']			=	$row->get( 'mailer_smtpuser', null, GetterInterface::STRING );
					$mailProperties['Password']			=	$row->get( 'mailer_smtppass', null, GetterInterface::STRING );
					$mailProperties['Host']				=	$row->get( 'mailer_smtphost', null, GetterInterface::STRING );

					$smtpPort							=	(int) $row->get( 'mailer_smtpport', null, GetterInterface::INT );

					if ( $smtpPort ) {
						$mailProperties['Port']			=	$smtpPort;
					}

					$smtpSecure							=	$row->get( 'mailer_smtpsecure', null, GetterInterface::STRING );

					if ( ( $smtpSecure === 'ssl' ) || ( $smtpSecure === 'tls' ) ) {
						$mailProperties['SMTPSecure']	=	$smtpSecure;
					}
				} elseif ( $mailMailer == 'sendmail' ) {
					$sendMail							=	$row->get( 'mailer_sendmail', null, GetterInterface::STRING );

					if ( $sendMail ) {
						$mailProperties['Sendmail']		=	$sendMail;
					}
				}
			}

			$error										=	null;

			if ( ! comprofilerMail( $mailFromEmail, $mailFromName, $mailTo, $mailSubject, $mailBody, $mailHtml, $mailCC, $mailBCC, $mailAttachments, $mailReplyToEmail, $mailReplyToName, $mailProperties, $error ) ) {
				if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
					var_dump( CBTxt::T( 'AUTO_ACTION_EMAIL_FAILED', ':: Action [action] :: Email failed to send. Error: [error]', array( '[action]' => (int) $trigger->get( 'id' ), '[error]' => $error ) ) );
				}
			}
		}
	}
コード例 #14
0
	/**
	 * Executes the action
	 *
	 * @param cbautoactionsActionTable $trigger
	 * @param UserTable                $user
	 * @param string                   $rawPassword
	 * @param array                    $vars
	 * @param array                    $extras
	 * @return mixed
	 */
	public function getAction( $trigger, $user, $rawPassword = null, $vars = array(), $extras = array() )
	{
		$cbUser				=	new CBuser();
		$cbUser->_cbuser	=	$user;

		$extras				=	array_merge( $extras, $this->getExtras( $vars ) );

		$vars['self']		=	$trigger;
		$vars['user']		=	$user;

		$trigger->set( '_cbuser', $cbUser );
		$trigger->set( '_password', ( $rawPassword ? $rawPassword : $user->get( 'password' ) ) );
		$trigger->set( '_extras', $extras );
		$trigger->set( '_vars', $vars );

		if ( $user->get( 'id' ) ) {
			$gids			=	Application::User( (int) $user->get( 'id' ) )->getAuthorisedGroups( false );

			array_unshift( $gids, -3 );

			if ( Application::User( (int) $user->get( 'id' ) )->isGlobalModerator() ) {
				array_unshift( $gids, -5 );
			} else {
				array_unshift( $gids, -4 );
			}
		} else {
			$gids			=	$user->get( 'gids', array() );

			array_unshift( $gids, -2 );
		}

		if ( $user->get( 'id' ) == Application::MyUser()->getUserId() ) {
			array_unshift( $gids, -7 );
		} else {
			array_unshift( $gids, -6 );
		}

		array_unshift( $gids, -1 );

		$trigger->set( '_gids', $gids );

		$access				=	explode( '|*|', $trigger->get( 'access' ) );

		if ( ! array_intersect( $access, $gids ) ) {
			if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
				var_dump( CBTxt::T( 'AUTO_ACTION_ACCESS_FAILED', ':: Action [action] :: Access check for [user_id] failed: looking for [access] in [groups]', array( '[action]' => (int) $trigger->get( 'id' ), '[user_id]' => (int) $user->get( 'id' ), '[access]' => implode( ', ', $access ), '[groups]' => implode( ', ', $gids ) ) ) );
			}

			return null;
		}

		foreach ( $trigger->getConditions() as $i => $conditional ) {
			/** @var ParamsInterface $conditional */
			$condTranslate	=	$conditional->get( 'translate', 0, GetterInterface::BOOLEAN );
			$condField		=	$trigger->getSubstituteString( $conditional->get( 'field', null, GetterInterface::HTML ), true, $condTranslate );
			$condOperator	=	$conditional->get( 'operator', '0', GetterInterface::STRING );
			$condValue		=	$trigger->getSubstituteString( $conditional->get( 'value', null, GetterInterface::HTML ), true, $condTranslate );

			if ( ! cbautoactionsClass::getFieldMatch( $condField, $condOperator, $condValue, $vars ) ) {
				if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
					var_dump( CBTxt::T( 'AUTO_ACTION_CONDITIONAL_FAILED', ':: Action [action] :: Conditional [cond] failed for [user_id]: [field] [operator] [value]', array( '[action]' => (int) $trigger->get( 'id' ), '[cond]' => ( $i + 1 ), '[user_id]' => (int) $user->get( 'id' ), '[field]' => cbautoactionsClass::formatCondition( $condField ), '[operator]' => cbautoactionsClass::getOperatorTitle( $condOperator ), '[value]' => cbautoactionsClass::formatCondition( $condValue ) ) ) );
				}

				return null;
			}
		}

		$excludeGlobal		=	explode( ',', $this->params->get( 'exclude', null, GetterInterface::STRING ) );
		$excludeTrigger		=	explode( ',', $trigger->getParams()->get( 'exclude', null, GetterInterface::STRING ) );
		$exclude			=	array_filter( array_merge( $excludeGlobal, $excludeTrigger ) );

		if ( $exclude ) {
			cbArrayToInts( $exclude );

			$exclude		=	array_unique( $exclude );

			if ( in_array( (int) $user->get( 'id' ), $exclude ) ) {
				if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
					var_dump( CBTxt::T( 'AUTO_ACTION_USER_EXCLUDED', ':: Action [action] :: User [user_id] excluded', array( '[action]' => (int) $trigger->get( 'id' ), '[user_id]' => (int) $user->get( 'id' ) ) ) );
				}

				return null;
			}
		}

		return $trigger->call( 'execute', array( $user ) );
	}
コード例 #15
0
ファイル: pms.php プロジェクト: kosmosby/medicine-prof
	/**
	 * @param cbautoactionsActionTable $trigger
	 * @param UserTable $user
	 */
	public function execute( $trigger, $user )
	{
		global $_CB_PMS;

		foreach ( $trigger->getParams()->subTree( 'pms' ) as $row ) {
			/** @var ParamsInterface $row */
			$pmFrom			=	$row->get( 'form', null, GetterInterface::STRING );

			if ( ! $pmFrom ) {
				$pmFrom		=	(int) $user->get( 'id' );
			} else {
				$pmFrom		=	(int) $trigger->getSubstituteString( $pmFrom );
			}

			if ( ! $pmFrom ) {
				if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
					var_dump( CBTxt::T( 'AUTO_ACTION_PMS_NO_FROM', ':: Action [action] :: Private Message skipped due to missing from', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
				}

				continue;
			}

			$pmTo			=	$trigger->getSubstituteString( $row->get( 'to', null, GetterInterface::STRING ) );

			if ( ! $pmTo ) {
				if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
					var_dump( CBTxt::T( 'AUTO_ACTION_PMS_NO_TO', ':: Action [action] :: Private Message skipped due to missing to', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
				}

				continue;
			}

			$pmMessage		=	$trigger->getSubstituteString( $row->get( 'message', null, GetterInterface::RAW ), false );

			if ( ! $pmMessage ) {
				if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
					var_dump( CBTxt::T( 'AUTO_ACTION_PMS_NO_MSG', ':: Action [action] :: Private Message skipped due to missing message', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
				}

				continue;
			}

			$pmSubject		=	$trigger->getSubstituteString( $row->get( 'subject', null, GetterInterface::STRING ) );

			$_CB_PMS->sendPMSMSG( $pmTo, $pmFrom, $pmSubject, $pmMessage, true );
		}
	}
コード例 #16
0
	/**
	 * @param cbautoactionsActionTable $trigger
	 * @param UserTable $user
	 */
	public function execute( $trigger, $user )
	{
		global $_CB_framework, $_PLUGINS, $ueConfig;

		$params						=	$trigger->getParams()->subTree( 'registration' );

		$approve					=	(int) $params->get( 'approve', null, GetterInterface::INT );
		$confirm					=	(int) $params->get( 'confirm', null, GetterInterface::INT );
		$approval					=	( $approve == 2 ? $ueConfig['reg_admin_approval'] : $approve );
		$confirmation				=	( $confirm == 2 ? $ueConfig['reg_confirmation'] : $confirm );
		$usergroup					=	$params->get( 'usergroup', null, GetterInterface::STRING );
		$password					=	$trigger->getSubstituteString( $params->get( 'password', null, GetterInterface::STRING ) );
		$name						=	array();

		if ( ! $usergroup ) {
			$gids					=	array( $_CB_framework->getCfg( 'new_usertype' ) );
		} else {
			$gids					=	explode( '|*|', $usergroup );
		}

		cbArrayToInts( $gids );

		$newUser					=	new UserTable();

		$newUser->set( 'gids', $gids );
		$newUser->set( 'sendEmail', 0 );
		$newUser->set( 'registerDate', $_CB_framework->getUTCDate() );
		$newUser->set( 'username', $trigger->getSubstituteString( $params->get( 'username', null, GetterInterface::STRING ) ) );
		$newUser->set( 'firstname', $trigger->getSubstituteString( $params->get( 'firstname', null, GetterInterface::STRING ) ) );
		$newUser->set( 'middlename', $trigger->getSubstituteString( $params->get( 'middlename', null, GetterInterface::STRING ) ) );
		$newUser->set( 'lastname', $trigger->getSubstituteString( $params->get( 'lastname', null, GetterInterface::STRING ) ) );

		if ( $newUser->get( 'firstname' ) ) {
			$name[]					=	$newUser->get( 'firstname' );
		}

		if ( $newUser->get( 'middlename' ) ) {
			$name[]					=	$newUser->get( 'middlename' );
		}

		if ( $newUser->get( 'lastname' ) ) {
			$name[]					=	$newUser->get( 'lastname' );
		}

		$newUser->set( 'name', implode( ' ', $name ) );
		$newUser->set( 'email', $trigger->getSubstituteString( $params->get( 'email', null, GetterInterface::STRING ) ) );

		if ( $password ) {
			$newUser->set( 'password', $newUser->hashAndSaltPassword( $password ) );
		} else {
			$newUser->setRandomPassword();

			$newUser->set( 'password', $newUser->hashAndSaltPassword( $newUser->get( 'password' ) ) );
		}

		$newUser->set( 'registeripaddr', cbGetIPlist() );

		if ( $approval == 0 ) {
			$newUser->set( 'approved', 1 );
		} else {
			$newUser->set( 'approved', 0 );
		}

		if ( $confirmation == 0 ) {
			$newUser->set( 'confirmed', 1 );
		} else {
			$newUser->set( 'confirmed', 0 );
		}

		if ( ( $newUser->get( 'confirmed' ) == 1 ) && ( $newUser->get( 'approved' ) == 1 ) ) {
			$newUser->set( 'block', 0 );
		} else {
			$newUser->set( 'block', 1 );
		}

		foreach ( $params->subTree( 'fields' ) as $row ) {
			/** @var ParamsInterface $row */
			$field					=	$row->get( 'field', null, GetterInterface::STRING );

			if ( $field ) {
				$newUser->set( $field, $trigger->getSubstituteString( $row->get( 'value', null, GetterInterface::RAW ), false, $row->get( 'translate', false, GetterInterface::BOOLEAN ) ) );
			}
		}

		$_PLUGINS->trigger( 'onBeforeUserRegistration', array( &$newUser, &$newUser ) );

		if ( ! $newUser->store() ) {
			if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
				var_dump( CBTxt::T( 'AUTO_ACTION_REGISTRATION_FAILED', ':: Action [action] :: Registration failed to save. Error: [error]', array( '[action]' => (int) $trigger->get( 'id' ), '[error]' => $newUser->getError() ) ) );
			}

			return;
		}

		if ( ( $newUser->get( 'confirmed' ) == 0 ) && ( $confirmation != 0 ) ) {
			if ( ! $newUser->store() ) {
				if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
					var_dump( CBTxt::T( 'AUTO_ACTION_REGISTRATION_FAILED', ':: Action [action] :: Registration failed to save. Error: [error]', array( '[action]' => (int) $trigger->get( 'id' ), '[error]' => $newUser->getError() ) ) );
				}

				return;
			}
		}

		if ( $params->get( 'supress', 1, GetterInterface::BOOLEAN ) ) {
			$emails					=	false;
		} else {
			$emails					=	true;
		}

		activateUser( $newUser, 1, 'UserRegistration', $emails, $emails );

		$_PLUGINS->trigger( 'onAfterUserRegistration', array( &$newUser, &$newUser, true ) );
	}
コード例 #17
0
ファイル: gallery.php プロジェクト: kosmosby/medicine-prof
	/**
	 * @param cbautoactionsActionTable $trigger
	 * @param UserTable $user
	 * @return null|string
	 */
	public function execute( $trigger, $user )
	{
		global $_CB_database;

		if ( ! $this->installed() ) {
			if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
				var_dump( CBTxt::T( 'AUTO_ACTION_GALLERY_NOT_INSTALLED', ':: Action [action] :: CB Gallery is not installed', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
			}

			return null;
		}

		foreach ( $trigger->getParams()->subTree( 'gallery' ) as $row ) {
			/** @var ParamsInterface $row */
			$owner							=	$row->get( 'owner', null, GetterInterface::STRING );

			if ( ! $owner ) {
				$owner						=	(int) $user->get( 'id' );
			} else {
				$owner						=	(int) $trigger->getSubstituteString( $owner );
			}

			if ( ! $owner ) {
				if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
					var_dump( CBTxt::T( 'AUTO_ACTION_GALLERY_NO_OWNER', ':: Action [action] :: CB Gallery skipped due to missing owner', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
				}

				continue;
			}

			$mode							=	$row->get( 'mode', 'item', GetterInterface::STRING );
			$type							=	$row->get( 'type', 'photos', GetterInterface::STRING );
			$value							=	$trigger->getSubstituteString( $row->get( 'value', null, GetterInterface::STRING ) );
			$title							=	$trigger->getSubstituteString( $row->get( 'title', null, GetterInterface::STRING ) );
			$description					=	$trigger->getSubstituteString( $row->get( 'description', null, GetterInterface::STRING ) );

			switch ( $mode ) {
				case 'folder':
					$object					=	new cbgalleryFolderTable( $_CB_database );
					break;
				case 'item':
				default:
					$object					=	new cbgalleryItemTable( $_CB_database );
					break;
			}

			$object->set( 'user_id', $owner );

			if ( $type ) {
				$object->set( 'type', $type );
			}

			if ( $title ) {
				$object->set( 'title', $title );
			}

			if ( $description ) {
				$object->set( 'description', $description );
			}

			if ( $mode == 'item' ) {
				if ( ! $value ) {
					if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
						var_dump( CBTxt::T( 'AUTO_ACTION_GALLERY_NO_VALUE', ':: Action [action] :: CB Gallery skipped due to missing value', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
					}

					continue;
				}

				$object->set( 'value', $value );
			}

			if ( ! $object->store() ) {
				if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
					var_dump( CBTxt::T( 'AUTO_ACTION_GALLERY_FAILED', ':: Action [action] :: CB Gallery failed to save. Error: [error]', array( '[action]' => (int) $trigger->get( 'id' ), '[error]' => $object->getError() ) ) );
				}
			}
		}

		return null;
	}
コード例 #18
0
ファイル: blog.php プロジェクト: kosmosby/medicine-prof
	/**
	 * @param cbautoactionsActionTable $trigger
	 * @param UserTable $user
	 */
	public function execute( $trigger, $user )
	{
		if ( ! $this->installed() ) {
			if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
				var_dump( CBTxt::T( 'AUTO_ACTION_BLOGS_NOT_INSTALLED', ':: Action [action] :: CB Blogs is not installed', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
			}

			return;
		}

		foreach ( $trigger->getParams()->subTree( 'blog' ) as $row ) {
			/** @var ParamsInterface $row */
			$blog			=	new cbblogsBlogTable();

			$owner			=	$row->get( 'owner', null, GetterInterface::STRING );

			if ( ! $owner ) {
				$owner		=	(int) $user->get( 'id' );
			} else {
				$owner		=	(int) $trigger->getSubstituteString( $owner );
			}

			if ( ! $owner ) {
				if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
					var_dump( CBTxt::T( 'AUTO_ACTION_BLOGS_NO_OWNER', ':: Action [action] :: CB Blogs skipped due to missing owner', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
				}

				continue;
			}

			$blogData		=	array(	'user' => $owner,
										'title' => $trigger->getSubstituteString( $row->get( 'title', null, GetterInterface::STRING ) ),
										'blog_intro' => $trigger->getSubstituteString( $row->get( 'intro', null, GetterInterface::RAW ), false ),
										'blog_full' => $trigger->getSubstituteString( $row->get( 'full', null, GetterInterface::RAW ), false ),
										'category' => $row->get( 'category', null, GetterInterface::STRING ),
										'published' => (int) $row->get( 'published', 1, GetterInterface::INT ),
										'access' => (int) $row->get( 'access', 1, GetterInterface::INT )
									);

			if ( ! $blog->bind( $blogData ) ) {
				if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
					var_dump( CBTxt::T( 'AUTO_ACTION_BLOGS_BIND_FAILED', ':: Action [action] :: CB Blogs failed to bind. Error: [error]', array( '[action]' => (int) $trigger->get( 'id' ), '[error]' => $blog->getError() ) ) );
				}

				continue;
			}

			if ( ! $blog->store() ) {
				if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
					var_dump( CBTxt::T( 'AUTO_ACTION_BLOGS_FAILED', ':: Action [action] :: CB Blogs failed to save. Error: [error]', array( '[action]' => (int) $trigger->get( 'id' ), '[error]' => $blog->getError() ) ) );
				}
			}
		}
	}
コード例 #19
0
ファイル: antispam.php プロジェクト: kosmosby/medicine-prof
	/**
	 * @param cbautoactionsActionTable $trigger
	 * @param UserTable $user
	 */
	public function execute( $trigger, $user )
	{
		global $_CB_framework, $_CB_database;

		if ( ! $this->installed() ) {
			if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
				var_dump( CBTxt::T( 'AUTO_ACTION_ANTISPAM_NOT_INSTALLED', ':: Action [action] :: CB AntiSpam is not installed', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
			}

			return;
		}

		foreach ( $trigger->getParams()->subTree( 'antispam' ) as $row ) {
			/** @var ParamsInterface $row */
			$mode					=	$row->get( 'mode', 'block', GetterInterface::STRING );
			$type					=	$row->get( 'type', 'user', GetterInterface::STRING );
			$value					=	$row->get( 'value', null, GetterInterface::STRING );

			if ( ! $value ) {
				switch ( $type ) {
					case 'user':
						$value		=	(int) $user->get( 'id' );
						break;
					case 'ip':
						$value		=	$user->get( 'registeripaddr' );
						break;
					case 'email':
						$value		=	$user->get( 'email' );
						break;
					case 'domain':
						$email		=	explode( '@', $user->get( 'email' ) );

						if ( count( $email ) > 1 ) {
							$value	=	array_pop( $email );
						}
						break;
				}
			} else {
				$value				=	$trigger->getSubstituteString( $value );
			}

			if ( ! $value ) {
				if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
					var_dump( CBTxt::T( 'AUTO_ACTION_ANTISPAM_NO_VALUE', ':: Action [action] :: CB AntiSpam skipped due to missing value', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
				}

				continue;
			}

			if ( $mode == 'block' ) {
				$duration			=	$row->get( 'duration', '+1 MONTH', GetterInterface::STRING );

				if ( $duration == 'custom' ) {
					$duration		=	$trigger->getSubstituteString( $row->get( 'custom_duration', null, GetterInterface::STRING ) );
				}

				$entry				=	new cbantispamBlock( $_CB_database );

				$entry->set( 'date', $_CB_framework->getUTCDate() );
				$entry->set( 'duration', $duration );
			} else {
				$entry				=	new cbantispamWhitelist( $_CB_database );
			}

			$entry->set( 'type', $type );
			$entry->set( 'value', $value );
			$entry->set( 'reason', $trigger->getSubstituteString( $row->get( 'reason', null, GetterInterface::RAW ) ), false );

			if ( ! $entry->store() ) {
				if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
					var_dump( CBTxt::T( 'AUTO_ACTION_ANTISPAM_FAILED', ':: Action [action] :: CB AntiSpam failed to save. Error: [error]', array( '[action]' => (int) $trigger->get( 'id' ), '[error]' => $entry->getError() ) ) );
				}
			}
		}
	}
コード例 #20
0
ファイル: redirect.php プロジェクト: kosmosby/medicine-prof
	/**
	 * @param cbautoactionsActionTable $trigger
	 * @param UserTable $user
	 */
	public function execute( $trigger, $user )
	{
		global $_CB_framework;

		$params						=	$trigger->getParams()->subTree( 'redirect' );
		$redirect					=	$trigger->getSubstituteString( $params->get( 'url', null, GetterInterface::STRING ), array( 'cbautoactionsClass', 'escapeURL' ) );

		if ( ! $redirect ) {
			if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
				var_dump( CBTxt::T( 'AUTO_ACTION_REDIRECT_NO_URL', ':: Action [action] :: Redirect skipped due to missing url', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
			}

			return;
		}

		$message					=	$trigger->getSubstituteString( CBTxt::T( $params->get( 'message', null, GetterInterface::RAW ) ), false );
		$messageType				=	$params->get( 'type', 'message', GetterInterface::STRING );

		if ( $messageType == 'custom' ) {
			$messageType			=	$trigger->getSubstituteString( $params->get( 'custom_type', null, GetterInterface::STRING ) );
		}

		if ( substr( strtolower( $redirect ), 0, 6 ) == 'goback' ) {
			$back					=	(int) substr( strtolower( $redirect ), 6 );

			if ( $message ) {
				$_CB_framework->enqueueMessage( $message, ( $messageType ? $messageType : null ) );
			}

			$_CB_framework->document->addHeadScriptDeclaration( ( $back && ( $back > 0 ) ? "window.history.go( -$back );" : "window.history.back();" ) );
		} elseif ( strtolower( $redirect ) == 'reload' ) {
			if ( $message ) {
				$_CB_framework->enqueueMessage( $message, ( $messageType ? $messageType : null ) );
			}

			$_CB_framework->document->addHeadScriptDeclaration( "window.location.reload();" );
		} else {
			if ( strtolower( $redirect ) == 'return' ) {
				$isHttps			=	( isset( $_SERVER['HTTPS'] ) && ( ! empty( $_SERVER['HTTPS'] ) ) && ( $_SERVER['HTTPS'] != 'off' ) );
				$redirect			=	'http' . ( $isHttps ? 's' : '' ) . '://' . $_SERVER['HTTP_HOST'];

				if ( ( ! empty( $_SERVER['PHP_SELF'] ) ) && ( ! empty( $_SERVER['REQUEST_URI'] ) ) ) {
					$redirect		.=	$_SERVER['REQUEST_URI'];
				} else {
					$redirect		.=	$_SERVER['SCRIPT_NAME'];

					if ( isset( $_SERVER['QUERY_STRING'] ) && ( ! empty( $_SERVER['QUERY_STRING'] ) ) ) {
						$redirect	.=	'?' . $_SERVER['QUERY_STRING'];
					}
				}

				$redirect			=	cbUnHtmlspecialchars( preg_replace( '/[\\\"\\\'][\\s]*javascript:(.*)[\\\"\\\']/', '""', preg_replace( '/eval\((.*)\)/', '', htmlspecialchars( urldecode( $redirect ) ) ) ) );

				if ( preg_match( '/index.php\?option=com_comprofiler&task=confirm&confirmCode=|index.php\?option=com_comprofiler&view=confirm&confirmCode=|index.php\?option=com_comprofiler&task=login|index.php\?option=com_comprofiler&view=login/', $redirect ) ) {
					$redirect		=	'index.php';
				}
			}

			cbRedirect( $redirect, $message, ( $message ? ( $messageType ? $messageType : null ) : null ) );
		}
	}
コード例 #21
0
ファイル: request.php プロジェクト: kosmosby/medicine-prof
	/**
	 * @param cbautoactionsActionTable $trigger
	 * @param UserTable $user
	 * @return mixed
	 */
	public function execute( $trigger, $user )
	{
		$return								=	null;

		foreach ( $trigger->getParams()->subTree( 'request' ) as $row ) {
			/** @var ParamsInterface $row */
			$url							=	$trigger->getSubstituteString( $row->get( 'url', null, GetterInterface::STRING ), array( 'cbautoactionsClass', 'escapeURL' ) );

			if ( ! $url ) {
				if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
					var_dump( CBTxt::T( 'AUTO_ACTION_REQUEST_NO_URL', ':: Action [action] :: Request skipped due to missing url', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
				}

				continue;
			}

			$client							=	new GuzzleHttp\Client();

			try {
				$options					=	array();

				if ( $row->get( 'auth', 'none', GetterInterface::STRING ) == 'basic' ) {
					$username				=	$trigger->getSubstituteString( $row->get( 'auth_username', null, GetterInterface::STRING ) );
					$password				=	$trigger->getSubstituteString( $row->get( 'auth_password', null, GetterInterface::STRING ) );

					if ( $username && $password ) {
						$options['auth']	=	array( $username, $password );
					}
				}

				$body						=	array();

				foreach ( $row->subTree( 'request' ) as $request ) {
					/** @var ParamsInterface $request */
					$key					=	$request->get( 'key', null, GetterInterface::STRING );

					if ( $key ) {
						$body[$key]			=	$trigger->getSubstituteString( $request->get( 'value', null, GetterInterface::RAW ), false, $request->get( 'translate', false, GetterInterface::BOOLEAN ) );
					}
				}

				$headers					=	array();

				foreach ( $row->subTree( 'header' ) as $header ) {
					/** @var ParamsInterface $header */
					$key					=	$header->get( 'key', null, GetterInterface::STRING );

					if ( $key ) {
						$headers[$key]		=	$trigger->getSubstituteString( $header->get( 'value', null, GetterInterface::RAW ), false, $header->get( 'translate', false, GetterInterface::BOOLEAN ) );
					}
				}

				if ( $headers ) {
					$options['headers']		=	$headers;
				}

				if ( $row->get( 'method', 'GET', GetterInterface::STRING ) == 'POST' ) {
					if ( $body ) {
						$options['body']	=	$body;
					}

					$result					=	$client->post( $url, $options );
				} else {
					if ( $body ) {
						$options['query']	=	$body;
					}

					$result					=	$client->get( $url, $options );
				}

				if ( $result->getStatusCode() != 200 ) {
					if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
						var_dump( CBTxt::T( 'AUTO_ACTION_REQUEST_FAILED', ':: Action [action] :: Request failed. Error: [error]', array( '[action]' => (int) $trigger->get( 'id' ), '[error]' => $result->getStatusCode() ) ) );
						var_dump( $result );
					}

					$result					=	false;
				}
			} catch ( Exception $e ) {
				if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
					var_dump( CBTxt::T( 'AUTO_ACTION_REQUEST_FAILED', ':: Action [action] :: Request failed. Error: [error]', array( '[action]' => (int) $trigger->get( 'id' ), '[error]' => $e->getMessage() ) ) );
				}

				$result						=	false;
			}

			if ( $result !== false ) {
				switch( $result->getHeader( 'Content-Type' ) ) {
					case 'application/xml':
						$content			=	CBTxt::T( 'HTTP Request XML response handling is not yet implemented.' );
						break;
					case 'application/json':
						$content			=	$this->jsonResults( $result->json() );
						break;
					default:
						$content			=	$result->getBody();
						break;
				}

				switch ( $row->get( 'return', 'ECHO', GetterInterface::STRING ) ) {
					case 'ECHO':
						echo $content;
						break;
					case 'DUMP':
						var_dump( $content );
						break;
					case 'PRINT':
						print $content;
						break;
					case 'RETURN':
					default:
						$return				.=	$content;
						break;
				}
			}
		}

		return $return;
	}
コード例 #22
0
ファイル: content.php プロジェクト: kosmosby/medicine-prof
	/**
	 * @param cbautoactionsActionTable $trigger
	 * @param UserTable $user
	 */
	public function execute( $trigger, $user )
	{
		global $_CB_framework;

		foreach ( $trigger->getParams()->subTree( 'content' ) as $row ) {
			/** @var ParamsInterface $row */
			$mode					=	(int) $row->get( 'mode', 1, GetterInterface::INT );
			$title					=	$trigger->getSubstituteString( $row->get( 'title', null, GetterInterface::STRING ) );
			$alias					=	$row->get( 'alias', null, GetterInterface::STRING );

			if ( ! $alias ) {
				$alias				=	$title;
			} else {
				$alias				=	$trigger->getSubstituteString( $alias );
			}

			$alias					=	$this->cleanAlias( $alias );
			$introText				=	$trigger->getSubstituteString( $row->get( 'introtext', null, GetterInterface::RAW ), false );
			$fullText				=	$trigger->getSubstituteString( $row->get( 'fulltext', null, GetterInterface::RAW ), false );
			$metaDesc				=	$trigger->getSubstituteString( $row->get( 'metadesc', null, GetterInterface::RAW ), false );
			$metaKey				=	$trigger->getSubstituteString( $row->get( 'metakey', null, GetterInterface::RAW ), false );
			$access					=	(int) $row->get( 'access', 1, GetterInterface::INT );
			$published				=	(int) $row->get( 'published', 1, GetterInterface::INT );
			$featured				=	(int) $row->get( 'featured', 0, GetterInterface::INT );
			$language				=	$row->get( 'language', '*', GetterInterface::STRING );
			$owner					=	$row->get( 'owner', null, GetterInterface::STRING );

			if ( ! $owner ) {
				$owner				=	(int) $user->get( 'id' );
			} else {
				$owner				=	(int) $trigger->getSubstituteString( $owner );
			}

			if ( ! $owner ) {
				if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
					var_dump( CBTxt::T( 'AUTO_ACTION_CONTENT_NO_OWNER', ':: Action [action] :: Content skipped due to missing owner', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
				}

				continue;
			}

			if ( $mode == 1 ) {
				JTable::addIncludePath( $_CB_framework->getCfg( 'absolute_path' ) . '/administrator/components/com_content/tables' );

				$category			=	(int) $row->get( 'category_j', null, GetterInterface::INT );
				$table				=	JTable::getInstance( 'content' );

				while ( $table->load( array( 'alias' => $alias, 'catid' => $category ) ) ) {
					$matches		=	null;

					if ( preg_match( '#-(\d+)$#', $alias, $matches ) ) {
						$alias		=	preg_replace( '#-(\d+)$#', '-' . ( $matches[1] + 1 ) . '', $alias );
					} else {
						$alias		.=	'-2';
					}
				}

				/** @var JTableContent $article */
				$article			=	JTable::getInstance( 'content' );

				$article->set( 'created_by', $owner );
				$article->set( 'title', $title );
				$article->set( 'alias', $alias );
				$article->set( 'introtext', $introText );
				$article->set( 'fulltext', $fullText );
				$article->set( 'metadesc', $metaDesc );
				$article->set( 'metakey', $metaKey );
				$article->set( 'catid', $category );
				$article->set( 'access', $access );
				$article->set( 'state', $published );
				$article->set( 'featured', $featured );
				$article->set( 'ordering', 1 );
				$article->set( 'created', $_CB_framework->getUTCDate() );
				$article->set( 'language', $language );

				$article->set( 'images', '{"image_intro":"","float_intro":"","image_intro_alt":"","image_intro_caption":"","image_fulltext":"","float_fulltext":"","image_fulltext_alt":"","image_fulltext_caption":""}' );
				$article->set( 'urls', '{"urla":null,"urlatext":"","targeta":"","urlb":null,"urlbtext":"","targetb":"","urlc":null,"urlctext":"","targetc":""}' );
				$article->set( 'attribs', '{"show_title":"","link_titles":"","show_tags":"","show_intro":"","info_block_position":"","show_category":"","link_category":"","show_parent_category":"","link_parent_category":"","show_author":"","link_author":"","show_create_date":"","show_modify_date":"","show_publish_date":"","show_item_navigation":"","show_icons":"","show_print_icon":"","show_email_icon":"","show_vote":"","show_hits":"","show_noauth":"","urls_position":"","alternative_readmore":"","article_layout":"","show_publishing_options":"","show_article_options":"","show_urls_images_backend":"","show_urls_images_frontend":""}' );
				$article->set( 'metadata', '{"robots":"","author":"","rights":"","xreference":"","tags":""}' );

				if ( ! $article->store() ) {
					if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
						var_dump( CBTxt::T( 'AUTO_ACTION_CONTENT_FAILED', ':: Action [action] :: Content failed to save', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
					}

					continue;
				}

				$article->reorder( '`catid` = ' . $category );

				if ( $article->get( 'featured' ) ) {
					$feature	=	JTable::getInstance( 'Featured', 'ContentTable' );

					$feature->set( 'content_id', (int) $article->get( 'id' ) );
					$feature->set( 'ordering', 0 );

					if ( $feature->store() ) {
						$feature->reorder();
					}
				}
			} elseif ( ( $mode == 2 ) && $this->isK2Installed() ) {
				$category			=	(int) $row->get( 'category_k', null, GetterInterface::INT );

				/** @var TableK2Item $article */
				$article			=	JTable::getInstance( 'K2Item', 'Table' );

				$article->set( 'created_by', $owner );
				$article->set( 'title', $title );
				$article->set( 'alias', $alias );
				$article->set( 'introtext', $introText );
				$article->set( 'fulltext', $fullText );
				$article->set( 'metadesc', $metaDesc );
				$article->set( 'metakey', $metaKey );
				$article->set( 'catid', $category );
				$article->set( 'access', $access );
				$article->set( 'published', $published );
				$article->set( 'featured', $featured );
				$article->set( 'ordering', 1 );
				$article->set( 'created', $_CB_framework->getUTCDate() );
				$article->set( 'language', $language );

				if ( ! $article->store() ) {
					if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
						var_dump( CBTxt::T( 'AUTO_ACTION_CONTENT_FAILED', ':: Action [action] :: Content failed to save', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
					}

					continue;
				}

				$article->reorder( '`catid` = ' . $category );
			}
		}
	}
コード例 #23
0
ファイル: field.php プロジェクト: kosmosby/medicine-prof
	/**
	 * @param cbautoactionsActionTable $trigger
	 * @param UserTable $user
	 */
	public function execute( $trigger, $user )
	{
		global $_CB_database;

		if ( ! $user->get( 'id' ) ) {
			if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
				var_dump( CBTxt::T( 'AUTO_ACTION_FIELD_NO_USER', ':: Action [action] :: Field skipped due to no user', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
			}

			return;
		}

		foreach ( $trigger->getParams()->subTree( 'field' ) as $row ) {
			/** @var ParamsInterface $row */
			$fieldId				=	$row->get( 'field', null, GetterInterface::INT );

			if ( ! $fieldId ) {
				if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
					var_dump( CBTxt::T( 'AUTO_ACTION_FIELD_NO_FIELD', ':: Action [action] :: Field skipped due to missing field', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
				}

				continue;
			}

			/** @var FieldTable[] $fields */
			static $fields			=	array();

			if ( ! isset( $fields[$fieldId] ) ) {
				$field				=	new FieldTable();

				$field->load( (int) $fieldId );

				$fields[$fieldId]	=	$field;
			}

			if ( ! $fields[$fieldId] ) {
				if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
					var_dump( CBTxt::T( 'AUTO_ACTION_FIELD_DOES_NOT_EXIST', ':: Action [action] :: Field skipped due to field [field_id] does not exist', array( '[action]' => (int) $trigger->get( 'id' ), '[field_id]' => (int) $fieldId ) ) );
				}

				continue;
			}

			$operator				=	$row->get( 'operator', 'set', GetterInterface::STRING );
			$value					=	$trigger->getSubstituteString( $row->get( 'value', null, GetterInterface::RAW ), false, $row->get( 'translate', false, GetterInterface::BOOLEAN ) );
			$fieldName				=	$fields[$fieldId]->get( 'name' );
			$fieldColumn			=	$_CB_database->NameQuote( $fieldName );

			if ( ( ! in_array( $fields[$fieldId]->get( 'type' ), array( 'integer', 'counter' ) ) ) && in_array( $operator, array( 'add', 'subtract', 'divide', 'multiply' ) ) ) {
				$operator			=	'set';
			}

			switch ( $operator ) {
				case 'prefix':
					$fieldValue		=	( $value . $user->get( $fieldName ) );
					break;
				case 'suffix':
					$fieldValue		=	( $user->get( $fieldName ) . $value );
					break;
				case 'add':
					$fieldValue		=	( (int) $user->get( $fieldName ) + (int) $value );
					break;
				case 'subtract':
					$fieldValue		=	( (int) $user->get( $fieldName ) - (int) $value );
					break;
				case 'divide':
					$fieldValue		=	( (int) $user->get( $fieldName ) / (int) $value );
					break;
				case 'multiply':
					$fieldValue		=	( (int) $user->get( $fieldName ) * (int) $value );
					break;
				case 'set':
				default:
					$fieldValue		=	$value;
					break;
			}

			$query					=	'UPDATE ' . $_CB_database->NameQuote( $fields[$fieldId]->get( 'table' ) )
									.	"\n SET " . $fieldColumn . " = " . $_CB_database->Quote( $fieldValue )
									.	"\n WHERE " . $_CB_database->NameQuote( 'id' ) . " = " . (int) $user->get( 'id' );
			$_CB_database->setQuery( $query );
			$_CB_database->query();

			$user->set( $fieldName, $fieldValue );
		}
	}
コード例 #24
0
ファイル: connection.php プロジェクト: kosmosby/medicine-prof
	/**
	 * @param cbautoactionsActionTable $trigger
	 * @param UserTable $user
	 */
	public function execute( $trigger, $user )
	{
		global $ueConfig;

		if ( ! $user->get( 'id' ) ) {
			if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
				var_dump( CBTxt::T( 'AUTO_ACTION_CONNECTION_NO_USER', ':: Action [action] :: Connection skipped due to no user', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
			}

			return;
		}

		foreach ( $trigger->getParams()->subTree( 'connection' ) as $row ) {
			/** @var ParamsInterface $row */
			$users										=	$trigger->getSubstituteString( $row->get( 'users', null, GetterInterface::STRING ) );

			if ( $users ) {
				$users									=	explode( ',', $users );

				cbArrayToInts( $users );

				$message								=	$trigger->getSubstituteString( $row->get( 'message', null, GetterInterface::RAW ), false );
				$mutual									=	$row->get( 'mutual', 2, GetterInterface::INT );
				$cross									=	$row->get( 'cross', 1, GetterInterface::INT );
				$notify									=	$row->get( 'notify', 0, GetterInterface::BOOLEAN );

				if ( $mutual ) {
					$oldMutual							=	$ueConfig['useMutualConnections'];
					$ueConfig['useMutualConnections']	=	( $mutual == 1 ? '1' : '0' );
				}

				if ( $cross ) {
					$oldCross							=	$ueConfig['autoAddConnections'];
					$ueConfig['autoAddConnections']		=	( $cross == 1 ? '1' : '0' );
				}

				if ( $row->get( 'direction', 0, GetterInterface::BOOLEAN ) ) {
					foreach ( $users as $userId ) {
						if ( $userId != $user->get( 'id' ) ) {
							$connections				=	new cbConnection( $userId );

							if ( ! $connections->getConnectionDetails( $userId, $user->get( 'id' ) ) ) {
								$connections->addConnection( $user->get( 'id' ), $message, $notify );
							}
						}
					}
				} else {
					$connections						=	new cbConnection( $user->get( 'id' ) );

					foreach ( $users as $userId ) {
						if ( $userId != $user->get( 'id' ) ) {
							if (  ! $connections->getConnectionDetails( $user->get( 'id' ), $userId ) ) {
								$connections->addConnection( $userId, $message, $notify );
							}
						}
					}
				}

				if ( $mutual ) {
					$ueConfig['useMutualConnections']	=	$oldMutual;
				}

				if ( $cross ) {
					$ueConfig['autoAddConnections']		=	$oldCross;
				}
			}
		}
	}
コード例 #25
0
ファイル: query.php プロジェクト: kosmosby/medicine-prof
	/**
	 * @param cbautoactionsActionTable $trigger
	 * @param UserTable $user
	 */
	public function execute( $trigger, $user )
	{
		global $_CB_framework, $_CB_database;

		foreach ( $trigger->getParams()->subTree( 'query' ) as $row ) {
			/** @var ParamsInterface $row */
			if ( $row->get( 'mode', 0, GetterInterface::BOOLEAN ) ) {
				$host					=	$row->get( 'host', null, GetterInterface::STRING );

				if ( ! $host ) {
					if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
						var_dump( CBTxt::T( 'AUTO_ACTION_QUERY_NO_HOST', ':: Action [action] :: Query skipped due to missing host', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
					}

					continue;
				}

				$username				=	$row->get( 'username', null, GetterInterface::STRING );

				if ( ! $username ) {
					if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
						var_dump( CBTxt::T( 'AUTO_ACTION_QUERY_NO_USERNAME', ':: Action [action] :: Query skipped due to missing username', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
					}

					continue;
				}

				$password				=	$row->get( 'password', null, GetterInterface::STRING );

				if ( ! $password ) {
					if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
						var_dump( CBTxt::T( 'AUTO_ACTION_QUERY_NO_PSWD', ':: Action [action] :: Query skipped due to missing password', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
					}

					continue;
				}

				$database				=	$row->get( 'database', null, GetterInterface::STRING );

				if ( ! $database ) {
					if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
						var_dump( CBTxt::T( 'AUTO_ACTION_QUERY_NO_DB', ':: Action [action] :: Query skipped due to missing database', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
					}

					continue;
				}

				$charset				=	$row->get( 'charset', null, GetterInterface::STRING );
				$prefix					=	$row->get( 'prefix', null, GetterInterface::STRING );

				if ( ! $prefix ) {
					$prefix				=	$_CB_framework->getCfg( 'dbprefix' );
				}

				$driver					=	$_CB_framework->getCfg( 'dbtype' );
				$options				=	array ( 'driver' => $driver, 'host' => $host, 'user' => $username, 'password' => $password, 'database' => $database, 'prefix' => $prefix );

				if ( is_callable( array( 'JDatabaseDriver', 'getInstance' ) ) ) {
					try {
						$_J_database	=&	JDatabaseDriver::getInstance( $options );
					} catch ( RuntimeException $e ) {
						if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
							var_dump( CBTxt::T( 'AUTO_ACTION_QUERY_EXT_DB_FAILED', ':: Action [action] :: Query external database failed. Error: [error]', array( '[action]' => (int) $trigger->get( 'id' ), '[error]' => $e->getMessage() ) ) );
						}

						continue;
					}
				} else {
					try {
						$_J_database	=&	JDatabase::getInstance( $options );
					} catch ( RuntimeException $e ) {
						if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
							var_dump( CBTxt::T( 'AUTO_ACTION_QUERY_EXT_DB_FAILED', ':: Action [action] :: Query external database failed. Error: [error]', array( '[action]' => (int) $trigger->get( 'id' ), '[error]' => $e->getMessage() ) ) );
						}

						continue;
					}
				}

				$_SQL_database			=	new CmsDatabaseDriver( $_J_database, $prefix, checkJversion( 'release' ) );

				if ( $charset ) {
					$_SQL_database->setQuery( 'SET NAMES ' . $_SQL_database->Quote( $charset ) );
					$_SQL_database->query();
				}
			} else {
				$_SQL_database			=	$_CB_database;
			}

			if ( $_SQL_database ) {
				$queries				=	preg_split( '/(;\s*[\r\n])/', trim( $trigger->getSubstituteString( $row->get( 'sql', null, GetterInterface::RAW ), array( 'cbautoactionsClass', 'escapeSQL' ) ) ) );

				if ( $queries ) foreach ( $queries as $query ) {
					if ( $query ) {
						$_SQL_database->setQuery( $query );
						$_SQL_database->query();
					}
				}
			}
		}
	}
コード例 #26
0
ファイル: cbsubs.php プロジェクト: kosmosby/medicine-prof
	/**
	 * @param cbautoactionsActionTable $trigger
	 * @param UserTable $user
	 */
	public function execute( $trigger, $user )
	{
		global $_CB_framework;

		if ( ( ! $user->get( 'id' ) ) || ( ! $this->installed() ) ) {
			if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
				var_dump( CBTxt::T( 'AUTO_ACTION_CBSUBS_NOT_INSTALLED', ':: Action [action] :: CB Paid Subscriptions is not installed', array( '[action]' => (int) $trigger->get( 'id' ) ) ) );
			}

			return;
		}

		foreach ( $trigger->getParams()->subTree( 'cbsubs' ) as $row ) {
			/** @var ParamsInterface $row */
			$plans										=	$row->get( 'plans' );

			if ( $plans ) {
				$plans									=	explode( '|*|', $plans );

				cbArrayToInts( $plans );

				$mode									=	$row->get( 'mode', 1, GetterInterface::INT );
				$subscriptions							=	cbpaidSomethingMgr::getAllSomethingOfUser( $user, null );
				$activePlans							=	array();

				if ( $subscriptions ) foreach ( $subscriptions as $type ) {
					foreach ( array_keys( $type ) as $typeId ) {
						/** @var cbpaidSomething $subscription */
						$subscription					=	$type[$typeId];
						$subscriptionId					=	(int) $subscription->get( 'id' );
						$subscriptionStatus				=	$subscription->get( 'status' );
						$planId							=	(int) $subscription->get( 'plan_id' );

						if ( in_array( $planId, $plans ) ) {
							switch ( $mode ) {
								case 2:
									if ( $subscriptionStatus != 'A' ) {
										$subscription->activate( $user, $_CB_framework->now(), true, 'R' );
									}
									break;
								case 3:
									if ( $subscriptionStatus == 'A' ) {
										cbpaidControllerOrder::doUnsubscribeConfirm( $user, null, $planId, $subscriptionId );
									}
									break;
								case 4:
									if ( $subscription->canDelete() ) {
										$subscription->revert( $user, 'Denied' );
										$subscription->delete();
									}
									break;
								case 1:
								default:
									if ( ( $subscriptionStatus == 'A' ) && ( ! in_array( $planId, $activePlans ) ) ) {
										$activePlans[]	=	$planId;
									}
									break;
							}
						}
					}
				}

				if ( $mode == 1 ) {
					$plansMgr							=	cbpaidPlansMgr::getInstance();
					$postData							=	array();
					$chosenPlans						=	array();

					foreach ( $plans as $planId ) {
						if ( ! in_array( $planId, $activePlans ) ) {
							$chosenPlans[$planId]		=	$plansMgr->loadPlan( $planId );
						}
					}

					if ( $chosenPlans ) {
						cbpaidControllerOrder::createSubscriptionsAndPayment( $user, $chosenPlans, $postData, null, null, 'A', null, 'U', 'free' );
					}
				}
			}
		}
	}